question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Fails to babelify arrow syntax on npm run production

See original GitHub issue

I 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:closed
  • Created 7 years ago
  • Comments:7

github_iconTop GitHub Comments

5reactions
JeffreyWaycommented, Feb 7, 2017

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. 😃

{
    "presets": [
        ["es2015", { "modules": false }],
    ],
    "plugins": [
        "transform-object-rest-spread"
    ]
}
0reactions
wellscommented, Feb 7, 2017

Another note, including sourceMaps() in your webpack.mix.js file will double your production JS file output. I was getting 5MB with npm run dev and 1.8MB with npm run production. Once I removed the sourceMaps() call, everything went back to the same 662KB size produced by laravel elixir.

Totally looking forward to using code splitting as well. Thanks @JeffreyWay

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found