Comments (5)
Assuming there is a bug in Uglifier variable mangling, you can disable it with {mangle: false}
configuration option. This leaves variable names intact resulting in slightly larger code size after gzip.
Uglifier should always return the same output with same input. However, there are few things that I'm aware of that could break the setup in similar ways as you've described.
If you're caching compiled files on deployment environments, updating Uglifier version can change the minified output. Similarly, any compiled .erb.js
files might be cached even when Ruby code it is calling is changed. You could try bumping config.assets.version
in your application.rb to invalidate asset cached.
You didn't mention if disabling Uglifier fixes the issue, i.e. are there any differences in compiled JS before minification. If you haven't already done so, it'd be help to deploy without minification and compare those files on different nodes.
from uglifier.
Unless you mean caching the asset files for the client browser, this is not the case because i can see files being re-generated on the server, and i was also comparing files pulled from the servers file system, not from the browser.
I took two different compressed javascript files, which I then "uncompressed" by reformatting it and then used diff to see what the changes are. They were all seemingly variable name differences.
I could try disabling mangling, but that would kind of defeat the purpose here, right?
I understand that uglifier should always return the same output with the same input, but for some reason this is not happening for me. It kind of seems like it's and environment thing, but my ruby, rubygems and uglifier gem versions match across environments.
from uglifier.
What does uglifier use as an underlying library though? I would try to check if the native libraries are at the same versions to rule that issue out.
from uglifier.
Uglifier uses UglifyJS2. This is embedded in Uglifier and as such the version should be same on all nodes.
When I talked about caches, I meant Sprockets caches, not browser. Sprockets caches partial assets and in some deployment setups these can be persisted over deployments. E.g. if you include two libraries in your application libraries, the compiled versions of these libraries may be stored there. By bumping config.assets.version
you can ensure that no stale and caches are used.
Disabling mangling only affects one aspect of the minification. Newlines and redundant code are still removed. To isolate the issue, you should try to disable mangling and even Uglifier itself if clearing caches doesn't help.
from uglifier.
I had this same issue and ultimately determined that the one node that was generating a different asset hash was running a different version of rake. Ensuring that all nodes had the same version of rake (which in our setup is managed outside of the Gemfile) solved the problem for me.
from uglifier.
Related Issues (20)
- Uglify changing order of declaration
- Uglify 4 having problems with ES6 assets, while 3 works fine HOT 3
- Uglifier mangle properties has a start_with? undefined error on nil:NilClass HOT 1
- Example for harmony in readme is very dangerous HOT 4
- inlining dependencies HOT 2
- Jekyll configuration to use ES6
- Different versions between `VERSION` and published HOT 2
- Uglifier::Error: Unexpected token: name (package)
- Uglifier::Error: HOT 6
- Uglifier Cannot Precompile JS Optional Chaining HOT 3
- Uglifier runs into problems with certain combination of modern JS syntax (await, destructuring, Promise.all) HOT 1
- Uglifier complains about field declaration syntax HOT 1
- NoMethodError: undefined method `start_with?' for nil:NilClass HOT 1
- jekyll 3.8.7 | Error: Unexpected token: keyword (const). To use ES6 syntax, harmony mode must be enabled with Uglifier.new(:harmony => true).
- Changing Uglifier.new parameters does nothing if I dont clean manually the assets files first HOT 2
- Documentation for :define => {} ?
- Custom replacements
- Uglifier::Error: - Solution: Switch to terser HOT 15
- Uglifier::Error: Unexpected token: punc (.) HOT 4
- Uglifier error in production mode on RoR 7.0.3.1 with Bootstrap 5.2 HOT 16
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from uglifier.