Comments (1)
Okay. This was a ride.
TL;DR: Install "@babel/plugin-proposal-object-rest-spread" if you are going to use the spread operator, e.g. { ... state, rest }
Details:
After studying webpack and babel in general, I had a few ideas. One of them was to disable production mode in the build script.
cross-env NODE_ENV=production webpack --mode production --config webpack.build.config.js
became
cross-env NODE_ENV=production webpack --config webpack.build.config.js
This basically stopped the bundled js files from being minified/uglified, so I could take a look at it.
Note: This usually spits out errors from webpack that no mode was set in the config files, so I added mode: "none"
in the config files as well.
Then taking a look at the bundled js, I saw the error was in the following line from my reducer:
// counterReducer.js
return
{
--> ...state,
count: state.count + 1
}
The problem was babel being unable to understand what the heck this was. So, I looked this issue up, and came across @babel/plugin-proposal-object-rest-spread. I installed the plugin using npm i --save @babel/plugin-proposal-object-rest-spread
and included it in .babelrc file.
// .babelrc file
{
...
"plugins": ["@babel/plugin-proposal-object-rest-spread"]
}
And it began to work perfectly fine in both development and production mode.
Perhaps all of the above could be avoided if I had simply used the core JS API, e.g.
Object.assign({}, state, { count: state.count + 1 })
but I haven't tested it.
from electron-react-webpack-boilerplate.
Related Issues (20)
- Webpack prod error - cannot concat react, react-dom, etc.
- webpack-dev-server stops access to local files HOT 2
- npm build give code ELIFECYCLE error HOT 2
- Error building package HOT 1
- Can not change main page font size HOT 3
- Error while building HOT 2
- Express, Sequelize and SQLite3
- how to reference images? HOT 3
- Cannot use ES5 syntax HOT 1
- Package/Build Error HOT 6
- unable to start the project HOT 1
- Electron Latest HOT 1
- which is the renderer js file? HOT 2
- Class Support?
- Bootstrap HOT 2
- tailwind css HOT 3
- Can't build application
- Application not making installer
- HtmlWebpackPlugin option nodeModules working? HOT 1
- SCSS Images
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from electron-react-webpack-boilerplate.