@rspack/core 0.7.2-canary-fdfff21-20240606140946 → 0.7.2-canary-3dcf0a9-20240607151650

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 (93) hide show
  1. package/dist/Compilation.d.ts +49 -5
  2. package/dist/Compilation.js +25 -43
  3. package/dist/Compiler.d.ts +5 -5
  4. package/dist/Compiler.js +9 -9
  5. package/dist/ContextModuleFactory.d.ts +1 -1
  6. package/dist/MultiCompiler.d.ts +1 -1
  7. package/dist/MultiCompiler.js +1 -1
  8. package/dist/NormalModule.js +1 -1
  9. package/dist/NormalModuleFactory.d.ts +1 -1
  10. package/dist/Stats.d.ts +1 -3
  11. package/dist/Stats.js +1 -26
  12. package/dist/builtin-plugin/APIPlugin.d.ts +1 -1
  13. package/dist/builtin-plugin/ArrayPushCallbackChunkFormatPlugin.d.ts +1 -1
  14. package/dist/builtin-plugin/AssetModulesPlugin.d.ts +1 -1
  15. package/dist/builtin-plugin/AsyncWebAssemblyModulesPlugin.d.ts +1 -1
  16. package/dist/builtin-plugin/BannerPlugin.d.ts +1 -1
  17. package/dist/builtin-plugin/BundlerInfoRspackPlugin.d.ts +1 -1
  18. package/dist/builtin-plugin/ChunkPrefetchPreloadPlugin.d.ts +1 -1
  19. package/dist/builtin-plugin/CommonJsChunkFormatPlugin.d.ts +1 -1
  20. package/dist/builtin-plugin/CopyRspackPlugin.d.ts +1 -1
  21. package/dist/builtin-plugin/CssModulesPlugin.d.ts +1 -1
  22. package/dist/builtin-plugin/DataUriPlugin.d.ts +1 -1
  23. package/dist/builtin-plugin/DefinePlugin.d.ts +1 -1
  24. package/dist/builtin-plugin/DeterministicChunkIdsPlugin.d.ts +1 -1
  25. package/dist/builtin-plugin/DeterministicModuleIdsPlugin.d.ts +1 -1
  26. package/dist/builtin-plugin/DynamicEntryPlugin.d.ts +1 -1
  27. package/dist/builtin-plugin/DynamicEntryPlugin.js +1 -1
  28. package/dist/builtin-plugin/ElectronTargetPlugin.d.ts +1 -1
  29. package/dist/builtin-plugin/EnableChunkLoadingPlugin.d.ts +1 -1
  30. package/dist/builtin-plugin/EnableWasmLoadingPlugin.d.ts +1 -1
  31. package/dist/builtin-plugin/EnsureChunkConditionsPlugin.d.ts +1 -1
  32. package/dist/builtin-plugin/EntryPlugin.d.ts +1 -1
  33. package/dist/builtin-plugin/EvalDevToolModulePlugin.d.ts +1 -1
  34. package/dist/builtin-plugin/EvalSourceMapDevToolPlugin.d.ts +1 -1
  35. package/dist/builtin-plugin/ExternalsPlugin.d.ts +3 -3
  36. package/dist/builtin-plugin/FileUriPlugin.d.ts +1 -1
  37. package/dist/builtin-plugin/FlagDependencyExportsPlugin.d.ts +1 -1
  38. package/dist/builtin-plugin/FlagDependencyUsagePlugin.d.ts +1 -1
  39. package/dist/builtin-plugin/HtmlRspackPlugin.d.ts +1 -1
  40. package/dist/builtin-plugin/HttpExternalsRspackPlugin.d.ts +1 -1
  41. package/dist/builtin-plugin/IgnorePlugin.d.ts +1 -1
  42. package/dist/builtin-plugin/InferAsyncModulesPlugin.d.ts +1 -1
  43. package/dist/builtin-plugin/JavascriptModulesPlugin.d.ts +1 -1
  44. package/dist/builtin-plugin/JsLoaderRspackPlugin.d.ts +1 -1
  45. package/dist/builtin-plugin/JsonModulesPlugin.d.ts +1 -1
  46. package/dist/builtin-plugin/LimitChunkCountPlugin.d.ts +1 -1
  47. package/dist/builtin-plugin/MangleExportsPlugin.d.ts +1 -1
  48. package/dist/builtin-plugin/MergeDuplicateChunksPlugin.d.ts +1 -1
  49. package/dist/builtin-plugin/ModuleChunkFormatPlugin.d.ts +1 -1
  50. package/dist/builtin-plugin/ModuleConcatenationPlugin.d.ts +1 -1
  51. package/dist/builtin-plugin/NamedChunkIdsPlugin.d.ts +1 -1
  52. package/dist/builtin-plugin/NamedModuleIdsPlugin.d.ts +1 -1
  53. package/dist/builtin-plugin/NaturalChunkIdsPlugin.d.ts +1 -1
  54. package/dist/builtin-plugin/NaturalModuleIdsPlugin.d.ts +1 -1
  55. package/dist/builtin-plugin/NodeTargetPlugin.d.ts +1 -1
  56. package/dist/builtin-plugin/ProgressPlugin.d.ts +1 -1
  57. package/dist/builtin-plugin/ProvidePlugin.d.ts +1 -1
  58. package/dist/builtin-plugin/RealContentHashPlugin.d.ts +1 -1
  59. package/dist/builtin-plugin/RemoveEmptyChunksPlugin.d.ts +1 -1
  60. package/dist/builtin-plugin/RuntimeChunkPlugin.d.ts +1 -1
  61. package/dist/builtin-plugin/RuntimePlugin.d.ts +1 -1
  62. package/dist/builtin-plugin/SideEffectsFlagPlugin.d.ts +1 -1
  63. package/dist/builtin-plugin/SizeLimitsPlugin.d.ts +1 -1
  64. package/dist/builtin-plugin/SourceMapDevToolPlugin.d.ts +1 -1
  65. package/dist/builtin-plugin/SplitChunksPlugin.js +1 -1
  66. package/dist/builtin-plugin/SwcCssMinimizerPlugin.d.ts +1 -1
  67. package/dist/builtin-plugin/SwcJsMinimizerPlugin.d.ts +1 -1
  68. package/dist/builtin-plugin/WarnCaseSensitiveModulesPlugin.d.ts +1 -1
  69. package/dist/builtin-plugin/WebWorkerTemplatePlugin.d.ts +1 -1
  70. package/dist/builtin-plugin/WorkerPlugin.js +1 -1
  71. package/dist/builtin-plugin/base.d.ts +1 -1
  72. package/dist/builtin-plugin/lazy-compilation/lazyCompilation.d.ts +1 -1
  73. package/dist/config/defaults.js +1 -1
  74. package/dist/config/normalization.d.ts +1 -1
  75. package/dist/config/zod.d.ts +795 -399
  76. package/dist/config/zod.js +58 -4
  77. package/dist/container/ContainerPlugin.d.ts +1 -1
  78. package/dist/container/ContainerReferencePlugin.d.ts +2 -2
  79. package/dist/container/ContainerReferencePlugin.js +1 -1
  80. package/dist/container/ModuleFederationRuntimePlugin.d.ts +1 -1
  81. package/dist/loader-runner/index.js +1 -1
  82. package/dist/node/NodeEnvironmentPlugin.js +1 -1
  83. package/dist/node/NodeWatchFileSystem.d.ts +1 -1
  84. package/dist/rspack.d.ts +1 -1
  85. package/dist/rspack.js +3 -3
  86. package/dist/rspackOptionsApply.js +3 -1
  87. package/dist/sharing/ConsumeSharedPlugin.d.ts +1 -1
  88. package/dist/sharing/ProvideSharedPlugin.d.ts +1 -1
  89. package/dist/sharing/ShareRuntimePlugin.d.ts +1 -1
  90. package/dist/stats/DefaultStatsPresetPlugin.d.ts +4 -0
  91. package/dist/stats/DefaultStatsPresetPlugin.js +307 -0
  92. package/dist/stats/statsFactoryUtils.d.ts +1 -6
  93. package/package.json +4 -4
@@ -608,12 +608,13 @@ const cacheOptions = zod_1.z.boolean();
608
608
  const statsOptions = zod_1.z.strictObject({
609
609
  all: zod_1.z.boolean().optional(),
610
610
  preset: zod_1.z
611
- .enum(["normal", "none", "verbose", "errors-only", "errors-warnings"])
611
+ .boolean()
612
+ .or(zod_1.z.enum(["normal", "none", "verbose", "errors-only", "errors-warnings"]))
612
613
  .optional(),
613
614
  assets: zod_1.z.boolean().optional(),
614
615
  chunks: zod_1.z.boolean().optional(),
615
616
  modules: zod_1.z.boolean().optional(),
616
- entrypoints: zod_1.z.boolean().optional(),
617
+ entrypoints: zod_1.z.boolean().or(zod_1.z.literal("auto")).optional(),
617
618
  chunkGroups: zod_1.z.boolean().optional(),
618
619
  warnings: zod_1.z.boolean().optional(),
619
620
  warningsCount: zod_1.z.boolean().optional(),
@@ -631,7 +632,6 @@ const statsOptions = zod_1.z.strictObject({
631
632
  timings: zod_1.z.boolean().optional(),
632
633
  builtAt: zod_1.z.boolean().optional(),
633
634
  moduleAssets: zod_1.z.boolean().optional(),
634
- modulesSpace: zod_1.z.number().optional(),
635
635
  nestedModules: zod_1.z.boolean().optional(),
636
636
  source: zod_1.z.boolean().optional(),
637
637
  logging: zod_1.z
@@ -645,7 +645,61 @@ const statsOptions = zod_1.z.strictObject({
645
645
  usedExports: zod_1.z.boolean().optional(),
646
646
  providedExports: zod_1.z.boolean().optional(),
647
647
  optimizationBailout: zod_1.z.boolean().optional(),
648
- orphanModules: zod_1.z.boolean().optional()
648
+ groupModulesByType: zod_1.z.boolean().optional(),
649
+ groupModulesByCacheStatus: zod_1.z.boolean().optional(),
650
+ groupModulesByLayer: zod_1.z.boolean().optional(),
651
+ groupModulesByAttributes: zod_1.z.boolean().optional(),
652
+ groupModulesByPath: zod_1.z.boolean().optional(),
653
+ groupModulesByExtension: zod_1.z.boolean().optional(),
654
+ modulesSpace: zod_1.z.number().optional(),
655
+ chunkModulesSpace: zod_1.z.number().optional(),
656
+ nestedModulesSpace: zod_1.z.number().optional(),
657
+ relatedAssets: zod_1.z.boolean().optional(),
658
+ groupAssetsByEmitStatus: zod_1.z.boolean().optional(),
659
+ groupAssetsByInfo: zod_1.z.boolean().optional(),
660
+ groupAssetsByPath: zod_1.z.boolean().optional(),
661
+ groupAssetsByExtension: zod_1.z.boolean().optional(),
662
+ groupAssetsByChunk: zod_1.z.boolean().optional(),
663
+ assetsSpace: zod_1.z.number().optional(),
664
+ orphanModules: zod_1.z.boolean().optional(),
665
+ excludeModules: zod_1.z
666
+ .array(zod_1.z
667
+ .string()
668
+ .or(zod_1.z.instanceof(RegExp))
669
+ .or(zod_1.z.function(zod_1.z.tuple([zod_1.z.string(), zod_1.z.any(), zod_1.z.any()]), zod_1.z.boolean())))
670
+ .or(zod_1.z.string())
671
+ .or(zod_1.z.instanceof(RegExp))
672
+ .or(zod_1.z.function(zod_1.z.tuple([zod_1.z.string(), zod_1.z.any(), zod_1.z.any()]), zod_1.z.boolean()))
673
+ .or(zod_1.z.boolean())
674
+ .optional(),
675
+ excludeAssets: zod_1.z
676
+ .array(zod_1.z
677
+ .string()
678
+ .or(zod_1.z.instanceof(RegExp))
679
+ .or(zod_1.z.function(zod_1.z.tuple([zod_1.z.string(), zod_1.z.any()]), zod_1.z.boolean())))
680
+ .or(zod_1.z.string())
681
+ .or(zod_1.z.instanceof(RegExp))
682
+ .or(zod_1.z.function(zod_1.z.tuple([zod_1.z.string(), zod_1.z.any()]), zod_1.z.boolean()))
683
+ .optional(),
684
+ modulesSort: zod_1.z.string().optional(),
685
+ chunkModulesSort: zod_1.z.string().optional(),
686
+ nestedModulesSort: zod_1.z.string().optional(),
687
+ chunksSort: zod_1.z.string().optional(),
688
+ assetsSort: zod_1.z.string().optional(),
689
+ performance: zod_1.z.boolean().optional(),
690
+ env: zod_1.z.boolean().optional(),
691
+ chunkGroupAuxiliary: zod_1.z.boolean().optional(),
692
+ chunkGroupChildren: zod_1.z.boolean().optional(),
693
+ chunkGroupMaxAssets: zod_1.z.number().optional(),
694
+ dependentModules: zod_1.z.boolean().optional(),
695
+ chunkOrigins: zod_1.z.boolean().optional(),
696
+ runtime: zod_1.z.boolean().optional(),
697
+ depth: zod_1.z.boolean().optional(),
698
+ reasonsSpace: zod_1.z.number().optional(),
699
+ groupReasonsByOrigin: zod_1.z.boolean().optional(),
700
+ errorDetails: zod_1.z.boolean().optional(),
701
+ errorStack: zod_1.z.boolean().optional(),
702
+ moduleTrace: zod_1.z.boolean().optional()
649
703
  });
650
704
  const statsValue = zod_1.z
651
705
  .enum(["none", "errors-only", "errors-warnings", "normal", "verbose"])
@@ -1,6 +1,6 @@
1
1
  import { BuiltinPlugin, BuiltinPluginName } from "@rspack/binding";
2
- import { RspackBuiltinPlugin } from "../builtin-plugin/base";
3
2
  import { Compiler } from "../Compiler";
3
+ import { RspackBuiltinPlugin } from "../builtin-plugin/base";
4
4
  import { EntryRuntime, FilenameTemplate, LibraryOptions } from "../config";
5
5
  export type ContainerPluginOptions = {
6
6
  exposes: Exposes;
@@ -1,6 +1,6 @@
1
1
  import { BuiltinPlugin, BuiltinPluginName } from "@rspack/binding";
2
- import { RspackBuiltinPlugin } from "../builtin-plugin/base";
3
2
  import { Compiler } from "../Compiler";
3
+ import { RspackBuiltinPlugin } from "../builtin-plugin/base";
4
4
  import { ExternalsType } from "../config";
5
5
  export type ContainerReferencePluginOptions = {
6
6
  remoteType: ExternalsType;
@@ -21,7 +21,7 @@ export type RemotesConfig = {
21
21
  export declare class ContainerReferencePlugin extends RspackBuiltinPlugin {
22
22
  name: BuiltinPluginName;
23
23
  _options: {
24
- remoteType: "promise" | "commonjs" | "umd" | "amd" | "module" | "global" | "jsonp" | "import" | "commonjs2" | "var" | "assign" | "this" | "window" | "self" | "commonjs-module" | "commonjs-static" | "amd-require" | "umd2" | "system" | "script" | "node-commonjs";
24
+ remoteType: "promise" | "global" | "jsonp" | "import" | "amd" | "commonjs" | "commonjs2" | "var" | "module" | "assign" | "this" | "window" | "self" | "commonjs-module" | "commonjs-static" | "amd-require" | "umd" | "umd2" | "system" | "script" | "node-commonjs";
25
25
  remotes: [string, {
26
26
  external: string[];
27
27
  shareScope: string;
@@ -2,8 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ContainerReferencePlugin = void 0;
4
4
  const binding_1 = require("@rspack/binding");
5
- const base_1 = require("../builtin-plugin/base");
6
5
  const ExternalsPlugin_1 = require("../builtin-plugin/ExternalsPlugin");
6
+ const base_1 = require("../builtin-plugin/base");
7
7
  const ShareRuntimePlugin_1 = require("../sharing/ShareRuntimePlugin");
8
8
  const options_1 = require("./options");
9
9
  class ContainerReferencePlugin extends base_1.RspackBuiltinPlugin {
@@ -3,7 +3,7 @@ export declare const ModuleFederationRuntimePlugin: {
3
3
  new (): {
4
4
  name: BuiltinPluginName;
5
5
  _options: void;
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;
6
+ 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" | "finishMake" | "entryOption" | undefined;
7
7
  raw(): import("@rspack/binding").BuiltinPlugin;
8
8
  apply(compiler: import("../Compiler").Compiler): void;
9
9
  };
@@ -11,8 +11,8 @@
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.runLoaders = exports.parsePathQueryFragment = void 0;
13
13
  const webpack_sources_1 = require("webpack-sources");
14
- const adapterRuleUse_1 = require("../config/adapterRuleUse");
15
14
  const NormalModule_1 = require("../NormalModule");
15
+ const adapterRuleUse_1 = require("../config/adapterRuleUse");
16
16
  const util_1 = require("../util");
17
17
  const createHash_1 = require("../util/createHash");
18
18
  const identifier_1 = require("../util/identifier");
@@ -16,8 +16,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
16
16
  const CachedInputFileSystem_1 = __importDefault(require("../../compiled/enhanced-resolve/CachedInputFileSystem"));
17
17
  const graceful_fs_1 = __importDefault(require("../../compiled/graceful-fs"));
18
18
  const createConsoleLogger_1 = __importDefault(require("../logging/createConsoleLogger"));
19
- const nodeConsole_1 = __importDefault(require("./nodeConsole"));
20
19
  const NodeWatchFileSystem_1 = __importDefault(require("./NodeWatchFileSystem"));
20
+ const nodeConsole_1 = __importDefault(require("./nodeConsole"));
21
21
  class NodeEnvironmentPlugin {
22
22
  constructor(options) {
23
23
  this.options = options;
@@ -8,7 +8,7 @@
8
8
  * https://github.com/webpack/webpack/blob/main/LICENSE
9
9
  */
10
10
  import Watchpack from "../../compiled/watchpack";
11
- import { FileSystemInfoEntry, Watcher, WatchFileSystem } from "../util/fs";
11
+ import { FileSystemInfoEntry, WatchFileSystem, Watcher } from "../util/fs";
12
12
  export default class NodeWatchFileSystem implements WatchFileSystem {
13
13
  inputFileSystem: any;
14
14
  watcherOptions: Watchpack.WatchOptions;
package/dist/rspack.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import { Callback } from "tapable";
2
2
  import { Compiler } from "./Compiler";
3
- import { RspackOptions } from "./config";
4
3
  import { MultiCompiler, MultiRspackOptions } from "./MultiCompiler";
5
4
  import MultiStats from "./MultiStats";
6
5
  import { Stats } from "./Stats";
6
+ import { RspackOptions } from "./config";
7
7
  declare function createMultiCompiler(options: MultiRspackOptions): MultiCompiler;
8
8
  declare function createCompiler(userOptions: RspackOptions): Compiler;
9
9
  declare function rspack(options: MultiRspackOptions): MultiCompiler;
package/dist/rspack.js CHANGED
@@ -16,14 +16,14 @@ exports.Stats = exports.rspack = exports.MultiStats = exports.createMultiCompile
16
16
  const assert_1 = __importDefault(require("assert"));
17
17
  const util_1 = __importDefault(require("util"));
18
18
  const Compiler_1 = require("./Compiler");
19
- const config_1 = require("./config");
20
19
  const MultiCompiler_1 = require("./MultiCompiler");
21
20
  const MultiStats_1 = __importDefault(require("./MultiStats"));
22
21
  exports.MultiStats = MultiStats_1.default;
23
- const NodeEnvironmentPlugin_1 = __importDefault(require("./node/NodeEnvironmentPlugin"));
24
- const rspackOptionsApply_1 = require("./rspackOptionsApply");
25
22
  const Stats_1 = require("./Stats");
26
23
  Object.defineProperty(exports, "Stats", { enumerable: true, get: function () { return Stats_1.Stats; } });
24
+ const config_1 = require("./config");
25
+ const NodeEnvironmentPlugin_1 = __importDefault(require("./node/NodeEnvironmentPlugin"));
26
+ const rspackOptionsApply_1 = require("./rspackOptionsApply");
27
27
  const util_2 = require("./util");
28
28
  const validate_1 = require("./util/validate");
29
29
  function createMultiCompiler(options) {
@@ -15,11 +15,12 @@ exports.RspackOptionsApply = void 0;
15
15
  */
16
16
  const assert_1 = __importDefault(require("assert"));
17
17
  const graceful_fs_1 = __importDefault(require("../compiled/graceful-fs"));
18
+ const Module_1 = require("./Module");
18
19
  const builtin_plugin_1 = require("./builtin-plugin");
19
20
  const EntryOptionPlugin_1 = __importDefault(require("./lib/EntryOptionPlugin"));
20
21
  const ignoreWarningsPlugin_1 = __importDefault(require("./lib/ignoreWarningsPlugin"));
21
- const Module_1 = require("./Module");
22
22
  const DefaultStatsFactoryPlugin_1 = require("./stats/DefaultStatsFactoryPlugin");
23
+ const DefaultStatsPresetPlugin_1 = require("./stats/DefaultStatsPresetPlugin");
23
24
  const DefaultStatsPrinterPlugin_1 = require("./stats/DefaultStatsPrinterPlugin");
24
25
  const assertNotNil_1 = require("./util/assertNotNil");
25
26
  const cleverMerge_1 = require("./util/cleverMerge");
@@ -254,6 +255,7 @@ class RspackOptionsApply {
254
255
  new builtin_plugin_1.WarnCaseSensitiveModulesPlugin().apply(compiler);
255
256
  new builtin_plugin_1.WorkerPlugin(options.output.workerChunkLoading, options.output.workerWasmLoading, options.output.module, options.output.workerPublicPath).apply(compiler);
256
257
  new DefaultStatsFactoryPlugin_1.DefaultStatsFactoryPlugin().apply(compiler);
258
+ new DefaultStatsPresetPlugin_1.DefaultStatsPresetPlugin().apply(compiler);
257
259
  new DefaultStatsPrinterPlugin_1.DefaultStatsPrinterPlugin().apply(compiler);
258
260
  if (options.ignoreWarnings && options.ignoreWarnings.length > 0) {
259
261
  new ignoreWarningsPlugin_1.default(options.ignoreWarnings).apply(compiler);
@@ -1,6 +1,6 @@
1
1
  import { BuiltinPlugin, BuiltinPluginName } from "@rspack/binding";
2
- import { RspackBuiltinPlugin } from "../builtin-plugin/base";
3
2
  import { Compiler } from "../Compiler";
3
+ import { RspackBuiltinPlugin } from "../builtin-plugin/base";
4
4
  export type ConsumeSharedPluginOptions = {
5
5
  consumes: Consumes;
6
6
  shareScope?: string;
@@ -1,6 +1,6 @@
1
1
  import { BuiltinPlugin, BuiltinPluginName } from "@rspack/binding";
2
- import { RspackBuiltinPlugin } from "../builtin-plugin/base";
3
2
  import { Compiler } from "../Compiler";
3
+ import { RspackBuiltinPlugin } from "../builtin-plugin/base";
4
4
  export type ProvideSharedPluginOptions = {
5
5
  provides: Provides;
6
6
  shareScope?: string;
@@ -1,6 +1,6 @@
1
1
  import { BuiltinPlugin, BuiltinPluginName } from "@rspack/binding";
2
- import { RspackBuiltinPlugin } from "../builtin-plugin/base";
3
2
  import { Compiler } from "../Compiler";
3
+ import { RspackBuiltinPlugin } from "../builtin-plugin/base";
4
4
  export declare class ShareRuntimePlugin extends RspackBuiltinPlugin {
5
5
  private enhanced;
6
6
  name: BuiltinPluginName;
@@ -0,0 +1,4 @@
1
+ import type { Compiler } from "../Compiler";
2
+ export declare class DefaultStatsPresetPlugin {
3
+ apply(compiler: Compiler): void;
4
+ }
@@ -0,0 +1,307 @@
1
+ "use strict";
2
+ /*
3
+ MIT License http://www.opensource.org/licenses/mit-license.php
4
+ Author Tobias Koppers @sokra
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.DefaultStatsPresetPlugin = void 0;
8
+ const applyDefaults = (options, defaults) => {
9
+ for (const key of Object.keys(defaults)) {
10
+ if (typeof options[key] === "undefined") {
11
+ options[key] = defaults[key];
12
+ }
13
+ }
14
+ };
15
+ const NAMED_PRESETS = {
16
+ verbose: {
17
+ hash: true,
18
+ builtAt: true,
19
+ // relatedAssets: true,
20
+ entrypoints: true,
21
+ chunkGroups: true,
22
+ ids: true,
23
+ modules: false,
24
+ chunks: true,
25
+ chunkRelations: true,
26
+ chunkModules: true,
27
+ // dependentModules: true,
28
+ // chunkOrigins: true,
29
+ // depth: true,
30
+ // env: true,
31
+ reasons: true,
32
+ usedExports: true,
33
+ providedExports: true,
34
+ optimizationBailout: true,
35
+ // errorDetails: true,
36
+ // errorStack: true,
37
+ publicPath: true,
38
+ logging: "verbose",
39
+ orphanModules: true,
40
+ runtimeModules: true,
41
+ // exclude: false,
42
+ // errorsSpace: Infinity,
43
+ // warningsSpace: Infinity,
44
+ modulesSpace: Infinity,
45
+ // chunkModulesSpace: Infinity,
46
+ // assetsSpace: Infinity,
47
+ // reasonsSpace: Infinity,
48
+ children: true
49
+ },
50
+ detailed: {
51
+ hash: true,
52
+ builtAt: true,
53
+ // relatedAssets: true,
54
+ entrypoints: true,
55
+ chunkGroups: true,
56
+ ids: true,
57
+ chunks: true,
58
+ chunkRelations: true,
59
+ chunkModules: false,
60
+ // chunkOrigins: true,
61
+ // depth: true,
62
+ usedExports: true,
63
+ providedExports: true,
64
+ optimizationBailout: true,
65
+ // errorDetails: true,
66
+ publicPath: true,
67
+ logging: true,
68
+ runtimeModules: true,
69
+ // exclude: false,
70
+ // errorsSpace: 1000,
71
+ // warningsSpace: 1000,
72
+ modulesSpace: 1000
73
+ // assetsSpace: 1000,
74
+ // reasonsSpace: 1000
75
+ },
76
+ minimal: {
77
+ all: false,
78
+ version: true,
79
+ timings: true,
80
+ modules: true,
81
+ // errorsSpace: 0,
82
+ // warningsSpace: 0,
83
+ modulesSpace: 0,
84
+ assets: true,
85
+ // assetsSpace: 0,
86
+ errors: true,
87
+ errorsCount: true,
88
+ warnings: true,
89
+ warningsCount: true,
90
+ logging: "warn"
91
+ },
92
+ "errors-only": {
93
+ all: false,
94
+ errors: true,
95
+ errorsCount: true,
96
+ // errorsSpace: Infinity,
97
+ // moduleTrace: true,
98
+ logging: "error"
99
+ },
100
+ "errors-warnings": {
101
+ all: false,
102
+ errors: true,
103
+ errorsCount: true,
104
+ // errorsSpace: Infinity,
105
+ warnings: true,
106
+ warningsCount: true,
107
+ // warningsSpace: Infinity,
108
+ logging: "warn"
109
+ },
110
+ summary: {
111
+ all: false,
112
+ version: true,
113
+ errorsCount: true,
114
+ warningsCount: true
115
+ },
116
+ none: {
117
+ all: false
118
+ }
119
+ };
120
+ const NORMAL_ON = ({ all }) => all !== false;
121
+ const NORMAL_OFF = ({ all }) => all === true;
122
+ const ON_FOR_TO_STRING = ({ all }, { forToString }) => forToString ? all !== false : all === true;
123
+ const OFF_FOR_TO_STRING = ({ all }, { forToString }) => forToString ? all === true : all !== false;
124
+ const AUTO_FOR_TO_STRING = ({ all }, { forToString }) => {
125
+ if (all === false)
126
+ return false;
127
+ if (all === true)
128
+ return true;
129
+ if (forToString)
130
+ return "auto";
131
+ return true;
132
+ };
133
+ const DEFAULTS = {
134
+ // context: (options, context, compilation) => compilation.compiler.context,
135
+ // requestShortener: (options, context, compilation) =>
136
+ // compilation.compiler.context === options.context
137
+ // ? compilation.requestShortener
138
+ // : new RequestShortener(options.context, compilation.compiler.root),
139
+ performance: NORMAL_ON,
140
+ hash: OFF_FOR_TO_STRING,
141
+ env: NORMAL_OFF,
142
+ version: NORMAL_ON,
143
+ timings: NORMAL_ON,
144
+ builtAt: OFF_FOR_TO_STRING,
145
+ assets: NORMAL_ON,
146
+ entrypoints: AUTO_FOR_TO_STRING,
147
+ chunkGroups: OFF_FOR_TO_STRING,
148
+ chunkGroupAuxiliary: OFF_FOR_TO_STRING,
149
+ chunkGroupChildren: OFF_FOR_TO_STRING,
150
+ chunkGroupMaxAssets: (o, { forToString }) => (forToString ? 5 : Infinity),
151
+ chunks: OFF_FOR_TO_STRING,
152
+ chunkRelations: OFF_FOR_TO_STRING,
153
+ chunkModules: ({ all, modules }) => {
154
+ if (all === false)
155
+ return false;
156
+ if (all === true)
157
+ return true;
158
+ if (modules)
159
+ return false;
160
+ return true;
161
+ },
162
+ dependentModules: OFF_FOR_TO_STRING,
163
+ chunkOrigins: OFF_FOR_TO_STRING,
164
+ ids: OFF_FOR_TO_STRING,
165
+ modules: ({ all, chunks, chunkModules }, { forToString }) => {
166
+ if (all === false)
167
+ return false;
168
+ if (all === true)
169
+ return true;
170
+ if (forToString && chunks && chunkModules)
171
+ return false;
172
+ return true;
173
+ },
174
+ nestedModules: OFF_FOR_TO_STRING,
175
+ groupModulesByType: ON_FOR_TO_STRING,
176
+ groupModulesByCacheStatus: ON_FOR_TO_STRING,
177
+ groupModulesByLayer: ON_FOR_TO_STRING,
178
+ groupModulesByAttributes: ON_FOR_TO_STRING,
179
+ groupModulesByPath: ON_FOR_TO_STRING,
180
+ groupModulesByExtension: ON_FOR_TO_STRING,
181
+ modulesSpace: (o, { forToString }) => (forToString ? 15 : Infinity),
182
+ chunkModulesSpace: (o, { forToString }) => (forToString ? 10 : Infinity),
183
+ nestedModulesSpace: (o, { forToString }) => (forToString ? 10 : Infinity),
184
+ relatedAssets: OFF_FOR_TO_STRING,
185
+ groupAssetsByEmitStatus: ON_FOR_TO_STRING,
186
+ groupAssetsByInfo: ON_FOR_TO_STRING,
187
+ groupAssetsByPath: ON_FOR_TO_STRING,
188
+ groupAssetsByExtension: ON_FOR_TO_STRING,
189
+ groupAssetsByChunk: ON_FOR_TO_STRING,
190
+ assetsSpace: (o, { forToString }) => (forToString ? 15 : Infinity),
191
+ orphanModules: OFF_FOR_TO_STRING,
192
+ runtimeModules: ({ all, runtime }, { forToString }) => runtime !== undefined
193
+ ? runtime
194
+ : forToString
195
+ ? all === true
196
+ : all !== false,
197
+ // cachedModules: ({ all, cached }, { forToString }) =>
198
+ // cached !== undefined ? cached : forToString ? all === true : all !== false,
199
+ moduleAssets: OFF_FOR_TO_STRING,
200
+ depth: OFF_FOR_TO_STRING,
201
+ // cachedAssets: OFF_FOR_TO_STRING,
202
+ reasons: OFF_FOR_TO_STRING,
203
+ reasonsSpace: (o, { forToString }) => (forToString ? 15 : Infinity),
204
+ groupReasonsByOrigin: ON_FOR_TO_STRING,
205
+ usedExports: OFF_FOR_TO_STRING,
206
+ providedExports: OFF_FOR_TO_STRING,
207
+ optimizationBailout: OFF_FOR_TO_STRING,
208
+ children: OFF_FOR_TO_STRING,
209
+ source: NORMAL_OFF,
210
+ moduleTrace: NORMAL_ON,
211
+ errors: NORMAL_ON,
212
+ errorsCount: NORMAL_ON,
213
+ errorDetails: AUTO_FOR_TO_STRING,
214
+ errorStack: OFF_FOR_TO_STRING,
215
+ warnings: NORMAL_ON,
216
+ warningsCount: NORMAL_ON,
217
+ publicPath: OFF_FOR_TO_STRING,
218
+ logging: ({ all }, { forToString }) => forToString && all !== false ? "info" : false,
219
+ loggingDebug: () => [],
220
+ loggingTrace: OFF_FOR_TO_STRING,
221
+ excludeModules: () => [],
222
+ excludeAssets: () => [],
223
+ modulesSort: () => "depth",
224
+ chunkModulesSort: () => "name",
225
+ nestedModulesSort: () => false,
226
+ chunksSort: () => false,
227
+ assetsSort: () => "!size",
228
+ outputPath: OFF_FOR_TO_STRING,
229
+ colors: () => false
230
+ };
231
+ const normalizeFilter = item => {
232
+ if (typeof item === "string") {
233
+ const regExp = new RegExp(`[\\\\/]${item.replace(/[-[\]{}()*+?.\\^$|]/g, "\\$&")}([\\\\/]|$|!|\\?)`);
234
+ return ident => regExp.test(ident);
235
+ }
236
+ if (item &&
237
+ typeof item === "object" &&
238
+ "test" in item &&
239
+ typeof item.test === "function") {
240
+ const test = item.test.bind(item);
241
+ return ident => test(ident);
242
+ }
243
+ if (typeof item === "function") {
244
+ return item;
245
+ }
246
+ if (typeof item === "boolean") {
247
+ return () => item;
248
+ }
249
+ };
250
+ const NORMALIZER = {
251
+ excludeModules: (value) => {
252
+ const array = !Array.isArray(value) ? (value ? [value] : []) : value;
253
+ return array.map(normalizeFilter);
254
+ },
255
+ excludeAssets: (value) => {
256
+ const array = !Array.isArray(value) ? (value ? [value] : []) : value;
257
+ return array.map(normalizeFilter);
258
+ },
259
+ warningsFilter: (value) => {
260
+ const array = !Array.isArray(value) ? (value ? [value] : []) : value;
261
+ return array.map(filter => {
262
+ if (typeof filter === "string") {
263
+ return (warning, warningString) => warningString.includes(filter);
264
+ }
265
+ if (filter instanceof RegExp) {
266
+ return (warning, warningString) => filter.test(warningString);
267
+ }
268
+ if (typeof filter === "function") {
269
+ return filter;
270
+ }
271
+ throw new Error(`Can only filter warnings with Strings or RegExps. (Given: ${filter})`);
272
+ });
273
+ },
274
+ logging: (value) => {
275
+ if (value === true)
276
+ value = "log";
277
+ return value;
278
+ },
279
+ loggingDebug: (value) => {
280
+ const array = !Array.isArray(value) ? (value ? [value] : []) : value;
281
+ return array.map(normalizeFilter);
282
+ }
283
+ };
284
+ class DefaultStatsPresetPlugin {
285
+ apply(compiler) {
286
+ compiler.hooks.compilation.tap("DefaultStatsPresetPlugin", compilation => {
287
+ for (const key of Object.keys(NAMED_PRESETS)) {
288
+ const defaults = NAMED_PRESETS[key];
289
+ compilation.hooks.statsPreset
290
+ .for(key)
291
+ .tap("DefaultStatsPresetPlugin", (options, context) => {
292
+ applyDefaults(options, defaults);
293
+ });
294
+ }
295
+ compilation.hooks.statsNormalize.tap("DefaultStatsPresetPlugin", (options, context) => {
296
+ for (const key of Object.keys(DEFAULTS)) {
297
+ if (options[key] === undefined)
298
+ options[key] = DEFAULTS[key](options, context, compilation);
299
+ }
300
+ for (const key of Object.keys(NORMALIZER)) {
301
+ options[key] = NORMALIZER[key](options[key]);
302
+ }
303
+ });
304
+ });
305
+ }
306
+ }
307
+ exports.DefaultStatsPresetPlugin = DefaultStatsPresetPlugin;
@@ -1,6 +1,5 @@
1
1
  import * as binding from "@rspack/binding";
2
- import type { Compilation } from "../Compilation";
3
- import type { StatsOptions } from "../config";
2
+ import type { Compilation, NormalizedStatsOptions } from "../Compilation";
4
3
  import { type Comparator } from "../util/comparators";
5
4
  import type { StatsFactory, StatsFactoryContext } from "./StatsFactory";
6
5
  export type KnownStatsChunkGroup = binding.JsStatsChunkGroup;
@@ -97,10 +96,6 @@ export type SimpleExtractors = {
97
96
  moduleReason: ExtractorsByOption<binding.JsStatsModuleReason, StatsModuleReason>;
98
97
  chunk: ExtractorsByOption<StatsChunk, KnownStatsChunk>;
99
98
  };
100
- type KnownNormalizedStatsOptions = {
101
- context: string;
102
- };
103
- export type NormalizedStatsOptions = KnownNormalizedStatsOptions & Omit<StatsOptions, keyof KnownNormalizedStatsOptions> & Record<string, any>;
104
99
  export declare const uniqueArray: <T, I>(items: Iterable<T>, selector: (arg: T) => Iterable<I>) => I[];
105
100
  export declare const uniqueOrderedArray: <T, I>(items: Iterable<T>, selector: (arg: T) => Iterable<I>, comparator: Comparator) => I[];
106
101
  export declare const iterateConfig: (config: Record<string, Record<string, Function>>, options: NormalizedStatsOptions, fn: (a1: string, a2: Function) => void) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rspack/core",
3
- "version": "0.7.2-canary-fdfff21-20240606140946",
3
+ "version": "0.7.2-canary-3dcf0a9-20240607151650",
4
4
  "webpackVersion": "5.75.0",
5
5
  "license": "MIT",
6
6
  "description": "A Fast Rust-based Web Bundler",
@@ -72,15 +72,15 @@
72
72
  "watchpack": "^2.4.0",
73
73
  "zod": "^3.21.4",
74
74
  "zod-validation-error": "1.3.1",
75
- "@rspack/core": "0.7.2-canary-fdfff21-20240606140946",
76
- "@rspack/plugin-minify": "^0.7.2-canary-fdfff21-20240606140946"
75
+ "@rspack/plugin-minify": "^0.7.2-canary-3dcf0a9-20240607151650",
76
+ "@rspack/core": "0.7.2-canary-3dcf0a9-20240607151650"
77
77
  },
78
78
  "dependencies": {
79
79
  "@module-federation/runtime-tools": "0.1.6",
80
80
  "caniuse-lite": "^1.0.30001616",
81
81
  "tapable": "2.2.1",
82
82
  "webpack-sources": "3.2.3",
83
- "@rspack/binding": "0.7.2-canary-fdfff21-20240606140946"
83
+ "@rspack/binding": "0.7.2-canary-3dcf0a9-20240607151650"
84
84
  },
85
85
  "peerDependencies": {
86
86
  "@swc/helpers": ">=0.5.1"