MCPcopy
hub / github.com/webpack/webpack / process

Method process

lib/WebpackOptionsApply.js:99–996  ·  lib/WebpackOptionsApply.js::WebpackOptionsApply.process

* Returns options object. * @param {WebpackOptions} options options object * @param {Compiler} compiler compiler object * @param {WebpackOptionsInterception=} interception intercepted options * @returns {WebpackOptions} options object

(options, compiler, interception)

Source from the content-addressed store, hash-verified

97 * @returns {WebpackOptions} options object
98 */
99 process(options, compiler, interception) {
100 compiler.outputPath = options.output.path;
101 compiler.recordsInputPath = options.recordsInputPath || null;
102 compiler.recordsOutputPath = options.recordsOutputPath || null;
103 compiler.name = options.name;
104
105 if (options.externals) {
106 class="cm">// @ts-expect-error https://github.com/microsoft/TypeScript/issues/41697
107 const ExternalsPlugin = require(class="st">"./ExternalsPlugin");
108
109 new ExternalsPlugin(options.externalsType, options.externals).apply(
110 compiler
111 );
112 }
113
114 if (options.externalsPresets.node) {
115 const NodeTargetPlugin = require(class="st">"./node/NodeTargetPlugin");
116
117 class="cm">// Some older versions of Node.js don't support all built-in modules via import, only via `require`,
118 class="cm">// but it seems like there shouldn't be a warning here since these versions are rarely used in real applications
119 new NodeTargetPlugin(
120 options.output.module ? class="st">"module-import" : class="st">"node-commonjs"
121 ).apply(compiler);
122
123 class="cm">// Handle external CSS `@import` and `url()`
124 if (options.experiments.css) {
125 class="cm">// @ts-expect-error https://github.com/microsoft/TypeScript/issues/41697
126 const ExternalsPlugin = require(class="st">"./ExternalsPlugin");
127
128 new ExternalsPlugin(
129 class="st">"module",
130 ({ request, dependencyType, contextInfo }, callback) => {
131 if (
132 /\.css(?:\?|$)/.test(contextInfo.issuer) &&
133 /^(?:\/\/|https?:\/\/|#)/.test(request)
134 ) {
135 if (dependencyType === class="st">"url") {
136 return callback(null, `asset ${request}`);
137 } else if (
138 (dependencyType === class="st">"css-import" ||
139 dependencyType === class="st">"css-import-local-module" ||
140 dependencyType === class="st">"css-import-global-module") &&
141 options.experiments.css
142 ) {
143 return callback(null, `css-import ${request}`);
144 }
145 }
146
147 callback();
148 }
149 ).apply(compiler);
150 }
151 }
152 if (options.externalsPresets.deno) {
153 const DenoTargetPlugin = require(class="st">"./deno/DenoTargetPlugin");
154
155 new DenoTargetPlugin().apply(compiler);
156 }

Callers

nothing calls this directly

Calls 12

tapMethod · 0.80
isArrayMethod · 0.80
extendMethod · 0.80
cleverMergeFunction · 0.70
applyMethod · 0.65
resolveMethod · 0.65
requireFunction · 0.50
callbackFunction · 0.50
testMethod · 0.45
pushMethod · 0.45
callMethod · 0.45

Tested by

no test coverage detected