webpacker: regeneratorRuntime is not defined
Seems to be similar to https://github.com/rails/webpacker/issues/517
webpacker 2.0.0 node 8.0.0
.babelrc
{
"presets": [
["env", {
"modules": false,
"targets": {
"node": "current",
"browsers": "> 1%",
"uglify": true
},
"useBuiltIns": true
}]
],
"plugins": [
"syntax-dynamic-import",
["transform-class-properties", { "spec": true }]
]
}
package.json
{
"name": "dirtylemon-admin",
"private": true,
"dependencies": {
"autoprefixer": "^7.1.1",
"axios": "^0.16.1",
"babel-core": "^6.25.0",
"babel-loader": "7.x",
"babel-plugin-syntax-dynamic-import": "^6.18.0",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-polyfill": "^6.23.0",
"babel-preset-env": "^1.5.2",
"babel-preset-react": "^6.24.1",
"bootstrap": "4.0.0-alpha.6",
"coffee-loader": "^0.7.3",
"coffee-script": "^1.12.6",
"compression-webpack-plugin": "^0.4.0",
"css-loader": "^0.28.4",
"extract-text-webpack-plugin": "^2.1.2",
"file-loader": "^0.11.2",
"glob": "^7.1.2",
"immutability-helper": "^2.2.0",
"jquery": "^3.2.1",
"js-yaml": "^3.8.4",
"lodash": "^4.17.4",
"moment": "^2.18.1",
"moment-timezone": "^0.5.13",
"node-sass": "^4.5.3",
"notie": "^4.3.0",
"numeral": "^2.0.6",
"path-complete-extname": "^0.1.0",
"postcss-loader": "^2.0.6",
"postcss-smart-import": "^0.7.4",
"precss": "^1.4.0",
"rails-erb-loader": "^5.0.2",
"react": "^15.5.4",
"react-auto-scroll": "^1.1.0",
"react-dom": "^15.5.4",
"react-redux": "^5.0.5",
"redux": "^3.6.0",
"redux-saga": "^0.15.3",
"redux-thunk": "^2.2.0",
"resolve-url-loader": "^2.0.3",
"sass-loader": "^6.0.6",
"style-loader": "^0.18.2",
"tablesort": "^5.0.0",
"webpack": "^2.6.1",
"webpack-manifest-plugin": "^1.1.0",
"webpack-merge": "^4.1.0"
},
"devDependencies": {
"webpack-dev-server": "^2.4.5"
}
}
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 1
- Comments: 45 (19 by maintainers)
Commits related to this issue
- Update Babel config to use async/await https://github.com/rails/webpacker/issues/517 https://github.com/rails/webpacker/issues/518 — committed to annict/annict by shimbaco 6 years ago
Here is my solution (reference: https://github.com/rails/webpacker/blob/master/docs/es6.md):
@babel/polyfill
:import "@babel/polyfill"
into your front-end app’s entry file (eg.app/javascript/packs/application.js
)Done!
I ended up using this solution https://stackoverflow.com/questions/44287584/how-to-minify-es6-code-using-webpack
Ok, I re run
rails webpacker:install:react
and it works. I’ll also update.babelrc
just in caseThere is a tricky part with @f6v solution. Installing the new
uglifyjs-webpack-plugin
package works, but you need to replace Webpacker’s defaultUglifyJs
plugin with it. Here is how:@gauravtiwari when I remove
"browsers": "> 1%", "uglify": true
and replace with
"node": "current"
it works fine in development mode but fails to deploy to heroku. Any ideas why?Don’t forget to also set
useBuiltIns: 'entry'
in your.babelrc
(defaults tofalse
)Also note:
So, make sure that if you use
@babel/polyfill
in multiple entry files (/packs/*.js
), don’t load multiple entry files on a single page. If you find yourself needing to do this, consider using dynamic import to include the different files.@f6v You may wanna use https://babeljs.io/blog/2016/08/30/babili instead, remove uglify and replace it with babili
@gauravtiwari I did, see my
.babelrc