@rspack/core 0.5.9-canary-73d1234-20240407005733 → 0.5.9-canary-ba4ea23-20240407091611

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -13,10 +13,10 @@ class ExecuteModulePlugin {
13
13
  const moduleObject = options.moduleObject;
14
14
  const source = options.codeGenerationResult.get("javascript");
15
15
  try {
16
- const fn = node_vm_1.default.runInThisContext(`(function(module, __webpack_exports__, ${_1.RuntimeGlobals.require}) {\n${source}\n})`, {
16
+ const fn = node_vm_1.default.runInThisContext(`(function(module, __webpack_module__, __webpack_exports__, exports, ${_1.RuntimeGlobals.require}) {\n${source}\n})`, {
17
17
  filename: moduleObject.id
18
18
  });
19
- fn.call(moduleObject.exports, moduleObject, moduleObject.exports, context.__webpack_require__);
19
+ fn.call(moduleObject.exports, moduleObject, moduleObject, moduleObject.exports, moduleObject.exports, context.__webpack_require__);
20
20
  }
21
21
  catch (e) {
22
22
  let err = e instanceof Error ? e : new Error(e);
package/dist/Module.d.ts CHANGED
@@ -21,6 +21,7 @@ export type ResolveData = {
21
21
  export declare class Module {
22
22
  #private;
23
23
  _originalSource?: Source;
24
+ rawRequest?: string;
24
25
  static __from_binding(module: JsModule): Module;
25
26
  constructor(module: JsModule);
26
27
  get context(): string | undefined;
package/dist/Module.js CHANGED
@@ -21,6 +21,7 @@ class Module {
21
21
  constructor(module) {
22
22
  _Module_inner.set(this, void 0);
23
23
  __classPrivateFieldSet(this, _Module_inner, module, "f");
24
+ this.rawRequest = module.rawRequest;
24
25
  }
25
26
  get context() {
26
27
  return __classPrivateFieldGet(this, _Module_inner, "f").context;
@@ -65,10 +65,11 @@ function toRawSplitChunksOptions(sc, compiler) {
65
65
  return chunks;
66
66
  }
67
67
  }
68
- const { name, chunks, cacheGroups = {}, fallbackCacheGroup, ...passThrough } = sc;
68
+ const { name, chunks, defaultSizeTypes, cacheGroups = {}, fallbackCacheGroup, ...passThrough } = sc;
69
69
  return {
70
70
  name: getName(name),
71
71
  chunks: getChunks(chunks),
72
+ defaultSizeTypes: defaultSizeTypes || ["javascript", "unknown"],
72
73
  cacheGroups: Object.entries(cacheGroups)
73
74
  .filter(([_key, group]) => group !== false)
74
75
  .map(([key, group]) => {
@@ -0,0 +1,3 @@
1
+ declare function _exports(moduleId: TODO, options: TODO): TODO;
2
+ export = _exports;
3
+ export type TODO = any;
@@ -0,0 +1,222 @@
1
+ "use strict";
2
+ /* eslint-env browser */
3
+ /*
4
+ eslint-disable
5
+ no-console,
6
+ func-names
7
+ */
8
+ /** @typedef {any} TODO */
9
+ const normalizeUrl = require("./normalize-url");
10
+ const srcByModuleId = Object.create(null);
11
+ const noDocument = typeof document === "undefined";
12
+ const { forEach } = Array.prototype;
13
+ /**
14
+ * @param {function} fn
15
+ * @param {number} time
16
+ * @returns {(function(): void)|*}
17
+ */
18
+ function debounce(fn, time) {
19
+ let timeout = 0;
20
+ return function () {
21
+ // @ts-ignore
22
+ const self = this;
23
+ // eslint-disable-next-line prefer-rest-params
24
+ const args = arguments;
25
+ const functionCall = function functionCall() {
26
+ return fn.apply(self, args);
27
+ };
28
+ clearTimeout(timeout);
29
+ // @ts-ignore
30
+ timeout = setTimeout(functionCall, time);
31
+ };
32
+ }
33
+ function noop() { }
34
+ /**
35
+ * @param {TODO} moduleId
36
+ * @returns {TODO}
37
+ */
38
+ function getCurrentScriptUrl(moduleId) {
39
+ let src = srcByModuleId[moduleId];
40
+ if (!src) {
41
+ if (document.currentScript) {
42
+ ({ src } = /** @type {HTMLScriptElement} */ (document.currentScript));
43
+ }
44
+ else {
45
+ const scripts = document.getElementsByTagName("script");
46
+ const lastScriptTag = scripts[scripts.length - 1];
47
+ if (lastScriptTag) {
48
+ ({ src } = lastScriptTag);
49
+ }
50
+ }
51
+ srcByModuleId[moduleId] = src;
52
+ }
53
+ /**
54
+ * @param {string} fileMap
55
+ * @returns {null | string[]}
56
+ */
57
+ return function (fileMap) {
58
+ if (!src) {
59
+ return null;
60
+ }
61
+ const splitResult = src.split(/([^\\/]+)\.js$/);
62
+ const filename = splitResult && splitResult[1];
63
+ if (!filename) {
64
+ return [src.replace(".js", ".css")];
65
+ }
66
+ if (!fileMap) {
67
+ return [src.replace(".js", ".css")];
68
+ }
69
+ return fileMap.split(",").map(mapRule => {
70
+ const reg = new RegExp(`${filename}\\.js$`, "g");
71
+ return normalizeUrl(src.replace(reg, `${mapRule.replace(/{fileName}/g, filename)}.css`));
72
+ });
73
+ };
74
+ }
75
+ /**
76
+ * @param {TODO} el
77
+ * @param {string} [url]
78
+ */
79
+ function updateCss(el, url) {
80
+ if (!url) {
81
+ if (!el.href) {
82
+ return;
83
+ }
84
+ // eslint-disable-next-line
85
+ url = el.href.split("?")[0];
86
+ }
87
+ if (!isUrlRequest(/** @type {string} */ (url))) {
88
+ return;
89
+ }
90
+ if (el.isLoaded === false) {
91
+ // We seem to be about to replace a css link that hasn't loaded yet.
92
+ // We're probably changing the same file more than once.
93
+ return;
94
+ }
95
+ if (!url || !(url.indexOf(".css") > -1)) {
96
+ return;
97
+ }
98
+ // eslint-disable-next-line no-param-reassign
99
+ el.visited = true;
100
+ const newEl = el.cloneNode();
101
+ newEl.isLoaded = false;
102
+ newEl.addEventListener("load", () => {
103
+ if (newEl.isLoaded) {
104
+ return;
105
+ }
106
+ newEl.isLoaded = true;
107
+ el.parentNode.removeChild(el);
108
+ });
109
+ newEl.addEventListener("error", () => {
110
+ if (newEl.isLoaded) {
111
+ return;
112
+ }
113
+ newEl.isLoaded = true;
114
+ el.parentNode.removeChild(el);
115
+ });
116
+ newEl.href = `${url}?${Date.now()}`;
117
+ if (el.nextSibling) {
118
+ el.parentNode.insertBefore(newEl, el.nextSibling);
119
+ }
120
+ else {
121
+ el.parentNode.appendChild(newEl);
122
+ }
123
+ }
124
+ /**
125
+ * @param {string} href
126
+ * @param {TODO} src
127
+ * @returns {TODO}
128
+ */
129
+ function getReloadUrl(href, src) {
130
+ let ret;
131
+ // eslint-disable-next-line no-param-reassign
132
+ href = normalizeUrl(href);
133
+ src.some(
134
+ /**
135
+ * @param {string} url
136
+ */
137
+ // eslint-disable-next-line array-callback-return
138
+ url => {
139
+ if (href.indexOf(src) > -1) {
140
+ ret = url;
141
+ }
142
+ });
143
+ return ret;
144
+ }
145
+ /**
146
+ * @param {string} [src]
147
+ * @returns {boolean}
148
+ */
149
+ function reloadStyle(src) {
150
+ if (!src) {
151
+ return false;
152
+ }
153
+ const elements = document.querySelectorAll("link");
154
+ let loaded = false;
155
+ forEach.call(elements, el => {
156
+ if (!el.href) {
157
+ return;
158
+ }
159
+ const url = getReloadUrl(el.href, src);
160
+ if (!isUrlRequest(url)) {
161
+ return;
162
+ }
163
+ if (el.visited === true) {
164
+ return;
165
+ }
166
+ if (url) {
167
+ updateCss(el, url);
168
+ loaded = true;
169
+ }
170
+ });
171
+ return loaded;
172
+ }
173
+ function reloadAll() {
174
+ const elements = document.querySelectorAll("link");
175
+ forEach.call(elements, el => {
176
+ if (el.visited === true) {
177
+ return;
178
+ }
179
+ updateCss(el);
180
+ });
181
+ }
182
+ /**
183
+ * @param {string} url
184
+ * @returns {boolean}
185
+ */
186
+ function isUrlRequest(url) {
187
+ // An URL is not an request if
188
+ // It is not http or https
189
+ if (!/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(url)) {
190
+ return false;
191
+ }
192
+ return true;
193
+ }
194
+ /**
195
+ * @param {TODO} moduleId
196
+ * @param {TODO} options
197
+ * @returns {TODO}
198
+ */
199
+ module.exports = function (moduleId, options) {
200
+ if (noDocument) {
201
+ console.log("no window.document found, will not HMR CSS");
202
+ return noop;
203
+ }
204
+ const getScriptSrc = getCurrentScriptUrl(moduleId);
205
+ function update() {
206
+ const src = getScriptSrc(options.filename);
207
+ const reloaded = reloadStyle(src);
208
+ if (options.locals) {
209
+ console.log("[HMR] Detected local css modules. Reload all css");
210
+ reloadAll();
211
+ return;
212
+ }
213
+ if (reloaded) {
214
+ console.log("[HMR] css reload %s", src.join(" "));
215
+ }
216
+ else {
217
+ console.log("[HMR] Reload all css");
218
+ reloadAll();
219
+ }
220
+ }
221
+ return debounce(update, 50);
222
+ };
@@ -0,0 +1,2 @@
1
+ declare function _exports(urlString: string): string;
2
+ export = _exports;
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ /* eslint-disable */
3
+ /**
4
+ * @param {string[]} pathComponents
5
+ * @returns {string}
6
+ */
7
+ function normalizeUrl(pathComponents) {
8
+ return pathComponents
9
+ .reduce(function (accumulator, item) {
10
+ switch (item) {
11
+ case "..":
12
+ accumulator.pop();
13
+ break;
14
+ case ".":
15
+ break;
16
+ default:
17
+ accumulator.push(item);
18
+ }
19
+ return accumulator;
20
+ }, /** @type {string[]} */ ([]))
21
+ .join("/");
22
+ }
23
+ /**
24
+ * @param {string} urlString
25
+ * @returns {string}
26
+ */
27
+ module.exports = function (urlString) {
28
+ urlString = urlString.trim();
29
+ if (/^data:/i.test(urlString)) {
30
+ return urlString;
31
+ }
32
+ var protocol = urlString.indexOf("//") !== -1 ? urlString.split("//")[0] + "//" : "";
33
+ var components = urlString.replace(new RegExp(protocol, "i"), "").split("/");
34
+ var host = components[0].toLowerCase().replace(/\.$/, "");
35
+ components[0] = "";
36
+ var path = normalizeUrl(components);
37
+ return protocol + host + path;
38
+ };
@@ -0,0 +1,22 @@
1
+ import type { RawCssExtractPluginOption } from "@rspack/binding";
2
+ import { Compiler } from "../..";
3
+ export * from "./loader";
4
+ export interface PluginOptions {
5
+ filename?: string;
6
+ chunkFilename?: string;
7
+ ignoreOrder?: boolean;
8
+ insert?: string | ((linkTag: HTMLLinkElement) => void);
9
+ attributes?: Record<string, string>;
10
+ linkType?: string | "text/css" | false;
11
+ runtime?: boolean;
12
+ pathinfo?: boolean;
13
+ }
14
+ export declare class CssExtractRspackPlugin {
15
+ static pluginName: string;
16
+ static loader: string;
17
+ options: PluginOptions;
18
+ constructor(options?: PluginOptions);
19
+ apply(compiler: Compiler): void;
20
+ normalizeOptions(options: PluginOptions): RawCssExtractPluginOption;
21
+ }
22
+ export default CssExtractRspackPlugin;
@@ -0,0 +1,109 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.CssExtractRspackPlugin = void 0;
18
+ const loader_1 = require("./loader");
19
+ __exportStar(require("./loader"), exports);
20
+ const DEFAULT_FILENAME = "[name].css";
21
+ const LOADER_PATH = require.resolve("./loader");
22
+ class CssExtractRspackPlugin {
23
+ constructor(options) {
24
+ this.options = options || {};
25
+ }
26
+ apply(compiler) {
27
+ const { splitChunks } = compiler.options.optimization;
28
+ if (splitChunks) {
29
+ if (
30
+ /** @type {string[]} */ splitChunks.defaultSizeTypes.includes("...")) {
31
+ /** @type {string[]} */
32
+ splitChunks.defaultSizeTypes.push(loader_1.MODULE_TYPE);
33
+ }
34
+ }
35
+ if (
36
+ // @ts-expect-error rspack don't support pathinfo for now
37
+ compiler.options.output.pathinfo &&
38
+ this.options.pathinfo === undefined) {
39
+ this.options.pathinfo = true;
40
+ }
41
+ compiler.__internal__registerBuiltinPlugin({
42
+ // @ts-expect-error CssExtractPlugin is a constant value of BuiltinPlugin
43
+ name: "CssExtractPlugin",
44
+ options: this.normalizeOptions(this.options)
45
+ });
46
+ }
47
+ normalizeOptions(options) {
48
+ var _a, _b, _c;
49
+ let chunkFilename = options.chunkFilename;
50
+ if (!chunkFilename) {
51
+ const filename = options.filename || DEFAULT_FILENAME;
52
+ if (typeof filename !== "function") {
53
+ const hasName = /** @type {string} */ filename.includes("[name]");
54
+ const hasId = /** @type {string} */ filename.includes("[id]");
55
+ const hasChunkHash =
56
+ /** @type {string} */
57
+ filename.includes("[chunkhash]");
58
+ const hasContentHash =
59
+ /** @type {string} */
60
+ filename.includes("[contenthash]");
61
+ // Anything changing depending on chunk is fine
62
+ if (hasChunkHash || hasContentHash || hasName || hasId) {
63
+ chunkFilename = filename;
64
+ }
65
+ else {
66
+ // Otherwise prefix "[id]." in front of the basename to make it changing
67
+ chunkFilename =
68
+ /** @type {string} */
69
+ filename.replace(/(^|\/)([^/]*(?:\?|$))/, "$1[id].$2");
70
+ }
71
+ }
72
+ else {
73
+ chunkFilename = "[id].css";
74
+ }
75
+ }
76
+ const normalzedOptions = {
77
+ filename: options.filename || DEFAULT_FILENAME,
78
+ chunkFilename: chunkFilename,
79
+ ignoreOrder: (_a = options.ignoreOrder) !== null && _a !== void 0 ? _a : false,
80
+ runtime: (_b = options.runtime) !== null && _b !== void 0 ? _b : true,
81
+ insert: typeof options.insert === "function"
82
+ ? options.insert.toString()
83
+ : JSON.stringify(options.insert),
84
+ linkType: typeof options.linkType === "undefined"
85
+ ? JSON.stringify("text/css")
86
+ : options.linkType === false
87
+ ? undefined
88
+ : JSON.stringify(options.linkType),
89
+ attributes: options.attributes
90
+ ? Reflect.ownKeys(options.attributes)
91
+ .map(k => [
92
+ JSON.stringify(k),
93
+ JSON.stringify(options.attributes[k])
94
+ ])
95
+ .reduce((obj, [k, v]) => {
96
+ // @ts-expect-error
97
+ obj[k] = v;
98
+ return obj;
99
+ }, {})
100
+ : {},
101
+ pathinfo: (_c = options.pathinfo) !== null && _c !== void 0 ? _c : false
102
+ };
103
+ return normalzedOptions;
104
+ }
105
+ }
106
+ CssExtractRspackPlugin.pluginName = "css-extract-rspack-plugin";
107
+ CssExtractRspackPlugin.loader = LOADER_PATH;
108
+ exports.CssExtractRspackPlugin = CssExtractRspackPlugin;
109
+ exports.default = CssExtractRspackPlugin;
@@ -0,0 +1,32 @@
1
+ {
2
+ "title": "Mini CSS Extract Plugin Loader options",
3
+ "type": "object",
4
+ "additionalProperties": false,
5
+ "properties": {
6
+ "publicPath": {
7
+ "anyOf": [
8
+ {
9
+ "type": "string"
10
+ },
11
+ {
12
+ "instanceof": "Function"
13
+ }
14
+ ],
15
+ "description": "Specifies a custom public path for the external resources like images, files, etc inside CSS.",
16
+ "link": "https://github.com/webpack-contrib/mini-css-extract-plugin#publicpath"
17
+ },
18
+ "emit": {
19
+ "type": "boolean",
20
+ "description": "If true, emits a file (writes a file to the filesystem). If false, the plugin will extract the CSS but will not emit the file",
21
+ "link": "https://github.com/webpack-contrib/mini-css-extract-plugin#emit"
22
+ },
23
+ "esModule": {
24
+ "type": "boolean",
25
+ "description": "Generates JS modules that use the ES modules syntax.",
26
+ "link": "https://github.com/webpack-contrib/mini-css-extract-plugin#esmodule"
27
+ },
28
+ "layer": {
29
+ "type": "string"
30
+ }
31
+ }
32
+ }
@@ -0,0 +1,15 @@
1
+ import type { LoaderDefinition } from "../..";
2
+ export declare const MODULE_TYPE = "css/mini-extract";
3
+ export declare const AUTO_PUBLIC_PATH = "__mini_css_extract_plugin_public_path_auto__";
4
+ export declare const ABSOLUTE_PUBLIC_PATH = "webpack:///mini-css-extract-plugin/";
5
+ export declare const BASE_URI = "webpack://";
6
+ export declare const SINGLE_DOT_PATH_SEGMENT = "__mini_css_extract_plugin_single_dot_path_segment__";
7
+ export interface LoaderOptions {
8
+ publicPath?: string | ((resourcePath: string, context: string) => string);
9
+ emit?: boolean;
10
+ esModule?: boolean;
11
+ layer?: boolean;
12
+ }
13
+ declare const loader: LoaderDefinition;
14
+ export declare const pitch: LoaderDefinition["pitch"];
15
+ export default loader;
@@ -0,0 +1,180 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.pitch = exports.SINGLE_DOT_PATH_SEGMENT = exports.BASE_URI = exports.ABSOLUTE_PUBLIC_PATH = exports.AUTO_PUBLIC_PATH = exports.MODULE_TYPE = void 0;
7
+ const loader_options_json_1 = __importDefault(require("./loader-options.json"));
8
+ const index_1 = require("./index");
9
+ const path_1 = __importDefault(require("path"));
10
+ const utils_1 = require("./utils");
11
+ exports.MODULE_TYPE = "css/mini-extract";
12
+ exports.AUTO_PUBLIC_PATH = "__mini_css_extract_plugin_public_path_auto__";
13
+ exports.ABSOLUTE_PUBLIC_PATH = "webpack:///mini-css-extract-plugin/";
14
+ exports.BASE_URI = "webpack://";
15
+ exports.SINGLE_DOT_PATH_SEGMENT = "__mini_css_extract_plugin_single_dot_path_segment__";
16
+ const SERIALIZE_SEP = "__RSPACK_CSS_EXTRACT_SEP__";
17
+ function hotLoader(content, context) {
18
+ const accept = context.locals
19
+ ? ""
20
+ : "module.hot.accept(undefined, cssReload);";
21
+ return `${content}
22
+ if(module.hot) {
23
+ // ${Date.now()}
24
+ var cssReload = require(${(0, utils_1.stringifyRequest)(context.loaderContext, path_1.default.join(__dirname, "./hmr/hotModuleReplacement.js"))})(module.id, ${JSON.stringify({
25
+ ...context.options,
26
+ locals: !!context.locals
27
+ })});
28
+ module.hot.dispose(cssReload);
29
+ ${accept}
30
+ }
31
+ `;
32
+ }
33
+ // mini-css-extract-plugin
34
+ const loader = function loader(content) {
35
+ if (this._compiler &&
36
+ this._compiler.options &&
37
+ this._compiler.options.experiments &&
38
+ this._compiler.options.experiments.css) {
39
+ return content;
40
+ }
41
+ };
42
+ const pitch = function (request, _, data) {
43
+ if (this._compiler &&
44
+ this._compiler.options &&
45
+ this._compiler.options.experiments &&
46
+ this._compiler.options.experiments.css) {
47
+ this.emitWarning(new Error("You can't use `experiments.css` and `mini-css-extract-plugin` together, please set `experiments.css` to `false`"));
48
+ return;
49
+ }
50
+ const options = this.getOptions(loader_options_json_1.default);
51
+ const emit = typeof options.emit !== "undefined" ? options.emit : true;
52
+ const callback = this.async();
53
+ const filepath = this.resourcePath;
54
+ let { publicPath } =
55
+ /** @type {Compilation} */
56
+ this._compilation.outputOptions;
57
+ if (typeof options.publicPath === "string") {
58
+ // eslint-disable-next-line prefer-destructuring
59
+ publicPath = options.publicPath;
60
+ }
61
+ else if (typeof options.publicPath === "function") {
62
+ publicPath = options.publicPath(this.resourcePath, this.rootContext);
63
+ }
64
+ if (publicPath === "auto") {
65
+ publicPath = exports.AUTO_PUBLIC_PATH;
66
+ }
67
+ let publicPathForExtract;
68
+ if (typeof publicPath === "string") {
69
+ const isAbsolutePublicPath = /^[a-zA-Z][a-zA-Z\d+\-.]*?:/.test(publicPath);
70
+ publicPathForExtract = isAbsolutePublicPath
71
+ ? publicPath
72
+ : `${exports.ABSOLUTE_PUBLIC_PATH}${publicPath.replace(/\./g, exports.SINGLE_DOT_PATH_SEGMENT)}`;
73
+ }
74
+ else {
75
+ publicPathForExtract = publicPath;
76
+ }
77
+ const handleExports = (originalExports) => {
78
+ /** @type {Locals | undefined} */
79
+ let locals;
80
+ let namedExport;
81
+ const esModule = typeof options.esModule !== "undefined" ? options.esModule : true;
82
+ let dependencies = [];
83
+ try {
84
+ // eslint-disable-next-line no-underscore-dangle
85
+ const exports = originalExports.__esModule
86
+ ? originalExports.default
87
+ : originalExports;
88
+ namedExport =
89
+ // eslint-disable-next-line no-underscore-dangle
90
+ originalExports.__esModule &&
91
+ (!originalExports.default || !("locals" in originalExports.default));
92
+ if (namedExport) {
93
+ Object.keys(originalExports).forEach(key => {
94
+ if (key !== "default") {
95
+ if (!locals) {
96
+ locals = {};
97
+ }
98
+ /** @type {Locals} */ locals[key] = originalExports[key];
99
+ }
100
+ });
101
+ }
102
+ else {
103
+ locals = exports && exports.locals;
104
+ }
105
+ if (Array.isArray(exports) && emit) {
106
+ const identifierCountMap = new Map();
107
+ dependencies = exports.map(([id, content, media, sourceMap, supports, layer]) => {
108
+ let identifier = id;
109
+ let context = this.rootContext;
110
+ const count = identifierCountMap.get(identifier) || 0;
111
+ identifierCountMap.set(identifier, count + 1);
112
+ return {
113
+ identifier,
114
+ context,
115
+ content,
116
+ media,
117
+ supports,
118
+ layer,
119
+ identifierIndex: count,
120
+ sourceMap: sourceMap
121
+ ? JSON.stringify(sourceMap)
122
+ : // eslint-disable-next-line no-undefined
123
+ undefined,
124
+ filepath
125
+ };
126
+ });
127
+ }
128
+ }
129
+ catch (e) {
130
+ callback(e);
131
+ return;
132
+ }
133
+ const result = locals
134
+ ? namedExport
135
+ ? Object.keys(locals)
136
+ .map(key => `\nexport var ${key} = ${(0, utils_1.stringifyLocal)(
137
+ /** @type {Locals} */ locals[key])};`)
138
+ .join("")
139
+ : `\n${esModule ? "export default" : "module.exports ="} ${JSON.stringify(locals)};`
140
+ : esModule
141
+ ? `\nexport {};`
142
+ : "";
143
+ let resultSource = `// extracted by ${index_1.CssExtractRspackPlugin.pluginName}`;
144
+ // only attempt hotreloading if the css is actually used for something other than hash values
145
+ resultSource +=
146
+ this.hot && emit
147
+ ? hotLoader(result, { loaderContext: this, options, locals: locals })
148
+ : result;
149
+ const additionalData = { ...data };
150
+ if (dependencies.length > 0) {
151
+ additionalData[index_1.CssExtractRspackPlugin.pluginName] = dependencies
152
+ .map(dep => {
153
+ return [
154
+ dep.identifier,
155
+ dep.content,
156
+ dep.context,
157
+ dep.media,
158
+ dep.supports,
159
+ dep.sourceMap,
160
+ dep.identifierIndex,
161
+ dep.filepath
162
+ ].join(SERIALIZE_SEP);
163
+ })
164
+ .join(SERIALIZE_SEP);
165
+ }
166
+ callback(null, resultSource, undefined, additionalData);
167
+ };
168
+ this.importModule(`${this.resourcePath}.webpack[javascript/auto]!=!!!${request}`, {
169
+ publicPath: /** @type {string} */ publicPathForExtract,
170
+ baseUri: `${exports.BASE_URI}/`
171
+ }, (error, exports) => {
172
+ if (error) {
173
+ callback(error);
174
+ return;
175
+ }
176
+ handleExports(exports);
177
+ });
178
+ };
179
+ exports.pitch = pitch;
180
+ exports.default = loader;