commit node_modules and generated files
This commit is contained in:
parent
6d7a135fea
commit
34b372292b
3379 changed files with 449603 additions and 2029 deletions
37
node_modules/webpack/lib/web/FetchCompileWasmTemplatePlugin.js
generated
vendored
Normal file
37
node_modules/webpack/lib/web/FetchCompileWasmTemplatePlugin.js
generated
vendored
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Tobias Koppers @sokra
|
||||
*/
|
||||
"use strict";
|
||||
|
||||
const WasmMainTemplatePlugin = require("../wasm/WasmMainTemplatePlugin");
|
||||
|
||||
class FetchCompileWasmTemplatePlugin {
|
||||
constructor(options) {
|
||||
this.options = options || {};
|
||||
}
|
||||
|
||||
apply(compiler) {
|
||||
compiler.hooks.thisCompilation.tap(
|
||||
"FetchCompileWasmTemplatePlugin",
|
||||
compilation => {
|
||||
const mainTemplate = compilation.mainTemplate;
|
||||
const generateLoadBinaryCode = path =>
|
||||
`fetch(${mainTemplate.requireFn}.p + ${path})`;
|
||||
|
||||
const plugin = new WasmMainTemplatePlugin(
|
||||
Object.assign(
|
||||
{
|
||||
generateLoadBinaryCode,
|
||||
supportsStreaming: true
|
||||
},
|
||||
this.options
|
||||
)
|
||||
);
|
||||
plugin.apply(mainTemplate);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = FetchCompileWasmTemplatePlugin;
|
||||
71
node_modules/webpack/lib/web/JsonpChunkTemplatePlugin.js
generated
vendored
Normal file
71
node_modules/webpack/lib/web/JsonpChunkTemplatePlugin.js
generated
vendored
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Tobias Koppers @sokra
|
||||
*/
|
||||
"use strict";
|
||||
|
||||
const { ConcatSource } = require("webpack-sources");
|
||||
|
||||
/** @typedef {import("../ChunkTemplate")} ChunkTemplate */
|
||||
|
||||
const getEntryInfo = chunk => {
|
||||
return [chunk.entryModule].filter(Boolean).map(m =>
|
||||
[m.id].concat(
|
||||
Array.from(chunk.groupsIterable)[0]
|
||||
.chunks.filter(c => c !== chunk)
|
||||
.map(c => c.id)
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
class JsonpChunkTemplatePlugin {
|
||||
/**
|
||||
* @param {ChunkTemplate} chunkTemplate the chunk template
|
||||
* @returns {void}
|
||||
*/
|
||||
apply(chunkTemplate) {
|
||||
chunkTemplate.hooks.render.tap(
|
||||
"JsonpChunkTemplatePlugin",
|
||||
(modules, chunk) => {
|
||||
const jsonpFunction = chunkTemplate.outputOptions.jsonpFunction;
|
||||
const globalObject = chunkTemplate.outputOptions.globalObject;
|
||||
const source = new ConcatSource();
|
||||
const prefetchChunks = chunk.getChildIdsByOrders().prefetch;
|
||||
source.add(
|
||||
`(${globalObject}[${JSON.stringify(
|
||||
jsonpFunction
|
||||
)}] = ${globalObject}[${JSON.stringify(
|
||||
jsonpFunction
|
||||
)}] || []).push([${JSON.stringify(chunk.ids)},`
|
||||
);
|
||||
source.add(modules);
|
||||
const entries = getEntryInfo(chunk);
|
||||
if (entries.length > 0) {
|
||||
source.add(`,${JSON.stringify(entries)}`);
|
||||
} else if (prefetchChunks && prefetchChunks.length) {
|
||||
source.add(`,0`);
|
||||
}
|
||||
|
||||
if (prefetchChunks && prefetchChunks.length) {
|
||||
source.add(`,${JSON.stringify(prefetchChunks)}`);
|
||||
}
|
||||
source.add("])");
|
||||
return source;
|
||||
}
|
||||
);
|
||||
chunkTemplate.hooks.hash.tap("JsonpChunkTemplatePlugin", hash => {
|
||||
hash.update("JsonpChunkTemplatePlugin");
|
||||
hash.update("4");
|
||||
hash.update(`${chunkTemplate.outputOptions.jsonpFunction}`);
|
||||
hash.update(`${chunkTemplate.outputOptions.globalObject}`);
|
||||
});
|
||||
chunkTemplate.hooks.hashForChunk.tap(
|
||||
"JsonpChunkTemplatePlugin",
|
||||
(hash, chunk) => {
|
||||
hash.update(JSON.stringify(getEntryInfo(chunk)));
|
||||
hash.update(JSON.stringify(chunk.getChildIdsByOrders().prefetch) || "");
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
module.exports = JsonpChunkTemplatePlugin;
|
||||
50
node_modules/webpack/lib/web/JsonpExportMainTemplatePlugin.js
generated
vendored
Normal file
50
node_modules/webpack/lib/web/JsonpExportMainTemplatePlugin.js
generated
vendored
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Tobias Koppers @sokra
|
||||
*/
|
||||
"use strict";
|
||||
|
||||
const { ConcatSource } = require("webpack-sources");
|
||||
|
||||
class JsonpExportMainTemplatePlugin {
|
||||
/**
|
||||
* @param {string} name jsonp function name
|
||||
*/
|
||||
constructor(name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
apply(compilation) {
|
||||
const { mainTemplate, chunkTemplate } = compilation;
|
||||
|
||||
const onRenderWithEntry = (source, chunk, hash) => {
|
||||
const name = mainTemplate.getAssetPath(this.name || "", {
|
||||
hash,
|
||||
chunk
|
||||
});
|
||||
return new ConcatSource(`${name}(`, source, ");");
|
||||
};
|
||||
|
||||
for (const template of [mainTemplate, chunkTemplate]) {
|
||||
template.hooks.renderWithEntry.tap(
|
||||
"JsonpExportMainTemplatePlugin",
|
||||
onRenderWithEntry
|
||||
);
|
||||
}
|
||||
|
||||
mainTemplate.hooks.globalHashPaths.tap(
|
||||
"JsonpExportMainTemplatePlugin",
|
||||
paths => {
|
||||
if (this.name) paths.push(this.name);
|
||||
return paths;
|
||||
}
|
||||
);
|
||||
|
||||
mainTemplate.hooks.hash.tap("JsonpExportMainTemplatePlugin", hash => {
|
||||
hash.update("jsonp export");
|
||||
hash.update(`${this.name}`);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = JsonpExportMainTemplatePlugin;
|
||||
39
node_modules/webpack/lib/web/JsonpHotUpdateChunkTemplatePlugin.js
generated
vendored
Normal file
39
node_modules/webpack/lib/web/JsonpHotUpdateChunkTemplatePlugin.js
generated
vendored
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Tobias Koppers @sokra
|
||||
*/
|
||||
"use strict";
|
||||
|
||||
const { ConcatSource } = require("webpack-sources");
|
||||
|
||||
class JsonpHotUpdateChunkTemplatePlugin {
|
||||
apply(hotUpdateChunkTemplate) {
|
||||
hotUpdateChunkTemplate.hooks.render.tap(
|
||||
"JsonpHotUpdateChunkTemplatePlugin",
|
||||
(modulesSource, modules, removedModules, hash, id) => {
|
||||
const source = new ConcatSource();
|
||||
source.add(
|
||||
`${
|
||||
hotUpdateChunkTemplate.outputOptions.hotUpdateFunction
|
||||
}(${JSON.stringify(id)},`
|
||||
);
|
||||
source.add(modulesSource);
|
||||
source.add(")");
|
||||
return source;
|
||||
}
|
||||
);
|
||||
hotUpdateChunkTemplate.hooks.hash.tap(
|
||||
"JsonpHotUpdateChunkTemplatePlugin",
|
||||
hash => {
|
||||
hash.update("JsonpHotUpdateChunkTemplatePlugin");
|
||||
hash.update("3");
|
||||
hash.update(
|
||||
`${hotUpdateChunkTemplate.outputOptions.hotUpdateFunction}`
|
||||
);
|
||||
hash.update(`${hotUpdateChunkTemplate.outputOptions.library}`);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = JsonpHotUpdateChunkTemplatePlugin;
|
||||
71
node_modules/webpack/lib/web/JsonpMainTemplate.runtime.js
generated
vendored
Normal file
71
node_modules/webpack/lib/web/JsonpMainTemplate.runtime.js
generated
vendored
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Tobias Koppers @sokra
|
||||
*/
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
var hotAddUpdateChunk = undefined;
|
||||
var parentHotUpdateCallback = undefined;
|
||||
var $require$ = undefined;
|
||||
var $hotMainFilename$ = undefined;
|
||||
var $hotChunkFilename$ = undefined;
|
||||
var $crossOriginLoading$ = undefined;
|
||||
|
||||
module.exports = function() {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
function webpackHotUpdateCallback(chunkId, moreModules) {
|
||||
hotAddUpdateChunk(chunkId, moreModules);
|
||||
if (parentHotUpdateCallback) parentHotUpdateCallback(chunkId, moreModules);
|
||||
} //$semicolon
|
||||
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
function hotDownloadUpdateChunk(chunkId) {
|
||||
var script = document.createElement("script");
|
||||
script.charset = "utf-8";
|
||||
script.src = $require$.p + $hotChunkFilename$;
|
||||
if ($crossOriginLoading$) script.crossOrigin = $crossOriginLoading$;
|
||||
document.head.appendChild(script);
|
||||
}
|
||||
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
function hotDownloadManifest(requestTimeout) {
|
||||
requestTimeout = requestTimeout || 10000;
|
||||
return new Promise(function(resolve, reject) {
|
||||
if (typeof XMLHttpRequest === "undefined") {
|
||||
return reject(new Error("No browser support"));
|
||||
}
|
||||
try {
|
||||
var request = new XMLHttpRequest();
|
||||
var requestPath = $require$.p + $hotMainFilename$;
|
||||
request.open("GET", requestPath, true);
|
||||
request.timeout = requestTimeout;
|
||||
request.send(null);
|
||||
} catch (err) {
|
||||
return reject(err);
|
||||
}
|
||||
request.onreadystatechange = function() {
|
||||
if (request.readyState !== 4) return;
|
||||
if (request.status === 0) {
|
||||
// timeout
|
||||
reject(
|
||||
new Error("Manifest request to " + requestPath + " timed out.")
|
||||
);
|
||||
} else if (request.status === 404) {
|
||||
// no update available
|
||||
resolve();
|
||||
} else if (request.status !== 200 && request.status !== 304) {
|
||||
// other failure
|
||||
reject(new Error("Manifest request to " + requestPath + " failed."));
|
||||
} else {
|
||||
// success
|
||||
try {
|
||||
var update = JSON.parse(request.responseText);
|
||||
} catch (e) {
|
||||
reject(e);
|
||||
return;
|
||||
}
|
||||
resolve(update);
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
};
|
||||
615
node_modules/webpack/lib/web/JsonpMainTemplatePlugin.js
generated
vendored
Normal file
615
node_modules/webpack/lib/web/JsonpMainTemplatePlugin.js
generated
vendored
Normal file
|
|
@ -0,0 +1,615 @@
|
|||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Tobias Koppers @sokra
|
||||
*/
|
||||
"use strict";
|
||||
|
||||
const { SyncWaterfallHook } = require("tapable");
|
||||
const Template = require("../Template");
|
||||
|
||||
class JsonpMainTemplatePlugin {
|
||||
apply(mainTemplate) {
|
||||
const needChunkOnDemandLoadingCode = chunk => {
|
||||
for (const chunkGroup of chunk.groupsIterable) {
|
||||
if (chunkGroup.getNumberOfChildren() > 0) return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
const needChunkLoadingCode = chunk => {
|
||||
for (const chunkGroup of chunk.groupsIterable) {
|
||||
if (chunkGroup.chunks.length > 1) return true;
|
||||
if (chunkGroup.getNumberOfChildren() > 0) return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
const needEntryDeferringCode = chunk => {
|
||||
for (const chunkGroup of chunk.groupsIterable) {
|
||||
if (chunkGroup.chunks.length > 1) return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
const needPrefetchingCode = chunk => {
|
||||
const allPrefetchChunks = chunk.getChildIdsByOrdersMap(true).prefetch;
|
||||
return allPrefetchChunks && Object.keys(allPrefetchChunks).length;
|
||||
};
|
||||
|
||||
// TODO webpack 5, no adding to .hooks, use WeakMap and static methods
|
||||
["jsonpScript", "linkPreload", "linkPrefetch"].forEach(hook => {
|
||||
if (!mainTemplate.hooks[hook]) {
|
||||
mainTemplate.hooks[hook] = new SyncWaterfallHook([
|
||||
"source",
|
||||
"chunk",
|
||||
"hash"
|
||||
]);
|
||||
}
|
||||
});
|
||||
|
||||
const getScriptSrcPath = (hash, chunk, chunkIdExpression) => {
|
||||
const chunkFilename = mainTemplate.outputOptions.chunkFilename;
|
||||
const chunkMaps = chunk.getChunkMaps();
|
||||
return mainTemplate.getAssetPath(JSON.stringify(chunkFilename), {
|
||||
hash: `" + ${mainTemplate.renderCurrentHashCode(hash)} + "`,
|
||||
hashWithLength: length =>
|
||||
`" + ${mainTemplate.renderCurrentHashCode(hash, length)} + "`,
|
||||
chunk: {
|
||||
id: `" + ${chunkIdExpression} + "`,
|
||||
hash: `" + ${JSON.stringify(
|
||||
chunkMaps.hash
|
||||
)}[${chunkIdExpression}] + "`,
|
||||
hashWithLength(length) {
|
||||
const shortChunkHashMap = Object.create(null);
|
||||
for (const chunkId of Object.keys(chunkMaps.hash)) {
|
||||
if (typeof chunkMaps.hash[chunkId] === "string") {
|
||||
shortChunkHashMap[chunkId] = chunkMaps.hash[chunkId].substr(
|
||||
0,
|
||||
length
|
||||
);
|
||||
}
|
||||
}
|
||||
return `" + ${JSON.stringify(
|
||||
shortChunkHashMap
|
||||
)}[${chunkIdExpression}] + "`;
|
||||
},
|
||||
name: `" + (${JSON.stringify(
|
||||
chunkMaps.name
|
||||
)}[${chunkIdExpression}]||${chunkIdExpression}) + "`,
|
||||
contentHash: {
|
||||
javascript: `" + ${JSON.stringify(
|
||||
chunkMaps.contentHash.javascript
|
||||
)}[${chunkIdExpression}] + "`
|
||||
},
|
||||
contentHashWithLength: {
|
||||
javascript: length => {
|
||||
const shortContentHashMap = {};
|
||||
const contentHash = chunkMaps.contentHash.javascript;
|
||||
for (const chunkId of Object.keys(contentHash)) {
|
||||
if (typeof contentHash[chunkId] === "string") {
|
||||
shortContentHashMap[chunkId] = contentHash[chunkId].substr(
|
||||
0,
|
||||
length
|
||||
);
|
||||
}
|
||||
}
|
||||
return `" + ${JSON.stringify(
|
||||
shortContentHashMap
|
||||
)}[${chunkIdExpression}] + "`;
|
||||
}
|
||||
}
|
||||
},
|
||||
contentHashType: "javascript"
|
||||
});
|
||||
};
|
||||
mainTemplate.hooks.localVars.tap(
|
||||
"JsonpMainTemplatePlugin",
|
||||
(source, chunk, hash) => {
|
||||
const extraCode = [];
|
||||
if (needChunkLoadingCode(chunk)) {
|
||||
extraCode.push(
|
||||
"",
|
||||
"// object to store loaded and loading chunks",
|
||||
"// undefined = chunk not loaded, null = chunk preloaded/prefetched",
|
||||
"// Promise = chunk loading, 0 = chunk loaded",
|
||||
"var installedChunks = {",
|
||||
Template.indent(
|
||||
chunk.ids.map(id => `${JSON.stringify(id)}: 0`).join(",\n")
|
||||
),
|
||||
"};",
|
||||
"",
|
||||
needEntryDeferringCode(chunk)
|
||||
? needPrefetchingCode(chunk)
|
||||
? "var deferredModules = [], deferredPrefetch = [];"
|
||||
: "var deferredModules = [];"
|
||||
: ""
|
||||
);
|
||||
}
|
||||
if (needChunkOnDemandLoadingCode(chunk)) {
|
||||
extraCode.push(
|
||||
"",
|
||||
"// script path function",
|
||||
"function jsonpScriptSrc(chunkId) {",
|
||||
Template.indent([
|
||||
`return ${mainTemplate.requireFn}.p + ${getScriptSrcPath(
|
||||
hash,
|
||||
chunk,
|
||||
"chunkId"
|
||||
)}`
|
||||
]),
|
||||
"}"
|
||||
);
|
||||
}
|
||||
if (extraCode.length === 0) return source;
|
||||
return Template.asString([source, ...extraCode]);
|
||||
}
|
||||
);
|
||||
|
||||
mainTemplate.hooks.jsonpScript.tap(
|
||||
"JsonpMainTemplatePlugin",
|
||||
(_, chunk, hash) => {
|
||||
const crossOriginLoading =
|
||||
mainTemplate.outputOptions.crossOriginLoading;
|
||||
const chunkLoadTimeout = mainTemplate.outputOptions.chunkLoadTimeout;
|
||||
const jsonpScriptType = mainTemplate.outputOptions.jsonpScriptType;
|
||||
|
||||
return Template.asString([
|
||||
"var script = document.createElement('script');",
|
||||
"var onScriptComplete;",
|
||||
jsonpScriptType
|
||||
? `script.type = ${JSON.stringify(jsonpScriptType)};`
|
||||
: "",
|
||||
"script.charset = 'utf-8';",
|
||||
`script.timeout = ${chunkLoadTimeout / 1000};`,
|
||||
`if (${mainTemplate.requireFn}.nc) {`,
|
||||
Template.indent(
|
||||
`script.setAttribute("nonce", ${mainTemplate.requireFn}.nc);`
|
||||
),
|
||||
"}",
|
||||
"script.src = jsonpScriptSrc(chunkId);",
|
||||
crossOriginLoading
|
||||
? Template.asString([
|
||||
"if (script.src.indexOf(window.location.origin + '/') !== 0) {",
|
||||
Template.indent(
|
||||
`script.crossOrigin = ${JSON.stringify(crossOriginLoading)};`
|
||||
),
|
||||
"}"
|
||||
])
|
||||
: "",
|
||||
"// create error before stack unwound to get useful stacktrace later",
|
||||
"var error = new Error();",
|
||||
"onScriptComplete = function (event) {",
|
||||
Template.indent([
|
||||
"// avoid mem leaks in IE.",
|
||||
"script.onerror = script.onload = null;",
|
||||
"clearTimeout(timeout);",
|
||||
"var chunk = installedChunks[chunkId];",
|
||||
"if(chunk !== 0) {",
|
||||
Template.indent([
|
||||
"if(chunk) {",
|
||||
Template.indent([
|
||||
"var errorType = event && (event.type === 'load' ? 'missing' : event.type);",
|
||||
"var realSrc = event && event.target && event.target.src;",
|
||||
"error.message = 'Loading chunk ' + chunkId + ' failed.\\n(' + errorType + ': ' + realSrc + ')';",
|
||||
"error.name = 'ChunkLoadError';",
|
||||
"error.type = errorType;",
|
||||
"error.request = realSrc;",
|
||||
"chunk[1](error);"
|
||||
]),
|
||||
"}",
|
||||
"installedChunks[chunkId] = undefined;"
|
||||
]),
|
||||
"}"
|
||||
]),
|
||||
"};",
|
||||
"var timeout = setTimeout(function(){",
|
||||
Template.indent([
|
||||
"onScriptComplete({ type: 'timeout', target: script });"
|
||||
]),
|
||||
`}, ${chunkLoadTimeout});`,
|
||||
"script.onerror = script.onload = onScriptComplete;"
|
||||
]);
|
||||
}
|
||||
);
|
||||
mainTemplate.hooks.linkPreload.tap(
|
||||
"JsonpMainTemplatePlugin",
|
||||
(_, chunk, hash) => {
|
||||
const crossOriginLoading =
|
||||
mainTemplate.outputOptions.crossOriginLoading;
|
||||
const jsonpScriptType = mainTemplate.outputOptions.jsonpScriptType;
|
||||
|
||||
return Template.asString([
|
||||
"var link = document.createElement('link');",
|
||||
jsonpScriptType
|
||||
? `link.type = ${JSON.stringify(jsonpScriptType)};`
|
||||
: "",
|
||||
"link.charset = 'utf-8';",
|
||||
`if (${mainTemplate.requireFn}.nc) {`,
|
||||
Template.indent(
|
||||
`link.setAttribute("nonce", ${mainTemplate.requireFn}.nc);`
|
||||
),
|
||||
"}",
|
||||
'link.rel = "preload";',
|
||||
'link.as = "script";',
|
||||
"link.href = jsonpScriptSrc(chunkId);",
|
||||
crossOriginLoading
|
||||
? Template.asString([
|
||||
"if (link.href.indexOf(window.location.origin + '/') !== 0) {",
|
||||
Template.indent(
|
||||
`link.crossOrigin = ${JSON.stringify(crossOriginLoading)};`
|
||||
),
|
||||
"}"
|
||||
])
|
||||
: ""
|
||||
]);
|
||||
}
|
||||
);
|
||||
mainTemplate.hooks.linkPrefetch.tap(
|
||||
"JsonpMainTemplatePlugin",
|
||||
(_, chunk, hash) => {
|
||||
const crossOriginLoading =
|
||||
mainTemplate.outputOptions.crossOriginLoading;
|
||||
|
||||
return Template.asString([
|
||||
"var link = document.createElement('link');",
|
||||
crossOriginLoading
|
||||
? `link.crossOrigin = ${JSON.stringify(crossOriginLoading)};`
|
||||
: "",
|
||||
`if (${mainTemplate.requireFn}.nc) {`,
|
||||
Template.indent(
|
||||
`link.setAttribute("nonce", ${mainTemplate.requireFn}.nc);`
|
||||
),
|
||||
"}",
|
||||
'link.rel = "prefetch";',
|
||||
'link.as = "script";',
|
||||
"link.href = jsonpScriptSrc(chunkId);"
|
||||
]);
|
||||
}
|
||||
);
|
||||
mainTemplate.hooks.requireEnsure.tap(
|
||||
"JsonpMainTemplatePlugin load",
|
||||
(source, chunk, hash) => {
|
||||
return Template.asString([
|
||||
source,
|
||||
"",
|
||||
"// JSONP chunk loading for javascript",
|
||||
"",
|
||||
"var installedChunkData = installedChunks[chunkId];",
|
||||
'if(installedChunkData !== 0) { // 0 means "already installed".',
|
||||
Template.indent([
|
||||
"",
|
||||
'// a Promise means "currently loading".',
|
||||
"if(installedChunkData) {",
|
||||
Template.indent(["promises.push(installedChunkData[2]);"]),
|
||||
"} else {",
|
||||
Template.indent([
|
||||
"// setup Promise in chunk cache",
|
||||
"var promise = new Promise(function(resolve, reject) {",
|
||||
Template.indent([
|
||||
"installedChunkData = installedChunks[chunkId] = [resolve, reject];"
|
||||
]),
|
||||
"});",
|
||||
"promises.push(installedChunkData[2] = promise);",
|
||||
"",
|
||||
"// start chunk loading",
|
||||
mainTemplate.hooks.jsonpScript.call("", chunk, hash),
|
||||
"document.head.appendChild(script);"
|
||||
]),
|
||||
"}"
|
||||
]),
|
||||
"}"
|
||||
]);
|
||||
}
|
||||
);
|
||||
mainTemplate.hooks.requireEnsure.tap(
|
||||
{
|
||||
name: "JsonpMainTemplatePlugin preload",
|
||||
stage: 10
|
||||
},
|
||||
(source, chunk, hash) => {
|
||||
const chunkMap = chunk.getChildIdsByOrdersMap().preload;
|
||||
if (!chunkMap || Object.keys(chunkMap).length === 0) return source;
|
||||
return Template.asString([
|
||||
source,
|
||||
"",
|
||||
"// chunk preloadng for javascript",
|
||||
"",
|
||||
`var chunkPreloadMap = ${JSON.stringify(chunkMap, null, "\t")};`,
|
||||
"",
|
||||
"var chunkPreloadData = chunkPreloadMap[chunkId];",
|
||||
"if(chunkPreloadData) {",
|
||||
Template.indent([
|
||||
"chunkPreloadData.forEach(function(chunkId) {",
|
||||
Template.indent([
|
||||
"if(installedChunks[chunkId] === undefined) {",
|
||||
Template.indent([
|
||||
"installedChunks[chunkId] = null;",
|
||||
mainTemplate.hooks.linkPreload.call("", chunk, hash),
|
||||
"document.head.appendChild(link);"
|
||||
]),
|
||||
"}"
|
||||
]),
|
||||
"});"
|
||||
]),
|
||||
"}"
|
||||
]);
|
||||
}
|
||||
);
|
||||
mainTemplate.hooks.requireExtensions.tap(
|
||||
"JsonpMainTemplatePlugin",
|
||||
(source, chunk) => {
|
||||
if (!needChunkOnDemandLoadingCode(chunk)) return source;
|
||||
|
||||
return Template.asString([
|
||||
source,
|
||||
"",
|
||||
"// on error function for async loading",
|
||||
`${mainTemplate.requireFn}.oe = function(err) { console.error(err); throw err; };`
|
||||
]);
|
||||
}
|
||||
);
|
||||
mainTemplate.hooks.bootstrap.tap(
|
||||
"JsonpMainTemplatePlugin",
|
||||
(source, chunk, hash) => {
|
||||
if (needChunkLoadingCode(chunk)) {
|
||||
const withDefer = needEntryDeferringCode(chunk);
|
||||
const withPrefetch = needPrefetchingCode(chunk);
|
||||
return Template.asString([
|
||||
source,
|
||||
"",
|
||||
"// install a JSONP callback for chunk loading",
|
||||
"function webpackJsonpCallback(data) {",
|
||||
Template.indent([
|
||||
"var chunkIds = data[0];",
|
||||
"var moreModules = data[1];",
|
||||
withDefer ? "var executeModules = data[2];" : "",
|
||||
withPrefetch ? "var prefetchChunks = data[3] || [];" : "",
|
||||
'// add "moreModules" to the modules object,',
|
||||
'// then flag all "chunkIds" as loaded and fire callback',
|
||||
"var moduleId, chunkId, i = 0, resolves = [];",
|
||||
"for(;i < chunkIds.length; i++) {",
|
||||
Template.indent([
|
||||
"chunkId = chunkIds[i];",
|
||||
"if(Object.prototype.hasOwnProperty.call(installedChunks, chunkId) && installedChunks[chunkId]) {",
|
||||
Template.indent("resolves.push(installedChunks[chunkId][0]);"),
|
||||
"}",
|
||||
"installedChunks[chunkId] = 0;"
|
||||
]),
|
||||
"}",
|
||||
"for(moduleId in moreModules) {",
|
||||
Template.indent([
|
||||
"if(Object.prototype.hasOwnProperty.call(moreModules, moduleId)) {",
|
||||
Template.indent(
|
||||
mainTemplate.renderAddModule(
|
||||
hash,
|
||||
chunk,
|
||||
"moduleId",
|
||||
"moreModules[moduleId]"
|
||||
)
|
||||
),
|
||||
"}"
|
||||
]),
|
||||
"}",
|
||||
"if(parentJsonpFunction) parentJsonpFunction(data);",
|
||||
withPrefetch
|
||||
? withDefer
|
||||
? "deferredPrefetch.push.apply(deferredPrefetch, prefetchChunks);"
|
||||
: Template.asString([
|
||||
"// chunk prefetching for javascript",
|
||||
"prefetchChunks.forEach(function(chunkId) {",
|
||||
Template.indent([
|
||||
"if(installedChunks[chunkId] === undefined) {",
|
||||
Template.indent([
|
||||
"installedChunks[chunkId] = null;",
|
||||
mainTemplate.hooks.linkPrefetch.call("", chunk, hash),
|
||||
"document.head.appendChild(link);"
|
||||
]),
|
||||
"}"
|
||||
]),
|
||||
"});"
|
||||
])
|
||||
: "",
|
||||
"while(resolves.length) {",
|
||||
Template.indent("resolves.shift()();"),
|
||||
"}",
|
||||
withDefer
|
||||
? Template.asString([
|
||||
"",
|
||||
"// add entry modules from loaded chunk to deferred list",
|
||||
"deferredModules.push.apply(deferredModules, executeModules || []);",
|
||||
"",
|
||||
"// run deferred modules when all chunks ready",
|
||||
"return checkDeferredModules();"
|
||||
])
|
||||
: ""
|
||||
]),
|
||||
"};",
|
||||
withDefer
|
||||
? Template.asString([
|
||||
"function checkDeferredModules() {",
|
||||
Template.indent([
|
||||
"var result;",
|
||||
"for(var i = 0; i < deferredModules.length; i++) {",
|
||||
Template.indent([
|
||||
"var deferredModule = deferredModules[i];",
|
||||
"var fulfilled = true;",
|
||||
"for(var j = 1; j < deferredModule.length; j++) {",
|
||||
Template.indent([
|
||||
"var depId = deferredModule[j];",
|
||||
"if(installedChunks[depId] !== 0) fulfilled = false;"
|
||||
]),
|
||||
"}",
|
||||
"if(fulfilled) {",
|
||||
Template.indent([
|
||||
"deferredModules.splice(i--, 1);",
|
||||
"result = " +
|
||||
mainTemplate.requireFn +
|
||||
"(" +
|
||||
mainTemplate.requireFn +
|
||||
".s = deferredModule[0]);"
|
||||
]),
|
||||
"}"
|
||||
]),
|
||||
"}",
|
||||
withPrefetch
|
||||
? Template.asString([
|
||||
"if(deferredModules.length === 0) {",
|
||||
Template.indent([
|
||||
"// chunk prefetching for javascript",
|
||||
"deferredPrefetch.forEach(function(chunkId) {",
|
||||
Template.indent([
|
||||
"if(installedChunks[chunkId] === undefined) {",
|
||||
Template.indent([
|
||||
"installedChunks[chunkId] = null;",
|
||||
mainTemplate.hooks.linkPrefetch.call(
|
||||
"",
|
||||
chunk,
|
||||
hash
|
||||
),
|
||||
"document.head.appendChild(link);"
|
||||
]),
|
||||
"}"
|
||||
]),
|
||||
"});",
|
||||
"deferredPrefetch.length = 0;"
|
||||
]),
|
||||
"}"
|
||||
])
|
||||
: "",
|
||||
"return result;"
|
||||
]),
|
||||
"}"
|
||||
])
|
||||
: ""
|
||||
]);
|
||||
}
|
||||
return source;
|
||||
}
|
||||
);
|
||||
mainTemplate.hooks.beforeStartup.tap(
|
||||
"JsonpMainTemplatePlugin",
|
||||
(source, chunk, hash) => {
|
||||
if (needChunkLoadingCode(chunk)) {
|
||||
var jsonpFunction = mainTemplate.outputOptions.jsonpFunction;
|
||||
var globalObject = mainTemplate.outputOptions.globalObject;
|
||||
return Template.asString([
|
||||
`var jsonpArray = ${globalObject}[${JSON.stringify(
|
||||
jsonpFunction
|
||||
)}] = ${globalObject}[${JSON.stringify(jsonpFunction)}] || [];`,
|
||||
"var oldJsonpFunction = jsonpArray.push.bind(jsonpArray);",
|
||||
"jsonpArray.push = webpackJsonpCallback;",
|
||||
"jsonpArray = jsonpArray.slice();",
|
||||
"for(var i = 0; i < jsonpArray.length; i++) webpackJsonpCallback(jsonpArray[i]);",
|
||||
"var parentJsonpFunction = oldJsonpFunction;",
|
||||
"",
|
||||
source
|
||||
]);
|
||||
}
|
||||
return source;
|
||||
}
|
||||
);
|
||||
mainTemplate.hooks.afterStartup.tap(
|
||||
"JsonpMainTemplatePlugin",
|
||||
(source, chunk, hash) => {
|
||||
const prefetchChunks = chunk.getChildIdsByOrders().prefetch;
|
||||
if (
|
||||
needChunkLoadingCode(chunk) &&
|
||||
prefetchChunks &&
|
||||
prefetchChunks.length
|
||||
) {
|
||||
return Template.asString([
|
||||
source,
|
||||
`webpackJsonpCallback([[], {}, 0, ${JSON.stringify(
|
||||
prefetchChunks
|
||||
)}]);`
|
||||
]);
|
||||
}
|
||||
return source;
|
||||
}
|
||||
);
|
||||
mainTemplate.hooks.startup.tap(
|
||||
"JsonpMainTemplatePlugin",
|
||||
(source, chunk, hash) => {
|
||||
if (needEntryDeferringCode(chunk)) {
|
||||
if (chunk.hasEntryModule()) {
|
||||
const entries = [chunk.entryModule].filter(Boolean).map(m =>
|
||||
[m.id].concat(
|
||||
Array.from(chunk.groupsIterable)[0]
|
||||
.chunks.filter(c => c !== chunk)
|
||||
.map(c => c.id)
|
||||
)
|
||||
);
|
||||
return Template.asString([
|
||||
"// add entry module to deferred list",
|
||||
`deferredModules.push(${entries
|
||||
.map(e => JSON.stringify(e))
|
||||
.join(", ")});`,
|
||||
"// run deferred modules when ready",
|
||||
"return checkDeferredModules();"
|
||||
]);
|
||||
} else {
|
||||
return Template.asString([
|
||||
"// run deferred modules from other chunks",
|
||||
"checkDeferredModules();"
|
||||
]);
|
||||
}
|
||||
}
|
||||
return source;
|
||||
}
|
||||
);
|
||||
mainTemplate.hooks.hotBootstrap.tap(
|
||||
"JsonpMainTemplatePlugin",
|
||||
(source, chunk, hash) => {
|
||||
const globalObject = mainTemplate.outputOptions.globalObject;
|
||||
const hotUpdateChunkFilename =
|
||||
mainTemplate.outputOptions.hotUpdateChunkFilename;
|
||||
const hotUpdateMainFilename =
|
||||
mainTemplate.outputOptions.hotUpdateMainFilename;
|
||||
const crossOriginLoading =
|
||||
mainTemplate.outputOptions.crossOriginLoading;
|
||||
const hotUpdateFunction = mainTemplate.outputOptions.hotUpdateFunction;
|
||||
const currentHotUpdateChunkFilename = mainTemplate.getAssetPath(
|
||||
JSON.stringify(hotUpdateChunkFilename),
|
||||
{
|
||||
hash: `" + ${mainTemplate.renderCurrentHashCode(hash)} + "`,
|
||||
hashWithLength: length =>
|
||||
`" + ${mainTemplate.renderCurrentHashCode(hash, length)} + "`,
|
||||
chunk: {
|
||||
id: '" + chunkId + "'
|
||||
}
|
||||
}
|
||||
);
|
||||
const currentHotUpdateMainFilename = mainTemplate.getAssetPath(
|
||||
JSON.stringify(hotUpdateMainFilename),
|
||||
{
|
||||
hash: `" + ${mainTemplate.renderCurrentHashCode(hash)} + "`,
|
||||
hashWithLength: length =>
|
||||
`" + ${mainTemplate.renderCurrentHashCode(hash, length)} + "`
|
||||
}
|
||||
);
|
||||
const runtimeSource = Template.getFunctionContent(
|
||||
require("./JsonpMainTemplate.runtime")
|
||||
)
|
||||
.replace(/\/\/\$semicolon/g, ";")
|
||||
.replace(/\$require\$/g, mainTemplate.requireFn)
|
||||
.replace(
|
||||
/\$crossOriginLoading\$/g,
|
||||
crossOriginLoading ? JSON.stringify(crossOriginLoading) : "null"
|
||||
)
|
||||
.replace(/\$hotMainFilename\$/g, currentHotUpdateMainFilename)
|
||||
.replace(/\$hotChunkFilename\$/g, currentHotUpdateChunkFilename)
|
||||
.replace(/\$hash\$/g, JSON.stringify(hash));
|
||||
return `${source}
|
||||
function hotDisposeChunk(chunkId) {
|
||||
delete installedChunks[chunkId];
|
||||
}
|
||||
var parentHotUpdateCallback = ${globalObject}[${JSON.stringify(
|
||||
hotUpdateFunction
|
||||
)}];
|
||||
${globalObject}[${JSON.stringify(hotUpdateFunction)}] = ${runtimeSource}`;
|
||||
}
|
||||
);
|
||||
mainTemplate.hooks.hash.tap("JsonpMainTemplatePlugin", hash => {
|
||||
hash.update("jsonp");
|
||||
hash.update("6");
|
||||
});
|
||||
}
|
||||
}
|
||||
module.exports = JsonpMainTemplatePlugin;
|
||||
23
node_modules/webpack/lib/web/JsonpTemplatePlugin.js
generated
vendored
Normal file
23
node_modules/webpack/lib/web/JsonpTemplatePlugin.js
generated
vendored
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Tobias Koppers @sokra
|
||||
*/
|
||||
"use strict";
|
||||
|
||||
const JsonpMainTemplatePlugin = require("./JsonpMainTemplatePlugin");
|
||||
const JsonpChunkTemplatePlugin = require("./JsonpChunkTemplatePlugin");
|
||||
const JsonpHotUpdateChunkTemplatePlugin = require("./JsonpHotUpdateChunkTemplatePlugin");
|
||||
|
||||
class JsonpTemplatePlugin {
|
||||
apply(compiler) {
|
||||
compiler.hooks.thisCompilation.tap("JsonpTemplatePlugin", compilation => {
|
||||
new JsonpMainTemplatePlugin().apply(compilation.mainTemplate);
|
||||
new JsonpChunkTemplatePlugin().apply(compilation.chunkTemplate);
|
||||
new JsonpHotUpdateChunkTemplatePlugin().apply(
|
||||
compilation.hotUpdateChunkTemplate
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = JsonpTemplatePlugin;
|
||||
18
node_modules/webpack/lib/web/WebEnvironmentPlugin.js
generated
vendored
Normal file
18
node_modules/webpack/lib/web/WebEnvironmentPlugin.js
generated
vendored
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Tobias Koppers @sokra
|
||||
*/
|
||||
"use strict";
|
||||
|
||||
class WebEnvironmentPlugin {
|
||||
constructor(inputFileSystem, outputFileSystem) {
|
||||
this.inputFileSystem = inputFileSystem;
|
||||
this.outputFileSystem = outputFileSystem;
|
||||
}
|
||||
|
||||
apply(compiler) {
|
||||
compiler.outputFileSystem = this.outputFileSystem;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = WebEnvironmentPlugin;
|
||||
Loading…
Add table
Add a link
Reference in a new issue