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 (.) #368

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

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

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 " > [email protected]" has unmet peer dependency "webpack@^4.0.0".
       warning " > [email protected]" has unmet peer dependency "webpack@^4.37.0 || ^5.0.0".
       warning "webpack-dev-server > [email protected]" 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 this is an Uglifier issue, not a turbo-rails issue.

@vmyts539
Copy link

vmyts539 commented Aug 9, 2022

@mur-wtag got the same issue, have you fixed it?

@mur-wtag
Copy link
Author

mur-wtag commented Aug 9, 2022

@mur-wtag got the same issue, have you fixed it?

@vmyts539 yup! in my Gemfile the gem uglifier was defined explicitly, I just removed it. And uglifier if being used from @hotwired/turbo-rails node module I guess now.

@mur-wtag mur-wtag closed this as completed Aug 9, 2022
@vikdotdev
Copy link

@mur-wtag This is the correct fix for this issue lautis/uglifier#186 (comment)

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

No branches or pull requests

4 participants