@rspack/core 1.3.5 → 1.3.6

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.
@@ -1,107 +1,59 @@
1
1
  "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
2
+ var __webpack_require__ = {};
3
+ __webpack_require__.n = (module)=>{
4
+ var getter = module && module.__esModule ? ()=>module.default : ()=>module;
5
+ return __webpack_require__.d(getter, {
6
+ a: getter
7
+ }), getter;
8
+ }, __webpack_require__.d = (exports1, definition)=>{
9
+ for(var key in definition)__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key) && Object.defineProperty(exports1, key, {
10
+ enumerable: !0,
11
+ get: definition[key]
12
+ });
13
+ }, __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop), __webpack_require__.r = (exports1)=>{
14
+ 'undefined' != typeof Symbol && Symbol.toStringTag && Object.defineProperty(exports1, Symbol.toStringTag, {
15
+ value: 'Module'
16
+ }), Object.defineProperty(exports1, '__esModule', {
17
+ value: !0
18
+ });
11
19
  };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
-
30
- // src/builtin-plugin/css-extract/loader.ts
31
- var loader_exports = {};
32
- __export(loader_exports, {
33
- ABSOLUTE_PUBLIC_PATH: () => ABSOLUTE_PUBLIC_PATH,
34
- AUTO_PUBLIC_PATH: () => AUTO_PUBLIC_PATH,
35
- BASE_URI: () => BASE_URI,
36
- MODULE_TYPE: () => MODULE_TYPE,
37
- SINGLE_DOT_PATH_SEGMENT: () => SINGLE_DOT_PATH_SEGMENT,
38
- default: () => loader_default,
39
- hotLoader: () => hotLoader,
40
- pitch: () => pitch
20
+ var __webpack_exports__ = {};
21
+ __webpack_require__.r(__webpack_exports__), __webpack_require__.d(__webpack_exports__, {
22
+ hotLoader: ()=>hotLoader,
23
+ MODULE_TYPE: ()=>MODULE_TYPE,
24
+ SINGLE_DOT_PATH_SEGMENT: ()=>SINGLE_DOT_PATH_SEGMENT,
25
+ BASE_URI: ()=>BASE_URI,
26
+ default: ()=>css_extract_loader,
27
+ pitch: ()=>pitch,
28
+ AUTO_PUBLIC_PATH: ()=>AUTO_PUBLIC_PATH,
29
+ ABSOLUTE_PUBLIC_PATH: ()=>ABSOLUTE_PUBLIC_PATH
41
30
  });
42
- module.exports = __toCommonJS(loader_exports);
43
- var import_node_path2 = __toESM(require("path"));
44
-
45
- // src/builtin-plugin/css-extract/utils.ts
46
- var import_node_path = __toESM(require("path"));
31
+ let external_node_path_namespaceObject = require("node:path");
32
+ var external_node_path_default = __webpack_require__.n(external_node_path_namespaceObject);
47
33
  function isAbsolutePath(str) {
48
- return import_node_path.default.posix.isAbsolute(str) || import_node_path.default.win32.isAbsolute(str);
49
- }
50
- var PLUGIN_NAME = "css-extract-rspack-plugin";
51
- var RELATIVE_PATH_REGEXP = /^\.\.?[/\\]/;
52
- function isRelativePath(str) {
53
- return RELATIVE_PATH_REGEXP.test(str);
54
- }
55
- function stringifyRequest(loaderContext, request) {
56
- if (typeof loaderContext.utils !== "undefined" && typeof loaderContext.utils.contextify === "function") {
57
- return JSON.stringify(
58
- loaderContext.utils.contextify(
59
- loaderContext.context || loaderContext.rootContext,
60
- request
61
- )
62
- );
63
- }
64
- const splitted = request.split("!");
65
- const { context } = loaderContext;
66
- return JSON.stringify(
67
- splitted.map((part) => {
68
- const splittedPart = part.match(/^(.*?)(\?.*)/);
69
- const query = splittedPart ? splittedPart[2] : "";
70
- let singlePath = splittedPart ? splittedPart[1] : part;
71
- if (isAbsolutePath(singlePath) && context) {
72
- singlePath = import_node_path.default.relative(context, singlePath);
73
- if (isAbsolutePath(singlePath)) {
74
- return singlePath + query;
75
- }
76
- if (!isRelativePath(singlePath)) {
77
- singlePath = `./${singlePath}`;
78
- }
79
- }
80
- return singlePath.replace(/\\/g, "/") + query;
81
- }).join("!")
82
- );
83
- }
84
- function stringifyLocal(value) {
85
- return typeof value === "function" ? value.toString() : JSON.stringify(value);
34
+ return external_node_path_default().posix.isAbsolute(str) || external_node_path_default().win32.isAbsolute(str);
86
35
  }
87
-
88
- // src/builtin-plugin/css-extract/loader.ts
89
- var BASE_URI = "webpack://";
90
- var MODULE_TYPE = "css/mini-extract";
91
- var AUTO_PUBLIC_PATH = "__mini_css_extract_plugin_public_path_auto__";
92
- var ABSOLUTE_PUBLIC_PATH = `${BASE_URI}/mini-css-extract-plugin/`;
93
- var SINGLE_DOT_PATH_SEGMENT = "__mini_css_extract_plugin_single_dot_path_segment__";
36
+ let PLUGIN_NAME = "css-extract-rspack-plugin", RELATIVE_PATH_REGEXP = /^\.\.?[/\\]/, BASE_URI = "webpack://", MODULE_TYPE = "css/mini-extract", AUTO_PUBLIC_PATH = "__mini_css_extract_plugin_public_path_auto__", ABSOLUTE_PUBLIC_PATH = `${BASE_URI}/mini-css-extract-plugin/`, SINGLE_DOT_PATH_SEGMENT = "__mini_css_extract_plugin_single_dot_path_segment__";
94
37
  function hotLoader(content, context) {
95
- const localsJsonString = JSON.stringify(JSON.stringify(context.locals));
96
- return `${content}
38
+ let localsJsonString = JSON.stringify(JSON.stringify(context.locals));
39
+ return `${content}
97
40
  if(module.hot) {
98
41
  (function() {
99
42
  var localsJsonString = ${localsJsonString};
100
43
  // ${Date.now()}
101
- var cssReload = require(${stringifyRequest(
102
- context.loaderContext,
103
- import_node_path2.default.join(__dirname, "cssExtractHmr.js")
104
- )}).cssReload(module.id, ${JSON.stringify(context.options ?? {})});
44
+ var cssReload = require(${function(loaderContext, request) {
45
+ if (void 0 !== loaderContext.utils && "function" == typeof loaderContext.utils.contextify) return JSON.stringify(loaderContext.utils.contextify(loaderContext.context || loaderContext.rootContext, request));
46
+ let splitted = request.split("!"), { context } = loaderContext;
47
+ return JSON.stringify(splitted.map((part)=>{
48
+ let splittedPart = part.match(/^(.*?)(\?.*)/), query = splittedPart ? splittedPart[2] : "", singlePath = splittedPart ? splittedPart[1] : part;
49
+ if (isAbsolutePath(singlePath) && context) {
50
+ var str;
51
+ if (isAbsolutePath(singlePath = external_node_path_default().relative(context, singlePath))) return singlePath + query;
52
+ str = singlePath, RELATIVE_PATH_REGEXP.test(str) || (singlePath = `./${singlePath}`);
53
+ }
54
+ return singlePath.replace(/\\/g, "/") + query;
55
+ }).join("!"));
56
+ }(context.loaderContext, external_node_path_default().join(__dirname, "cssExtractHmr.js"))}).cssReload(module.id, ${JSON.stringify(context.options ?? {})});
105
57
  // only invalidate when locals change
106
58
  if (
107
59
  module.hot.data &&
@@ -120,159 +72,90 @@ function hotLoader(content, context) {
120
72
  }
121
73
  `;
122
74
  }
123
- var loader = function loader2(content) {
124
- var _a, _b, _c;
125
- if (((_c = (_b = (_a = this._compiler) == null ? void 0 : _a.options) == null ? void 0 : _b.experiments) == null ? void 0 : _c.css) && this._module && (this._module.type === "css" || this._module.type === "css/auto" || this._module.type === "css/global" || this._module.type === "css/module")) {
126
- return content;
127
- }
128
- };
129
- var pitch = function(request, _, data) {
130
- var _a, _b, _c;
131
- if (((_c = (_b = (_a = this._compiler) == null ? void 0 : _a.options) == null ? void 0 : _b.experiments) == null ? void 0 : _c.css) && this._module && (this._module.type === "css" || this._module.type === "css/auto" || this._module.type === "css/global" || this._module.type === "css/module")) {
132
- const e = new Error(
133
- `use type 'css' and \`CssExtractRspackPlugin\` together, please set \`experiments.css\` to \`false\` or set \`{ type: "javascript/auto" }\` for rules with \`CssExtractRspackPlugin\` in your rspack config (now \`CssExtractRspackPlugin\` does nothing).`
134
- );
135
- e.stack = void 0;
136
- this.emitWarning(e);
137
- return;
138
- }
139
- const options = this.getOptions();
140
- const emit = typeof options.emit !== "undefined" ? options.emit : true;
141
- const callback = this.async();
142
- const filepath = this.resourcePath;
143
- const parseMeta = this.__internal__parseMeta;
144
- this.addDependency(filepath);
145
- let { publicPath } = this._compilation.outputOptions;
146
- if (typeof options.publicPath === "string") {
147
- publicPath = options.publicPath;
148
- } else if (typeof options.publicPath === "function") {
149
- publicPath = options.publicPath(this.resourcePath, this.rootContext);
150
- }
151
- if (publicPath === "auto") {
152
- publicPath = AUTO_PUBLIC_PATH;
153
- }
154
- let publicPathForExtract;
155
- if (typeof publicPath === "string") {
156
- const isAbsolutePublicPath = /^[a-zA-Z][a-zA-Z\d+\-.]*?:/.test(publicPath);
157
- publicPathForExtract = isAbsolutePublicPath ? publicPath : `${ABSOLUTE_PUBLIC_PATH}${publicPath.replace(
158
- /\./g,
159
- SINGLE_DOT_PATH_SEGMENT
160
- )}`;
161
- } else {
162
- publicPathForExtract = publicPath;
163
- }
164
- const handleExports = (originalExports) => {
165
- let locals;
166
- let namedExport;
167
- const esModule = typeof options.esModule !== "undefined" ? options.esModule : true;
168
- let dependencies = [];
169
- try {
170
- const exports2 = originalExports.__esModule ? originalExports.default : originalExports;
171
- namedExport = // eslint-disable-next-line no-underscore-dangle
172
- originalExports.__esModule && (!originalExports.default || !("locals" in originalExports.default));
173
- if (namedExport) {
174
- for (const key of Object.keys(originalExports)) {
175
- if (key !== "default") {
176
- if (!locals) {
177
- locals = {};
178
- }
179
- locals[key] = originalExports[key];
180
- }
181
- }
182
- } else {
183
- locals = exports2 == null ? void 0 : exports2.locals;
184
- }
185
- if (Array.isArray(exports2) && emit) {
186
- const identifierCountMap = /* @__PURE__ */ new Map();
187
- dependencies = exports2.map(([id, content, media, sourceMap, supports, layer]) => {
188
- const identifier = id;
189
- const context = this.rootContext;
190
- const count = identifierCountMap.get(identifier) || 0;
191
- identifierCountMap.set(identifier, count + 1);
192
- return {
193
- identifier,
194
- context,
195
- content,
196
- media,
197
- supports,
198
- layer,
199
- identifierIndex: count,
200
- sourceMap: sourceMap ? JSON.stringify(sourceMap) : (
201
- // eslint-disable-next-line no-undefined
202
- void 0
203
- ),
204
- filepath
205
- };
206
- }).filter((item) => item !== null);
207
- }
208
- } catch (e) {
209
- callback(e);
210
- return;
211
- }
212
- const result = function makeResult() {
213
- if (locals) {
214
- if (namedExport) {
215
- const identifiers = Array.from(
216
- function* generateIdentifiers() {
217
- let identifierId = 0;
218
- for (const key of Object.keys(locals)) {
219
- identifierId += 1;
220
- yield [`_${identifierId.toString(16)}`, key];
221
- }
222
- }()
223
- );
224
- const localsString = identifiers.map(
225
- ([id, key]) => `
226
- var ${id} = ${stringifyLocal(locals[key])};`
227
- ).join("");
228
- const exportsString = `export { ${identifiers.map(([id, key]) => `${id} as ${JSON.stringify(key)}`).join(", ")} }`;
229
- const defaultExport = typeof options.defaultExport !== "undefined" ? options.defaultExport : false;
230
- return defaultExport ? `${localsString}
231
- ${exportsString}
232
- export default { ${identifiers.map(([id, key]) => `${JSON.stringify(key)}: ${id}`).join(", ")} }
233
- ` : `${localsString}
234
- ${exportsString}
235
- `;
236
- }
237
- return `
238
- ${esModule ? "export default" : "module.exports = "} ${JSON.stringify(locals)};`;
239
- }
240
- if (esModule) {
241
- return "\nexport {};";
242
- }
243
- return "";
244
- }();
245
- let resultSource = `// extracted by ${PLUGIN_NAME}`;
246
- resultSource += this.hot && emit ? hotLoader(result, { loaderContext: this, options, locals }) : result;
247
- if (dependencies.length > 0) {
248
- parseMeta[PLUGIN_NAME] = JSON.stringify(dependencies);
249
- }
250
- callback(null, resultSource, void 0, data);
251
- };
252
- this.importModule(
253
- `${this.resourcePath}.webpack[javascript/auto]!=!!!${request}`,
254
- {
255
- layer: options.layer,
256
- publicPath: publicPathForExtract,
257
- baseUri: `${BASE_URI}/`
258
- },
259
- (error, exports2) => {
260
- if (error) {
261
- callback(error);
75
+ let pitch = function(request, _, data) {
76
+ let publicPathForExtract;
77
+ if (this._compiler?.options?.experiments?.css && this._module && ("css" === this._module.type || "css/auto" === this._module.type || "css/global" === this._module.type || "css/module" === this._module.type)) {
78
+ let e = Error("use type 'css' and `CssExtractRspackPlugin` together, please set `experiments.css` to `false` or set `{ type: \"javascript/auto\" }` for rules with `CssExtractRspackPlugin` in your rspack config (now `CssExtractRspackPlugin` does nothing).");
79
+ e.stack = void 0, this.emitWarning(e);
262
80
  return;
263
- }
264
- handleExports(exports2);
265
81
  }
266
- );
82
+ let options = this.getOptions(), emit = void 0 === options.emit || options.emit, callback = this.async(), filepath = this.resourcePath, parseMeta = this.__internal__parseMeta;
83
+ this.addDependency(filepath);
84
+ let { publicPath } = this._compilation.outputOptions;
85
+ "string" == typeof options.publicPath ? publicPath = options.publicPath : "function" == typeof options.publicPath && (publicPath = options.publicPath(this.resourcePath, this.rootContext)), "auto" === publicPath && (publicPath = AUTO_PUBLIC_PATH), publicPathForExtract = "string" == typeof publicPath ? /^[a-zA-Z][a-zA-Z\d+\-.]*?:/.test(publicPath) ? publicPath : `${ABSOLUTE_PUBLIC_PATH}${publicPath.replace(/\./g, SINGLE_DOT_PATH_SEGMENT)}` : publicPath;
86
+ let handleExports = (originalExports)=>{
87
+ let locals, namedExport, esModule = void 0 === options.esModule || options.esModule, dependencies = [];
88
+ try {
89
+ let exports1 = originalExports.__esModule ? originalExports.default : originalExports;
90
+ if (namedExport = originalExports.__esModule && (!originalExports.default || !("locals" in originalExports.default))) for (let key of Object.keys(originalExports))"default" !== key && (locals || (locals = {}), locals[key] = originalExports[key]);
91
+ else locals = exports1?.locals;
92
+ if (Array.isArray(exports1) && emit) {
93
+ let identifierCountMap = new Map();
94
+ dependencies = exports1.map(([id, content, media, sourceMap, supports, layer])=>{
95
+ let context = this.rootContext, count = identifierCountMap.get(id) || 0;
96
+ return identifierCountMap.set(id, count + 1), {
97
+ identifier: id,
98
+ context,
99
+ content,
100
+ media,
101
+ supports,
102
+ layer,
103
+ identifierIndex: count,
104
+ sourceMap: sourceMap ? JSON.stringify(sourceMap) : void 0,
105
+ filepath
106
+ };
107
+ }).filter((item)=>null !== item);
108
+ }
109
+ } catch (e) {
110
+ callback(e);
111
+ return;
112
+ }
113
+ let result = function() {
114
+ if (locals) {
115
+ if (namedExport) {
116
+ let identifiers = Array.from(function*() {
117
+ let identifierId = 0;
118
+ for (let key of Object.keys(locals))identifierId += 1, yield [
119
+ `_${identifierId.toString(16)}`,
120
+ key
121
+ ];
122
+ }()), localsString = identifiers.map(([id, key])=>{
123
+ var value;
124
+ return `\nvar ${id} = ${"function" == typeof (value = locals[key]) ? value.toString() : JSON.stringify(value)};`;
125
+ }).join(""), exportsString = `export { ${identifiers.map(([id, key])=>`${id} as ${JSON.stringify(key)}`).join(", ")} }`;
126
+ return void 0 !== options.defaultExport && options.defaultExport ? `${localsString}\n${exportsString}\nexport default { ${identifiers.map(([id, key])=>`${JSON.stringify(key)}: ${id}`).join(", ")} }\n` : `${localsString}\n${exportsString}\n`;
127
+ }
128
+ return `\n${esModule ? "export default" : "module.exports = "} ${JSON.stringify(locals)};`;
129
+ }
130
+ return esModule ? "\nexport {};" : "";
131
+ }(), resultSource = `// extracted by ${PLUGIN_NAME}`;
132
+ resultSource += this.hot && emit ? hotLoader(result, {
133
+ loaderContext: this,
134
+ options,
135
+ locals: locals
136
+ }) : result, dependencies.length > 0 && (parseMeta[PLUGIN_NAME] = JSON.stringify(dependencies)), callback(null, resultSource, void 0, data);
137
+ };
138
+ this.importModule(`${this.resourcePath}.webpack[javascript/auto]!=!!!${request}`, {
139
+ layer: options.layer,
140
+ publicPath: publicPathForExtract,
141
+ baseUri: `${BASE_URI}/`
142
+ }, (error, exports1)=>{
143
+ if (error) return void callback(error);
144
+ handleExports(exports1);
145
+ });
146
+ }, css_extract_loader = function(content) {
147
+ if (this._compiler?.options?.experiments?.css && this._module && ("css" === this._module.type || "css/auto" === this._module.type || "css/global" === this._module.type || "css/module" === this._module.type)) return content;
267
148
  };
268
- var loader_default = loader;
269
- // Annotate the CommonJS export names for ESM import in node:
270
- 0 && (module.exports = {
271
- ABSOLUTE_PUBLIC_PATH,
272
- AUTO_PUBLIC_PATH,
273
- BASE_URI,
274
- MODULE_TYPE,
275
- SINGLE_DOT_PATH_SEGMENT,
276
- hotLoader,
277
- pitch
149
+ for(var __webpack_i__ in exports.ABSOLUTE_PUBLIC_PATH = __webpack_exports__.ABSOLUTE_PUBLIC_PATH, exports.AUTO_PUBLIC_PATH = __webpack_exports__.AUTO_PUBLIC_PATH, exports.BASE_URI = __webpack_exports__.BASE_URI, exports.MODULE_TYPE = __webpack_exports__.MODULE_TYPE, exports.SINGLE_DOT_PATH_SEGMENT = __webpack_exports__.SINGLE_DOT_PATH_SEGMENT, exports.default = __webpack_exports__.default, exports.hotLoader = __webpack_exports__.hotLoader, exports.pitch = __webpack_exports__.pitch, __webpack_exports__)-1 === [
150
+ "ABSOLUTE_PUBLIC_PATH",
151
+ "AUTO_PUBLIC_PATH",
152
+ "BASE_URI",
153
+ "MODULE_TYPE",
154
+ "SINGLE_DOT_PATH_SEGMENT",
155
+ "default",
156
+ "hotLoader",
157
+ "pitch"
158
+ ].indexOf(__webpack_i__) && (exports[__webpack_i__] = __webpack_exports__[__webpack_i__]);
159
+ Object.defineProperty(exports, '__esModule', {
160
+ value: !0
278
161
  });
package/dist/exports.d.ts CHANGED
@@ -170,7 +170,7 @@ export type { LoaderOptions as LightningcssLoaderOptions, FeatureOptions as Ligh
170
170
  export type { SubresourceIntegrityPluginOptions } from "./builtin-plugin";
171
171
  interface Experiments {
172
172
  globalTrace: {
173
- register: (filter: string, layer: "chrome" | "logger" | "otel", output: string) => Promise<void>;
173
+ register: (filter: string, layer: "chrome" | "logger", output: string) => Promise<void>;
174
174
  cleanup: () => Promise<void>;
175
175
  };
176
176
  RemoveDuplicateModulesPlugin: typeof RemoveDuplicateModulesPlugin;