Skip to content
This repository has been archived by the owner on Jan 22, 2018. It is now read-only.

error when minifying code #3

Closed
gabririgo opened this issue Oct 9, 2017 · 8 comments
Closed

error when minifying code #3

gabririgo opened this issue Oct 9, 2017 · 8 comments

Comments

@gabririgo
Copy link

react gives me this error:

Failed to minify the code from this file:

./node_modules/@parity/api/format/output.js:19 

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

From the link:

npm run build fails to minify

You may occasionally find a package you depend on needs compiled or ships code for a non-browser environment.
This is considered poor practice in the ecosystem and does not have an escape hatch in Create React App.

To resolve this:

Open an issue on the dependency's issue tracker and ask that the package be published pre-compiled (retaining ES6 Modules).
Fork the package and publish a corrected version yourself.
If the dependency is small enough, copy it to your src/ folder and treat it as application code.

@jacogr
Copy link
Contributor

jacogr commented Oct 10, 2017

We are using from this repo in a React/Webpack environment without issues, along with Uglify.

Could you post the full failure log? (Line 19 is a require from another package, so not 100% sure where/why, would need to investigate and see how we can squash it)

@gabririgo
Copy link
Author

gabririgo commented Oct 10, 2017

sure will do and come back, using parity/parity.js and using transport instead of provider it does not give any error

@jacogr
Copy link
Contributor

jacogr commented Oct 10, 2017

Will also create a scaled-down version using react-create-app - should help in debugging the issue.

@jacogr
Copy link
Contributor

jacogr commented Oct 10, 2017

Ok, can reproduce -

test-js-api$ npm run build                          

> test-js-api@0.1.0 build /Users/jacogreeff/Projects/ethcore/test-js-api
> react-scripts build

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

Failed to minify the code from this file: 

 	./node_modules/@parity/api/format/output.js:19 

@gabririgo
Copy link
Author

yes that is the error prompted when using using yarn build in react-create-app!

@jacogr
Copy link
Contributor

jacogr commented Oct 11, 2017

Ok, this is due to react-create-app not operating on node_modules and has no real way of overriding this. Although the target browsers, those supporting fetch (& node) supports arrow functions and const { xyz } = abc deconstructions, the build does not since it is looking for a lower common.

facebook/create-react-app#1125

As per the above, we are not the only ones with this slight issue. Leaving it open to try and find a solution that does not involve re-wiring everything pre arrow-functions and deconstruction and also does not require bringing back the pre-compilation step.

@jacogr
Copy link
Contributor

jacogr commented Nov 2, 2017

@parity/api version 2.1.1+ should solve the issue, the explicit ES5 version is now published to npm.

@jacogr jacogr closed this as completed Nov 2, 2017
@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.

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

No branches or pull requests

3 participants