@rspack/core 1.0.0-alpha.2 → 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 (166) 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/ChunkGraph.d.ts +1 -1
  11. package/dist/Compilation.d.ts +9 -9
  12. package/dist/Compilation.js +27 -24
  13. package/dist/Compiler.d.ts +6 -6
  14. package/dist/Compiler.js +5 -6
  15. package/dist/ContextModuleFactory.d.ts +1 -1
  16. package/dist/ErrorHelpers.d.ts +16 -7
  17. package/dist/ErrorHelpers.js +34 -33
  18. package/dist/ExecuteModulePlugin.js +1 -1
  19. package/dist/FileSystem.d.ts +2 -2
  20. package/dist/Module.d.ts +5 -5
  21. package/dist/Module.js +3 -6
  22. package/dist/MultiCompiler.d.ts +3 -3
  23. package/dist/MultiCompiler.js +1 -1
  24. package/dist/MultiStats.d.ts +2 -2
  25. package/dist/MultiWatching.d.ts +2 -2
  26. package/dist/NormalModule.d.ts +1 -1
  27. package/dist/NormalModuleFactory.d.ts +1 -1
  28. package/dist/Resolver.d.ts +19 -0
  29. package/dist/Resolver.js +39 -0
  30. package/dist/ResolverFactory.d.ts +12 -46
  31. package/dist/ResolverFactory.js +55 -120
  32. package/dist/RspackError.d.ts +1 -1
  33. package/dist/RuntimeGlobals.d.ts +1 -1
  34. package/dist/RuntimeGlobals.js +3 -3
  35. package/dist/Stats.d.ts +2 -2
  36. package/dist/Stats.js +4 -4
  37. package/dist/Template.js +2 -2
  38. package/dist/Watching.d.ts +3 -3
  39. package/dist/builtin-loader/swc/index.d.ts +0 -2
  40. package/dist/builtin-loader/swc/index.js +1 -3
  41. package/dist/builtin-loader/swc/pluginImport.d.ts +17 -1
  42. package/dist/builtin-loader/swc/react.d.ts +11 -1
  43. package/dist/builtin-plugin/APIPlugin.d.ts +3 -3
  44. package/dist/builtin-plugin/ArrayPushCallbackChunkFormatPlugin.d.ts +3 -3
  45. package/dist/builtin-plugin/AssetModulesPlugin.d.ts +3 -3
  46. package/dist/builtin-plugin/AsyncWebAssemblyModulesPlugin.d.ts +3 -3
  47. package/dist/builtin-plugin/BannerPlugin.d.ts +25 -4
  48. package/dist/builtin-plugin/BundlerInfoRspackPlugin.d.ts +4 -4
  49. package/dist/builtin-plugin/ChunkPrefetchPreloadPlugin.d.ts +3 -3
  50. package/dist/builtin-plugin/CommonJsChunkFormatPlugin.d.ts +3 -3
  51. package/dist/builtin-plugin/CopyRspackPlugin.d.ts +4 -4
  52. package/dist/builtin-plugin/CssModulesPlugin.d.ts +3 -3
  53. package/dist/builtin-plugin/DataUriPlugin.d.ts +3 -3
  54. package/dist/builtin-plugin/DefinePlugin.d.ts +10 -4
  55. package/dist/builtin-plugin/DefinePlugin.js +42 -8
  56. package/dist/builtin-plugin/DeterministicChunkIdsPlugin.d.ts +3 -3
  57. package/dist/builtin-plugin/DeterministicModuleIdsPlugin.d.ts +3 -3
  58. package/dist/builtin-plugin/DynamicEntryPlugin.d.ts +5 -5
  59. package/dist/builtin-plugin/ElectronTargetPlugin.d.ts +3 -3
  60. package/dist/builtin-plugin/EnableChunkLoadingPlugin.d.ts +3 -3
  61. package/dist/builtin-plugin/EnableLibraryPlugin.d.ts +2 -2
  62. package/dist/builtin-plugin/EnableWasmLoadingPlugin.d.ts +3 -3
  63. package/dist/builtin-plugin/EnsureChunkConditionsPlugin.d.ts +3 -3
  64. package/dist/builtin-plugin/EntryPlugin.d.ts +5 -5
  65. package/dist/builtin-plugin/EntryPlugin.js +1 -1
  66. package/dist/builtin-plugin/EvalDevToolModulePlugin.d.ts +4 -4
  67. package/dist/builtin-plugin/EvalSourceMapDevToolPlugin.d.ts +5 -5
  68. package/dist/builtin-plugin/ExternalsPlugin.d.ts +22 -6
  69. package/dist/builtin-plugin/FetchCompileAsyncWasmPlugin.d.ts +3 -3
  70. package/dist/builtin-plugin/FileUriPlugin.d.ts +3 -3
  71. package/dist/builtin-plugin/FlagDependencyExportsPlugin.d.ts +3 -3
  72. package/dist/builtin-plugin/FlagDependencyUsagePlugin.d.ts +3 -3
  73. package/dist/builtin-plugin/HotModuleReplacementPlugin.d.ts +2 -2
  74. package/dist/builtin-plugin/HtmlRspackPlugin.d.ts +19 -4
  75. package/dist/builtin-plugin/HttpExternalsRspackPlugin.d.ts +4 -4
  76. package/dist/builtin-plugin/IgnorePlugin.d.ts +4 -4
  77. package/dist/builtin-plugin/InferAsyncModulesPlugin.d.ts +3 -3
  78. package/dist/builtin-plugin/JavascriptModulesPlugin.d.ts +2 -2
  79. package/dist/builtin-plugin/JsLoaderRspackPlugin.d.ts +4 -4
  80. package/dist/builtin-plugin/JsonModulesPlugin.d.ts +3 -3
  81. package/dist/builtin-plugin/LightningCssMiminizerRspackPlugin.d.ts +4 -4
  82. package/dist/builtin-plugin/LimitChunkCountPlugin.d.ts +4 -4
  83. package/dist/builtin-plugin/MangleExportsPlugin.d.ts +3 -3
  84. package/dist/builtin-plugin/MergeDuplicateChunksPlugin.d.ts +3 -3
  85. package/dist/builtin-plugin/ModuleChunkFormatPlugin.d.ts +3 -3
  86. package/dist/builtin-plugin/ModuleConcatenationPlugin.d.ts +3 -3
  87. package/dist/builtin-plugin/NamedChunkIdsPlugin.d.ts +3 -3
  88. package/dist/builtin-plugin/NamedModuleIdsPlugin.d.ts +3 -3
  89. package/dist/builtin-plugin/NaturalChunkIdsPlugin.d.ts +3 -3
  90. package/dist/builtin-plugin/NaturalModuleIdsPlugin.d.ts +3 -3
  91. package/dist/builtin-plugin/NodeTargetPlugin.d.ts +3 -3
  92. package/dist/builtin-plugin/ProgressPlugin.d.ts +4 -4
  93. package/dist/builtin-plugin/ProvidePlugin.d.ts +3 -3
  94. package/dist/builtin-plugin/RealContentHashPlugin.d.ts +3 -3
  95. package/dist/builtin-plugin/RemoveEmptyChunksPlugin.d.ts +3 -3
  96. package/dist/builtin-plugin/RuntimeChunkPlugin.d.ts +4 -4
  97. package/dist/builtin-plugin/RuntimePlugin.d.ts +3 -3
  98. package/dist/builtin-plugin/SideEffectsFlagPlugin.d.ts +3 -3
  99. package/dist/builtin-plugin/SizeLimitsPlugin.d.ts +9 -4
  100. package/dist/builtin-plugin/SourceMapDevToolPlugin.d.ts +4 -4
  101. package/dist/builtin-plugin/SplitChunksPlugin.d.ts +3 -3
  102. package/dist/builtin-plugin/SwcCssMinimizerPlugin.d.ts +12 -4
  103. package/dist/builtin-plugin/SwcCssMinimizerPlugin.js +7 -1
  104. package/dist/builtin-plugin/SwcJsMinimizerPlugin.d.ts +4 -4
  105. package/dist/builtin-plugin/SwcJsMinimizerPlugin.js +2 -2
  106. package/dist/builtin-plugin/WarnCaseSensitiveModulesPlugin.d.ts +3 -3
  107. package/dist/builtin-plugin/WebWorkerTemplatePlugin.d.ts +3 -3
  108. package/dist/builtin-plugin/WorkerPlugin.d.ts +3 -3
  109. package/dist/builtin-plugin/WorkerPlugin.js +5 -1
  110. package/dist/builtin-plugin/base.d.ts +6 -6
  111. package/dist/builtin-plugin/base.js +4 -4
  112. package/dist/builtin-plugin/css-extract/index.d.ts +1 -1
  113. package/dist/builtin-plugin/css-extract/loader.js +15 -5
  114. package/dist/builtin-plugin/css-extract/utils.d.ts +1 -1
  115. package/dist/builtin-plugin/index.d.ts +1 -7
  116. package/dist/builtin-plugin/index.js +3 -17
  117. package/dist/builtin-plugin/lazy-compilation/lazyCompilation.d.ts +11 -17
  118. package/dist/builtin-plugin/lazy-compilation/plugin.d.ts +2 -2
  119. package/dist/config/adapter.d.ts +5 -4
  120. package/dist/config/adapter.js +23 -11
  121. package/dist/config/adapterRuleUse.d.ts +7 -7
  122. package/dist/config/adapterRuleUse.js +1 -1
  123. package/dist/config/browserslistTargetHandler.js +1 -1
  124. package/dist/config/defaults.d.ts +1 -1
  125. package/dist/config/defaults.js +4 -3
  126. package/dist/config/zod.d.ts +491 -384
  127. package/dist/config/zod.js +44 -42
  128. package/dist/container/ContainerPlugin.d.ts +3 -3
  129. package/dist/container/ContainerReferencePlugin.d.ts +4 -4
  130. package/dist/container/ModuleFederationPlugin.d.ts +2 -2
  131. package/dist/container/ModuleFederationPlugin.js +2 -2
  132. package/dist/container/ModuleFederationPluginV1.d.ts +5 -5
  133. package/dist/container/ModuleFederationRuntimePlugin.d.ts +3 -3
  134. package/dist/container/default.runtime.js +1 -1
  135. package/dist/lib/EntryOptionPlugin.d.ts +2 -2
  136. package/dist/lib/NormalModuleReplacementPlugin.d.ts +2 -2
  137. package/dist/loader-runner/index.d.ts +2 -2
  138. package/dist/loader-runner/index.js +38 -51
  139. package/dist/loader-runner/loadLoader.js +1 -1
  140. package/dist/logging/runtime.js +1 -1
  141. package/dist/node/NodeTemplatePlugin.d.ts +1 -1
  142. package/dist/node/NodeWatchFileSystem.d.ts +1 -1
  143. package/dist/rspack.d.ts +3 -3
  144. package/dist/rspack.js +1 -1
  145. package/dist/rspackOptionsApply.d.ts +1 -1
  146. package/dist/rspackOptionsApply.js +1 -19
  147. package/dist/sharing/ConsumeSharedPlugin.d.ts +2 -2
  148. package/dist/sharing/ConsumeSharedPlugin.js +1 -1
  149. package/dist/sharing/ProvideSharedPlugin.d.ts +2 -2
  150. package/dist/sharing/SharePlugin.d.ts +1 -1
  151. package/dist/sharing/ShareRuntimePlugin.d.ts +2 -2
  152. package/dist/stats/DefaultStatsFactoryPlugin.js +246 -46
  153. package/dist/stats/DefaultStatsPresetPlugin.js +17 -17
  154. package/dist/stats/DefaultStatsPrinterPlugin.js +1 -1
  155. package/dist/stats/StatsFactory.d.ts +2 -2
  156. package/dist/stats/statsFactoryUtils.d.ts +16 -1
  157. package/dist/util/SplitChunkSize.d.ts +1 -1
  158. package/dist/util/bindingVersionCheck.js +1 -1
  159. package/dist/util/comparators.d.ts +1 -1
  160. package/dist/util/fs.d.ts +1 -1
  161. package/dist/util/identifier.d.ts +65 -62
  162. package/dist/util/identifier.js +30 -55
  163. package/dist/util/index.d.ts +1 -1
  164. package/dist/util/index.js +4 -2
  165. package/dist/util/validate.d.ts +1 -1
  166. package/package.json +7 -34
@@ -1,76 +1,79 @@
1
- /**
2
- * @param {string} context context used to create relative path
3
- * @param {string} identifier identifier used to create relative path
4
- * @param {Object=} associatedObjectForCache an object to which the cache will be attached
5
- * @returns {string} the returned relative path
6
- */
7
- export function makePathsRelative(context: string, identifier: string, associatedObjectForCache?: Object | undefined): string;
8
- export namespace makePathsRelative {
1
+ interface ParsedResource {
2
+ resource: string;
3
+ path: string;
4
+ query: string;
5
+ fragment: string;
6
+ }
7
+ type ParsedResourceWithoutFragment = Omit<ParsedResource, "fragment">;
8
+ export declare const makePathsRelative: {
9
+ (context: string, identifier: string, associatedObjectForCache: object | undefined): string;
9
10
  /**
10
11
  * @param {Object=} associatedObjectForCache an object to which the cache will be attached
11
12
  * @returns {function(string, string): string} cached function
12
13
  */
13
- function bindCache(associatedObjectForCache?: Object | undefined): (arg0: string, arg1: string) => string;
14
+ bindCache(associatedObjectForCache: object | undefined): (arg0: string, arg1: string) => string;
14
15
  /**
15
16
  * @param {string} context context used to create relative path
16
17
  * @param {Object=} associatedObjectForCache an object to which the cache will be attached
17
18
  * @returns {function(string): string} cached function
18
19
  */
19
- function bindContextCache(context: string, associatedObjectForCache?: Object | undefined): (arg0: string) => string;
20
- }
21
- /**
22
- * @param {string} context context used to create relative path
23
- * @param {string} identifier identifier used to create relative path
24
- * @param {Object=} associatedObjectForCache an object to which the cache will be attached
25
- * @returns {string} the returned relative path
26
- */
27
- export function makePathsAbsolute(context: string, identifier: string, associatedObjectForCache?: Object | undefined): string;
28
- export namespace makePathsAbsolute { }
29
- /**
30
- * @param {string} str the path with query and fragment
31
- * @param {Object=} associatedObjectForCache an object to which the cache will be attached
32
- * @returns {ParsedResource} parsed parts
33
- */
34
- export function parseResource(str: string, associatedObjectForCache?: Object | undefined): ParsedResource;
35
- export namespace parseResource {
36
- function bindCache(associatedObjectForCache: any): (str: any) => any;
37
- }
38
- /**
39
- * @param {string} str the path with query and fragment
40
- * @param {Object=} associatedObjectForCache an object to which the cache will be attached
41
- * @returns {ParsedResource} parsed parts
42
- */
43
- export function parseResourceWithoutFragment(str: string, associatedObjectForCache?: Object | undefined): ParsedResource;
44
- export namespace parseResourceWithoutFragment { }
45
- export function getUndoPath(filename: string, outputPath: string, enforceRelative: boolean): string;
46
- export type MakeRelativePathsCache = {
47
- relativePaths?: Map<string, Map<string, string>> | undefined;
20
+ bindContextCache(context: string, associatedObjectForCache: object | undefined): (arg0: string) => string;
48
21
  };
49
- export type ParsedResource = {
50
- resource: string;
51
- path: string;
52
- query: string;
53
- fragment: string;
22
+ export declare const makePathsAbsolute: {
23
+ (context: string, identifier: string, associatedObjectForCache: object | undefined): string;
24
+ /**
25
+ * @param {Object=} associatedObjectForCache an object to which the cache will be attached
26
+ * @returns {function(string, string): string} cached function
27
+ */
28
+ bindCache(associatedObjectForCache: object | undefined): (arg0: string, arg1: string) => string;
29
+ /**
30
+ * @param {string} context context used to create relative path
31
+ * @param {Object=} associatedObjectForCache an object to which the cache will be attached
32
+ * @returns {function(string): string} cached function
33
+ */
34
+ bindContextCache(context: string, associatedObjectForCache: object | undefined): (arg0: string) => string;
54
35
  };
55
- export type ParsedResourceWithoutFragment = {
56
- resource: string;
57
- path: string;
58
- query: string;
36
+ export declare const contextify: {
37
+ (context: string, identifier: string, associatedObjectForCache: object | undefined): string;
38
+ /**
39
+ * @param {Object=} associatedObjectForCache an object to which the cache will be attached
40
+ * @returns {function(string, string): string} cached function
41
+ */
42
+ bindCache(associatedObjectForCache: object | undefined): (arg0: string, arg1: string) => string;
43
+ /**
44
+ * @param {string} context context used to create relative path
45
+ * @param {Object=} associatedObjectForCache an object to which the cache will be attached
46
+ * @returns {function(string): string} cached function
47
+ */
48
+ bindContextCache(context: string, associatedObjectForCache: object | undefined): (arg0: string) => string;
49
+ };
50
+ export declare const absolutify: {
51
+ (context: string, identifier: string, associatedObjectForCache: object | undefined): string;
52
+ /**
53
+ * @param {Object=} associatedObjectForCache an object to which the cache will be attached
54
+ * @returns {function(string, string): string} cached function
55
+ */
56
+ bindCache(associatedObjectForCache: object | undefined): (arg0: string, arg1: string) => string;
57
+ /**
58
+ * @param {string} context context used to create relative path
59
+ * @param {Object=} associatedObjectForCache an object to which the cache will be attached
60
+ * @returns {function(string): string} cached function
61
+ */
62
+ bindContextCache(context: string, associatedObjectForCache: object | undefined): (arg0: string) => string;
63
+ };
64
+ export declare const parseResource: {
65
+ (str: string, associatedObjectForCache?: object): ParsedResource;
66
+ bindCache(associatedObjectForCache: object): (str: string) => ParsedResource;
67
+ };
68
+ export declare const parseResourceWithoutFragment: {
69
+ (str: string, associatedObjectForCache?: object): ParsedResourceWithoutFragment;
70
+ bindCache(associatedObjectForCache: object): (str: string) => ParsedResourceWithoutFragment;
59
71
  };
60
72
  /**
61
- * @param {string} context context used to create relative path
62
- * @param {string} identifier identifier used to create relative path
63
- * @param {Object=} associatedObjectForCache an object to which the cache will be attached
64
- * @returns {string} the returned relative path
65
- */
66
- export function contextify(context: string, identifier: string, associatedObjectForCache?: Object | undefined): string;
67
- export namespace contextify { }
68
- /**
69
- * @param {string} context context used to create relative path
70
- * @param {string} identifier identifier used to create relative path
71
- * @param {Object=} associatedObjectForCache an object to which the cache will be attached
72
- * @returns {string} the returned relative path
73
+ * @param {string} filename the filename which should be undone
74
+ * @param {string} outputPath the output path that is restored (only relevant when filename contains "..")
75
+ * @param {boolean} enforceRelative true returns ./ for empty paths
76
+ * @returns {string} repeated ../ to leave the directory of the provided filename to be back on output dir
73
77
  */
74
- export function absolutify(context: string, identifier: string, associatedObjectForCache?: Object | undefined): string;
75
- export namespace absolutify { }
76
- import path = require("path");
78
+ export declare const getUndoPath: (filename: string, outputPath: string, enforceRelative: boolean) => string;
79
+ export {};
@@ -1,17 +1,17 @@
1
+ "use strict";
1
2
  /*
2
3
  MIT License http://www.opensource.org/licenses/mit-license.php
3
4
  */
4
- "use strict";
5
- const path = require("path");
5
+ var __importDefault = (this && this.__importDefault) || function (mod) {
6
+ return (mod && mod.__esModule) ? mod : { "default": mod };
7
+ };
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.getUndoPath = exports.parseResourceWithoutFragment = exports.parseResource = exports.absolutify = exports.contextify = exports.makePathsAbsolute = exports.makePathsRelative = void 0;
10
+ const path_1 = __importDefault(require("path"));
6
11
  const WINDOWS_ABS_PATH_REGEXP = /^[a-zA-Z]:[\\/]/;
7
12
  const SEGMENTS_SPLIT_REGEXP = /([|!])/;
8
13
  const WINDOWS_PATH_SEPARATOR_REGEXP = /\\/g;
9
- /**
10
- * @typedef {Object} MakeRelativePathsCache
11
- * @property {Map<string, Map<string, string>>=} relativePaths
12
- */
13
- // @ts-expect-error
14
- const relativePathToRequest = relativePath => {
14
+ const relativePathToRequest = (relativePath) => {
15
15
  if (relativePath === "")
16
16
  return "./.";
17
17
  if (relativePath === "..")
@@ -37,7 +37,7 @@ const absoluteToRequest = (context, maybeAbsolutePath) => {
37
37
  let resource = querySplitPos === -1
38
38
  ? maybeAbsolutePath
39
39
  : maybeAbsolutePath.slice(0, querySplitPos);
40
- resource = relativePathToRequest(path.posix.relative(context, resource));
40
+ resource = relativePathToRequest(path_1.default.posix.relative(context, resource));
41
41
  return querySplitPos === -1
42
42
  ? resource
43
43
  : resource + maybeAbsolutePath.slice(querySplitPos);
@@ -47,7 +47,7 @@ const absoluteToRequest = (context, maybeAbsolutePath) => {
47
47
  let resource = querySplitPos === -1
48
48
  ? maybeAbsolutePath
49
49
  : maybeAbsolutePath.slice(0, querySplitPos);
50
- resource = path.win32.relative(context, resource);
50
+ resource = path_1.default.win32.relative(context, resource);
51
51
  if (!WINDOWS_ABS_PATH_REGEXP.test(resource)) {
52
52
  resource = relativePathToRequest(resource.replace(WINDOWS_PATH_SEPARATOR_REGEXP, "/"));
53
53
  }
@@ -65,28 +65,19 @@ const absoluteToRequest = (context, maybeAbsolutePath) => {
65
65
  */
66
66
  const requestToAbsolute = (context, relativePath) => {
67
67
  if (relativePath.startsWith("./") || relativePath.startsWith("../"))
68
- return path.join(context, relativePath);
68
+ return path_1.default.join(context, relativePath);
69
69
  return relativePath;
70
70
  };
71
- // @ts-expect-error
72
- const makeCacheable = realFn => {
73
- /** @type {WeakMap<object, Map<string, ParsedResource>>} */
71
+ const makeCacheable = (realFn) => {
74
72
  const cache = new WeakMap();
75
- // @ts-expect-error
76
- const getCache = associatedObjectForCache => {
73
+ const getCache = (associatedObjectForCache) => {
77
74
  const entry = cache.get(associatedObjectForCache);
78
75
  if (entry !== undefined)
79
76
  return entry;
80
- /** @type {Map<string, ParsedResource>} */
81
77
  const map = new Map();
82
78
  cache.set(associatedObjectForCache, map);
83
79
  return map;
84
80
  };
85
- /**
86
- * @param {string} str the path with query and fragment
87
- * @param {Object=} associatedObjectForCache an object to which the cache will be attached
88
- * @returns {ParsedResource} parsed parts
89
- */
90
81
  const fn = (str, associatedObjectForCache) => {
91
82
  if (!associatedObjectForCache)
92
83
  return realFn(str);
@@ -98,11 +89,9 @@ const makeCacheable = realFn => {
98
89
  cache.set(str, result);
99
90
  return result;
100
91
  };
101
- // @ts-expect-error
102
- fn.bindCache = associatedObjectForCache => {
92
+ fn.bindCache = (associatedObjectForCache) => {
103
93
  const cache = getCache(associatedObjectForCache);
104
- // @ts-expect-error
105
- return str => {
94
+ return (str) => {
106
95
  const entry = cache.get(str);
107
96
  if (entry !== undefined)
108
97
  return entry;
@@ -113,9 +102,7 @@ const makeCacheable = realFn => {
113
102
  };
114
103
  return fn;
115
104
  };
116
- // @ts-expect-error
117
- const makeCacheableWithContext = fn => {
118
- /** @type {WeakMap<object, Map<string, Map<string, string>>>} */
105
+ const makeCacheableWithContext = (fn) => {
119
106
  const cache = new WeakMap();
120
107
  /**
121
108
  * @param {string} context context used to create relative path
@@ -126,6 +113,7 @@ const makeCacheableWithContext = fn => {
126
113
  const cachedFn = (context, identifier, associatedObjectForCache) => {
127
114
  if (!associatedObjectForCache)
128
115
  return fn(context, identifier);
116
+ /** @type {Map<string, Map<string, string>> | undefined} */
129
117
  let innerCache = cache.get(associatedObjectForCache);
130
118
  if (innerCache === undefined) {
131
119
  innerCache = new Map();
@@ -152,8 +140,7 @@ const makeCacheableWithContext = fn => {
152
140
  * @param {Object=} associatedObjectForCache an object to which the cache will be attached
153
141
  * @returns {function(string, string): string} cached function
154
142
  */
155
- cachedFn.bindCache = associatedObjectForCache => {
156
- // @ts-expect-error
143
+ cachedFn.bindCache = (associatedObjectForCache) => {
157
144
  let innerCache;
158
145
  if (associatedObjectForCache) {
159
146
  innerCache = cache.get(associatedObjectForCache);
@@ -172,11 +159,10 @@ const makeCacheableWithContext = fn => {
172
159
  */
173
160
  const boundFn = (context, identifier) => {
174
161
  let cachedResult;
175
- // @ts-expect-error
176
- let innerSubCache = innerCache.get(context);
162
+ let innerSubCache = innerCache?.get(context);
177
163
  if (innerSubCache === undefined) {
178
- // @ts-expect-error
179
- innerCache.set(context, (innerSubCache = new Map()));
164
+ innerSubCache = new Map();
165
+ innerCache?.set(context, innerSubCache);
180
166
  }
181
167
  else {
182
168
  cachedResult = innerSubCache.get(identifier);
@@ -198,7 +184,6 @@ const makeCacheableWithContext = fn => {
198
184
  * @returns {function(string): string} cached function
199
185
  */
200
186
  cachedFn.bindContextCache = (context, associatedObjectForCache) => {
201
- // @ts-expect-error
202
187
  let innerSubCache;
203
188
  if (associatedObjectForCache) {
204
189
  let innerCache = cache.get(associatedObjectForCache);
@@ -218,16 +203,14 @@ const makeCacheableWithContext = fn => {
218
203
  * @param {string} identifier identifier used to create relative path
219
204
  * @returns {string} the returned relative path
220
205
  */
221
- const boundFn = identifier => {
222
- // @ts-expect-error
223
- const cachedResult = innerSubCache.get(identifier);
206
+ const boundFn = (identifier) => {
207
+ const cachedResult = innerSubCache?.get(identifier);
224
208
  if (cachedResult !== undefined) {
225
209
  return cachedResult;
226
210
  }
227
211
  else {
228
212
  const result = fn(context, identifier);
229
- // @ts-expect-error
230
- innerSubCache.set(identifier, result);
213
+ innerSubCache?.set(identifier, result);
231
214
  return result;
232
215
  }
233
216
  };
@@ -272,8 +255,7 @@ const _contextify = (context, request) => {
272
255
  .map(r => absoluteToRequest(context, r))
273
256
  .join("!");
274
257
  };
275
- const contextify = makeCacheableWithContext(_contextify);
276
- exports.contextify = contextify;
258
+ exports.contextify = makeCacheableWithContext(_contextify);
277
259
  /**
278
260
  * @param {string} context absolute context path
279
261
  * @param {string} request any request string
@@ -285,25 +267,19 @@ const _absolutify = (context, request) => {
285
267
  .map(r => requestToAbsolute(context, r))
286
268
  .join("!");
287
269
  };
288
- const absolutify = makeCacheableWithContext(_absolutify);
289
- exports.absolutify = absolutify;
270
+ exports.absolutify = makeCacheableWithContext(_absolutify);
290
271
  const PATH_QUERY_FRAGMENT_REGEXP = /^((?:\u200b.|[^?#\u200b])*)(\?(?:\u200b.|[^#\u200b])*)?(#.*)?$/;
291
272
  const PATH_QUERY_REGEXP = /^((?:\u200b.|[^?\u200b])*)(\?.*)?$/;
292
- /** @typedef {{ resource: string, path: string, query: string, fragment: string }} ParsedResource */
293
- /** @typedef {{ resource: string, path: string, query: string }} ParsedResourceWithoutFragment */
294
273
  /**
295
274
  * @param {string} str the path with query and fragment
296
275
  * @returns {ParsedResource} parsed parts
297
276
  */
298
- const _parseResource = str => {
277
+ const _parseResource = (str) => {
299
278
  const match = PATH_QUERY_FRAGMENT_REGEXP.exec(str);
300
279
  return {
301
280
  resource: str,
302
- // @ts-expect-error
303
281
  path: match[1].replace(/\u200b(.)/g, "$1"),
304
- // @ts-expect-error
305
282
  query: match[2] ? match[2].replace(/\u200b(.)/g, "$1") : "",
306
- // @ts-expect-error
307
283
  fragment: match[3] || ""
308
284
  };
309
285
  };
@@ -313,13 +289,11 @@ exports.parseResource = makeCacheable(_parseResource);
313
289
  * @param {string} str the path with query and fragment
314
290
  * @returns {ParsedResourceWithoutFragment} parsed parts
315
291
  */
316
- const _parseResourceWithoutFragment = str => {
292
+ const _parseResourceWithoutFragment = (str) => {
317
293
  const match = PATH_QUERY_REGEXP.exec(str);
318
294
  return {
319
295
  resource: str,
320
- // @ts-expect-error
321
296
  path: match[1].replace(/\u200b(.)/g, "$1"),
322
- // @ts-expect-error
323
297
  query: match[2] ? match[2].replace(/\u200b(.)/g, "$1") : ""
324
298
  };
325
299
  };
@@ -330,7 +304,7 @@ exports.parseResourceWithoutFragment = makeCacheable(_parseResourceWithoutFragme
330
304
  * @param {boolean} enforceRelative true returns ./ for empty paths
331
305
  * @returns {string} repeated ../ to leave the directory of the provided filename to be back on output dir
332
306
  */
333
- exports.getUndoPath = (filename, outputPath, enforceRelative) => {
307
+ const getUndoPath = (filename, outputPath, enforceRelative) => {
334
308
  let depth = -1;
335
309
  let append = "";
336
310
  outputPath = outputPath.replace(/[\\/]$/, "");
@@ -359,3 +333,4 @@ exports.getUndoPath = (filename, outputPath, enforceRelative) => {
359
333
  ? `./${append}`
360
334
  : append;
361
335
  };
336
+ exports.getUndoPath = getUndoPath;
@@ -1,6 +1,6 @@
1
1
  /// <reference types="node" />
2
2
  import type { JsRspackError, JsStatsError } from "@rspack/binding";
3
- import { LoaderObject } from "../loader-runner";
3
+ import type { LoaderObject } from "../loader-runner";
4
4
  export declare function mapValues(record: Record<string, string>, fn: (key: string) => string): {
5
5
  [k: string]: string;
6
6
  };
@@ -63,10 +63,12 @@ function concatErrorMsgAndStack(err) {
63
63
  if (typeof err === "string") {
64
64
  return new Error(err);
65
65
  }
66
- if ("stack" in err) {
66
+ const hideStack = "hideStack" in err && err.hideStack;
67
+ if (!hideStack && "stack" in err) {
67
68
  err.message = err.stack || err.message;
68
- return err;
69
69
  }
70
+ // maybe `null`, use `undefined` to compatible with `Option<String>`
71
+ err.stack = err.stack || undefined;
70
72
  return err;
71
73
  }
72
74
  exports.concatErrorMsgAndStack = concatErrorMsgAndStack;
@@ -1,3 +1,3 @@
1
- import { z } from "../../compiled/zod";
1
+ import type { z } from "../../compiled/zod";
2
2
  export declare function validate<T extends z.ZodType>(opts: any, schema: T): void;
3
3
  export declare function isValidate<T extends z.ZodType>(opts: any, schema: T): boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rspack/core",
3
- "version": "1.0.0-alpha.2",
3
+ "version": "1.0.0-alpha.4",
4
4
  "webpackVersion": "5.75.0",
5
5
  "license": "MIT",
6
6
  "description": "The fast Rust-based web bundler with webpack-compatible API",
@@ -36,57 +36,30 @@
36
36
  "directory": "packages/rspack"
37
37
  },
38
38
  "devDependencies": {
39
- "@swc/plugin-remove-console": "1.5.121",
39
+ "@swc/core": "1.4.0",
40
40
  "@types/neo-async": "^2.6.6",
41
41
  "@types/watchpack": "^2.4.0",
42
42
  "@types/webpack-sources": "3.2.3",
43
- "@types/ws": "8.5.10",
44
- "babel-loader": "^9.1.0",
45
- "babel-plugin-import": "^1.13.5",
46
43
  "browserslist": "^4.21.3",
47
- "copy-webpack-plugin": "5.1.2",
48
44
  "cross-env": "^7.0.3",
49
- "del": "^6.0.0",
50
45
  "enhanced-resolve": "5.12.0",
51
- "file-loader": "^6.2.0",
52
- "glob": "^10.3.10",
53
46
  "graceful-fs": "4.2.10",
54
- "html-loader": "^5.0.0",
55
- "html-webpack-plugin": "^5.5.0",
56
- "identity-obj-proxy": "3.0.0",
57
- "jest-environment-jsdom": "^29",
58
- "jest-serializer-path": "^0.1.15",
59
- "jsdom": "^24.0.0",
47
+ "@types/graceful-fs": "4.1.9",
60
48
  "json-parse-even-better-errors": "^3.0.0",
61
- "less": "4.2.0",
62
- "less-loader": "^12.0.0",
63
49
  "neo-async": "2.6.2",
64
- "node-polyfill-webpack-plugin": "3.0.0",
65
- "postcss-loader": "^8.0.0",
66
- "postcss-pxtorem": "^6.0.0",
67
50
  "prebundle": "^1.1.0",
68
- "pug-loader": "^2.4.0",
69
- "react-relay": "^16.0.0",
70
- "sass": "1.56.2",
71
- "sass-loader": "14.2.1",
72
- "source-map": "^0.7.4",
73
- "source-map-loader": "^5.0.0",
74
- "styled-components": "^6.0.8",
75
- "terser": "5.27.2",
76
51
  "tsc-alias": "^1.8.8",
77
- "wast-loader": "^1.11.4",
78
52
  "watchpack": "^2.4.0",
79
53
  "webpack-sources": "3.2.3",
54
+ "webpack-dev-server": "4.13.1",
80
55
  "zod": "^3.21.4",
81
- "zod-validation-error": "1.3.1",
82
- "@rspack/core": "1.0.0-alpha.2",
83
- "@rspack/plugin-minify": "^1.0.0-alpha.2"
56
+ "zod-validation-error": "1.3.1"
84
57
  },
85
58
  "dependencies": {
86
59
  "@module-federation/runtime-tools": "0.2.3",
87
60
  "caniuse-lite": "^1.0.30001616",
88
- "@rspack/binding": "1.0.0-alpha.2",
89
- "@rspack/lite-tapable": "1.0.0-alpha.2"
61
+ "@rspack/lite-tapable": "1.0.0-alpha.4",
62
+ "@rspack/binding": "1.0.0-alpha.4"
90
63
  },
91
64
  "peerDependencies": {
92
65
  "@swc/helpers": ">=0.5.1"