Fails to babelify arrow syntax on npm run production
See original GitHub issueI just tried out Laravel mix and found that it would compile without errors with npm run dev
. However, when I attempted to run npm run production
, it failed on some arrow syntax in a .js file.
export function addRecords (records, newRecords, type) {
if (!newRecords) {
return
}
newRecords.forEach(newRecord => {
addRecord(records, newRecord, type)
})
}
And the error below refers to the newRecords.forEach(newRecord => {
line above:
> node node_modules/cross-env/bin/cross-env.js NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js
fallbackLoader option has been deprecated - replace with "fallback"
loader option has been deprecated - replace with "use"
95% emitting
ERROR Failed to compile with 1 errors
error
/js/app.a25a2e810095631e31db.js from UglifyJs
SyntaxError: Unexpected token: operator (>) [./resources/assets/js/vuex/helpers.js:6,21][/js/app.a25a2e810095631e31db.js:5690,32]
Sorry but failing on ES2015 arrow syntax is a bit of a deal breaker here.
Issue Analytics
- State:
- Created 7 years ago
- Comments:7
Top Results From Across the Web
babel with browerify causing syntax error with arrow functions
Alright after adding 'stage-1' I was able to use arrow functions without any issues. .transform(babelify, {presets: ['es2015', 'stage-1', ...
Read more >`npm run build` -> Error: Failed to parse package.json data ...
Failed to parse package.json data. The error is related to babelify: The problem is that new version of babelify is changed and that...
Read more >Improve your client-side-javascript workflow more by using ES6
Integrate babel with browserify yey — the code is transpiled to ES5! Running npm run build should create a dist/bundle. js file. If...
Read more >nodejs/node - Gitter
@Nepoxx i've a question.. I don't use it, because I don't like having to babelify my code. WHY? instead of running via node...
Read more >[Solved]-Babelify breaks down-babel.js - appsloveworld
Coding example for the question Babelify breaks down-babel.js. ... create react app production build breaks material-ui v1.0.0 components in npm module ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yep. You’re using a custom .babelrc file that doesn’t specify ES2015 compilation. And now you’re wondering why you’re not getting ES2015 compilation. 😃
Another note, including
sourceMaps()
in yourwebpack.mix.js
file will double your production JS file output. I was getting 5MB withnpm run dev
and 1.8MB withnpm run production
. Once I removed thesourceMaps()
call, everything went back to the same 662KB size produced by laravel elixir.Totally looking forward to using code splitting as well. Thanks @JeffreyWay