Skip to content
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

Build fails when included in create-react-app #86

Closed
dan1elhughes opened this issue Jan 31, 2018 · 10 comments
Closed

Build fails when included in create-react-app #86

dan1elhughes opened this issue Jan 31, 2018 · 10 comments
Labels

Comments

@dan1elhughes
Copy link

> npm run build

> <redacted>@0.1.0 build X:\github\<redacted>
> react-scripts build

Creating an optimized production build...
Failed to compile.

Failed to minify the code from this file:

        ./node_modules/superstruct/lib/index.es.js:7

Read more here: http://bit.ly/2tRViJ9

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! ethereum-pos@0.1.0 build: `react-scripts build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the ethereum-pos@0.1.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\<redacted>

Looking at the link printed above, it looks like create-react-app expects the node modules to be compiled ES5. Is there a way around this?

@ianstormtaylor
Copy link
Owner

ianstormtaylor commented Jan 31, 2018

@dan1elhughes why is it getting the lib/index.es.js file (which is package.module) instead of the lib/index.js file (which is package.main), do you know? There are two entry points, one is for CJS and one for ES modules.

Edit: seems like that might not be it, but there's no real information in create-react-app's error message, so it's hard to know why it's failing.

@dan1elhughes
Copy link
Author

dan1elhughes commented Feb 12, 2018

Is it possible to publish lib/index.js pre-compiled to ES5, as part of the build process? Even when I manually require that file, it's specifically failing on Class StructError extends TypeError {

@ianstormtaylor
Copy link
Owner

Why is ES5 required? It should be the latest-ish ES* spec instead I'd think. Or rather, create-react-app shouldn't be failing when importing files that contain class declarations, since those are supported by every major browser already? It should compile them down if needed instead?

@dan1elhughes
Copy link
Author

I've done some searching around and I'm struggling to figure out quite what's causing this. I've got a workaround for now, but it's not pretty..

@jsleeuw
Copy link

jsleeuw commented Mar 8, 2018

I got around this with react-app-rewire-babel-loader.

@dan1elhughes
Copy link
Author

@jsleeuw That looks useful, thanks!
@ianstormtaylor I don't think Create React App is going to work out of the box with this unless it's ES5, as babel-compiling all of node modules would be very computationally heavy. I'm happy to investigate putting a build process in place to publish this as ES5, if that's a direction you're willing to go?

@ianstormtaylor
Copy link
Owner

I think the newer versions of create react app do babelize all node modules?

I’d be open to that PR. I’d just like to figure out what the root cause is before changing anything first.

@dan1elhughes
Copy link
Author

Ah yes, looks like that is indeed the case in facebook/create-react-app#1125 . I'll update my project to latest CRA and see if that changes anything

@dan1elhughes
Copy link
Author

Nope, turns out that feature is in the 2.x alpha versions, not the recently released 1.1.1 version. I'll look at creating that PR.

@dan1elhughes
Copy link
Author

I'm no longer using this library so I'm going to close this issue. If this bug still exists, I'm sure it'll reappear in another issue as needed :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants