@rspack/core 1.0.0-beta.4 → 1.0.0-rc.0

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.
Files changed (42) hide show
  1. package/dist/Compilation.d.ts +2 -3
  2. package/dist/Compilation.js +0 -2
  3. package/dist/Compiler.d.ts +2 -2
  4. package/dist/Compiler.js +1 -3
  5. package/dist/MultiCompiler.d.ts +3 -3
  6. package/dist/MultiCompiler.js +1 -3
  7. package/dist/NormalModule.d.ts +2 -1
  8. package/dist/NormalModule.js +1 -1
  9. package/dist/builtin-loader/lightningcss/index.d.ts +1 -0
  10. package/dist/builtin-plugin/HtmlRspackPlugin.d.ts +41 -10
  11. package/dist/builtin-plugin/HtmlRspackPlugin.js +16 -4
  12. package/dist/builtin-plugin/LightningCssMiminizerRspackPlugin.d.ts +2 -2
  13. package/dist/builtin-plugin/LightningCssMiminizerRspackPlugin.js +1 -7
  14. package/dist/builtin-plugin/{SwcCssMinimizerPlugin.d.ts → NoEmitOnErrorsPlugin.d.ts} +3 -9
  15. package/dist/builtin-plugin/NoEmitOnErrorsPlugin.js +6 -0
  16. package/dist/builtin-plugin/SwcJsMinimizerPlugin.d.ts +2 -6
  17. package/dist/builtin-plugin/SwcJsMinimizerPlugin.js +1 -0
  18. package/dist/builtin-plugin/css-extract/loader.d.ts +1 -1
  19. package/dist/builtin-plugin/css-extract/loader.js +2 -10
  20. package/dist/builtin-plugin/index.d.ts +1 -1
  21. package/dist/builtin-plugin/index.js +1 -1
  22. package/dist/config/adapterRuleUse.d.ts +1 -0
  23. package/dist/config/adapterRuleUse.js +2 -6
  24. package/dist/config/defaults.js +14 -7
  25. package/dist/config/zod.d.ts +8 -0
  26. package/dist/config/zod.js +2 -1
  27. package/dist/container/ModuleFederationPlugin.d.ts +1 -0
  28. package/dist/container/ModuleFederationPlugin.js +1 -0
  29. package/dist/container/default.runtime.js +1 -1
  30. package/dist/exports.d.ts +1 -1
  31. package/dist/exports.js +20 -20
  32. package/dist/lib/EnvironmentPlugin.d.ts +2 -2
  33. package/dist/lib/EnvironmentPlugin.js +1 -1
  34. package/dist/loader-runner/index.js +3 -3
  35. package/dist/loader-runner/loadLoader.js +1 -1
  36. package/dist/node/NodeEnvironmentPlugin.js +4 -4
  37. package/dist/node/NodeWatchFileSystem.d.ts +3 -3
  38. package/dist/node/NodeWatchFileSystem.js +8 -8
  39. package/dist/rspackOptionsApply.js +3 -0
  40. package/dist/util/fs.d.ts +245 -22
  41. package/package.json +4 -4
  42. package/dist/builtin-plugin/SwcCssMinimizerPlugin.js +0 -12
@@ -27,6 +27,7 @@ import { Logger } from "./logging/Logger";
27
27
  import { StatsFactory } from "./stats/StatsFactory";
28
28
  import { StatsPrinter } from "./stats/StatsPrinter";
29
29
  import { type AssetInfo } from "./util/AssetInfo";
30
+ import type { InputFileSystem } from "./util/fs";
30
31
  import type Hash from "./util/hash";
31
32
  export { type AssetInfo } from "./util/AssetInfo";
32
33
  export type Assets = Record<string, Source>;
@@ -175,7 +176,7 @@ export declare class Compilation {
175
176
  endTime?: number;
176
177
  compiler: Compiler;
177
178
  resolverFactory: ResolverFactory;
178
- inputFileSystem: any;
179
+ inputFileSystem: InputFileSystem | null;
179
180
  options: RspackOptionsNormalized;
180
181
  outputOptions: OutputNormalized;
181
182
  logging: Map<string, LogEntry[]>;
@@ -227,8 +228,6 @@ export declare class Compilation {
227
228
  createStatsPrinter(options: StatsOptions): StatsPrinter;
228
229
  /**
229
230
  * Update an existing asset. Trying to update an asset that doesn't exist will throw an error.
230
- *
231
- * FIXME: *AssetInfo* may be undefined in update fn for webpack impl, but still not implemented in rspack
232
231
  */
233
232
  updateAsset(filename: string, newSourceOrFunction: Source | ((source: Source) => Source), assetInfoUpdateOrFunction?: AssetInfo | ((assetInfo: AssetInfo) => AssetInfo)): void;
234
233
  /**
@@ -297,8 +297,6 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
297
297
  }
298
298
  /**
299
299
  * Update an existing asset. Trying to update an asset that doesn't exist will throw an error.
300
- *
301
- * FIXME: *AssetInfo* may be undefined in update fn for webpack impl, but still not implemented in rspack
302
300
  */
303
301
  updateAsset(filename, newSourceOrFunction, assetInfoUpdateOrFunction) {
304
302
  let compatNewSourceOrFunction;
@@ -27,7 +27,7 @@ import type { Source } from "../compiled/webpack-sources";
27
27
  import type { CompilationParams } from "./Compilation";
28
28
  import type { FileSystemInfoEntry } from "./FileSystemInfo";
29
29
  import type { EntryNormalized, OutputNormalized, RspackOptionsNormalized, RspackPluginInstance } from "./config";
30
- import type { OutputFileSystem, WatchFileSystem } from "./util/fs";
30
+ import type { InputFileSystem, OutputFileSystem, WatchFileSystem } from "./util/fs";
31
31
  export interface AssetEmittedInfo {
32
32
  content: Buffer;
33
33
  source: Source;
@@ -79,7 +79,7 @@ declare class Compiler {
79
79
  resolverFactory: ResolverFactory;
80
80
  infrastructureLogger: any;
81
81
  watching?: Watching;
82
- inputFileSystem: any;
82
+ inputFileSystem: InputFileSystem | null;
83
83
  intermediateFileSystem: any;
84
84
  outputFileSystem: OutputFileSystem | null;
85
85
  watchFileSystem: WatchFileSystem | null;
package/dist/Compiler.js CHANGED
@@ -372,9 +372,7 @@ class Compiler {
372
372
  });
373
373
  }
374
374
  purgeInputFileSystem() {
375
- if (this.inputFileSystem?.purge) {
376
- this.inputFileSystem.purge();
377
- }
375
+ this.inputFileSystem?.purge?.();
378
376
  }
379
377
  /**
380
378
  * @param compilation - the compilation
@@ -12,7 +12,7 @@ import type { Compiler, RspackOptions } from ".";
12
12
  import MultiStats from "./MultiStats";
13
13
  import MultiWatching from "./MultiWatching";
14
14
  import type { WatchOptions } from "./config";
15
- import type { WatchFileSystem } from "./util/fs";
15
+ import type { InputFileSystem, WatchFileSystem } from "./util/fs";
16
16
  export interface MultiCompilerOptions {
17
17
  /**
18
18
  * how many Compilers are allows to run at the same time in parallel
@@ -37,11 +37,11 @@ export declare class MultiCompiler {
37
37
  constructor(compilers: Compiler[] | Record<string, Compiler>, options?: MultiCompilerOptions);
38
38
  get options(): import(".").RspackOptionsNormalized[] & MultiCompilerOptions;
39
39
  get outputPath(): string;
40
- get inputFileSystem(): void;
40
+ get inputFileSystem(): InputFileSystem;
41
41
  get outputFileSystem(): typeof import("fs");
42
42
  get watchFileSystem(): WatchFileSystem;
43
43
  get intermediateFileSystem(): void;
44
- set inputFileSystem(value: void);
44
+ set inputFileSystem(value: InputFileSystem);
45
45
  set outputFileSystem(value: typeof import("fs"));
46
46
  set watchFileSystem(value: WatchFileSystem);
47
47
  set intermediateFileSystem(value: void);
@@ -275,9 +275,7 @@ class MultiCompiler {
275
275
  }
276
276
  purgeInputFileSystem() {
277
277
  for (const compiler of this.compilers) {
278
- if (compiler.inputFileSystem?.purge) {
279
- compiler.inputFileSystem.purge();
280
- }
278
+ compiler.inputFileSystem?.purge?.();
281
279
  }
282
280
  }
283
281
  close(callback) {
@@ -1,10 +1,11 @@
1
1
  /// <reference types="node" />
2
2
  import * as liteTapable from "@rspack/lite-tapable";
3
3
  import { Compilation } from "./Compilation";
4
+ import type { Module } from "./Module";
4
5
  import type { LoaderContext } from "./config";
5
6
  export declare class NormalModule {
6
7
  static getCompilationHooks(compilation: Compilation): {
7
- loader: liteTapable.SyncHook<[LoaderContext<{}>], void, {
8
+ loader: liteTapable.SyncHook<[LoaderContext<{}>, Module], void, {
8
9
  _UnsetAdditionalOptions: true;
9
10
  }>;
10
11
  readResourceForScheme: any;
@@ -76,7 +76,7 @@ class NormalModule {
76
76
  let hooks = compilationHooksMap.get(compilation);
77
77
  if (hooks === undefined) {
78
78
  hooks = {
79
- loader: new liteTapable.SyncHook(["loaderContext"]),
79
+ loader: new liteTapable.SyncHook(["loaderContext", "module"]),
80
80
  // TODO webpack 6 deprecate
81
81
  readResourceForScheme: new liteTapable.HookMap(scheme => {
82
82
  const hook = hooks.readResource.for(scheme);
@@ -78,6 +78,7 @@ export type FeatureOptions = {
78
78
  color?: boolean;
79
79
  };
80
80
  export type LoaderOptions = {
81
+ minify?: boolean;
81
82
  errorRecovery?: boolean;
82
83
  targets?: Targets | string[] | string;
83
84
  include?: FeatureOptions;
@@ -7,24 +7,40 @@ declare const htmlRspackPluginOptions: z.ZodObject<{
7
7
  templateParameters: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
8
8
  inject: z.ZodOptional<z.ZodUnion<[z.ZodEnum<["head", "body"]>, z.ZodBoolean]>>;
9
9
  publicPath: z.ZodOptional<z.ZodString>;
10
- scriptLoading: z.ZodOptional<z.ZodEnum<["blocking", "defer", "module"]>>;
10
+ base: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodObject<{
11
+ href: z.ZodOptional<z.ZodString>;
12
+ target: z.ZodOptional<z.ZodEnum<["_self", "_blank", "_parent", "_top"]>>;
13
+ }, "strict", z.ZodTypeAny, {
14
+ target?: "_self" | "_blank" | "_parent" | "_top" | undefined;
15
+ href?: string | undefined;
16
+ }, {
17
+ target?: "_self" | "_blank" | "_parent" | "_top" | undefined;
18
+ href?: string | undefined;
19
+ }>]>>;
20
+ scriptLoading: z.ZodOptional<z.ZodEnum<["blocking", "defer", "module", "systemjs-module"]>>;
11
21
  chunks: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
12
- excludedChunks: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
22
+ excludeChunks: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
13
23
  sri: z.ZodOptional<z.ZodEnum<["sha256", "sha384", "sha512"]>>;
14
24
  minify: z.ZodOptional<z.ZodBoolean>;
15
25
  title: z.ZodOptional<z.ZodString>;
16
26
  favicon: z.ZodOptional<z.ZodString>;
17
27
  meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>>>;
28
+ hash: z.ZodOptional<z.ZodBoolean>;
18
29
  }, "strict", z.ZodTypeAny, {
19
30
  filename?: string | undefined;
20
31
  publicPath?: string | undefined;
32
+ hash?: boolean | undefined;
21
33
  chunks?: string[] | undefined;
22
34
  template?: string | undefined;
23
35
  templateContent?: string | undefined;
24
36
  templateParameters?: Record<string, string> | undefined;
25
37
  inject?: boolean | "head" | "body" | undefined;
26
- scriptLoading?: "module" | "blocking" | "defer" | undefined;
27
- excludedChunks?: string[] | undefined;
38
+ base?: string | {
39
+ target?: "_self" | "_blank" | "_parent" | "_top" | undefined;
40
+ href?: string | undefined;
41
+ } | undefined;
42
+ scriptLoading?: "module" | "blocking" | "defer" | "systemjs-module" | undefined;
43
+ excludeChunks?: string[] | undefined;
28
44
  sri?: "sha256" | "sha384" | "sha512" | undefined;
29
45
  minify?: boolean | undefined;
30
46
  title?: string | undefined;
@@ -33,13 +49,18 @@ declare const htmlRspackPluginOptions: z.ZodObject<{
33
49
  }, {
34
50
  filename?: string | undefined;
35
51
  publicPath?: string | undefined;
52
+ hash?: boolean | undefined;
36
53
  chunks?: string[] | undefined;
37
54
  template?: string | undefined;
38
55
  templateContent?: string | undefined;
39
56
  templateParameters?: Record<string, string> | undefined;
40
57
  inject?: boolean | "head" | "body" | undefined;
41
- scriptLoading?: "module" | "blocking" | "defer" | undefined;
42
- excludedChunks?: string[] | undefined;
58
+ base?: string | {
59
+ target?: "_self" | "_blank" | "_parent" | "_top" | undefined;
60
+ href?: string | undefined;
61
+ } | undefined;
62
+ scriptLoading?: "module" | "blocking" | "defer" | "systemjs-module" | undefined;
63
+ excludeChunks?: string[] | undefined;
43
64
  sri?: "sha256" | "sha384" | "sha512" | undefined;
44
65
  minify?: boolean | undefined;
45
66
  title?: string | undefined;
@@ -51,13 +72,18 @@ export declare const HtmlRspackPlugin: {
51
72
  new (c?: {
52
73
  filename?: string | undefined;
53
74
  publicPath?: string | undefined;
75
+ hash?: boolean | undefined;
54
76
  chunks?: string[] | undefined;
55
77
  template?: string | undefined;
56
78
  templateContent?: string | undefined;
57
79
  templateParameters?: Record<string, string> | undefined;
58
80
  inject?: boolean | "head" | "body" | undefined;
59
- scriptLoading?: "module" | "blocking" | "defer" | undefined;
60
- excludedChunks?: string[] | undefined;
81
+ base?: string | {
82
+ target?: "_self" | "_blank" | "_parent" | "_top" | undefined;
83
+ href?: string | undefined;
84
+ } | undefined;
85
+ scriptLoading?: "module" | "blocking" | "defer" | "systemjs-module" | undefined;
86
+ excludeChunks?: string[] | undefined;
61
87
  sri?: "sha256" | "sha384" | "sha512" | undefined;
62
88
  minify?: boolean | undefined;
63
89
  title?: string | undefined;
@@ -68,13 +94,18 @@ export declare const HtmlRspackPlugin: {
68
94
  _args: [c?: {
69
95
  filename?: string | undefined;
70
96
  publicPath?: string | undefined;
97
+ hash?: boolean | undefined;
71
98
  chunks?: string[] | undefined;
72
99
  template?: string | undefined;
73
100
  templateContent?: string | undefined;
74
101
  templateParameters?: Record<string, string> | undefined;
75
102
  inject?: boolean | "head" | "body" | undefined;
76
- scriptLoading?: "module" | "blocking" | "defer" | undefined;
77
- excludedChunks?: string[] | undefined;
103
+ base?: string | {
104
+ target?: "_self" | "_blank" | "_parent" | "_top" | undefined;
105
+ href?: string | undefined;
106
+ } | undefined;
107
+ scriptLoading?: "module" | "blocking" | "defer" | "systemjs-module" | undefined;
108
+ excludeChunks?: string[] | undefined;
78
109
  sri?: "sha256" | "sha384" | "sha512" | undefined;
79
110
  minify?: boolean | undefined;
80
111
  title?: string | undefined;
@@ -12,14 +12,24 @@ const htmlRspackPluginOptions = zod_1.z.strictObject({
12
12
  templateParameters: zod_1.z.record(zod_1.z.string()).optional(),
13
13
  inject: zod_1.z.enum(["head", "body"]).or(zod_1.z.boolean()).optional(),
14
14
  publicPath: zod_1.z.string().optional(),
15
- scriptLoading: zod_1.z.enum(["blocking", "defer", "module"]).optional(),
15
+ base: zod_1.z
16
+ .string()
17
+ .or(zod_1.z.strictObject({
18
+ href: zod_1.z.string().optional(),
19
+ target: zod_1.z.enum(["_self", "_blank", "_parent", "_top"]).optional()
20
+ }))
21
+ .optional(),
22
+ scriptLoading: zod_1.z
23
+ .enum(["blocking", "defer", "module", "systemjs-module"])
24
+ .optional(),
16
25
  chunks: zod_1.z.string().array().optional(),
17
- excludedChunks: zod_1.z.string().array().optional(),
26
+ excludeChunks: zod_1.z.string().array().optional(),
18
27
  sri: zod_1.z.enum(["sha256", "sha384", "sha512"]).optional(),
19
28
  minify: zod_1.z.boolean().optional(),
20
29
  title: zod_1.z.string().optional(),
21
30
  favicon: zod_1.z.string().optional(),
22
- meta: zod_1.z.record(zod_1.z.string().or(zod_1.z.record(zod_1.z.string()))).optional()
31
+ meta: zod_1.z.record(zod_1.z.string().or(zod_1.z.record(zod_1.z.string()))).optional(),
32
+ hash: zod_1.z.boolean().optional()
23
33
  });
24
34
  exports.HtmlRspackPlugin = (0, base_1.create)(binding_1.BuiltinPluginName.HtmlRspackPlugin, (c = {}) => {
25
35
  (0, validate_1.validate)(c, htmlRspackPluginOptions);
@@ -48,10 +58,12 @@ exports.HtmlRspackPlugin = (0, base_1.create)(binding_1.BuiltinPluginName.HtmlRs
48
58
  : configInject === false
49
59
  ? "false"
50
60
  : configInject;
61
+ const base = typeof c.base === "string" ? { href: c.base } : c.base;
51
62
  return {
52
63
  ...c,
53
64
  meta,
54
65
  scriptLoading,
55
- inject
66
+ inject,
67
+ base
56
68
  };
57
69
  });
@@ -1,5 +1,5 @@
1
1
  import { BuiltinPluginName } from "@rspack/binding";
2
- import { type Drafts, type FeatureOptions, type NonStandard, type PseudoClasses, type Targets } from "../builtin-loader/lightningcss";
2
+ import { type Drafts, type FeatureOptions, type NonStandard, type PseudoClasses } from "../builtin-loader/lightningcss";
3
3
  import type { AssetConditions } from "../util/assetCondition";
4
4
  export type LightningCssMinimizerRspackPluginOptions = {
5
5
  test?: AssetConditions;
@@ -8,7 +8,7 @@ export type LightningCssMinimizerRspackPluginOptions = {
8
8
  removeUnusedLocalIdents?: boolean;
9
9
  minimizerOptions?: {
10
10
  errorRecovery?: boolean;
11
- targets?: Targets | string[] | string;
11
+ targets?: string[] | string;
12
12
  include?: FeatureOptions;
13
13
  exclude?: FeatureOptions;
14
14
  draft?: Drafts;
@@ -1,11 +1,7 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.LightningCssMinimizerRspackPlugin = void 0;
7
4
  const binding_1 = require("@rspack/binding");
8
- const browserslist_1 = __importDefault(require("../../compiled/browserslist"));
9
5
  const lightningcss_1 = require("../builtin-loader/lightningcss");
10
6
  const base_1 = require("./base");
11
7
  exports.LightningCssMinimizerRspackPlugin = (0, base_1.create)(binding_1.BuiltinPluginName.LightningCssMinimizerRspackPlugin, (options) => {
@@ -25,9 +21,7 @@ exports.LightningCssMinimizerRspackPlugin = (0, base_1.create)(binding_1.Builtin
25
21
  : // exclude all features, avoid downgrade css syntax when minimize
26
22
  // 1048575 = Features.Empty | Features.Nesting | ... | Features.LogicalProperties
27
23
  1048575,
28
- targets: typeof targets === "string" || Array.isArray(targets)
29
- ? (0, lightningcss_1.browserslistToTargets)((0, browserslist_1.default)(targets))
30
- : targets,
24
+ targets: typeof targets === "string" ? [targets] : targets,
31
25
  draft: draft ? { customMedia: draft.customMedia ?? false } : undefined,
32
26
  nonStandard: nonStandard
33
27
  ? {
@@ -1,14 +1,8 @@
1
1
  import { BuiltinPluginName } from "@rspack/binding";
2
- import type { AssetConditions } from "../util/assetCondition";
3
- export type SwcCssMinimizerRspackPluginOptions = {
4
- test?: AssetConditions;
5
- exclude?: AssetConditions;
6
- include?: AssetConditions;
7
- };
8
- export declare const SwcCssMinimizerRspackPlugin: {
9
- new (options?: SwcCssMinimizerRspackPluginOptions | undefined): {
2
+ export declare const NoEmitOnErrorsPlugin: {
3
+ new (): {
10
4
  name: BuiltinPluginName;
11
- _args: [options?: SwcCssMinimizerRspackPluginOptions | undefined];
5
+ _args: [];
12
6
  affectedHooks: "done" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | undefined;
13
7
  raw(compiler: import("../Compiler").Compiler): import("@rspack/binding").BuiltinPlugin;
14
8
  apply(compiler: import("../Compiler").Compiler): void;
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NoEmitOnErrorsPlugin = void 0;
4
+ const binding_1 = require("@rspack/binding");
5
+ const base_1 = require("./base");
6
+ exports.NoEmitOnErrorsPlugin = (0, base_1.create)(binding_1.BuiltinPluginName.NoEmitOnErrorsPlugin, () => undefined);
@@ -13,6 +13,7 @@ export type SwcJsMinimizerRspackPluginOptions = {
13
13
  include?: AssetConditions;
14
14
  extractComments?: ExtractCommentsOptions | undefined;
15
15
  minimizerOptions?: {
16
+ minify?: boolean;
16
17
  compress?: TerserCompressOptions | boolean;
17
18
  mangle?: TerserMangleOptions | boolean;
18
19
  format?: JsFormatOptions & ToSnakeCaseProperties<JsFormatOptions>;
@@ -203,12 +204,7 @@ export type TerserManglePropertiesOptions = {};
203
204
  export declare const SwcJsMinimizerRspackPlugin: {
204
205
  new (options?: SwcJsMinimizerRspackPluginOptions | undefined): {
205
206
  name: BuiltinPluginName;
206
- _args: [options?: SwcJsMinimizerRspackPluginOptions | undefined]; /**
207
- * - `false`: removes all comments
208
- * - `'some'`: preserves some comments
209
- * - `'all'`: preserves all comments
210
- * @default false
211
- */
207
+ _args: [options?: SwcJsMinimizerRspackPluginOptions | undefined];
212
208
  affectedHooks: "done" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | undefined;
213
209
  raw(compiler: import("../Compiler").Compiler): import("@rspack/binding").BuiltinPlugin;
214
210
  apply(compiler: import("../Compiler").Compiler): void;
@@ -73,6 +73,7 @@ exports.SwcJsMinimizerRspackPlugin = (0, base_1.create)(binding_1.BuiltinPluginN
73
73
  compress,
74
74
  mangle,
75
75
  format,
76
+ minify: options?.minimizerOptions?.minify,
76
77
  module: options?.minimizerOptions?.module
77
78
  }
78
79
  };
@@ -8,7 +8,7 @@ export interface CssExtractRspackLoaderOptions {
8
8
  publicPath?: string | ((resourcePath: string, context: string) => string);
9
9
  emit?: boolean;
10
10
  esModule?: boolean;
11
- layer?: boolean;
11
+ layer?: string;
12
12
  defaultExport?: boolean;
13
13
  }
14
14
  export declare function hotLoader(content: string, context: {
@@ -190,22 +190,14 @@ const pitch = function (request, _, data) {
190
190
  if (dependencies.length > 0) {
191
191
  additionalData[index_1.CssExtractRspackPlugin.pluginName] = dependencies
192
192
  .map(dep => {
193
- return [
194
- dep.identifier,
195
- dep.content,
196
- dep.context,
197
- dep.media,
198
- dep.supports,
199
- dep.sourceMap,
200
- dep.identifierIndex,
201
- dep.filepath
202
- ].join(SERIALIZE_SEP);
193
+ return JSON.stringify(dep);
203
194
  })
204
195
  .join(SERIALIZE_SEP);
205
196
  }
206
197
  callback(null, resultSource, undefined, additionalData);
207
198
  };
208
199
  this.importModule(`${this.resourcePath}.webpack[javascript/auto]!=!!!${request}`, {
200
+ layer: options.layer,
209
201
  publicPath: /** @type {Filename} */ publicPathForExtract,
210
202
  baseUri: `${exports.BASE_URI}/`
211
203
  }, (error, exports) => {
@@ -56,10 +56,10 @@ export * from "./SideEffectsFlagPlugin";
56
56
  export * from "./SizeLimitsPlugin";
57
57
  export * from "./SourceMapDevToolPlugin";
58
58
  export * from "./SplitChunksPlugin";
59
- export * from "./SwcCssMinimizerPlugin";
60
59
  export * from "./LightningCssMiminizerRspackPlugin";
61
60
  export * from "./SwcJsMinimizerPlugin";
62
61
  export * from "./WarnCaseSensitiveModulesPlugin";
63
62
  export * from "./WebWorkerTemplatePlugin";
64
63
  export * from "./WorkerPlugin";
65
64
  export * from "./FetchCompileAsyncWasmPlugin";
65
+ export * from "./NoEmitOnErrorsPlugin";
@@ -74,10 +74,10 @@ __exportStar(require("./SideEffectsFlagPlugin"), exports);
74
74
  __exportStar(require("./SizeLimitsPlugin"), exports);
75
75
  __exportStar(require("./SourceMapDevToolPlugin"), exports);
76
76
  __exportStar(require("./SplitChunksPlugin"), exports);
77
- __exportStar(require("./SwcCssMinimizerPlugin"), exports);
78
77
  __exportStar(require("./LightningCssMiminizerRspackPlugin"), exports);
79
78
  __exportStar(require("./SwcJsMinimizerPlugin"), exports);
80
79
  __exportStar(require("./WarnCaseSensitiveModulesPlugin"), exports);
81
80
  __exportStar(require("./WebWorkerTemplatePlugin"), exports);
82
81
  __exportStar(require("./WorkerPlugin"), exports);
83
82
  __exportStar(require("./FetchCompileAsyncWasmPlugin"), exports);
83
+ __exportStar(require("./NoEmitOnErrorsPlugin"), exports);
@@ -87,6 +87,7 @@ export interface LoaderContext<OptionsType = {}> {
87
87
  getMissingDependencies(): string[];
88
88
  addBuildDependency(file: string): void;
89
89
  importModule(request: string, options: {
90
+ layer?: string;
90
91
  publicPath?: PublicPath;
91
92
  baseUri?: string;
92
93
  }, callback: (err?: Error, res?: any) => void): void;
@@ -5,7 +5,6 @@ const builtin_loader_1 = require("../builtin-loader");
5
5
  const lightningcss_1 = require("../builtin-loader/lightningcss");
6
6
  const loader_runner_1 = require("../loader-runner");
7
7
  const util_1 = require("../util");
8
- const browserslist = require("../../compiled/browserslist");
9
8
  exports.BUILTIN_LOADER_PREFIX = "builtin:";
10
9
  function createRawModuleRuleUses(uses, path, options) {
11
10
  const normalizeRuleSetUseItem = (item) => typeof item === "string" ? { loader: item } : item;
@@ -26,11 +25,8 @@ const getSwcLoaderOptions = (o, _) => {
26
25
  };
27
26
  const getLightningcssLoaderOptions = (o, _) => {
28
27
  if (o && typeof o === "object") {
29
- if (o.targets && typeof o.targets === "string") {
30
- o.targets = (0, lightningcss_1.browserslistToTargets)(browserslist(o.targets));
31
- }
32
- if (o.targets && Array.isArray(o.targets)) {
33
- o.targets = (0, lightningcss_1.browserslistToTargets)(browserslist(o.targets));
28
+ if (typeof o.targets === "string") {
29
+ o.targets = [o.targets];
34
30
  }
35
31
  if (o.include && typeof o.include === "object") {
36
32
  o.include = (0, lightningcss_1.toFeatures)(o.include);
@@ -69,6 +69,8 @@ const applyRspackOptionsDefaults = (options) => {
69
69
  entry: options.entry,
70
70
  futureDefaults: options.experiments.futureDefaults
71
71
  });
72
+ // bundlerInfo is affected by outputDefaults so must be executed after outputDefaults
73
+ applybundlerInfoDefaults(options.experiments.rspackFuture, options.output.library);
72
74
  applyExternalsPresetsDefaults(options.externalsPresets, {
73
75
  targetProperties
74
76
  });
@@ -133,12 +135,16 @@ const applyExperimentsDefaults = (experiments) => {
133
135
  D(experiments, "topLevelAwait", true);
134
136
  // IGNORE(experiments.rspackFuture): Rspack specific configuration
135
137
  D(experiments, "rspackFuture", {});
136
- if (typeof experiments.rspackFuture === "object") {
137
- D(experiments.rspackFuture, "bundlerInfo", {});
138
- if (typeof experiments.rspackFuture.bundlerInfo === "object") {
139
- D(experiments.rspackFuture.bundlerInfo, "version", require("../../package.json").version);
140
- D(experiments.rspackFuture.bundlerInfo, "bundler", "rspack");
141
- D(experiments.rspackFuture.bundlerInfo, "force", true);
138
+ // rspackFuture.bundlerInfo default value is applied after applyDefaults
139
+ };
140
+ const applybundlerInfoDefaults = (rspackFuture, library) => {
141
+ if (typeof rspackFuture === "object") {
142
+ D(rspackFuture, "bundlerInfo", {});
143
+ if (typeof rspackFuture.bundlerInfo === "object") {
144
+ D(rspackFuture.bundlerInfo, "version", require("../../package.json").version);
145
+ D(rspackFuture.bundlerInfo, "bundler", "rspack");
146
+ // don't inject for library mode
147
+ D(rspackFuture.bundlerInfo, "force", !library);
142
148
  }
143
149
  }
144
150
  };
@@ -688,11 +694,12 @@ const applyOptimizationDefaults = (optimization, { production, development, css
688
694
  D(optimization, "providedExports", true);
689
695
  D(optimization, "usedExports", production);
690
696
  D(optimization, "innerGraph", production);
697
+ D(optimization, "emitOnErrors", !production);
691
698
  D(optimization, "runtimeChunk", false);
692
699
  D(optimization, "realContentHash", production);
693
700
  D(optimization, "minimize", production);
694
701
  D(optimization, "concatenateModules", production);
695
- // IGNORE(optimization.minimizer): Rspack use `SwcJsMinimizerRspackPlugin` and `SwcCssMinimizerRspackPlugin` by default
702
+ // IGNORE(optimization.minimizer): Rspack use `SwcJsMinimizerRspackPlugin` and `LightningCssMinimizerRspackPlugin` by default
696
703
  A(optimization, "minimizer", () => [
697
704
  new builtin_plugin_1.SwcJsMinimizerRspackPlugin(),
698
705
  new builtin_plugin_1.LightningCssMinimizerRspackPlugin()
@@ -5818,6 +5818,7 @@ declare const optimization: z.ZodObject<{
5818
5818
  usedExports: z.ZodOptional<z.ZodUnion<[z.ZodEnum<["global"]>, z.ZodBoolean]>>;
5819
5819
  mangleExports: z.ZodOptional<z.ZodUnion<[z.ZodEnum<["size", "deterministic"]>, z.ZodBoolean]>>;
5820
5820
  nodeEnv: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodLiteral<false>]>>;
5821
+ emitOnErrors: z.ZodOptional<z.ZodBoolean>;
5821
5822
  }, "strict", z.ZodTypeAny, {
5822
5823
  moduleIds?: "named" | "natural" | "deterministic" | undefined;
5823
5824
  chunkIds?: "named" | "natural" | "deterministic" | undefined;
@@ -5883,6 +5884,7 @@ declare const optimization: z.ZodObject<{
5883
5884
  innerGraph?: boolean | undefined;
5884
5885
  mangleExports?: boolean | "deterministic" | "size" | undefined;
5885
5886
  nodeEnv?: string | false | undefined;
5887
+ emitOnErrors?: boolean | undefined;
5886
5888
  }, {
5887
5889
  moduleIds?: "named" | "natural" | "deterministic" | undefined;
5888
5890
  chunkIds?: "named" | "natural" | "deterministic" | undefined;
@@ -5948,6 +5950,7 @@ declare const optimization: z.ZodObject<{
5948
5950
  innerGraph?: boolean | undefined;
5949
5951
  mangleExports?: boolean | "deterministic" | "size" | undefined;
5950
5952
  nodeEnv?: string | false | undefined;
5953
+ emitOnErrors?: boolean | undefined;
5951
5954
  }>;
5952
5955
  export type Optimization = z.infer<typeof optimization>;
5953
5956
  declare const rspackFutureOptions: z.ZodObject<{
@@ -7962,6 +7965,7 @@ export declare const rspackOptions: z.ZodObject<{
7962
7965
  usedExports: z.ZodOptional<z.ZodUnion<[z.ZodEnum<["global"]>, z.ZodBoolean]>>;
7963
7966
  mangleExports: z.ZodOptional<z.ZodUnion<[z.ZodEnum<["size", "deterministic"]>, z.ZodBoolean]>>;
7964
7967
  nodeEnv: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodLiteral<false>]>>;
7968
+ emitOnErrors: z.ZodOptional<z.ZodBoolean>;
7965
7969
  }, "strict", z.ZodTypeAny, {
7966
7970
  moduleIds?: "named" | "natural" | "deterministic" | undefined;
7967
7971
  chunkIds?: "named" | "natural" | "deterministic" | undefined;
@@ -8027,6 +8031,7 @@ export declare const rspackOptions: z.ZodObject<{
8027
8031
  innerGraph?: boolean | undefined;
8028
8032
  mangleExports?: boolean | "deterministic" | "size" | undefined;
8029
8033
  nodeEnv?: string | false | undefined;
8034
+ emitOnErrors?: boolean | undefined;
8030
8035
  }, {
8031
8036
  moduleIds?: "named" | "natural" | "deterministic" | undefined;
8032
8037
  chunkIds?: "named" | "natural" | "deterministic" | undefined;
@@ -8092,6 +8097,7 @@ export declare const rspackOptions: z.ZodObject<{
8092
8097
  innerGraph?: boolean | undefined;
8093
8098
  mangleExports?: boolean | "deterministic" | "size" | undefined;
8094
8099
  nodeEnv?: string | false | undefined;
8100
+ emitOnErrors?: boolean | undefined;
8095
8101
  }>>;
8096
8102
  resolve: z.ZodOptional<z.ZodType<ResolveOptions, z.ZodTypeDef, ResolveOptions>>;
8097
8103
  resolveLoader: z.ZodOptional<z.ZodType<ResolveOptions, z.ZodTypeDef, ResolveOptions>>;
@@ -9552,6 +9558,7 @@ export declare const rspackOptions: z.ZodObject<{
9552
9558
  innerGraph?: boolean | undefined;
9553
9559
  mangleExports?: boolean | "deterministic" | "size" | undefined;
9554
9560
  nodeEnv?: string | false | undefined;
9561
+ emitOnErrors?: boolean | undefined;
9555
9562
  } | undefined;
9556
9563
  resolveLoader?: ResolveOptions | undefined;
9557
9564
  plugins?: (false | "" | 0 | RspackPluginInstance | RspackPluginFunction | WebpackPluginInstance | WebpackPluginFunction | null | undefined)[] | undefined;
@@ -10124,6 +10131,7 @@ export declare const rspackOptions: z.ZodObject<{
10124
10131
  innerGraph?: boolean | undefined;
10125
10132
  mangleExports?: boolean | "deterministic" | "size" | undefined;
10126
10133
  nodeEnv?: string | false | undefined;
10134
+ emitOnErrors?: boolean | undefined;
10127
10135
  } | undefined;
10128
10136
  resolveLoader?: ResolveOptions | undefined;
10129
10137
  plugins?: (false | "" | 0 | RspackPluginInstance | RspackPluginFunction | WebpackPluginInstance | WebpackPluginFunction | null | undefined)[] | undefined;
@@ -846,7 +846,8 @@ const optimization = zod_1.z.strictObject({
846
846
  innerGraph: zod_1.z.boolean().optional(),
847
847
  usedExports: zod_1.z.enum(["global"]).or(zod_1.z.boolean()).optional(),
848
848
  mangleExports: zod_1.z.enum(["size", "deterministic"]).or(zod_1.z.boolean()).optional(),
849
- nodeEnv: zod_1.z.union([zod_1.z.string(), zod_1.z.literal(false)]).optional()
849
+ nodeEnv: zod_1.z.union([zod_1.z.string(), zod_1.z.literal(false)]).optional(),
850
+ emitOnErrors: zod_1.z.boolean().optional()
850
851
  });
851
852
  //#endregion
852
853
  //#region Experiments
@@ -3,6 +3,7 @@ import type { ModuleFederationPluginV1Options } from "./ModuleFederationPluginV1
3
3
  export interface ModuleFederationPluginOptions extends Omit<ModuleFederationPluginV1Options, "enhanced"> {
4
4
  runtimePlugins?: RuntimePlugins;
5
5
  implementation?: string;
6
+ shareStrategy?: "version-first" | "loaded-first";
6
7
  }
7
8
  export type RuntimePlugins = string[];
8
9
  export declare class ModuleFederationPlugin {
@@ -130,6 +130,7 @@ function getDefaultEntryRuntime(paths, options, compiler) {
130
130
  `const __module_federation_runtime_plugins__ = [${runtimePluginVars.join(", ")}]`,
131
131
  `const __module_federation_remote_infos__ = ${JSON.stringify(remoteInfos)}`,
132
132
  `const __module_federation_container_name__ = ${JSON.stringify(options.name ?? compiler.options.output.uniqueName)}`,
133
+ `const __module_federation_share_strategy__ = ${JSON.stringify(options.shareStrategy ?? "version-first")}`,
133
134
  compiler.webpack.Template.getFunctionContent(require("./default.runtime"))
134
135
  ].join(";");
135
136
  return `@module-federation/runtime/rspack.js!=!data:text/javascript,${content}`;