Skip to content
This repository was archived by the owner on Dec 5, 2019. It is now read-only.

Commit 259adad

Browse files
fix(index): typo buildMobule => buildModule (#242)
1 parent 4c7f80a commit 259adad

File tree

1 file changed

+44
-16
lines changed

1 file changed

+44
-16
lines changed

Diff for: src/index.js

+44-16
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
/*
2-
MIT License http://www.opensource.org/licenses/mit-license.php
3-
Author Tobias Koppers @sokra
1+
/* eslint-disable
2+
no-param-reassign
43
*/
5-
64
import crypto from 'crypto';
75
import { SourceMapConsumer } from 'source-map';
86
import { SourceMapSource, RawSource, ConcatSource } from 'webpack-sources';
@@ -14,10 +12,6 @@ import schema from './options.json';
1412
import Uglify from './uglify';
1513
import versions from './uglify/versions';
1614

17-
/* eslint-disable
18-
no-param-reassign
19-
*/
20-
2115
const warningRegex = /\[.+:([0-9]+),([0-9]+)\]/;
2216

2317
class UglifyJsPlugin {
@@ -95,7 +89,7 @@ class UglifyJsPlugin {
9589
apply(compiler) {
9690
const requestShortener = new RequestShortener(compiler.context);
9791

98-
const buildMobuleFn = (moduleArg) => {
92+
const buildModuleFn = (moduleArg) => {
9993
// to get detailed location info about errors
10094
moduleArg.useSourceMap = true;
10195
};
@@ -105,8 +99,10 @@ class UglifyJsPlugin {
10599
cache: this.options.cache,
106100
parallel: this.options.parallel,
107101
});
102+
108103
const uglifiedAssets = new WeakSet();
109104
const tasks = [];
105+
110106
chunks.reduce((acc, chunk) => acc.concat(chunk.files || []), [])
111107
.concat(compilation.additionalChunkAssets || [])
112108
.filter(ModuleFilenameHelpers.matchObject.bind(null, this.options))
@@ -164,7 +160,14 @@ class UglifyJsPlugin {
164160

165161
tasks.push(task);
166162
} catch (error) {
167-
compilation.errors.push(UglifyJsPlugin.buildError(error, file, sourceMap, requestShortener));
163+
compilation.errors.push(
164+
UglifyJsPlugin.buildError(
165+
error,
166+
file,
167+
sourceMap,
168+
requestShortener,
169+
),
170+
);
168171
}
169172
});
170173

@@ -181,13 +184,25 @@ class UglifyJsPlugin {
181184
// Handling results
182185
// Error case: add errors, and go to next file
183186
if (error) {
184-
compilation.errors.push(UglifyJsPlugin.buildError(error, file, sourceMap, requestShortener));
187+
compilation.errors.push(
188+
UglifyJsPlugin.buildError(
189+
error,
190+
file,
191+
sourceMap,
192+
requestShortener,
193+
),
194+
);
195+
185196
return;
186197
}
187198

188199
let outputSource;
189200
if (map) {
190-
outputSource = new SourceMapSource(code, file, JSON.parse(map), input, inputSourceMap);
201+
outputSource = new SourceMapSource(
202+
code,
203+
file,
204+
JSON.parse(map), input, inputSourceMap,
205+
);
191206
} else {
192207
outputSource = new RawSource(code);
193208
}
@@ -197,9 +212,11 @@ class UglifyJsPlugin {
197212
// Add a banner to the original file
198213
if (this.options.extractComments.banner !== false) {
199214
let banner = this.options.extractComments.banner || `For license information please see ${commentsFile}`;
215+
200216
if (typeof banner === 'function') {
201217
banner = banner(commentsFile);
202218
}
219+
203220
if (banner) {
204221
outputSource = new ConcatSource(
205222
`/*! ${banner} */\n`, outputSource,
@@ -208,6 +225,7 @@ class UglifyJsPlugin {
208225
}
209226

210227
const commentsSource = new RawSource(`${extractedComments.join('\n\n')}\n`);
228+
211229
if (commentsFile in compilation.assets) {
212230
// commentsFile already exists, append new comments...
213231
if (compilation.assets[commentsFile] instanceof ConcatSource) {
@@ -228,14 +246,24 @@ class UglifyJsPlugin {
228246

229247
// Handling warnings
230248
if (warnings) {
231-
const warnArr = UglifyJsPlugin.buildWarnings(warnings, file, sourceMap, this.options.warningsFilter, requestShortener);
249+
const warnArr = UglifyJsPlugin.buildWarnings(
250+
warnings,
251+
file,
252+
sourceMap,
253+
this.options.warningsFilter,
254+
requestShortener,
255+
);
256+
232257
if (warnArr.length > 0) {
233-
compilation.warnings.push(new Error(`${file} from UglifyJs\n${warnArr.join('\n')}`));
258+
compilation.warnings.push(
259+
new Error(`${file} from UglifyJs\n${warnArr.join('\n')}`),
260+
);
234261
}
235262
}
236263
});
237264

238265
uglify.exit();
266+
239267
callback();
240268
});
241269
};
@@ -245,15 +273,15 @@ class UglifyJsPlugin {
245273

246274
compiler.hooks.compilation.tap(plugin, (compilation) => {
247275
if (this.options.sourceMap) {
248-
compilation.hooks.buildMobule.tap(plugin, buildMobuleFn);
276+
compilation.hooks.buildModule.tap(plugin, buildModuleFn);
249277
}
250278

251279
compilation.hooks.optimizeChunkAssets.tapAsync(plugin, optimizeFn.bind(this, compilation));
252280
});
253281
} else {
254282
compiler.plugin('compilation', (compilation) => {
255283
if (this.options.sourceMap) {
256-
compilation.plugin('build-module', buildMobuleFn);
284+
compilation.plugin('build-module', buildModuleFn);
257285
}
258286

259287
compilation.plugin('optimize-chunk-assets', optimizeFn.bind(this, compilation));

0 commit comments

Comments
 (0)