-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
React Scripts 2.0.3 babel-loader fails to build imported local ES6 module #5318
Comments
Your packages must be build and you need to import those copies. We're hoping to make this more ergonomic going forward (this didn't work in v1, either). Please see linked issue for proposal. duplicate of #5161 |
@Timer thanks for the update on this. Just to be clear for my understanding, if I want to be able to import/export an external (local or otherwise) ES6 package into my CRA2 package, I would have to either:
|
I am currently using approach #1 for my own setup and its working out ok but there can be hiccups (#1333 (comment)). you may be able to rewire the configs without ejecting using react-app-rewired or some other package (eg https://www.npmjs.com/package/react-app-rewire-yarn-workspaces) |
@bugzpodder Would you be able to provide a little more information on your setup? I've transpiled my "common" library (correctly, i believe), but when i try to import the output I'm still getting "Failed to compile, cannot resolve module 'common'. I'm not sure what I'm missing. Thanks in advance!! |
Maybe it would help if you provided something so I can take a look? |
@bugzpodder Thank so much for the reply. This is the current setup I have: common's webpack config:
I currently just have src/index.js with a very simple component i'm trying to export and then import into admin.
The Error I'm getting now is "Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports." |
Hello @cleverettgirl did you set up yarn workspaces? You'd setup yarn workspaces with two workspaces, one for cra admin app, the other for your simple component. Then you can do an import from your cra app. |
@bugzpodder Yup! in my root package.json I have
|
@cleverettgirl see https://github.com/bugzpodder/yarn-workspace-cra |
@bugzpodder wow, thank you so much!!! |
Is this a bug report?
Not sure.
Did you try recovering your dependencies?
Yes.
Which terms did you search for in User Guide?
react-scripts, babel-loader
Environment
Steps to Reproduce
react-scripts start
and it should produce an errorExpected Behavior
The
babel-loader
instance within my CRA2 module should be able to transpile + remove Flow types from the imported ES6 module.Actual Behavior
babel-loader
fails with a SyntaxError according to the browser console output.WebStorm gave a slightly different output:
Reproducible Demo
N/A
The text was updated successfully, but these errors were encountered: