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

Fails to build on create-react-app: Publish ES5 to NPM #4

Closed
glcheetham opened this issue Nov 22, 2017 · 6 comments
Closed

Fails to build on create-react-app: Publish ES5 to NPM #4

glcheetham opened this issue Nov 22, 2017 · 6 comments
Labels

Comments

@glcheetham
Copy link

When building a project using merge-options on create-react-app, react-scripts build will give the following error:

> react-scripts build

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

Failed to minify the code from this file:

 	./node_modules/merge-options/index.js:11

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

This link to the create-react-app documentation explains the problem in more detail:

Some third-party packages don't compile their code to ES5 before publishing to npm. This often causes problems in the ecosystem because neither browsers (except for most modern versions) nor some tools currently support all ES6 features. We recommend to publish code on npm as ES5 at least for a few more years.

@glcheetham
Copy link
Author

See my PR #5

@kisenka
Copy link

kisenka commented Dec 1, 2017

@schnittstabil could you please take a look at #5. I am really need it.

@glcheetham
Copy link
Author

@kisenka you can use my fork instead https://www.npmjs.com/package/merge-options-es5

npm i merge-options-es5

@schnittstabil
Copy link
Owner

schnittstabil commented Dec 10, 2017

Sorry, I target node.js, if users want to use my modules in legacy browsers, it's up to them to transpile them. More importantly, those users know better which features they have to transpile than I do.

Btw, create-react-app extensively uses ES6+ features via Babel/Webpack, but is still unable to deal with (mature) ES6 features in dependencies. Trying to put the blame on maintainers of node.js packages is quite bizarre in my opinion.

Anyway, @glcheetham thanks for publishing your fork at npm. See also facebook/create-react-app#1125 for more workarounds.

@gaearon
Copy link

gaearon commented Jan 13, 2018

FYI, we're starting the work to compile deps with babel-preset-env in Create React App: facebook/create-react-app#3776

Let us know if you have feedback about how this should work.

@robatron
Copy link

@kisenka , @glcheetham , it's a bit hacky, but we just run an inline babel build on merge-options in our postinstall script:

package.json

"postinstall": 
  "babel node_modules/merge-options/index.js -o node_modules/merge-options/index.js"

.babelrc

{
  "presets": ["env"]
}

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

5 participants