[React]: Build prod generates 2 builds even with latest browser in browserlist still
See original GitHub issueCurrent Behavior
yarn build app --prod
always generates 2 prod builds (esm and es5) even when the newest browsers are specified in browserslist
.
Expected Behavior
Add a possibility for the developer to decide about the build version and be able to force only one build. You may ask why? For example to allow service workers usage generated by workbox (see https://developers.google.com/web/tools/workbox/modules/workbox-webpack-plugin). The current configuration doesn’t allow me to use the webpack plugin because of two builds (one build overrides the other one when injecting manifest to service worker).
Steps to Reproduce
See reproduction in this PR https://github.com/darkowic/nx-examples/pull/1
Here is browserslist
file https://github.com/darkowic/nx-examples/pull/1/files#diff-7dd1c466112a2275694f8d6b13dcc997
Steps:
- Install dependencies
- Build example
yarn build react-example --prod
- See 2 production builds
npx http-server dist/apps/react-example/
and open page then go to offline - service worker doesn’t work at all
Note: it works in dev mode and dev build… it is even more confusing to debug it because of it 😛
To work around the issue, I use patch-package library and comment out the second build from web builder - https://github.com/darkowic/nx-examples/pull/1/files#diff-ff5cf6c862873d747cfdf24ade8bcb71
Failure Logs
Environment
$ nx report
> NX Report complete - copy this into the issue template
@nrwl/angular : 9.5.0-rc.0
@nrwl/cli : 9.5.0-rc.0
@nrwl/cypress : 9.5.0-rc.0
@nrwl/eslint-plugin-nx : Not Found
@nrwl/express : Not Found
@nrwl/jest : 9.5.0-rc.0
@nrwl/linter : 9.5.0-rc.0
@nrwl/nest : Not Found
@nrwl/next : Not Found
@nrwl/node : Not Found
@nrwl/react : 9.5.0-rc.0
@nrwl/schematics : Not Found
@nrwl/tao : 9.5.0-rc.0
@nrwl/web : 9.5.0-rc.0
@nrwl/workspace : 9.5.0-rc.0
typescript : 3.8.3
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:6 (1 by maintainers)
I think this should be fixed by https://github.com/nrwl/nx/pull/3319 in Nx 10.
Thanks for fixing it! @FrozenPandaz how about providing an option to force the behavior? It is useful for applications with service workers