@rspack/core 1.0.0-alpha.3 → 1.0.0-alpha.4

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 (48) hide show
  1. package/compiled/browserslist/index.js +17 -17
  2. package/compiled/enhanced-resolve/index.js +107 -107
  3. package/compiled/graceful-fs/index.js +8 -8
  4. package/compiled/json-parse-even-better-errors/index.js +2 -2
  5. package/compiled/neo-async/index.js +2 -2
  6. package/compiled/watchpack/index.js +15 -15
  7. package/compiled/webpack-sources/index.js +76 -76
  8. package/compiled/zod/index.js +30 -30
  9. package/compiled/zod-validation-error/index.js +6 -6
  10. package/dist/Compilation.js +2 -3
  11. package/dist/ErrorHelpers.d.ts +16 -7
  12. package/dist/ErrorHelpers.js +34 -33
  13. package/dist/ExecuteModulePlugin.js +1 -1
  14. package/dist/Module.d.ts +1 -2
  15. package/dist/Module.js +2 -6
  16. package/dist/MultiCompiler.js +1 -1
  17. package/dist/ResolverFactory.d.ts +5 -1
  18. package/dist/ResolverFactory.js +7 -1
  19. package/dist/RuntimeGlobals.js +3 -3
  20. package/dist/Stats.js +4 -4
  21. package/dist/Template.js +2 -2
  22. package/dist/builtin-plugin/DefinePlugin.js +2 -2
  23. package/dist/builtin-plugin/EntryPlugin.js +1 -1
  24. package/dist/builtin-plugin/SwcCssMinimizerPlugin.d.ts +10 -2
  25. package/dist/builtin-plugin/SwcCssMinimizerPlugin.js +7 -1
  26. package/dist/builtin-plugin/SwcJsMinimizerPlugin.js +2 -2
  27. package/dist/builtin-plugin/WorkerPlugin.js +5 -1
  28. package/dist/builtin-plugin/base.js +1 -1
  29. package/dist/builtin-plugin/css-extract/loader.js +3 -3
  30. package/dist/config/adapter.d.ts +1 -1
  31. package/dist/config/adapter.js +20 -9
  32. package/dist/config/adapterRuleUse.js +1 -1
  33. package/dist/config/browserslistTargetHandler.js +1 -1
  34. package/dist/config/defaults.js +4 -3
  35. package/dist/config/zod.d.ts +110 -3
  36. package/dist/config/zod.js +42 -39
  37. package/dist/container/ModuleFederationPlugin.js +2 -2
  38. package/dist/loader-runner/index.js +6 -6
  39. package/dist/logging/runtime.js +1 -1
  40. package/dist/rspack.js +1 -1
  41. package/dist/sharing/ConsumeSharedPlugin.js +1 -1
  42. package/dist/stats/DefaultStatsFactoryPlugin.js +246 -46
  43. package/dist/stats/DefaultStatsPresetPlugin.js +17 -17
  44. package/dist/stats/DefaultStatsPrinterPlugin.js +1 -1
  45. package/dist/stats/statsFactoryUtils.d.ts +15 -0
  46. package/dist/util/identifier.d.ts +65 -62
  47. package/dist/util/identifier.js +30 -55
  48. package/package.json +6 -3
@@ -2,7 +2,7 @@ import type { RawLibraryOptions, RawOptions } from "@rspack/binding";
2
2
  import type { Compiler } from "../Compiler";
3
3
  import { type LoaderContext, type LoaderDefinition, type LoaderDefinitionFunction } from "./adapterRuleUse";
4
4
  import type { RspackOptionsNormalized } from "./normalization";
5
- import { type ChunkLoading, type LibraryOptions, type Resolve } from "./zod";
5
+ import type { ChunkLoading, LibraryOptions, Resolve } from "./zod";
6
6
  export type { LoaderContext, LoaderDefinition, LoaderDefinitionFunction };
7
7
  export declare const getRawOptions: (options: RspackOptionsNormalized, compiler: Compiler) => RawOptions;
8
8
  export declare function getRawResolve(resolve: Resolve): RawOptions["resolve"];
@@ -262,7 +262,7 @@ const getRawModuleRule = (rule, path, options, upperType) => {
262
262
  }
263
263
  let funcUse;
264
264
  if (typeof rule.use === "function") {
265
- let use = rule.use;
265
+ const use = rule.use;
266
266
  funcUse = (rawContext) => {
267
267
  const context = {
268
268
  ...rawContext,
@@ -272,7 +272,7 @@ const getRawModuleRule = (rule, path, options, upperType) => {
272
272
  return (0, adapterRuleUse_1.createRawModuleRuleUses)(uses ?? [], `${path}.use`, options);
273
273
  };
274
274
  }
275
- let rawModuleRule = {
275
+ const rawModuleRule = {
276
276
  test: rule.test ? getRawRuleSetCondition(rule.test) : undefined,
277
277
  include: rule.include ? getRawRuleSetCondition(rule.include) : undefined,
278
278
  exclude: rule.exclude ? getRawRuleSetCondition(rule.exclude) : undefined,
@@ -392,10 +392,14 @@ function getRawRuleSetLogicalConditions(logical) {
392
392
  };
393
393
  }
394
394
  function getRawParserOptionsByModuleType(parser) {
395
- return Object.fromEntries(Object.entries(parser).map(([k, v]) => [k, getRawParserOptions(v, k)]));
395
+ return Object.fromEntries(Object.entries(parser)
396
+ .map(([k, v]) => [k, getRawParserOptions(v, k)])
397
+ .filter(([k, v]) => v !== undefined));
396
398
  }
397
399
  function getRawGeneratorOptionsByModuleType(parser) {
398
- return Object.fromEntries(Object.entries(parser).map(([k, v]) => [k, getRawGeneratorOptions(v, k)]));
400
+ return Object.fromEntries(Object.entries(parser)
401
+ .map(([k, v]) => [k, getRawGeneratorOptions(v, k)])
402
+ .filter(([k, v]) => v !== undefined));
399
403
  }
400
404
  function getRawParserOptions(parser, type) {
401
405
  if (type === "asset") {
@@ -405,10 +409,8 @@ function getRawParserOptions(parser, type) {
405
409
  };
406
410
  }
407
411
  else if (type === "javascript") {
408
- return {
409
- type: "javascript",
410
- javascript: getRawJavascriptParserOptions(parser)
411
- };
412
+ // Filter this out, since `parser["javascript"]` already merge into `parser["javascript/*"]` in default.ts
413
+ return;
412
414
  }
413
415
  else if (type === "javascript/auto") {
414
416
  return {
@@ -470,7 +472,8 @@ function getRawJavascriptParserOptions(parser) {
470
472
  ? "false"
471
473
  : parser.reexportExportsPresence,
472
474
  strictExportPresence: parser.strictExportPresence ?? false,
473
- worker: getRawJavascriptParserOptionsWorker(parser.worker)
475
+ worker: getRawJavascriptParserOptionsWorker(parser.worker),
476
+ overrideStrict: parser.overrideStrict
474
477
  };
475
478
  }
476
479
  function getRawJavascriptParserOptionsWorker(worker) {
@@ -546,6 +549,14 @@ function getRawGeneratorOptions(generator, type) {
546
549
  cssModule: getRawCssAutoOrModuleGeneratorOptions(generator)
547
550
  };
548
551
  }
552
+ if ([
553
+ "javascript",
554
+ "javascript/auto",
555
+ "javascript/dynamic",
556
+ "javascript/esm"
557
+ ].includes(type)) {
558
+ return undefined;
559
+ }
549
560
  throw new Error(`unreachable: unknow module type: ${type}`);
550
561
  }
551
562
  function getRawAssetGeneratorOptions(options) {
@@ -15,7 +15,7 @@ function createRawModuleRuleUses(uses, path, options) {
15
15
  exports.createRawModuleRuleUses = createRawModuleRuleUses;
16
16
  const getSwcLoaderOptions = (o, options) => {
17
17
  if (o && typeof o === "object" && o.rspackExperiments) {
18
- let expr = o.rspackExperiments;
18
+ const expr = o.rspackExperiments;
19
19
  if (expr.import || expr.pluginImport) {
20
20
  expr.import = (0, builtin_loader_1.resolvePluginImport)(expr.import || expr.pluginImport);
21
21
  }
@@ -83,7 +83,7 @@ const resolve = browsers => {
83
83
  const [parsedMajor, parserMinor] =
84
84
  // safari TP supports all features for normal safari
85
85
  parsedVersion === "TP"
86
- ? [Infinity, Infinity]
86
+ ? [Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY]
87
87
  : parsedVersion.includes("-")
88
88
  ? parsedVersion.split("-")[0].split(".")
89
89
  : parsedVersion.split(".");
@@ -30,7 +30,7 @@ const applyRspackOptionsDefaults = (options) => {
30
30
  });
31
31
  const { mode, target } = options;
32
32
  (0, assert_1.default)(!(0, util_1.isNil)(target));
33
- let targetProperties = target === false
33
+ const targetProperties = target === false
34
34
  ? false
35
35
  : typeof target === "string"
36
36
  ? (0, target_1.getTargetProperties)(target, options.context)
@@ -151,6 +151,7 @@ const applyJavascriptParserOptionsDefaults = (parserOptions, fallback) => {
151
151
  D(parserOptions, "reexportExportsPresence", fallback?.reexportExportsPresence);
152
152
  D(parserOptions, "strictExportPresence", fallback?.strictExportPresence ?? false);
153
153
  D(parserOptions, "worker", fallback?.worker ?? ["..."]);
154
+ D(parserOptions, "overrideStrict", fallback?.overrideStrict ?? undefined);
154
155
  };
155
156
  const applyModuleDefaults = (module, { asyncWebAssembly, css, targetProperties }) => {
156
157
  (0, assertNotNil_1.assertNotNill)(module.parser);
@@ -726,8 +727,8 @@ const applyOptimizationDefaults = (optimization, { production, development, css
726
727
  F(splitChunks, "minSize", () => (production ? 20000 : 10000));
727
728
  // F(splitChunks, "minRemainingSize", () => (development ? 0 : undefined));
728
729
  // F(splitChunks, "enforceSizeThreshold", () => (production ? 50000 : 30000));
729
- F(splitChunks, "maxAsyncRequests", () => (production ? 30 : Infinity));
730
- F(splitChunks, "maxInitialRequests", () => (production ? 30 : Infinity));
730
+ F(splitChunks, "maxAsyncRequests", () => production ? 30 : Number.POSITIVE_INFINITY);
731
+ F(splitChunks, "maxInitialRequests", () => production ? 30 : Number.POSITIVE_INFINITY);
731
732
  D(splitChunks, "automaticNameDelimiter", "-");
732
733
  const { cacheGroups } = splitChunks;
733
734
  if (cacheGroups) {