@rspack/core 1.5.8 → 1.6.0-beta.0

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.
@@ -222,7 +222,7 @@ export declare class Compilation {
222
222
  * Get a map of all entrypoints.
223
223
  */
224
224
  get entrypoints(): ReadonlyMap<string, Entrypoint>;
225
- get chunkGroups(): ReadonlyArray<ChunkGroup>;
225
+ get chunkGroups(): readonly ChunkGroup[];
226
226
  /**
227
227
  * Get the named chunk groups.
228
228
  *
@@ -261,7 +261,7 @@ export declare class Compilation {
261
261
  /**
262
262
  * Get an array of Asset
263
263
  */
264
- getAssets(): ReadonlyArray<Asset>;
264
+ getAssets(): readonly Asset[];
265
265
  getAsset(name: string): Readonly<Asset> | void;
266
266
  /**
267
267
  * Note: This is not a webpack public API, maybe removed in future.
@@ -19,7 +19,7 @@ export interface MultiCompilerOptions {
19
19
  */
20
20
  parallelism?: number;
21
21
  }
22
- export type MultiRspackOptions = ReadonlyArray<RspackOptions> & MultiCompilerOptions;
22
+ export type MultiRspackOptions = readonly RspackOptions[] & MultiCompilerOptions;
23
23
  export declare class MultiCompiler {
24
24
  #private;
25
25
  compilers: Compiler[];
@@ -12,8 +12,8 @@ type RawPluginImportConfig = {
12
12
  style?: RawStyleConfig;
13
13
  camelToDashComponentName?: boolean;
14
14
  transformToDefaultImport?: boolean;
15
- ignoreEsComponent?: Array<string>;
16
- ignoreStyleComponent?: Array<string>;
15
+ ignoreEsComponent?: string[];
16
+ ignoreStyleComponent?: string[];
17
17
  };
18
18
  type PluginImportConfig = {
19
19
  libraryName: string;
@@ -31,7 +31,7 @@ export type CircularDependencyRspackPluginOptions = {
31
31
  * module "app/design/components/Button.tsx". When the entry is a RegExp,
32
32
  * it is tested against the entire identifier.
33
33
  */
34
- ignoredConnections?: Array<[string | RegExp, string | RegExp]>;
34
+ ignoredConnections?: [string | RegExp, string | RegExp][];
35
35
  /**
36
36
  * Called once for every detected cycle. Providing this handler overrides the
37
37
  * default behavior of adding diagnostics to the compilation.
@@ -12,5 +12,5 @@ type CodeValue = RecursiveArrayOrRecord<CodeValuePrimitive>;
12
12
  type CodeValuePrimitive = null | undefined | RegExp | Function | string | number | boolean | bigint;
13
13
  type RecursiveArrayOrRecord<T> = {
14
14
  [index: string]: RecursiveArrayOrRecord<T>;
15
- } | Array<RecursiveArrayOrRecord<T>> | T;
15
+ } | RecursiveArrayOrRecord<T>[] | T;
16
16
  export {};
@@ -7,8 +7,8 @@ export declare namespace RsdoctorPluginData {
7
7
  export type { JsRsdoctorAsset as RsdoctorAsset, JsRsdoctorChunkGraph as RsdoctorChunkGraph, JsRsdoctorModuleGraph as RsdoctorModuleGraph, JsRsdoctorChunk as RsdoctorChunk, JsRsdoctorModule as RsdoctorModule, JsRsdoctorSideEffect as RsdoctorSideEffect, JsRsdoctorExportInfo as RsdoctorExportInfo, JsRsdoctorVariable as RsdoctorVariable, JsRsdoctorDependency as RsdoctorDependency, JsRsdoctorEntrypoint as RsdoctorEntrypoint, JsRsdoctorStatement as RsdoctorStatement, JsRsdoctorSourceRange as RsdoctorSourceRange, JsRsdoctorSourcePosition as RsdoctorSourcePosition, JsRsdoctorModuleGraphModule as RsdoctorModuleGraphModule, JsRsdoctorModuleIdsPatch as RsdoctorModuleIdsPatch, JsRsdoctorModuleOriginalSource as RsdoctorModuleOriginalSource, JsRsdoctorAssetPatch as RsdoctorAssetPatch, JsRsdoctorChunkAssets as RsdoctorChunkAssets, JsRsdoctorEntrypointAssets as RsdoctorEntrypointAssets, JsRsdoctorChunkModules as RsdoctorChunkModules, JsRsdoctorModuleSourcesPatch as RsdoctorModuleSourcesPatch };
8
8
  }
9
9
  export type RsdoctorPluginOptions = {
10
- moduleGraphFeatures?: boolean | Array<"graph" | "ids" | "sources">;
11
- chunkGraphFeatures?: boolean | Array<"graph" | "assets">;
10
+ moduleGraphFeatures?: boolean | ("graph" | "ids" | "sources")[];
11
+ chunkGraphFeatures?: boolean | ("graph" | "assets")[];
12
12
  sourceMapFeatures?: {
13
13
  module?: boolean;
14
14
  cheap?: boolean;
@@ -18,7 +18,7 @@ declare const HtmlRspackPlugin: typeof HtmlRspackPluginImpl & {
18
18
  */
19
19
  getHooks: (compilation: Compilation) => HtmlRspackPluginHooks;
20
20
  getCompilationHooks: (compilation: Compilation) => HtmlRspackPluginHooks;
21
- createHtmlTagObject: (tagName: string, attributes?: Record<string, string | boolean>, innerHTML?: string | undefined) => JsHtmlPluginTag;
21
+ createHtmlTagObject: (tagName: string, attributes?: Record<string, string | boolean>, innerHTML?: string) => JsHtmlPluginTag;
22
22
  version: number;
23
23
  };
24
24
  export { HtmlRspackPlugin };
@@ -79,10 +79,13 @@ export interface Diagnostic {
79
79
  sourceCode?: string;
80
80
  /**
81
81
  * Location to the source code.
82
- *
83
82
  * If `sourceCode` is not provided, location will be omitted.
84
83
  */
85
84
  location?: DiagnosticLocation;
85
+ /**
86
+ * Optional filename to show.
87
+ * If provided, it becomes the `StatsError.file` value in stats.
88
+ */
86
89
  file?: string;
87
90
  severity: "error" | "warning";
88
91
  }
@@ -28,10 +28,10 @@ type ResponseData = {
28
28
  byteLength: number;
29
29
  };
30
30
  type ModifyResponseData<RequestInternal extends IncomingMessage = IncomingMessage, ResponseInternal extends ServerResponse = ServerResponse> = (req: RequestInternal, res: ResponseInternal, data: Buffer | ReadStream, byteLength: number) => ResponseData;
31
- type Headers = Array<{
31
+ type Headers = {
32
32
  key: string;
33
33
  value: string;
34
- }> | Record<string, string | string[]>;
34
+ }[] | Record<string, string | string[]>;
35
35
  type OutputFileSystem = import("..").OutputFileSystem & {
36
36
  createReadStream?: typeof import("fs").createReadStream;
37
37
  statSync: import("fs").StatSyncFn;
@@ -131,8 +131,8 @@ type ProxyConfigArrayItem = {
131
131
  [key: string]: any;
132
132
  };
133
133
  type ByPass = (req: Request, res: Response, proxyConfig: ProxyConfigArrayItem) => any;
134
- type ProxyConfigArray = (ProxyConfigArrayItem | ((req?: Request | undefined, res?: Response | undefined, next?: NextFunction | undefined) => ProxyConfigArrayItem))[];
135
- type Callback = (stats?: Stats | MultiStats | undefined) => any;
134
+ type ProxyConfigArray = (ProxyConfigArrayItem | ((req?: Request, res?: Response, next?: NextFunction) => ProxyConfigArrayItem))[];
135
+ type Callback = (stats?: Stats | MultiStats) => any;
136
136
  type DevMiddlewareContext<_RequestInternal extends IncomingMessage = IncomingMessage, _ResponseInternal extends ServerResponse = ServerResponse> = {
137
137
  state: boolean;
138
138
  stats: Stats | MultiStats | undefined;
@@ -84,9 +84,9 @@ export type ExperimentCacheNormalized = boolean | {
84
84
  buildDependencies: string[];
85
85
  version: string;
86
86
  snapshot: {
87
- immutablePaths: Array<string | RegExp>;
88
- unmanagedPaths: Array<string | RegExp>;
89
- managedPaths: Array<string | RegExp>;
87
+ immutablePaths: (string | RegExp)[];
88
+ unmanagedPaths: (string | RegExp)[];
89
+ managedPaths: (string | RegExp)[];
90
90
  };
91
91
  storage: {
92
92
  type: "filesystem";
@@ -105,6 +105,9 @@ export interface ExperimentsNormalized {
105
105
  outputModule?: boolean;
106
106
  topLevelAwait?: boolean;
107
107
  css?: boolean;
108
+ /**
109
+ * @deprecated This option is deprecated, layers is enabled since v1.6.0
110
+ */
108
111
  layers?: boolean;
109
112
  incremental?: false | Incremental;
110
113
  parallelCodeSplitting?: boolean;
@@ -664,6 +664,8 @@ export type RuleSetRule = {
664
664
  oneOf?: (RuleSetRule | Falsy)[];
665
665
  /** A kind of Nested Rule, an array of Rules that is also used when the parent Rule matches. */
666
666
  rules?: (RuleSetRule | Falsy)[];
667
+ /** Whether to extract source maps from the module. */
668
+ extractSourceMap?: boolean;
667
669
  };
668
670
  /** A list of rules. */
669
671
  export type RuleSetRules = ("..." | RuleSetRule | Falsy)[];
@@ -1194,6 +1196,32 @@ export type CacheOptions = boolean;
1194
1196
  type StatsPresets = "normal" | "none" | "verbose" | "errors-only" | "errors-warnings" | "minimal" | "detailed" | "summary";
1195
1197
  type ModuleFilterItemTypes = RegExp | string | ((name: string, module: any, type: any) => boolean);
1196
1198
  type ModuleFilterTypes = boolean | ModuleFilterItemTypes | ModuleFilterItemTypes[];
1199
+ export type StatsColorOptions = {
1200
+ /**
1201
+ * Custom color for bold text.
1202
+ */
1203
+ bold?: string;
1204
+ /**
1205
+ * Custom color for cyan text.
1206
+ */
1207
+ cyan?: string;
1208
+ /**
1209
+ * Custom color for green text.
1210
+ */
1211
+ green?: string;
1212
+ /**
1213
+ * Custom color for magenta text.
1214
+ */
1215
+ magenta?: string;
1216
+ /**
1217
+ * Custom color for red text.
1218
+ */
1219
+ red?: string;
1220
+ /**
1221
+ * Custom color for yellow text.
1222
+ */
1223
+ yellow?: string;
1224
+ };
1197
1225
  /** Options for stats */
1198
1226
  export type StatsOptions = {
1199
1227
  /**
@@ -1253,7 +1281,7 @@ export type StatsOptions = {
1253
1281
  * Enables or disables the use of colors in the output.
1254
1282
  * @default false
1255
1283
  */
1256
- colors?: boolean;
1284
+ colors?: boolean | StatsColorOptions;
1257
1285
  /**
1258
1286
  * Enables or disables the display of the hash.
1259
1287
  * @default true
@@ -1724,7 +1752,7 @@ export type Optimization = {
1724
1752
  * Customize the minimizer.
1725
1753
  * By default, `rspack.SwcJsMinimizerRspackPlugin` and `rspack.LightningCssMinimizerRspackPlugin` are used.
1726
1754
  */
1727
- minimizer?: Array<"..." | Plugin>;
1755
+ minimizer?: ("..." | Plugin)[];
1728
1756
  /**
1729
1757
  * Whether to merge chunks which contain the same modules.
1730
1758
  * Setting optimization.mergeDuplicateChunks to false will disable this optimization.
@@ -1833,9 +1861,9 @@ export type ExperimentCacheOptions = boolean | {
1833
1861
  buildDependencies?: string[];
1834
1862
  version?: string;
1835
1863
  snapshot?: {
1836
- immutablePaths?: Array<string | RegExp>;
1837
- unmanagedPaths?: Array<string | RegExp>;
1838
- managedPaths?: Array<string | RegExp>;
1864
+ immutablePaths?: (string | RegExp)[];
1865
+ unmanagedPaths?: (string | RegExp)[];
1866
+ managedPaths?: (string | RegExp)[];
1839
1867
  };
1840
1868
  storage?: {
1841
1869
  type: "filesystem";
@@ -2027,6 +2055,7 @@ export type Experiments = {
2027
2055
  css?: boolean;
2028
2056
  /**
2029
2057
  * Enable module layers feature.
2058
+ * @deprecated This option is deprecated, layers is enabled since v1.6.0
2030
2059
  * @default false
2031
2060
  */
2032
2061
  layers?: boolean;
@@ -5,7 +5,7 @@ export interface ModuleFederationPluginOptions extends Omit<ModuleFederationPlug
5
5
  implementation?: string;
6
6
  shareStrategy?: "version-first" | "loaded-first";
7
7
  }
8
- export type RuntimePlugins = string[];
8
+ export type RuntimePlugins = string[] | [string, Record<string, unknown>][];
9
9
  export declare class ModuleFederationPlugin {
10
10
  private _options;
11
11
  constructor(_options: ModuleFederationPluginOptions);
@@ -34,7 +34,7 @@ __webpack_require__.r(__webpack_exports__), __webpack_require__.d(__webpack_expo
34
34
  cssReload: ()=>cssReload,
35
35
  normalizeUrl: ()=>normalizeUrl
36
36
  });
37
- let srcByModuleId = Object.create(null), noDocument = "undefined" == typeof document, { forEach } = Array.prototype;
37
+ const srcByModuleId = Object.create(null), noDocument = "undefined" == typeof document, { forEach } = Array.prototype;
38
38
  function noop() {}
39
39
  function updateCss(el, url) {
40
40
  let normalizedUrl;
@@ -94,14 +94,13 @@ function cssReload(moduleId, options) {
94
94
  if (!src) return !1;
95
95
  let elements = document.querySelectorAll("link"), loaded = !1;
96
96
  return forEach.call(elements, (el)=>{
97
+ var href;
98
+ let ret, normalizedHref;
97
99
  if (!el.href) return;
98
- let url = function(href, src) {
99
- let ret = "", normalizedHref = normalizeUrl(href);
100
- return src.some((url)=>{
101
- normalizedHref.indexOf(src) > -1 && (ret = url);
102
- }), ret;
103
- }(el.href, src);
104
- isUrlRequest(url) && !0 !== el.visited && url && (updateCss(el, url), loaded = !0);
100
+ let url = (href = el.href, ret = "", normalizedHref = normalizeUrl(href), src.some((url)=>{
101
+ normalizedHref.indexOf(src) > -1 && (ret = url);
102
+ }), ret);
103
+ !isUrlRequest(url) || !0 !== el.visited && url && (updateCss(el, url), loaded = !0);
105
104
  }), loaded;
106
105
  }(src);
107
106
  if (options.locals) {
@@ -28,12 +28,12 @@ __webpack_require__.r(__webpack_exports__), __webpack_require__.d(__webpack_expo
28
28
  AUTO_PUBLIC_PATH: ()=>AUTO_PUBLIC_PATH,
29
29
  pitch: ()=>pitch
30
30
  });
31
- let external_node_path_namespaceObject = require("node:path");
31
+ const external_node_path_namespaceObject = require("node:path");
32
32
  var external_node_path_default = __webpack_require__.n(external_node_path_namespaceObject);
33
33
  function isAbsolutePath(str) {
34
34
  return external_node_path_default().posix.isAbsolute(str) || external_node_path_default().win32.isAbsolute(str);
35
35
  }
36
- let PLUGIN_NAME = "css-extract-rspack-plugin", RELATIVE_PATH_REGEXP = /^\.\.?[/\\]/, BASE_URI = "webpack://", MODULE_TYPE = "css/mini-extract", AUTO_PUBLIC_PATH = "__mini_css_extract_plugin_public_path_auto__", ABSOLUTE_PUBLIC_PATH = `${BASE_URI}/mini-css-extract-plugin/`, SINGLE_DOT_PATH_SEGMENT = "__mini_css_extract_plugin_single_dot_path_segment__";
36
+ const PLUGIN_NAME = "css-extract-rspack-plugin", RELATIVE_PATH_REGEXP = /^\.\.?[/\\]/, BASE_URI = "webpack://", MODULE_TYPE = "css/mini-extract", AUTO_PUBLIC_PATH = "__mini_css_extract_plugin_public_path_auto__", ABSOLUTE_PUBLIC_PATH = `${BASE_URI}/mini-css-extract-plugin/`, SINGLE_DOT_PATH_SEGMENT = "__mini_css_extract_plugin_single_dot_path_segment__";
37
37
  function hotLoader(content, context) {
38
38
  let localsJsonString = JSON.stringify(JSON.stringify(context.locals));
39
39
  return `${content}
@@ -72,7 +72,7 @@ function hotLoader(content, context) {
72
72
  }
73
73
  `;
74
74
  }
75
- let pitch = function(request, _, data) {
75
+ const pitch = function(request, _, data) {
76
76
  let publicPathForExtract;
77
77
  if (this._compiler?.options?.experiments?.css && this._module && ("css" === this._module.type || "css/auto" === this._module.type || "css/global" === this._module.type || "css/module" === this._module.type)) {
78
78
  let e = Error("use type 'css' and `CssExtractRspackPlugin` together, please set `experiments.css` to `false` or set `{ type: \"javascript/auto\" }` for rules with `CssExtractRspackPlugin` in your rspack config (now `CssExtractRspackPlugin` does nothing).");
@@ -140,8 +140,7 @@ let pitch = function(request, _, data) {
140
140
  publicPath: publicPathForExtract,
141
141
  baseUri: `${BASE_URI}/`
142
142
  }, (error, exports1)=>{
143
- if (error) return void callback(error);
144
- handleExports(exports1);
143
+ error ? callback(error) : handleExports(exports1);
145
144
  });
146
145
  }, css_extract_loader = function(content) {
147
146
  if (this._compiler?.options?.experiments?.css && this._module && ("css" === this._module.type || "css/auto" === this._module.type || "css/global" === this._module.type || "css/module" === this._module.type)) return content;
package/dist/exports.d.ts CHANGED
@@ -56,7 +56,7 @@ export { default as EntryOptionPlugin } from "./lib/EntryOptionPlugin";
56
56
  export { EnvironmentPlugin } from "./lib/EnvironmentPlugin";
57
57
  export { LoaderOptionsPlugin } from "./lib/LoaderOptionsPlugin";
58
58
  export { LoaderTargetPlugin } from "./lib/LoaderTargetPlugin";
59
- export type { OutputFileSystem } from "./util/fs";
59
+ export type { OutputFileSystem, WatchFileSystem } from "./util/fs";
60
60
  import { EsmLibraryPlugin, FetchCompileAsyncWasmPlugin, lazyCompilationMiddleware, SubresourceIntegrityPlugin } from "./builtin-plugin";
61
61
  interface Web {
62
62
  FetchCompileAsyncWasmPlugin: typeof FetchCompileAsyncWasmPlugin;