Closed
Description
Is this a bug report?
Yes
Did you try recovering your dependencies?
Yes
I created a minimal repro using CRA2 "react-scripts": "2.0.0-next.3e165448"
Which terms did you search for in User Guide?
browserslist
, bad build
, yarn build
Environment
npx create-react-app --info
Environment:
OS: Linux 4.13
Node: 8.11.2
Yarn: 1.7.0
npm: 5.6.0
Watchman: Not Found
Xcode: N/A
Android Studio: Not Found
Packages: (wanted => installed)
react: ^16.4.1 => 16.4.1
react-dom: ^16.4.1 => 16.4.1
react-scripts: 2.0.0-next.3e165448 => 2.0.0-next.3e165448
Steps to Reproduce
Clone https://github.com/jazeee/cra-build-bug-demo
Repro in Demo app:
yarn start
- Click on the red div element. Observe an alert saying
Works
. yarn build
- node_modules/.bin/serve build/
- Click on the red div element.
Observe an alert sayingTypeError: Assignment to constant variable.
Expected Behavior
Expect Works
Also, can see the compiled code has a problem:
const t = e.data
, n = e.selectedRows
//...
onClick: ()=>{
try {
n = n, // This is being reassigned...
//... Stripped for clarity
For reference, can make the minified code beautiful using:
yarn build && js-beautify build/static/js/main.*.js
Actual Behavior
Observe an alert saying TypeError: Assignment to constant variable.
Reproducible Demo
Clone https://github.com/jazeee/cra-build-bug-demo
Works when using:
In package.json
:
"browserslist": {
"development": [
"last 1 chrome versions"
],
"production": [
">1%",
"last 4 versions",
"Firefox ESR",
"not ie < 11"
]
}
Since this is using a "bleeding edge" build (last 1 browser version), feel free to consider this as minor. It probably is an issue, but it can wait...
Thanks much.