mirror of
https://github.com/zhigang1992/create-react-app.git
synced 2026-05-18 04:24:19 +08:00
Update minify instructions (#5105)
* changed to Migrate to v2.x * richer explanation * Update README.md
This commit is contained in:
committed by
Joe Haddad
parent
54323f07dc
commit
cbf532073e
@@ -2406,20 +2406,9 @@ This will only work for locales that have been explicitly imported before.
|
||||
|
||||
### `npm run build` fails to minify
|
||||
|
||||
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.
|
||||
Starting in Create React App v2, we now compile all ES.Next features found in `node_modules`. This means you can consume packages and not worry about them being syntax-incompatible with any browser.
|
||||
|
||||
<br>
|
||||
To resolve this:
|
||||
|
||||
1. Open an issue on the dependency's issue tracker and ask that the package be published pre-compiled.
|
||||
|
||||
- Note: Create React App can consume both CommonJS and ES modules. For Node.js compatibility, it is recommended that the main entry point is CommonJS. However, they can optionally provide an ES module entry point with the `module` field in `package.json`. Note that **even if a library provides an ES Modules version, it should still precompile other ES6 features to ES5 if it intends to support older browsers**.
|
||||
|
||||
2. Fork the package and publish a corrected version yourself.
|
||||
|
||||
3. If the dependency is small enough, copy it to your `src/` folder and treat it as application code.
|
||||
|
||||
In the future, we might start automatically compiling incompatible third-party modules, but it is not currently supported. This approach would also slow down the production builds.
|
||||
If you're seeing this error, you're likely using an old version of `react-scripts` and need to upgrade to `react-scripts@>=2.0.0`.
|
||||
|
||||
## Alternatives to Ejecting
|
||||
|
||||
|
||||
Reference in New Issue
Block a user