1
  • Ruby version: 3.2.2
  • Rails version: 7.0.4.3
  • Filterrific gem version: 5.2.5

I am getting the following error on my server when I run rails:assets_precompile

** Execute assets:precompile
       rake aborted!
       Uglifier::Error: Unexpected token: punc (.)
       --
        12656   // send after event
        12657   form.dispatchEvent(new Event('loadedFilterrificResults'));
        12658   document.querySelector('.filterrific_spinner').style.display = 'none';
        12659 
        12660   return response;
        12661 }
        12662 
        12663 Filterrific.cspNonce = function() {
           =>   return document.querySelector("meta[name=csp-nonce]")?.content
        12665 }
        12666 
        12667 Filterrific.findParents = function(elem, selector) {
        12668   var elements = [];
        12669   var ishaveselector = selector !== undefined;
        12670 
        12671   while ((elem = elem.parentElement) !== null) {
        12672     if (elem.nodeType !== Node.ELEMENT_NODE) {
       ==
       /home/roi/app/shared/vendor/bundle/ruby/3.2.0/gems/uglifier-4.2.0/lib/uglifier.rb:291:in `parse_result'

I have the following line in production.rb:

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

The code uglifier is complaining about is in:

~/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/filterrific-5.2.5/app/assets/javascripts/filterrific/filterrific.js

Any suggestions?

Mark Fraser
  • 3,160
  • 2
  • 29
  • 48
  • `document.querySelector("meta[name=csp-nonce]")?.content` it doesn't like the question mark followed by the period – Chiperific May 08 '23 at 02:25
  • 1
    Switch to [terser](https://github.com/terser/terser) as in the comments on https://stackoverflow.com/a/66619837/479863, I couldn't get Uglifier to work with JavaScript's `?.` even though Ugifier is supposed to support it. – mu is too short May 10 '23 at 18:30

0 Answers0