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
|
||||
Author Tobias Koppers @sokra
|
||||
*/
|
||||
/*globals hotAddUpdateChunk parentHotUpdateCallback document XMLHttpRequest $require$ $hotChunkFilename$ $hotMainFilename$ */
|
||||
/*globals hotAddUpdateChunk parentHotUpdateCallback document XMLHttpRequest $require$ $hotChunkFilename$ $hotMainFilename$ $crossOriginLoading$ */
|
||||
module.exports = function() {
|
||||
function webpackHotUpdateCallback(chunkId, moreModules) { // eslint-disable-line no-unused-vars
|
||||
hotAddUpdateChunk(chunkId, moreModules);
|
||||
|
|
@ -15,6 +15,7 @@ module.exports = function() {
|
|||
script.type = "text/javascript";
|
||||
script.charset = "utf-8";
|
||||
script.src = $require$.p + $hotChunkFilename$;
|
||||
$crossOriginLoading$;
|
||||
head.appendChild(script);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -171,6 +171,7 @@ class JsonpMainTemplatePlugin {
|
|||
mainTemplate.plugin("hot-bootstrap", function(source, chunk, hash) {
|
||||
const hotUpdateChunkFilename = this.outputOptions.hotUpdateChunkFilename;
|
||||
const hotUpdateMainFilename = this.outputOptions.hotUpdateMainFilename;
|
||||
const crossOriginLoading = this.outputOptions.crossOriginLoading;
|
||||
const hotUpdateFunction = this.outputOptions.hotUpdateFunction;
|
||||
const currentHotUpdateChunkFilename = this.applyPluginsWaterfall("asset-path", JSON.stringify(hotUpdateChunkFilename), {
|
||||
hash: `" + ${this.renderCurrentHashCode(hash)} + "`,
|
||||
|
|
@ -186,6 +187,7 @@ class JsonpMainTemplatePlugin {
|
|||
const runtimeSource = Template.getFunctionContent(require("./JsonpMainTemplate.runtime.js"))
|
||||
.replace(/\/\/\$semicolon/g, ";")
|
||||
.replace(/\$require\$/g, this.requireFn)
|
||||
.replace(/\$crossOriginLoading\$/g, crossOriginLoading ? `script.crossOrigin = ${JSON.stringify(crossOriginLoading)}` : "")
|
||||
.replace(/\$hotMainFilename\$/g, currentHotUpdateMainFilename)
|
||||
.replace(/\$hotChunkFilename\$/g, currentHotUpdateChunkFilename)
|
||||
.replace(/\$hash\$/g, JSON.stringify(hash));
|
||||
|
|
|
|||
Loading…
Reference in New Issue