$
This commit is contained in:
20
node_modules/webpack/LICENSE
generated
vendored
Normal file
20
node_modules/webpack/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
Copyright JS Foundation and other contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
'Software'), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
715
node_modules/webpack/README.md
generated
vendored
Normal file
715
node_modules/webpack/README.md
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
9
node_modules/webpack/SECURITY.md
generated
vendored
Normal file
9
node_modules/webpack/SECURITY.md
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
# Reporting Security Issues
|
||||
|
||||
If you discover a security issue in webpack, please report it by sending an
|
||||
email to [webpack@opencollective.com](mailto:webpack@opencollective.com).
|
||||
|
||||
This will allow us to assess the risk, and make a fix available before we add a
|
||||
bug report to the GitHub repository.
|
||||
|
||||
Thanks for helping make webpack safe for everyone.
|
163
node_modules/webpack/bin/webpack.js
generated
vendored
Normal file
163
node_modules/webpack/bin/webpack.js
generated
vendored
Normal file
@@ -0,0 +1,163 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
/**
|
||||
* @param {string} command process to run
|
||||
* @param {string[]} args command line arguments
|
||||
* @returns {Promise<void>} promise
|
||||
*/
|
||||
const runCommand = (command, args) => {
|
||||
const cp = require("child_process");
|
||||
return new Promise((resolve, reject) => {
|
||||
const executedCommand = cp.spawn(command, args, {
|
||||
stdio: "inherit",
|
||||
shell: true
|
||||
});
|
||||
|
||||
executedCommand.on("error", error => {
|
||||
reject(error);
|
||||
});
|
||||
|
||||
executedCommand.on("exit", code => {
|
||||
if (code === 0) {
|
||||
resolve();
|
||||
} else {
|
||||
reject();
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} packageName name of the package
|
||||
* @returns {boolean} is the package installed?
|
||||
*/
|
||||
const isInstalled = packageName => {
|
||||
if (process.versions.pnp) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const path = require("path");
|
||||
const fs = require("graceful-fs");
|
||||
|
||||
let dir = __dirname;
|
||||
|
||||
do {
|
||||
try {
|
||||
if (
|
||||
fs.statSync(path.join(dir, "node_modules", packageName)).isDirectory()
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
} catch (_error) {
|
||||
// Nothing
|
||||
}
|
||||
} while (dir !== (dir = path.dirname(dir)));
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {CliOption} cli options
|
||||
* @returns {void}
|
||||
*/
|
||||
const runCli = cli => {
|
||||
const path = require("path");
|
||||
const pkgPath = require.resolve(`${cli.package}/package.json`);
|
||||
// eslint-disable-next-line node/no-missing-require
|
||||
const pkg = require(pkgPath);
|
||||
// eslint-disable-next-line node/no-missing-require
|
||||
require(path.resolve(path.dirname(pkgPath), pkg.bin[cli.binName]));
|
||||
};
|
||||
|
||||
/**
|
||||
* @typedef {Object} CliOption
|
||||
* @property {string} name display name
|
||||
* @property {string} package npm package name
|
||||
* @property {string} binName name of the executable file
|
||||
* @property {boolean} installed currently installed?
|
||||
* @property {string} url homepage
|
||||
*/
|
||||
|
||||
/** @type {CliOption} */
|
||||
const cli = {
|
||||
name: "webpack-cli",
|
||||
package: "webpack-cli",
|
||||
binName: "webpack-cli",
|
||||
installed: isInstalled("webpack-cli"),
|
||||
url: "https://github.com/webpack/webpack-cli"
|
||||
};
|
||||
|
||||
if (!cli.installed) {
|
||||
const path = require("path");
|
||||
const fs = require("graceful-fs");
|
||||
const readLine = require("readline");
|
||||
|
||||
const notify =
|
||||
"CLI for webpack must be installed.\n" + ` ${cli.name} (${cli.url})\n`;
|
||||
|
||||
console.error(notify);
|
||||
|
||||
let packageManager;
|
||||
|
||||
if (fs.existsSync(path.resolve(process.cwd(), "yarn.lock"))) {
|
||||
packageManager = "yarn";
|
||||
} else if (fs.existsSync(path.resolve(process.cwd(), "pnpm-lock.yaml"))) {
|
||||
packageManager = "pnpm";
|
||||
} else {
|
||||
packageManager = "npm";
|
||||
}
|
||||
|
||||
const installOptions = [packageManager === "yarn" ? "add" : "install", "-D"];
|
||||
|
||||
console.error(
|
||||
`We will use "${packageManager}" to install the CLI via "${packageManager} ${installOptions.join(
|
||||
" "
|
||||
)} ${cli.package}".`
|
||||
);
|
||||
|
||||
const question = `Do you want to install 'webpack-cli' (yes/no): `;
|
||||
|
||||
const questionInterface = readLine.createInterface({
|
||||
input: process.stdin,
|
||||
output: process.stderr
|
||||
});
|
||||
|
||||
// In certain scenarios (e.g. when STDIN is not in terminal mode), the callback function will not be
|
||||
// executed. Setting the exit code here to ensure the script exits correctly in those cases. The callback
|
||||
// function is responsible for clearing the exit code if the user wishes to install webpack-cli.
|
||||
process.exitCode = 1;
|
||||
questionInterface.question(question, answer => {
|
||||
questionInterface.close();
|
||||
|
||||
const normalizedAnswer = answer.toLowerCase().startsWith("y");
|
||||
|
||||
if (!normalizedAnswer) {
|
||||
console.error(
|
||||
"You need to install 'webpack-cli' to use webpack via CLI.\n" +
|
||||
"You can also install the CLI manually."
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
process.exitCode = 0;
|
||||
|
||||
console.log(
|
||||
`Installing '${
|
||||
cli.package
|
||||
}' (running '${packageManager} ${installOptions.join(" ")} ${
|
||||
cli.package
|
||||
}')...`
|
||||
);
|
||||
|
||||
runCommand(packageManager, installOptions.concat(cli.package))
|
||||
.then(() => {
|
||||
runCli(cli);
|
||||
})
|
||||
.catch(error => {
|
||||
console.error(error);
|
||||
process.exitCode = 1;
|
||||
});
|
||||
});
|
||||
} else {
|
||||
runCli(cli);
|
||||
}
|
74
node_modules/webpack/hot/dev-server.js
generated
vendored
Normal file
74
node_modules/webpack/hot/dev-server.js
generated
vendored
Normal file
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Tobias Koppers @sokra
|
||||
*/
|
||||
/* globals __webpack_hash__ */
|
||||
if (module.hot) {
|
||||
var lastHash;
|
||||
var upToDate = function upToDate() {
|
||||
return lastHash.indexOf(__webpack_hash__) >= 0;
|
||||
};
|
||||
var log = require("./log");
|
||||
var check = function check() {
|
||||
module.hot
|
||||
.check(true)
|
||||
.then(function (updatedModules) {
|
||||
if (!updatedModules) {
|
||||
log(
|
||||
"warning",
|
||||
"[HMR] Cannot find update. " +
|
||||
(typeof window !== "undefined"
|
||||
? "Need to do a full reload!"
|
||||
: "Please reload manually!")
|
||||
);
|
||||
log(
|
||||
"warning",
|
||||
"[HMR] (Probably because of restarting the webpack-dev-server)"
|
||||
);
|
||||
if (typeof window !== "undefined") {
|
||||
window.location.reload();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (!upToDate()) {
|
||||
check();
|
||||
}
|
||||
|
||||
require("./log-apply-result")(updatedModules, updatedModules);
|
||||
|
||||
if (upToDate()) {
|
||||
log("info", "[HMR] App is up to date.");
|
||||
}
|
||||
})
|
||||
.catch(function (err) {
|
||||
var status = module.hot.status();
|
||||
if (["abort", "fail"].indexOf(status) >= 0) {
|
||||
log(
|
||||
"warning",
|
||||
"[HMR] Cannot apply update. " +
|
||||
(typeof window !== "undefined"
|
||||
? "Need to do a full reload!"
|
||||
: "Please reload manually!")
|
||||
);
|
||||
log("warning", "[HMR] " + log.formatError(err));
|
||||
if (typeof window !== "undefined") {
|
||||
window.location.reload();
|
||||
}
|
||||
} else {
|
||||
log("warning", "[HMR] Update failed: " + log.formatError(err));
|
||||
}
|
||||
});
|
||||
};
|
||||
var hotEmitter = require("./emitter");
|
||||
hotEmitter.on("webpackHotUpdate", function (currentHash) {
|
||||
lastHash = currentHash;
|
||||
if (!upToDate() && module.hot.status() === "idle") {
|
||||
log("info", "[HMR] Checking for updates on the server...");
|
||||
check();
|
||||
}
|
||||
});
|
||||
log("info", "[HMR] Waiting for update signal from WDS...");
|
||||
} else {
|
||||
throw new Error("[HMR] Hot Module Replacement is disabled.");
|
||||
}
|
2
node_modules/webpack/hot/emitter.js
generated
vendored
Normal file
2
node_modules/webpack/hot/emitter.js
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
var EventEmitter = require("events");
|
||||
module.exports = new EventEmitter();
|
40
node_modules/webpack/hot/lazy-compilation-node.js
generated
vendored
Normal file
40
node_modules/webpack/hot/lazy-compilation-node.js
generated
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
/* global __resourceQuery */
|
||||
|
||||
"use strict";
|
||||
|
||||
var urlBase = decodeURIComponent(__resourceQuery.slice(1));
|
||||
exports.keepAlive = function (options) {
|
||||
var data = options.data;
|
||||
var onError = options.onError;
|
||||
var active = options.active;
|
||||
var module = options.module;
|
||||
var response;
|
||||
var request = (
|
||||
urlBase.startsWith("https") ? require("https") : require("http")
|
||||
).request(
|
||||
urlBase + data,
|
||||
{
|
||||
agent: false,
|
||||
headers: { accept: "text/event-stream" }
|
||||
},
|
||||
function (res) {
|
||||
response = res;
|
||||
response.on("error", errorHandler);
|
||||
if (!active && !module.hot) {
|
||||
console.log(
|
||||
"Hot Module Replacement is not enabled. Waiting for process restart..."
|
||||
);
|
||||
}
|
||||
}
|
||||
);
|
||||
function errorHandler(err) {
|
||||
err.message =
|
||||
"Problem communicating active modules to the server: " + err.message;
|
||||
onError(err);
|
||||
}
|
||||
request.on("error", errorHandler);
|
||||
request.end();
|
||||
return function () {
|
||||
response.destroy();
|
||||
};
|
||||
};
|
74
node_modules/webpack/hot/lazy-compilation-web.js
generated
vendored
Normal file
74
node_modules/webpack/hot/lazy-compilation-web.js
generated
vendored
Normal file
@@ -0,0 +1,74 @@
|
||||
/* global __resourceQuery */
|
||||
|
||||
"use strict";
|
||||
|
||||
if (typeof EventSource !== "function") {
|
||||
throw new Error(
|
||||
"Environment doesn't support lazy compilation (requires EventSource)"
|
||||
);
|
||||
}
|
||||
|
||||
var urlBase = decodeURIComponent(__resourceQuery.slice(1));
|
||||
var activeEventSource;
|
||||
var activeKeys = new Map();
|
||||
var errorHandlers = new Set();
|
||||
|
||||
var updateEventSource = function updateEventSource() {
|
||||
if (activeEventSource) activeEventSource.close();
|
||||
if (activeKeys.size) {
|
||||
activeEventSource = new EventSource(
|
||||
urlBase + Array.from(activeKeys.keys()).join("@")
|
||||
);
|
||||
activeEventSource.onerror = function (event) {
|
||||
errorHandlers.forEach(function (onError) {
|
||||
onError(
|
||||
new Error(
|
||||
"Problem communicating active modules to the server: " +
|
||||
event.message +
|
||||
" " +
|
||||
event.filename +
|
||||
":" +
|
||||
event.lineno +
|
||||
":" +
|
||||
event.colno +
|
||||
" " +
|
||||
event.error
|
||||
)
|
||||
);
|
||||
});
|
||||
};
|
||||
} else {
|
||||
activeEventSource = undefined;
|
||||
}
|
||||
};
|
||||
|
||||
exports.keepAlive = function (options) {
|
||||
var data = options.data;
|
||||
var onError = options.onError;
|
||||
var active = options.active;
|
||||
var module = options.module;
|
||||
errorHandlers.add(onError);
|
||||
var value = activeKeys.get(data) || 0;
|
||||
activeKeys.set(data, value + 1);
|
||||
if (value === 0) {
|
||||
updateEventSource();
|
||||
}
|
||||
if (!active && !module.hot) {
|
||||
console.log(
|
||||
"Hot Module Replacement is not enabled. Waiting for process restart..."
|
||||
);
|
||||
}
|
||||
|
||||
return function () {
|
||||
errorHandlers.delete(onError);
|
||||
setTimeout(function () {
|
||||
var value = activeKeys.get(data);
|
||||
if (value === 1) {
|
||||
activeKeys.delete(data);
|
||||
updateEventSource();
|
||||
} else {
|
||||
activeKeys.set(data, value - 1);
|
||||
}
|
||||
}, 1000);
|
||||
};
|
||||
};
|
44
node_modules/webpack/hot/log-apply-result.js
generated
vendored
Normal file
44
node_modules/webpack/hot/log-apply-result.js
generated
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Tobias Koppers @sokra
|
||||
*/
|
||||
module.exports = function (updatedModules, renewedModules) {
|
||||
var unacceptedModules = updatedModules.filter(function (moduleId) {
|
||||
return renewedModules && renewedModules.indexOf(moduleId) < 0;
|
||||
});
|
||||
var log = require("./log");
|
||||
|
||||
if (unacceptedModules.length > 0) {
|
||||
log(
|
||||
"warning",
|
||||
"[HMR] The following modules couldn't be hot updated: (They would need a full reload!)"
|
||||
);
|
||||
unacceptedModules.forEach(function (moduleId) {
|
||||
log("warning", "[HMR] - " + moduleId);
|
||||
});
|
||||
}
|
||||
|
||||
if (!renewedModules || renewedModules.length === 0) {
|
||||
log("info", "[HMR] Nothing hot updated.");
|
||||
} else {
|
||||
log("info", "[HMR] Updated modules:");
|
||||
renewedModules.forEach(function (moduleId) {
|
||||
if (typeof moduleId === "string" && moduleId.indexOf("!") !== -1) {
|
||||
var parts = moduleId.split("!");
|
||||
log.groupCollapsed("info", "[HMR] - " + parts.pop());
|
||||
log("info", "[HMR] - " + moduleId);
|
||||
log.groupEnd("info");
|
||||
} else {
|
||||
log("info", "[HMR] - " + moduleId);
|
||||
}
|
||||
});
|
||||
var numberIds = renewedModules.every(function (moduleId) {
|
||||
return typeof moduleId === "number";
|
||||
});
|
||||
if (numberIds)
|
||||
log(
|
||||
"info",
|
||||
'[HMR] Consider using the optimization.moduleIds: "named" for module names.'
|
||||
);
|
||||
}
|
||||
};
|
59
node_modules/webpack/hot/log.js
generated
vendored
Normal file
59
node_modules/webpack/hot/log.js
generated
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
var logLevel = "info";
|
||||
|
||||
function dummy() {}
|
||||
|
||||
function shouldLog(level) {
|
||||
var shouldLog =
|
||||
(logLevel === "info" && level === "info") ||
|
||||
(["info", "warning"].indexOf(logLevel) >= 0 && level === "warning") ||
|
||||
(["info", "warning", "error"].indexOf(logLevel) >= 0 && level === "error");
|
||||
return shouldLog;
|
||||
}
|
||||
|
||||
function logGroup(logFn) {
|
||||
return function (level, msg) {
|
||||
if (shouldLog(level)) {
|
||||
logFn(msg);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = function (level, msg) {
|
||||
if (shouldLog(level)) {
|
||||
if (level === "info") {
|
||||
console.log(msg);
|
||||
} else if (level === "warning") {
|
||||
console.warn(msg);
|
||||
} else if (level === "error") {
|
||||
console.error(msg);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/* eslint-disable node/no-unsupported-features/node-builtins */
|
||||
var group = console.group || dummy;
|
||||
var groupCollapsed = console.groupCollapsed || dummy;
|
||||
var groupEnd = console.groupEnd || dummy;
|
||||
/* eslint-enable node/no-unsupported-features/node-builtins */
|
||||
|
||||
module.exports.group = logGroup(group);
|
||||
|
||||
module.exports.groupCollapsed = logGroup(groupCollapsed);
|
||||
|
||||
module.exports.groupEnd = logGroup(groupEnd);
|
||||
|
||||
module.exports.setLogLevel = function (level) {
|
||||
logLevel = level;
|
||||
};
|
||||
|
||||
module.exports.formatError = function (err) {
|
||||
var message = err.message;
|
||||
var stack = err.stack;
|
||||
if (!stack) {
|
||||
return message;
|
||||
} else if (stack.indexOf(message) < 0) {
|
||||
return message + "\n" + stack;
|
||||
} else {
|
||||
return stack;
|
||||
}
|
||||
};
|
102
node_modules/webpack/hot/only-dev-server.js
generated
vendored
Normal file
102
node_modules/webpack/hot/only-dev-server.js
generated
vendored
Normal file
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Tobias Koppers @sokra
|
||||
*/
|
||||
/*globals __webpack_hash__ */
|
||||
if (module.hot) {
|
||||
var lastHash;
|
||||
var upToDate = function upToDate() {
|
||||
return lastHash.indexOf(__webpack_hash__) >= 0;
|
||||
};
|
||||
var log = require("./log");
|
||||
var check = function check() {
|
||||
module.hot
|
||||
.check()
|
||||
.then(function (updatedModules) {
|
||||
if (!updatedModules) {
|
||||
log("warning", "[HMR] Cannot find update. Need to do a full reload!");
|
||||
log(
|
||||
"warning",
|
||||
"[HMR] (Probably because of restarting the webpack-dev-server)"
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
return module.hot
|
||||
.apply({
|
||||
ignoreUnaccepted: true,
|
||||
ignoreDeclined: true,
|
||||
ignoreErrored: true,
|
||||
onUnaccepted: function (data) {
|
||||
log(
|
||||
"warning",
|
||||
"Ignored an update to unaccepted module " +
|
||||
data.chain.join(" -> ")
|
||||
);
|
||||
},
|
||||
onDeclined: function (data) {
|
||||
log(
|
||||
"warning",
|
||||
"Ignored an update to declined module " +
|
||||
data.chain.join(" -> ")
|
||||
);
|
||||
},
|
||||
onErrored: function (data) {
|
||||
log("error", data.error);
|
||||
log(
|
||||
"warning",
|
||||
"Ignored an error while updating module " +
|
||||
data.moduleId +
|
||||
" (" +
|
||||
data.type +
|
||||
")"
|
||||
);
|
||||
}
|
||||
})
|
||||
.then(function (renewedModules) {
|
||||
if (!upToDate()) {
|
||||
check();
|
||||
}
|
||||
|
||||
require("./log-apply-result")(updatedModules, renewedModules);
|
||||
|
||||
if (upToDate()) {
|
||||
log("info", "[HMR] App is up to date.");
|
||||
}
|
||||
});
|
||||
})
|
||||
.catch(function (err) {
|
||||
var status = module.hot.status();
|
||||
if (["abort", "fail"].indexOf(status) >= 0) {
|
||||
log(
|
||||
"warning",
|
||||
"[HMR] Cannot check for update. Need to do a full reload!"
|
||||
);
|
||||
log("warning", "[HMR] " + log.formatError(err));
|
||||
} else {
|
||||
log("warning", "[HMR] Update check failed: " + log.formatError(err));
|
||||
}
|
||||
});
|
||||
};
|
||||
var hotEmitter = require("./emitter");
|
||||
hotEmitter.on("webpackHotUpdate", function (currentHash) {
|
||||
lastHash = currentHash;
|
||||
if (!upToDate()) {
|
||||
var status = module.hot.status();
|
||||
if (status === "idle") {
|
||||
log("info", "[HMR] Checking for updates on the server...");
|
||||
check();
|
||||
} else if (["abort", "fail"].indexOf(status) >= 0) {
|
||||
log(
|
||||
"warning",
|
||||
"[HMR] Cannot apply update as a previous update " +
|
||||
status +
|
||||
"ed. Need to do a full reload!"
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
log("info", "[HMR] Waiting for update signal from WDS...");
|
||||
} else {
|
||||
throw new Error("[HMR] Hot Module Replacement is disabled.");
|
||||
}
|
37
node_modules/webpack/hot/poll.js
generated
vendored
Normal file
37
node_modules/webpack/hot/poll.js
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Tobias Koppers @sokra
|
||||
*/
|
||||
/*globals __resourceQuery */
|
||||
if (module.hot) {
|
||||
var hotPollInterval = +__resourceQuery.slice(1) || 10 * 60 * 1000;
|
||||
var log = require("./log");
|
||||
|
||||
var checkForUpdate = function checkForUpdate(fromUpdate) {
|
||||
if (module.hot.status() === "idle") {
|
||||
module.hot
|
||||
.check(true)
|
||||
.then(function (updatedModules) {
|
||||
if (!updatedModules) {
|
||||
if (fromUpdate) log("info", "[HMR] Update applied.");
|
||||
return;
|
||||
}
|
||||
require("./log-apply-result")(updatedModules, updatedModules);
|
||||
checkForUpdate(true);
|
||||
})
|
||||
.catch(function (err) {
|
||||
var status = module.hot.status();
|
||||
if (["abort", "fail"].indexOf(status) >= 0) {
|
||||
log("warning", "[HMR] Cannot apply update.");
|
||||
log("warning", "[HMR] " + log.formatError(err));
|
||||
log("warning", "[HMR] You need to restart the application!");
|
||||
} else {
|
||||
log("warning", "[HMR] Update failed: " + log.formatError(err));
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
setInterval(checkForUpdate, hotPollInterval);
|
||||
} else {
|
||||
throw new Error("[HMR] Hot Module Replacement is disabled.");
|
||||
}
|
62
node_modules/webpack/hot/signal.js
generated
vendored
Normal file
62
node_modules/webpack/hot/signal.js
generated
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Tobias Koppers @sokra
|
||||
*/
|
||||
/*globals __resourceQuery */
|
||||
if (module.hot) {
|
||||
var log = require("./log");
|
||||
var checkForUpdate = function checkForUpdate(fromUpdate) {
|
||||
module.hot
|
||||
.check()
|
||||
.then(function (updatedModules) {
|
||||
if (!updatedModules) {
|
||||
if (fromUpdate) log("info", "[HMR] Update applied.");
|
||||
else log("warning", "[HMR] Cannot find update.");
|
||||
return;
|
||||
}
|
||||
|
||||
return module.hot
|
||||
.apply({
|
||||
ignoreUnaccepted: true,
|
||||
onUnaccepted: function (data) {
|
||||
log(
|
||||
"warning",
|
||||
"Ignored an update to unaccepted module " +
|
||||
data.chain.join(" -> ")
|
||||
);
|
||||
}
|
||||
})
|
||||
.then(function (renewedModules) {
|
||||
require("./log-apply-result")(updatedModules, renewedModules);
|
||||
|
||||
checkForUpdate(true);
|
||||
return null;
|
||||
});
|
||||
})
|
||||
.catch(function (err) {
|
||||
var status = module.hot.status();
|
||||
if (["abort", "fail"].indexOf(status) >= 0) {
|
||||
log("warning", "[HMR] Cannot apply update.");
|
||||
log("warning", "[HMR] " + log.formatError(err));
|
||||
log("warning", "[HMR] You need to restart the application!");
|
||||
} else {
|
||||
log("warning", "[HMR] Update failed: " + (err.stack || err.message));
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
process.on(__resourceQuery.slice(1) || "SIGUSR2", function () {
|
||||
if (module.hot.status() !== "idle") {
|
||||
log(
|
||||
"warning",
|
||||
"[HMR] Got signal but currently in " + module.hot.status() + " state."
|
||||
);
|
||||
log("warning", "[HMR] Need to be in idle state to start hot update.");
|
||||
return;
|
||||
}
|
||||
|
||||
checkForUpdate();
|
||||
});
|
||||
} else {
|
||||
throw new Error("[HMR] Hot Module Replacement is disabled.");
|
||||
}
|
253
node_modules/webpack/lib/APIPlugin.js
generated
vendored
Normal file
253
node_modules/webpack/lib/APIPlugin.js
generated
vendored
Normal file
@@ -0,0 +1,253 @@
|
||||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Tobias Koppers @sokra
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
const RuntimeGlobals = require("./RuntimeGlobals");
|
||||
const WebpackError = require("./WebpackError");
|
||||
const ConstDependency = require("./dependencies/ConstDependency");
|
||||
const BasicEvaluatedExpression = require("./javascript/BasicEvaluatedExpression");
|
||||
const {
|
||||
toConstantDependency,
|
||||
evaluateToString
|
||||
} = require("./javascript/JavascriptParserHelpers");
|
||||
const ChunkNameRuntimeModule = require("./runtime/ChunkNameRuntimeModule");
|
||||
const GetFullHashRuntimeModule = require("./runtime/GetFullHashRuntimeModule");
|
||||
|
||||
/** @typedef {import("./Compiler")} Compiler */
|
||||
/** @typedef {import("./javascript/JavascriptParser")} JavascriptParser */
|
||||
|
||||
/* eslint-disable camelcase */
|
||||
const REPLACEMENTS = {
|
||||
__webpack_require__: {
|
||||
expr: RuntimeGlobals.require,
|
||||
req: [RuntimeGlobals.require],
|
||||
type: "function",
|
||||
assign: false
|
||||
},
|
||||
__webpack_public_path__: {
|
||||
expr: RuntimeGlobals.publicPath,
|
||||
req: [RuntimeGlobals.publicPath],
|
||||
type: "string",
|
||||
assign: true
|
||||
},
|
||||
__webpack_base_uri__: {
|
||||
expr: RuntimeGlobals.baseURI,
|
||||
req: [RuntimeGlobals.baseURI],
|
||||
type: "string",
|
||||
assign: true
|
||||
},
|
||||
__webpack_modules__: {
|
||||
expr: RuntimeGlobals.moduleFactories,
|
||||
req: [RuntimeGlobals.moduleFactories],
|
||||
type: "object",
|
||||
assign: false
|
||||
},
|
||||
__webpack_chunk_load__: {
|
||||
expr: RuntimeGlobals.ensureChunk,
|
||||
req: [RuntimeGlobals.ensureChunk],
|
||||
type: "function",
|
||||
assign: true
|
||||
},
|
||||
__non_webpack_require__: {
|
||||
expr: "require",
|
||||
req: null,
|
||||
type: undefined, // type is not known, depends on environment
|
||||
assign: true
|
||||
},
|
||||
__webpack_nonce__: {
|
||||
expr: RuntimeGlobals.scriptNonce,
|
||||
req: [RuntimeGlobals.scriptNonce],
|
||||
type: "string",
|
||||
assign: true
|
||||
},
|
||||
__webpack_hash__: {
|
||||
expr: `${RuntimeGlobals.getFullHash}()`,
|
||||
req: [RuntimeGlobals.getFullHash],
|
||||
type: "string",
|
||||
assign: false
|
||||
},
|
||||
__webpack_chunkname__: {
|
||||
expr: RuntimeGlobals.chunkName,
|
||||
req: [RuntimeGlobals.chunkName],
|
||||
type: "string",
|
||||
assign: false
|
||||
},
|
||||
__webpack_get_script_filename__: {
|
||||
expr: RuntimeGlobals.getChunkScriptFilename,
|
||||
req: [RuntimeGlobals.getChunkScriptFilename],
|
||||
type: "function",
|
||||
assign: true
|
||||
},
|
||||
__webpack_runtime_id__: {
|
||||
expr: RuntimeGlobals.runtimeId,
|
||||
req: [RuntimeGlobals.runtimeId],
|
||||
assign: false
|
||||
},
|
||||
"require.onError": {
|
||||
expr: RuntimeGlobals.uncaughtErrorHandler,
|
||||
req: [RuntimeGlobals.uncaughtErrorHandler],
|
||||
type: undefined, // type is not known, could be function or undefined
|
||||
assign: true // is never a pattern
|
||||
},
|
||||
__system_context__: {
|
||||
expr: RuntimeGlobals.systemContext,
|
||||
req: [RuntimeGlobals.systemContext],
|
||||
type: "object",
|
||||
assign: false
|
||||
},
|
||||
__webpack_share_scopes__: {
|
||||
expr: RuntimeGlobals.shareScopeMap,
|
||||
req: [RuntimeGlobals.shareScopeMap],
|
||||
type: "object",
|
||||
assign: false
|
||||
},
|
||||
__webpack_init_sharing__: {
|
||||
expr: RuntimeGlobals.initializeSharing,
|
||||
req: [RuntimeGlobals.initializeSharing],
|
||||
type: "function",
|
||||
assign: true
|
||||
}
|
||||
};
|
||||
/* eslint-enable camelcase */
|
||||
|
||||
class APIPlugin {
|
||||
/**
|
||||
* Apply the plugin
|
||||
* @param {Compiler} compiler the compiler instance
|
||||
* @returns {void}
|
||||
*/
|
||||
apply(compiler) {
|
||||
compiler.hooks.compilation.tap(
|
||||
"APIPlugin",
|
||||
(compilation, { normalModuleFactory }) => {
|
||||
compilation.dependencyTemplates.set(
|
||||
ConstDependency,
|
||||
new ConstDependency.Template()
|
||||
);
|
||||
|
||||
compilation.hooks.runtimeRequirementInTree
|
||||
.for(RuntimeGlobals.chunkName)
|
||||
.tap("APIPlugin", chunk => {
|
||||
compilation.addRuntimeModule(
|
||||
chunk,
|
||||
new ChunkNameRuntimeModule(chunk.name)
|
||||
);
|
||||
return true;
|
||||
});
|
||||
|
||||
compilation.hooks.runtimeRequirementInTree
|
||||
.for(RuntimeGlobals.getFullHash)
|
||||
.tap("APIPlugin", (chunk, set) => {
|
||||
compilation.addRuntimeModule(chunk, new GetFullHashRuntimeModule());
|
||||
return true;
|
||||
});
|
||||
|
||||
/**
|
||||
* @param {JavascriptParser} parser the parser
|
||||
*/
|
||||
const handler = parser => {
|
||||
Object.keys(REPLACEMENTS).forEach(key => {
|
||||
const info = REPLACEMENTS[key];
|
||||
parser.hooks.expression
|
||||
.for(key)
|
||||
.tap(
|
||||
"APIPlugin",
|
||||
toConstantDependency(parser, info.expr, info.req)
|
||||
);
|
||||
if (info.assign === false) {
|
||||
parser.hooks.assign.for(key).tap("APIPlugin", expr => {
|
||||
const err = new WebpackError(`${key} must not be assigned`);
|
||||
err.loc = expr.loc;
|
||||
throw err;
|
||||
});
|
||||
}
|
||||
if (info.type) {
|
||||
parser.hooks.evaluateTypeof
|
||||
.for(key)
|
||||
.tap("APIPlugin", evaluateToString(info.type));
|
||||
}
|
||||
});
|
||||
|
||||
parser.hooks.expression
|
||||
.for("__webpack_layer__")
|
||||
.tap("APIPlugin", expr => {
|
||||
const dep = new ConstDependency(
|
||||
JSON.stringify(parser.state.module.layer),
|
||||
expr.range
|
||||
);
|
||||
dep.loc = expr.loc;
|
||||
parser.state.module.addPresentationalDependency(dep);
|
||||
return true;
|
||||
});
|
||||
parser.hooks.evaluateIdentifier
|
||||
.for("__webpack_layer__")
|
||||
.tap("APIPlugin", expr =>
|
||||
(parser.state.module.layer === null
|
||||
? new BasicEvaluatedExpression().setNull()
|
||||
: new BasicEvaluatedExpression().setString(
|
||||
parser.state.module.layer
|
||||
)
|
||||
).setRange(expr.range)
|
||||
);
|
||||
parser.hooks.evaluateTypeof
|
||||
.for("__webpack_layer__")
|
||||
.tap("APIPlugin", expr =>
|
||||
new BasicEvaluatedExpression()
|
||||
.setString(
|
||||
parser.state.module.layer === null ? "object" : "string"
|
||||
)
|
||||
.setRange(expr.range)
|
||||
);
|
||||
|
||||
parser.hooks.expression
|
||||
.for("__webpack_module__.id")
|
||||
.tap("APIPlugin", expr => {
|
||||
parser.state.module.buildInfo.moduleConcatenationBailout =
|
||||
"__webpack_module__.id";
|
||||
const dep = new ConstDependency(
|
||||
parser.state.module.moduleArgument + ".id",
|
||||
expr.range,
|
||||
[RuntimeGlobals.moduleId]
|
||||
);
|
||||
dep.loc = expr.loc;
|
||||
parser.state.module.addPresentationalDependency(dep);
|
||||
return true;
|
||||
});
|
||||
|
||||
parser.hooks.expression
|
||||
.for("__webpack_module__")
|
||||
.tap("APIPlugin", expr => {
|
||||
parser.state.module.buildInfo.moduleConcatenationBailout =
|
||||
"__webpack_module__";
|
||||
const dep = new ConstDependency(
|
||||
parser.state.module.moduleArgument,
|
||||
expr.range,
|
||||
[RuntimeGlobals.module]
|
||||
);
|
||||
dep.loc = expr.loc;
|
||||
parser.state.module.addPresentationalDependency(dep);
|
||||
return true;
|
||||
});
|
||||
parser.hooks.evaluateTypeof
|
||||
.for("__webpack_module__")
|
||||
.tap("APIPlugin", evaluateToString("object"));
|
||||
};
|
||||
|
||||
normalModuleFactory.hooks.parser
|
||||
.for("javascript/auto")
|
||||
.tap("APIPlugin", handler);
|
||||
normalModuleFactory.hooks.parser
|
||||
.for("javascript/dynamic")
|
||||
.tap("APIPlugin", handler);
|
||||
normalModuleFactory.hooks.parser
|
||||
.for("javascript/esm")
|
||||
.tap("APIPlugin", handler);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = APIPlugin;
|
49
node_modules/webpack/lib/AbstractMethodError.js
generated
vendored
Normal file
49
node_modules/webpack/lib/AbstractMethodError.js
generated
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Ivan Kopeykin @vankop
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
const WebpackError = require("./WebpackError");
|
||||
const CURRENT_METHOD_REGEXP = /at ([a-zA-Z0-9_.]*)/;
|
||||
|
||||
/**
|
||||
* @param {string=} method method name
|
||||
* @returns {string} message
|
||||
*/
|
||||
function createMessage(method) {
|
||||
return `Abstract method${method ? " " + method : ""}. Must be overridden.`;
|
||||
}
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function Message() {
|
||||
/** @type {string} */
|
||||
this.stack = undefined;
|
||||
Error.captureStackTrace(this);
|
||||
/** @type {RegExpMatchArray} */
|
||||
const match = this.stack.split("\n")[3].match(CURRENT_METHOD_REGEXP);
|
||||
|
||||
this.message = match && match[1] ? createMessage(match[1]) : createMessage();
|
||||
}
|
||||
|
||||
/**
|
||||
* Error for abstract method
|
||||
* @example
|
||||
* class FooClass {
|
||||
* abstractMethod() {
|
||||
* throw new AbstractMethodError(); // error message: Abstract method FooClass.abstractMethod. Must be overridden.
|
||||
* }
|
||||
* }
|
||||
*
|
||||
*/
|
||||
class AbstractMethodError extends WebpackError {
|
||||
constructor() {
|
||||
super(new Message().message);
|
||||
this.name = "AbstractMethodError";
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = AbstractMethodError;
|
106
node_modules/webpack/lib/AsyncDependenciesBlock.js
generated
vendored
Normal file
106
node_modules/webpack/lib/AsyncDependenciesBlock.js
generated
vendored
Normal file
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Tobias Koppers @sokra
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
const DependenciesBlock = require("./DependenciesBlock");
|
||||
const makeSerializable = require("./util/makeSerializable");
|
||||
|
||||
/** @typedef {import("./ChunkGraph")} ChunkGraph */
|
||||
/** @typedef {import("./ChunkGroup")} ChunkGroup */
|
||||
/** @typedef {import("./ChunkGroup").ChunkGroupOptions} ChunkGroupOptions */
|
||||
/** @typedef {import("./Dependency").DependencyLocation} DependencyLocation */
|
||||
/** @typedef {import("./Dependency").UpdateHashContext} UpdateHashContext */
|
||||
/** @typedef {import("./Entrypoint").EntryOptions} EntryOptions */
|
||||
/** @typedef {import("./Module")} Module */
|
||||
/** @typedef {import("./util/Hash")} Hash */
|
||||
|
||||
class AsyncDependenciesBlock extends DependenciesBlock {
|
||||
/**
|
||||
* @param {ChunkGroupOptions & { entryOptions?: EntryOptions }} groupOptions options for the group
|
||||
* @param {DependencyLocation=} loc the line of code
|
||||
* @param {string=} request the request
|
||||
*/
|
||||
constructor(groupOptions, loc, request) {
|
||||
super();
|
||||
if (typeof groupOptions === "string") {
|
||||
groupOptions = { name: groupOptions };
|
||||
} else if (!groupOptions) {
|
||||
groupOptions = { name: undefined };
|
||||
}
|
||||
this.groupOptions = groupOptions;
|
||||
this.loc = loc;
|
||||
this.request = request;
|
||||
this._stringifiedGroupOptions = undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {string} The name of the chunk
|
||||
*/
|
||||
get chunkName() {
|
||||
return this.groupOptions.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} value The new chunk name
|
||||
* @returns {void}
|
||||
*/
|
||||
set chunkName(value) {
|
||||
if (this.groupOptions.name !== value) {
|
||||
this.groupOptions.name = value;
|
||||
this._stringifiedGroupOptions = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Hash} hash the hash used to track dependencies
|
||||
* @param {UpdateHashContext} context context
|
||||
* @returns {void}
|
||||
*/
|
||||
updateHash(hash, context) {
|
||||
const { chunkGraph } = context;
|
||||
if (this._stringifiedGroupOptions === undefined) {
|
||||
this._stringifiedGroupOptions = JSON.stringify(this.groupOptions);
|
||||
}
|
||||
const chunkGroup = chunkGraph.getBlockChunkGroup(this);
|
||||
hash.update(
|
||||
`${this._stringifiedGroupOptions}${chunkGroup ? chunkGroup.id : ""}`
|
||||
);
|
||||
super.updateHash(hash, context);
|
||||
}
|
||||
|
||||
serialize(context) {
|
||||
const { write } = context;
|
||||
write(this.groupOptions);
|
||||
write(this.loc);
|
||||
write(this.request);
|
||||
super.serialize(context);
|
||||
}
|
||||
|
||||
deserialize(context) {
|
||||
const { read } = context;
|
||||
this.groupOptions = read();
|
||||
this.loc = read();
|
||||
this.request = read();
|
||||
super.deserialize(context);
|
||||
}
|
||||
}
|
||||
|
||||
makeSerializable(AsyncDependenciesBlock, "webpack/lib/AsyncDependenciesBlock");
|
||||
|
||||
Object.defineProperty(AsyncDependenciesBlock.prototype, "module", {
|
||||
get() {
|
||||
throw new Error(
|
||||
"module property was removed from AsyncDependenciesBlock (it's not needed)"
|
||||
);
|
||||
},
|
||||
set() {
|
||||
throw new Error(
|
||||
"module property was removed from AsyncDependenciesBlock (it's not needed)"
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = AsyncDependenciesBlock;
|
31
node_modules/webpack/lib/AsyncDependencyToInitialChunkError.js
generated
vendored
Normal file
31
node_modules/webpack/lib/AsyncDependencyToInitialChunkError.js
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Sean Larkin @thelarkinn
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
const WebpackError = require("./WebpackError");
|
||||
|
||||
/** @typedef {import("./Dependency").DependencyLocation} DependencyLocation */
|
||||
/** @typedef {import("./Module")} Module */
|
||||
|
||||
class AsyncDependencyToInitialChunkError extends WebpackError {
|
||||
/**
|
||||
* Creates an instance of AsyncDependencyToInitialChunkError.
|
||||
* @param {string} chunkName Name of Chunk
|
||||
* @param {Module} module module tied to dependency
|
||||
* @param {DependencyLocation} loc location of dependency
|
||||
*/
|
||||
constructor(chunkName, module, loc) {
|
||||
super(
|
||||
`It's not allowed to load an initial chunk on demand. The chunk name "${chunkName}" is already used by an entrypoint.`
|
||||
);
|
||||
|
||||
this.name = "AsyncDependencyToInitialChunkError";
|
||||
this.module = module;
|
||||
this.loc = loc;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = AsyncDependencyToInitialChunkError;
|
65
node_modules/webpack/lib/AutomaticPrefetchPlugin.js
generated
vendored
Normal file
65
node_modules/webpack/lib/AutomaticPrefetchPlugin.js
generated
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Tobias Koppers @sokra
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
const asyncLib = require("neo-async");
|
||||
const NormalModule = require("./NormalModule");
|
||||
const PrefetchDependency = require("./dependencies/PrefetchDependency");
|
||||
|
||||
/** @typedef {import("./Compiler")} Compiler */
|
||||
|
||||
class AutomaticPrefetchPlugin {
|
||||
/**
|
||||
* Apply the plugin
|
||||
* @param {Compiler} compiler the compiler instance
|
||||
* @returns {void}
|
||||
*/
|
||||
apply(compiler) {
|
||||
compiler.hooks.compilation.tap(
|
||||
"AutomaticPrefetchPlugin",
|
||||
(compilation, { normalModuleFactory }) => {
|
||||
compilation.dependencyFactories.set(
|
||||
PrefetchDependency,
|
||||
normalModuleFactory
|
||||
);
|
||||
}
|
||||
);
|
||||
let lastModules = null;
|
||||
compiler.hooks.afterCompile.tap("AutomaticPrefetchPlugin", compilation => {
|
||||
lastModules = [];
|
||||
|
||||
for (const m of compilation.modules) {
|
||||
if (m instanceof NormalModule) {
|
||||
lastModules.push({
|
||||
context: m.context,
|
||||
request: m.request
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
compiler.hooks.make.tapAsync(
|
||||
"AutomaticPrefetchPlugin",
|
||||
(compilation, callback) => {
|
||||
if (!lastModules) return callback();
|
||||
asyncLib.forEach(
|
||||
lastModules,
|
||||
(m, callback) => {
|
||||
compilation.addModuleChain(
|
||||
m.context || compiler.context,
|
||||
new PrefetchDependency(`!!${m.request}`),
|
||||
callback
|
||||
);
|
||||
},
|
||||
err => {
|
||||
lastModules = null;
|
||||
callback(err);
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
module.exports = AutomaticPrefetchPlugin;
|
125
node_modules/webpack/lib/BannerPlugin.js
generated
vendored
Normal file
125
node_modules/webpack/lib/BannerPlugin.js
generated
vendored
Normal file
@@ -0,0 +1,125 @@
|
||||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Tobias Koppers @sokra
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
const { ConcatSource } = require("webpack-sources");
|
||||
const Compilation = require("./Compilation");
|
||||
const ModuleFilenameHelpers = require("./ModuleFilenameHelpers");
|
||||
const Template = require("./Template");
|
||||
const createSchemaValidation = require("./util/create-schema-validation");
|
||||
|
||||
/** @typedef {import("../declarations/plugins/BannerPlugin").BannerPluginArgument} BannerPluginArgument */
|
||||
/** @typedef {import("../declarations/plugins/BannerPlugin").BannerPluginOptions} BannerPluginOptions */
|
||||
/** @typedef {import("./Compiler")} Compiler */
|
||||
|
||||
const validate = createSchemaValidation(
|
||||
require("../schemas/plugins/BannerPlugin.check.js"),
|
||||
() => require("../schemas/plugins/BannerPlugin.json"),
|
||||
{
|
||||
name: "Banner Plugin",
|
||||
baseDataPath: "options"
|
||||
}
|
||||
);
|
||||
|
||||
const wrapComment = str => {
|
||||
if (!str.includes("\n")) {
|
||||
return Template.toComment(str);
|
||||
}
|
||||
return `/*!\n * ${str
|
||||
.replace(/\*\//g, "* /")
|
||||
.split("\n")
|
||||
.join("\n * ")
|
||||
.replace(/\s+\n/g, "\n")
|
||||
.trimEnd()}\n */`;
|
||||
};
|
||||
|
||||
class BannerPlugin {
|
||||
/**
|
||||
* @param {BannerPluginArgument} options options object
|
||||
*/
|
||||
constructor(options) {
|
||||
if (typeof options === "string" || typeof options === "function") {
|
||||
options = {
|
||||
banner: options
|
||||
};
|
||||
}
|
||||
|
||||
validate(options);
|
||||
|
||||
this.options = options;
|
||||
|
||||
const bannerOption = options.banner;
|
||||
if (typeof bannerOption === "function") {
|
||||
const getBanner = bannerOption;
|
||||
this.banner = this.options.raw
|
||||
? getBanner
|
||||
: data => wrapComment(getBanner(data));
|
||||
} else {
|
||||
const banner = this.options.raw
|
||||
? bannerOption
|
||||
: wrapComment(bannerOption);
|
||||
this.banner = () => banner;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply the plugin
|
||||
* @param {Compiler} compiler the compiler instance
|
||||
* @returns {void}
|
||||
*/
|
||||
apply(compiler) {
|
||||
const options = this.options;
|
||||
const banner = this.banner;
|
||||
const matchObject = ModuleFilenameHelpers.matchObject.bind(
|
||||
undefined,
|
||||
options
|
||||
);
|
||||
const cache = new WeakMap();
|
||||
|
||||
compiler.hooks.compilation.tap("BannerPlugin", compilation => {
|
||||
compilation.hooks.processAssets.tap(
|
||||
{
|
||||
name: "BannerPlugin",
|
||||
stage: Compilation.PROCESS_ASSETS_STAGE_ADDITIONS
|
||||
},
|
||||
() => {
|
||||
for (const chunk of compilation.chunks) {
|
||||
if (options.entryOnly && !chunk.canBeInitial()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (const file of chunk.files) {
|
||||
if (!matchObject(file)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const data = {
|
||||
chunk,
|
||||
filename: file
|
||||
};
|
||||
|
||||
const comment = compilation.getPath(banner, data);
|
||||
|
||||
compilation.updateAsset(file, old => {
|
||||
let cached = cache.get(old);
|
||||
if (!cached || cached.comment !== comment) {
|
||||
const source = options.footer
|
||||
? new ConcatSource(old, "\n", comment)
|
||||
: new ConcatSource(comment, "\n", old);
|
||||
cache.set(old, { source, comment });
|
||||
return source;
|
||||
}
|
||||
return cached.source;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = BannerPlugin;
|
161
node_modules/webpack/lib/Cache.js
generated
vendored
Normal file
161
node_modules/webpack/lib/Cache.js
generated
vendored
Normal file
@@ -0,0 +1,161 @@
|
||||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Tobias Koppers @sokra
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
const { AsyncParallelHook, AsyncSeriesBailHook, SyncHook } = require("tapable");
|
||||
const {
|
||||
makeWebpackError,
|
||||
makeWebpackErrorCallback
|
||||
} = require("./HookWebpackError");
|
||||
|
||||
/** @typedef {import("./WebpackError")} WebpackError */
|
||||
|
||||
/**
|
||||
* @typedef {Object} Etag
|
||||
* @property {function(): string} toString
|
||||
*/
|
||||
|
||||
/**
|
||||
* @template T
|
||||
* @callback CallbackCache
|
||||
* @param {(WebpackError | null)=} err
|
||||
* @param {T=} result
|
||||
* @returns {void}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @callback GotHandler
|
||||
* @param {any} result
|
||||
* @param {function(Error=): void} callback
|
||||
* @returns {void}
|
||||
*/
|
||||
|
||||
const needCalls = (times, callback) => {
|
||||
return err => {
|
||||
if (--times === 0) {
|
||||
return callback(err);
|
||||
}
|
||||
if (err && times > 0) {
|
||||
times = 0;
|
||||
return callback(err);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
class Cache {
|
||||
constructor() {
|
||||
this.hooks = {
|
||||
/** @type {AsyncSeriesBailHook<[string, Etag | null, GotHandler[]], any>} */
|
||||
get: new AsyncSeriesBailHook(["identifier", "etag", "gotHandlers"]),
|
||||
/** @type {AsyncParallelHook<[string, Etag | null, any]>} */
|
||||
store: new AsyncParallelHook(["identifier", "etag", "data"]),
|
||||
/** @type {AsyncParallelHook<[Iterable<string>]>} */
|
||||
storeBuildDependencies: new AsyncParallelHook(["dependencies"]),
|
||||
/** @type {SyncHook<[]>} */
|
||||
beginIdle: new SyncHook([]),
|
||||
/** @type {AsyncParallelHook<[]>} */
|
||||
endIdle: new AsyncParallelHook([]),
|
||||
/** @type {AsyncParallelHook<[]>} */
|
||||
shutdown: new AsyncParallelHook([])
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @template T
|
||||
* @param {string} identifier the cache identifier
|
||||
* @param {Etag | null} etag the etag
|
||||
* @param {CallbackCache<T>} callback signals when the value is retrieved
|
||||
* @returns {void}
|
||||
*/
|
||||
get(identifier, etag, callback) {
|
||||
const gotHandlers = [];
|
||||
this.hooks.get.callAsync(identifier, etag, gotHandlers, (err, result) => {
|
||||
if (err) {
|
||||
callback(makeWebpackError(err, "Cache.hooks.get"));
|
||||
return;
|
||||
}
|
||||
if (result === null) {
|
||||
result = undefined;
|
||||
}
|
||||
if (gotHandlers.length > 1) {
|
||||
const innerCallback = needCalls(gotHandlers.length, () =>
|
||||
callback(null, result)
|
||||
);
|
||||
for (const gotHandler of gotHandlers) {
|
||||
gotHandler(result, innerCallback);
|
||||
}
|
||||
} else if (gotHandlers.length === 1) {
|
||||
gotHandlers[0](result, () => callback(null, result));
|
||||
} else {
|
||||
callback(null, result);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @template T
|
||||
* @param {string} identifier the cache identifier
|
||||
* @param {Etag | null} etag the etag
|
||||
* @param {T} data the value to store
|
||||
* @param {CallbackCache<void>} callback signals when the value is stored
|
||||
* @returns {void}
|
||||
*/
|
||||
store(identifier, etag, data, callback) {
|
||||
this.hooks.store.callAsync(
|
||||
identifier,
|
||||
etag,
|
||||
data,
|
||||
makeWebpackErrorCallback(callback, "Cache.hooks.store")
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* After this method has succeeded the cache can only be restored when build dependencies are
|
||||
* @param {Iterable<string>} dependencies list of all build dependencies
|
||||
* @param {CallbackCache<void>} callback signals when the dependencies are stored
|
||||
* @returns {void}
|
||||
*/
|
||||
storeBuildDependencies(dependencies, callback) {
|
||||
this.hooks.storeBuildDependencies.callAsync(
|
||||
dependencies,
|
||||
makeWebpackErrorCallback(callback, "Cache.hooks.storeBuildDependencies")
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {void}
|
||||
*/
|
||||
beginIdle() {
|
||||
this.hooks.beginIdle.call();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {CallbackCache<void>} callback signals when the call finishes
|
||||
* @returns {void}
|
||||
*/
|
||||
endIdle(callback) {
|
||||
this.hooks.endIdle.callAsync(
|
||||
makeWebpackErrorCallback(callback, "Cache.hooks.endIdle")
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {CallbackCache<void>} callback signals when the call finishes
|
||||
* @returns {void}
|
||||
*/
|
||||
shutdown(callback) {
|
||||
this.hooks.shutdown.callAsync(
|
||||
makeWebpackErrorCallback(callback, "Cache.hooks.shutdown")
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Cache.STAGE_MEMORY = -10;
|
||||
Cache.STAGE_DEFAULT = 0;
|
||||
Cache.STAGE_DISK = 10;
|
||||
Cache.STAGE_NETWORK = 20;
|
||||
|
||||
module.exports = Cache;
|
345
node_modules/webpack/lib/CacheFacade.js
generated
vendored
Normal file
345
node_modules/webpack/lib/CacheFacade.js
generated
vendored
Normal file
@@ -0,0 +1,345 @@
|
||||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Tobias Koppers @sokra
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
const { forEachBail } = require("enhanced-resolve");
|
||||
const asyncLib = require("neo-async");
|
||||
const getLazyHashedEtag = require("./cache/getLazyHashedEtag");
|
||||
const mergeEtags = require("./cache/mergeEtags");
|
||||
|
||||
/** @typedef {import("./Cache")} Cache */
|
||||
/** @typedef {import("./Cache").Etag} Etag */
|
||||
/** @typedef {import("./WebpackError")} WebpackError */
|
||||
/** @typedef {import("./cache/getLazyHashedEtag").HashableObject} HashableObject */
|
||||
/** @typedef {typeof import("./util/Hash")} HashConstructor */
|
||||
|
||||
/**
|
||||
* @template T
|
||||
* @callback CallbackCache
|
||||
* @param {(WebpackError | null)=} err
|
||||
* @param {T=} result
|
||||
* @returns {void}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @template T
|
||||
* @callback CallbackNormalErrorCache
|
||||
* @param {(Error | null)=} err
|
||||
* @param {T=} result
|
||||
* @returns {void}
|
||||
*/
|
||||
|
||||
class MultiItemCache {
|
||||
/**
|
||||
* @param {ItemCacheFacade[]} items item caches
|
||||
*/
|
||||
constructor(items) {
|
||||
this._items = items;
|
||||
if (items.length === 1) return /** @type {any} */ (items[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @template T
|
||||
* @param {CallbackCache<T>} callback signals when the value is retrieved
|
||||
* @returns {void}
|
||||
*/
|
||||
get(callback) {
|
||||
forEachBail(this._items, (item, callback) => item.get(callback), callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* @template T
|
||||
* @returns {Promise<T>} promise with the data
|
||||
*/
|
||||
getPromise() {
|
||||
const next = i => {
|
||||
return this._items[i].getPromise().then(result => {
|
||||
if (result !== undefined) return result;
|
||||
if (++i < this._items.length) return next(i);
|
||||
});
|
||||
};
|
||||
return next(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @template T
|
||||
* @param {T} data the value to store
|
||||
* @param {CallbackCache<void>} callback signals when the value is stored
|
||||
* @returns {void}
|
||||
*/
|
||||
store(data, callback) {
|
||||
asyncLib.each(
|
||||
this._items,
|
||||
(item, callback) => item.store(data, callback),
|
||||
callback
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @template T
|
||||
* @param {T} data the value to store
|
||||
* @returns {Promise<void>} promise signals when the value is stored
|
||||
*/
|
||||
storePromise(data) {
|
||||
return Promise.all(this._items.map(item => item.storePromise(data))).then(
|
||||
() => {}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class ItemCacheFacade {
|
||||
/**
|
||||
* @param {Cache} cache the root cache
|
||||
* @param {string} name the child cache item name
|
||||
* @param {Etag | null} etag the etag
|
||||
*/
|
||||
constructor(cache, name, etag) {
|
||||
this._cache = cache;
|
||||
this._name = name;
|
||||
this._etag = etag;
|
||||
}
|
||||
|
||||
/**
|
||||
* @template T
|
||||
* @param {CallbackCache<T>} callback signals when the value is retrieved
|
||||
* @returns {void}
|
||||
*/
|
||||
get(callback) {
|
||||
this._cache.get(this._name, this._etag, callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* @template T
|
||||
* @returns {Promise<T>} promise with the data
|
||||
*/
|
||||
getPromise() {
|
||||
return new Promise((resolve, reject) => {
|
||||
this._cache.get(this._name, this._etag, (err, data) => {
|
||||
if (err) {
|
||||
reject(err);
|
||||
} else {
|
||||
resolve(data);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @template T
|
||||
* @param {T} data the value to store
|
||||
* @param {CallbackCache<void>} callback signals when the value is stored
|
||||
* @returns {void}
|
||||
*/
|
||||
store(data, callback) {
|
||||
this._cache.store(this._name, this._etag, data, callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* @template T
|
||||
* @param {T} data the value to store
|
||||
* @returns {Promise<void>} promise signals when the value is stored
|
||||
*/
|
||||
storePromise(data) {
|
||||
return new Promise((resolve, reject) => {
|
||||
this._cache.store(this._name, this._etag, data, err => {
|
||||
if (err) {
|
||||
reject(err);
|
||||
} else {
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @template T
|
||||
* @param {function(CallbackNormalErrorCache<T>): void} computer function to compute the value if not cached
|
||||
* @param {CallbackNormalErrorCache<T>} callback signals when the value is retrieved
|
||||
* @returns {void}
|
||||
*/
|
||||
provide(computer, callback) {
|
||||
this.get((err, cacheEntry) => {
|
||||
if (err) return callback(err);
|
||||
if (cacheEntry !== undefined) return cacheEntry;
|
||||
computer((err, result) => {
|
||||
if (err) return callback(err);
|
||||
this.store(result, err => {
|
||||
if (err) return callback(err);
|
||||
callback(null, result);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @template T
|
||||
* @param {function(): Promise<T> | T} computer function to compute the value if not cached
|
||||
* @returns {Promise<T>} promise with the data
|
||||
*/
|
||||
async providePromise(computer) {
|
||||
const cacheEntry = await this.getPromise();
|
||||
if (cacheEntry !== undefined) return cacheEntry;
|
||||
const result = await computer();
|
||||
await this.storePromise(result);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
class CacheFacade {
|
||||
/**
|
||||
* @param {Cache} cache the root cache
|
||||
* @param {string} name the child cache name
|
||||
* @param {string | HashConstructor} hashFunction the hash function to use
|
||||
*/
|
||||
constructor(cache, name, hashFunction) {
|
||||
this._cache = cache;
|
||||
this._name = name;
|
||||
this._hashFunction = hashFunction;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} name the child cache name#
|
||||
* @returns {CacheFacade} child cache
|
||||
*/
|
||||
getChildCache(name) {
|
||||
return new CacheFacade(
|
||||
this._cache,
|
||||
`${this._name}|${name}`,
|
||||
this._hashFunction
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} identifier the cache identifier
|
||||
* @param {Etag | null} etag the etag
|
||||
* @returns {ItemCacheFacade} item cache
|
||||
*/
|
||||
getItemCache(identifier, etag) {
|
||||
return new ItemCacheFacade(
|
||||
this._cache,
|
||||
`${this._name}|${identifier}`,
|
||||
etag
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {HashableObject} obj an hashable object
|
||||
* @returns {Etag} an etag that is lazy hashed
|
||||
*/
|
||||
getLazyHashedEtag(obj) {
|
||||
return getLazyHashedEtag(obj, this._hashFunction);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Etag} a an etag
|
||||
* @param {Etag} b another etag
|
||||
* @returns {Etag} an etag that represents both
|
||||
*/
|
||||
mergeEtags(a, b) {
|
||||
return mergeEtags(a, b);
|
||||
}
|
||||
|
||||
/**
|
||||
* @template T
|
||||
* @param {string} identifier the cache identifier
|
||||
* @param {Etag | null} etag the etag
|
||||
* @param {CallbackCache<T>} callback signals when the value is retrieved
|
||||
* @returns {void}
|
||||
*/
|
||||
get(identifier, etag, callback) {
|
||||
this._cache.get(`${this._name}|${identifier}`, etag, callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* @template T
|
||||
* @param {string} identifier the cache identifier
|
||||
* @param {Etag | null} etag the etag
|
||||
* @returns {Promise<T>} promise with the data
|
||||
*/
|
||||
getPromise(identifier, etag) {
|
||||
return new Promise((resolve, reject) => {
|
||||
this._cache.get(`${this._name}|${identifier}`, etag, (err, data) => {
|
||||
if (err) {
|
||||
reject(err);
|
||||
} else {
|
||||
resolve(data);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @template T
|
||||
* @param {string} identifier the cache identifier
|
||||
* @param {Etag | null} etag the etag
|
||||
* @param {T} data the value to store
|
||||
* @param {CallbackCache<void>} callback signals when the value is stored
|
||||
* @returns {void}
|
||||
*/
|
||||
store(identifier, etag, data, callback) {
|
||||
this._cache.store(`${this._name}|${identifier}`, etag, data, callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* @template T
|
||||
* @param {string} identifier the cache identifier
|
||||
* @param {Etag | null} etag the etag
|
||||
* @param {T} data the value to store
|
||||
* @returns {Promise<void>} promise signals when the value is stored
|
||||
*/
|
||||
storePromise(identifier, etag, data) {
|
||||
return new Promise((resolve, reject) => {
|
||||
this._cache.store(`${this._name}|${identifier}`, etag, data, err => {
|
||||
if (err) {
|
||||
reject(err);
|
||||
} else {
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @template T
|
||||
* @param {string} identifier the cache identifier
|
||||
* @param {Etag | null} etag the etag
|
||||
* @param {function(CallbackNormalErrorCache<T>): void} computer function to compute the value if not cached
|
||||
* @param {CallbackNormalErrorCache<T>} callback signals when the value is retrieved
|
||||
* @returns {void}
|
||||
*/
|
||||
provide(identifier, etag, computer, callback) {
|
||||
this.get(identifier, etag, (err, cacheEntry) => {
|
||||
if (err) return callback(err);
|
||||
if (cacheEntry !== undefined) return cacheEntry;
|
||||
computer((err, result) => {
|
||||
if (err) return callback(err);
|
||||
this.store(identifier, etag, result, err => {
|
||||
if (err) return callback(err);
|
||||
callback(null, result);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @template T
|
||||
* @param {string} identifier the cache identifier
|
||||
* @param {Etag | null} etag the etag
|
||||
* @param {function(): Promise<T> | T} computer function to compute the value if not cached
|
||||
* @returns {Promise<T>} promise with the data
|
||||
*/
|
||||
async providePromise(identifier, etag, computer) {
|
||||
const cacheEntry = await this.getPromise(identifier, etag);
|
||||
if (cacheEntry !== undefined) return cacheEntry;
|
||||
const result = await computer();
|
||||
await this.storePromise(identifier, etag, result);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = CacheFacade;
|
||||
module.exports.ItemCacheFacade = ItemCacheFacade;
|
||||
module.exports.MultiItemCache = MultiItemCache;
|
71
node_modules/webpack/lib/CaseSensitiveModulesWarning.js
generated
vendored
Normal file
71
node_modules/webpack/lib/CaseSensitiveModulesWarning.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 WebpackError = require("./WebpackError");
|
||||
|
||||
/** @typedef {import("./Module")} Module */
|
||||
/** @typedef {import("./ModuleGraph")} ModuleGraph */
|
||||
|
||||
/**
|
||||
* @param {Module[]} modules the modules to be sorted
|
||||
* @returns {Module[]} sorted version of original modules
|
||||
*/
|
||||
const sortModules = modules => {
|
||||
return modules.sort((a, b) => {
|
||||
const aIdent = a.identifier();
|
||||
const bIdent = b.identifier();
|
||||
/* istanbul ignore next */
|
||||
if (aIdent < bIdent) return -1;
|
||||
/* istanbul ignore next */
|
||||
if (aIdent > bIdent) return 1;
|
||||
/* istanbul ignore next */
|
||||
return 0;
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {Module[]} modules each module from throw
|
||||
* @param {ModuleGraph} moduleGraph the module graph
|
||||
* @returns {string} each message from provided modules
|
||||
*/
|
||||
const createModulesListMessage = (modules, moduleGraph) => {
|
||||
return modules
|
||||
.map(m => {
|
||||
let message = `* ${m.identifier()}`;
|
||||
const validReasons = Array.from(
|
||||
moduleGraph.getIncomingConnectionsByOriginModule(m).keys()
|
||||
).filter(x => x);
|
||||
|
||||
if (validReasons.length > 0) {
|
||||
message += `\n Used by ${validReasons.length} module(s), i. e.`;
|
||||
message += `\n ${validReasons[0].identifier()}`;
|
||||
}
|
||||
return message;
|
||||
})
|
||||
.join("\n");
|
||||
};
|
||||
|
||||
class CaseSensitiveModulesWarning extends WebpackError {
|
||||
/**
|
||||
* Creates an instance of CaseSensitiveModulesWarning.
|
||||
* @param {Iterable<Module>} modules modules that were detected
|
||||
* @param {ModuleGraph} moduleGraph the module graph
|
||||
*/
|
||||
constructor(modules, moduleGraph) {
|
||||
const sortedModules = sortModules(Array.from(modules));
|
||||
const modulesList = createModulesListMessage(sortedModules, moduleGraph);
|
||||
super(`There are multiple modules with names that only differ in casing.
|
||||
This can lead to unexpected behavior when compiling on a filesystem with other case-semantic.
|
||||
Use equal casing. Compare these module identifiers:
|
||||
${modulesList}`);
|
||||
|
||||
this.name = "CaseSensitiveModulesWarning";
|
||||
this.module = sortedModules[0];
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = CaseSensitiveModulesWarning;
|
820
node_modules/webpack/lib/Chunk.js
generated
vendored
Normal file
820
node_modules/webpack/lib/Chunk.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1814
node_modules/webpack/lib/ChunkGraph.js
generated
vendored
Normal file
1814
node_modules/webpack/lib/ChunkGraph.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
584
node_modules/webpack/lib/ChunkGroup.js
generated
vendored
Normal file
584
node_modules/webpack/lib/ChunkGroup.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
31
node_modules/webpack/lib/ChunkRenderError.js
generated
vendored
Normal file
31
node_modules/webpack/lib/ChunkRenderError.js
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Tobias Koppers @sokra
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
const WebpackError = require("./WebpackError");
|
||||
|
||||
/** @typedef {import("./Chunk")} Chunk */
|
||||
|
||||
class ChunkRenderError extends WebpackError {
|
||||
/**
|
||||
* Create a new ChunkRenderError
|
||||
* @param {Chunk} chunk A chunk
|
||||
* @param {string} file Related file
|
||||
* @param {Error} error Original error
|
||||
*/
|
||||
constructor(chunk, file, error) {
|
||||
super();
|
||||
|
||||
this.name = "ChunkRenderError";
|
||||
this.error = error;
|
||||
this.message = error.message;
|
||||
this.details = error.stack;
|
||||
this.file = file;
|
||||
this.chunk = chunk;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = ChunkRenderError;
|
138
node_modules/webpack/lib/ChunkTemplate.js
generated
vendored
Normal file
138
node_modules/webpack/lib/ChunkTemplate.js
generated
vendored
Normal file
@@ -0,0 +1,138 @@
|
||||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Tobias Koppers @sokra
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
const util = require("util");
|
||||
const memoize = require("./util/memoize");
|
||||
|
||||
/** @typedef {import("../declarations/WebpackOptions").Output} OutputOptions */
|
||||
/** @typedef {import("./Compilation")} Compilation */
|
||||
|
||||
const getJavascriptModulesPlugin = memoize(() =>
|
||||
require("./javascript/JavascriptModulesPlugin")
|
||||
);
|
||||
|
||||
// TODO webpack 6 remove this class
|
||||
class ChunkTemplate {
|
||||
/**
|
||||
* @param {OutputOptions} outputOptions output options
|
||||
* @param {Compilation} compilation the compilation
|
||||
*/
|
||||
constructor(outputOptions, compilation) {
|
||||
this._outputOptions = outputOptions || {};
|
||||
this.hooks = Object.freeze({
|
||||
renderManifest: {
|
||||
tap: util.deprecate(
|
||||
(options, fn) => {
|
||||
compilation.hooks.renderManifest.tap(
|
||||
options,
|
||||
(entries, options) => {
|
||||
if (options.chunk.hasRuntime()) return entries;
|
||||
return fn(entries, options);
|
||||
}
|
||||
);
|
||||
},
|
||||
"ChunkTemplate.hooks.renderManifest is deprecated (use Compilation.hooks.renderManifest instead)",
|
||||
"DEP_WEBPACK_CHUNK_TEMPLATE_RENDER_MANIFEST"
|
||||
)
|
||||
},
|
||||
modules: {
|
||||
tap: util.deprecate(
|
||||
(options, fn) => {
|
||||
getJavascriptModulesPlugin()
|
||||
.getCompilationHooks(compilation)
|
||||
.renderChunk.tap(options, (source, renderContext) =>
|
||||
fn(
|
||||
source,
|
||||
compilation.moduleTemplates.javascript,
|
||||
renderContext
|
||||
)
|
||||
);
|
||||
},
|
||||
"ChunkTemplate.hooks.modules is deprecated (use JavascriptModulesPlugin.getCompilationHooks().renderChunk instead)",
|
||||
"DEP_WEBPACK_CHUNK_TEMPLATE_MODULES"
|
||||
)
|
||||
},
|
||||
render: {
|
||||
tap: util.deprecate(
|
||||
(options, fn) => {
|
||||
getJavascriptModulesPlugin()
|
||||
.getCompilationHooks(compilation)
|
||||
.renderChunk.tap(options, (source, renderContext) =>
|
||||
fn(
|
||||
source,
|
||||
compilation.moduleTemplates.javascript,
|
||||
renderContext
|
||||
)
|
||||
);
|
||||
},
|
||||
"ChunkTemplate.hooks.render is deprecated (use JavascriptModulesPlugin.getCompilationHooks().renderChunk instead)",
|
||||
"DEP_WEBPACK_CHUNK_TEMPLATE_RENDER"
|
||||
)
|
||||
},
|
||||
renderWithEntry: {
|
||||
tap: util.deprecate(
|
||||
(options, fn) => {
|
||||
getJavascriptModulesPlugin()
|
||||
.getCompilationHooks(compilation)
|
||||
.render.tap(options, (source, renderContext) => {
|
||||
if (
|
||||
renderContext.chunkGraph.getNumberOfEntryModules(
|
||||
renderContext.chunk
|
||||
) === 0 ||
|
||||
renderContext.chunk.hasRuntime()
|
||||
) {
|
||||
return source;
|
||||
}
|
||||
return fn(source, renderContext.chunk);
|
||||
});
|
||||
},
|
||||
"ChunkTemplate.hooks.renderWithEntry is deprecated (use JavascriptModulesPlugin.getCompilationHooks().render instead)",
|
||||
"DEP_WEBPACK_CHUNK_TEMPLATE_RENDER_WITH_ENTRY"
|
||||
)
|
||||
},
|
||||
hash: {
|
||||
tap: util.deprecate(
|
||||
(options, fn) => {
|
||||
compilation.hooks.fullHash.tap(options, fn);
|
||||
},
|
||||
"ChunkTemplate.hooks.hash is deprecated (use Compilation.hooks.fullHash instead)",
|
||||
"DEP_WEBPACK_CHUNK_TEMPLATE_HASH"
|
||||
)
|
||||
},
|
||||
hashForChunk: {
|
||||
tap: util.deprecate(
|
||||
(options, fn) => {
|
||||
getJavascriptModulesPlugin()
|
||||
.getCompilationHooks(compilation)
|
||||
.chunkHash.tap(options, (chunk, hash, context) => {
|
||||
if (chunk.hasRuntime()) return;
|
||||
fn(hash, chunk, context);
|
||||
});
|
||||
},
|
||||
"ChunkTemplate.hooks.hashForChunk is deprecated (use JavascriptModulesPlugin.getCompilationHooks().chunkHash instead)",
|
||||
"DEP_WEBPACK_CHUNK_TEMPLATE_HASH_FOR_CHUNK"
|
||||
)
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Object.defineProperty(ChunkTemplate.prototype, "outputOptions", {
|
||||
get: util.deprecate(
|
||||
/**
|
||||
* @this {ChunkTemplate}
|
||||
* @returns {OutputOptions} output options
|
||||
*/
|
||||
function () {
|
||||
return this._outputOptions;
|
||||
},
|
||||
"ChunkTemplate.outputOptions is deprecated (use Compilation.outputOptions instead)",
|
||||
"DEP_WEBPACK_CHUNK_TEMPLATE_OUTPUT_OPTIONS"
|
||||
)
|
||||
});
|
||||
|
||||
module.exports = ChunkTemplate;
|
420
node_modules/webpack/lib/CleanPlugin.js
generated
vendored
Normal file
420
node_modules/webpack/lib/CleanPlugin.js
generated
vendored
Normal file
@@ -0,0 +1,420 @@
|
||||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Sergey Melyukov @smelukov
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
const asyncLib = require("neo-async");
|
||||
const { SyncBailHook } = require("tapable");
|
||||
const Compilation = require("../lib/Compilation");
|
||||
const createSchemaValidation = require("./util/create-schema-validation");
|
||||
const { join } = require("./util/fs");
|
||||
const processAsyncTree = require("./util/processAsyncTree");
|
||||
|
||||
/** @typedef {import("../declarations/WebpackOptions").CleanOptions} CleanOptions */
|
||||
/** @typedef {import("./Compiler")} Compiler */
|
||||
/** @typedef {import("./logging/Logger").Logger} Logger */
|
||||
/** @typedef {import("./util/fs").OutputFileSystem} OutputFileSystem */
|
||||
/** @typedef {import("./util/fs").StatsCallback} StatsCallback */
|
||||
|
||||
/** @typedef {(function(string):boolean)|RegExp} IgnoreItem */
|
||||
/** @typedef {Map<string, number>} Assets */
|
||||
/** @typedef {function(IgnoreItem): void} AddToIgnoreCallback */
|
||||
|
||||
/**
|
||||
* @typedef {Object} CleanPluginCompilationHooks
|
||||
* @property {SyncBailHook<[string], boolean>} keep when returning true the file/directory will be kept during cleaning, returning false will clean it and ignore the following plugins and config
|
||||
*/
|
||||
|
||||
const validate = createSchemaValidation(
|
||||
undefined,
|
||||
() => {
|
||||
const { definitions } = require("../schemas/WebpackOptions.json");
|
||||
return {
|
||||
definitions,
|
||||
oneOf: [{ $ref: "#/definitions/CleanOptions" }]
|
||||
};
|
||||
},
|
||||
{
|
||||
name: "Clean Plugin",
|
||||
baseDataPath: "options"
|
||||
}
|
||||
);
|
||||
const _10sec = 10 * 1000;
|
||||
|
||||
/**
|
||||
* marge assets map 2 into map 1
|
||||
* @param {Assets} as1 assets
|
||||
* @param {Assets} as2 assets
|
||||
* @returns {void}
|
||||
*/
|
||||
const mergeAssets = (as1, as2) => {
|
||||
for (const [key, value1] of as2) {
|
||||
const value2 = as1.get(key);
|
||||
if (!value2 || value1 > value2) as1.set(key, value1);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {OutputFileSystem} fs filesystem
|
||||
* @param {string} outputPath output path
|
||||
* @param {Map<string, number>} currentAssets filename of the current assets (must not start with .. or ., must only use / as path separator)
|
||||
* @param {function((Error | null)=, Set<string>=): void} callback returns the filenames of the assets that shouldn't be there
|
||||
* @returns {void}
|
||||
*/
|
||||
const getDiffToFs = (fs, outputPath, currentAssets, callback) => {
|
||||
const directories = new Set();
|
||||
// get directories of assets
|
||||
for (const [asset] of currentAssets) {
|
||||
directories.add(asset.replace(/(^|\/)[^/]*$/, ""));
|
||||
}
|
||||
// and all parent directories
|
||||
for (const directory of directories) {
|
||||
directories.add(directory.replace(/(^|\/)[^/]*$/, ""));
|
||||
}
|
||||
const diff = new Set();
|
||||
asyncLib.forEachLimit(
|
||||
directories,
|
||||
10,
|
||||
(directory, callback) => {
|
||||
fs.readdir(join(fs, outputPath, directory), (err, entries) => {
|
||||
if (err) {
|
||||
if (err.code === "ENOENT") return callback();
|
||||
if (err.code === "ENOTDIR") {
|
||||
diff.add(directory);
|
||||
return callback();
|
||||
}
|
||||
return callback(err);
|
||||
}
|
||||
for (const entry of entries) {
|
||||
const file = /** @type {string} */ (entry);
|
||||
const filename = directory ? `${directory}/${file}` : file;
|
||||
if (!directories.has(filename) && !currentAssets.has(filename)) {
|
||||
diff.add(filename);
|
||||
}
|
||||
}
|
||||
callback();
|
||||
});
|
||||
},
|
||||
err => {
|
||||
if (err) return callback(err);
|
||||
|
||||
callback(null, diff);
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {Assets} currentAssets assets list
|
||||
* @param {Assets} oldAssets old assets list
|
||||
* @returns {Set<string>} diff
|
||||
*/
|
||||
const getDiffToOldAssets = (currentAssets, oldAssets) => {
|
||||
const diff = new Set();
|
||||
const now = Date.now();
|
||||
for (const [asset, ts] of oldAssets) {
|
||||
if (ts >= now) continue;
|
||||
if (!currentAssets.has(asset)) diff.add(asset);
|
||||
}
|
||||
return diff;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {OutputFileSystem} fs filesystem
|
||||
* @param {string} filename path to file
|
||||
* @param {StatsCallback} callback callback for provided filename
|
||||
* @returns {void}
|
||||
*/
|
||||
const doStat = (fs, filename, callback) => {
|
||||
if ("lstat" in fs) {
|
||||
fs.lstat(filename, callback);
|
||||
} else {
|
||||
fs.stat(filename, callback);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {OutputFileSystem} fs filesystem
|
||||
* @param {string} outputPath output path
|
||||
* @param {boolean} dry only log instead of fs modification
|
||||
* @param {Logger} logger logger
|
||||
* @param {Set<string>} diff filenames of the assets that shouldn't be there
|
||||
* @param {function(string): boolean} isKept check if the entry is ignored
|
||||
* @param {function(Error=, Assets=): void} callback callback
|
||||
* @returns {void}
|
||||
*/
|
||||
const applyDiff = (fs, outputPath, dry, logger, diff, isKept, callback) => {
|
||||
const log = msg => {
|
||||
if (dry) {
|
||||
logger.info(msg);
|
||||
} else {
|
||||
logger.log(msg);
|
||||
}
|
||||
};
|
||||
/** @typedef {{ type: "check" | "unlink" | "rmdir", filename: string, parent: { remaining: number, job: Job } | undefined }} Job */
|
||||
/** @type {Job[]} */
|
||||
const jobs = Array.from(diff.keys(), filename => ({
|
||||
type: "check",
|
||||
filename,
|
||||
parent: undefined
|
||||
}));
|
||||
/** @type {Assets} */
|
||||
const keptAssets = new Map();
|
||||
processAsyncTree(
|
||||
jobs,
|
||||
10,
|
||||
({ type, filename, parent }, push, callback) => {
|
||||
const handleError = err => {
|
||||
if (err.code === "ENOENT") {
|
||||
log(`${filename} was removed during cleaning by something else`);
|
||||
handleParent();
|
||||
return callback();
|
||||
}
|
||||
return callback(err);
|
||||
};
|
||||
const handleParent = () => {
|
||||
if (parent && --parent.remaining === 0) push(parent.job);
|
||||
};
|
||||
const path = join(fs, outputPath, filename);
|
||||
switch (type) {
|
||||
case "check":
|
||||
if (isKept(filename)) {
|
||||
keptAssets.set(filename, 0);
|
||||
// do not decrement parent entry as we don't want to delete the parent
|
||||
log(`${filename} will be kept`);
|
||||
return process.nextTick(callback);
|
||||
}
|
||||
doStat(fs, path, (err, stats) => {
|
||||
if (err) return handleError(err);
|
||||
if (!stats.isDirectory()) {
|
||||
push({
|
||||
type: "unlink",
|
||||
filename,
|
||||
parent
|
||||
});
|
||||
return callback();
|
||||
}
|
||||
fs.readdir(path, (err, entries) => {
|
||||
if (err) return handleError(err);
|
||||
/** @type {Job} */
|
||||
const deleteJob = {
|
||||
type: "rmdir",
|
||||
filename,
|
||||
parent
|
||||
};
|
||||
if (entries.length === 0) {
|
||||
push(deleteJob);
|
||||
} else {
|
||||
const parentToken = {
|
||||
remaining: entries.length,
|
||||
job: deleteJob
|
||||
};
|
||||
for (const entry of entries) {
|
||||
const file = /** @type {string} */ (entry);
|
||||
if (file.startsWith(".")) {
|
||||
log(
|
||||
`${filename} will be kept (dot-files will never be removed)`
|
||||
);
|
||||
continue;
|
||||
}
|
||||
push({
|
||||
type: "check",
|
||||
filename: `${filename}/${file}`,
|
||||
parent: parentToken
|
||||
});
|
||||
}
|
||||
}
|
||||
return callback();
|
||||
});
|
||||
});
|
||||
break;
|
||||
case "rmdir":
|
||||
log(`${filename} will be removed`);
|
||||
if (dry) {
|
||||
handleParent();
|
||||
return process.nextTick(callback);
|
||||
}
|
||||
if (!fs.rmdir) {
|
||||
logger.warn(
|
||||
`${filename} can't be removed because output file system doesn't support removing directories (rmdir)`
|
||||
);
|
||||
return process.nextTick(callback);
|
||||
}
|
||||
fs.rmdir(path, err => {
|
||||
if (err) return handleError(err);
|
||||
handleParent();
|
||||
callback();
|
||||
});
|
||||
break;
|
||||
case "unlink":
|
||||
log(`${filename} will be removed`);
|
||||
if (dry) {
|
||||
handleParent();
|
||||
return process.nextTick(callback);
|
||||
}
|
||||
if (!fs.unlink) {
|
||||
logger.warn(
|
||||
`${filename} can't be removed because output file system doesn't support removing files (rmdir)`
|
||||
);
|
||||
return process.nextTick(callback);
|
||||
}
|
||||
fs.unlink(path, err => {
|
||||
if (err) return handleError(err);
|
||||
handleParent();
|
||||
callback();
|
||||
});
|
||||
break;
|
||||
}
|
||||
},
|
||||
err => {
|
||||
if (err) return callback(err);
|
||||
callback(undefined, keptAssets);
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
/** @type {WeakMap<Compilation, CleanPluginCompilationHooks>} */
|
||||
const compilationHooksMap = new WeakMap();
|
||||
|
||||
class CleanPlugin {
|
||||
/**
|
||||
* @param {Compilation} compilation the compilation
|
||||
* @returns {CleanPluginCompilationHooks} the attached hooks
|
||||
*/
|
||||
static getCompilationHooks(compilation) {
|
||||
if (!(compilation instanceof Compilation)) {
|
||||
throw new TypeError(
|
||||
"The 'compilation' argument must be an instance of Compilation"
|
||||
);
|
||||
}
|
||||
let hooks = compilationHooksMap.get(compilation);
|
||||
if (hooks === undefined) {
|
||||
hooks = {
|
||||
/** @type {SyncBailHook<[string], boolean>} */
|
||||
keep: new SyncBailHook(["ignore"])
|
||||
};
|
||||
compilationHooksMap.set(compilation, hooks);
|
||||
}
|
||||
return hooks;
|
||||
}
|
||||
|
||||
/** @param {CleanOptions} options options */
|
||||
constructor(options = {}) {
|
||||
validate(options);
|
||||
this.options = { dry: false, ...options };
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply the plugin
|
||||
* @param {Compiler} compiler the compiler instance
|
||||
* @returns {void}
|
||||
*/
|
||||
apply(compiler) {
|
||||
const { dry, keep } = this.options;
|
||||
|
||||
const keepFn =
|
||||
typeof keep === "function"
|
||||
? keep
|
||||
: typeof keep === "string"
|
||||
? path => path.startsWith(keep)
|
||||
: typeof keep === "object" && keep.test
|
||||
? path => keep.test(path)
|
||||
: () => false;
|
||||
|
||||
// We assume that no external modification happens while the compiler is active
|
||||
// So we can store the old assets and only diff to them to avoid fs access on
|
||||
// incremental builds
|
||||
/** @type {undefined|Assets} */
|
||||
let oldAssets;
|
||||
|
||||
compiler.hooks.emit.tapAsync(
|
||||
{
|
||||
name: "CleanPlugin",
|
||||
stage: 100
|
||||
},
|
||||
(compilation, callback) => {
|
||||
const hooks = CleanPlugin.getCompilationHooks(compilation);
|
||||
const logger = compilation.getLogger("webpack.CleanPlugin");
|
||||
const fs = compiler.outputFileSystem;
|
||||
|
||||
if (!fs.readdir) {
|
||||
return callback(
|
||||
new Error(
|
||||
"CleanPlugin: Output filesystem doesn't support listing directories (readdir)"
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/** @type {Assets} */
|
||||
const currentAssets = new Map();
|
||||
const now = Date.now();
|
||||
for (const asset of Object.keys(compilation.assets)) {
|
||||
if (/^[A-Za-z]:\\|^\/|^\\\\/.test(asset)) continue;
|
||||
let normalizedAsset;
|
||||
let newNormalizedAsset = asset.replace(/\\/g, "/");
|
||||
do {
|
||||
normalizedAsset = newNormalizedAsset;
|
||||
newNormalizedAsset = normalizedAsset.replace(
|
||||
/(^|\/)(?!\.\.)[^/]+\/\.\.\//g,
|
||||
"$1"
|
||||
);
|
||||
} while (newNormalizedAsset !== normalizedAsset);
|
||||
if (normalizedAsset.startsWith("../")) continue;
|
||||
const assetInfo = compilation.assetsInfo.get(asset);
|
||||
if (assetInfo && assetInfo.hotModuleReplacement) {
|
||||
currentAssets.set(normalizedAsset, now + _10sec);
|
||||
} else {
|
||||
currentAssets.set(normalizedAsset, 0);
|
||||
}
|
||||
}
|
||||
|
||||
const outputPath = compilation.getPath(compiler.outputPath, {});
|
||||
|
||||
const isKept = path => {
|
||||
const result = hooks.keep.call(path);
|
||||
if (result !== undefined) return result;
|
||||
return keepFn(path);
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {Error=} err err
|
||||
* @param {Set<string>=} diff diff
|
||||
*/
|
||||
const diffCallback = (err, diff) => {
|
||||
if (err) {
|
||||
oldAssets = undefined;
|
||||
callback(err);
|
||||
return;
|
||||
}
|
||||
applyDiff(
|
||||
fs,
|
||||
outputPath,
|
||||
dry,
|
||||
logger,
|
||||
diff,
|
||||
isKept,
|
||||
(err, keptAssets) => {
|
||||
if (err) {
|
||||
oldAssets = undefined;
|
||||
} else {
|
||||
if (oldAssets) mergeAssets(currentAssets, oldAssets);
|
||||
oldAssets = currentAssets;
|
||||
if (keptAssets) mergeAssets(oldAssets, keptAssets);
|
||||
}
|
||||
callback(err);
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
if (oldAssets) {
|
||||
diffCallback(null, getDiffToOldAssets(currentAssets, oldAssets));
|
||||
} else {
|
||||
getDiffToFs(fs, outputPath, currentAssets, diffCallback);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = CleanPlugin;
|
29
node_modules/webpack/lib/CodeGenerationError.js
generated
vendored
Normal file
29
node_modules/webpack/lib/CodeGenerationError.js
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Tobias Koppers @sokra
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
const WebpackError = require("./WebpackError");
|
||||
|
||||
/** @typedef {import("./Module")} Module */
|
||||
|
||||
class CodeGenerationError extends WebpackError {
|
||||
/**
|
||||
* Create a new CodeGenerationError
|
||||
* @param {Module} module related module
|
||||
* @param {Error} error Original error
|
||||
*/
|
||||
constructor(module, error) {
|
||||
super();
|
||||
|
||||
this.name = "CodeGenerationError";
|
||||
this.error = error;
|
||||
this.message = error.message;
|
||||
this.details = error.stack;
|
||||
this.module = module;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = CodeGenerationError;
|
155
node_modules/webpack/lib/CodeGenerationResults.js
generated
vendored
Normal file
155
node_modules/webpack/lib/CodeGenerationResults.js
generated
vendored
Normal file
@@ -0,0 +1,155 @@
|
||||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Tobias Koppers @sokra
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
const { provide } = require("./util/MapHelpers");
|
||||
const { first } = require("./util/SetHelpers");
|
||||
const createHash = require("./util/createHash");
|
||||
const { runtimeToString, RuntimeSpecMap } = require("./util/runtime");
|
||||
|
||||
/** @typedef {import("webpack-sources").Source} Source */
|
||||
/** @typedef {import("./Module")} Module */
|
||||
/** @typedef {import("./Module").CodeGenerationResult} CodeGenerationResult */
|
||||
/** @typedef {typeof import("./util/Hash")} Hash */
|
||||
/** @typedef {import("./util/runtime").RuntimeSpec} RuntimeSpec */
|
||||
|
||||
class CodeGenerationResults {
|
||||
/**
|
||||
* @param {string | Hash} hashFunction the hash function to use
|
||||
*/
|
||||
constructor(hashFunction = "md4") {
|
||||
/** @type {Map<Module, RuntimeSpecMap<CodeGenerationResult>>} */
|
||||
this.map = new Map();
|
||||
this._hashFunction = hashFunction;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Module} module the module
|
||||
* @param {RuntimeSpec} runtime runtime(s)
|
||||
* @returns {CodeGenerationResult} the CodeGenerationResult
|
||||
*/
|
||||
get(module, runtime) {
|
||||
const entry = this.map.get(module);
|
||||
if (entry === undefined) {
|
||||
throw new Error(
|
||||
`No code generation entry for ${module.identifier()} (existing entries: ${Array.from(
|
||||
this.map.keys(),
|
||||
m => m.identifier()
|
||||
).join(", ")})`
|
||||
);
|
||||
}
|
||||
if (runtime === undefined) {
|
||||
if (entry.size > 1) {
|
||||
const results = new Set(entry.values());
|
||||
if (results.size !== 1) {
|
||||
throw new Error(
|
||||
`No unique code generation entry for unspecified runtime for ${module.identifier()} (existing runtimes: ${Array.from(
|
||||
entry.keys(),
|
||||
r => runtimeToString(r)
|
||||
).join(", ")}).
|
||||
Caller might not support runtime-dependent code generation (opt-out via optimization.usedExports: "global").`
|
||||
);
|
||||
}
|
||||
return first(results);
|
||||
}
|
||||
return entry.values().next().value;
|
||||
}
|
||||
const result = entry.get(runtime);
|
||||
if (result === undefined) {
|
||||
throw new Error(
|
||||
`No code generation entry for runtime ${runtimeToString(
|
||||
runtime
|
||||
)} for ${module.identifier()} (existing runtimes: ${Array.from(
|
||||
entry.keys(),
|
||||
r => runtimeToString(r)
|
||||
).join(", ")})`
|
||||
);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Module} module the module
|
||||
* @param {RuntimeSpec} runtime runtime(s)
|
||||
* @returns {boolean} true, when we have data for this
|
||||
*/
|
||||
has(module, runtime) {
|
||||
const entry = this.map.get(module);
|
||||
if (entry === undefined) {
|
||||
return false;
|
||||
}
|
||||
if (runtime !== undefined) {
|
||||
return entry.has(runtime);
|
||||
} else if (entry.size > 1) {
|
||||
const results = new Set(entry.values());
|
||||
return results.size === 1;
|
||||
} else {
|
||||
return entry.size === 1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Module} module the module
|
||||
* @param {RuntimeSpec} runtime runtime(s)
|
||||
* @param {string} sourceType the source type
|
||||
* @returns {Source} a source
|
||||
*/
|
||||
getSource(module, runtime, sourceType) {
|
||||
return this.get(module, runtime).sources.get(sourceType);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Module} module the module
|
||||
* @param {RuntimeSpec} runtime runtime(s)
|
||||
* @returns {ReadonlySet<string>} runtime requirements
|
||||
*/
|
||||
getRuntimeRequirements(module, runtime) {
|
||||
return this.get(module, runtime).runtimeRequirements;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Module} module the module
|
||||
* @param {RuntimeSpec} runtime runtime(s)
|
||||
* @param {string} key data key
|
||||
* @returns {any} data generated by code generation
|
||||
*/
|
||||
getData(module, runtime, key) {
|
||||
const data = this.get(module, runtime).data;
|
||||
return data === undefined ? undefined : data.get(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Module} module the module
|
||||
* @param {RuntimeSpec} runtime runtime(s)
|
||||
* @returns {any} hash of the code generation
|
||||
*/
|
||||
getHash(module, runtime) {
|
||||
const info = this.get(module, runtime);
|
||||
if (info.hash !== undefined) return info.hash;
|
||||
const hash = createHash(this._hashFunction);
|
||||
for (const [type, source] of info.sources) {
|
||||
hash.update(type);
|
||||
source.updateHash(hash);
|
||||
}
|
||||
if (info.runtimeRequirements) {
|
||||
for (const rr of info.runtimeRequirements) hash.update(rr);
|
||||
}
|
||||
return (info.hash = /** @type {string} */ (hash.digest("hex")));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Module} module the module
|
||||
* @param {RuntimeSpec} runtime runtime(s)
|
||||
* @param {CodeGenerationResult} result result from module
|
||||
* @returns {void}
|
||||
*/
|
||||
add(module, runtime, result) {
|
||||
const map = provide(this.map, module, () => new RuntimeSpecMap());
|
||||
map.set(runtime, result);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = CodeGenerationResults;
|
33
node_modules/webpack/lib/CommentCompilationWarning.js
generated
vendored
Normal file
33
node_modules/webpack/lib/CommentCompilationWarning.js
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Tobias Koppers @sokra
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
const WebpackError = require("./WebpackError");
|
||||
const makeSerializable = require("./util/makeSerializable");
|
||||
|
||||
/** @typedef {import("./Dependency").DependencyLocation} DependencyLocation */
|
||||
|
||||
class CommentCompilationWarning extends WebpackError {
|
||||
/**
|
||||
*
|
||||
* @param {string} message warning message
|
||||
* @param {DependencyLocation} loc affected lines of code
|
||||
*/
|
||||
constructor(message, loc) {
|
||||
super(message);
|
||||
|
||||
this.name = "CommentCompilationWarning";
|
||||
|
||||
this.loc = loc;
|
||||
}
|
||||
}
|
||||
|
||||
makeSerializable(
|
||||
CommentCompilationWarning,
|
||||
"webpack/lib/CommentCompilationWarning"
|
||||
);
|
||||
|
||||
module.exports = CommentCompilationWarning;
|
152
node_modules/webpack/lib/CompatibilityPlugin.js
generated
vendored
Normal file
152
node_modules/webpack/lib/CompatibilityPlugin.js
generated
vendored
Normal file
@@ -0,0 +1,152 @@
|
||||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Tobias Koppers @sokra
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
const ConstDependency = require("./dependencies/ConstDependency");
|
||||
|
||||
/** @typedef {import("./Compiler")} Compiler */
|
||||
/** @typedef {import("./javascript/JavascriptParser")} JavascriptParser */
|
||||
|
||||
const nestedWebpackRequireTag = Symbol("nested __webpack_require__");
|
||||
|
||||
class CompatibilityPlugin {
|
||||
/**
|
||||
* Apply the plugin
|
||||
* @param {Compiler} compiler the compiler instance
|
||||
* @returns {void}
|
||||
*/
|
||||
apply(compiler) {
|
||||
compiler.hooks.compilation.tap(
|
||||
"CompatibilityPlugin",
|
||||
(compilation, { normalModuleFactory }) => {
|
||||
compilation.dependencyTemplates.set(
|
||||
ConstDependency,
|
||||
new ConstDependency.Template()
|
||||
);
|
||||
|
||||
normalModuleFactory.hooks.parser
|
||||
.for("javascript/auto")
|
||||
.tap("CompatibilityPlugin", (parser, parserOptions) => {
|
||||
if (
|
||||
parserOptions.browserify !== undefined &&
|
||||
!parserOptions.browserify
|
||||
)
|
||||
return;
|
||||
|
||||
parser.hooks.call
|
||||
.for("require")
|
||||
.tap("CompatibilityPlugin", expr => {
|
||||
// support for browserify style require delegator: "require(o, !0)"
|
||||
if (expr.arguments.length !== 2) return;
|
||||
const second = parser.evaluateExpression(expr.arguments[1]);
|
||||
if (!second.isBoolean()) return;
|
||||
if (second.asBool() !== true) return;
|
||||
const dep = new ConstDependency("require", expr.callee.range);
|
||||
dep.loc = expr.loc;
|
||||
if (parser.state.current.dependencies.length > 0) {
|
||||
const last =
|
||||
parser.state.current.dependencies[
|
||||
parser.state.current.dependencies.length - 1
|
||||
];
|
||||
if (
|
||||
last.critical &&
|
||||
last.options &&
|
||||
last.options.request === "." &&
|
||||
last.userRequest === "." &&
|
||||
last.options.recursive
|
||||
)
|
||||
parser.state.current.dependencies.pop();
|
||||
}
|
||||
parser.state.module.addPresentationalDependency(dep);
|
||||
return true;
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* @param {JavascriptParser} parser the parser
|
||||
* @returns {void}
|
||||
*/
|
||||
const handler = parser => {
|
||||
// Handle nested requires
|
||||
parser.hooks.preStatement.tap("CompatibilityPlugin", statement => {
|
||||
if (
|
||||
statement.type === "FunctionDeclaration" &&
|
||||
statement.id &&
|
||||
statement.id.name === "__webpack_require__"
|
||||
) {
|
||||
const newName = `__nested_webpack_require_${statement.range[0]}__`;
|
||||
parser.tagVariable(statement.id.name, nestedWebpackRequireTag, {
|
||||
name: newName,
|
||||
declaration: {
|
||||
updated: false,
|
||||
loc: statement.id.loc,
|
||||
range: statement.id.range
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
});
|
||||
parser.hooks.pattern
|
||||
.for("__webpack_require__")
|
||||
.tap("CompatibilityPlugin", pattern => {
|
||||
const newName = `__nested_webpack_require_${pattern.range[0]}__`;
|
||||
parser.tagVariable(pattern.name, nestedWebpackRequireTag, {
|
||||
name: newName,
|
||||
declaration: {
|
||||
updated: false,
|
||||
loc: pattern.loc,
|
||||
range: pattern.range
|
||||
}
|
||||
});
|
||||
return true;
|
||||
});
|
||||
parser.hooks.expression
|
||||
.for(nestedWebpackRequireTag)
|
||||
.tap("CompatibilityPlugin", expr => {
|
||||
const { name, declaration } = parser.currentTagData;
|
||||
if (!declaration.updated) {
|
||||
const dep = new ConstDependency(name, declaration.range);
|
||||
dep.loc = declaration.loc;
|
||||
parser.state.module.addPresentationalDependency(dep);
|
||||
declaration.updated = true;
|
||||
}
|
||||
const dep = new ConstDependency(name, expr.range);
|
||||
dep.loc = expr.loc;
|
||||
parser.state.module.addPresentationalDependency(dep);
|
||||
return true;
|
||||
});
|
||||
|
||||
// Handle hashbang
|
||||
parser.hooks.program.tap(
|
||||
"CompatibilityPlugin",
|
||||
(program, comments) => {
|
||||
if (comments.length === 0) return;
|
||||
const c = comments[0];
|
||||
if (c.type === "Line" && c.range[0] === 0) {
|
||||
if (parser.state.source.slice(0, 2).toString() !== "#!") return;
|
||||
// this is a hashbang comment
|
||||
const dep = new ConstDependency("//", 0);
|
||||
dep.loc = c.loc;
|
||||
parser.state.module.addPresentationalDependency(dep);
|
||||
}
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
normalModuleFactory.hooks.parser
|
||||
.for("javascript/auto")
|
||||
.tap("CompatibilityPlugin", handler);
|
||||
normalModuleFactory.hooks.parser
|
||||
.for("javascript/dynamic")
|
||||
.tap("CompatibilityPlugin", handler);
|
||||
normalModuleFactory.hooks.parser
|
||||
.for("javascript/esm")
|
||||
.tap("CompatibilityPlugin", handler);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
module.exports = CompatibilityPlugin;
|
5301
node_modules/webpack/lib/Compilation.js
generated
vendored
Normal file
5301
node_modules/webpack/lib/Compilation.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1230
node_modules/webpack/lib/Compiler.js
generated
vendored
Normal file
1230
node_modules/webpack/lib/Compiler.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
159
node_modules/webpack/lib/ConcatenationScope.js
generated
vendored
Normal file
159
node_modules/webpack/lib/ConcatenationScope.js
generated
vendored
Normal file
@@ -0,0 +1,159 @@
|
||||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Tobias Koppers @sokra
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
/** @typedef {import("./Module")} Module */
|
||||
|
||||
const MODULE_REFERENCE_REGEXP =
|
||||
/^__WEBPACK_MODULE_REFERENCE__(\d+)_([\da-f]+|ns)(_call)?(_directImport)?(?:_asiSafe(\d))?__$/;
|
||||
|
||||
const DEFAULT_EXPORT = "__WEBPACK_DEFAULT_EXPORT__";
|
||||
const NAMESPACE_OBJECT_EXPORT = "__WEBPACK_NAMESPACE_OBJECT__";
|
||||
|
||||
/**
|
||||
* @typedef {Object} ExternalModuleInfo
|
||||
* @property {number} index
|
||||
* @property {Module} module
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} ConcatenatedModuleInfo
|
||||
* @property {number} index
|
||||
* @property {Module} module
|
||||
* @property {Map<string, string>} exportMap mapping from export name to symbol
|
||||
* @property {Map<string, string>} rawExportMap mapping from export name to symbol
|
||||
* @property {string=} namespaceExportSymbol
|
||||
*/
|
||||
|
||||
/** @typedef {ConcatenatedModuleInfo | ExternalModuleInfo} ModuleInfo */
|
||||
|
||||
/**
|
||||
* @typedef {Object} ModuleReferenceOptions
|
||||
* @property {string[]} ids the properties/exports of the module
|
||||
* @property {boolean} call true, when this referenced export is called
|
||||
* @property {boolean} directImport true, when this referenced export is directly imported (not via property access)
|
||||
* @property {boolean | undefined} asiSafe if the position is ASI safe or unknown
|
||||
*/
|
||||
|
||||
class ConcatenationScope {
|
||||
/**
|
||||
* @param {ModuleInfo[] | Map<Module, ModuleInfo>} modulesMap all module info by module
|
||||
* @param {ConcatenatedModuleInfo} currentModule the current module info
|
||||
*/
|
||||
constructor(modulesMap, currentModule) {
|
||||
this._currentModule = currentModule;
|
||||
if (Array.isArray(modulesMap)) {
|
||||
const map = new Map();
|
||||
for (const info of modulesMap) {
|
||||
map.set(info.module, info);
|
||||
}
|
||||
modulesMap = map;
|
||||
}
|
||||
this._modulesMap = modulesMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Module} module the referenced module
|
||||
* @returns {boolean} true, when it's in the scope
|
||||
*/
|
||||
isModuleInScope(module) {
|
||||
return this._modulesMap.has(module);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {string} exportName name of the export
|
||||
* @param {string} symbol identifier of the export in source code
|
||||
*/
|
||||
registerExport(exportName, symbol) {
|
||||
if (!this._currentModule.exportMap) {
|
||||
this._currentModule.exportMap = new Map();
|
||||
}
|
||||
if (!this._currentModule.exportMap.has(exportName)) {
|
||||
this._currentModule.exportMap.set(exportName, symbol);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {string} exportName name of the export
|
||||
* @param {string} expression expression to be used
|
||||
*/
|
||||
registerRawExport(exportName, expression) {
|
||||
if (!this._currentModule.rawExportMap) {
|
||||
this._currentModule.rawExportMap = new Map();
|
||||
}
|
||||
if (!this._currentModule.rawExportMap.has(exportName)) {
|
||||
this._currentModule.rawExportMap.set(exportName, expression);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} symbol identifier of the export in source code
|
||||
*/
|
||||
registerNamespaceExport(symbol) {
|
||||
this._currentModule.namespaceExportSymbol = symbol;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {Module} module the referenced module
|
||||
* @param {Partial<ModuleReferenceOptions>} options options
|
||||
* @returns {string} the reference as identifier
|
||||
*/
|
||||
createModuleReference(
|
||||
module,
|
||||
{ ids = undefined, call = false, directImport = false, asiSafe = false }
|
||||
) {
|
||||
const info = this._modulesMap.get(module);
|
||||
const callFlag = call ? "_call" : "";
|
||||
const directImportFlag = directImport ? "_directImport" : "";
|
||||
const asiSafeFlag = asiSafe
|
||||
? "_asiSafe1"
|
||||
: asiSafe === false
|
||||
? "_asiSafe0"
|
||||
: "";
|
||||
const exportData = ids
|
||||
? Buffer.from(JSON.stringify(ids), "utf-8").toString("hex")
|
||||
: "ns";
|
||||
// a "._" is appended to allow "delete ...", which would cause a SyntaxError in strict mode
|
||||
return `__WEBPACK_MODULE_REFERENCE__${info.index}_${exportData}${callFlag}${directImportFlag}${asiSafeFlag}__._`;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} name the identifier
|
||||
* @returns {boolean} true, when it's an module reference
|
||||
*/
|
||||
static isModuleReference(name) {
|
||||
return MODULE_REFERENCE_REGEXP.test(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} name the identifier
|
||||
* @returns {ModuleReferenceOptions & { index: number }} parsed options and index
|
||||
*/
|
||||
static matchModuleReference(name) {
|
||||
const match = MODULE_REFERENCE_REGEXP.exec(name);
|
||||
if (!match) return null;
|
||||
const index = +match[1];
|
||||
const asiSafe = match[5];
|
||||
return {
|
||||
index,
|
||||
ids:
|
||||
match[2] === "ns"
|
||||
? []
|
||||
: JSON.parse(Buffer.from(match[2], "hex").toString("utf-8")),
|
||||
call: !!match[3],
|
||||
directImport: !!match[4],
|
||||
asiSafe: asiSafe ? asiSafe === "1" : undefined
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
ConcatenationScope.DEFAULT_EXPORT = DEFAULT_EXPORT;
|
||||
ConcatenationScope.NAMESPACE_OBJECT_EXPORT = NAMESPACE_OBJECT_EXPORT;
|
||||
|
||||
module.exports = ConcatenationScope;
|
18
node_modules/webpack/lib/ConcurrentCompilationError.js
generated
vendored
Normal file
18
node_modules/webpack/lib/ConcurrentCompilationError.js
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Maksim Nazarjev @acupofspirt
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
const WebpackError = require("./WebpackError");
|
||||
|
||||
module.exports = class ConcurrentCompilationError extends WebpackError {
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.name = "ConcurrentCompilationError";
|
||||
this.message =
|
||||
"You ran Webpack twice. Each instance only supports a single concurrent compilation at a time.";
|
||||
}
|
||||
};
|
112
node_modules/webpack/lib/ConditionalInitFragment.js
generated
vendored
Normal file
112
node_modules/webpack/lib/ConditionalInitFragment.js
generated
vendored
Normal file
@@ -0,0 +1,112 @@
|
||||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Tobias Koppers @sokra
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
const { ConcatSource, PrefixSource } = require("webpack-sources");
|
||||
const InitFragment = require("./InitFragment");
|
||||
const Template = require("./Template");
|
||||
const { mergeRuntime } = require("./util/runtime");
|
||||
|
||||
/** @typedef {import("webpack-sources").Source} Source */
|
||||
/** @typedef {import("./Generator").GenerateContext} GenerateContext */
|
||||
/** @typedef {import("./util/runtime").RuntimeSpec} RuntimeSpec */
|
||||
|
||||
const wrapInCondition = (condition, source) => {
|
||||
if (typeof source === "string") {
|
||||
return Template.asString([
|
||||
`if (${condition}) {`,
|
||||
Template.indent(source),
|
||||
"}",
|
||||
""
|
||||
]);
|
||||
} else {
|
||||
return new ConcatSource(
|
||||
`if (${condition}) {\n`,
|
||||
new PrefixSource("\t", source),
|
||||
"}\n"
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @typedef {GenerateContext} Context
|
||||
*/
|
||||
class ConditionalInitFragment extends InitFragment {
|
||||
/**
|
||||
* @param {string|Source} content the source code that will be included as initialization code
|
||||
* @param {number} stage category of initialization code (contribute to order)
|
||||
* @param {number} position position in the category (contribute to order)
|
||||
* @param {string} key unique key to avoid emitting the same initialization code twice
|
||||
* @param {RuntimeSpec | boolean} runtimeCondition in which runtime this fragment should be executed
|
||||
* @param {string|Source=} endContent the source code that will be included at the end of the module
|
||||
*/
|
||||
constructor(
|
||||
content,
|
||||
stage,
|
||||
position,
|
||||
key,
|
||||
runtimeCondition = true,
|
||||
endContent
|
||||
) {
|
||||
super(content, stage, position, key, endContent);
|
||||
this.runtimeCondition = runtimeCondition;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Context} context context
|
||||
* @returns {string|Source} the source code that will be included as initialization code
|
||||
*/
|
||||
getContent(context) {
|
||||
if (this.runtimeCondition === false || !this.content) return "";
|
||||
if (this.runtimeCondition === true) return this.content;
|
||||
const expr = context.runtimeTemplate.runtimeConditionExpression({
|
||||
chunkGraph: context.chunkGraph,
|
||||
runtimeRequirements: context.runtimeRequirements,
|
||||
runtime: context.runtime,
|
||||
runtimeCondition: this.runtimeCondition
|
||||
});
|
||||
if (expr === "true") return this.content;
|
||||
return wrapInCondition(expr, this.content);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Context} context context
|
||||
* @returns {string|Source=} the source code that will be included at the end of the module
|
||||
*/
|
||||
getEndContent(context) {
|
||||
if (this.runtimeCondition === false || !this.endContent) return "";
|
||||
if (this.runtimeCondition === true) return this.endContent;
|
||||
const expr = context.runtimeTemplate.runtimeConditionExpression({
|
||||
chunkGraph: context.chunkGraph,
|
||||
runtimeRequirements: context.runtimeRequirements,
|
||||
runtime: context.runtime,
|
||||
runtimeCondition: this.runtimeCondition
|
||||
});
|
||||
if (expr === "true") return this.endContent;
|
||||
return wrapInCondition(expr, this.endContent);
|
||||
}
|
||||
|
||||
merge(other) {
|
||||
if (this.runtimeCondition === true) return this;
|
||||
if (other.runtimeCondition === true) return other;
|
||||
if (this.runtimeCondition === false) return other;
|
||||
if (other.runtimeCondition === false) return this;
|
||||
const runtimeCondition = mergeRuntime(
|
||||
this.runtimeCondition,
|
||||
other.runtimeCondition
|
||||
);
|
||||
return new ConditionalInitFragment(
|
||||
this.content,
|
||||
this.stage,
|
||||
this.position,
|
||||
this.key,
|
||||
runtimeCondition,
|
||||
this.endContent
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = ConditionalInitFragment;
|
497
node_modules/webpack/lib/ConstPlugin.js
generated
vendored
Normal file
497
node_modules/webpack/lib/ConstPlugin.js
generated
vendored
Normal file
@@ -0,0 +1,497 @@
|
||||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Tobias Koppers @sokra
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
const CachedConstDependency = require("./dependencies/CachedConstDependency");
|
||||
const ConstDependency = require("./dependencies/ConstDependency");
|
||||
const { evaluateToString } = require("./javascript/JavascriptParserHelpers");
|
||||
const { parseResource } = require("./util/identifier");
|
||||
|
||||
/** @typedef {import("estree").Expression} ExpressionNode */
|
||||
/** @typedef {import("estree").Super} SuperNode */
|
||||
/** @typedef {import("./Compiler")} Compiler */
|
||||
|
||||
const collectDeclaration = (declarations, pattern) => {
|
||||
const stack = [pattern];
|
||||
while (stack.length > 0) {
|
||||
const node = stack.pop();
|
||||
switch (node.type) {
|
||||
case "Identifier":
|
||||
declarations.add(node.name);
|
||||
break;
|
||||
case "ArrayPattern":
|
||||
for (const element of node.elements) {
|
||||
if (element) {
|
||||
stack.push(element);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "AssignmentPattern":
|
||||
stack.push(node.left);
|
||||
break;
|
||||
case "ObjectPattern":
|
||||
for (const property of node.properties) {
|
||||
stack.push(property.value);
|
||||
}
|
||||
break;
|
||||
case "RestElement":
|
||||
stack.push(node.argument);
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const getHoistedDeclarations = (branch, includeFunctionDeclarations) => {
|
||||
const declarations = new Set();
|
||||
const stack = [branch];
|
||||
while (stack.length > 0) {
|
||||
const node = stack.pop();
|
||||
// Some node could be `null` or `undefined`.
|
||||
if (!node) continue;
|
||||
switch (node.type) {
|
||||
// Walk through control statements to look for hoisted declarations.
|
||||
// Some branches are skipped since they do not allow declarations.
|
||||
case "BlockStatement":
|
||||
for (const stmt of node.body) {
|
||||
stack.push(stmt);
|
||||
}
|
||||
break;
|
||||
case "IfStatement":
|
||||
stack.push(node.consequent);
|
||||
stack.push(node.alternate);
|
||||
break;
|
||||
case "ForStatement":
|
||||
stack.push(node.init);
|
||||
stack.push(node.body);
|
||||
break;
|
||||
case "ForInStatement":
|
||||
case "ForOfStatement":
|
||||
stack.push(node.left);
|
||||
stack.push(node.body);
|
||||
break;
|
||||
case "DoWhileStatement":
|
||||
case "WhileStatement":
|
||||
case "LabeledStatement":
|
||||
stack.push(node.body);
|
||||
break;
|
||||
case "SwitchStatement":
|
||||
for (const cs of node.cases) {
|
||||
for (const consequent of cs.consequent) {
|
||||
stack.push(consequent);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "TryStatement":
|
||||
stack.push(node.block);
|
||||
if (node.handler) {
|
||||
stack.push(node.handler.body);
|
||||
}
|
||||
stack.push(node.finalizer);
|
||||
break;
|
||||
case "FunctionDeclaration":
|
||||
if (includeFunctionDeclarations) {
|
||||
collectDeclaration(declarations, node.id);
|
||||
}
|
||||
break;
|
||||
case "VariableDeclaration":
|
||||
if (node.kind === "var") {
|
||||
for (const decl of node.declarations) {
|
||||
collectDeclaration(declarations, decl.id);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return Array.from(declarations);
|
||||
};
|
||||
|
||||
class ConstPlugin {
|
||||
/**
|
||||
* Apply the plugin
|
||||
* @param {Compiler} compiler the compiler instance
|
||||
* @returns {void}
|
||||
*/
|
||||
apply(compiler) {
|
||||
const cachedParseResource = parseResource.bindCache(compiler.root);
|
||||
compiler.hooks.compilation.tap(
|
||||
"ConstPlugin",
|
||||
(compilation, { normalModuleFactory }) => {
|
||||
compilation.dependencyTemplates.set(
|
||||
ConstDependency,
|
||||
new ConstDependency.Template()
|
||||
);
|
||||
|
||||
compilation.dependencyTemplates.set(
|
||||
CachedConstDependency,
|
||||
new CachedConstDependency.Template()
|
||||
);
|
||||
|
||||
const handler = parser => {
|
||||
parser.hooks.statementIf.tap("ConstPlugin", statement => {
|
||||
if (parser.scope.isAsmJs) return;
|
||||
const param = parser.evaluateExpression(statement.test);
|
||||
const bool = param.asBool();
|
||||
if (typeof bool === "boolean") {
|
||||
if (!param.couldHaveSideEffects()) {
|
||||
const dep = new ConstDependency(`${bool}`, param.range);
|
||||
dep.loc = statement.loc;
|
||||
parser.state.module.addPresentationalDependency(dep);
|
||||
} else {
|
||||
parser.walkExpression(statement.test);
|
||||
}
|
||||
const branchToRemove = bool
|
||||
? statement.alternate
|
||||
: statement.consequent;
|
||||
if (branchToRemove) {
|
||||
// Before removing the dead branch, the hoisted declarations
|
||||
// must be collected.
|
||||
//
|
||||
// Given the following code:
|
||||
//
|
||||
// if (true) f() else g()
|
||||
// if (false) {
|
||||
// function f() {}
|
||||
// const g = function g() {}
|
||||
// if (someTest) {
|
||||
// let a = 1
|
||||
// var x, {y, z} = obj
|
||||
// }
|
||||
// } else {
|
||||
// …
|
||||
// }
|
||||
//
|
||||
// the generated code is:
|
||||
//
|
||||
// if (true) f() else {}
|
||||
// if (false) {
|
||||
// var f, x, y, z; (in loose mode)
|
||||
// var x, y, z; (in strict mode)
|
||||
// } else {
|
||||
// …
|
||||
// }
|
||||
//
|
||||
// NOTE: When code runs in strict mode, `var` declarations
|
||||
// are hoisted but `function` declarations don't.
|
||||
//
|
||||
let declarations;
|
||||
if (parser.scope.isStrict) {
|
||||
// If the code runs in strict mode, variable declarations
|
||||
// using `var` must be hoisted.
|
||||
declarations = getHoistedDeclarations(branchToRemove, false);
|
||||
} else {
|
||||
// Otherwise, collect all hoisted declaration.
|
||||
declarations = getHoistedDeclarations(branchToRemove, true);
|
||||
}
|
||||
let replacement;
|
||||
if (declarations.length > 0) {
|
||||
replacement = `{ var ${declarations.join(", ")}; }`;
|
||||
} else {
|
||||
replacement = "{}";
|
||||
}
|
||||
const dep = new ConstDependency(
|
||||
replacement,
|
||||
branchToRemove.range
|
||||
);
|
||||
dep.loc = branchToRemove.loc;
|
||||
parser.state.module.addPresentationalDependency(dep);
|
||||
}
|
||||
return bool;
|
||||
}
|
||||
});
|
||||
parser.hooks.expressionConditionalOperator.tap(
|
||||
"ConstPlugin",
|
||||
expression => {
|
||||
if (parser.scope.isAsmJs) return;
|
||||
const param = parser.evaluateExpression(expression.test);
|
||||
const bool = param.asBool();
|
||||
if (typeof bool === "boolean") {
|
||||
if (!param.couldHaveSideEffects()) {
|
||||
const dep = new ConstDependency(` ${bool}`, param.range);
|
||||
dep.loc = expression.loc;
|
||||
parser.state.module.addPresentationalDependency(dep);
|
||||
} else {
|
||||
parser.walkExpression(expression.test);
|
||||
}
|
||||
// Expressions do not hoist.
|
||||
// It is safe to remove the dead branch.
|
||||
//
|
||||
// Given the following code:
|
||||
//
|
||||
// false ? someExpression() : otherExpression();
|
||||
//
|
||||
// the generated code is:
|
||||
//
|
||||
// false ? 0 : otherExpression();
|
||||
//
|
||||
const branchToRemove = bool
|
||||
? expression.alternate
|
||||
: expression.consequent;
|
||||
const dep = new ConstDependency("0", branchToRemove.range);
|
||||
dep.loc = branchToRemove.loc;
|
||||
parser.state.module.addPresentationalDependency(dep);
|
||||
return bool;
|
||||
}
|
||||
}
|
||||
);
|
||||
parser.hooks.expressionLogicalOperator.tap(
|
||||
"ConstPlugin",
|
||||
expression => {
|
||||
if (parser.scope.isAsmJs) return;
|
||||
if (
|
||||
expression.operator === "&&" ||
|
||||
expression.operator === "||"
|
||||
) {
|
||||
const param = parser.evaluateExpression(expression.left);
|
||||
const bool = param.asBool();
|
||||
if (typeof bool === "boolean") {
|
||||
// Expressions do not hoist.
|
||||
// It is safe to remove the dead branch.
|
||||
//
|
||||
// ------------------------------------------
|
||||
//
|
||||
// Given the following code:
|
||||
//
|
||||
// falsyExpression() && someExpression();
|
||||
//
|
||||
// the generated code is:
|
||||
//
|
||||
// falsyExpression() && false;
|
||||
//
|
||||
// ------------------------------------------
|
||||
//
|
||||
// Given the following code:
|
||||
//
|
||||
// truthyExpression() && someExpression();
|
||||
//
|
||||
// the generated code is:
|
||||
//
|
||||
// true && someExpression();
|
||||
//
|
||||
// ------------------------------------------
|
||||
//
|
||||
// Given the following code:
|
||||
//
|
||||
// truthyExpression() || someExpression();
|
||||
//
|
||||
// the generated code is:
|
||||
//
|
||||
// truthyExpression() || false;
|
||||
//
|
||||
// ------------------------------------------
|
||||
//
|
||||
// Given the following code:
|
||||
//
|
||||
// falsyExpression() || someExpression();
|
||||
//
|
||||
// the generated code is:
|
||||
//
|
||||
// false && someExpression();
|
||||
//
|
||||
const keepRight =
|
||||
(expression.operator === "&&" && bool) ||
|
||||
(expression.operator === "||" && !bool);
|
||||
|
||||
if (
|
||||
!param.couldHaveSideEffects() &&
|
||||
(param.isBoolean() || keepRight)
|
||||
) {
|
||||
// for case like
|
||||
//
|
||||
// return'development'===process.env.NODE_ENV&&'foo'
|
||||
//
|
||||
// we need a space before the bool to prevent result like
|
||||
//
|
||||
// returnfalse&&'foo'
|
||||
//
|
||||
const dep = new ConstDependency(` ${bool}`, param.range);
|
||||
dep.loc = expression.loc;
|
||||
parser.state.module.addPresentationalDependency(dep);
|
||||
} else {
|
||||
parser.walkExpression(expression.left);
|
||||
}
|
||||
if (!keepRight) {
|
||||
const dep = new ConstDependency(
|
||||
"0",
|
||||
expression.right.range
|
||||
);
|
||||
dep.loc = expression.loc;
|
||||
parser.state.module.addPresentationalDependency(dep);
|
||||
}
|
||||
return keepRight;
|
||||
}
|
||||
} else if (expression.operator === "??") {
|
||||
const param = parser.evaluateExpression(expression.left);
|
||||
const keepRight = param.asNullish();
|
||||
if (typeof keepRight === "boolean") {
|
||||
// ------------------------------------------
|
||||
//
|
||||
// Given the following code:
|
||||
//
|
||||
// nonNullish ?? someExpression();
|
||||
//
|
||||
// the generated code is:
|
||||
//
|
||||
// nonNullish ?? 0;
|
||||
//
|
||||
// ------------------------------------------
|
||||
//
|
||||
// Given the following code:
|
||||
//
|
||||
// nullish ?? someExpression();
|
||||
//
|
||||
// the generated code is:
|
||||
//
|
||||
// null ?? someExpression();
|
||||
//
|
||||
if (!param.couldHaveSideEffects() && keepRight) {
|
||||
// cspell:word returnnull
|
||||
// for case like
|
||||
//
|
||||
// return('development'===process.env.NODE_ENV&&null)??'foo'
|
||||
//
|
||||
// we need a space before the bool to prevent result like
|
||||
//
|
||||
// returnnull??'foo'
|
||||
//
|
||||
const dep = new ConstDependency(" null", param.range);
|
||||
dep.loc = expression.loc;
|
||||
parser.state.module.addPresentationalDependency(dep);
|
||||
} else {
|
||||
const dep = new ConstDependency(
|
||||
"0",
|
||||
expression.right.range
|
||||
);
|
||||
dep.loc = expression.loc;
|
||||
parser.state.module.addPresentationalDependency(dep);
|
||||
parser.walkExpression(expression.left);
|
||||
}
|
||||
|
||||
return keepRight;
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
parser.hooks.optionalChaining.tap("ConstPlugin", expr => {
|
||||
/** @type {ExpressionNode[]} */
|
||||
const optionalExpressionsStack = [];
|
||||
/** @type {ExpressionNode|SuperNode} */
|
||||
let next = expr.expression;
|
||||
|
||||
while (
|
||||
next.type === "MemberExpression" ||
|
||||
next.type === "CallExpression"
|
||||
) {
|
||||
if (next.type === "MemberExpression") {
|
||||
if (next.optional) {
|
||||
// SuperNode can not be optional
|
||||
optionalExpressionsStack.push(
|
||||
/** @type {ExpressionNode} */ (next.object)
|
||||
);
|
||||
}
|
||||
next = next.object;
|
||||
} else {
|
||||
if (next.optional) {
|
||||
// SuperNode can not be optional
|
||||
optionalExpressionsStack.push(
|
||||
/** @type {ExpressionNode} */ (next.callee)
|
||||
);
|
||||
}
|
||||
next = next.callee;
|
||||
}
|
||||
}
|
||||
|
||||
while (optionalExpressionsStack.length) {
|
||||
const expression = optionalExpressionsStack.pop();
|
||||
const evaluated = parser.evaluateExpression(expression);
|
||||
|
||||
if (evaluated.asNullish()) {
|
||||
// ------------------------------------------
|
||||
//
|
||||
// Given the following code:
|
||||
//
|
||||
// nullishMemberChain?.a.b();
|
||||
//
|
||||
// the generated code is:
|
||||
//
|
||||
// undefined;
|
||||
//
|
||||
// ------------------------------------------
|
||||
//
|
||||
const dep = new ConstDependency(" undefined", expr.range);
|
||||
dep.loc = expr.loc;
|
||||
parser.state.module.addPresentationalDependency(dep);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
});
|
||||
parser.hooks.evaluateIdentifier
|
||||
.for("__resourceQuery")
|
||||
.tap("ConstPlugin", expr => {
|
||||
if (parser.scope.isAsmJs) return;
|
||||
if (!parser.state.module) return;
|
||||
return evaluateToString(
|
||||
cachedParseResource(parser.state.module.resource).query
|
||||
)(expr);
|
||||
});
|
||||
parser.hooks.expression
|
||||
.for("__resourceQuery")
|
||||
.tap("ConstPlugin", expr => {
|
||||
if (parser.scope.isAsmJs) return;
|
||||
if (!parser.state.module) return;
|
||||
const dep = new CachedConstDependency(
|
||||
JSON.stringify(
|
||||
cachedParseResource(parser.state.module.resource).query
|
||||
),
|
||||
expr.range,
|
||||
"__resourceQuery"
|
||||
);
|
||||
dep.loc = expr.loc;
|
||||
parser.state.module.addPresentationalDependency(dep);
|
||||
return true;
|
||||
});
|
||||
|
||||
parser.hooks.evaluateIdentifier
|
||||
.for("__resourceFragment")
|
||||
.tap("ConstPlugin", expr => {
|
||||
if (parser.scope.isAsmJs) return;
|
||||
if (!parser.state.module) return;
|
||||
return evaluateToString(
|
||||
cachedParseResource(parser.state.module.resource).fragment
|
||||
)(expr);
|
||||
});
|
||||
parser.hooks.expression
|
||||
.for("__resourceFragment")
|
||||
.tap("ConstPlugin", expr => {
|
||||
if (parser.scope.isAsmJs) return;
|
||||
if (!parser.state.module) return;
|
||||
const dep = new CachedConstDependency(
|
||||
JSON.stringify(
|
||||
cachedParseResource(parser.state.module.resource).fragment
|
||||
),
|
||||
expr.range,
|
||||
"__resourceFragment"
|
||||
);
|
||||
dep.loc = expr.loc;
|
||||
parser.state.module.addPresentationalDependency(dep);
|
||||
return true;
|
||||
});
|
||||
};
|
||||
|
||||
normalModuleFactory.hooks.parser
|
||||
.for("javascript/auto")
|
||||
.tap("ConstPlugin", handler);
|
||||
normalModuleFactory.hooks.parser
|
||||
.for("javascript/dynamic")
|
||||
.tap("ConstPlugin", handler);
|
||||
normalModuleFactory.hooks.parser
|
||||
.for("javascript/esm")
|
||||
.tap("ConstPlugin", handler);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = ConstPlugin;
|
32
node_modules/webpack/lib/ContextExclusionPlugin.js
generated
vendored
Normal file
32
node_modules/webpack/lib/ContextExclusionPlugin.js
generated
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
/** @typedef {import("./Compiler")} Compiler */
|
||||
/** @typedef {import("./ContextModuleFactory")} ContextModuleFactory */
|
||||
|
||||
class ContextExclusionPlugin {
|
||||
/**
|
||||
* @param {RegExp} negativeMatcher Matcher regular expression
|
||||
*/
|
||||
constructor(negativeMatcher) {
|
||||
this.negativeMatcher = negativeMatcher;
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply the plugin
|
||||
* @param {Compiler} compiler the compiler instance
|
||||
* @returns {void}
|
||||
*/
|
||||
apply(compiler) {
|
||||
compiler.hooks.contextModuleFactory.tap("ContextExclusionPlugin", cmf => {
|
||||
cmf.hooks.contextModuleFiles.tap("ContextExclusionPlugin", files => {
|
||||
return files.filter(filePath => !this.negativeMatcher.test(filePath));
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = ContextExclusionPlugin;
|
1170
node_modules/webpack/lib/ContextModule.js
generated
vendored
Normal file
1170
node_modules/webpack/lib/ContextModule.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
433
node_modules/webpack/lib/ContextModuleFactory.js
generated
vendored
Normal file
433
node_modules/webpack/lib/ContextModuleFactory.js
generated
vendored
Normal file
@@ -0,0 +1,433 @@
|
||||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Tobias Koppers @sokra
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
const asyncLib = require("neo-async");
|
||||
const { AsyncSeriesWaterfallHook, SyncWaterfallHook } = require("tapable");
|
||||
const ContextModule = require("./ContextModule");
|
||||
const ModuleFactory = require("./ModuleFactory");
|
||||
const ContextElementDependency = require("./dependencies/ContextElementDependency");
|
||||
const LazySet = require("./util/LazySet");
|
||||
const { cachedSetProperty } = require("./util/cleverMerge");
|
||||
const { createFakeHook } = require("./util/deprecation");
|
||||
const { join } = require("./util/fs");
|
||||
|
||||
/** @typedef {import("./ContextModule").ContextModuleOptions} ContextModuleOptions */
|
||||
/** @typedef {import("./ContextModule").ResolveDependenciesCallback} ResolveDependenciesCallback */
|
||||
/** @typedef {import("./Module")} Module */
|
||||
/** @typedef {import("./ModuleFactory").ModuleFactoryCreateData} ModuleFactoryCreateData */
|
||||
/** @typedef {import("./ModuleFactory").ModuleFactoryResult} ModuleFactoryResult */
|
||||
/** @typedef {import("./ResolverFactory")} ResolverFactory */
|
||||
/** @typedef {import("./dependencies/ContextDependency")} ContextDependency */
|
||||
/** @template T @typedef {import("./util/deprecation").FakeHook<T>} FakeHook<T> */
|
||||
/** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */
|
||||
|
||||
const EMPTY_RESOLVE_OPTIONS = {};
|
||||
|
||||
module.exports = class ContextModuleFactory extends ModuleFactory {
|
||||
/**
|
||||
* @param {ResolverFactory} resolverFactory resolverFactory
|
||||
*/
|
||||
constructor(resolverFactory) {
|
||||
super();
|
||||
/** @type {AsyncSeriesWaterfallHook<[TODO[], ContextModuleOptions]>} */
|
||||
const alternativeRequests = new AsyncSeriesWaterfallHook([
|
||||
"modules",
|
||||
"options"
|
||||
]);
|
||||
this.hooks = Object.freeze({
|
||||
/** @type {AsyncSeriesWaterfallHook<[TODO]>} */
|
||||
beforeResolve: new AsyncSeriesWaterfallHook(["data"]),
|
||||
/** @type {AsyncSeriesWaterfallHook<[TODO]>} */
|
||||
afterResolve: new AsyncSeriesWaterfallHook(["data"]),
|
||||
/** @type {SyncWaterfallHook<[string[]]>} */
|
||||
contextModuleFiles: new SyncWaterfallHook(["files"]),
|
||||
/** @type {FakeHook<Pick<AsyncSeriesWaterfallHook<[TODO[]]>, "tap" | "tapAsync" | "tapPromise" | "name">>} */
|
||||
alternatives: createFakeHook(
|
||||
{
|
||||
name: "alternatives",
|
||||
/** @type {AsyncSeriesWaterfallHook<[TODO[]]>["intercept"]} */
|
||||
intercept: interceptor => {
|
||||
throw new Error(
|
||||
"Intercepting fake hook ContextModuleFactory.hooks.alternatives is not possible, use ContextModuleFactory.hooks.alternativeRequests instead"
|
||||
);
|
||||
},
|
||||
/** @type {AsyncSeriesWaterfallHook<[TODO[]]>["tap"]} */
|
||||
tap: (options, fn) => {
|
||||
alternativeRequests.tap(options, fn);
|
||||
},
|
||||
/** @type {AsyncSeriesWaterfallHook<[TODO[]]>["tapAsync"]} */
|
||||
tapAsync: (options, fn) => {
|
||||
alternativeRequests.tapAsync(options, (items, _options, callback) =>
|
||||
fn(items, callback)
|
||||
);
|
||||
},
|
||||
/** @type {AsyncSeriesWaterfallHook<[TODO[]]>["tapPromise"]} */
|
||||
tapPromise: (options, fn) => {
|
||||
alternativeRequests.tapPromise(options, fn);
|
||||
}
|
||||
},
|
||||
"ContextModuleFactory.hooks.alternatives has deprecated in favor of ContextModuleFactory.hooks.alternativeRequests with an additional options argument.",
|
||||
"DEP_WEBPACK_CONTEXT_MODULE_FACTORY_ALTERNATIVES"
|
||||
),
|
||||
alternativeRequests
|
||||
});
|
||||
this.resolverFactory = resolverFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {ModuleFactoryCreateData} data data object
|
||||
* @param {function(Error=, ModuleFactoryResult=): void} callback callback
|
||||
* @returns {void}
|
||||
*/
|
||||
create(data, callback) {
|
||||
const context = data.context;
|
||||
const dependencies = data.dependencies;
|
||||
const resolveOptions = data.resolveOptions;
|
||||
const dependency = /** @type {ContextDependency} */ (dependencies[0]);
|
||||
const fileDependencies = new LazySet();
|
||||
const missingDependencies = new LazySet();
|
||||
const contextDependencies = new LazySet();
|
||||
this.hooks.beforeResolve.callAsync(
|
||||
{
|
||||
context: context,
|
||||
dependencies: dependencies,
|
||||
resolveOptions,
|
||||
fileDependencies,
|
||||
missingDependencies,
|
||||
contextDependencies,
|
||||
...dependency.options
|
||||
},
|
||||
(err, beforeResolveResult) => {
|
||||
if (err) {
|
||||
return callback(err, {
|
||||
fileDependencies,
|
||||
missingDependencies,
|
||||
contextDependencies
|
||||
});
|
||||
}
|
||||
|
||||
// Ignored
|
||||
if (!beforeResolveResult) {
|
||||
return callback(null, {
|
||||
fileDependencies,
|
||||
missingDependencies,
|
||||
contextDependencies
|
||||
});
|
||||
}
|
||||
|
||||
const context = beforeResolveResult.context;
|
||||
const request = beforeResolveResult.request;
|
||||
const resolveOptions = beforeResolveResult.resolveOptions;
|
||||
|
||||
let loaders,
|
||||
resource,
|
||||
loadersPrefix = "";
|
||||
const idx = request.lastIndexOf("!");
|
||||
if (idx >= 0) {
|
||||
let loadersRequest = request.slice(0, idx + 1);
|
||||
let i;
|
||||
for (
|
||||
i = 0;
|
||||
i < loadersRequest.length && loadersRequest[i] === "!";
|
||||
i++
|
||||
) {
|
||||
loadersPrefix += "!";
|
||||
}
|
||||
loadersRequest = loadersRequest
|
||||
.slice(i)
|
||||
.replace(/!+$/, "")
|
||||
.replace(/!!+/g, "!");
|
||||
if (loadersRequest === "") {
|
||||
loaders = [];
|
||||
} else {
|
||||
loaders = loadersRequest.split("!");
|
||||
}
|
||||
resource = request.slice(idx + 1);
|
||||
} else {
|
||||
loaders = [];
|
||||
resource = request;
|
||||
}
|
||||
|
||||
const contextResolver = this.resolverFactory.get(
|
||||
"context",
|
||||
dependencies.length > 0
|
||||
? cachedSetProperty(
|
||||
resolveOptions || EMPTY_RESOLVE_OPTIONS,
|
||||
"dependencyType",
|
||||
dependencies[0].category
|
||||
)
|
||||
: resolveOptions
|
||||
);
|
||||
const loaderResolver = this.resolverFactory.get("loader");
|
||||
|
||||
asyncLib.parallel(
|
||||
[
|
||||
callback => {
|
||||
const results = [];
|
||||
const yield_ = obj => results.push(obj);
|
||||
|
||||
contextResolver.resolve(
|
||||
{},
|
||||
context,
|
||||
resource,
|
||||
{
|
||||
fileDependencies,
|
||||
missingDependencies,
|
||||
contextDependencies,
|
||||
yield: yield_
|
||||
},
|
||||
err => {
|
||||
if (err) return callback(err);
|
||||
callback(null, results);
|
||||
}
|
||||
);
|
||||
},
|
||||
callback => {
|
||||
asyncLib.map(
|
||||
loaders,
|
||||
(loader, callback) => {
|
||||
loaderResolver.resolve(
|
||||
{},
|
||||
context,
|
||||
loader,
|
||||
{
|
||||
fileDependencies,
|
||||
missingDependencies,
|
||||
contextDependencies
|
||||
},
|
||||
(err, result) => {
|
||||
if (err) return callback(err);
|
||||
callback(null, result);
|
||||
}
|
||||
);
|
||||
},
|
||||
callback
|
||||
);
|
||||
}
|
||||
],
|
||||
(err, result) => {
|
||||
if (err) {
|
||||
return callback(err, {
|
||||
fileDependencies,
|
||||
missingDependencies,
|
||||
contextDependencies
|
||||
});
|
||||
}
|
||||
let [contextResult, loaderResult] = result;
|
||||
if (contextResult.length > 1) {
|
||||
const first = contextResult[0];
|
||||
contextResult = contextResult.filter(r => r.path);
|
||||
if (contextResult.length === 0) contextResult.push(first);
|
||||
}
|
||||
this.hooks.afterResolve.callAsync(
|
||||
{
|
||||
addon:
|
||||
loadersPrefix +
|
||||
loaderResult.join("!") +
|
||||
(loaderResult.length > 0 ? "!" : ""),
|
||||
resource:
|
||||
contextResult.length > 1
|
||||
? contextResult.map(r => r.path)
|
||||
: contextResult[0].path,
|
||||
resolveDependencies: this.resolveDependencies.bind(this),
|
||||
resourceQuery: contextResult[0].query,
|
||||
resourceFragment: contextResult[0].fragment,
|
||||
...beforeResolveResult
|
||||
},
|
||||
(err, result) => {
|
||||
if (err) {
|
||||
return callback(err, {
|
||||
fileDependencies,
|
||||
missingDependencies,
|
||||
contextDependencies
|
||||
});
|
||||
}
|
||||
|
||||
// Ignored
|
||||
if (!result) {
|
||||
return callback(null, {
|
||||
fileDependencies,
|
||||
missingDependencies,
|
||||
contextDependencies
|
||||
});
|
||||
}
|
||||
|
||||
return callback(null, {
|
||||
module: new ContextModule(result.resolveDependencies, result),
|
||||
fileDependencies,
|
||||
missingDependencies,
|
||||
contextDependencies
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {InputFileSystem} fs file system
|
||||
* @param {ContextModuleOptions} options options
|
||||
* @param {ResolveDependenciesCallback} callback callback function
|
||||
* @returns {void}
|
||||
*/
|
||||
resolveDependencies(fs, options, callback) {
|
||||
const cmf = this;
|
||||
const {
|
||||
resource,
|
||||
resourceQuery,
|
||||
resourceFragment,
|
||||
recursive,
|
||||
regExp,
|
||||
include,
|
||||
exclude,
|
||||
referencedExports,
|
||||
category,
|
||||
typePrefix
|
||||
} = options;
|
||||
if (!regExp || !resource) return callback(null, []);
|
||||
|
||||
const addDirectoryChecked = (ctx, directory, visited, callback) => {
|
||||
fs.realpath(directory, (err, realPath) => {
|
||||
if (err) return callback(err);
|
||||
if (visited.has(realPath)) return callback(null, []);
|
||||
let recursionStack;
|
||||
addDirectory(
|
||||
ctx,
|
||||
directory,
|
||||
(_, dir, callback) => {
|
||||
if (recursionStack === undefined) {
|
||||
recursionStack = new Set(visited);
|
||||
recursionStack.add(realPath);
|
||||
}
|
||||
addDirectoryChecked(ctx, dir, recursionStack, callback);
|
||||
},
|
||||
callback
|
||||
);
|
||||
});
|
||||
};
|
||||
|
||||
const addDirectory = (ctx, directory, addSubDirectory, callback) => {
|
||||
fs.readdir(directory, (err, files) => {
|
||||
if (err) return callback(err);
|
||||
const processedFiles = cmf.hooks.contextModuleFiles.call(
|
||||
/** @type {string[]} */ (files).map(file => file.normalize("NFC"))
|
||||
);
|
||||
if (!processedFiles || processedFiles.length === 0)
|
||||
return callback(null, []);
|
||||
asyncLib.map(
|
||||
processedFiles.filter(p => p.indexOf(".") !== 0),
|
||||
(segment, callback) => {
|
||||
const subResource = join(fs, directory, segment);
|
||||
|
||||
if (!exclude || !subResource.match(exclude)) {
|
||||
fs.stat(subResource, (err, stat) => {
|
||||
if (err) {
|
||||
if (err.code === "ENOENT") {
|
||||
// ENOENT is ok here because the file may have been deleted between
|
||||
// the readdir and stat calls.
|
||||
return callback();
|
||||
} else {
|
||||
return callback(err);
|
||||
}
|
||||
}
|
||||
|
||||
if (stat.isDirectory()) {
|
||||
if (!recursive) return callback();
|
||||
addSubDirectory(ctx, subResource, callback);
|
||||
} else if (
|
||||
stat.isFile() &&
|
||||
(!include || subResource.match(include))
|
||||
) {
|
||||
const obj = {
|
||||
context: ctx,
|
||||
request:
|
||||
"." + subResource.slice(ctx.length).replace(/\\/g, "/")
|
||||
};
|
||||
|
||||
this.hooks.alternativeRequests.callAsync(
|
||||
[obj],
|
||||
options,
|
||||
(err, alternatives) => {
|
||||
if (err) return callback(err);
|
||||
alternatives = alternatives
|
||||
.filter(obj => regExp.test(obj.request))
|
||||
.map(obj => {
|
||||
const dep = new ContextElementDependency(
|
||||
`${obj.request}${resourceQuery}${resourceFragment}`,
|
||||
obj.request,
|
||||
typePrefix,
|
||||
category,
|
||||
referencedExports,
|
||||
obj.context
|
||||
);
|
||||
dep.optional = true;
|
||||
return dep;
|
||||
});
|
||||
callback(null, alternatives);
|
||||
}
|
||||
);
|
||||
} else {
|
||||
callback();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
callback();
|
||||
}
|
||||
},
|
||||
(err, result) => {
|
||||
if (err) return callback(err);
|
||||
|
||||
if (!result) return callback(null, []);
|
||||
|
||||
const flattenedResult = [];
|
||||
|
||||
for (const item of result) {
|
||||
if (item) flattenedResult.push(...item);
|
||||
}
|
||||
|
||||
callback(null, flattenedResult);
|
||||
}
|
||||
);
|
||||
});
|
||||
};
|
||||
|
||||
const addSubDirectory = (ctx, dir, callback) =>
|
||||
addDirectory(ctx, dir, addSubDirectory, callback);
|
||||
|
||||
const visitResource = (resource, callback) => {
|
||||
if (typeof fs.realpath === "function") {
|
||||
addDirectoryChecked(resource, resource, new Set(), callback);
|
||||
} else {
|
||||
addDirectory(resource, resource, addSubDirectory, callback);
|
||||
}
|
||||
};
|
||||
|
||||
if (typeof resource === "string") {
|
||||
visitResource(resource, callback);
|
||||
} else {
|
||||
asyncLib.map(resource, visitResource, (err, result) => {
|
||||
if (err) return callback(err);
|
||||
|
||||
// result dependencies should have unique userRequest
|
||||
// ordered by resolve result
|
||||
const temp = new Set();
|
||||
const res = [];
|
||||
for (let i = 0; i < result.length; i++) {
|
||||
const inner = result[i];
|
||||
for (const el of inner) {
|
||||
if (temp.has(el.userRequest)) continue;
|
||||
res.push(el);
|
||||
temp.add(el.userRequest);
|
||||
}
|
||||
}
|
||||
callback(null, res);
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
157
node_modules/webpack/lib/ContextReplacementPlugin.js
generated
vendored
Normal file
157
node_modules/webpack/lib/ContextReplacementPlugin.js
generated
vendored
Normal file
@@ -0,0 +1,157 @@
|
||||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Tobias Koppers @sokra
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
const ContextElementDependency = require("./dependencies/ContextElementDependency");
|
||||
const { join } = require("./util/fs");
|
||||
|
||||
class ContextReplacementPlugin {
|
||||
constructor(
|
||||
resourceRegExp,
|
||||
newContentResource,
|
||||
newContentRecursive,
|
||||
newContentRegExp
|
||||
) {
|
||||
this.resourceRegExp = resourceRegExp;
|
||||
|
||||
if (typeof newContentResource === "function") {
|
||||
this.newContentCallback = newContentResource;
|
||||
} else if (
|
||||
typeof newContentResource === "string" &&
|
||||
typeof newContentRecursive === "object"
|
||||
) {
|
||||
this.newContentResource = newContentResource;
|
||||
this.newContentCreateContextMap = (fs, callback) => {
|
||||
callback(null, newContentRecursive);
|
||||
};
|
||||
} else if (
|
||||
typeof newContentResource === "string" &&
|
||||
typeof newContentRecursive === "function"
|
||||
) {
|
||||
this.newContentResource = newContentResource;
|
||||
this.newContentCreateContextMap = newContentRecursive;
|
||||
} else {
|
||||
if (typeof newContentResource !== "string") {
|
||||
newContentRegExp = newContentRecursive;
|
||||
newContentRecursive = newContentResource;
|
||||
newContentResource = undefined;
|
||||
}
|
||||
if (typeof newContentRecursive !== "boolean") {
|
||||
newContentRegExp = newContentRecursive;
|
||||
newContentRecursive = undefined;
|
||||
}
|
||||
this.newContentResource = newContentResource;
|
||||
this.newContentRecursive = newContentRecursive;
|
||||
this.newContentRegExp = newContentRegExp;
|
||||
}
|
||||
}
|
||||
|
||||
apply(compiler) {
|
||||
const resourceRegExp = this.resourceRegExp;
|
||||
const newContentCallback = this.newContentCallback;
|
||||
const newContentResource = this.newContentResource;
|
||||
const newContentRecursive = this.newContentRecursive;
|
||||
const newContentRegExp = this.newContentRegExp;
|
||||
const newContentCreateContextMap = this.newContentCreateContextMap;
|
||||
|
||||
compiler.hooks.contextModuleFactory.tap("ContextReplacementPlugin", cmf => {
|
||||
cmf.hooks.beforeResolve.tap("ContextReplacementPlugin", result => {
|
||||
if (!result) return;
|
||||
if (resourceRegExp.test(result.request)) {
|
||||
if (newContentResource !== undefined) {
|
||||
result.request = newContentResource;
|
||||
}
|
||||
if (newContentRecursive !== undefined) {
|
||||
result.recursive = newContentRecursive;
|
||||
}
|
||||
if (newContentRegExp !== undefined) {
|
||||
result.regExp = newContentRegExp;
|
||||
}
|
||||
if (typeof newContentCallback === "function") {
|
||||
newContentCallback(result);
|
||||
} else {
|
||||
for (const d of result.dependencies) {
|
||||
if (d.critical) d.critical = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
});
|
||||
cmf.hooks.afterResolve.tap("ContextReplacementPlugin", result => {
|
||||
if (!result) return;
|
||||
if (resourceRegExp.test(result.resource)) {
|
||||
if (newContentResource !== undefined) {
|
||||
if (
|
||||
newContentResource.startsWith("/") ||
|
||||
(newContentResource.length > 1 && newContentResource[1] === ":")
|
||||
) {
|
||||
result.resource = newContentResource;
|
||||
} else {
|
||||
result.resource = join(
|
||||
compiler.inputFileSystem,
|
||||
result.resource,
|
||||
newContentResource
|
||||
);
|
||||
}
|
||||
}
|
||||
if (newContentRecursive !== undefined) {
|
||||
result.recursive = newContentRecursive;
|
||||
}
|
||||
if (newContentRegExp !== undefined) {
|
||||
result.regExp = newContentRegExp;
|
||||
}
|
||||
if (typeof newContentCreateContextMap === "function") {
|
||||
result.resolveDependencies =
|
||||
createResolveDependenciesFromContextMap(
|
||||
newContentCreateContextMap
|
||||
);
|
||||
}
|
||||
if (typeof newContentCallback === "function") {
|
||||
const origResource = result.resource;
|
||||
newContentCallback(result);
|
||||
if (
|
||||
result.resource !== origResource &&
|
||||
!result.resource.startsWith("/") &&
|
||||
(result.resource.length <= 1 || result.resource[1] !== ":")
|
||||
) {
|
||||
// When the function changed it to an relative path
|
||||
result.resource = join(
|
||||
compiler.inputFileSystem,
|
||||
origResource,
|
||||
result.resource
|
||||
);
|
||||
}
|
||||
} else {
|
||||
for (const d of result.dependencies) {
|
||||
if (d.critical) d.critical = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const createResolveDependenciesFromContextMap = createContextMap => {
|
||||
const resolveDependenciesFromContextMap = (fs, options, callback) => {
|
||||
createContextMap(fs, (err, map) => {
|
||||
if (err) return callback(err);
|
||||
const dependencies = Object.keys(map).map(key => {
|
||||
return new ContextElementDependency(
|
||||
map[key] + options.resourceQuery + options.resourceFragment,
|
||||
key,
|
||||
options.category,
|
||||
options.referencedExports
|
||||
);
|
||||
});
|
||||
callback(null, dependencies);
|
||||
});
|
||||
};
|
||||
return resolveDependenciesFromContextMap;
|
||||
};
|
||||
|
||||
module.exports = ContextReplacementPlugin;
|
601
node_modules/webpack/lib/DefinePlugin.js
generated
vendored
Normal file
601
node_modules/webpack/lib/DefinePlugin.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
239
node_modules/webpack/lib/DelegatedModule.js
generated
vendored
Normal file
239
node_modules/webpack/lib/DelegatedModule.js
generated
vendored
Normal file
@@ -0,0 +1,239 @@
|
||||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Tobias Koppers @sokra
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
const { OriginalSource, RawSource } = require("webpack-sources");
|
||||
const Module = require("./Module");
|
||||
const RuntimeGlobals = require("./RuntimeGlobals");
|
||||
const DelegatedSourceDependency = require("./dependencies/DelegatedSourceDependency");
|
||||
const StaticExportsDependency = require("./dependencies/StaticExportsDependency");
|
||||
const makeSerializable = require("./util/makeSerializable");
|
||||
|
||||
/** @typedef {import("webpack-sources").Source} Source */
|
||||
/** @typedef {import("../declarations/WebpackOptions").WebpackOptionsNormalized} WebpackOptions */
|
||||
/** @typedef {import("./ChunkGraph")} ChunkGraph */
|
||||
/** @typedef {import("./Compilation")} Compilation */
|
||||
/** @typedef {import("./Dependency").UpdateHashContext} UpdateHashContext */
|
||||
/** @typedef {import("./DependencyTemplates")} DependencyTemplates */
|
||||
/** @typedef {import("./LibManifestPlugin").ManifestModuleData} ManifestModuleData */
|
||||
/** @typedef {import("./Module").CodeGenerationContext} CodeGenerationContext */
|
||||
/** @typedef {import("./Module").CodeGenerationResult} CodeGenerationResult */
|
||||
/** @typedef {import("./Module").LibIdentOptions} LibIdentOptions */
|
||||
/** @typedef {import("./Module").NeedBuildContext} NeedBuildContext */
|
||||
/** @typedef {import("./Module").SourceContext} SourceContext */
|
||||
/** @typedef {import("./RequestShortener")} RequestShortener */
|
||||
/** @typedef {import("./ResolverFactory").ResolverWithOptions} ResolverWithOptions */
|
||||
/** @typedef {import("./RuntimeTemplate")} RuntimeTemplate */
|
||||
/** @typedef {import("./WebpackError")} WebpackError */
|
||||
/** @typedef {import("./dependencies/ModuleDependency")} ModuleDependency */
|
||||
/** @typedef {import("./util/Hash")} Hash */
|
||||
/** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */
|
||||
|
||||
const TYPES = new Set(["javascript"]);
|
||||
const RUNTIME_REQUIREMENTS = new Set([
|
||||
RuntimeGlobals.module,
|
||||
RuntimeGlobals.require
|
||||
]);
|
||||
|
||||
class DelegatedModule extends Module {
|
||||
constructor(sourceRequest, data, type, userRequest, originalRequest) {
|
||||
super("javascript/dynamic", null);
|
||||
|
||||
// Info from Factory
|
||||
this.sourceRequest = sourceRequest;
|
||||
this.request = data.id;
|
||||
this.delegationType = type;
|
||||
this.userRequest = userRequest;
|
||||
this.originalRequest = originalRequest;
|
||||
/** @type {ManifestModuleData} */
|
||||
this.delegateData = data;
|
||||
|
||||
// Build info
|
||||
this.delegatedSourceDependency = undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {Set<string>} types available (do not mutate)
|
||||
*/
|
||||
getSourceTypes() {
|
||||
return TYPES;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {LibIdentOptions} options options
|
||||
* @returns {string | null} an identifier for library inclusion
|
||||
*/
|
||||
libIdent(options) {
|
||||
return typeof this.originalRequest === "string"
|
||||
? this.originalRequest
|
||||
: this.originalRequest.libIdent(options);
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {string} a unique identifier of the module
|
||||
*/
|
||||
identifier() {
|
||||
return `delegated ${JSON.stringify(this.request)} from ${
|
||||
this.sourceRequest
|
||||
}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {RequestShortener} requestShortener the request shortener
|
||||
* @returns {string} a user readable identifier of the module
|
||||
*/
|
||||
readableIdentifier(requestShortener) {
|
||||
return `delegated ${this.userRequest} from ${this.sourceRequest}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {NeedBuildContext} context context info
|
||||
* @param {function((WebpackError | null)=, boolean=): void} callback callback function, returns true, if the module needs a rebuild
|
||||
* @returns {void}
|
||||
*/
|
||||
needBuild(context, callback) {
|
||||
return callback(null, !this.buildMeta);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {WebpackOptions} options webpack options
|
||||
* @param {Compilation} compilation the compilation
|
||||
* @param {ResolverWithOptions} resolver the resolver
|
||||
* @param {InputFileSystem} fs the file system
|
||||
* @param {function(WebpackError=): void} callback callback function
|
||||
* @returns {void}
|
||||
*/
|
||||
build(options, compilation, resolver, fs, callback) {
|
||||
this.buildMeta = { ...this.delegateData.buildMeta };
|
||||
this.buildInfo = {};
|
||||
this.dependencies.length = 0;
|
||||
this.delegatedSourceDependency = new DelegatedSourceDependency(
|
||||
this.sourceRequest
|
||||
);
|
||||
this.addDependency(this.delegatedSourceDependency);
|
||||
this.addDependency(
|
||||
new StaticExportsDependency(this.delegateData.exports || true, false)
|
||||
);
|
||||
callback();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {CodeGenerationContext} context context for code generation
|
||||
* @returns {CodeGenerationResult} result
|
||||
*/
|
||||
codeGeneration({ runtimeTemplate, moduleGraph, chunkGraph }) {
|
||||
const dep = /** @type {DelegatedSourceDependency} */ (this.dependencies[0]);
|
||||
const sourceModule = moduleGraph.getModule(dep);
|
||||
let str;
|
||||
|
||||
if (!sourceModule) {
|
||||
str = runtimeTemplate.throwMissingModuleErrorBlock({
|
||||
request: this.sourceRequest
|
||||
});
|
||||
} else {
|
||||
str = `module.exports = (${runtimeTemplate.moduleExports({
|
||||
module: sourceModule,
|
||||
chunkGraph,
|
||||
request: dep.request,
|
||||
runtimeRequirements: new Set()
|
||||
})})`;
|
||||
|
||||
switch (this.delegationType) {
|
||||
case "require":
|
||||
str += `(${JSON.stringify(this.request)})`;
|
||||
break;
|
||||
case "object":
|
||||
str += `[${JSON.stringify(this.request)}]`;
|
||||
break;
|
||||
}
|
||||
|
||||
str += ";";
|
||||
}
|
||||
|
||||
const sources = new Map();
|
||||
if (this.useSourceMap || this.useSimpleSourceMap) {
|
||||
sources.set("javascript", new OriginalSource(str, this.identifier()));
|
||||
} else {
|
||||
sources.set("javascript", new RawSource(str));
|
||||
}
|
||||
|
||||
return {
|
||||
sources,
|
||||
runtimeRequirements: RUNTIME_REQUIREMENTS
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string=} type the source type for which the size should be estimated
|
||||
* @returns {number} the estimated size of the module (must be non-zero)
|
||||
*/
|
||||
size(type) {
|
||||
return 42;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Hash} hash the hash used to track dependencies
|
||||
* @param {UpdateHashContext} context context
|
||||
* @returns {void}
|
||||
*/
|
||||
updateHash(hash, context) {
|
||||
hash.update(this.delegationType);
|
||||
hash.update(JSON.stringify(this.request));
|
||||
super.updateHash(hash, context);
|
||||
}
|
||||
|
||||
serialize(context) {
|
||||
const { write } = context;
|
||||
// constructor
|
||||
write(this.sourceRequest);
|
||||
write(this.delegateData);
|
||||
write(this.delegationType);
|
||||
write(this.userRequest);
|
||||
write(this.originalRequest);
|
||||
super.serialize(context);
|
||||
}
|
||||
|
||||
static deserialize(context) {
|
||||
const { read } = context;
|
||||
const obj = new DelegatedModule(
|
||||
read(), // sourceRequest
|
||||
read(), // delegateData
|
||||
read(), // delegationType
|
||||
read(), // userRequest
|
||||
read() // originalRequest
|
||||
);
|
||||
obj.deserialize(context);
|
||||
return obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Assuming this module is in the cache. Update the (cached) module with
|
||||
* the fresh module from the factory. Usually updates internal references
|
||||
* and properties.
|
||||
* @param {Module} module fresh module
|
||||
* @returns {void}
|
||||
*/
|
||||
updateCacheModule(module) {
|
||||
super.updateCacheModule(module);
|
||||
const m = /** @type {DelegatedModule} */ (module);
|
||||
this.delegationType = m.delegationType;
|
||||
this.userRequest = m.userRequest;
|
||||
this.originalRequest = m.originalRequest;
|
||||
this.delegateData = m.delegateData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Assuming this module is in the cache. Remove internal references to allow freeing some memory.
|
||||
*/
|
||||
cleanupForCache() {
|
||||
super.cleanupForCache();
|
||||
this.delegateData = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
makeSerializable(DelegatedModule, "webpack/lib/DelegatedModule");
|
||||
|
||||
module.exports = DelegatedModule;
|
91
node_modules/webpack/lib/DelegatedModuleFactoryPlugin.js
generated
vendored
Normal file
91
node_modules/webpack/lib/DelegatedModuleFactoryPlugin.js
generated
vendored
Normal file
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Tobias Koppers @sokra
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
const DelegatedModule = require("./DelegatedModule");
|
||||
|
||||
// options.source
|
||||
// options.type
|
||||
// options.context
|
||||
// options.scope
|
||||
// options.content
|
||||
// options.associatedObjectForCache
|
||||
class DelegatedModuleFactoryPlugin {
|
||||
constructor(options) {
|
||||
this.options = options;
|
||||
options.type = options.type || "require";
|
||||
options.extensions = options.extensions || ["", ".js", ".json", ".wasm"];
|
||||
}
|
||||
|
||||
apply(normalModuleFactory) {
|
||||
const scope = this.options.scope;
|
||||
if (scope) {
|
||||
normalModuleFactory.hooks.factorize.tapAsync(
|
||||
"DelegatedModuleFactoryPlugin",
|
||||
(data, callback) => {
|
||||
const [dependency] = data.dependencies;
|
||||
const { request } = dependency;
|
||||
if (request && request.startsWith(`${scope}/`)) {
|
||||
const innerRequest = "." + request.slice(scope.length);
|
||||
let resolved;
|
||||
if (innerRequest in this.options.content) {
|
||||
resolved = this.options.content[innerRequest];
|
||||
return callback(
|
||||
null,
|
||||
new DelegatedModule(
|
||||
this.options.source,
|
||||
resolved,
|
||||
this.options.type,
|
||||
innerRequest,
|
||||
request
|
||||
)
|
||||
);
|
||||
}
|
||||
for (let i = 0; i < this.options.extensions.length; i++) {
|
||||
const extension = this.options.extensions[i];
|
||||
const requestPlusExt = innerRequest + extension;
|
||||
if (requestPlusExt in this.options.content) {
|
||||
resolved = this.options.content[requestPlusExt];
|
||||
return callback(
|
||||
null,
|
||||
new DelegatedModule(
|
||||
this.options.source,
|
||||
resolved,
|
||||
this.options.type,
|
||||
requestPlusExt,
|
||||
request + extension
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
return callback();
|
||||
}
|
||||
);
|
||||
} else {
|
||||
normalModuleFactory.hooks.module.tap(
|
||||
"DelegatedModuleFactoryPlugin",
|
||||
module => {
|
||||
const request = module.libIdent(this.options);
|
||||
if (request) {
|
||||
if (request in this.options.content) {
|
||||
const resolved = this.options.content[request];
|
||||
return new DelegatedModule(
|
||||
this.options.source,
|
||||
resolved,
|
||||
this.options.type,
|
||||
request,
|
||||
module
|
||||
);
|
||||
}
|
||||
}
|
||||
return module;
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
module.exports = DelegatedModuleFactoryPlugin;
|
43
node_modules/webpack/lib/DelegatedPlugin.js
generated
vendored
Normal file
43
node_modules/webpack/lib/DelegatedPlugin.js
generated
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Tobias Koppers @sokra
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
const DelegatedModuleFactoryPlugin = require("./DelegatedModuleFactoryPlugin");
|
||||
const DelegatedSourceDependency = require("./dependencies/DelegatedSourceDependency");
|
||||
|
||||
/** @typedef {import("./Compiler")} Compiler */
|
||||
|
||||
class DelegatedPlugin {
|
||||
constructor(options) {
|
||||
this.options = options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply the plugin
|
||||
* @param {Compiler} compiler the compiler instance
|
||||
* @returns {void}
|
||||
*/
|
||||
apply(compiler) {
|
||||
compiler.hooks.compilation.tap(
|
||||
"DelegatedPlugin",
|
||||
(compilation, { normalModuleFactory }) => {
|
||||
compilation.dependencyFactories.set(
|
||||
DelegatedSourceDependency,
|
||||
normalModuleFactory
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
compiler.hooks.compile.tap("DelegatedPlugin", ({ normalModuleFactory }) => {
|
||||
new DelegatedModuleFactoryPlugin({
|
||||
associatedObjectForCache: compiler.root,
|
||||
...this.options
|
||||
}).apply(normalModuleFactory);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = DelegatedPlugin;
|
107
node_modules/webpack/lib/DependenciesBlock.js
generated
vendored
Normal file
107
node_modules/webpack/lib/DependenciesBlock.js
generated
vendored
Normal file
@@ -0,0 +1,107 @@
|
||||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Tobias Koppers @sokra
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
const makeSerializable = require("./util/makeSerializable");
|
||||
|
||||
/** @typedef {import("./AsyncDependenciesBlock")} AsyncDependenciesBlock */
|
||||
/** @typedef {import("./ChunkGraph")} ChunkGraph */
|
||||
/** @typedef {import("./ChunkGroup")} ChunkGroup */
|
||||
/** @typedef {import("./Dependency")} Dependency */
|
||||
/** @typedef {import("./Dependency").UpdateHashContext} UpdateHashContext */
|
||||
/** @typedef {import("./util/Hash")} Hash */
|
||||
|
||||
/** @typedef {(d: Dependency) => boolean} DependencyFilterFunction */
|
||||
|
||||
class DependenciesBlock {
|
||||
constructor() {
|
||||
/** @type {Dependency[]} */
|
||||
this.dependencies = [];
|
||||
/** @type {AsyncDependenciesBlock[]} */
|
||||
this.blocks = [];
|
||||
/** @type {DependenciesBlock} */
|
||||
this.parent = undefined;
|
||||
}
|
||||
|
||||
getRootBlock() {
|
||||
/** @type {DependenciesBlock} */
|
||||
let current = this;
|
||||
while (current.parent) current = current.parent;
|
||||
return current;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a DependencyBlock to DependencyBlock relationship.
|
||||
* This is used for when a Module has a AsyncDependencyBlock tie (for code-splitting)
|
||||
*
|
||||
* @param {AsyncDependenciesBlock} block block being added
|
||||
* @returns {void}
|
||||
*/
|
||||
addBlock(block) {
|
||||
this.blocks.push(block);
|
||||
block.parent = this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Dependency} dependency dependency being tied to block.
|
||||
* This is an "edge" pointing to another "node" on module graph.
|
||||
* @returns {void}
|
||||
*/
|
||||
addDependency(dependency) {
|
||||
this.dependencies.push(dependency);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Dependency} dependency dependency being removed
|
||||
* @returns {void}
|
||||
*/
|
||||
removeDependency(dependency) {
|
||||
const idx = this.dependencies.indexOf(dependency);
|
||||
if (idx >= 0) {
|
||||
this.dependencies.splice(idx, 1);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes all dependencies and blocks
|
||||
* @returns {void}
|
||||
*/
|
||||
clearDependenciesAndBlocks() {
|
||||
this.dependencies.length = 0;
|
||||
this.blocks.length = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Hash} hash the hash used to track dependencies
|
||||
* @param {UpdateHashContext} context context
|
||||
* @returns {void}
|
||||
*/
|
||||
updateHash(hash, context) {
|
||||
for (const dep of this.dependencies) {
|
||||
dep.updateHash(hash, context);
|
||||
}
|
||||
for (const block of this.blocks) {
|
||||
block.updateHash(hash, context);
|
||||
}
|
||||
}
|
||||
|
||||
serialize({ write }) {
|
||||
write(this.dependencies);
|
||||
write(this.blocks);
|
||||
}
|
||||
|
||||
deserialize({ read }) {
|
||||
this.dependencies = read();
|
||||
this.blocks = read();
|
||||
for (const block of this.blocks) {
|
||||
block.parent = this;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
makeSerializable(DependenciesBlock, "webpack/lib/DependenciesBlock");
|
||||
|
||||
module.exports = DependenciesBlock;
|
355
node_modules/webpack/lib/Dependency.js
generated
vendored
Normal file
355
node_modules/webpack/lib/Dependency.js
generated
vendored
Normal file
@@ -0,0 +1,355 @@
|
||||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Tobias Koppers @sokra
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
const memoize = require("./util/memoize");
|
||||
|
||||
/** @typedef {import("webpack-sources").Source} Source */
|
||||
/** @typedef {import("./ChunkGraph")} ChunkGraph */
|
||||
/** @typedef {import("./DependenciesBlock")} DependenciesBlock */
|
||||
/** @typedef {import("./DependencyTemplates")} DependencyTemplates */
|
||||
/** @typedef {import("./Module")} Module */
|
||||
/** @typedef {import("./ModuleGraph")} ModuleGraph */
|
||||
/** @typedef {import("./ModuleGraphConnection")} ModuleGraphConnection */
|
||||
/** @typedef {import("./ModuleGraphConnection").ConnectionState} ConnectionState */
|
||||
/** @typedef {import("./RuntimeTemplate")} RuntimeTemplate */
|
||||
/** @typedef {import("./WebpackError")} WebpackError */
|
||||
/** @typedef {import("./util/Hash")} Hash */
|
||||
/** @typedef {import("./util/runtime").RuntimeSpec} RuntimeSpec */
|
||||
|
||||
/**
|
||||
* @typedef {Object} UpdateHashContext
|
||||
* @property {ChunkGraph} chunkGraph
|
||||
* @property {RuntimeSpec} runtime
|
||||
* @property {RuntimeTemplate=} runtimeTemplate
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} SourcePosition
|
||||
* @property {number} line
|
||||
* @property {number=} column
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} RealDependencyLocation
|
||||
* @property {SourcePosition} start
|
||||
* @property {SourcePosition=} end
|
||||
* @property {number=} index
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} SyntheticDependencyLocation
|
||||
* @property {string} name
|
||||
* @property {number=} index
|
||||
*/
|
||||
|
||||
/** @typedef {SyntheticDependencyLocation|RealDependencyLocation} DependencyLocation */
|
||||
|
||||
/**
|
||||
* @typedef {Object} ExportSpec
|
||||
* @property {string} name the name of the export
|
||||
* @property {boolean=} canMangle can the export be renamed (defaults to true)
|
||||
* @property {boolean=} terminalBinding is the export a terminal binding that should be checked for export star conflicts
|
||||
* @property {(string | ExportSpec)[]=} exports nested exports
|
||||
* @property {ModuleGraphConnection=} from when reexported: from which module
|
||||
* @property {string[] | null=} export when reexported: from which export
|
||||
* @property {number=} priority when reexported: with which priority
|
||||
* @property {boolean=} hidden export is not visible, because another export blends over it
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} ExportsSpec
|
||||
* @property {(string | ExportSpec)[] | true | null} exports exported names, true for unknown exports or null for no exports
|
||||
* @property {Set<string>=} excludeExports when exports = true, list of unaffected exports
|
||||
* @property {Set<string>=} hideExports list of maybe prior exposed, but now hidden exports
|
||||
* @property {ModuleGraphConnection=} from when reexported: from which module
|
||||
* @property {number=} priority when reexported: with which priority
|
||||
* @property {boolean=} canMangle can the export be renamed (defaults to true)
|
||||
* @property {boolean=} terminalBinding are the exports terminal bindings that should be checked for export star conflicts
|
||||
* @property {Module[]=} dependencies module on which the result depends on
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} ReferencedExport
|
||||
* @property {string[]} name name of the referenced export
|
||||
* @property {boolean=} canMangle when false, referenced export can not be mangled, defaults to true
|
||||
*/
|
||||
|
||||
const TRANSITIVE = Symbol("transitive");
|
||||
|
||||
const getIgnoredModule = memoize(() => {
|
||||
const RawModule = require("./RawModule");
|
||||
return new RawModule("/* (ignored) */", `ignored`, `(ignored)`);
|
||||
});
|
||||
|
||||
class Dependency {
|
||||
constructor() {
|
||||
/** @type {Module} */
|
||||
this._parentModule = undefined;
|
||||
/** @type {DependenciesBlock} */
|
||||
this._parentDependenciesBlock = undefined;
|
||||
/** @type {number} */
|
||||
this._parentDependenciesBlockIndex = -1;
|
||||
// TODO check if this can be moved into ModuleDependency
|
||||
/** @type {boolean} */
|
||||
this.weak = false;
|
||||
// TODO check if this can be moved into ModuleDependency
|
||||
/** @type {boolean} */
|
||||
this.optional = false;
|
||||
this._locSL = 0;
|
||||
this._locSC = 0;
|
||||
this._locEL = 0;
|
||||
this._locEC = 0;
|
||||
this._locI = undefined;
|
||||
this._locN = undefined;
|
||||
this._loc = undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {string} a display name for the type of dependency
|
||||
*/
|
||||
get type() {
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {string} a dependency category, typical categories are "commonjs", "amd", "esm"
|
||||
*/
|
||||
get category() {
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {DependencyLocation} location
|
||||
*/
|
||||
get loc() {
|
||||
if (this._loc !== undefined) return this._loc;
|
||||
/** @type {SyntheticDependencyLocation & RealDependencyLocation} */
|
||||
const loc = {};
|
||||
if (this._locSL > 0) {
|
||||
loc.start = { line: this._locSL, column: this._locSC };
|
||||
}
|
||||
if (this._locEL > 0) {
|
||||
loc.end = { line: this._locEL, column: this._locEC };
|
||||
}
|
||||
if (this._locN !== undefined) {
|
||||
loc.name = this._locN;
|
||||
}
|
||||
if (this._locI !== undefined) {
|
||||
loc.index = this._locI;
|
||||
}
|
||||
return (this._loc = loc);
|
||||
}
|
||||
|
||||
set loc(loc) {
|
||||
if ("start" in loc && typeof loc.start === "object") {
|
||||
this._locSL = loc.start.line || 0;
|
||||
this._locSC = loc.start.column || 0;
|
||||
} else {
|
||||
this._locSL = 0;
|
||||
this._locSC = 0;
|
||||
}
|
||||
if ("end" in loc && typeof loc.end === "object") {
|
||||
this._locEL = loc.end.line || 0;
|
||||
this._locEC = loc.end.column || 0;
|
||||
} else {
|
||||
this._locEL = 0;
|
||||
this._locEC = 0;
|
||||
}
|
||||
if ("index" in loc) {
|
||||
this._locI = loc.index;
|
||||
} else {
|
||||
this._locI = undefined;
|
||||
}
|
||||
if ("name" in loc) {
|
||||
this._locN = loc.name;
|
||||
} else {
|
||||
this._locN = undefined;
|
||||
}
|
||||
this._loc = loc;
|
||||
}
|
||||
|
||||
setLoc(startLine, startColumn, endLine, endColumn) {
|
||||
this._locSL = startLine;
|
||||
this._locSC = startColumn;
|
||||
this._locEL = endLine;
|
||||
this._locEC = endColumn;
|
||||
this._locI = undefined;
|
||||
this._locN = undefined;
|
||||
this._loc = undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {string | undefined} a request context
|
||||
*/
|
||||
getContext() {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {string | null} an identifier to merge equal requests
|
||||
*/
|
||||
getResourceIdentifier() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {boolean | TRANSITIVE} true, when changes to the referenced module could affect the referencing module; TRANSITIVE, when changes to the referenced module could affect referencing modules of the referencing module
|
||||
*/
|
||||
couldAffectReferencingModule() {
|
||||
return TRANSITIVE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the referenced module and export
|
||||
* @deprecated
|
||||
* @param {ModuleGraph} moduleGraph module graph
|
||||
* @returns {never} throws error
|
||||
*/
|
||||
getReference(moduleGraph) {
|
||||
throw new Error(
|
||||
"Dependency.getReference was removed in favor of Dependency.getReferencedExports, ModuleGraph.getModule and ModuleGraph.getConnection().active"
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns list of exports referenced by this dependency
|
||||
* @param {ModuleGraph} moduleGraph module graph
|
||||
* @param {RuntimeSpec} runtime the runtime for which the module is analysed
|
||||
* @returns {(string[] | ReferencedExport)[]} referenced exports
|
||||
*/
|
||||
getReferencedExports(moduleGraph, runtime) {
|
||||
return Dependency.EXPORTS_OBJECT_REFERENCED;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {ModuleGraph} moduleGraph module graph
|
||||
* @returns {null | false | function(ModuleGraphConnection, RuntimeSpec): ConnectionState} function to determine if the connection is active
|
||||
*/
|
||||
getCondition(moduleGraph) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the exported names
|
||||
* @param {ModuleGraph} moduleGraph module graph
|
||||
* @returns {ExportsSpec | undefined} export names
|
||||
*/
|
||||
getExports(moduleGraph) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns warnings
|
||||
* @param {ModuleGraph} moduleGraph module graph
|
||||
* @returns {WebpackError[]} warnings
|
||||
*/
|
||||
getWarnings(moduleGraph) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns errors
|
||||
* @param {ModuleGraph} moduleGraph module graph
|
||||
* @returns {WebpackError[]} errors
|
||||
*/
|
||||
getErrors(moduleGraph) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the hash
|
||||
* @param {Hash} hash hash to be updated
|
||||
* @param {UpdateHashContext} context context
|
||||
* @returns {void}
|
||||
*/
|
||||
updateHash(hash, context) {}
|
||||
|
||||
/**
|
||||
* implement this method to allow the occurrence order plugin to count correctly
|
||||
* @returns {number} count how often the id is used in this dependency
|
||||
*/
|
||||
getNumberOfIdOccurrences() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {ModuleGraph} moduleGraph the module graph
|
||||
* @returns {ConnectionState} how this dependency connects the module to referencing modules
|
||||
*/
|
||||
getModuleEvaluationSideEffectsState(moduleGraph) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} context context directory
|
||||
* @returns {Module} a module
|
||||
*/
|
||||
createIgnoredModule(context) {
|
||||
return getIgnoredModule();
|
||||
}
|
||||
|
||||
serialize({ write }) {
|
||||
write(this.weak);
|
||||
write(this.optional);
|
||||
write(this._locSL);
|
||||
write(this._locSC);
|
||||
write(this._locEL);
|
||||
write(this._locEC);
|
||||
write(this._locI);
|
||||
write(this._locN);
|
||||
}
|
||||
|
||||
deserialize({ read }) {
|
||||
this.weak = read();
|
||||
this.optional = read();
|
||||
this._locSL = read();
|
||||
this._locSC = read();
|
||||
this._locEL = read();
|
||||
this._locEC = read();
|
||||
this._locI = read();
|
||||
this._locN = read();
|
||||
}
|
||||
}
|
||||
|
||||
/** @type {string[][]} */
|
||||
Dependency.NO_EXPORTS_REFERENCED = [];
|
||||
/** @type {string[][]} */
|
||||
Dependency.EXPORTS_OBJECT_REFERENCED = [[]];
|
||||
|
||||
Object.defineProperty(Dependency.prototype, "module", {
|
||||
/**
|
||||
* @deprecated
|
||||
* @returns {never} throws
|
||||
*/
|
||||
get() {
|
||||
throw new Error(
|
||||
"module property was removed from Dependency (use compilation.moduleGraph.getModule(dependency) instead)"
|
||||
);
|
||||
},
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* @returns {never} throws
|
||||
*/
|
||||
set() {
|
||||
throw new Error(
|
||||
"module property was removed from Dependency (use compilation.moduleGraph.updateModule(dependency, module) instead)"
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
Object.defineProperty(Dependency.prototype, "disconnect", {
|
||||
get() {
|
||||
throw new Error(
|
||||
"disconnect was removed from Dependency (Dependency no longer carries graph specific information)"
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
Dependency.TRANSITIVE = TRANSITIVE;
|
||||
|
||||
module.exports = Dependency;
|
57
node_modules/webpack/lib/DependencyTemplate.js
generated
vendored
Normal file
57
node_modules/webpack/lib/DependencyTemplate.js
generated
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Tobias Koppers @sokra
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
/** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */
|
||||
/** @typedef {import("./ChunkGraph")} ChunkGraph */
|
||||
/** @typedef {import("./CodeGenerationResults")} CodeGenerationResults */
|
||||
/** @typedef {import("./ConcatenationScope")} ConcatenationScope */
|
||||
/** @typedef {import("./Dependency")} Dependency */
|
||||
/** @typedef {import("./Dependency").RuntimeSpec} RuntimeSpec */
|
||||
/** @typedef {import("./DependencyTemplates")} DependencyTemplates */
|
||||
/** @typedef {import("./Generator").GenerateContext} GenerateContext */
|
||||
/** @template T @typedef {import("./InitFragment")<T>} InitFragment */
|
||||
/** @typedef {import("./Module")} Module */
|
||||
/** @typedef {import("./ModuleGraph")} ModuleGraph */
|
||||
/** @typedef {import("./RuntimeTemplate")} RuntimeTemplate */
|
||||
|
||||
/**
|
||||
* @typedef {Object} DependencyTemplateContext
|
||||
* @property {RuntimeTemplate} runtimeTemplate the runtime template
|
||||
* @property {DependencyTemplates} dependencyTemplates the dependency templates
|
||||
* @property {ModuleGraph} moduleGraph the module graph
|
||||
* @property {ChunkGraph} chunkGraph the chunk graph
|
||||
* @property {Set<string>} runtimeRequirements the requirements for runtime
|
||||
* @property {Module} module current module
|
||||
* @property {RuntimeSpec} runtime current runtimes, for which code is generated
|
||||
* @property {InitFragment<GenerateContext>[]} initFragments mutable array of init fragments for the current module
|
||||
* @property {ConcatenationScope=} concatenationScope when in a concatenated module, information about other concatenated modules
|
||||
* @property {CodeGenerationResults} codeGenerationResults the code generation results
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} CssDependencyTemplateContextExtras
|
||||
* @property {Map<string, string>} cssExports the css exports
|
||||
*/
|
||||
|
||||
/** @typedef {DependencyTemplateContext & CssDependencyTemplateContextExtras} CssDependencyTemplateContext */
|
||||
|
||||
class DependencyTemplate {
|
||||
/* istanbul ignore next */
|
||||
/**
|
||||
* @abstract
|
||||
* @param {Dependency} dependency the dependency for which the template should be applied
|
||||
* @param {ReplaceSource} source the current replace source which can be modified
|
||||
* @param {DependencyTemplateContext} templateContext the context object
|
||||
* @returns {void}
|
||||
*/
|
||||
apply(dependency, source, templateContext) {
|
||||
const AbstractMethodError = require("./AbstractMethodError");
|
||||
throw new AbstractMethodError();
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = DependencyTemplate;
|
67
node_modules/webpack/lib/DependencyTemplates.js
generated
vendored
Normal file
67
node_modules/webpack/lib/DependencyTemplates.js
generated
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Tobias Koppers @sokra
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
const createHash = require("./util/createHash");
|
||||
|
||||
/** @typedef {import("./Dependency")} Dependency */
|
||||
/** @typedef {import("./DependencyTemplate")} DependencyTemplate */
|
||||
/** @typedef {typeof import("./util/Hash")} Hash */
|
||||
|
||||
/** @typedef {new (...args: any[]) => Dependency} DependencyConstructor */
|
||||
|
||||
class DependencyTemplates {
|
||||
/**
|
||||
* @param {string | Hash} hashFunction the hash function to use
|
||||
*/
|
||||
constructor(hashFunction = "md4") {
|
||||
/** @type {Map<Function, DependencyTemplate>} */
|
||||
this._map = new Map();
|
||||
/** @type {string} */
|
||||
this._hash = "31d6cfe0d16ae931b73c59d7e0c089c0";
|
||||
this._hashFunction = hashFunction;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {DependencyConstructor} dependency Constructor of Dependency
|
||||
* @returns {DependencyTemplate} template for this dependency
|
||||
*/
|
||||
get(dependency) {
|
||||
return this._map.get(dependency);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {DependencyConstructor} dependency Constructor of Dependency
|
||||
* @param {DependencyTemplate} dependencyTemplate template for this dependency
|
||||
* @returns {void}
|
||||
*/
|
||||
set(dependency, dependencyTemplate) {
|
||||
this._map.set(dependency, dependencyTemplate);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} part additional hash contributor
|
||||
* @returns {void}
|
||||
*/
|
||||
updateHash(part) {
|
||||
const hash = createHash(this._hashFunction);
|
||||
hash.update(`${this._hash}${part}`);
|
||||
this._hash = /** @type {string} */ (hash.digest("hex"));
|
||||
}
|
||||
|
||||
getHash() {
|
||||
return this._hash;
|
||||
}
|
||||
|
||||
clone() {
|
||||
const newInstance = new DependencyTemplates(this._hashFunction);
|
||||
newInstance._map = new Map(this._map);
|
||||
newInstance._hash = this._hash;
|
||||
return newInstance;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = DependencyTemplates;
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user