DEV Community

Discussion on: How to Create a React Typescript Monorepo with Git Submodules

Collapse
 
rejetto profile image
Massimo Melina

thanks for sharing!
I made a little experiment that didn't go well:
in simple-shared-data/index.ts
I added:

export const fun1 = () => console.log("I'm fun1")
Enter fullscreen mode Exit fullscreen mode

Then I imported it in App.tsx, like this:

import { QueryPayload, fun1 } from "@my-namespace/simple-shared-data";
Enter fullscreen mode Exit fullscreen mode

But as soon as I try to use it, like this:

onClick={() => { 
  fun1(); 
  fetch("http://localhost:3001/", {})
Enter fullscreen mode Exit fullscreen mode

Then it goes crazy😡

ERROR in ../simple-shared-data/index.ts 3:7
Module parse failed: Unexpected token (3:7)
File was processed with these loaders:
 * ../../node_modules/@pmmmwh/react-refresh-webpack-plugin/loader/index.js
 * ../../node_modules/source-map-loader/dist/cjs.js
You may need an additional loader to handle the result of these loaders.
| __webpack_require__.$Refresh$.runtime = require('C:/temp/monorepo-example/node_modules/react-refresh/runtime.js');
|
> export interface QueryPayload {
|   payload: string;
| }
 @ ./src/App.tsx 8:0-56 48:10-14
 @ ./src/index.tsx 7:0-24 11:33-36
webpack 5.65.0 compiled with 1 error in 223 ms
Enter fullscreen mode Exit fullscreen mode

are we doomed to export just types? 🀒
any help?😭