Skip to content

Commit 1d78f99

Browse files
committed
use const where applicable in UglifyJsPlugin
1 parent 92364dc commit 1d78f99

1 file changed

Lines changed: 14 additions & 14 deletions

File tree

‎lib/optimize/UglifyJsPlugin.js‎

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ class UglifyJsPlugin {
1919
}
2020

2121
apply(compiler) {
22-
let options = this.options;
22+
const options = this.options;
2323
options.test = options.test || /\.js($|\?)/i;
2424

25-
let requestShortener = new RequestShortener(compiler.context);
25+
const requestShortener = new RequestShortener(compiler.context);
2626
compiler.plugin("compilation", (compilation) => {
2727
if(options.sourceMap) {
2828
compilation.plugin("build-module", (module) => {
@@ -31,16 +31,16 @@ class UglifyJsPlugin {
3131
});
3232
}
3333
compilation.plugin("optimize-chunk-assets", (chunks, callback) => {
34-
let files = [];
34+
const files = [];
3535
chunks.forEach((chunk) => files.push.apply(files, chunk.files));
3636
files.push.apply(files, compilation.additionalChunkAssets);
3737
const filterdFiles = files.filter(ModuleFilenameHelpers.matchObject.bind(undefined, options));
3838
filterdFiles.forEach((file) => {
39-
let oldWarnFunction = uglify.AST_Node.warn_function;
40-
let warnings = [];
39+
const oldWarnFunction = uglify.AST_Node.warn_function;
40+
const warnings = [];
4141
let sourceMap;
4242
try {
43-
let asset = compilation.assets[file];
43+
const asset = compilation.assets[file];
4444
if(asset.__UglifyJsPlugin) {
4545
compilation.assets[file] = asset.__UglifyJsPlugin;
4646
return;
@@ -49,7 +49,7 @@ class UglifyJsPlugin {
4949
let inputSourceMap;
5050
if(options.sourceMap) {
5151
if(asset.sourceAndMap) {
52-
let sourceAndMap = asset.sourceAndMap();
52+
const sourceAndMap = asset.sourceAndMap();
5353
inputSourceMap = sourceAndMap.map;
5454
input = sourceAndMap.source;
5555
} else {
@@ -58,10 +58,10 @@ class UglifyJsPlugin {
5858
}
5959
sourceMap = new SourceMapConsumer(inputSourceMap);
6060
uglify.AST_Node.warn_function = (warning) => { // eslint-disable-line camelcase
61-
let match = /\[.+:([0-9]+),([0-9]+)\]/.exec(warning);
62-
let line = +match[1];
63-
let column = +match[2];
64-
let original = sourceMap.originalPositionFor({
61+
const match = /\[.+:([0-9]+),([0-9]+)\]/.exec(warning);
62+
const line = +match[1];
63+
const column = +match[2];
64+
const original = sourceMap.originalPositionFor({
6565
line: line,
6666
column: column
6767
});
@@ -81,7 +81,7 @@ class UglifyJsPlugin {
8181
});
8282
if(options.compress !== false) {
8383
ast.figure_out_scope();
84-
let compress = uglify.Compressor(options.compress || {
84+
const compress = uglify.Compressor(options.compress || {
8585
warnings: false
8686
}); // eslint-disable-line new-cap
8787
ast = ast.transform(compress);
@@ -94,7 +94,7 @@ class UglifyJsPlugin {
9494
uglify.mangle_properties(ast, options.mangle.props);
9595
}
9696
}
97-
let output = {};
97+
const output = {};
9898
output.comments = Object.prototype.hasOwnProperty.call(options, "comments") ? options.comments : /^\**!|@preserve|@license/;
9999
output.beautify = options.beautify;
100100
for(let k in options.output) {
@@ -120,7 +120,7 @@ class UglifyJsPlugin {
120120
}
121121
} catch(err) {
122122
if(err.line) {
123-
let original = sourceMap && sourceMap.originalPositionFor({
123+
const original = sourceMap && sourceMap.originalPositionFor({
124124
line: err.line,
125125
column: err.col
126126
});

0 commit comments

Comments
 (0)