nav tabs on admin dashboard
This commit is contained in:
24
node_modules/webpack/lib/node/NodeChunkTemplatePlugin.js
generated
vendored
24
node_modules/webpack/lib/node/NodeChunkTemplatePlugin.js
generated
vendored
@@ -5,19 +5,23 @@
|
||||
|
||||
"use strict";
|
||||
|
||||
const ConcatSource = require("webpack-sources").ConcatSource;
|
||||
const { ConcatSource } = require("webpack-sources");
|
||||
|
||||
class NodeChunkTemplatePlugin {
|
||||
|
||||
apply(chunkTemplate) {
|
||||
chunkTemplate.plugin("render", function(modules, chunk) {
|
||||
const source = new ConcatSource();
|
||||
source.add(`exports.ids = ${JSON.stringify(chunk.ids)};\nexports.modules = `);
|
||||
source.add(modules);
|
||||
source.add(";");
|
||||
return source;
|
||||
});
|
||||
chunkTemplate.plugin("hash", function(hash) {
|
||||
chunkTemplate.hooks.render.tap(
|
||||
"NodeChunkTemplatePlugin",
|
||||
(modules, chunk) => {
|
||||
const source = new ConcatSource();
|
||||
source.add(
|
||||
`exports.ids = ${JSON.stringify(chunk.ids)};\nexports.modules = `
|
||||
);
|
||||
source.add(modules);
|
||||
source.add(";");
|
||||
return source;
|
||||
}
|
||||
);
|
||||
chunkTemplate.hooks.hash.tap("NodeChunkTemplatePlugin", hash => {
|
||||
hash.update("node");
|
||||
hash.update("3");
|
||||
});
|
||||
|
||||
15
node_modules/webpack/lib/node/NodeEnvironmentPlugin.js
generated
vendored
15
node_modules/webpack/lib/node/NodeEnvironmentPlugin.js
generated
vendored
@@ -11,14 +11,17 @@ const CachedInputFileSystem = require("enhanced-resolve/lib/CachedInputFileSyste
|
||||
|
||||
class NodeEnvironmentPlugin {
|
||||
apply(compiler) {
|
||||
compiler.inputFileSystem = new CachedInputFileSystem(new NodeJsInputFileSystem(), 60000);
|
||||
compiler.inputFileSystem = new CachedInputFileSystem(
|
||||
new NodeJsInputFileSystem(),
|
||||
60000
|
||||
);
|
||||
const inputFileSystem = compiler.inputFileSystem;
|
||||
compiler.outputFileSystem = new NodeOutputFileSystem();
|
||||
compiler.watchFileSystem = new NodeWatchFileSystem(compiler.inputFileSystem);
|
||||
compiler.plugin("before-run", (compiler, callback) => {
|
||||
if(compiler.inputFileSystem === inputFileSystem)
|
||||
inputFileSystem.purge();
|
||||
callback();
|
||||
compiler.watchFileSystem = new NodeWatchFileSystem(
|
||||
compiler.inputFileSystem
|
||||
);
|
||||
compiler.hooks.beforeRun.tap("NodeEnvironmentPlugin", compiler => {
|
||||
if (compiler.inputFileSystem === inputFileSystem) inputFileSystem.purge();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
39
node_modules/webpack/lib/node/NodeHotUpdateChunkTemplatePlugin.js
generated
vendored
39
node_modules/webpack/lib/node/NodeHotUpdateChunkTemplatePlugin.js
generated
vendored
@@ -4,24 +4,33 @@
|
||||
*/
|
||||
"use strict";
|
||||
|
||||
const ConcatSource = require("webpack-sources").ConcatSource;
|
||||
const { ConcatSource } = require("webpack-sources");
|
||||
|
||||
class NodeHotUpdateChunkTemplatePlugin {
|
||||
|
||||
apply(hotUpdateChunkTemplate) {
|
||||
hotUpdateChunkTemplate.plugin("render", (modulesSource, modules, removedModules, hash, id) => {
|
||||
const source = new ConcatSource();
|
||||
source.add("exports.id = " + JSON.stringify(id) + ";\nexports.modules = ");
|
||||
source.add(modulesSource);
|
||||
source.add(";");
|
||||
return source;
|
||||
});
|
||||
hotUpdateChunkTemplate.plugin("hash", function(hash) {
|
||||
hash.update("NodeHotUpdateChunkTemplatePlugin");
|
||||
hash.update("3");
|
||||
hash.update(this.outputOptions.hotUpdateFunction + "");
|
||||
hash.update(this.outputOptions.library + "");
|
||||
});
|
||||
hotUpdateChunkTemplate.hooks.render.tap(
|
||||
"NodeHotUpdateChunkTemplatePlugin",
|
||||
(modulesSource, modules, removedModules, hash, id) => {
|
||||
const source = new ConcatSource();
|
||||
source.add(
|
||||
"exports.id = " + JSON.stringify(id) + ";\nexports.modules = "
|
||||
);
|
||||
source.add(modulesSource);
|
||||
source.add(";");
|
||||
return source;
|
||||
}
|
||||
);
|
||||
hotUpdateChunkTemplate.hooks.hash.tap(
|
||||
"NodeHotUpdateChunkTemplatePlugin",
|
||||
hash => {
|
||||
hash.update("NodeHotUpdateChunkTemplatePlugin");
|
||||
hash.update("3");
|
||||
hash.update(
|
||||
hotUpdateChunkTemplate.outputOptions.hotUpdateFunction + ""
|
||||
);
|
||||
hash.update(hotUpdateChunkTemplate.outputOptions.library + "");
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
module.exports = NodeHotUpdateChunkTemplatePlugin;
|
||||
|
||||
11
node_modules/webpack/lib/node/NodeMainTemplate.runtime.js
generated
vendored
11
node_modules/webpack/lib/node/NodeMainTemplate.runtime.js
generated
vendored
@@ -4,21 +4,24 @@
|
||||
*/
|
||||
/*global installedChunks $hotChunkFilename$ hotAddUpdateChunk $hotMainFilename$ */
|
||||
module.exports = function() {
|
||||
function hotDownloadUpdateChunk(chunkId) { // eslint-disable-line no-unused-vars
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
function hotDownloadUpdateChunk(chunkId) {
|
||||
var chunk = require("./" + $hotChunkFilename$);
|
||||
hotAddUpdateChunk(chunk.id, chunk.modules);
|
||||
}
|
||||
|
||||
function hotDownloadManifest() { // eslint-disable-line no-unused-vars
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
function hotDownloadManifest() {
|
||||
try {
|
||||
var update = require("./" + $hotMainFilename$);
|
||||
} catch(e) {
|
||||
} catch (e) {
|
||||
return Promise.resolve();
|
||||
}
|
||||
return Promise.resolve(update);
|
||||
}
|
||||
|
||||
function hotDisposeChunk(chunkId) { //eslint-disable-line no-unused-vars
|
||||
//eslint-disable-next-line no-unused-vars
|
||||
function hotDisposeChunk(chunkId) {
|
||||
delete installedChunks[chunkId];
|
||||
}
|
||||
};
|
||||
|
||||
26
node_modules/webpack/lib/node/NodeMainTemplateAsync.runtime.js
generated
vendored
26
node_modules/webpack/lib/node/NodeMainTemplateAsync.runtime.js
generated
vendored
@@ -4,29 +4,32 @@
|
||||
*/
|
||||
/*global installedChunks $hotChunkFilename$ $require$ hotAddUpdateChunk $hotMainFilename$ */
|
||||
module.exports = function() {
|
||||
function hotDownloadUpdateChunk(chunkId) { // eslint-disable-line no-unused-vars
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
function hotDownloadUpdateChunk(chunkId) {
|
||||
var filename = require("path").join(__dirname, $hotChunkFilename$);
|
||||
require("fs").readFile(filename, "utf-8", function(err, content) {
|
||||
if(err) {
|
||||
if($require$.onError)
|
||||
return $require$.oe(err);
|
||||
else
|
||||
throw err;
|
||||
if (err) {
|
||||
if ($require$.onError) return $require$.oe(err);
|
||||
throw err;
|
||||
}
|
||||
var chunk = {};
|
||||
require("vm").runInThisContext("(function(exports) {" + content + "\n})", filename)(chunk);
|
||||
require("vm").runInThisContext(
|
||||
"(function(exports) {" + content + "\n})",
|
||||
{ filename: filename }
|
||||
)(chunk);
|
||||
hotAddUpdateChunk(chunk.id, chunk.modules);
|
||||
});
|
||||
}
|
||||
|
||||
function hotDownloadManifest() { // eslint-disable-line no-unused-vars
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
function hotDownloadManifest() {
|
||||
var filename = require("path").join(__dirname, $hotMainFilename$);
|
||||
return new Promise(function(resolve, reject) {
|
||||
require("fs").readFile(filename, "utf-8", function(err, content) {
|
||||
if(err) return resolve();
|
||||
if (err) return resolve();
|
||||
try {
|
||||
var update = JSON.parse(content);
|
||||
} catch(e) {
|
||||
} catch (e) {
|
||||
return reject(e);
|
||||
}
|
||||
resolve(update);
|
||||
@@ -34,7 +37,8 @@ module.exports = function() {
|
||||
});
|
||||
}
|
||||
|
||||
function hotDisposeChunk(chunkId) { //eslint-disable-line no-unused-vars
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
function hotDisposeChunk(chunkId) {
|
||||
delete installedChunks[chunkId];
|
||||
}
|
||||
};
|
||||
|
||||
464
node_modules/webpack/lib/node/NodeMainTemplatePlugin.js
generated
vendored
464
node_modules/webpack/lib/node/NodeMainTemplatePlugin.js
generated
vendored
@@ -12,172 +12,310 @@ module.exports = class NodeMainTemplatePlugin {
|
||||
}
|
||||
|
||||
apply(mainTemplate) {
|
||||
const needChunkOnDemandLoadingCode = chunk => {
|
||||
for (const chunkGroup of chunk.groupsIterable) {
|
||||
if (chunkGroup.getNumberOfChildren() > 0) return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
const asyncChunkLoading = this.asyncChunkLoading;
|
||||
mainTemplate.plugin("local-vars", function(source, chunk) {
|
||||
if(chunk.chunks.length > 0) {
|
||||
return this.asString([
|
||||
source,
|
||||
"",
|
||||
"// object to store loaded chunks",
|
||||
"// \"0\" means \"already loaded\"",
|
||||
"var installedChunks = {",
|
||||
this.indent(chunk.ids.map((id) => `${id}: 0`).join(",\n")),
|
||||
"};"
|
||||
]);
|
||||
}
|
||||
return source;
|
||||
});
|
||||
mainTemplate.plugin("require-extensions", function(source, chunk) {
|
||||
if(chunk.chunks.length > 0) {
|
||||
return this.asString([
|
||||
source,
|
||||
"",
|
||||
"// uncatched error handler for webpack runtime",
|
||||
`${this.requireFn}.oe = function(err) {`,
|
||||
this.indent([
|
||||
"process.nextTick(function() {",
|
||||
this.indent("throw err; // catch this error by using System.import().catch()"),
|
||||
"});"
|
||||
]),
|
||||
"};"
|
||||
]);
|
||||
}
|
||||
return source;
|
||||
});
|
||||
mainTemplate.plugin("require-ensure", function(_, chunk, hash) {
|
||||
const chunkFilename = this.outputOptions.chunkFilename;
|
||||
const chunkMaps = chunk.getChunkMaps();
|
||||
const insertMoreModules = [
|
||||
"var moreModules = chunk.modules, chunkIds = chunk.ids;",
|
||||
"for(var moduleId in moreModules) {",
|
||||
this.indent(this.renderAddModule(hash, chunk, "moduleId", "moreModules[moduleId]")),
|
||||
"}"
|
||||
];
|
||||
if(asyncChunkLoading) {
|
||||
return this.asString([
|
||||
"// \"0\" is the signal for \"already loaded\"",
|
||||
"if(installedChunks[chunkId] === 0)",
|
||||
this.indent([
|
||||
"return Promise.resolve();"
|
||||
]),
|
||||
"// array of [resolve, reject, promise] means \"currently loading\"",
|
||||
"if(installedChunks[chunkId])",
|
||||
this.indent([
|
||||
"return installedChunks[chunkId][2];"
|
||||
]),
|
||||
"// load the chunk and return promise to it",
|
||||
"var promise = new Promise(function(resolve, reject) {",
|
||||
this.indent([
|
||||
"installedChunks[chunkId] = [resolve, reject];",
|
||||
"var filename = __dirname + " + this.applyPluginsWaterfall("asset-path", JSON.stringify(`/${chunkFilename}`), {
|
||||
hash: `" + ${this.renderCurrentHashCode(hash)} + "`,
|
||||
hashWithLength: (length) => `" + ${this.renderCurrentHashCode(hash, length)} + "`,
|
||||
chunk: {
|
||||
id: "\" + chunkId + \"",
|
||||
hash: `" + ${JSON.stringify(chunkMaps.hash)}[chunkId] + "`,
|
||||
hashWithLength: (length) => {
|
||||
const shortChunkHashMap = {};
|
||||
Object.keys(chunkMaps.hash).forEach((chunkId) => {
|
||||
if(typeof chunkMaps.hash[chunkId] === "string")
|
||||
shortChunkHashMap[chunkId] = chunkMaps.hash[chunkId].substr(0, length);
|
||||
});
|
||||
return `" + ${JSON.stringify(shortChunkHashMap)}[chunkId] + "`;
|
||||
},
|
||||
name: `" + (${JSON.stringify(chunkMaps.name)}[chunkId]||chunkId) + "`
|
||||
}
|
||||
}) + ";",
|
||||
"require('fs').readFile(filename, 'utf-8', function(err, content) {",
|
||||
this.indent([
|
||||
"if(err) return reject(err);",
|
||||
"var chunk = {};",
|
||||
"require('vm').runInThisContext('(function(exports, require, __dirname, __filename) {' + content + '\\n})', filename)" +
|
||||
"(chunk, require, require('path').dirname(filename), filename);"
|
||||
].concat(insertMoreModules).concat([
|
||||
"var callbacks = [];",
|
||||
"for(var i = 0; i < chunkIds.length; i++) {",
|
||||
this.indent([
|
||||
"if(installedChunks[chunkIds[i]])",
|
||||
this.indent([
|
||||
"callbacks = callbacks.concat(installedChunks[chunkIds[i]][0]);"
|
||||
]),
|
||||
"installedChunks[chunkIds[i]] = 0;"
|
||||
]),
|
||||
"}",
|
||||
"for(i = 0; i < callbacks.length; i++)",
|
||||
this.indent("callbacks[i]();")
|
||||
])),
|
||||
"});"
|
||||
]),
|
||||
"});",
|
||||
"return installedChunks[chunkId][2] = promise;"
|
||||
]);
|
||||
} else {
|
||||
const request = this.applyPluginsWaterfall("asset-path", JSON.stringify(`./${chunkFilename}`), {
|
||||
hash: `" + ${this.renderCurrentHashCode(hash)} + "`,
|
||||
hashWithLength: (length) => `" + ${this.renderCurrentHashCode(hash, length)} + "`,
|
||||
chunk: {
|
||||
id: "\" + chunkId + \"",
|
||||
hash: `" + ${JSON.stringify(chunkMaps.hash)}[chunkId] + "`,
|
||||
hashWithLength: (length) => {
|
||||
const shortChunkHashMap = {};
|
||||
Object.keys(chunkMaps.hash).forEach((chunkId) => {
|
||||
if(typeof chunkMaps.hash[chunkId] === "string")
|
||||
shortChunkHashMap[chunkId] = chunkMaps.hash[chunkId].substr(0, length);
|
||||
});
|
||||
return `" + ${JSON.stringify(shortChunkHashMap)}[chunkId] + "`;
|
||||
},
|
||||
name: `" + (${JSON.stringify(chunkMaps.name)}[chunkId]||chunkId) + "`
|
||||
}
|
||||
});
|
||||
return this.asString([
|
||||
"// \"0\" is the signal for \"already loaded\"",
|
||||
"if(installedChunks[chunkId] !== 0) {",
|
||||
this.indent([
|
||||
`var chunk = require(${request});`
|
||||
].concat(insertMoreModules).concat([
|
||||
"for(var i = 0; i < chunkIds.length; i++)",
|
||||
this.indent("installedChunks[chunkIds[i]] = 0;")
|
||||
])),
|
||||
"}",
|
||||
"return Promise.resolve();"
|
||||
]);
|
||||
}
|
||||
});
|
||||
mainTemplate.plugin("hot-bootstrap", function(source, chunk, hash) {
|
||||
const hotUpdateChunkFilename = this.outputOptions.hotUpdateChunkFilename;
|
||||
const hotUpdateMainFilename = this.outputOptions.hotUpdateMainFilename;
|
||||
const chunkMaps = chunk.getChunkMaps();
|
||||
const currentHotUpdateChunkFilename = this.applyPluginsWaterfall("asset-path", JSON.stringify(hotUpdateChunkFilename), {
|
||||
hash: `" + ${this.renderCurrentHashCode(hash)} + "`,
|
||||
hashWithLength: (length) => `" + ${this.renderCurrentHashCode(hash, length)} + "`,
|
||||
chunk: {
|
||||
id: "\" + chunkId + \"",
|
||||
hash: `" + ${JSON.stringify(chunkMaps.hash)}[chunkId] + "`,
|
||||
hashWithLength: (length) => {
|
||||
const shortChunkHashMap = {};
|
||||
Object.keys(chunkMaps.hash).forEach((chunkId) => {
|
||||
if(typeof chunkMaps.hash[chunkId] === "string")
|
||||
shortChunkHashMap[chunkId] = chunkMaps.hash[chunkId].substr(0, length);
|
||||
});
|
||||
return `" + ${JSON.stringify(shortChunkHashMap)}[chunkId] + "`;
|
||||
},
|
||||
name: `" + (${JSON.stringify(chunkMaps.name)}[chunkId]||chunkId) + "`
|
||||
mainTemplate.hooks.localVars.tap(
|
||||
"NodeMainTemplatePlugin",
|
||||
(source, chunk) => {
|
||||
if (needChunkOnDemandLoadingCode(chunk)) {
|
||||
return Template.asString([
|
||||
source,
|
||||
"",
|
||||
"// object to store loaded chunks",
|
||||
'// "0" means "already loaded"',
|
||||
"var installedChunks = {",
|
||||
Template.indent(
|
||||
chunk.ids.map(id => `${JSON.stringify(id)}: 0`).join(",\n")
|
||||
),
|
||||
"};"
|
||||
]);
|
||||
}
|
||||
});
|
||||
const currentHotUpdateMainFilename = this.applyPluginsWaterfall("asset-path", JSON.stringify(hotUpdateMainFilename), {
|
||||
hash: `" + ${this.renderCurrentHashCode(hash)} + "`,
|
||||
hashWithLength: (length) => `" + ${this.renderCurrentHashCode(hash, length)} + "`
|
||||
});
|
||||
return Template.getFunctionContent(asyncChunkLoading ? require("./NodeMainTemplateAsync.runtime.js") : require("./NodeMainTemplate.runtime.js"))
|
||||
.replace(/\$require\$/g, this.requireFn)
|
||||
.replace(/\$hotMainFilename\$/g, currentHotUpdateMainFilename)
|
||||
.replace(/\$hotChunkFilename\$/g, currentHotUpdateChunkFilename);
|
||||
});
|
||||
mainTemplate.plugin("hash", function(hash) {
|
||||
return source;
|
||||
}
|
||||
);
|
||||
mainTemplate.hooks.requireExtensions.tap(
|
||||
"NodeMainTemplatePlugin",
|
||||
(source, chunk) => {
|
||||
if (needChunkOnDemandLoadingCode(chunk)) {
|
||||
return Template.asString([
|
||||
source,
|
||||
"",
|
||||
"// uncaught error handler for webpack runtime",
|
||||
`${mainTemplate.requireFn}.oe = function(err) {`,
|
||||
Template.indent([
|
||||
"process.nextTick(function() {",
|
||||
Template.indent(
|
||||
"throw err; // catch this error by using import().catch()"
|
||||
),
|
||||
"});"
|
||||
]),
|
||||
"};"
|
||||
]);
|
||||
}
|
||||
return source;
|
||||
}
|
||||
);
|
||||
mainTemplate.hooks.requireEnsure.tap(
|
||||
"NodeMainTemplatePlugin",
|
||||
(source, chunk, hash) => {
|
||||
const chunkFilename = mainTemplate.outputOptions.chunkFilename;
|
||||
const chunkMaps = chunk.getChunkMaps();
|
||||
const insertMoreModules = [
|
||||
"var moreModules = chunk.modules, chunkIds = chunk.ids;",
|
||||
"for(var moduleId in moreModules) {",
|
||||
Template.indent(
|
||||
mainTemplate.renderAddModule(
|
||||
hash,
|
||||
chunk,
|
||||
"moduleId",
|
||||
"moreModules[moduleId]"
|
||||
)
|
||||
),
|
||||
"}"
|
||||
];
|
||||
if (asyncChunkLoading) {
|
||||
return Template.asString([
|
||||
source,
|
||||
"",
|
||||
"// ReadFile + VM.run chunk loading for javascript",
|
||||
"",
|
||||
"var installedChunkData = installedChunks[chunkId];",
|
||||
'if(installedChunkData !== 0) { // 0 means "already installed".',
|
||||
Template.indent([
|
||||
'// array of [resolve, reject, promise] means "currently loading"',
|
||||
"if(installedChunkData) {",
|
||||
Template.indent(["promises.push(installedChunkData[2]);"]),
|
||||
"} else {",
|
||||
Template.indent([
|
||||
"// load the chunk and return promise to it",
|
||||
"var promise = new Promise(function(resolve, reject) {",
|
||||
Template.indent([
|
||||
"installedChunkData = installedChunks[chunkId] = [resolve, reject];",
|
||||
"var filename = require('path').join(__dirname, " +
|
||||
mainTemplate.getAssetPath(
|
||||
JSON.stringify(`/${chunkFilename}`),
|
||||
{
|
||||
hash: `" + ${mainTemplate.renderCurrentHashCode(
|
||||
hash
|
||||
)} + "`,
|
||||
hashWithLength: length =>
|
||||
`" + ${mainTemplate.renderCurrentHashCode(
|
||||
hash,
|
||||
length
|
||||
)} + "`,
|
||||
chunk: {
|
||||
id: '" + chunkId + "',
|
||||
hash: `" + ${JSON.stringify(
|
||||
chunkMaps.hash
|
||||
)}[chunkId] + "`,
|
||||
hashWithLength: length => {
|
||||
const shortChunkHashMap = {};
|
||||
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
|
||||
)}[chunkId] + "`;
|
||||
},
|
||||
contentHash: {
|
||||
javascript: `" + ${JSON.stringify(
|
||||
chunkMaps.contentHash.javascript
|
||||
)}[chunkId] + "`
|
||||
},
|
||||
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
|
||||
)}[chunkId] + "`;
|
||||
}
|
||||
},
|
||||
name: `" + (${JSON.stringify(
|
||||
chunkMaps.name
|
||||
)}[chunkId]||chunkId) + "`
|
||||
},
|
||||
contentHashType: "javascript"
|
||||
}
|
||||
) +
|
||||
");",
|
||||
"require('fs').readFile(filename, 'utf-8', function(err, content) {",
|
||||
Template.indent(
|
||||
[
|
||||
"if(err) return reject(err);",
|
||||
"var chunk = {};",
|
||||
"require('vm').runInThisContext('(function(exports, require, __dirname, __filename) {' + content + '\\n})', filename)" +
|
||||
"(chunk, require, require('path').dirname(filename), filename);"
|
||||
]
|
||||
.concat(insertMoreModules)
|
||||
.concat([
|
||||
"var callbacks = [];",
|
||||
"for(var i = 0; i < chunkIds.length; i++) {",
|
||||
Template.indent([
|
||||
"if(installedChunks[chunkIds[i]])",
|
||||
Template.indent([
|
||||
"callbacks = callbacks.concat(installedChunks[chunkIds[i]][0]);"
|
||||
]),
|
||||
"installedChunks[chunkIds[i]] = 0;"
|
||||
]),
|
||||
"}",
|
||||
"for(i = 0; i < callbacks.length; i++)",
|
||||
Template.indent("callbacks[i]();")
|
||||
])
|
||||
),
|
||||
"});"
|
||||
]),
|
||||
"});",
|
||||
"promises.push(installedChunkData[2] = promise);"
|
||||
]),
|
||||
"}"
|
||||
]),
|
||||
"}"
|
||||
]);
|
||||
} else {
|
||||
const request = mainTemplate.getAssetPath(
|
||||
JSON.stringify(`./${chunkFilename}`),
|
||||
{
|
||||
hash: `" + ${mainTemplate.renderCurrentHashCode(hash)} + "`,
|
||||
hashWithLength: length =>
|
||||
`" + ${mainTemplate.renderCurrentHashCode(hash, length)} + "`,
|
||||
chunk: {
|
||||
id: '" + chunkId + "',
|
||||
hash: `" + ${JSON.stringify(chunkMaps.hash)}[chunkId] + "`,
|
||||
hashWithLength: length => {
|
||||
const shortChunkHashMap = {};
|
||||
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
|
||||
)}[chunkId] + "`;
|
||||
},
|
||||
contentHash: {
|
||||
javascript: `" + ${JSON.stringify(
|
||||
chunkMaps.contentHash.javascript
|
||||
)}[chunkId] + "`
|
||||
},
|
||||
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
|
||||
)}[chunkId] + "`;
|
||||
}
|
||||
},
|
||||
name: `" + (${JSON.stringify(
|
||||
chunkMaps.name
|
||||
)}[chunkId]||chunkId) + "`
|
||||
},
|
||||
contentHashType: "javascript"
|
||||
}
|
||||
);
|
||||
return Template.asString([
|
||||
source,
|
||||
"",
|
||||
"// require() chunk loading for javascript",
|
||||
"",
|
||||
'// "0" is the signal for "already loaded"',
|
||||
"if(installedChunks[chunkId] !== 0) {",
|
||||
Template.indent(
|
||||
[`var chunk = require(${request});`]
|
||||
.concat(insertMoreModules)
|
||||
.concat([
|
||||
"for(var i = 0; i < chunkIds.length; i++)",
|
||||
Template.indent("installedChunks[chunkIds[i]] = 0;")
|
||||
])
|
||||
),
|
||||
"}"
|
||||
]);
|
||||
}
|
||||
}
|
||||
);
|
||||
mainTemplate.hooks.hotBootstrap.tap(
|
||||
"NodeMainTemplatePlugin",
|
||||
(source, chunk, hash) => {
|
||||
const hotUpdateChunkFilename =
|
||||
mainTemplate.outputOptions.hotUpdateChunkFilename;
|
||||
const hotUpdateMainFilename =
|
||||
mainTemplate.outputOptions.hotUpdateMainFilename;
|
||||
const chunkMaps = chunk.getChunkMaps();
|
||||
const currentHotUpdateChunkFilename = mainTemplate.getAssetPath(
|
||||
JSON.stringify(hotUpdateChunkFilename),
|
||||
{
|
||||
hash: `" + ${mainTemplate.renderCurrentHashCode(hash)} + "`,
|
||||
hashWithLength: length =>
|
||||
`" + ${mainTemplate.renderCurrentHashCode(hash, length)} + "`,
|
||||
chunk: {
|
||||
id: '" + chunkId + "',
|
||||
hash: `" + ${JSON.stringify(chunkMaps.hash)}[chunkId] + "`,
|
||||
hashWithLength: length => {
|
||||
const shortChunkHashMap = {};
|
||||
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)}[chunkId] + "`;
|
||||
},
|
||||
name: `" + (${JSON.stringify(
|
||||
chunkMaps.name
|
||||
)}[chunkId]||chunkId) + "`
|
||||
}
|
||||
}
|
||||
);
|
||||
const currentHotUpdateMainFilename = mainTemplate.getAssetPath(
|
||||
JSON.stringify(hotUpdateMainFilename),
|
||||
{
|
||||
hash: `" + ${mainTemplate.renderCurrentHashCode(hash)} + "`,
|
||||
hashWithLength: length =>
|
||||
`" + ${mainTemplate.renderCurrentHashCode(hash, length)} + "`
|
||||
}
|
||||
);
|
||||
return Template.getFunctionContent(
|
||||
asyncChunkLoading
|
||||
? require("./NodeMainTemplateAsync.runtime")
|
||||
: require("./NodeMainTemplate.runtime")
|
||||
)
|
||||
.replace(/\$require\$/g, mainTemplate.requireFn)
|
||||
.replace(/\$hotMainFilename\$/g, currentHotUpdateMainFilename)
|
||||
.replace(/\$hotChunkFilename\$/g, currentHotUpdateChunkFilename);
|
||||
}
|
||||
);
|
||||
mainTemplate.hooks.hash.tap("NodeMainTemplatePlugin", hash => {
|
||||
hash.update("node");
|
||||
hash.update("3");
|
||||
hash.update(this.outputOptions.filename + "");
|
||||
hash.update(this.outputOptions.chunkFilename + "");
|
||||
hash.update("4");
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
181
node_modules/webpack/lib/node/NodeSourcePlugin.js
generated
vendored
181
node_modules/webpack/lib/node/NodeSourcePlugin.js
generated
vendored
@@ -13,76 +13,129 @@ module.exports = class NodeSourcePlugin {
|
||||
}
|
||||
apply(compiler) {
|
||||
const options = this.options;
|
||||
if(options === false) // allow single kill switch to turn off this plugin
|
||||
if (options === false) {
|
||||
// allow single kill switch to turn off this plugin
|
||||
return;
|
||||
|
||||
function getPathToModule(module, type) {
|
||||
if(type === true || (type === undefined && nodeLibsBrowser[module])) {
|
||||
if(!nodeLibsBrowser[module]) throw new Error(`No browser version for node.js core module ${module} available`);
|
||||
return nodeLibsBrowser[module];
|
||||
} else if(type === "mock") {
|
||||
return require.resolve(`node-libs-browser/mock/${module}`);
|
||||
} else if(type === "empty") {
|
||||
return require.resolve("node-libs-browser/mock/empty");
|
||||
} else return module;
|
||||
}
|
||||
|
||||
function addExpression(parser, name, module, type, suffix) {
|
||||
suffix = suffix || "";
|
||||
parser.plugin(`expression ${name}`, function() {
|
||||
if(this.state.module && this.state.module.resource === getPathToModule(module, type)) return;
|
||||
const mockModule = ParserHelpers.requireFileAsExpression(this.state.module.context, getPathToModule(module, type));
|
||||
return ParserHelpers.addParsedVariableToModule(this, name, mockModule + suffix);
|
||||
});
|
||||
}
|
||||
|
||||
compiler.plugin("compilation", function(compilation, params) {
|
||||
params.normalModuleFactory.plugin("parser", function(parser, parserOptions) {
|
||||
|
||||
if(parserOptions.node === false)
|
||||
return;
|
||||
|
||||
let localOptions = options;
|
||||
if(parserOptions.node)
|
||||
localOptions = Object.assign({}, localOptions, parserOptions.node);
|
||||
|
||||
if(localOptions.global) {
|
||||
parser.plugin("expression global", function() {
|
||||
const retrieveGlobalModule = ParserHelpers.requireFileAsExpression(this.state.module.context, require.resolve("../../buildin/global.js"));
|
||||
return ParserHelpers.addParsedVariableToModule(this, "global", retrieveGlobalModule);
|
||||
});
|
||||
}
|
||||
if(localOptions.process) {
|
||||
const processType = localOptions.process;
|
||||
addExpression(parser, "process", "process", processType);
|
||||
}
|
||||
if(localOptions.console) {
|
||||
const consoleType = localOptions.console;
|
||||
addExpression(parser, "console", "console", consoleType);
|
||||
}
|
||||
const bufferType = localOptions.Buffer;
|
||||
if(bufferType) {
|
||||
addExpression(parser, "Buffer", "buffer", bufferType, ".Buffer");
|
||||
}
|
||||
if(localOptions.setImmediate) {
|
||||
const setImmediateType = localOptions.setImmediate;
|
||||
addExpression(parser, "setImmediate", "timers", setImmediateType, ".setImmediate");
|
||||
addExpression(parser, "clearImmediate", "timers", setImmediateType, ".clearImmediate");
|
||||
}
|
||||
});
|
||||
});
|
||||
compiler.plugin("after-resolvers", (compiler) => {
|
||||
Object.keys(nodeLibsBrowser).forEach((lib) => {
|
||||
if(options[lib] !== false) {
|
||||
compiler.resolvers.normal.apply(
|
||||
new AliasPlugin("described-resolve", {
|
||||
name: lib,
|
||||
onlyModule: true,
|
||||
alias: getPathToModule(lib, options[lib])
|
||||
}, "resolve")
|
||||
const getPathToModule = (module, type) => {
|
||||
if (type === true || (type === undefined && nodeLibsBrowser[module])) {
|
||||
if (!nodeLibsBrowser[module]) {
|
||||
throw new Error(
|
||||
`No browser version for node.js core module ${module} available`
|
||||
);
|
||||
}
|
||||
return nodeLibsBrowser[module];
|
||||
} else if (type === "mock") {
|
||||
return require.resolve(`node-libs-browser/mock/${module}`);
|
||||
} else if (type === "empty") {
|
||||
return require.resolve("node-libs-browser/mock/empty");
|
||||
} else {
|
||||
return module;
|
||||
}
|
||||
};
|
||||
|
||||
const addExpression = (parser, name, module, type, suffix) => {
|
||||
suffix = suffix || "";
|
||||
parser.hooks.expression.for(name).tap("NodeSourcePlugin", () => {
|
||||
if (
|
||||
parser.state.module &&
|
||||
parser.state.module.resource === getPathToModule(module, type)
|
||||
)
|
||||
return;
|
||||
const mockModule = ParserHelpers.requireFileAsExpression(
|
||||
parser.state.module.context,
|
||||
getPathToModule(module, type)
|
||||
);
|
||||
return ParserHelpers.addParsedVariableToModule(
|
||||
parser,
|
||||
name,
|
||||
mockModule + suffix
|
||||
);
|
||||
});
|
||||
};
|
||||
|
||||
compiler.hooks.compilation.tap(
|
||||
"NodeSourcePlugin",
|
||||
(compilation, { normalModuleFactory }) => {
|
||||
const handler = (parser, parserOptions) => {
|
||||
if (parserOptions.node === false) return;
|
||||
|
||||
let localOptions = options;
|
||||
if (parserOptions.node) {
|
||||
localOptions = Object.assign({}, localOptions, parserOptions.node);
|
||||
}
|
||||
if (localOptions.global) {
|
||||
parser.hooks.expression
|
||||
.for("global")
|
||||
.tap("NodeSourcePlugin", () => {
|
||||
const retrieveGlobalModule = ParserHelpers.requireFileAsExpression(
|
||||
parser.state.module.context,
|
||||
require.resolve("../../buildin/global")
|
||||
);
|
||||
return ParserHelpers.addParsedVariableToModule(
|
||||
parser,
|
||||
"global",
|
||||
retrieveGlobalModule
|
||||
);
|
||||
});
|
||||
}
|
||||
if (localOptions.process) {
|
||||
const processType = localOptions.process;
|
||||
addExpression(parser, "process", "process", processType);
|
||||
}
|
||||
if (localOptions.console) {
|
||||
const consoleType = localOptions.console;
|
||||
addExpression(parser, "console", "console", consoleType);
|
||||
}
|
||||
const bufferType = localOptions.Buffer;
|
||||
if (bufferType) {
|
||||
addExpression(parser, "Buffer", "buffer", bufferType, ".Buffer");
|
||||
}
|
||||
if (localOptions.setImmediate) {
|
||||
const setImmediateType = localOptions.setImmediate;
|
||||
addExpression(
|
||||
parser,
|
||||
"setImmediate",
|
||||
"timers",
|
||||
setImmediateType,
|
||||
".setImmediate"
|
||||
);
|
||||
addExpression(
|
||||
parser,
|
||||
"clearImmediate",
|
||||
"timers",
|
||||
setImmediateType,
|
||||
".clearImmediate"
|
||||
);
|
||||
}
|
||||
};
|
||||
normalModuleFactory.hooks.parser
|
||||
.for("javascript/auto")
|
||||
.tap("NodeSourcePlugin", handler);
|
||||
normalModuleFactory.hooks.parser
|
||||
.for("javascript/dynamic")
|
||||
.tap("NodeSourcePlugin", handler);
|
||||
}
|
||||
);
|
||||
compiler.hooks.afterResolvers.tap("NodeSourcePlugin", compiler => {
|
||||
for (const lib of Object.keys(nodeLibsBrowser)) {
|
||||
if (options[lib] !== false) {
|
||||
compiler.resolverFactory.hooks.resolver
|
||||
.for("normal")
|
||||
.tap("NodeSourcePlugin", resolver => {
|
||||
new AliasPlugin(
|
||||
"described-resolve",
|
||||
{
|
||||
name: lib,
|
||||
onlyModule: true,
|
||||
alias: getPathToModule(lib, options[lib])
|
||||
},
|
||||
"resolve"
|
||||
).apply(resolver);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
4
node_modules/webpack/lib/node/NodeTargetPlugin.js
generated
vendored
4
node_modules/webpack/lib/node/NodeTargetPlugin.js
generated
vendored
@@ -6,7 +6,9 @@
|
||||
|
||||
const ExternalsPlugin = require("../ExternalsPlugin");
|
||||
|
||||
const builtins = require("module").builtinModules || Object.keys(process.binding("natives"));
|
||||
const builtins =
|
||||
// eslint-disable-next-line node/no-unsupported-features/node-builtins,node/no-deprecated-api
|
||||
require("module").builtinModules || Object.keys(process.binding("natives"));
|
||||
|
||||
class NodeTargetPlugin {
|
||||
apply(compiler) {
|
||||
|
||||
12
node_modules/webpack/lib/node/NodeTemplatePlugin.js
generated
vendored
12
node_modules/webpack/lib/node/NodeTemplatePlugin.js
generated
vendored
@@ -16,10 +16,14 @@ class NodeTemplatePlugin {
|
||||
}
|
||||
|
||||
apply(compiler) {
|
||||
compiler.plugin("this-compilation", (compilation) => {
|
||||
compilation.mainTemplate.apply(new NodeMainTemplatePlugin(this.asyncChunkLoading));
|
||||
compilation.chunkTemplate.apply(new NodeChunkTemplatePlugin());
|
||||
compilation.hotUpdateChunkTemplate.apply(new NodeHotUpdateChunkTemplatePlugin());
|
||||
compiler.hooks.thisCompilation.tap("NodeTemplatePlugin", compilation => {
|
||||
new NodeMainTemplatePlugin(this.asyncChunkLoading).apply(
|
||||
compilation.mainTemplate
|
||||
);
|
||||
new NodeChunkTemplatePlugin().apply(compilation.chunkTemplate);
|
||||
new NodeHotUpdateChunkTemplatePlugin().apply(
|
||||
compilation.hotUpdateChunkTemplate
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
75
node_modules/webpack/lib/node/NodeWatchFileSystem.js
generated
vendored
75
node_modules/webpack/lib/node/NodeWatchFileSystem.js
generated
vendored
@@ -5,6 +5,7 @@
|
||||
"use strict";
|
||||
|
||||
const Watchpack = require("watchpack");
|
||||
const objectToMap = require("../util/objectToMap");
|
||||
|
||||
class NodeWatchFileSystem {
|
||||
constructor(inputFileSystem) {
|
||||
@@ -16,54 +17,90 @@ class NodeWatchFileSystem {
|
||||
}
|
||||
|
||||
watch(files, dirs, missing, startTime, options, callback, callbackUndelayed) {
|
||||
if(!Array.isArray(files))
|
||||
if (!Array.isArray(files)) {
|
||||
throw new Error("Invalid arguments: 'files'");
|
||||
if(!Array.isArray(dirs))
|
||||
}
|
||||
if (!Array.isArray(dirs)) {
|
||||
throw new Error("Invalid arguments: 'dirs'");
|
||||
if(!Array.isArray(missing))
|
||||
}
|
||||
if (!Array.isArray(missing)) {
|
||||
throw new Error("Invalid arguments: 'missing'");
|
||||
if(typeof callback !== "function")
|
||||
}
|
||||
if (typeof callback !== "function") {
|
||||
throw new Error("Invalid arguments: 'callback'");
|
||||
if(typeof startTime !== "number" && startTime)
|
||||
}
|
||||
if (typeof startTime !== "number" && startTime) {
|
||||
throw new Error("Invalid arguments: 'startTime'");
|
||||
if(typeof options !== "object")
|
||||
}
|
||||
if (typeof options !== "object") {
|
||||
throw new Error("Invalid arguments: 'options'");
|
||||
if(typeof callbackUndelayed !== "function" && callbackUndelayed)
|
||||
}
|
||||
if (typeof callbackUndelayed !== "function" && callbackUndelayed) {
|
||||
throw new Error("Invalid arguments: 'callbackUndelayed'");
|
||||
}
|
||||
const oldWatcher = this.watcher;
|
||||
this.watcher = new Watchpack(options);
|
||||
|
||||
if(callbackUndelayed)
|
||||
if (callbackUndelayed) {
|
||||
this.watcher.once("change", callbackUndelayed);
|
||||
|
||||
}
|
||||
const cachedFiles = files;
|
||||
const cachedDirs = dirs;
|
||||
this.watcher.once("aggregated", (changes, removals) => {
|
||||
changes = changes.concat(removals);
|
||||
if(this.inputFileSystem && this.inputFileSystem.purge) {
|
||||
if (this.inputFileSystem && this.inputFileSystem.purge) {
|
||||
this.inputFileSystem.purge(changes);
|
||||
}
|
||||
const times = this.watcher.getTimes();
|
||||
callback(null,
|
||||
changes.filter(file => files.indexOf(file) >= 0).sort(),
|
||||
changes.filter(file => dirs.indexOf(file) >= 0).sort(),
|
||||
changes.filter(file => missing.indexOf(file) >= 0).sort(), times, times);
|
||||
const times = objectToMap(this.watcher.getTimes());
|
||||
files = new Set(files);
|
||||
dirs = new Set(dirs);
|
||||
missing = new Set(missing);
|
||||
removals = new Set(removals.filter(file => files.has(file)));
|
||||
callback(
|
||||
null,
|
||||
changes.filter(file => files.has(file)).sort(),
|
||||
changes.filter(file => dirs.has(file)).sort(),
|
||||
changes.filter(file => missing.has(file)).sort(),
|
||||
times,
|
||||
times,
|
||||
removals
|
||||
);
|
||||
});
|
||||
|
||||
this.watcher.watch(files.concat(missing), dirs.concat(missing), startTime);
|
||||
this.watcher.watch(
|
||||
cachedFiles.concat(missing),
|
||||
cachedDirs.concat(missing),
|
||||
startTime
|
||||
);
|
||||
|
||||
if(oldWatcher) {
|
||||
if (oldWatcher) {
|
||||
oldWatcher.close();
|
||||
}
|
||||
return {
|
||||
close: () => {
|
||||
if(this.watcher) {
|
||||
if (this.watcher) {
|
||||
this.watcher.close();
|
||||
this.watcher = null;
|
||||
}
|
||||
},
|
||||
pause: () => {
|
||||
if(this.watcher) {
|
||||
if (this.watcher) {
|
||||
this.watcher.pause();
|
||||
}
|
||||
},
|
||||
getFileTimestamps: () => {
|
||||
if (this.watcher) {
|
||||
return objectToMap(this.watcher.getTimes());
|
||||
} else {
|
||||
return new Map();
|
||||
}
|
||||
},
|
||||
getContextTimestamps: () => {
|
||||
if (this.watcher) {
|
||||
return objectToMap(this.watcher.getTimes());
|
||||
} else {
|
||||
return new Map();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user