Skip to content

Commit ccd7ad0

Browse files
alexlamslXhmikosR
authored andcommitted
Upgrade to uglify-js 3.0.4. (#472)
Upgrade to uglify-js 3.0.4
1 parent f3086c1 commit ccd7ad0

38 files changed

+275
-446
lines changed

Gruntfile.js

Lines changed: 63 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ module.exports = function(grunt) {
7070
},
7171
options: {
7272
mangle: {
73-
except: ['argumentC']
73+
reserved: ['argumentC']
7474
}
7575
}
7676
},
@@ -83,20 +83,6 @@ module.exports = function(grunt) {
8383
footer: '\n// This is a footer.'
8484
}
8585
},
86-
enclose: {
87-
files: {
88-
'tmp/enclose.js': ['test/fixtures/src/simple.js']
89-
},
90-
options: {
91-
beautify: true,
92-
compress: false,
93-
enclose: {
94-
'window.argA': 'paramA',
95-
'window.argB': 'paramB'
96-
},
97-
mangle: false
98-
}
99-
},
10086
multifile: {
10187
files: {
10288
'tmp/multifile.js': ['test/fixtures/src/simple.js', 'test/fixtures/src/comments.js']
@@ -110,15 +96,19 @@ module.exports = function(grunt) {
11096
dest: 'tmp/comments.js',
11197
options: {
11298
mangle: false,
113-
preserveComments: 'some'
99+
output: {
100+
comments: 'some'
101+
}
114102
}
115103
},
116104
commentsWithImportant: {
117105
src: 'test/fixtures/src/comments.js',
118106
dest: 'tmp/commentsWithImportant.js',
119107
options: {
120108
mangle: false,
121-
preserveComments: /^!|@preserve|@license|@cc_on/i
109+
output: {
110+
comments: /^!|@preserve|@license|@cc_on/i
111+
}
122112
}
123113
},
124114
wrap: {
@@ -134,31 +124,26 @@ module.exports = function(grunt) {
134124
dest: 'tmp/maxLineLen.js',
135125
options: {
136126
mangle: false,
137-
maxLineLen: 100
127+
output: {
128+
max_line_len: 100
129+
}
138130
}
139131
},
140132
ASCIIOnly: {
141133
src: 'test/fixtures/src/localization.js',
142134
dest: 'tmp/asciionly.js',
143135
options: {
144136
mangle: false,
145-
ASCIIOnly: true
137+
output: {
138+
ascii_only: true
139+
}
146140
}
147141
},
148142
screwIE8: {
149143
src: 'test/fixtures/src/screwIE8.js',
150144
dest: 'tmp/screwIE8.js',
151145
options: {
152-
screwIE8: false
153-
}
154-
},
155-
exportAll: {
156-
src: 'test/fixtures/src/simple.js',
157-
dest: 'tmp/exportAll.js',
158-
options: {
159-
mangle: false,
160-
wrap: 'testExport',
161-
exportAll: true
146+
ie8: true
162147
}
163148
},
164149
sourcemap_basic: {
@@ -188,16 +173,18 @@ module.exports = function(grunt) {
188173
src: 'test/fixtures/src/simple.js',
189174
dest: 'tmp/sourcemap_customRoot.js',
190175
options: {
191-
sourceMap: true,
192-
sourceMapRoot: 'https://github.com/RReverser/grunt-contrib-uglify/tree/master/tmp'
176+
sourceMap: {
177+
root: 'https://github.com/RReverser/grunt-contrib-uglify/tree/master/tmp'
178+
}
193179
}
194180
},
195181
sourcemap_customUrl: {
196182
src: 'test/fixtures/src/simple.js',
197183
dest: 'tmp/sourcemap_customUrl.js',
198184
options: {
199-
sourceMap: true,
200-
sourceMapUrl: 'http://www.test.com/test/sourcemap_customUrl.js.map'
185+
sourceMap: {
186+
url: 'http://www.test.com/test/sourcemap_customUrl.js.map'
187+
}
201188
}
202189
},
203190
sourcemap_functionName: {
@@ -227,7 +214,7 @@ module.exports = function(grunt) {
227214
options: {
228215
sourceMap: true,
229216
sourceMapName: function(dest) {
230-
return dest+'.fn.map';
217+
return dest + '.fn.map';
231218
}
232219
}
233220
},
@@ -238,40 +225,45 @@ module.exports = function(grunt) {
238225
options: {
239226
mangle: false,
240227
banner: '// Hello World\n',
241-
sourceMap: true,
228+
sourceMap: {
229+
includeSources: false
230+
},
242231
sourceMapIn: function() {
243232
return 'test/fixtures/src/simple2.map';
244-
},
245-
sourceMapIncludeSources: false
233+
}
246234
}
247235
},
248236
sourcemap_sources: {
249237
files: {
250238
'tmp/sourcemap_sources.js': ['test/fixtures/src/simple.js']
251239
},
252240
options: {
253-
sourceMap: true,
254-
sourceMapIncludeSources: true
241+
sourceMap: {
242+
includeSources: true
243+
}
255244
}
256245
},
257246
sourcemapin_sources: {
258247
files: {
259248
'tmp/sourcemapin_sources.js': ['test/fixtures/src/simple2.js']
260249
},
261250
options: {
262-
sourceMap: true,
251+
sourceMap: {
252+
includeSources: true
253+
},
263254
sourceMapIn: function() {
264255
return 'test/fixtures/src/simple2.map';
265-
},
266-
sourceMapIncludeSources: true
256+
}
267257
}
268258
},
269259
expression_json: {
270260
files: {
271261
'tmp/expression.json': ['test/fixtures/src/simple.json']
272262
},
273263
options: {
274-
expression: true,
264+
parse: {
265+
expression: true
266+
},
275267
mangle: false,
276268
compress: false
277269
}
@@ -281,7 +273,9 @@ module.exports = function(grunt) {
281273
'tmp/expression.js': ['test/fixtures/src/expression.js']
282274
},
283275
options: {
284-
expression: true,
276+
parse: {
277+
expression: true
278+
},
285279
mangle: false,
286280
compress: false
287281
}
@@ -291,7 +285,9 @@ module.exports = function(grunt) {
291285
'tmp/mangleprops.js': ['test/fixtures/src/mangleprops.js']
292286
},
293287
options: {
294-
mangleProperties: true
288+
mangle: {
289+
properties: true
290+
}
295291
}
296292
},
297293
mangleprops_withExcept: {
@@ -300,9 +296,9 @@ module.exports = function(grunt) {
300296
},
301297
options: {
302298
mangle: {
303-
except: ['dontMangleMeVariable']
304-
},
305-
mangleProperties: true
299+
reserved: ['dontMangleMeVariable'],
300+
properties: true
301+
}
306302
}
307303
},
308304
mangleprops_withExceptionsFiles: {
@@ -311,9 +307,9 @@ module.exports = function(grunt) {
311307
},
312308
options: {
313309
mangle: {
314-
toplevel: true
310+
toplevel: true,
311+
properties: true
315312
},
316-
mangleProperties: true,
317313
exceptionsFiles: ['test/fixtures/src/exceptionsfile1.json', 'test/fixtures/src/exceptionsfile2.json']
318314
}
319315
},
@@ -324,9 +320,9 @@ module.exports = function(grunt) {
324320
options: {
325321
mangle: {
326322
toplevel: true,
327-
except: ['dontMangleMeVariable']
323+
reserved: ['dontMangleMeVariable'],
324+
properties: true
328325
},
329-
mangleProperties: true,
330326
exceptionsFiles: ['test/fixtures/src/exceptionsfile1.json', 'test/fixtures/src/exceptionsfile2.json']
331327
}
332328
},
@@ -337,9 +333,9 @@ module.exports = function(grunt) {
337333
},
338334
options: {
339335
mangle: {
340-
toplevel: true
336+
toplevel: true,
337+
properties: true
341338
},
342-
mangleProperties: true,
343339
nameCache: 'tmp/uglify_name_cache.json'
344340
}
345341
},
@@ -348,8 +344,10 @@ module.exports = function(grunt) {
348344
'tmp/mangleprops_withRegex.js': ['test/fixtures/src/mangleprops_withRegex.js']
349345
},
350346
options: {
351-
mangleProperties: {
352-
regex: /^[^#].*/
347+
mangle: {
348+
properties: {
349+
regex: /^[^#].*/
350+
}
353351
}
354352
}
355353
},
@@ -358,23 +356,29 @@ module.exports = function(grunt) {
358356
'tmp/quotes_single.js': ['test/fixtures/src/quotes.js']
359357
},
360358
options: {
361-
quoteStyle: 1
359+
output: {
360+
quote_style: 1
361+
}
362362
}
363363
},
364364
quotes_double: {
365365
files: {
366366
'tmp/quotes_double.js': ['test/fixtures/src/quotes.js']
367367
},
368368
options: {
369-
quoteStyle: 2
369+
output: {
370+
quote_style: 2
371+
}
370372
}
371373
},
372374
quotes_original: {
373375
files: {
374376
'tmp/quotes_original.js': ['test/fixtures/src/quotes.js']
375377
},
376378
options: {
377-
quoteStyle: 3
379+
output: {
380+
quote_style: 3
381+
}
378382
}
379383
},
380384
mangle_isNotObject: {

docs/uglify-examples.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@ grunt.initConfig({
3939

4040
## Reserved identifiers
4141

42-
You can specify identifiers to leave untouched with an `except` array in the `mangle` options.
42+
You can specify identifiers to leave untouched with an `reserved` array in the `mangle` options.
4343

4444
```js
4545
// Project configuration.
4646
grunt.initConfig({
4747
uglify: {
4848
options: {
4949
mangle: {
50-
except: ['jQuery', 'Backbone']
50+
reserved: ['jQuery', 'Backbone']
5151
}
5252
},
5353
my_target: {
@@ -85,7 +85,7 @@ grunt.initConfig({
8585

8686
## Advanced source maps
8787

88-
Set the `sourceMapIncludeSources` option to `true` to embed your sources directly into the map. To include
88+
Set the `sourceMap.includeSources` option to `true` to embed your sources directly into the map. To include
8989
a source map from a previous compilation pass it as the value of the `sourceMapIn` option.
9090

9191
```js
@@ -94,8 +94,9 @@ grunt.initConfig({
9494
uglify: {
9595
my_target: {
9696
options: {
97-
sourceMap: true,
98-
sourceMapIncludeSources: true,
97+
sourceMap: {
98+
includeSources: true
99+
},
99100
sourceMapIn: 'example/coffeescript-sourcemap.js', // input sourcemap from a previous compilation
100101
},
101102
files: {
@@ -106,7 +107,7 @@ grunt.initConfig({
106107
});
107108
```
108109

109-
Refer to the [UglifyJS SourceMap Documentation](http://lisperator.net/uglifyjs/codegen#source-map) for more information.
110+
Refer to the [UglifyJS SourceMap Documentation](https://github.com/mishoo/UglifyJS2#source-map-options) for more information.
110111

111112
## Turn off console warnings
112113

@@ -134,11 +135,9 @@ grunt.initConfig({
134135
## Beautify
135136

136137
Specify `beautify: true` to beautify your code for debugging/troubleshooting purposes.
137-
Pass an object to manually configure any other output options passed directly to `UglifyJS.OutputStream()`.
138-
139-
See [UglifyJS Codegen documentation](http://lisperator.net/uglifyjs/codegen) for more information.
138+
Pass an object to manually configure any other output options.
140139

141-
_Note that manual configuration will require you to explicitly set `beautify: true` if you want traditional, beautified output._
140+
See [UglifyJS documentation](https://github.com/mishoo/UglifyJS2#beautifier-options) for more information.
142141

143142
```js
144143
// Project configuration.
@@ -155,8 +154,7 @@ grunt.initConfig({
155154
my_advanced_target: {
156155
options: {
157156
beautify: {
158-
width: 80,
159-
beautify: true
157+
width: 80
160158
}
161159
},
162160
files: {
@@ -193,9 +191,9 @@ grunt.initConfig({
193191

194192
## Conditional compilation
195193

196-
You can also enable UglifyJS conditional compilation. This is commonly used to remove debug code blocks for production builds. This is equivalent to the command line [`--define` option](https://github.com/mishoo/UglifyJS#use-as-a-code-pre-processor).
194+
You can also enable UglifyJS conditional compilation. This is commonly used to remove debug code blocks for production builds. This is equivalent to the command line `--define` option.
197195

198-
See [UglifyJS global definitions documentation](http://lisperator.net/uglifyjs/compress#global-defs) for more information.
196+
See [UglifyJS global definitions documentation](https://github.com/mishoo/UglifyJS2#conditional-compilation) for more information.
199197

200198
```js
201199
// Project configuration.
@@ -250,7 +248,7 @@ uglify: {
250248
dev: {
251249
options: {
252250
mangle: {
253-
except: ['jQuery']
251+
reserved: ['jQuery']
254252
}
255253
},
256254
files: [{
@@ -280,7 +278,9 @@ on the format of the exception file format please see the [UglifyJS docs](https:
280278
grunt.initConfig({
281279
uglify: {
282280
options: {
283-
mangleProperties: true,
281+
mangle: {
282+
properties: true
283+
},
284284
reserveDOMCache: true,
285285
exceptionsFiles: [ 'myExceptionsFile.json' ]
286286
},

0 commit comments

Comments
 (0)