@rspack/core 0.6.2 → 0.6.3-canary-e0ce3b5-20240423104040

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.
@@ -6,3 +6,4 @@ export { resolveRelay } from "./relay";
6
6
  export type { RelayOptions } from "./relay";
7
7
  export { resolvePluginImport } from "./pluginImport";
8
8
  export type { PluginImportOptions } from "./pluginImport";
9
+ export type { SwcLoaderOptions, SwcLoaderEnvConfig, SwcLoaderJscConfig, SwcLoaderModuleConfig, SwcLoaderParserConfig, SwcLoaderEsParserConfig, SwcLoaderTsParserConfig, SwcLoaderTransformConfig } from "./types";
@@ -1,4 +1,4 @@
1
- import { RawPluginImportConfig } from "@rspack/binding";
1
+ import type { RawPluginImportConfig } from "@rspack/binding";
2
2
  type PluginImportConfig = {
3
3
  libraryName: string;
4
4
  libraryDirectory?: string;
@@ -8,8 +8,8 @@ type PluginImportConfig = {
8
8
  styleLibraryDirectory?: string;
9
9
  camelToDashComponentName?: boolean;
10
10
  transformToDefaultImport?: boolean;
11
- ignoreEsComponent?: Array<string>;
12
- ignoreStyleComponent?: Array<string>;
11
+ ignoreEsComponent?: string[];
12
+ ignoreStyleComponent?: string[];
13
13
  };
14
14
  type PluginImportOptions = PluginImportConfig[] | undefined;
15
15
  declare function resolvePluginImport(pluginImport: PluginImportOptions): RawPluginImportConfig[] | undefined;
@@ -1,4 +1,4 @@
1
- import { RawReactOptions } from "@rspack/binding";
1
+ import type { RawReactOptions } from "@rspack/binding";
2
2
  declare function resolveReact(react: ReactOptions): RawReactOptions;
3
3
  type ReactOptions = RawReactOptions | undefined;
4
4
  export { resolveReact };
@@ -1,4 +1,4 @@
1
- import { RawRelayConfig } from "@rspack/binding";
1
+ import type { RawRelayConfig } from "@rspack/binding";
2
2
  type RelayOptions = boolean | RawRelayConfig | undefined;
3
3
  declare function resolveRelay(relay: RelayOptions, rootDir: string): RawRelayConfig | undefined;
4
4
  export { resolveRelay };
@@ -0,0 +1,462 @@
1
+ /**
2
+ * Some types are modified from https://github.com/swc-project/swc/blob/16a38851/packages/types/index.ts#L647
3
+ * license at https://github.com/swc-project/swc/blob/main/LICENSE
4
+ */
5
+ import type { ReactOptions } from "./react";
6
+ import type { RelayOptions } from "./relay";
7
+ import type { EmotionOptions } from "./emotion";
8
+ import type { PluginImportOptions } from "./pluginImport";
9
+ export type StyledComponentsOptions = {
10
+ displayName?: boolean;
11
+ ssr?: boolean;
12
+ fileName?: boolean;
13
+ meaninglessFileNames?: string[];
14
+ namespace?: string;
15
+ topLevelImportPaths?: string[];
16
+ transpileTemplateLiterals?: boolean;
17
+ minify?: boolean;
18
+ pure?: boolean;
19
+ cssProps?: boolean;
20
+ };
21
+ export type JscTarget = "es3" | "es5" | "es2015" | "es2016" | "es2017" | "es2018" | "es2019" | "es2020" | "es2021" | "es2022" | "esnext";
22
+ export type SwcLoaderParserConfig = SwcLoaderTsParserConfig | SwcLoaderEsParserConfig;
23
+ export interface SwcLoaderTsParserConfig {
24
+ syntax: "typescript";
25
+ /**
26
+ * Defaults to `false`.
27
+ */
28
+ tsx?: boolean;
29
+ /**
30
+ * Defaults to `false`.
31
+ */
32
+ decorators?: boolean;
33
+ /**
34
+ * Defaults to `false`
35
+ */
36
+ dynamicImport?: boolean;
37
+ }
38
+ export interface SwcLoaderEsParserConfig {
39
+ syntax: "ecmascript";
40
+ /**
41
+ * Defaults to false.
42
+ */
43
+ jsx?: boolean;
44
+ /**
45
+ * Defaults to `false`
46
+ */
47
+ functionBind?: boolean;
48
+ /**
49
+ * Defaults to `false`
50
+ */
51
+ decorators?: boolean;
52
+ /**
53
+ * Defaults to `false`
54
+ */
55
+ decoratorsBeforeExport?: boolean;
56
+ /**
57
+ * Defaults to `false`
58
+ */
59
+ exportDefaultFrom?: boolean;
60
+ /**
61
+ * Defaults to `false`
62
+ */
63
+ importAssertions?: boolean;
64
+ }
65
+ /**
66
+ * - `import { DEBUG } from '@ember/env-flags';`
67
+ * - `import { FEATURE_A, FEATURE_B } from '@ember/features';`
68
+ *
69
+ * See: https://github.com/swc-project/swc/issues/18#issuecomment-466272558
70
+ */
71
+ export type ConstModulesConfig = {
72
+ globals?: {
73
+ [module: string]: {
74
+ [name: string]: string;
75
+ };
76
+ };
77
+ };
78
+ /**
79
+ * Options for inline-global pass.
80
+ */
81
+ export interface GlobalPassOption {
82
+ /**
83
+ * Global variables that should be inlined with passed value.
84
+ *
85
+ * e.g. `{ __DEBUG__: true }`
86
+ */
87
+ vars?: Record<string, string>;
88
+ /**
89
+ * Names of environment variables that should be inlined with the value of corresponding env during build.
90
+ *
91
+ * Defaults to `["NODE_ENV", "SWC_ENV"]`
92
+ */
93
+ envs?: string[] | Record<string, string>;
94
+ /**
95
+ * Replaces typeof calls for passed variables with corresponding value
96
+ *
97
+ * e.g. `{ window: 'object' }`
98
+ */
99
+ typeofs?: Record<string, string>;
100
+ }
101
+ /**
102
+ * https://swc.rs/docs/configuring-swc.html#jsctransformoptimizerjsonify
103
+ */
104
+ export type OptimizerConfig = {
105
+ /**
106
+ * https://swc.rs/docs/configuration/compilation#jsctransformoptimizersimplify
107
+ */
108
+ simplify?: boolean;
109
+ /**
110
+ * https://swc.rs/docs/configuring-swc.html#jsctransformoptimizerglobals
111
+ */
112
+ globals?: GlobalPassOption;
113
+ /**
114
+ * https://swc.rs/docs/configuring-swc.html#jsctransformoptimizerjsonify
115
+ */
116
+ jsonify?: {
117
+ minCost: number;
118
+ };
119
+ };
120
+ export interface SwcLoaderTransformConfig {
121
+ /**
122
+ * Effective only if `syntax` supports ƒ.
123
+ */
124
+ react?: ReactOptions;
125
+ constModules?: ConstModulesConfig;
126
+ /**
127
+ * Defaults to null, which skips optimizer pass.
128
+ */
129
+ optimizer?: OptimizerConfig;
130
+ /**
131
+ * https://swc.rs/docs/configuring-swc.html#jsctransformlegacydecorator
132
+ */
133
+ legacyDecorator?: boolean;
134
+ /**
135
+ * https://swc.rs/docs/configuring-swc.html#jsctransformdecoratormetadata
136
+ */
137
+ decoratorMetadata?: boolean;
138
+ /**
139
+ * https://swc.rs/docs/configuration/compilation#jsctransformdecoratorversion
140
+ */
141
+ decoratorVersion?: "2021-12" | "2022-03";
142
+ treatConstEnumAsEnum?: boolean;
143
+ useDefineForClassFields?: boolean;
144
+ }
145
+ export interface SwcLoaderEnvConfig {
146
+ mode?: "usage" | "entry";
147
+ debug?: boolean;
148
+ dynamicImport?: boolean;
149
+ loose?: boolean;
150
+ /**
151
+ * Transpiles the broken syntax to the closest non-broken modern syntax
152
+ * Defaults to false.
153
+ */
154
+ bugfixes?: boolean;
155
+ /**
156
+ * Skipped es features.
157
+ * e.g.)
158
+ * - `core-js/modules/foo`
159
+ */
160
+ skip?: string[];
161
+ include?: string[];
162
+ exclude?: string[];
163
+ /**
164
+ * The version of the used core js.
165
+ */
166
+ coreJs?: string;
167
+ targets?: any;
168
+ path?: string;
169
+ shippedProposals?: boolean;
170
+ /**
171
+ * Enable all transforms
172
+ */
173
+ forceAllTransforms?: boolean;
174
+ }
175
+ export interface SwcLoaderJscConfig {
176
+ loose?: boolean;
177
+ /**
178
+ * Defaults to EsParserConfig
179
+ */
180
+ parser?: SwcLoaderParserConfig;
181
+ transform?: SwcLoaderTransformConfig;
182
+ /**
183
+ * Use `@swc/helpers` instead of inline helpers.
184
+ */
185
+ externalHelpers?: boolean;
186
+ /**
187
+ * Defaults to `es3` (which enabled **all** pass).
188
+ */
189
+ target?: JscTarget;
190
+ /**
191
+ * Keep class names.
192
+ */
193
+ keepClassNames?: boolean;
194
+ /**
195
+ * This is experimental, and can be removed without a major version bump.
196
+ */
197
+ experimental?: {
198
+ optimizeHygiene?: boolean;
199
+ /**
200
+ * Preserve `with` in imports and exports.
201
+ */
202
+ keepImportAttributes?: boolean;
203
+ /**
204
+ * Use `assert` instead of `with` for imports and exports.
205
+ * This option only works when `keepImportAttributes` is `true`.
206
+ */
207
+ emitAssertForImportAttributes?: boolean;
208
+ /**
209
+ * Specify the location where SWC stores its intermediate cache files.
210
+ * Currently only transform plugin uses this. If not specified, SWC will
211
+ * create `.swc` directories.
212
+ */
213
+ cacheRoot?: string;
214
+ /**
215
+ * List of custom transform plugins written in WebAssembly.
216
+ * First parameter of tuple indicates the name of the plugin - it can be either
217
+ * a name of the npm package can be resolved, or absolute path to .wasm binary.
218
+ *
219
+ * Second parameter of tuple is JSON based configuration for the plugin.
220
+ */
221
+ plugins?: Array<[string, Record<string, any>]>;
222
+ /**
223
+ * Disable builtin transforms. If enabled, only Wasm plugins are used.
224
+ */
225
+ disableBuiltinTransformsForInternalTesting?: boolean;
226
+ };
227
+ baseUrl?: string;
228
+ paths?: {
229
+ [from: string]: [string];
230
+ };
231
+ preserveAllComments?: boolean;
232
+ }
233
+ export type SwcLoaderModuleConfig = Es6Config | CommonJsConfig | UmdConfig | AmdConfig | NodeNextConfig | SystemjsConfig;
234
+ export interface BaseModuleConfig {
235
+ /**
236
+ * By default, when using exports with babel a non-enumerable `__esModule`
237
+ * property is exported. In some cases this property is used to determine
238
+ * if the import is the default export or if it contains the default export.
239
+ *
240
+ * In order to prevent the __esModule property from being exported, you
241
+ * can set the strict option to true.
242
+ *
243
+ * Defaults to `false`.
244
+ */
245
+ strict?: boolean;
246
+ /**
247
+ * Emits 'use strict' directive.
248
+ *
249
+ * Defaults to `true`.
250
+ */
251
+ strictMode?: boolean;
252
+ /**
253
+ * Changes Babel's compiled import statements to be lazily evaluated when their imported bindings are used for the first time.
254
+ *
255
+ * This can improve initial load time of your module because evaluating dependencies up
256
+ * front is sometimes entirely un-necessary. This is especially the case when implementing
257
+ * a library module.
258
+ *
259
+ *
260
+ * The value of `lazy` has a few possible effects:
261
+ *
262
+ * - `false` - No lazy initialization of any imported module.
263
+ * - `true` - Do not lazy-initialize local `./foo` imports, but lazy-init `foo` dependencies.
264
+ *
265
+ * Local paths are much more likely to have circular dependencies, which may break if loaded lazily,
266
+ * so they are not lazy by default, whereas dependencies between independent modules are rarely cyclical.
267
+ *
268
+ * - `Array<string>` - Lazy-initialize all imports with source matching one of the given strings.
269
+ *
270
+ * -----
271
+ *
272
+ * The two cases where imports can never be lazy are:
273
+ *
274
+ * - `import "foo";`
275
+ *
276
+ * Side-effect imports are automatically non-lazy since their very existence means
277
+ * that there is no binding to later kick off initialization.
278
+ *
279
+ * - `export * from "foo"`
280
+ *
281
+ * Re-exporting all names requires up-front execution because otherwise there is no
282
+ * way to know what names need to be exported.
283
+ *
284
+ * Defaults to `false`.
285
+ */
286
+ lazy?: boolean | string[];
287
+ /**
288
+ * @deprecated Use the `importInterop` option instead.
289
+ *
290
+ * By default, when using exports with swc a non-enumerable __esModule property is exported.
291
+ * This property is then used to determine if the import is the default export or if
292
+ * it contains the default export.
293
+ *
294
+ * In cases where the auto-unwrapping of default is not needed, you can set the noInterop option
295
+ * to true to avoid the usage of the interopRequireDefault helper (shown in inline form above).
296
+ *
297
+ * Defaults to `false`.
298
+ */
299
+ noInterop?: boolean;
300
+ /**
301
+ * Defaults to `swc`.
302
+ *
303
+ * CommonJS modules and ECMAScript modules are not fully compatible.
304
+ * However, compilers, bundlers and JavaScript runtimes developed different strategies
305
+ * to make them work together as well as possible.
306
+ *
307
+ * - `swc` (alias: `babel`)
308
+ *
309
+ * When using exports with `swc` a non-enumerable `__esModule` property is exported
310
+ * This property is then used to determine if the import is the default export
311
+ * or if it contains the default export.
312
+ *
313
+ * ```javascript
314
+ * import foo from "foo";
315
+ * import { bar } from "bar";
316
+ * foo;
317
+ * bar;
318
+ *
319
+ * // Is compiled to ...
320
+ *
321
+ * "use strict";
322
+ *
323
+ * function _interop_require_default(obj) {
324
+ * return obj && obj.__esModule ? obj : { default: obj };
325
+ * }
326
+ *
327
+ * var _foo = _interop_require_default(require("foo"));
328
+ * var _bar = require("bar");
329
+ *
330
+ * _foo.default;
331
+ * _bar.bar;
332
+ * ```
333
+ *
334
+ * When this import interop is used, if both the imported and the importer module are compiled
335
+ * with swc they behave as if none of them was compiled.
336
+ *
337
+ * This is the default behavior.
338
+ *
339
+ * - `node`
340
+ *
341
+ * When importing CommonJS files (either directly written in CommonJS, or generated with a compiler)
342
+ * Node.js always binds the `default` export to the value of `module.exports`.
343
+ *
344
+ * ```javascript
345
+ * import foo from "foo";
346
+ * import { bar } from "bar";
347
+ * foo;
348
+ * bar;
349
+ *
350
+ * // Is compiled to ...
351
+ *
352
+ * "use strict";
353
+ *
354
+ * var _foo = require("foo");
355
+ * var _bar = require("bar");
356
+ *
357
+ * _foo;
358
+ * _bar.bar;
359
+ * ```
360
+ * This is not exactly the same as what Node.js does since swc allows accessing any property of `module.exports`
361
+ * as a named export, while Node.js only allows importing statically analyzable properties of `module.exports`.
362
+ * However, any import working in Node.js will also work when compiled with swc using `importInterop: "node"`.
363
+ *
364
+ * - `none`
365
+ *
366
+ * If you know that the imported file has been transformed with a compiler that stores the `default` export on
367
+ * `exports.default` (such as swc or Babel), you can safely omit the `_interop_require_default` helper.
368
+ *
369
+ * ```javascript
370
+ * import foo from "foo";
371
+ * import { bar } from "bar";
372
+ * foo;
373
+ * bar;
374
+ *
375
+ * // Is compiled to ...
376
+ *
377
+ * "use strict";
378
+ *
379
+ * var _foo = require("foo");
380
+ * var _bar = require("bar");
381
+ *
382
+ * _foo.default;
383
+ * _bar.bar;
384
+ * ```
385
+ */
386
+ importInterop?: "swc" | "babel" | "node" | "none";
387
+ /**
388
+ * Emits `cjs-module-lexer` annotation
389
+ * `cjs-module-lexer` is used in Node.js core for detecting the named exports available when importing a CJS module into ESM.
390
+ * swc will emit `cjs-module-lexer` detectable annotation with this option enabled.
391
+ *
392
+ * Defaults to `true` if import_interop is Node, else `false`
393
+ */
394
+ exportInteropAnnotation?: boolean;
395
+ /**
396
+ * If set to true, dynamic imports will be preserved.
397
+ */
398
+ ignoreDynamic?: boolean;
399
+ allowTopLevelThis?: boolean;
400
+ preserveImportMeta?: boolean;
401
+ }
402
+ export interface Es6Config extends BaseModuleConfig {
403
+ type: "es6";
404
+ }
405
+ export interface NodeNextConfig extends BaseModuleConfig {
406
+ type: "nodenext";
407
+ }
408
+ export interface CommonJsConfig extends BaseModuleConfig {
409
+ type: "commonjs";
410
+ }
411
+ export interface UmdConfig extends BaseModuleConfig {
412
+ type: "umd";
413
+ globals?: {
414
+ [key: string]: string;
415
+ };
416
+ }
417
+ export interface AmdConfig extends BaseModuleConfig {
418
+ type: "amd";
419
+ moduleId?: string;
420
+ }
421
+ export interface SystemjsConfig {
422
+ type: "systemjs";
423
+ allowTopLevelThis?: boolean;
424
+ }
425
+ export type SwcLoaderOptions = {
426
+ /**
427
+ * Note: The type is string because it follows rust's regex syntax.
428
+ */
429
+ test?: string | string[];
430
+ /**
431
+ * Note: The type is string because it follows rust's regex syntax.
432
+ */
433
+ exclude?: string | string[];
434
+ env?: SwcLoaderEnvConfig;
435
+ jsc?: SwcLoaderJscConfig;
436
+ module?: SwcLoaderModuleConfig;
437
+ minify?: boolean;
438
+ /**
439
+ * - true to generate a sourcemap for the code and include it in the result object.
440
+ * - "inline" to generate a sourcemap and append it as a data URL to the end of the code, but not include it in the result object.
441
+ *
442
+ * `swc-cli` overloads some of these to also affect how maps are written to disk:
443
+ *
444
+ * - true will write the map to a .map file on disk
445
+ * - "inline" will write the file directly, so it will have a data: containing the map
446
+ * - Note: These options are bit weird, so it may make the most sense to just use true
447
+ * and handle the rest in your own code, depending on your use case.
448
+ */
449
+ sourceMaps?: boolean;
450
+ inlineSourcesContent?: boolean;
451
+ isModule?: boolean | "unknown";
452
+ /**
453
+ * Experimental features provided by Rspack.
454
+ * @experimental
455
+ */
456
+ rspackExperiments?: {
457
+ relay?: RelayOptions;
458
+ emotion?: EmotionOptions;
459
+ import?: PluginImportOptions;
460
+ styledComponents?: StyledComponentsOptions;
461
+ };
462
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -4,6 +4,7 @@ exports.ModuleFederationPlugin = void 0;
4
4
  const config_1 = require("../config");
5
5
  const options_1 = require("./options");
6
6
  const validate_1 = require("../util/validate");
7
+ const ModuleFederationRuntimePlugin_1 = require("./ModuleFederationRuntimePlugin");
7
8
  class ModuleFederationPlugin {
8
9
  constructor(_options) {
9
10
  this._options = _options;
@@ -19,6 +20,7 @@ class ModuleFederationPlugin {
19
20
  compiler.hooks.afterPlugins.tap(ModuleFederationPlugin.name, () => {
20
21
  new webpack.EntryPlugin(compiler.context, getDefaultEntryRuntime(paths, this._options, compiler), { name: undefined }).apply(compiler);
21
22
  });
23
+ new ModuleFederationRuntimePlugin_1.ModuleFederationRuntimePlugin().apply(compiler);
22
24
  new webpack.container.ModuleFederationPluginV1({
23
25
  ...this._options,
24
26
  enhanced: true
@@ -0,0 +1,10 @@
1
+ import { BuiltinPluginName } from "@rspack/binding";
2
+ export declare const ModuleFederationRuntimePlugin: {
3
+ new (): {
4
+ name: BuiltinPluginName;
5
+ _options: void;
6
+ affectedHooks: "done" | "compilation" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | undefined;
7
+ raw(): import("@rspack/binding").BuiltinPlugin;
8
+ apply(compiler: import("../Compiler").Compiler): void;
9
+ };
10
+ };
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ModuleFederationRuntimePlugin = void 0;
4
+ const binding_1 = require("@rspack/binding");
5
+ const base_1 = require("../builtin-plugin/base");
6
+ exports.ModuleFederationRuntimePlugin = (0, base_1.create)(binding_1.BuiltinPluginName.ModuleFederationRuntimePlugin, () => { });
@@ -3,8 +3,9 @@
3
3
  var __module_federation_bundler_runtime__, __module_federation_runtime_plugins__, __module_federation_remote_infos__, __module_federation_container_name__;
4
4
  module.exports = function () {
5
5
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
6
- if (__webpack_require__.initializeSharingData ||
7
- __webpack_require__.initializeExposesData) {
6
+ if ((__webpack_require__.initializeSharingData ||
7
+ __webpack_require__.initializeExposesData) &&
8
+ __webpack_require__.federation) {
8
9
  const override = (obj, key, value) => {
9
10
  if (!obj)
10
11
  return;
@@ -36,7 +37,10 @@ module.exports = function () {
36
37
  const initializeSharingInitPromises = [];
37
38
  const initializeSharingInitTokens = [];
38
39
  const containerShareScope = (_l = __webpack_require__.initializeExposesData) === null || _l === void 0 ? void 0 : _l.shareScope;
39
- early(__webpack_require__, "federation", () => __module_federation_bundler_runtime__);
40
+ for (const key in __module_federation_bundler_runtime__) {
41
+ __webpack_require__.federation[key] =
42
+ __module_federation_bundler_runtime__[key];
43
+ }
40
44
  early(__webpack_require__.federation, "consumesLoadingModuleToHandlerMapping", () => {
41
45
  const consumesLoadingModuleToHandlerMapping = {};
42
46
  for (let [moduleId, data] of Object.entries(consumesLoadingModuleToConsumeDataMapping)) {
@@ -106,11 +110,11 @@ module.exports = function () {
106
110
  }
107
111
  return idToRemoteMap;
108
112
  });
109
- override(__webpack_require__, "S", __module_federation_bundler_runtime__.bundlerRuntime.S);
110
- if (__module_federation_bundler_runtime__.attachShareScopeMap) {
111
- __module_federation_bundler_runtime__.attachShareScopeMap(__webpack_require__);
113
+ override(__webpack_require__, "S", __webpack_require__.federation.bundlerRuntime.S);
114
+ if (__webpack_require__.federation.attachShareScopeMap) {
115
+ __webpack_require__.federation.attachShareScopeMap(__webpack_require__);
112
116
  }
113
- override(__webpack_require__.f, "remotes", (chunkId, promises) => __module_federation_bundler_runtime__.bundlerRuntime.remotes({
117
+ override(__webpack_require__.f, "remotes", (chunkId, promises) => __webpack_require__.federation.bundlerRuntime.remotes({
114
118
  chunkId,
115
119
  promises,
116
120
  chunkMapping: remotesLoadingChunkMapping,
@@ -120,7 +124,7 @@ module.exports = function () {
120
124
  .idToRemoteMap,
121
125
  webpackRequire: __webpack_require__
122
126
  }));
123
- override(__webpack_require__.f, "consumes", (chunkId, promises) => __module_federation_bundler_runtime__.bundlerRuntime.consumes({
127
+ override(__webpack_require__.f, "consumes", (chunkId, promises) => __webpack_require__.federation.bundlerRuntime.consumes({
124
128
  chunkId,
125
129
  promises,
126
130
  chunkMapping: consumesLoadingChunkMapping,
@@ -128,14 +132,14 @@ module.exports = function () {
128
132
  installedModules: consumesLoadinginstalledModules,
129
133
  webpackRequire: __webpack_require__
130
134
  }));
131
- override(__webpack_require__, "I", (name, initScope) => __module_federation_bundler_runtime__.bundlerRuntime.I({
135
+ override(__webpack_require__, "I", (name, initScope) => __webpack_require__.federation.bundlerRuntime.I({
132
136
  shareScopeName: name,
133
137
  initScope,
134
138
  initPromises: initializeSharingInitPromises,
135
139
  initTokens: initializeSharingInitTokens,
136
140
  webpackRequire: __webpack_require__
137
141
  }));
138
- override(__webpack_require__, "initContainer", (shareScope, initScope, remoteEntryInitOptions) => __module_federation_bundler_runtime__.bundlerRuntime.initContainerEntry({
142
+ override(__webpack_require__, "initContainer", (shareScope, initScope, remoteEntryInitOptions) => __webpack_require__.federation.bundlerRuntime.initContainerEntry({
139
143
  shareScope,
140
144
  initScope,
141
145
  remoteEntryInitOptions,
@@ -153,14 +157,14 @@ module.exports = function () {
153
157
  __webpack_require__.R = undefined;
154
158
  return getScope;
155
159
  });
156
- __module_federation_bundler_runtime__.instance =
157
- __module_federation_bundler_runtime__.runtime.init(__module_federation_bundler_runtime__.initOptions);
160
+ __webpack_require__.federation.instance =
161
+ __webpack_require__.federation.runtime.init(__webpack_require__.federation.initOptions);
158
162
  if ((_m = __webpack_require__.consumesLoadingData) === null || _m === void 0 ? void 0 : _m.initialConsumes) {
159
- __module_federation_bundler_runtime__.bundlerRuntime.installInitialConsumes({
163
+ __webpack_require__.federation.bundlerRuntime.installInitialConsumes({
160
164
  webpackRequire: __webpack_require__,
161
165
  installedModules: consumesLoadinginstalledModules,
162
166
  initialConsumes: __webpack_require__.consumesLoadingData.initialConsumes,
163
- moduleToHandlerMapping: __module_federation_bundler_runtime__.consumesLoadingModuleToHandlerMapping
167
+ moduleToHandlerMapping: __webpack_require__.federation.consumesLoadingModuleToHandlerMapping
164
168
  });
165
169
  }
166
170
  }
package/dist/exports.d.ts CHANGED
@@ -14,9 +14,9 @@ export { MultiStats } from "./MultiStats";
14
14
  export type { ChunkGroup } from "./ChunkGroup";
15
15
  export type { NormalModuleFactory } from "./NormalModuleFactory";
16
16
  export { NormalModule } from "./NormalModule";
17
- declare const ModuleFilenameHelpers: any;
17
+ import * as ModuleFilenameHelpers from "./lib/ModuleFilenameHelpers";
18
18
  export { ModuleFilenameHelpers };
19
- declare const Template: any;
19
+ import Template = require("./Template");
20
20
  export { Template };
21
21
  export declare const WebpackError: ErrorConstructor;
22
22
  export type { Watching } from "./Watching";
@@ -129,3 +129,4 @@ export type { SourceMapDevToolPluginOptions } from "./builtin-plugin";
129
129
  export { EvalDevToolModulePlugin } from "./builtin-plugin";
130
130
  export type { EvalDevToolModulePluginOptions } from "./builtin-plugin";
131
131
  export { CssExtractRspackPlugin } from "./builtin-plugin";
132
+ export type { SwcLoaderOptions, SwcLoaderEnvConfig, SwcLoaderJscConfig, SwcLoaderModuleConfig, SwcLoaderParserConfig, SwcLoaderEsParserConfig, SwcLoaderTsParserConfig, SwcLoaderTransformConfig } from "./builtin-loader/swc/index";
package/dist/exports.js CHANGED
@@ -1,4 +1,27 @@
1
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
27
  };
@@ -25,7 +48,7 @@ Object.defineProperty(exports, "MultiStats", { enumerable: true, get: function (
25
48
  var NormalModule_1 = require("./NormalModule");
26
49
  Object.defineProperty(exports, "NormalModule", { enumerable: true, get: function () { return NormalModule_1.NormalModule; } });
27
50
  // API extractor not working with some re-exports, see: https://github.com/microsoft/fluentui/issues/20694
28
- const ModuleFilenameHelpers = require("./lib/ModuleFilenameHelpers");
51
+ const ModuleFilenameHelpers = __importStar(require("./lib/ModuleFilenameHelpers"));
29
52
  exports.ModuleFilenameHelpers = ModuleFilenameHelpers;
30
53
  // API extractor not working with some re-exports, see: https://github.com/microsoft/fluentui/issues/20694
31
54
  const Template = require("./Template");
@@ -520,7 +520,7 @@ async function runLoaders(compiler, rawContext) {
520
520
  resolve({
521
521
  content: (0, util_1.isNil)(content) ? undefined : (0, util_1.toBuffer)(content),
522
522
  sourceMap: (0, util_1.serializeObject)(sourceMap),
523
- additionalData: (0, util_1.serializeObject)(additionalData),
523
+ additionalData,
524
524
  buildDependencies,
525
525
  cacheable,
526
526
  fileDependencies,
@@ -542,7 +542,7 @@ async function runLoaders(compiler, rawContext) {
542
542
  : (0, util_1.toObject)(rawContext.sourceMap),
543
543
  (0, util_1.isNil)(rawContext.additionalData)
544
544
  ? undefined
545
- : (0, util_1.toObject)(rawContext.additionalData)
545
+ : rawContext.additionalData
546
546
  ], (err, result) => {
547
547
  if (err) {
548
548
  return reject(err);
@@ -551,7 +551,7 @@ async function runLoaders(compiler, rawContext) {
551
551
  resolve({
552
552
  content: (0, util_1.isNil)(content) ? undefined : (0, util_1.toBuffer)(content),
553
553
  sourceMap: (0, util_1.serializeObject)(sourceMap),
554
- additionalData: (0, util_1.serializeObject)(additionalData),
554
+ additionalData,
555
555
  buildDependencies,
556
556
  cacheable,
557
557
  fileDependencies,
@@ -54,7 +54,7 @@ module.exports = function loadLoader(loader, callback) {
54
54
  Object.assign({}, this.__internal__context, {
55
55
  content: isNil(content) ? undefined : toBuffer(content),
56
56
  sourceMap: serializeObject(sourceMap),
57
- additionalData: serializeObject(additionalData)
57
+ additionalData
58
58
  }));
59
59
  // @ts-expect-error
60
60
  this.__internal__context.additionalDataExternal =
@@ -69,9 +69,7 @@ module.exports = function loadLoader(loader, callback) {
69
69
  context.buildDependencies.forEach(this.addBuildDependency);
70
70
  callback(null, context.content, isNil(context.sourceMap)
71
71
  ? undefined
72
- : toObject(context.sourceMap), isNil(context.additionalData)
73
- ? undefined
74
- : toObject(context.additionalData));
72
+ : toObject(context.sourceMap), isNil(context.additionalData) ? undefined : context.additionalData);
75
73
  // @ts-expect-error
76
74
  this._compilation.__internal__pushNativeDiagnostics(context.diagnosticsExternal);
77
75
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rspack/core",
3
- "version": "0.6.2",
3
+ "version": "0.6.3-canary-e0ce3b5-20240423104040",
4
4
  "webpackVersion": "5.75.0",
5
5
  "license": "MIT",
6
6
  "description": "A Fast Rust-based Web Bundler",
@@ -60,8 +60,8 @@
60
60
  "styled-components": "^6.0.8",
61
61
  "terser": "5.27.2",
62
62
  "wast-loader": "^1.11.4",
63
- "@rspack/core": "0.6.2",
64
- "@rspack/plugin-minify": "^0.6.2"
63
+ "@rspack/plugin-minify": "^0.6.3-canary-e0ce3b5-20240423104040",
64
+ "@rspack/core": "0.6.3-canary-e0ce3b5-20240423104040"
65
65
  },
66
66
  "dependencies": {
67
67
  "@module-federation/runtime-tools": "0.1.6",
@@ -76,7 +76,7 @@
76
76
  "webpack-sources": "3.2.3",
77
77
  "zod": "^3.21.4",
78
78
  "zod-validation-error": "1.3.1",
79
- "@rspack/binding": "0.6.2"
79
+ "@rspack/binding": "0.6.3-canary-e0ce3b5-20240423104040"
80
80
  },
81
81
  "peerDependencies": {
82
82
  "@swc/helpers": ">=0.5.1"