Uglifyjs is a general-purpose JavaScript parser/compressor/beautifier toolkit. It is developed on NodeJS, but it should work on any JavaScript platform supporting the CommonJS module system.
Questions tagged [uglifyjs]
819 questions
28
votes
4 answers
Webpack bundles my files in the wrong order (CommonsChunkPlugin)
What I want is to bundle my JavaScript vendor files in a specific order via CommonsChunkPlugin from Webpack.
I'm using the CommonsChunkPlugin for Webpack. The usage from the official documentation is straight forward and easy. It works as intended…
Ollie Cee
- 644
- 1
- 6
- 13
27
votes
2 answers
How to exclude certain requireJS files from uglifying/optimizing
I have a working requirejs project that is using grunt for building and deployment. If using no optimization at all, the build is working without problems and I get one big js file to deploy it on production.
The problem I have is, that I have some…
Marco Rinck
- 712
- 2
- 6
- 17
25
votes
2 answers
Does grunt-contrib-uglify not parse "let" keywords?
I am getting an error,
'Unexpected token: name (bazz)'
when my grunt task is running uglify.
The only thing I noticed on that line was that I was using the 'let' keyword instead of 'var', so I wasn't sure why that error was getting thrown.
I…
Michael M
- 458
- 1
- 7
- 14
23
votes
2 answers
Gulp ngmin + uglify not working properly
I have the following gulp task:
gulp.task('scripts', function() {
return gulp.src(['app/js/app.js', 'app/config/config.js', 'app/js/controllers.js', 'app/js/directives.js' , 'app/js/filters.js', 'app/js/footer.js',
…
Oleg Belousov
- 9,633
- 12
- 68
- 119
20
votes
1 answer
How to minify nested properties
I'm using terser-js to minify my code.
The output:
a.prototype.a = ...
a.prototype.b = ...
a.prototype.c = ...
What I want:
var h = a.prototype
h.a = ...
h.b = ...
h.c = ...
Note that I can't write it by hand because the inputs are generated from…
Wei Hsieh
- 1,543
- 7
- 21
20
votes
1 answer
How to combine TypeScript code and JS libraries into one file with source maps?
I can successfully compile my TypeScript project into a single JS file with source maps using something like this:
tsc --sourcemap --out app.js app.ts
I can also successfully minify that output using UglifyJS, while keeping source maps…
dumbmatter
- 8,057
- 5
- 33
- 71
20
votes
4 answers
Javascript minification why is false replaced with !1 and true with !0
I'm writing an app using Enyo2 which comes with a minification tool based on UglifyJS.
I've noticed that:
var t = false
is replaced with
var t=!1
The same way true is replaced with !0. I'm sure there is a good explanation for that, I just can't…
Arek S
- 2,913
- 4
- 19
- 29
19
votes
3 answers
ngAnnotate - Warning: StringMap expected string key
I get this warning when using Grunt and grunt-ng-annotate.
There is no reference in the warning to where the error is in the file, which makes debugging it hard.
Any ideas?
iss42
- 2,409
- 2
- 19
- 34
19
votes
3 answers
ERROR in bundle.js from UglifyJs Name expected
I am trying to use UglifyJS to minimize/compress my bundle.js file. When I run webpack -p, I am getting the following:
ERROR in bundle.js from UglifyJs
Name expected [bundle.js:105519,6]
Line 105519 is as follows:
const {M, l, pattern} =…
Colby Cox
- 217
- 2
- 7
19
votes
6 answers
Rails 5 Heroku deploy error: ExecJS::ProgramError: SyntaxError: Unexpected token: name (autoRegisterNamespace)
When trying to deploy a rails 5 app to heroku, I get the following error, when it reaches Running: rake assets:precompile:
remote: ExecJS::ProgramError: SyntaxError: Unexpected token: name (autoRegisterNamespace) (line: 14767, col: 7, pos:…
Niels Kristian
- 8,262
- 10
- 50
- 100
19
votes
1 answer
Disable uglyfying in r.js
I am looking for a way to prevent r.js (RequireJS' optimization script) from ugylyfying our JS-modules to maintain readability for debugging purposes.
I expect the script (running on Node.js by the way) to have some command line option to be…
Leo Selig
- 992
- 1
- 15
- 30
19
votes
4 answers
Why does this JavaScript work?
I was looking at the output of some stuff from UglifyJS and happened across some code like the following:
var a = 0;
var b = function () {
return function () {
a++;
}(), 'Hello, World'
}();
After running that code a is 1 and b is…
knpwrs
- 13,484
- 10
- 56
- 98
19
votes
1 answer
How do I remove comments using the RequireJS optimizer?
I am trying to remove copyright comments from my optimized script files. We are using RequireJS with the default UglifierJS. I looked into Uglifier which in itself has a flag called -nc or --no-comments, but it does not seem like RequireJS lets you…
Michael Yagudaev
- 5,629
- 2
- 43
- 50
19
votes
6 answers
UglifyJS: concat and minify or viceversa?
I'm writing an app that uses many JS files. Underscore, Backbone, jQuery, jQuery plugins for sliders, several files for models, routers, collections and views.
In my dev machine, I load every file separately, but in production I use only one JS file…
fedeisas
- 1,851
- 2
- 21
- 33
18
votes
2 answers
How to integrate uglify-es in grunt?
I'm using gruntjs (which uses uglifyjs) to build my Angularjs app. But uglifyjs still does not support es6, so in corresponding GitHub issue i found this. So now there is uglify-es, which seemingly supports es6. But I'm not sure how to integrate it…
Yevhenii Bahmutskyi
- 1,223
- 2
- 15
- 35