mirror of https://github.com/webpack/webpack.git
Merge pull request #5729 from STRML/feature/crossOrigin-hotReload
Also add script.crossOrigin for hot-reloaded chunks
This commit is contained in:
commit
b8f181f57f
|
|
@ -2,7 +2,7 @@
|
||||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||||
Author Tobias Koppers @sokra
|
Author Tobias Koppers @sokra
|
||||||
*/
|
*/
|
||||||
/*globals hotAddUpdateChunk parentHotUpdateCallback document XMLHttpRequest $require$ $hotChunkFilename$ $hotMainFilename$ */
|
/*globals hotAddUpdateChunk parentHotUpdateCallback document XMLHttpRequest $require$ $hotChunkFilename$ $hotMainFilename$ $crossOriginLoading$ */
|
||||||
module.exports = function() {
|
module.exports = function() {
|
||||||
function webpackHotUpdateCallback(chunkId, moreModules) { // eslint-disable-line no-unused-vars
|
function webpackHotUpdateCallback(chunkId, moreModules) { // eslint-disable-line no-unused-vars
|
||||||
hotAddUpdateChunk(chunkId, moreModules);
|
hotAddUpdateChunk(chunkId, moreModules);
|
||||||
|
|
@ -15,6 +15,7 @@ module.exports = function() {
|
||||||
script.type = "text/javascript";
|
script.type = "text/javascript";
|
||||||
script.charset = "utf-8";
|
script.charset = "utf-8";
|
||||||
script.src = $require$.p + $hotChunkFilename$;
|
script.src = $require$.p + $hotChunkFilename$;
|
||||||
|
$crossOriginLoading$;
|
||||||
head.appendChild(script);
|
head.appendChild(script);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -171,6 +171,7 @@ class JsonpMainTemplatePlugin {
|
||||||
mainTemplate.plugin("hot-bootstrap", function(source, chunk, hash) {
|
mainTemplate.plugin("hot-bootstrap", function(source, chunk, hash) {
|
||||||
const hotUpdateChunkFilename = this.outputOptions.hotUpdateChunkFilename;
|
const hotUpdateChunkFilename = this.outputOptions.hotUpdateChunkFilename;
|
||||||
const hotUpdateMainFilename = this.outputOptions.hotUpdateMainFilename;
|
const hotUpdateMainFilename = this.outputOptions.hotUpdateMainFilename;
|
||||||
|
const crossOriginLoading = this.outputOptions.crossOriginLoading;
|
||||||
const hotUpdateFunction = this.outputOptions.hotUpdateFunction;
|
const hotUpdateFunction = this.outputOptions.hotUpdateFunction;
|
||||||
const currentHotUpdateChunkFilename = this.applyPluginsWaterfall("asset-path", JSON.stringify(hotUpdateChunkFilename), {
|
const currentHotUpdateChunkFilename = this.applyPluginsWaterfall("asset-path", JSON.stringify(hotUpdateChunkFilename), {
|
||||||
hash: `" + ${this.renderCurrentHashCode(hash)} + "`,
|
hash: `" + ${this.renderCurrentHashCode(hash)} + "`,
|
||||||
|
|
@ -186,6 +187,7 @@ class JsonpMainTemplatePlugin {
|
||||||
const runtimeSource = Template.getFunctionContent(require("./JsonpMainTemplate.runtime.js"))
|
const runtimeSource = Template.getFunctionContent(require("./JsonpMainTemplate.runtime.js"))
|
||||||
.replace(/\/\/\$semicolon/g, ";")
|
.replace(/\/\/\$semicolon/g, ";")
|
||||||
.replace(/\$require\$/g, this.requireFn)
|
.replace(/\$require\$/g, this.requireFn)
|
||||||
|
.replace(/\$crossOriginLoading\$/g, crossOriginLoading ? `script.crossOrigin = ${JSON.stringify(crossOriginLoading)}` : "")
|
||||||
.replace(/\$hotMainFilename\$/g, currentHotUpdateMainFilename)
|
.replace(/\$hotMainFilename\$/g, currentHotUpdateMainFilename)
|
||||||
.replace(/\$hotChunkFilename\$/g, currentHotUpdateChunkFilename)
|
.replace(/\$hotChunkFilename\$/g, currentHotUpdateChunkFilename)
|
||||||
.replace(/\$hash\$/g, JSON.stringify(hash));
|
.replace(/\$hash\$/g, JSON.stringify(hash));
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue