Skip to content

Commit 54178cb

Browse files
committed
add proper plugin names, rever ruleset change, reverse order of used function
1 parent 18953ff commit 54178cb

6 files changed

Lines changed: 25 additions & 19 deletions

lib/AmdMainTemplatePlugin.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@ class AmdMainTemplatePlugin {
1919
chunkTemplate
2020
} = compilation;
2121

22-
for(const template of [mainTemplate, chunkTemplate]) {
23-
template.hooks.renderWithEntry("AmdMainTemplatePlugin", onRenderWithEntry);
24-
}
25-
2622
const onRenderWithEntry = (source, chunk, hash) => {
2723
const externals = chunk.getModules().filter((m) => m.external);
2824
const externalsDepsArray = JSON.stringify(externals.map((m) =>
@@ -48,6 +44,11 @@ class AmdMainTemplatePlugin {
4844
}
4945
};
5046

47+
for(const template of [mainTemplate, chunkTemplate]) {
48+
template.hooks.renderWithEntry("AmdMainTemplatePlugin", onRenderWithEntry);
49+
}
50+
51+
5152
mainTemplate.hooks.globalHashPaths.tap("AmdMainTemplatePlugin", paths => {
5253
if(this.name) paths.push(this.name);
5354
return paths;

lib/ExportPropertyMainTemplatePlugin.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ class ExportPropertyMainTemplatePlugin {
2121
chunkTemplate
2222
} = compilation;
2323

24-
for(const template of [mainTemplate, chunkTemplate]) {
25-
template.hooks.renderWithEntry("AmdMainTemplatePlugin", onRenderWithEntry);
26-
}
27-
2824
const onRenderWithEntry = (source, chunk, hash) => {
2925
const postfix = `${accessorToObjectAccess([].concat(this.property))}`;
3026
return new ConcatSource(source, postfix);
3127
};
3228

29+
for(const template of [mainTemplate, chunkTemplate]) {
30+
template.hooks.renderWithEntry("ExportPropertyMainTemplatePlugin", onRenderWithEntry);
31+
}
32+
3333
mainTemplate.hooks.hash.tap("ExportPropertyMainTemplatePlugin", hash => {
3434
hash.update("export property");
3535
hash.update(`${this.property}`);

lib/RuleSet.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ module.exports = class RuleSet {
427427

428428
if(rule.oneOf) {
429429
for(let i = 0; i < rule.oneOf.length; i++) {
430-
if(this._run(data, rule.oneof[i], result))
430+
if(this._run(data, rule.oneOf[i], result))
431431
break;
432432
}
433433
}

lib/SetVarMainTemplatePlugin.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@ class SetVarMainTemplatePlugin {
1818
chunkTemplate
1919
} = compilation;
2020

21-
for(const template of [mainTemplate, chunkTemplate]) {
22-
template.hooks.renderWithEntry("AmdMainTemplatePlugin", onRenderWithEntry);
23-
}
2421

2522
const onRenderWithEntry = (source, chunk, hash) => {
2623
const varExpression = mainTemplate.getAssetPath(this.varExpression, {
@@ -34,6 +31,11 @@ class SetVarMainTemplatePlugin {
3431
return new ConcatSource(prefix, source);
3532
}
3633
};
34+
35+
for(const template of [mainTemplate, chunkTemplate]) {
36+
template.hooks.renderWithEntry("SetVarMainTemplatePlugin", onRenderWithEntry);
37+
}
38+
3739
mainTemplate.hooks.globalHashPaths.tap("SetVarMainTemplatePlugin", paths => {
3840
if(this.varExpression) paths.push(this.varExpression);
3941
return paths;

lib/UmdMainTemplatePlugin.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,6 @@ class UmdMainTemplatePlugin {
4545
chunkTemplate
4646
} = compilation;
4747

48-
for(const template of [mainTemplate, chunkTemplate]) {
49-
template.hooks.renderWithEntry("AmdMainTemplatePlugin", onRenderWithEntry);
50-
}
51-
5248
const onRenderWithEntry = (source, chunk, hash) => {
5349
let externals = chunk.getModules().filter(m => m.external && (m.externalType === "umd" || m.externalType === "umd2"));
5450
const optionalExternals = [];
@@ -181,12 +177,18 @@ class UmdMainTemplatePlugin {
181177
) +
182178
"})(typeof self !== 'undefined' ? self : this, function(" + externalsArguments(externals) + ") {\nreturn ", "webpack/universalModuleDefinition"), source, ";\n})");
183179
};
180+
181+
for(const template of [mainTemplate, chunkTemplate]) {
182+
template.hooks.renderWithEntry("UmdMainTemplatePlugin", onRenderWithEntry);
183+
}
184+
184185
mainTemplate.hooks.globalHasPaths.tap("UmdMainTemplatePlugin", (paths) => {
185186
if(this.names.root) paths = paths.concat(this.names.root);
186187
if(this.names.amd) paths = paths.concat(this.names.amd);
187188
if(this.names.commonjs) paths = paths.concat(this.names.commonjs);
188189
return paths;
189190
});
191+
190192
mainTemplate.hooks.hash.tap("UmdMainTemplatePlugin", (hash) => {
191193
hash.update("umd");
192194
hash.update(`${this.names.root}`);

lib/web/JsonpExportMainTemplatePlugin.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ class JsonpExportMainTemplatePlugin {
1717
chunkTemplate
1818
} = compilation;
1919

20-
for(const template of [mainTemplate, chunkTemplate]) {
21-
template.hooks.renderWithEntry("AmdMainTemplatePlugin", onRenderWithEntry);
22-
}
2320

2421
const onRenderWithEntry = (source, chunk, hash) => {
2522
const name = mainTemplate.getAssetPath(this.name || "", {
@@ -29,6 +26,10 @@ class JsonpExportMainTemplatePlugin {
2926
return new ConcatSource(`${name}(`, source, ");");
3027
};
3128

29+
for(const template of [mainTemplate, chunkTemplate]) {
30+
template.hooks.renderWithEntry("JsonpExportMainTemplatePlugin", onRenderWithEntry);
31+
}
32+
3233
mainTemplate.hooks.globalHashPaths.tap("JsonpExportMainTemplatePlugin", paths => {
3334
if(this.name) paths.push(this.name);
3435
return paths;

0 commit comments

Comments
 (0)