I have made a typescript monorepo here with the following folder structure:
.
└── packages
├── package.json // Housing the monorepo workspace
├── web-app // Housing the NextJS website
└── web-core // Housing the redux business logic
Whenever I run yarn dev
inside the root or inside the web-app
, I get the following parsing error:
error - ../web-core/index.ts
Module parse failed: Unexpected token (3:7)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
| export * from "./counter";
| export { default as MyProvider } from "./provider";
> export type { RootState } from "./store";
|
I know this is some webpack or babel issue insider web-core
but I would need some guidance as to how can I solve this. Please help. Thanks!
CodePudding user response:
Can you try removing type
from export type { RootState } from "./store";
?
CodePudding user response:
I found the solution to it. I am using a monorepo approach with NextJS in web-app
and Redux in web-core
. To consume the web-core
inside the web-app
, I need to first build it the web-core
. Adding it to the package.json
of web-app
isn't enough. Since I am not planning to publish web-core
as a separate npm package, I just need to build it.
To build it, I added the next-transpile-modules
as a dev dependency to web-app
and added the code in next.config.js
:
...
const withTM = require("next-transpile-modules")(["@issue/web-core"]);
module.exports = withTM(nextConfig);