Comments (2)
Consider using name cache (--name-cache
on CLI or nameCache
on API), which tracks renaming of variables thus avoid clashes which you experience.
from uglifyjs.
How is nameCache
supposed to work, @alexlamsl?
I thought it stores all variables it minified, thus preventing the re-use of mangled names.
However, it looks like it only stores them in the supplied object when minifying a top level variable; if toplevel
is set to false
, the object is left unchanged.
I've encountered this because a constant at the top level named url
was minified to n
(which was reflected in the object), but in another file, lang
was also renamed to n
in an anonymous function.
This obviously causes errors, especially as the const
which was in front of lang
was also removed, causing it to use the global scope.
Original:
// script.js
const url = "https://api.tomatenkuchen.com/api/"
// language.js
const getLanguage = () => {
if (getCookie("lang")) return getCookie("lang")
const userLang = navigator.language || navigator.userLanguage
if (userLang) {
const lang = userLang.split("-")[0]
return lang == "de" || lang == "fr" || lang == "hu" || lang == "ja" ? lang : "en"
}
return "en"
}
Minified/mangled:
// script.js
const n="https://api.tomatenkuchen.com/api/"; // [...]
// language.js
const getLanguage=()=>getCookie("lang")?getCookie("lang"):!(n=navigator.language||navigator.userLanguage)||"de"!=(n=n.split("-")[0])&&"fr"!=n&&"hu"!=n&&"ja"!=n?"en":n // [...]
It's quite difficult to provide something easily reproducible, it's probably just caused by having many mangled variables.
I can try to create something easier to reproduce if needed.
from uglifyjs.
Related Issues (20)
- ufuzz failure
- ufuzz failure
- ufuzz failure
- ufuzz failure
- ufuzz failure
- ufuzz failure
- ufuzz failure
- ufuzz failure
- ufuzz failure
- ufuzz failure
- ufuzz failure
- ufuzz failure
- ufuzz failure
- ufuzz failure HOT 1
- ufuzz failure
- ufuzz failure
- ufuzz failure
- ufuzz failure
- ufuzz failure
- uglify-js fails if the folder specified in -o option doesn't exist HOT 1
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 uglifyjs.