-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ES6 syntax fails to compile even on a clean new app with --webpack=stimulus #1285
Comments
@joelsouza Thanks for filing the issue. I have reproduced this bug. Running Try replacing # production.rb
config.assets.js_compressor = :uglifier
# with
config.assets.js_compressor = Uglifier.new(harmony: true) or comment it out entirely. |
I've confirmed this but I'm not sure why Sprockets/Uglifier are causing problems with assets that should be managed by Webpacker. |
@guilleiguaran Yeah strange but from compilation logs, notice sprockets is compiling stimulus files so perhaps it's noting to do with webpacker but stimulus files are being added to sprockets somehow and is compiled? (it's not in application.js) |
/cc @javan maybe you have any idea about this? |
It looks like Sprockets is compiling I suspect this isn't a webpacker issue, but rather a load path conflict with Sprockets. 🤔 |
I couldn't reproduce this with last sprockets beta (v4.0.0.beta6), we need to release a final version of sprockets v4.0. Closing since this isn't a issue with webpacker |
Hey @guilleiguaran, any idea if this is because sprockets now supports ES6 or the load path conflict was resolved? |
I found the underlying sprockets issue is being tracked in rails/sprockets#567 The maintainer, @schneems, recommends upgrading to Sprockets 4 which doesn't have the issue. |
If anyone is still running into this issue, change Reference: lautis/uglifier#127 |
|
@davidmtobias Uglifier has known issues, see: #1816 PR about the root issue: webpack/webpack#8036 (comment) |
@davidmtobias Perhaps try updating your Uglifier gem? That helped me avoid some issues with “Invalid escape sequence” errors on my application.js file (which uses Sprockets/Rails) and allowed Webpacker to build my other files without failing on Rails’ ‘assets:precompile’ task. Are the issues coming from your Webpacker files? |
This config change was found in this github issue. - rails/webpacker#1285 - This error is found in CI during bin/rails assets:precompile but is not reproducible locally. When running the task locally, there is a separate issue.
Commenting out the following line in Rails.application.config.assets.paths << Rails.root.join('node_modules') |
reactjs/react-rails#546 (comment) fixed issue for us. |
What worked for me (harmony: true) wasn't enough, but with compress option it passed: config.assets.js_compressor = Uglifier.new(harmony: true, compress: { unused: false }) |
ES6 syntax fails to compile even on a clean new app.
Expected Behavior
Run
RAILS_ENV=production rake assets:precompile
and get compiled assets without errorsCurrent Behavior
Uglifier::Error: Unexpected token: punc ({). To use ES6 syntax, harmony mode must be enabled with Uglifier.new(:harmony => true).
Steps to Reproduce
Context (Environment)
Rails 5.1.5
Detailed Description
The text was updated successfully, but these errors were encountered: