Skip to content

Commit b8f181f

Browse files
authored
Merge pull request webpack#5729 from STRML/feature/crossOrigin-hotReload
Also add script.crossOrigin for hot-reloaded chunks
2 parents 6b5ffa4 + 6aa3154 commit b8f181f

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

lib/JsonpMainTemplate.runtime.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
MIT License http://www.opensource.org/licenses/mit-license.php
33
Author Tobias Koppers @sokra
44
*/
5-
/*globals hotAddUpdateChunk parentHotUpdateCallback document XMLHttpRequest $require$ $hotChunkFilename$ $hotMainFilename$ */
5+
/*globals hotAddUpdateChunk parentHotUpdateCallback document XMLHttpRequest $require$ $hotChunkFilename$ $hotMainFilename$ $crossOriginLoading$ */
66
module.exports = function() {
77
function webpackHotUpdateCallback(chunkId, moreModules) { // eslint-disable-line no-unused-vars
88
hotAddUpdateChunk(chunkId, moreModules);
@@ -15,6 +15,7 @@ module.exports = function() {
1515
script.type = "text/javascript";
1616
script.charset = "utf-8";
1717
script.src = $require$.p + $hotChunkFilename$;
18+
$crossOriginLoading$;
1819
head.appendChild(script);
1920
}
2021

lib/JsonpMainTemplatePlugin.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ class JsonpMainTemplatePlugin {
171171
mainTemplate.plugin("hot-bootstrap", function(source, chunk, hash) {
172172
const hotUpdateChunkFilename = this.outputOptions.hotUpdateChunkFilename;
173173
const hotUpdateMainFilename = this.outputOptions.hotUpdateMainFilename;
174+
const crossOriginLoading = this.outputOptions.crossOriginLoading;
174175
const hotUpdateFunction = this.outputOptions.hotUpdateFunction;
175176
const currentHotUpdateChunkFilename = this.applyPluginsWaterfall("asset-path", JSON.stringify(hotUpdateChunkFilename), {
176177
hash: `" + ${this.renderCurrentHashCode(hash)} + "`,
@@ -186,6 +187,7 @@ class JsonpMainTemplatePlugin {
186187
const runtimeSource = Template.getFunctionContent(require("./JsonpMainTemplate.runtime.js"))
187188
.replace(/\/\/\$semicolon/g, ";")
188189
.replace(/\$require\$/g, this.requireFn)
190+
.replace(/\$crossOriginLoading\$/g, crossOriginLoading ? `script.crossOrigin = ${JSON.stringify(crossOriginLoading)}` : "")
189191
.replace(/\$hotMainFilename\$/g, currentHotUpdateMainFilename)
190192
.replace(/\$hotChunkFilename\$/g, currentHotUpdateChunkFilename)
191193
.replace(/\$hash\$/g, JSON.stringify(hash));

0 commit comments

Comments
 (0)