@rspack/core 0.6.3-canary-e4fdc75-20240428004651 → 0.6.3-canary-2ffdf97-20240430074011

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.
@@ -0,0 +1,11 @@
1
+ import { BuiltinPluginName, RawDynamicEntryPluginOptions } from "@rspack/binding";
2
+ import { EntryDynamicNormalized } from "../config";
3
+ export declare const DynamicEntryPlugin: {
4
+ new (context: string, entry: EntryDynamicNormalized): {
5
+ name: BuiltinPluginName;
6
+ _options: RawDynamicEntryPluginOptions;
7
+ 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;
8
+ raw(): import("@rspack/binding").BuiltinPlugin;
9
+ apply(compiler: import("../Compiler").Compiler): void;
10
+ };
11
+ };
@@ -0,0 +1,25 @@
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.DynamicEntryPlugin = void 0;
7
+ const binding_1 = require("@rspack/binding");
8
+ const base_1 = require("./base");
9
+ const EntryOptionPlugin_1 = __importDefault(require("../lib/EntryOptionPlugin"));
10
+ const EntryPlugin_1 = require("./EntryPlugin");
11
+ exports.DynamicEntryPlugin = (0, base_1.create)(binding_1.BuiltinPluginName.DynamicEntryPlugin, (context, entry) => {
12
+ return {
13
+ context,
14
+ entry: async () => {
15
+ const result = await entry();
16
+ return Object.entries(result).map(([name, desc]) => {
17
+ const options = EntryOptionPlugin_1.default.entryDescriptionToOptions({}, name, desc);
18
+ return {
19
+ import: desc.import,
20
+ options: (0, EntryPlugin_1.getRawEntryOptions)(options)
21
+ };
22
+ });
23
+ }
24
+ };
25
+ }, "make");
@@ -1,4 +1,4 @@
1
- import { BuiltinPluginName, RawEntryPluginOptions } from "@rspack/binding";
1
+ import { BuiltinPluginName, RawEntryOptions, RawEntryPluginOptions } from "@rspack/binding";
2
2
  import { ChunkLoading, EntryRuntime, FilenameTemplate, LibraryOptions, PublicPath } from "../config";
3
3
  export type EntryOptions = {
4
4
  name?: string;
@@ -20,3 +20,4 @@ export declare const EntryPlugin: {
20
20
  apply(compiler: import("../Compiler").Compiler): void;
21
21
  };
22
22
  };
23
+ export declare function getRawEntryOptions(entry: EntryOptions): RawEntryOptions;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.EntryPlugin = void 0;
3
+ exports.getRawEntryOptions = exports.EntryPlugin = void 0;
4
4
  const binding_1 = require("@rspack/binding");
5
5
  const base_1 = require("./base");
6
6
  const config_1 = require("../config");
@@ -20,7 +20,7 @@ function getRawEntryOptions(entry) {
20
20
  name: entry.name,
21
21
  publicPath: entry.publicPath,
22
22
  baseUri: entry.baseUri,
23
- runtime: !(0, util_1.isNil)(runtime) ? (0, config_1.getRawEntryRuntime)(runtime) : undefined,
23
+ runtime,
24
24
  chunkLoading: !(0, util_1.isNil)(chunkLoading)
25
25
  ? (0, config_1.getRawChunkLoading)(chunkLoading)
26
26
  : undefined,
@@ -30,3 +30,4 @@ function getRawEntryOptions(entry) {
30
30
  dependOn: entry.dependOn
31
31
  };
32
32
  }
33
+ exports.getRawEntryOptions = getRawEntryOptions;
@@ -0,0 +1,11 @@
1
+ import { BuiltinPluginName, RawRuntimeChunkOptions } from "@rspack/binding";
2
+ export type RuntimeChunkPluginOptions = RawRuntimeChunkOptions;
3
+ export declare const RuntimeChunkPlugin: {
4
+ new (options: RawRuntimeChunkOptions): {
5
+ name: BuiltinPluginName;
6
+ _options: RawRuntimeChunkOptions;
7
+ 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;
8
+ raw(): import("@rspack/binding").BuiltinPlugin;
9
+ apply(compiler: import("../Compiler").Compiler): void;
10
+ };
11
+ };
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RuntimeChunkPlugin = void 0;
4
+ const binding_1 = require("@rspack/binding");
5
+ const base_1 = require("./base");
6
+ exports.RuntimeChunkPlugin = (0, base_1.create)(binding_1.BuiltinPluginName.RuntimeChunkPlugin, (options) => options, "thisCompilation");
@@ -5,6 +5,7 @@ export * from "./BannerPlugin";
5
5
  export * from "./IgnorePlugin";
6
6
  export * from "./ProgressPlugin";
7
7
  export * from "./EntryPlugin";
8
+ export * from "./DynamicEntryPlugin";
8
9
  export * from "./ExternalsPlugin";
9
10
  export * from "./NodeTargetPlugin";
10
11
  export * from "./ElectronTargetPlugin";
@@ -49,6 +50,7 @@ export * from "./BundlerInfoRspackPlugin";
49
50
  export * from "./ModuleConcatenationPlugin";
50
51
  export * from "./CssModulesPlugin";
51
52
  export * from "./APIPlugin";
53
+ export * from "./RuntimeChunkPlugin";
52
54
  export * from "./HtmlRspackPlugin";
53
55
  export * from "./CopyRspackPlugin";
54
56
  export * from "./SwcJsMinimizerPlugin";
@@ -23,6 +23,7 @@ __exportStar(require("./BannerPlugin"), exports);
23
23
  __exportStar(require("./IgnorePlugin"), exports);
24
24
  __exportStar(require("./ProgressPlugin"), exports);
25
25
  __exportStar(require("./EntryPlugin"), exports);
26
+ __exportStar(require("./DynamicEntryPlugin"), exports);
26
27
  __exportStar(require("./ExternalsPlugin"), exports);
27
28
  __exportStar(require("./NodeTargetPlugin"), exports);
28
29
  __exportStar(require("./ElectronTargetPlugin"), exports);
@@ -67,6 +68,7 @@ __exportStar(require("./BundlerInfoRspackPlugin"), exports);
67
68
  __exportStar(require("./ModuleConcatenationPlugin"), exports);
68
69
  __exportStar(require("./CssModulesPlugin"), exports);
69
70
  __exportStar(require("./APIPlugin"), exports);
71
+ __exportStar(require("./RuntimeChunkPlugin"), exports);
70
72
  __exportStar(require("./HtmlRspackPlugin"), exports);
71
73
  __exportStar(require("./CopyRspackPlugin"), exports);
72
74
  __exportStar(require("./SwcJsMinimizerPlugin"), exports);
@@ -1,10 +1,9 @@
1
1
  import type { RawOptions, RawLibraryOptions } from "@rspack/binding";
2
2
  import { Compiler } from "../Compiler";
3
3
  import { LoaderContext, LoaderDefinition, LoaderDefinitionFunction } from "./adapterRuleUse";
4
- import { LibraryOptions, EntryRuntime, ChunkLoading } from "./zod";
4
+ import { LibraryOptions, ChunkLoading } from "./zod";
5
5
  import { RspackOptionsNormalized } from "./normalization";
6
6
  export type { LoaderContext, LoaderDefinition, LoaderDefinitionFunction };
7
7
  export declare const getRawOptions: (options: RspackOptionsNormalized, compiler: Compiler) => RawOptions;
8
8
  export declare function getRawLibrary(library: LibraryOptions): RawLibraryOptions;
9
- export declare function getRawEntryRuntime(runtime: EntryRuntime): string | undefined;
10
9
  export declare function getRawChunkLoading(chunkLoading: ChunkLoading): string;
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getRawChunkLoading = exports.getRawEntryRuntime = exports.getRawLibrary = exports.getRawOptions = void 0;
6
+ exports.getRawChunkLoading = exports.getRawLibrary = exports.getRawOptions = void 0;
7
7
  const assert_1 = __importDefault(require("assert"));
8
8
  const Stats_1 = require("../Stats");
9
9
  const util_1 = require("../util");
@@ -647,10 +647,6 @@ function getRawStats(stats) {
647
647
  colors: (_a = statsOptions.colors) !== null && _a !== void 0 ? _a : false
648
648
  };
649
649
  }
650
- function getRawEntryRuntime(runtime) {
651
- return runtime === false ? undefined : runtime;
652
- }
653
- exports.getRawEntryRuntime = getRawEntryRuntime;
654
650
  function getRawChunkLoading(chunkLoading) {
655
651
  return chunkLoading === false ? "false" : chunkLoading;
656
652
  }
@@ -127,12 +127,24 @@ const applyExperimentsDefaults = (experiments, { cache }) => {
127
127
  }
128
128
  };
129
129
  const applySnapshotDefaults = (snapshot, { production }) => {
130
- F(snapshot, "module", () => production
131
- ? { timestamp: true, hash: true }
132
- : { timestamp: true, hash: false });
133
- F(snapshot, "resolve", () => production
134
- ? { timestamp: true, hash: true }
135
- : { timestamp: true, hash: false });
130
+ if (typeof snapshot.module === "object") {
131
+ D(snapshot.module, "timestamp", false);
132
+ D(snapshot.module, "hash", false);
133
+ }
134
+ else {
135
+ F(snapshot, "module", () => production
136
+ ? { timestamp: true, hash: true }
137
+ : { timestamp: true, hash: false });
138
+ }
139
+ if (typeof snapshot.resolve === "object") {
140
+ D(snapshot.resolve, "timestamp", false);
141
+ D(snapshot.resolve, "hash", false);
142
+ }
143
+ else {
144
+ F(snapshot, "resolve", () => production
145
+ ? { timestamp: true, hash: true }
146
+ : { timestamp: true, hash: false });
147
+ }
136
148
  };
137
149
  const applyJavascriptParserOptionsDefaults = (parserOptions, fallback) => {
138
150
  var _a, _b, _c, _d, _e, _f;
@@ -520,6 +532,9 @@ const applyOutputDefaults = (output, { context, outputModule, targetProperties:
520
532
  F(trustedTypes, "policyName", () => output.uniqueName.replace(/[^a-zA-Z0-9\-#=_/@.%]+/g, "_") || "webpack");
521
533
  }
522
534
  const forEachEntry = (fn) => {
535
+ if (typeof entry === "function") {
536
+ return;
537
+ }
523
538
  for (const name of Object.keys(entry)) {
524
539
  fn(entry[name]);
525
540
  }
@@ -10,7 +10,8 @@
10
10
  import type { Compilation } from "../Compilation";
11
11
  import type { Context, Dependencies, Node, DevTool, Externals, ExternalsPresets, ExternalsType, InfrastructureLogging, LibraryOptions, Mode, Name, Resolve, Target, SnapshotOptions, CacheOptions, StatsValue, Optimization, Plugins, Watch, WatchOptions, DevServer, Profile, Bail, Builtins, EntryRuntime, ChunkLoading, PublicPath, EntryFilename, Path, Clean, Filename, ChunkFilename, CrossOriginLoading, CssFilename, CssChunkFilename, HotUpdateMainFilename, HotUpdateChunkFilename, AssetModuleFilename, UniqueName, ChunkLoadingGlobal, EnabledLibraryTypes, OutputModule, StrictModuleErrorHandling, GlobalObject, ImportFunctionName, Iife, WasmLoading, EnabledWasmLoadingTypes, WebassemblyModuleFilename, TrustedTypes, SourceMapFilename, HashDigest, HashDigestLength, HashFunction, HashSalt, WorkerPublicPath, RuleSetRules, ParserOptionsByModuleType, GeneratorOptionsByModuleType, RspackFutureOptions, HotUpdateGlobal, ScriptType, NoParseOption, DevtoolNamespace, DevtoolModuleFilenameTemplate, DevtoolFallbackModuleFilenameTemplate, RspackOptions } from "./zod";
12
12
  export declare const getNormalizedRspackOptions: (config: RspackOptions) => RspackOptionsNormalized;
13
- export type EntryNormalized = EntryStaticNormalized;
13
+ export type EntryDynamicNormalized = () => Promise<EntryStaticNormalized>;
14
+ export type EntryNormalized = EntryDynamicNormalized | EntryStaticNormalized;
14
15
  export interface EntryStaticNormalized {
15
16
  [k: string]: EntryDescriptionNormalized;
16
17
  }
@@ -88,7 +89,9 @@ export interface ExperimentsNormalized {
88
89
  }
89
90
  export type IgnoreWarningsNormalized = ((warning: Error, compilation: Compilation) => boolean)[];
90
91
  export type OptimizationRuntimeChunkNormalized = false | {
91
- name: (...args: any[]) => string | undefined;
92
+ name: string | ((entrypoint: {
93
+ name: string;
94
+ }) => string);
92
95
  };
93
96
  export interface RspackOptionsNormalized {
94
97
  name?: Name;
@@ -30,7 +30,9 @@ const getNormalizedRspackOptions = (config) => {
30
30
  mode: config.mode,
31
31
  entry: config.entry === undefined
32
32
  ? { main: {} }
33
- : getNormalizedEntryStatic(typeof config.entry === "function" ? config.entry() : config.entry),
33
+ : typeof config.entry === "function"
34
+ ? (fn => () => Promise.resolve().then(fn).then(getNormalizedEntryStatic))(config.entry)
35
+ : getNormalizedEntryStatic(config.entry),
34
36
  output: nestedConfig(config.output, output => {
35
37
  var _a;
36
38
  const { library } = output;
@@ -255,19 +257,20 @@ const getNormalizedOptimizationRuntimeChunk = (runtimeChunk) => {
255
257
  return false;
256
258
  if (runtimeChunk === "single") {
257
259
  return {
258
- name: () => "runtime"
260
+ name: "single"
259
261
  };
260
262
  }
261
263
  if (runtimeChunk === true || runtimeChunk === "multiple") {
262
264
  return {
263
- name: (entrypoint) => `runtime~${entrypoint.name}`
265
+ name: "multiple"
264
266
  };
265
267
  }
266
- const { name } = runtimeChunk;
267
- const opts = {
268
- name: typeof name === "function" ? name : () => name
269
- };
270
- return opts;
268
+ if (runtimeChunk.name) {
269
+ const opts = {
270
+ name: runtimeChunk.name
271
+ };
272
+ return opts;
273
+ }
271
274
  };
272
275
  const nestedConfig = (value, fn) => value === undefined ? fn({}) : fn(value);
273
276
  const optionalNestedConfig = (value, fn) => (value === undefined ? undefined : fn(value));
@@ -3850,11 +3850,21 @@ export type RspackPluginFunction = (this: Compiler, compiler: Compiler) => void;
3850
3850
  declare const plugins: z.ZodArray<z.ZodUnion<[z.ZodType<RspackPluginInstance, z.ZodTypeDef, RspackPluginInstance>, z.ZodType<RspackPluginFunction, z.ZodTypeDef, RspackPluginFunction>, z.ZodUnion<[z.ZodLiteral<false>, z.ZodLiteral<0>, z.ZodLiteral<"">, z.ZodNull, z.ZodUndefined]>]>, "many">;
3851
3851
  export type Plugins = z.infer<typeof plugins>;
3852
3852
  declare const optimizationRuntimeChunk: z.ZodUnion<[z.ZodUnion<[z.ZodEnum<["single", "multiple"]>, z.ZodBoolean]>, z.ZodObject<{
3853
- name: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnion<[z.ZodString, z.ZodUndefined]>>]>>;
3853
+ name: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodFunction<z.ZodTuple<[z.ZodObject<{
3854
+ name: z.ZodString;
3855
+ }, "strict", z.ZodTypeAny, {
3856
+ name: string;
3857
+ }, {
3858
+ name: string;
3859
+ }>], z.ZodUnknown>, z.ZodString>]>>;
3854
3860
  }, "strict", z.ZodTypeAny, {
3855
- name?: string | ((...args: unknown[]) => string | undefined) | undefined;
3861
+ name?: string | ((args_0: {
3862
+ name: string;
3863
+ }, ...args_1: unknown[]) => string) | undefined;
3856
3864
  }, {
3857
- name?: string | ((...args: unknown[]) => string | undefined) | undefined;
3865
+ name?: string | ((args_0: {
3866
+ name: string;
3867
+ }, ...args_1: unknown[]) => string) | undefined;
3858
3868
  }>]>;
3859
3869
  export type OptimizationRuntimeChunk = z.infer<typeof optimizationRuntimeChunk>;
3860
3870
  declare const optimizationSplitChunksNameFunction: z.ZodFunction<z.ZodTuple<[z.ZodOptional<z.ZodType<Module, z.ZodTypeDef, Module>>], z.ZodUnknown>, z.ZodUnknown>;
@@ -4252,11 +4262,21 @@ declare const optimization: z.ZodObject<{
4252
4262
  hidePathInfo?: boolean | undefined;
4253
4263
  }>]>>;
4254
4264
  runtimeChunk: z.ZodOptional<z.ZodUnion<[z.ZodUnion<[z.ZodEnum<["single", "multiple"]>, z.ZodBoolean]>, z.ZodObject<{
4255
- name: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnion<[z.ZodString, z.ZodUndefined]>>]>>;
4265
+ name: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodFunction<z.ZodTuple<[z.ZodObject<{
4266
+ name: z.ZodString;
4267
+ }, "strict", z.ZodTypeAny, {
4268
+ name: string;
4269
+ }, {
4270
+ name: string;
4271
+ }>], z.ZodUnknown>, z.ZodString>]>>;
4256
4272
  }, "strict", z.ZodTypeAny, {
4257
- name?: string | ((...args: unknown[]) => string | undefined) | undefined;
4273
+ name?: string | ((args_0: {
4274
+ name: string;
4275
+ }, ...args_1: unknown[]) => string) | undefined;
4258
4276
  }, {
4259
- name?: string | ((...args: unknown[]) => string | undefined) | undefined;
4277
+ name?: string | ((args_0: {
4278
+ name: string;
4279
+ }, ...args_1: unknown[]) => string) | undefined;
4260
4280
  }>]>>;
4261
4281
  removeAvailableModules: z.ZodOptional<z.ZodBoolean>;
4262
4282
  removeEmptyChunks: z.ZodOptional<z.ZodBoolean>;
@@ -4315,7 +4335,9 @@ declare const optimization: z.ZodObject<{
4315
4335
  hidePathInfo?: boolean | undefined;
4316
4336
  } | undefined;
4317
4337
  runtimeChunk?: boolean | "single" | "multiple" | {
4318
- name?: string | ((...args: unknown[]) => string | undefined) | undefined;
4338
+ name?: string | ((args_0: {
4339
+ name: string;
4340
+ }, ...args_1: unknown[]) => string) | undefined;
4319
4341
  } | undefined;
4320
4342
  removeAvailableModules?: boolean | undefined;
4321
4343
  removeEmptyChunks?: boolean | undefined;
@@ -4374,7 +4396,9 @@ declare const optimization: z.ZodObject<{
4374
4396
  hidePathInfo?: boolean | undefined;
4375
4397
  } | undefined;
4376
4398
  runtimeChunk?: boolean | "single" | "multiple" | {
4377
- name?: string | ((...args: unknown[]) => string | undefined) | undefined;
4399
+ name?: string | ((args_0: {
4400
+ name: string;
4401
+ }, ...args_1: unknown[]) => string) | undefined;
4378
4402
  } | undefined;
4379
4403
  removeAvailableModules?: boolean | undefined;
4380
4404
  removeEmptyChunks?: boolean | undefined;
@@ -5600,11 +5624,21 @@ export declare const rspackOptions: z.ZodObject<{
5600
5624
  hidePathInfo?: boolean | undefined;
5601
5625
  }>]>>;
5602
5626
  runtimeChunk: z.ZodOptional<z.ZodUnion<[z.ZodUnion<[z.ZodEnum<["single", "multiple"]>, z.ZodBoolean]>, z.ZodObject<{
5603
- name: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnion<[z.ZodString, z.ZodUndefined]>>]>>;
5627
+ name: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodFunction<z.ZodTuple<[z.ZodObject<{
5628
+ name: z.ZodString;
5629
+ }, "strict", z.ZodTypeAny, {
5630
+ name: string;
5631
+ }, {
5632
+ name: string;
5633
+ }>], z.ZodUnknown>, z.ZodString>]>>;
5604
5634
  }, "strict", z.ZodTypeAny, {
5605
- name?: string | ((...args: unknown[]) => string | undefined) | undefined;
5635
+ name?: string | ((args_0: {
5636
+ name: string;
5637
+ }, ...args_1: unknown[]) => string) | undefined;
5606
5638
  }, {
5607
- name?: string | ((...args: unknown[]) => string | undefined) | undefined;
5639
+ name?: string | ((args_0: {
5640
+ name: string;
5641
+ }, ...args_1: unknown[]) => string) | undefined;
5608
5642
  }>]>>;
5609
5643
  removeAvailableModules: z.ZodOptional<z.ZodBoolean>;
5610
5644
  removeEmptyChunks: z.ZodOptional<z.ZodBoolean>;
@@ -5663,7 +5697,9 @@ export declare const rspackOptions: z.ZodObject<{
5663
5697
  hidePathInfo?: boolean | undefined;
5664
5698
  } | undefined;
5665
5699
  runtimeChunk?: boolean | "single" | "multiple" | {
5666
- name?: string | ((...args: unknown[]) => string | undefined) | undefined;
5700
+ name?: string | ((args_0: {
5701
+ name: string;
5702
+ }, ...args_1: unknown[]) => string) | undefined;
5667
5703
  } | undefined;
5668
5704
  removeAvailableModules?: boolean | undefined;
5669
5705
  removeEmptyChunks?: boolean | undefined;
@@ -5722,7 +5758,9 @@ export declare const rspackOptions: z.ZodObject<{
5722
5758
  hidePathInfo?: boolean | undefined;
5723
5759
  } | undefined;
5724
5760
  runtimeChunk?: boolean | "single" | "multiple" | {
5725
- name?: string | ((...args: unknown[]) => string | undefined) | undefined;
5761
+ name?: string | ((args_0: {
5762
+ name: string;
5763
+ }, ...args_1: unknown[]) => string) | undefined;
5726
5764
  } | undefined;
5727
5765
  removeAvailableModules?: boolean | undefined;
5728
5766
  removeEmptyChunks?: boolean | undefined;
@@ -6672,7 +6710,9 @@ export declare const rspackOptions: z.ZodObject<{
6672
6710
  hidePathInfo?: boolean | undefined;
6673
6711
  } | undefined;
6674
6712
  runtimeChunk?: boolean | "single" | "multiple" | {
6675
- name?: string | ((...args: unknown[]) => string | undefined) | undefined;
6713
+ name?: string | ((args_0: {
6714
+ name: string;
6715
+ }, ...args_1: unknown[]) => string) | undefined;
6676
6716
  } | undefined;
6677
6717
  removeAvailableModules?: boolean | undefined;
6678
6718
  removeEmptyChunks?: boolean | undefined;
@@ -7086,7 +7126,9 @@ export declare const rspackOptions: z.ZodObject<{
7086
7126
  hidePathInfo?: boolean | undefined;
7087
7127
  } | undefined;
7088
7128
  runtimeChunk?: boolean | "single" | "multiple" | {
7089
- name?: string | ((...args: unknown[]) => string | undefined) | undefined;
7129
+ name?: string | ((args_0: {
7130
+ name: string;
7131
+ }, ...args_1: unknown[]) => string) | undefined;
7090
7132
  } | undefined;
7091
7133
  removeAvailableModules?: boolean | undefined;
7092
7134
  removeEmptyChunks?: boolean | undefined;
@@ -657,7 +657,10 @@ const optimizationRuntimeChunk = zod_1.z
657
657
  .or(zod_1.z.strictObject({
658
658
  name: zod_1.z
659
659
  .string()
660
- .or(zod_1.z.function().returns(zod_1.z.string().or(zod_1.z.undefined())))
660
+ .or(zod_1.z
661
+ .function()
662
+ .args(zod_1.z.strictObject({ name: zod_1.z.string() }))
663
+ .returns(zod_1.z.string()))
661
664
  .optional()
662
665
  }));
663
666
  const optimizationSplitChunksNameFunction = zod_1.z.function().args(zod_1.z.instanceof(Module_1.Module).optional()
@@ -4,7 +4,6 @@ exports.ContainerPlugin = void 0;
4
4
  const binding_1 = require("@rspack/binding");
5
5
  const base_1 = require("../builtin-plugin/base");
6
6
  const config_1 = require("../config");
7
- const util_1 = require("../util");
8
7
  const options_1 = require("../container/options");
9
8
  const ShareRuntimePlugin_1 = require("../sharing/ShareRuntimePlugin");
10
9
  class ContainerPlugin extends base_1.RspackBuiltinPlugin {
@@ -41,7 +40,7 @@ class ContainerPlugin extends base_1.RspackBuiltinPlugin {
41
40
  name,
42
41
  shareScope,
43
42
  library: (0, config_1.getRawLibrary)(library),
44
- runtime: !(0, util_1.isNil)(runtime) ? (0, config_1.getRawEntryRuntime)(runtime) : undefined,
43
+ runtime,
45
44
  filename,
46
45
  exposes: exposes.map(([key, r]) => ({ key, ...r })),
47
46
  enhanced
package/dist/exports.d.ts CHANGED
@@ -48,6 +48,7 @@ export { ProgressPlugin } from "./builtin-plugin";
48
48
  export type { ProgressPluginArgument } from "./builtin-plugin";
49
49
  export { EntryPlugin } from "./builtin-plugin";
50
50
  export type { EntryOptions } from "./builtin-plugin";
51
+ export { DynamicEntryPlugin } from "./builtin-plugin";
51
52
  export { ExternalsPlugin } from "./builtin-plugin";
52
53
  export { HotModuleReplacementPlugin } from "./builtin-plugin";
53
54
  export { LoaderOptionsPlugin } from "./lib/LoaderOptionsPlugin";
@@ -87,8 +88,10 @@ interface Webworker {
87
88
  }
88
89
  export declare const webworker: Webworker;
89
90
  import { LimitChunkCountPlugin } from "./builtin-plugin";
91
+ import { RuntimeChunkPlugin } from "./builtin-plugin";
90
92
  interface Optimize {
91
93
  LimitChunkCountPlugin: typeof LimitChunkCountPlugin;
94
+ RuntimeChunkPlugin: typeof RuntimeChunkPlugin;
92
95
  }
93
96
  export declare const optimize: Optimize;
94
97
  import { ModuleFederationPlugin } from "./container/ModuleFederationPlugin";
package/dist/exports.js CHANGED
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.CssExtractRspackPlugin = exports.EvalDevToolModulePlugin = exports.EvalSourceMapDevToolPlugin = exports.SourceMapDevToolPlugin = exports.CopyRspackPlugin = exports.SwcCssMinimizerRspackPlugin = exports.SwcJsMinimizerRspackPlugin = exports.HtmlRspackPlugin = exports.sharing = exports.container = exports.optimize = exports.webworker = exports.javascript = exports.wasm = exports.library = exports.electron = exports.node = exports.NormalModuleReplacementPlugin = exports.EnvironmentPlugin = exports.LoaderTargetPlugin = exports.LoaderOptionsPlugin = exports.HotModuleReplacementPlugin = exports.ExternalsPlugin = exports.EntryPlugin = exports.ProgressPlugin = exports.DefinePlugin = exports.ProvidePlugin = exports.IgnorePlugin = exports.BannerPlugin = exports.EntryOptionPlugin = exports.experimental_cleanupGlobalTrace = exports.experimental_registerGlobalTrace = exports.util = exports.config = exports.sources = exports.WebpackError = exports.Template = exports.ModuleFilenameHelpers = exports.NormalModule = exports.MultiStats = exports.Stats = exports.RuntimeGlobals = exports.WebpackOptionsApply = exports.RspackOptionsApply = exports.MultiCompiler = exports.Compilation = exports.Compiler = exports.rspackVersion = exports.version = void 0;
29
+ exports.CssExtractRspackPlugin = exports.EvalDevToolModulePlugin = exports.EvalSourceMapDevToolPlugin = exports.SourceMapDevToolPlugin = exports.CopyRspackPlugin = exports.SwcCssMinimizerRspackPlugin = exports.SwcJsMinimizerRspackPlugin = exports.HtmlRspackPlugin = exports.sharing = exports.container = exports.optimize = exports.webworker = exports.javascript = exports.wasm = exports.library = exports.electron = exports.node = exports.NormalModuleReplacementPlugin = exports.EnvironmentPlugin = exports.LoaderTargetPlugin = exports.LoaderOptionsPlugin = exports.HotModuleReplacementPlugin = exports.ExternalsPlugin = exports.DynamicEntryPlugin = exports.EntryPlugin = exports.ProgressPlugin = exports.DefinePlugin = exports.ProvidePlugin = exports.IgnorePlugin = exports.BannerPlugin = exports.EntryOptionPlugin = exports.experimental_cleanupGlobalTrace = exports.experimental_registerGlobalTrace = exports.util = exports.config = exports.sources = exports.WebpackError = exports.Template = exports.ModuleFilenameHelpers = exports.NormalModule = exports.MultiStats = exports.Stats = exports.RuntimeGlobals = exports.WebpackOptionsApply = exports.RspackOptionsApply = exports.MultiCompiler = exports.Compilation = exports.Compiler = exports.rspackVersion = exports.version = void 0;
30
30
  const { version: rspackVersion, webpackVersion } = require("../package.json");
31
31
  exports.rspackVersion = rspackVersion;
32
32
  exports.version = webpackVersion;
@@ -85,9 +85,11 @@ Object.defineProperty(exports, "ProgressPlugin", { enumerable: true, get: functi
85
85
  var builtin_plugin_6 = require("./builtin-plugin");
86
86
  Object.defineProperty(exports, "EntryPlugin", { enumerable: true, get: function () { return builtin_plugin_6.EntryPlugin; } });
87
87
  var builtin_plugin_7 = require("./builtin-plugin");
88
- Object.defineProperty(exports, "ExternalsPlugin", { enumerable: true, get: function () { return builtin_plugin_7.ExternalsPlugin; } });
88
+ Object.defineProperty(exports, "DynamicEntryPlugin", { enumerable: true, get: function () { return builtin_plugin_7.DynamicEntryPlugin; } });
89
89
  var builtin_plugin_8 = require("./builtin-plugin");
90
- Object.defineProperty(exports, "HotModuleReplacementPlugin", { enumerable: true, get: function () { return builtin_plugin_8.HotModuleReplacementPlugin; } });
90
+ Object.defineProperty(exports, "ExternalsPlugin", { enumerable: true, get: function () { return builtin_plugin_8.ExternalsPlugin; } });
91
+ var builtin_plugin_9 = require("./builtin-plugin");
92
+ Object.defineProperty(exports, "HotModuleReplacementPlugin", { enumerable: true, get: function () { return builtin_plugin_9.HotModuleReplacementPlugin; } });
91
93
  var LoaderOptionsPlugin_1 = require("./lib/LoaderOptionsPlugin");
92
94
  Object.defineProperty(exports, "LoaderOptionsPlugin", { enumerable: true, get: function () { return LoaderOptionsPlugin_1.LoaderOptionsPlugin; } });
93
95
  var LoaderTargetPlugin_1 = require("./lib/LoaderTargetPlugin");
@@ -97,20 +99,21 @@ Object.defineProperty(exports, "EnvironmentPlugin", { enumerable: true, get: fun
97
99
  var NormalModuleReplacementPlugin_1 = require("./lib/NormalModuleReplacementPlugin");
98
100
  Object.defineProperty(exports, "NormalModuleReplacementPlugin", { enumerable: true, get: function () { return NormalModuleReplacementPlugin_1.NormalModuleReplacementPlugin; } });
99
101
  const NodeTemplatePlugin_1 = __importDefault(require("./node/NodeTemplatePlugin"));
100
- const builtin_plugin_9 = require("./builtin-plugin");
101
- exports.node = { NodeTargetPlugin: builtin_plugin_9.NodeTargetPlugin, NodeTemplatePlugin: NodeTemplatePlugin_1.default };
102
102
  const builtin_plugin_10 = require("./builtin-plugin");
103
- exports.electron = { ElectronTargetPlugin: builtin_plugin_10.ElectronTargetPlugin };
103
+ exports.node = { NodeTargetPlugin: builtin_plugin_10.NodeTargetPlugin, NodeTemplatePlugin: NodeTemplatePlugin_1.default };
104
104
  const builtin_plugin_11 = require("./builtin-plugin");
105
- exports.library = { EnableLibraryPlugin: builtin_plugin_11.EnableLibraryPlugin };
105
+ exports.electron = { ElectronTargetPlugin: builtin_plugin_11.ElectronTargetPlugin };
106
106
  const builtin_plugin_12 = require("./builtin-plugin");
107
- exports.wasm = { EnableWasmLoadingPlugin: builtin_plugin_12.EnableWasmLoadingPlugin };
107
+ exports.library = { EnableLibraryPlugin: builtin_plugin_12.EnableLibraryPlugin };
108
108
  const builtin_plugin_13 = require("./builtin-plugin");
109
- exports.javascript = { EnableChunkLoadingPlugin: builtin_plugin_13.EnableChunkLoadingPlugin };
109
+ exports.wasm = { EnableWasmLoadingPlugin: builtin_plugin_13.EnableWasmLoadingPlugin };
110
110
  const builtin_plugin_14 = require("./builtin-plugin");
111
- exports.webworker = { WebWorkerTemplatePlugin: builtin_plugin_14.WebWorkerTemplatePlugin };
111
+ exports.javascript = { EnableChunkLoadingPlugin: builtin_plugin_14.EnableChunkLoadingPlugin };
112
112
  const builtin_plugin_15 = require("./builtin-plugin");
113
- exports.optimize = { LimitChunkCountPlugin: builtin_plugin_15.LimitChunkCountPlugin };
113
+ exports.webworker = { WebWorkerTemplatePlugin: builtin_plugin_15.WebWorkerTemplatePlugin };
114
+ const builtin_plugin_16 = require("./builtin-plugin");
115
+ const builtin_plugin_17 = require("./builtin-plugin");
116
+ exports.optimize = { LimitChunkCountPlugin: builtin_plugin_16.LimitChunkCountPlugin, RuntimeChunkPlugin: builtin_plugin_17.RuntimeChunkPlugin };
114
117
  const ModuleFederationPlugin_1 = require("./container/ModuleFederationPlugin");
115
118
  const ModuleFederationPluginV1_1 = require("./container/ModuleFederationPluginV1");
116
119
  const ContainerPlugin_1 = require("./container/ContainerPlugin");
@@ -130,19 +133,19 @@ exports.sharing = {
130
133
  SharePlugin: SharePlugin_1.SharePlugin
131
134
  };
132
135
  ///// Rspack Postfixed Internal Plugins /////
133
- var builtin_plugin_16 = require("./builtin-plugin");
134
- Object.defineProperty(exports, "HtmlRspackPlugin", { enumerable: true, get: function () { return builtin_plugin_16.HtmlRspackPlugin; } });
135
- var builtin_plugin_17 = require("./builtin-plugin");
136
- Object.defineProperty(exports, "SwcJsMinimizerRspackPlugin", { enumerable: true, get: function () { return builtin_plugin_17.SwcJsMinimizerRspackPlugin; } });
137
136
  var builtin_plugin_18 = require("./builtin-plugin");
138
- Object.defineProperty(exports, "SwcCssMinimizerRspackPlugin", { enumerable: true, get: function () { return builtin_plugin_18.SwcCssMinimizerRspackPlugin; } });
137
+ Object.defineProperty(exports, "HtmlRspackPlugin", { enumerable: true, get: function () { return builtin_plugin_18.HtmlRspackPlugin; } });
139
138
  var builtin_plugin_19 = require("./builtin-plugin");
140
- Object.defineProperty(exports, "CopyRspackPlugin", { enumerable: true, get: function () { return builtin_plugin_19.CopyRspackPlugin; } });
139
+ Object.defineProperty(exports, "SwcJsMinimizerRspackPlugin", { enumerable: true, get: function () { return builtin_plugin_19.SwcJsMinimizerRspackPlugin; } });
141
140
  var builtin_plugin_20 = require("./builtin-plugin");
142
- Object.defineProperty(exports, "SourceMapDevToolPlugin", { enumerable: true, get: function () { return builtin_plugin_20.SourceMapDevToolPlugin; } });
141
+ Object.defineProperty(exports, "SwcCssMinimizerRspackPlugin", { enumerable: true, get: function () { return builtin_plugin_20.SwcCssMinimizerRspackPlugin; } });
143
142
  var builtin_plugin_21 = require("./builtin-plugin");
144
- Object.defineProperty(exports, "EvalSourceMapDevToolPlugin", { enumerable: true, get: function () { return builtin_plugin_21.EvalSourceMapDevToolPlugin; } });
143
+ Object.defineProperty(exports, "CopyRspackPlugin", { enumerable: true, get: function () { return builtin_plugin_21.CopyRspackPlugin; } });
145
144
  var builtin_plugin_22 = require("./builtin-plugin");
146
- Object.defineProperty(exports, "EvalDevToolModulePlugin", { enumerable: true, get: function () { return builtin_plugin_22.EvalDevToolModulePlugin; } });
145
+ Object.defineProperty(exports, "SourceMapDevToolPlugin", { enumerable: true, get: function () { return builtin_plugin_22.SourceMapDevToolPlugin; } });
147
146
  var builtin_plugin_23 = require("./builtin-plugin");
148
- Object.defineProperty(exports, "CssExtractRspackPlugin", { enumerable: true, get: function () { return builtin_plugin_23.CssExtractRspackPlugin; } });
147
+ Object.defineProperty(exports, "EvalSourceMapDevToolPlugin", { enumerable: true, get: function () { return builtin_plugin_23.EvalSourceMapDevToolPlugin; } });
148
+ var builtin_plugin_24 = require("./builtin-plugin");
149
+ Object.defineProperty(exports, "EvalDevToolModulePlugin", { enumerable: true, get: function () { return builtin_plugin_24.EvalDevToolModulePlugin; } });
150
+ var builtin_plugin_25 = require("./builtin-plugin");
151
+ Object.defineProperty(exports, "CssExtractRspackPlugin", { enumerable: true, get: function () { return builtin_plugin_25.CssExtractRspackPlugin; } });
@@ -22,10 +22,8 @@ class EntryOptionPlugin {
22
22
  });
23
23
  }
24
24
  static applyEntryOption(compiler, context, entry) {
25
- // TODO: dynamic entry is not supported yet
26
25
  if (typeof entry === "function") {
27
- // const DynamicEntryPlugin = require("./DynamicEntryPlugin");
28
- // new DynamicEntryPlugin(context, entry).apply(compiler);
26
+ new builtin_plugin_1.DynamicEntryPlugin(context, entry).apply(compiler);
29
27
  }
30
28
  else {
31
29
  for (const name of Object.keys(entry)) {
@@ -82,11 +82,7 @@ class RspackOptionsApply {
82
82
  const runtimeChunk = options.optimization
83
83
  .runtimeChunk;
84
84
  if (runtimeChunk) {
85
- Object.entries(options.entry).forEach(([entryName, value]) => {
86
- if (value.runtime === undefined && !value.dependOn) {
87
- value.runtime = runtimeChunk.name({ name: entryName });
88
- }
89
- });
85
+ new builtin_plugin_1.RuntimeChunkPlugin(runtimeChunk).apply(compiler);
90
86
  }
91
87
  if (options.devtool) {
92
88
  if (options.devtool.includes("source-map")) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rspack/core",
3
- "version": "0.6.3-canary-e4fdc75-20240428004651",
3
+ "version": "0.6.3-canary-2ffdf97-20240430074011",
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/plugin-minify": "^0.6.3-canary-e4fdc75-20240428004651",
64
- "@rspack/core": "0.6.3-canary-e4fdc75-20240428004651"
63
+ "@rspack/core": "0.6.3-canary-2ffdf97-20240430074011",
64
+ "@rspack/plugin-minify": "^0.6.3-canary-2ffdf97-20240430074011"
65
65
  },
66
66
  "dependencies": {
67
67
  "@module-federation/runtime-tools": "0.1.6",
@@ -75,7 +75,7 @@
75
75
  "webpack-sources": "3.2.3",
76
76
  "zod": "^3.21.4",
77
77
  "zod-validation-error": "1.3.1",
78
- "@rspack/binding": "0.6.3-canary-e4fdc75-20240428004651"
78
+ "@rspack/binding": "0.6.3-canary-2ffdf97-20240430074011"
79
79
  },
80
80
  "peerDependencies": {
81
81
  "@swc/helpers": ">=0.5.1"