@rspack/core 0.7.0-canary-7e3a2e5-20240529004417 → 0.7.0-canary-db5d248-20240530004121

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.
@@ -27,6 +27,11 @@
27
27
  },
28
28
  "layer": {
29
29
  "type": "string"
30
+ },
31
+ "defaultExport": {
32
+ "type": "boolean",
33
+ "description": "Duplicate the named export with CSS modules locals to the default export (only when `esModules: true` for css-loader).",
34
+ "link": "https://github.com/webpack-contrib/mini-css-extract-plugin#defaultexports"
30
35
  }
31
36
  }
32
37
  }
@@ -9,6 +9,7 @@ export interface CssExtractRspackLoaderOptions {
9
9
  emit?: boolean;
10
10
  esModule?: boolean;
11
11
  layer?: boolean;
12
+ defaultExport?: boolean;
12
13
  }
13
14
  declare const loader: LoaderDefinition;
14
15
  export declare const pitch: LoaderDefinition["pitch"];
@@ -133,16 +133,39 @@ const pitch = function (request, _, data) {
133
133
  callback(e);
134
134
  return;
135
135
  }
136
- const result = locals
137
- ? namedExport
138
- ? Object.keys(locals)
139
- .map(key => `\nexport var ${key} = ${(0, utils_1.stringifyLocal)(
140
- /** @type {Locals} */ locals[key])};`)
141
- .join("")
142
- : `\n${esModule ? "export default" : "module.exports ="} ${JSON.stringify(locals)};`
143
- : esModule
144
- ? `\nexport {};`
145
- : "";
136
+ const result = (function makeResult() {
137
+ if (locals) {
138
+ if (namedExport) {
139
+ const identifiers = Array.from((function* generateIdentifiers() {
140
+ let identifierId = 0;
141
+ for (const key of Object.keys(locals)) {
142
+ identifierId += 1;
143
+ yield [`_${identifierId.toString(16)}`, key];
144
+ }
145
+ })());
146
+ const localsString = identifiers
147
+ .map(([id, key]) => `\nvar ${id} = ${(0, utils_1.stringifyLocal)(
148
+ /** @type {Locals} */ locals[key])};`)
149
+ .join("");
150
+ const exportsString = `export { ${identifiers
151
+ .map(([id, key]) => `${id} as ${JSON.stringify(key)}`)
152
+ .join(", ")} }`;
153
+ const defaultExport = typeof options.defaultExport !== "undefined"
154
+ ? options.defaultExport
155
+ : false;
156
+ return defaultExport
157
+ ? `${localsString}\n${exportsString}\nexport default { ${identifiers
158
+ .map(([id, key]) => `${JSON.stringify(key)}: ${id}`)
159
+ .join(", ")} }\n`
160
+ : `${localsString}\n${exportsString}\n`;
161
+ }
162
+ return `\n${esModule ? "export default" : "module.exports = "} ${JSON.stringify(locals)};`;
163
+ }
164
+ else if (esModule) {
165
+ return "\nexport {};";
166
+ }
167
+ return "";
168
+ })();
146
169
  let resultSource = `// extracted by ${index_1.CssExtractRspackPlugin.pluginName}`;
147
170
  // only attempt hotreloading if the css is actually used for something other than hash values
148
171
  resultSource +=
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rspack/core",
3
- "version": "0.7.0-canary-7e3a2e5-20240529004417",
3
+ "version": "0.7.0-canary-db5d248-20240530004121",
4
4
  "webpackVersion": "5.75.0",
5
5
  "license": "MIT",
6
6
  "description": "A Fast Rust-based Web Bundler",
@@ -72,15 +72,15 @@
72
72
  "watchpack": "^2.4.0",
73
73
  "zod": "^3.21.4",
74
74
  "zod-validation-error": "1.3.1",
75
- "@rspack/core": "0.7.0-canary-7e3a2e5-20240529004417",
76
- "@rspack/plugin-minify": "^0.7.0-canary-7e3a2e5-20240529004417"
75
+ "@rspack/core": "0.7.0-canary-db5d248-20240530004121",
76
+ "@rspack/plugin-minify": "^0.7.0-canary-db5d248-20240530004121"
77
77
  },
78
78
  "dependencies": {
79
79
  "@module-federation/runtime-tools": "0.1.6",
80
80
  "caniuse-lite": "^1.0.30001616",
81
81
  "tapable": "2.2.1",
82
82
  "webpack-sources": "3.2.3",
83
- "@rspack/binding": "0.7.0-canary-7e3a2e5-20240529004417"
83
+ "@rspack/binding": "0.7.0-canary-db5d248-20240530004121"
84
84
  },
85
85
  "peerDependencies": {
86
86
  "@swc/helpers": ">=0.5.1"