@rspack/core 0.5.7 → 0.5.8-canary-2e1be96-20240321104547

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 (76) hide show
  1. package/dist/Chunk.d.ts +2 -0
  2. package/dist/Chunk.js +4 -0
  3. package/dist/Compilation.d.ts +17 -19
  4. package/dist/Compilation.js +10 -10
  5. package/dist/Compiler.d.ts +7 -6
  6. package/dist/Compiler.js +156 -240
  7. package/dist/Module.d.ts +3 -0
  8. package/dist/Module.js +12 -0
  9. package/dist/NormalModuleFactory.d.ts +2 -1
  10. package/dist/NormalModuleFactory.js +25 -1
  11. package/dist/Watching.js +2 -2
  12. package/dist/builtin-plugin/ArrayPushCallbackChunkFormatPlugin.d.ts +1 -1
  13. package/dist/builtin-plugin/AssetModulesPlugin.d.ts +1 -1
  14. package/dist/builtin-plugin/AsyncWebAssemblyModulesPlugin.d.ts +1 -1
  15. package/dist/builtin-plugin/BannerPlugin.d.ts +1 -1
  16. package/dist/builtin-plugin/BundlerInfoRspackPlugin.d.ts +1 -1
  17. package/dist/builtin-plugin/ChunkPrefetchPreloadPlugin.d.ts +1 -1
  18. package/dist/builtin-plugin/CommonJsChunkFormatPlugin.d.ts +1 -1
  19. package/dist/builtin-plugin/CopyRspackPlugin.d.ts +1 -1
  20. package/dist/builtin-plugin/DataUriPlugin.d.ts +1 -1
  21. package/dist/builtin-plugin/DefinePlugin.d.ts +1 -1
  22. package/dist/builtin-plugin/DeterministicChunkIdsPlugin.d.ts +1 -1
  23. package/dist/builtin-plugin/DeterministicModuleIdsPlugin.d.ts +1 -1
  24. package/dist/builtin-plugin/ElectronTargetPlugin.d.ts +1 -1
  25. package/dist/builtin-plugin/EnableChunkLoadingPlugin.d.ts +1 -1
  26. package/dist/builtin-plugin/EnableLibraryPlugin.d.ts +1 -1
  27. package/dist/builtin-plugin/EnableWasmLoadingPlugin.d.ts +1 -1
  28. package/dist/builtin-plugin/EnsureChunkConditionsPlugin.d.ts +1 -1
  29. package/dist/builtin-plugin/EntryPlugin.d.ts +1 -1
  30. package/dist/builtin-plugin/EvalDevToolModulePlugin.d.ts +1 -1
  31. package/dist/builtin-plugin/EvalSourceMapDevToolPlugin.d.ts +1 -1
  32. package/dist/builtin-plugin/ExternalsPlugin.d.ts +1 -1
  33. package/dist/builtin-plugin/FileUriPlugin.d.ts +1 -1
  34. package/dist/builtin-plugin/FlagDependencyExportsPlugin.d.ts +1 -1
  35. package/dist/builtin-plugin/FlagDependencyUsagePlugin.d.ts +1 -1
  36. package/dist/builtin-plugin/HtmlRspackPlugin.d.ts +1 -1
  37. package/dist/builtin-plugin/HttpExternalsRspackPlugin.d.ts +1 -1
  38. package/dist/builtin-plugin/InferAsyncModulesPlugin.d.ts +1 -1
  39. package/dist/builtin-plugin/JavascriptModulesPlugin.d.ts +1 -1
  40. package/dist/builtin-plugin/JsLoaderRspackPlugin.d.ts +11 -0
  41. package/dist/builtin-plugin/JsLoaderRspackPlugin.js +7 -0
  42. package/dist/builtin-plugin/JsonModulesPlugin.d.ts +1 -1
  43. package/dist/builtin-plugin/LimitChunkCountPlugin.d.ts +1 -1
  44. package/dist/builtin-plugin/MangleExportsPlugin.d.ts +1 -1
  45. package/dist/builtin-plugin/MergeDuplicateChunksPlugin.d.ts +1 -1
  46. package/dist/builtin-plugin/ModuleChunkFormatPlugin.d.ts +1 -1
  47. package/dist/builtin-plugin/ModuleConcatenationPlugin.d.ts +1 -1
  48. package/dist/builtin-plugin/NamedChunkIdsPlugin.d.ts +1 -1
  49. package/dist/builtin-plugin/NamedModuleIdsPlugin.d.ts +1 -1
  50. package/dist/builtin-plugin/NodeTargetPlugin.d.ts +1 -1
  51. package/dist/builtin-plugin/ProgressPlugin.d.ts +1 -1
  52. package/dist/builtin-plugin/ProvidePlugin.d.ts +1 -1
  53. package/dist/builtin-plugin/RealContentHashPlugin.d.ts +1 -1
  54. package/dist/builtin-plugin/RemoveEmptyChunksPlugin.d.ts +1 -1
  55. package/dist/builtin-plugin/RuntimePlugin.d.ts +1 -1
  56. package/dist/builtin-plugin/SideEffectsFlagPlugin.d.ts +1 -1
  57. package/dist/builtin-plugin/SourceMapDevToolPlugin.d.ts +1 -1
  58. package/dist/builtin-plugin/SwcCssMinimizerPlugin.d.ts +1 -1
  59. package/dist/builtin-plugin/SwcJsMinimizerPlugin.d.ts +1 -1
  60. package/dist/builtin-plugin/WarnCaseSensitiveModulesPlugin.d.ts +1 -1
  61. package/dist/builtin-plugin/WebWorkerTemplatePlugin.d.ts +1 -1
  62. package/dist/builtin-plugin/base.d.ts +1 -1
  63. package/dist/builtin-plugin/index.d.ts +1 -0
  64. package/dist/builtin-plugin/index.js +1 -0
  65. package/dist/config/adapter.js +9 -8
  66. package/dist/config/zod.d.ts +332 -78
  67. package/dist/config/zod.js +8 -1
  68. package/dist/exports.d.ts +27 -15
  69. package/dist/lite-tapable/index.d.ts +14 -1
  70. package/dist/lite-tapable/index.js +168 -1
  71. package/dist/loader-runner/index.d.ts +2 -2
  72. package/dist/loader-runner/index.js +4 -4
  73. package/dist/rspackOptionsApply.js +1 -0
  74. package/package.json +5 -5
  75. package/dist/util/normalization.d.ts +0 -5
  76. package/dist/util/normalization.js +0 -9
@@ -329,7 +329,14 @@ const assetGeneratorDataUrlOptions = zod_1.z.strictObject({
329
329
  encoding: zod_1.z.literal(false).or(zod_1.z.literal("base64")).optional(),
330
330
  mimetype: zod_1.z.string().optional()
331
331
  });
332
- const assetGeneratorDataUrl = assetGeneratorDataUrlOptions;
332
+ const assetGeneratorDataUrlFunction = zod_1.z
333
+ .function()
334
+ .args(zod_1.z.strictObject({
335
+ content: zod_1.z.string(),
336
+ filename: zod_1.z.string()
337
+ }))
338
+ .returns(zod_1.z.string());
339
+ const assetGeneratorDataUrl = assetGeneratorDataUrlOptions.or(assetGeneratorDataUrlFunction);
333
340
  const assetInlineGeneratorOptions = zod_1.z.strictObject({
334
341
  dataUrl: assetGeneratorDataUrl.optional()
335
342
  });
package/dist/exports.d.ts CHANGED
@@ -128,7 +128,7 @@ export declare const config: {
128
128
  devtoolModuleFilenameTemplate?: string | ((args_0: any) => any) | undefined;
129
129
  devtoolFallbackModuleFilenameTemplate?: string | ((args_0: any) => any) | undefined;
130
130
  } | undefined;
131
- target?: false | "node" | "async-node" | "es5" | "web" | "webworker" | "es3" | "es2015" | "es2016" | "es2017" | "es2018" | "es2019" | "es2020" | "es2021" | "es2022" | "browserslist" | `node${number}` | `async-node${number}` | `node${number}.${number}` | `async-node${number}.${number}` | "electron-main" | `electron${number}-main` | `electron${number}.${number}-main` | "electron-renderer" | `electron${number}-renderer` | `electron${number}.${number}-renderer` | "electron-preload" | `electron${number}-preload` | `electron${number}.${number}-preload` | ("node" | "async-node" | "es5" | "web" | "webworker" | "es3" | "es2015" | "es2016" | "es2017" | "es2018" | "es2019" | "es2020" | "es2021" | "es2022" | "browserslist" | `node${number}` | `async-node${number}` | `node${number}.${number}` | `async-node${number}.${number}` | "electron-main" | `electron${number}-main` | `electron${number}.${number}-main` | "electron-renderer" | `electron${number}-renderer` | `electron${number}.${number}-renderer` | "electron-preload" | `electron${number}-preload` | `electron${number}.${number}-preload`)[] | undefined;
131
+ target?: false | "node" | "async-node" | "web" | "webworker" | "es3" | "es5" | "es2015" | "es2016" | "es2017" | "es2018" | "es2019" | "es2020" | "es2021" | "es2022" | "browserslist" | `node${number}` | `async-node${number}` | `node${number}.${number}` | `async-node${number}.${number}` | "electron-main" | `electron${number}-main` | `electron${number}.${number}-main` | "electron-renderer" | `electron${number}-renderer` | `electron${number}.${number}-renderer` | "electron-preload" | `electron${number}-preload` | `electron${number}.${number}-preload` | ("node" | "async-node" | "web" | "webworker" | "es3" | "es5" | "es2015" | "es2016" | "es2017" | "es2018" | "es2019" | "es2020" | "es2021" | "es2022" | "browserslist" | `node${number}` | `async-node${number}` | `node${number}.${number}` | `async-node${number}.${number}` | "electron-main" | `electron${number}-main` | `electron${number}.${number}-main` | "electron-renderer" | `electron${number}-renderer` | `electron${number}.${number}-renderer` | "electron-preload" | `electron${number}-preload` | `electron${number}.${number}-preload`)[] | undefined;
132
132
  mode?: "production" | "development" | "none" | undefined;
133
133
  experiments?: {
134
134
  lazyCompilation?: boolean | undefined;
@@ -249,7 +249,7 @@ export declare const config: {
249
249
  moduleIds?: "named" | "deterministic" | undefined;
250
250
  chunkIds?: "named" | "deterministic" | undefined;
251
251
  minimize?: boolean | undefined;
252
- minimizer?: (false | "" | 0 | "..." | import("./config").RspackPluginInstance | import("./config").RspackPluginFunction | null | undefined)[] | undefined;
252
+ minimizer?: (false | "" | 0 | import("./config").RspackPluginInstance | "..." | import("./config").RspackPluginFunction | null | undefined)[] | undefined;
253
253
  mergeDuplicateChunks?: boolean | undefined;
254
254
  splitChunks?: false | {
255
255
  chunks?: RegExp | "async" | "initial" | "all" | ((args_0: import("./Chunk").Chunk, ...args_1: unknown[]) => boolean) | undefined;
@@ -329,7 +329,10 @@ export declare const config: {
329
329
  dataUrl?: {
330
330
  encoding?: false | "base64" | undefined;
331
331
  mimetype?: string | undefined;
332
- } | undefined;
332
+ } | ((args_0: {
333
+ filename: string;
334
+ content: string;
335
+ }, ...args_1: unknown[]) => string) | undefined;
333
336
  filename?: string | undefined;
334
337
  publicPath?: string | undefined;
335
338
  } | undefined;
@@ -337,7 +340,10 @@ export declare const config: {
337
340
  dataUrl?: {
338
341
  encoding?: false | "base64" | undefined;
339
342
  mimetype?: string | undefined;
340
- } | undefined;
343
+ } | ((args_0: {
344
+ filename: string;
345
+ content: string;
346
+ }, ...args_1: unknown[]) => string) | undefined;
341
347
  } | undefined;
342
348
  "asset/resource"?: {
343
349
  filename?: string | undefined;
@@ -456,7 +462,7 @@ export declare const config: {
456
462
  devtoolModuleFilenameTemplate?: string | ((args_0: any) => any) | undefined;
457
463
  devtoolFallbackModuleFilenameTemplate?: string | ((args_0: any) => any) | undefined;
458
464
  } | undefined;
459
- target?: false | "node" | "async-node" | "es5" | "web" | "webworker" | "es3" | "es2015" | "es2016" | "es2017" | "es2018" | "es2019" | "es2020" | "es2021" | "es2022" | "browserslist" | `node${number}` | `async-node${number}` | `node${number}.${number}` | `async-node${number}.${number}` | "electron-main" | `electron${number}-main` | `electron${number}.${number}-main` | "electron-renderer" | `electron${number}-renderer` | `electron${number}.${number}-renderer` | "electron-preload" | `electron${number}-preload` | `electron${number}.${number}-preload` | ("node" | "async-node" | "es5" | "web" | "webworker" | "es3" | "es2015" | "es2016" | "es2017" | "es2018" | "es2019" | "es2020" | "es2021" | "es2022" | "browserslist" | `node${number}` | `async-node${number}` | `node${number}.${number}` | `async-node${number}.${number}` | "electron-main" | `electron${number}-main` | `electron${number}.${number}-main` | "electron-renderer" | `electron${number}-renderer` | `electron${number}.${number}-renderer` | "electron-preload" | `electron${number}-preload` | `electron${number}.${number}-preload`)[] | undefined;
465
+ target?: false | "node" | "async-node" | "web" | "webworker" | "es3" | "es5" | "es2015" | "es2016" | "es2017" | "es2018" | "es2019" | "es2020" | "es2021" | "es2022" | "browserslist" | `node${number}` | `async-node${number}` | `node${number}.${number}` | `async-node${number}.${number}` | "electron-main" | `electron${number}-main` | `electron${number}.${number}-main` | "electron-renderer" | `electron${number}-renderer` | `electron${number}.${number}-renderer` | "electron-preload" | `electron${number}-preload` | `electron${number}.${number}-preload` | ("node" | "async-node" | "web" | "webworker" | "es3" | "es5" | "es2015" | "es2016" | "es2017" | "es2018" | "es2019" | "es2020" | "es2021" | "es2022" | "browserslist" | `node${number}` | `async-node${number}` | `node${number}.${number}` | `async-node${number}.${number}` | "electron-main" | `electron${number}-main` | `electron${number}.${number}-main` | "electron-renderer" | `electron${number}-renderer` | `electron${number}.${number}-renderer` | "electron-preload" | `electron${number}-preload` | `electron${number}.${number}-preload`)[] | undefined;
460
466
  mode?: "production" | "development" | "none" | undefined;
461
467
  experiments?: {
462
468
  lazyCompilation?: boolean | undefined;
@@ -577,7 +583,7 @@ export declare const config: {
577
583
  moduleIds?: "named" | "deterministic" | undefined;
578
584
  chunkIds?: "named" | "deterministic" | undefined;
579
585
  minimize?: boolean | undefined;
580
- minimizer?: (false | "" | 0 | "..." | import("./config").RspackPluginInstance | import("./config").RspackPluginFunction | null | undefined)[] | undefined;
586
+ minimizer?: (false | "" | 0 | import("./config").RspackPluginInstance | "..." | import("./config").RspackPluginFunction | null | undefined)[] | undefined;
581
587
  mergeDuplicateChunks?: boolean | undefined;
582
588
  splitChunks?: false | {
583
589
  chunks?: RegExp | "async" | "initial" | "all" | ((args_0: import("./Chunk").Chunk, ...args_1: unknown[]) => boolean) | undefined;
@@ -657,7 +663,10 @@ export declare const config: {
657
663
  dataUrl?: {
658
664
  encoding?: false | "base64" | undefined;
659
665
  mimetype?: string | undefined;
660
- } | undefined;
666
+ } | ((args_0: {
667
+ filename: string;
668
+ content: string;
669
+ }, ...args_1: unknown[]) => string) | undefined;
661
670
  filename?: string | undefined;
662
671
  publicPath?: string | undefined;
663
672
  } | undefined;
@@ -665,7 +674,10 @@ export declare const config: {
665
674
  dataUrl?: {
666
675
  encoding?: false | "base64" | undefined;
667
676
  mimetype?: string | undefined;
668
- } | undefined;
677
+ } | ((args_0: {
678
+ filename: string;
679
+ content: string;
680
+ }, ...args_1: unknown[]) => string) | undefined;
669
681
  } | undefined;
670
682
  "asset/resource"?: {
671
683
  filename?: string | undefined;
@@ -707,7 +719,7 @@ export declare const node: {
707
719
  new (): {
708
720
  name: import("@rspack/binding").BuiltinPluginName;
709
721
  _options: undefined;
710
- affectedHooks: "emit" | "done" | "compilation" | "make" | "compile" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishModules" | "finishMake" | "entryOption" | undefined;
722
+ affectedHooks: "make" | "compile" | "emit" | "afterEmit" | "invalid" | "done" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishModules" | "finishMake" | "entryOption" | undefined;
711
723
  raw(): import("@rspack/binding").BuiltinPlugin;
712
724
  apply(compiler: import("./Compiler").Compiler): void;
713
725
  };
@@ -719,7 +731,7 @@ export declare const electron: {
719
731
  new (context?: string | undefined): {
720
732
  name: import("@rspack/binding").BuiltinPluginName;
721
733
  _options: string;
722
- affectedHooks: "emit" | "done" | "compilation" | "make" | "compile" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishModules" | "finishMake" | "entryOption" | undefined;
734
+ affectedHooks: "make" | "compile" | "emit" | "afterEmit" | "invalid" | "done" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishModules" | "finishMake" | "entryOption" | undefined;
723
735
  raw(): import("@rspack/binding").BuiltinPlugin;
724
736
  apply(compiler: import("./Compiler").Compiler): void;
725
737
  };
@@ -730,7 +742,7 @@ export declare const library: {
730
742
  new (type: any): {
731
743
  name: import("@rspack/binding").BuiltinPluginName;
732
744
  _options: any;
733
- affectedHooks: "emit" | "done" | "compilation" | "make" | "compile" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishModules" | "finishMake" | "entryOption" | undefined;
745
+ affectedHooks: "make" | "compile" | "emit" | "afterEmit" | "invalid" | "done" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishModules" | "finishMake" | "entryOption" | undefined;
734
746
  raw(): import("@rspack/binding").BuiltinPlugin;
735
747
  apply(compiler: import("./Compiler").Compiler): void;
736
748
  };
@@ -741,7 +753,7 @@ export declare const wasm: {
741
753
  new (type: any): {
742
754
  name: import("@rspack/binding").BuiltinPluginName;
743
755
  _options: any;
744
- affectedHooks: "emit" | "done" | "compilation" | "make" | "compile" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishModules" | "finishMake" | "entryOption" | undefined;
756
+ affectedHooks: "make" | "compile" | "emit" | "afterEmit" | "invalid" | "done" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishModules" | "finishMake" | "entryOption" | undefined;
745
757
  raw(): import("@rspack/binding").BuiltinPlugin;
746
758
  apply(compiler: import("./Compiler").Compiler): void;
747
759
  };
@@ -752,7 +764,7 @@ export declare const javascript: {
752
764
  new (type: any): {
753
765
  name: import("@rspack/binding").BuiltinPluginName;
754
766
  _options: any;
755
- affectedHooks: "emit" | "done" | "compilation" | "make" | "compile" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishModules" | "finishMake" | "entryOption" | undefined;
767
+ affectedHooks: "make" | "compile" | "emit" | "afterEmit" | "invalid" | "done" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishModules" | "finishMake" | "entryOption" | undefined;
756
768
  raw(): import("@rspack/binding").BuiltinPlugin;
757
769
  apply(compiler: import("./Compiler").Compiler): void;
758
770
  };
@@ -763,7 +775,7 @@ export declare const webworker: {
763
775
  new (): {
764
776
  name: import("@rspack/binding").BuiltinPluginName;
765
777
  _options: undefined;
766
- affectedHooks: "emit" | "done" | "compilation" | "make" | "compile" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishModules" | "finishMake" | "entryOption" | undefined;
778
+ affectedHooks: "make" | "compile" | "emit" | "afterEmit" | "invalid" | "done" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishModules" | "finishMake" | "entryOption" | undefined;
767
779
  raw(): import("@rspack/binding").BuiltinPlugin;
768
780
  apply(compiler: import("./Compiler").Compiler): void;
769
781
  };
@@ -774,7 +786,7 @@ export declare const optimize: {
774
786
  new (options: import("./builtin-plugin").LimitChunkCountOptions): {
775
787
  name: import("@rspack/binding").BuiltinPluginName;
776
788
  _options: import("@rspack/binding").RawLimitChunkCountPluginOptions;
777
- affectedHooks: "emit" | "done" | "compilation" | "make" | "compile" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishModules" | "finishMake" | "entryOption" | undefined;
789
+ affectedHooks: "make" | "compile" | "emit" | "afterEmit" | "invalid" | "done" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishModules" | "finishMake" | "entryOption" | undefined;
778
790
  raw(): import("@rspack/binding").BuiltinPlugin;
779
791
  apply(compiler: import("./Compiler").Compiler): void;
780
792
  };
@@ -46,7 +46,7 @@ export interface HookInterceptor<T, R, AdditionalOptions = UnsetAdditionalOption
46
46
  register?: (tap: FullTap & IfSet<AdditionalOptions>) => FullTap & IfSet<AdditionalOptions>;
47
47
  }
48
48
  type ArgumentNames<T extends any[]> = FixedSizeArray<T["length"], string>;
49
- declare class Hook<T, R, AdditionalOptions = UnsetAdditionalOptions> {
49
+ export declare class Hook<T, R, AdditionalOptions = UnsetAdditionalOptions> {
50
50
  args?: ArgumentNames<AsArray<T>>;
51
51
  name?: string;
52
52
  taps: (FullTap & IfSet<AdditionalOptions>)[];
@@ -58,6 +58,7 @@ declare class Hook<T, R, AdditionalOptions = UnsetAdditionalOptions> {
58
58
  _runErrorInterceptors(e: Error): void;
59
59
  _runTapInterceptors(tap: FullTap & IfSet<AdditionalOptions>): void;
60
60
  _runDoneInterceptors(): void;
61
+ _runResultInterceptors(r: R): void;
61
62
  isUsed(): boolean;
62
63
  queryStageRange(stageRange: StageRange): QueriedHook<T, R, AdditionalOptions>;
63
64
  callAsyncStageRange(queried: QueriedHook<T, R, AdditionalOptions>, ...args: Append<AsArray<T>, Callback<Error, R>>): void;
@@ -89,6 +90,13 @@ export declare class SyncHook<T, R = void, AdditionalOptions = UnsetAdditionalOp
89
90
  tapAsync(): never;
90
91
  tapPromise(): never;
91
92
  }
93
+ export declare class SyncBailHook<T, R, AdditionalOptions = UnsetAdditionalOptions> extends Hook<T, R, AdditionalOptions> {
94
+ callAsyncStageRange(queried: QueriedHook<T, R, AdditionalOptions>, ...args: Append<AsArray<T>, Callback<Error, R>>): void;
95
+ call(...args: AsArray<T>): R;
96
+ callStageRange(queried: QueriedHook<T, R, AdditionalOptions>, ...args: AsArray<T>): R;
97
+ tapAsync(): never;
98
+ tapPromise(): never;
99
+ }
92
100
  export declare class AsyncParallelHook<T, AdditionalOptions = UnsetAdditionalOptions> extends Hook<T, void, AdditionalOptions> {
93
101
  callAsyncStageRange(queried: QueriedHook<T, void, AdditionalOptions>, ...args: Append<AsArray<T>, Callback<Error, void>>): void;
94
102
  tapAsync(options: Options<AdditionalOptions>, fn: FnWithCallback<T, void>): void;
@@ -99,4 +107,9 @@ export declare class AsyncSeriesHook<T, AdditionalOptions = UnsetAdditionalOptio
99
107
  tapAsync(options: Options<AdditionalOptions>, fn: FnWithCallback<T, void>): void;
100
108
  tapPromise(options: Options<AdditionalOptions>, fn: Fn<T, void>): void;
101
109
  }
110
+ export declare class AsyncSeriesBailHook<T, R, AdditionalOptions = UnsetAdditionalOptions> extends Hook<T, R, AdditionalOptions> {
111
+ callAsyncStageRange(queried: QueriedHook<T, R, AdditionalOptions>, ...args: Append<AsArray<T>, Callback<Error, R>>): void;
112
+ tapAsync(options: Options<AdditionalOptions>, fn: FnWithCallback<T, void>): void;
113
+ tapPromise(options: Options<AdditionalOptions>, fn: Fn<T, void>): void;
114
+ }
102
115
  export {};
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AsyncSeriesHook = exports.AsyncParallelHook = exports.SyncHook = exports.QueriedHook = exports.safeStage = exports.maxStage = exports.minStage = void 0;
3
+ exports.AsyncSeriesBailHook = exports.AsyncSeriesHook = exports.AsyncParallelHook = exports.SyncBailHook = exports.SyncHook = exports.QueriedHook = exports.safeStage = exports.maxStage = exports.minStage = exports.Hook = void 0;
4
4
  class Hook {
5
5
  constructor(args, name) {
6
6
  this.args = args;
@@ -55,6 +55,13 @@ class Hook {
55
55
  }
56
56
  }
57
57
  }
58
+ _runResultInterceptors(r) {
59
+ for (const interceptor of this.interceptors) {
60
+ if (interceptor.result) {
61
+ interceptor.result(r);
62
+ }
63
+ }
64
+ }
58
65
  isUsed() {
59
66
  return this.taps.length > 0 || this.interceptors.length > 0;
60
67
  }
@@ -136,6 +143,7 @@ class Hook {
136
143
  this.taps[i] = item;
137
144
  }
138
145
  }
146
+ exports.Hook = Hook;
139
147
  exports.minStage = -Infinity;
140
148
  exports.maxStage = Infinity;
141
149
  const allStageRange = [exports.minStage, exports.maxStage];
@@ -241,6 +249,59 @@ class SyncHook extends Hook {
241
249
  }
242
250
  }
243
251
  exports.SyncHook = SyncHook;
252
+ class SyncBailHook extends Hook {
253
+ callAsyncStageRange(queried, ...args) {
254
+ const { stageRange: [from, to], tapsInRange } = queried;
255
+ const args2 = [...args];
256
+ const cb = args2.pop();
257
+ if (from === exports.minStage) {
258
+ this._runCallInterceptors(...args2);
259
+ }
260
+ for (let tap of tapsInRange) {
261
+ this._runTapInterceptors(tap);
262
+ let r = undefined;
263
+ try {
264
+ r = tap.fn(...args2);
265
+ }
266
+ catch (e) {
267
+ const err = e;
268
+ this._runErrorInterceptors(err);
269
+ return cb(err);
270
+ }
271
+ if (r !== undefined) {
272
+ this._runResultInterceptors(r);
273
+ return cb(null, r);
274
+ }
275
+ }
276
+ if (to === exports.maxStage) {
277
+ this._runDoneInterceptors();
278
+ cb(null);
279
+ }
280
+ }
281
+ call(...args) {
282
+ return this.callStageRange(this.queryStageRange(allStageRange), ...args);
283
+ }
284
+ callStageRange(queried, ...args) {
285
+ let result, error;
286
+ this.callAsyncStageRange(queried,
287
+ // @ts-expect-error
288
+ ...args, (e, r) => {
289
+ error = e;
290
+ result = r;
291
+ });
292
+ if (error) {
293
+ throw error;
294
+ }
295
+ return result;
296
+ }
297
+ tapAsync() {
298
+ throw new Error("tapAsync is not supported on a SyncBailHook");
299
+ }
300
+ tapPromise() {
301
+ throw new Error("tapPromise is not supported on a SyncBailHook");
302
+ }
303
+ }
304
+ exports.SyncBailHook = SyncBailHook;
244
305
  class AsyncParallelHook extends Hook {
245
306
  callAsyncStageRange(queried, ...args) {
246
307
  const { stageRange: [from, to], tapsInRange } = queried;
@@ -411,3 +472,109 @@ class AsyncSeriesHook extends Hook {
411
472
  }
412
473
  }
413
474
  exports.AsyncSeriesHook = AsyncSeriesHook;
475
+ class AsyncSeriesBailHook extends Hook {
476
+ callAsyncStageRange(queried, ...args) {
477
+ const { stageRange: [from, to], tapsInRange } = queried;
478
+ const args2 = [...args];
479
+ const cb = args2.pop();
480
+ if (from === exports.minStage) {
481
+ this._runCallInterceptors(...args2);
482
+ }
483
+ const done = () => {
484
+ this._runDoneInterceptors();
485
+ cb(null);
486
+ };
487
+ const error = (e) => {
488
+ this._runErrorInterceptors(e);
489
+ cb(e);
490
+ };
491
+ const result = (r) => {
492
+ this._runResultInterceptors(r);
493
+ cb(null, r);
494
+ };
495
+ if (tapsInRange.length === 0)
496
+ return done();
497
+ let index = 0;
498
+ const next = () => {
499
+ const tap = tapsInRange[index];
500
+ this._runTapInterceptors(tap);
501
+ if (tap.type === "promise") {
502
+ const promise = tap.fn(...args2);
503
+ if (!promise || !promise.then) {
504
+ throw new Error("Tap function (tapPromise) did not return promise (returned " +
505
+ promise +
506
+ ")");
507
+ }
508
+ promise.then((r) => {
509
+ index += 1;
510
+ if (r !== undefined) {
511
+ result(r);
512
+ }
513
+ else if (index === tapsInRange.length) {
514
+ done();
515
+ }
516
+ else {
517
+ next();
518
+ }
519
+ }, (e) => {
520
+ index = tapsInRange.length;
521
+ error(e);
522
+ });
523
+ }
524
+ else if (tap.type === "async") {
525
+ tap.fn(...args2, (e, r) => {
526
+ if (e) {
527
+ index = tapsInRange.length;
528
+ error(e);
529
+ }
530
+ else {
531
+ index += 1;
532
+ if (r !== undefined) {
533
+ result(r);
534
+ }
535
+ else if (index === tapsInRange.length) {
536
+ done();
537
+ }
538
+ else {
539
+ next();
540
+ }
541
+ }
542
+ });
543
+ }
544
+ else {
545
+ let hasError = false;
546
+ let r = undefined;
547
+ try {
548
+ r = tap.fn(...args2);
549
+ }
550
+ catch (e) {
551
+ hasError = true;
552
+ index = tapsInRange.length;
553
+ error(e);
554
+ }
555
+ if (!hasError) {
556
+ index += 1;
557
+ if (r !== undefined) {
558
+ result(r);
559
+ }
560
+ else if (index === tapsInRange.length) {
561
+ done();
562
+ }
563
+ else {
564
+ next();
565
+ }
566
+ }
567
+ }
568
+ if (index === tapsInRange.length)
569
+ return;
570
+ };
571
+ next();
572
+ }
573
+ tapAsync(options, fn) {
574
+ this._tap("async", options, fn);
575
+ }
576
+ tapPromise(options, fn) {
577
+ this._tap("promise", options, fn);
578
+ }
579
+ }
580
+ exports.AsyncSeriesBailHook = AsyncSeriesBailHook;
@@ -7,11 +7,11 @@
7
7
  * Copyright (c) JS Foundation and other contributors
8
8
  * https://github.com/webpack/loader-runner/blob/main/LICENSE
9
9
  */
10
- import type { JsLoaderContext } from "@rspack/binding";
10
+ import type { JsLoaderContext, JsLoaderResult } from "@rspack/binding";
11
11
  import { Compiler } from "../Compiler";
12
12
  export declare function parsePathQueryFragment(str: string): {
13
13
  path: string;
14
14
  query: string;
15
15
  fragment: string;
16
16
  };
17
- export declare function runLoaders(compiler: Compiler, rawContext: JsLoaderContext): Promise<unknown>;
17
+ export declare function runLoaders(compiler: Compiler, rawContext: JsLoaderContext): Promise<JsLoaderResult>;
@@ -200,8 +200,8 @@ async function runLoaders(compiler, rawContext) {
200
200
  loaderContext.importModule = function importModule(request, options, callback) {
201
201
  if (!callback) {
202
202
  return new Promise((resolve, reject) => {
203
- compiler.compilation
204
- .__internal_getInner()
203
+ compiler
204
+ .compilation.__internal_getInner()
205
205
  .importModule(request, options.publicPath, options.baseUri, rawContext._moduleIdentifier, loaderContext.context, (err, res) => {
206
206
  if (err)
207
207
  reject(err);
@@ -224,8 +224,8 @@ async function runLoaders(compiler, rawContext) {
224
224
  });
225
225
  });
226
226
  }
227
- return compiler.compilation
228
- .__internal_getInner()
227
+ return compiler
228
+ .compilation.__internal_getInner()
229
229
  .importModule(request, options.publicPath, options.baseUri, rawContext._moduleIdentifier, loaderContext.context, (err, res) => {
230
230
  if (err) {
231
231
  callback(err, undefined);
@@ -137,6 +137,7 @@ class RspackOptionsApply {
137
137
  if (options.experiments.asyncWebAssembly) {
138
138
  new builtin_plugin_1.AsyncWebAssemblyModulesPlugin().apply(compiler);
139
139
  }
140
+ new builtin_plugin_1.JsLoaderRspackPlugin(compiler).apply(compiler);
140
141
  if (options.experiments.rspackFuture.disableApplyEntryLazily) {
141
142
  applyEntryOptions(compiler, options);
142
143
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rspack/core",
3
- "version": "0.5.7",
3
+ "version": "0.5.8-canary-2e1be96-20240321104547",
4
4
  "webpackVersion": "5.75.0",
5
5
  "license": "MIT",
6
6
  "description": "A Fast Rust-based Web Bundler",
@@ -45,6 +45,7 @@
45
45
  "jest-serializer-path": "^0.1.15",
46
46
  "less": "4.2.0",
47
47
  "less-loader": "^12.0.0",
48
+ "node-polyfill-webpack-plugin": "3.0.0",
48
49
  "postcss-loader": "^8.0.0",
49
50
  "postcss-pxtorem": "^6.0.0",
50
51
  "pug-loader": "^2.4.0",
@@ -55,9 +56,8 @@
55
56
  "styled-components": "^6.0.8",
56
57
  "terser": "5.27.2",
57
58
  "wast-loader": "^1.11.4",
58
- "@rspack/plugin-minify": "^0.5.7",
59
- "@rspack/core": "0.5.7",
60
- "@rspack/plugin-node-polyfill": "^0.5.7"
59
+ "@rspack/core": "0.5.8-canary-2e1be96-20240321104547",
60
+ "@rspack/plugin-minify": "^0.5.8-canary-2e1be96-20240321104547"
61
61
  },
62
62
  "dependencies": {
63
63
  "@module-federation/runtime-tools": "0.0.8",
@@ -72,7 +72,7 @@
72
72
  "webpack-sources": "3.2.3",
73
73
  "zod": "^3.21.4",
74
74
  "zod-validation-error": "1.3.1",
75
- "@rspack/binding": "0.5.7"
75
+ "@rspack/binding": "0.5.8-canary-2e1be96-20240321104547"
76
76
  },
77
77
  "peerDependencies": {
78
78
  "@swc/helpers": ">=0.5.1"
@@ -1,5 +0,0 @@
1
- import type { JsModule } from "@rspack/binding";
2
- export interface NormalizedJsModule extends JsModule {
3
- identifier: () => string;
4
- }
5
- export declare function normalizeJsModule(m: JsModule): NormalizedJsModule;
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.normalizeJsModule = void 0;
4
- function normalizeJsModule(m) {
5
- return Object.assign(m, {
6
- identifier: () => m.moduleIdentifier
7
- });
8
- }
9
- exports.normalizeJsModule = normalizeJsModule;