summaryrefslogtreecommitdiff
path: root/node_modules/webpack/lib/EvalDevToolModulePlugin.js
diff options
context:
space:
mode:
authorlittleblack111 <littleblack11111@gmail.com>2023-10-31 15:37:35 +0800
committerlittleblack111 <littleblack11111@gmail.com>2023-10-31 15:37:35 +0800
commitd5f14083061f2ce6a42313188443a42e30796320 (patch)
treecc6a9889e08b29595a76a33b9e7b4ef84866468b /node_modules/webpack/lib/EvalDevToolModulePlugin.js
parentb1a6ea021f29f182b62f9f81024a3d8ac8621b7f (diff)
added make browserlist(autoprefixer) work fixed
Diffstat (limited to 'node_modules/webpack/lib/EvalDevToolModulePlugin.js')
-rw-r--r--node_modules/webpack/lib/EvalDevToolModulePlugin.js117
1 files changed, 117 insertions, 0 deletions
diff --git a/node_modules/webpack/lib/EvalDevToolModulePlugin.js b/node_modules/webpack/lib/EvalDevToolModulePlugin.js
new file mode 100644
index 00000000..b0a47db8
--- /dev/null
+++ b/node_modules/webpack/lib/EvalDevToolModulePlugin.js
@@ -0,0 +1,117 @@
+/*
+ MIT License http://www.opensource.org/licenses/mit-license.php
+ Author Tobias Koppers @sokra
+*/
+
+"use strict";
+
+const { ConcatSource, RawSource } = require("webpack-sources");
+const ExternalModule = require("./ExternalModule");
+const ModuleFilenameHelpers = require("./ModuleFilenameHelpers");
+const RuntimeGlobals = require("./RuntimeGlobals");
+const JavascriptModulesPlugin = require("./javascript/JavascriptModulesPlugin");
+
+/** @typedef {import("webpack-sources").Source} Source */
+/** @typedef {import("./Compiler")} Compiler */
+
+/** @type {WeakMap<Source, Source>} */
+const cache = new WeakMap();
+
+const devtoolWarning = new RawSource(`/*
+ * ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
+ * This devtool is neither made for production nor for readable output files.
+ * It uses "eval()" calls to create a separate source file in the browser devtools.
+ * If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/)
+ * or disable the default devtool with "devtool: false".
+ * If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/).
+ */
+`);
+
+class EvalDevToolModulePlugin {
+ constructor(options) {
+ this.namespace = options.namespace || "";
+ this.sourceUrlComment = options.sourceUrlComment || "\n//# sourceURL=[url]";
+ this.moduleFilenameTemplate =
+ options.moduleFilenameTemplate ||
+ "webpack://[namespace]/[resourcePath]?[loaders]";
+ }
+
+ /**
+ * Apply the plugin
+ * @param {Compiler} compiler the compiler instance
+ * @returns {void}
+ */
+ apply(compiler) {
+ compiler.hooks.compilation.tap("EvalDevToolModulePlugin", compilation => {
+ const hooks = JavascriptModulesPlugin.getCompilationHooks(compilation);
+ hooks.renderModuleContent.tap(
+ "EvalDevToolModulePlugin",
+ (source, module, { runtimeTemplate, chunkGraph }) => {
+ const cacheEntry = cache.get(source);
+ if (cacheEntry !== undefined) return cacheEntry;
+ if (module instanceof ExternalModule) {
+ cache.set(source, source);
+ return source;
+ }
+ const content = source.source();
+ const str = ModuleFilenameHelpers.createFilename(
+ module,
+ {
+ moduleFilenameTemplate: this.moduleFilenameTemplate,
+ namespace: this.namespace
+ },
+ {
+ requestShortener: runtimeTemplate.requestShortener,
+ chunkGraph,
+ hashFunction: compilation.outputOptions.hashFunction
+ }
+ );
+ const footer =
+ "\n" +
+ this.sourceUrlComment.replace(
+ /\[url\]/g,
+ encodeURI(str)
+ .replace(/%2F/g, "/")
+ .replace(/%20/g, "_")
+ .replace(/%5E/g, "^")
+ .replace(/%5C/g, "\\")
+ .replace(/^\//, "")
+ );
+ const result = new RawSource(
+ `eval(${
+ compilation.outputOptions.trustedTypes
+ ? `${RuntimeGlobals.createScript}(${JSON.stringify(
+ content + footer
+ )})`
+ : JSON.stringify(content + footer)
+ });`
+ );
+ cache.set(source, result);
+ return result;
+ }
+ );
+ hooks.inlineInRuntimeBailout.tap(
+ "EvalDevToolModulePlugin",
+ () => "the eval devtool is used."
+ );
+ hooks.render.tap(
+ "EvalDevToolModulePlugin",
+ source => new ConcatSource(devtoolWarning, source)
+ );
+ hooks.chunkHash.tap("EvalDevToolModulePlugin", (chunk, hash) => {
+ hash.update("EvalDevToolModulePlugin");
+ hash.update("2");
+ });
+ if (compilation.outputOptions.trustedTypes) {
+ compilation.hooks.additionalModuleRuntimeRequirements.tap(
+ "EvalDevToolModulePlugin",
+ (module, set, context) => {
+ set.add(RuntimeGlobals.createScript);
+ }
+ );
+ }
+ });
+ }
+}
+
+module.exports = EvalDevToolModulePlugin;