Open thkim1011 opened 1 year ago
Any progress here? also get this with create-react-app
project. The error:
Compiled with problems:
ERROR in ./node_modules/@USER-NAME/any-package/src/index.tsx 12:2
Module parse failed: Unexpected token (12:2)
File was processed with these loaders:
* ./node_modules/source-map-loader/dist/cjs.js
You may need an additional loader to handle the result of these loaders.
|
| export default (
> <Provider data={data}>
| <App />
| </Provider>
@eschneor oh I ended up doing a lot of research into this, and I think create-react-app
just isn't the right build tool (?) for this purpose. It doesn't provide an easy way to override the given webpack configurations which is what's necessary for supporting importing an outside typescript package.
For my use case, I ended up using next.js which provides an experimental externalDir
flag (see here). But haven't looked into this any further. I hope this is somewhat helpful.
@thkim1011 try this one, just add the workspace in the dangerouslyAddModulePathsToTranspile
https://github.com/akveo/react-native-ui-kitten/issues/996#issuecomment-616115469
Describe the bug
When using importing objects/types from another node package in a yarn workspace, the compiler throws an error. I've set up minimum example that causes this issue below, which I've also uploaded to a git repo. So far this seems to only happen when I try to import enums but I think there's something under the hood that's not set up properly, and there isn't very good documentation about how to debug this error.
Did you try recovering your dependencies?
Yes.
Which terms did you search for in User Guide?
I searched for 'Module parse failed'.
Environment
Steps to reproduce
yarn-workspace-bug
directory with the typescript template.workspace-a
as a dependency of the newly created React app.App.tsx
file with the following.function App() { return (
); }
export default App;
Failed to compile.
Module parse failed: Unexpected token (3:7) File was processed with these loaders:
webpack compiled with 1 error
nvm use cd workspace-b yarn start