Skip to content

Commit 26512c5

Browse files
committed
Merge pull request webpack#988 from researchgate/crossorigin-loading
Possibility to load chunks with crossorigin
2 parents 8d350b6 + d7458e2 commit 26512c5

2 files changed

Lines changed: 3 additions & 0 deletions

File tree

lib/JsonpMainTemplatePlugin.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ JsonpMainTemplatePlugin.prototype.apply = function(mainTemplate) {
3333
var filename = this.outputOptions.filename || "bundle.js";
3434
var chunkFilename = this.outputOptions.chunkFilename || "[id]." + filename;
3535
var chunkMaps = chunk.getChunkMaps();
36+
var crossOriginLoading = this.outputOptions.crossOriginLoading;
3637
return this.asString([
3738
"// \"0\" is the signal for \"already loaded\"",
3839
"if(installedChunks[chunkId] === 0)",
@@ -50,6 +51,7 @@ JsonpMainTemplatePlugin.prototype.apply = function(mainTemplate) {
5051
"script.type = 'text/javascript';",
5152
"script.charset = 'utf-8';",
5253
"script.async = true;",
54+
crossOriginLoading ? "script.crossOrigin = '" + crossOriginLoading + "';" : "",
5355
"script.src = " + this.requireFn + ".p + " +
5456
this.applyPluginsWaterfall("asset-path", JSON.stringify(chunkFilename), {
5557
hash: "\" + " + this.renderCurrentHashCode(hash) + " + \"",

lib/WebpackOptionsDefaulter.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ function WebpackOptionsDefaulter() {
3434
this.set("output.sourceMapFilename", "[file].map[query]");
3535
this.set("output.hotUpdateChunkFilename", "[id].[hash].hot-update.js");
3636
this.set("output.hotUpdateMainFilename", "[hash].hot-update.json");
37+
this.set("output.crossOriginLoading", false);
3738
this.set("output.hashFunction", "md5");
3839
this.set("output.hashDigest", "hex");
3940
this.set("output.hashDigestLength", 20);

0 commit comments

Comments
 (0)