Skip to content
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

Uglifier::Error: Unexpected token: punc (.) #186

Open
mur-wtag opened this issue Aug 2, 2022 · 4 comments
Open

Uglifier::Error: Unexpected token: punc (.) #186

mur-wtag opened this issue Aug 2, 2022 · 4 comments

Comments

@mur-wtag
Copy link

mur-wtag commented Aug 2, 2022

I know there there are tons of solution for this issue and I've tried all of them and still facing this issue while it's trying to compile assets.

here is the error logs:

[4/5] Linking dependencies...
       warning " > uglifyjs-webpack-plugin@2.2.0" has unmet peer dependency "webpack@^4.0.0".
       warning " > webpack-dev-server@4.8.1" has unmet peer dependency "webpack@^4.37.0 || ^5.0.0".
       warning "webpack-dev-server > webpack-dev-middleware@5.3.1" has unmet peer dependency "webpack@^4.0.0 || ^5.0.0".
       [5/5] Building fresh packages...
       Done in 3.02s.
       rake aborted!
       Uglifier::Error: Unexpected token: punc (.)
       --
        3527       })
        3528     };
        3529   }
        3530 }
        3531 
        3532 customElements.define("turbo-cable-stream-source", TurboCableStreamSourceElement);
        3533 
        3534 function overrideMethodWithFormmethod({detail: {formSubmission: {fetchRequest: fetchRequest, submitter: submitter}}}) {
          =>   const formMethod = submitter?.formMethod;
        3536   if (formMethod && fetchRequest.body.has("_method")) {
        3537     fetchRequest.body.set("_method", formMethod);
        3538   }
        3539 }
        3540 
        3541 addEventListener("turbo:submit-start", overrideMethodWithFormmethod);
        3542 
        3543 var adapters = {
       ==
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/uglifier-4.2.0/lib/uglifier.rb:291:in `parse_result'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/uglifier-4.2.0/lib/uglifier.rb:221:in `run_uglifyjs'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/uglifier-4.2.0/lib/uglifier.rb:166:in `compile'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/sprockets-3.7.2/lib/sprockets/compressing.rb:65:in `block in js_compressor='
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/sprockets-3.7.2/lib/sprockets/legacy_proc_processor.rb:31:in `call'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/sprockets-3.7.2/lib/sprockets/processor_utils.rb:75:in `call_processor'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/sprockets-3.7.2/lib/sprockets/processor_utils.rb:57:in `block in call_processors'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/sprockets-3.7.2/lib/sprockets/processor_utils.rb:56:in `reverse_each'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/sprockets-3.7.2/lib/sprockets/processor_utils.rb:56:in `call_processors'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/sprockets-3.7.2/lib/sprockets/loader.rb:134:in `load_from_unloaded'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/sprockets-3.7.2/lib/sprockets/loader.rb:60:in `block in load'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/sprockets-3.7.2/lib/sprockets/loader.rb:317:in `fetch_asset_from_dependency_cache'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/sprockets-3.7.2/lib/sprockets/loader.rb:44:in `load'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/sprockets-3.7.2/lib/sprockets/cached_environment.rb:20:in `block in initialize'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/sprockets-3.7.2/lib/sprockets/cached_environment.rb:47:in `load'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/sprockets-3.7.2/lib/sprockets/base.rb:66:in `find_asset'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/sprockets-3.7.2/lib/sprockets/base.rb:73:in `find_all_linked_assets'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/sprockets-3.7.2/lib/sprockets/manifest.rb:134:in `block in find'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/sprockets-3.7.2/lib/sprockets/manifest.rb:133:in `each'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/sprockets-3.7.2/lib/sprockets/manifest.rb:133:in `find'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/sprockets-3.7.2/lib/sprockets/manifest.rb:186:in `compile'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/sprockets-rails-3.4.2/lib/sprockets/rails/task.rb:67:in `block (3 levels) in define'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/sprockets-3.7.2/lib/rake/sprocketstask.rb:147:in `with_logger'
       /layers/heroku_ruby/gems/vendor/bundle/ruby/2.7.0/gems/sprockets-rails-3.4.2/lib/sprockets/rails/task.rb:66:in `block (2 levels) in define'
       Tasks: TOP => assets:precompile
       (See full trace by running task with --trace)

 !
 !     Precompiling assets failed.
 !
ERROR: failed to build: exit status 1
Error: errors were encountered with one or more resources

In my project's production.rb I've defined this to enable ES6/harmony:

config.assets.js_compressor = Uglifier.new(harmony: true)

Not sure how to resolve this issue. Any help will be appreciable 🙏

@tleish
Copy link

tleish commented Aug 3, 2022

Seems replacing with terser with ES6 support has been the repeated suggestion here.

@vikdotdev
Copy link

This seems to be caused by Turbo having es2020? features in it's gems' /app/assets/javascripts/turbo.js. I've hit the same problem and am not sure how to proceed.

@vikdotdev
Copy link

Weirdly enough the exact syntax is not in the source code of https://github.com/hotwired/turbo-rails

@vikdotdev
Copy link

vikdotdev commented Aug 9, 2022

Here's the fix in turbo-rails https://github.com/hotwired/turbo-rails/pull/337/files
Use main branch version until >= v1.1.2 comes out:

gem "turbo-rails", github: 'hotwired/turbo-rails'

Edit or more safely with:

gem "turbo-rails", github: 'hotwired/turbo-rails', ref: '37be2c6c39c417ddd5f12dcd494fb232220b0d08'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants