@rsbuild/core 2.0.8 → 2.0.9

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 (75) hide show
  1. package/dist/1~rslib-runtime.js +8 -5
  2. package/dist/756.js +13 -7
  3. package/dist/memfs.js +4 -4
  4. package/dist-types/build.d.ts +1 -1
  5. package/dist-types/cli/init.d.ts +1 -1
  6. package/dist-types/configChain.d.ts +59 -118
  7. package/dist-types/constants.d.ts +35 -31
  8. package/dist-types/createContext.d.ts +1 -2
  9. package/dist-types/createRsbuild.d.ts +1 -2
  10. package/dist-types/defaultConfig.d.ts +2 -4
  11. package/dist-types/helpers/exitHook.d.ts +1 -1
  12. package/dist-types/helpers/format.d.ts +2 -1
  13. package/dist-types/helpers/fs.d.ts +2 -4
  14. package/dist-types/helpers/index.d.ts +1 -2
  15. package/dist-types/helpers/path.d.ts +4 -8
  16. package/dist-types/helpers/stats.d.ts +3 -5
  17. package/dist-types/helpers/url.d.ts +1 -0
  18. package/dist-types/helpers/vendors.d.ts +2 -3
  19. package/dist-types/helpers/version.d.ts +2 -3
  20. package/dist-types/hooks.d.ts +6 -8
  21. package/dist-types/index.d.ts +10 -5
  22. package/dist-types/initConfigs.d.ts +2 -3
  23. package/dist-types/initPlugins.d.ts +1 -1
  24. package/dist-types/inspectConfig.d.ts +1 -1
  25. package/dist-types/loadConfig.d.ts +24 -32
  26. package/dist-types/loadEnv.d.ts +48 -57
  27. package/dist-types/loader/transformRawLoader.d.ts +1 -0
  28. package/dist-types/logger.d.ts +1 -2
  29. package/dist-types/mergeConfig.d.ts +1 -2
  30. package/dist-types/pluginHelper.d.ts +1 -2
  31. package/dist-types/pluginManager.d.ts +4 -7
  32. package/dist-types/plugins/basic.d.ts +1 -2
  33. package/dist-types/plugins/css.d.ts +4 -0
  34. package/dist-types/plugins/fileSize.d.ts +6 -5
  35. package/dist-types/plugins/rspackProfile.d.ts +2 -0
  36. package/dist-types/plugins/server.d.ts +1 -0
  37. package/dist-types/plugins/swc.d.ts +1 -2
  38. package/dist-types/restart.d.ts +4 -5
  39. package/dist-types/rspack-plugins/RsbuildHtmlPlugin.d.ts +2 -3
  40. package/dist-types/rspack-plugins/resource-hints/HtmlResourceHintsPlugin.d.ts +2 -3
  41. package/dist-types/rspack-plugins/resource-hints/doesChunkBelongToHtml.d.ts +3 -4
  42. package/dist-types/rspack-plugins/resource-hints/extractChunks.d.ts +1 -2
  43. package/dist-types/rspack-plugins/resource-hints/getResourceType.d.ts +2 -3
  44. package/dist-types/rspackConfig.d.ts +1 -1
  45. package/dist-types/server/ansiHTML.d.ts +1 -2
  46. package/dist-types/server/assets-middleware/getFileFromUrl.d.ts +1 -2
  47. package/dist-types/server/assets-middleware/index.d.ts +3 -5
  48. package/dist-types/server/assets-middleware/setupWriteToDisk.d.ts +1 -2
  49. package/dist-types/server/browserLogs.d.ts +1 -2
  50. package/dist-types/server/buildManager.d.ts +4 -6
  51. package/dist-types/server/cliShortcuts.d.ts +3 -1
  52. package/dist-types/server/devMiddlewares.d.ts +2 -3
  53. package/dist-types/server/devServer.d.ts +18 -23
  54. package/dist-types/server/gracefulShutdown.d.ts +2 -4
  55. package/dist-types/server/gzipMiddleware.d.ts +1 -1
  56. package/dist-types/server/helper.d.ts +36 -45
  57. package/dist-types/server/historyApiFallback.d.ts +8 -1
  58. package/dist-types/server/httpServer.d.ts +1 -1
  59. package/dist-types/server/middlewares.d.ts +4 -8
  60. package/dist-types/server/open.d.ts +1 -1
  61. package/dist-types/server/runner/basic.d.ts +4 -5
  62. package/dist-types/server/runner/index.d.ts +3 -1
  63. package/dist-types/server/socketServer.d.ts +24 -18
  64. package/dist-types/server/watchFiles.d.ts +1 -1
  65. package/dist-types/types/config.d.ts +1192 -1465
  66. package/dist-types/types/context.d.ts +63 -92
  67. package/dist-types/types/hooks.d.ts +106 -150
  68. package/dist-types/types/plugin.d.ts +359 -444
  69. package/dist-types/types/rsbuild.d.ts +156 -191
  70. package/dist-types/types/thirdParty.d.ts +101 -132
  71. package/dist-types/types/utils.d.ts +2 -5
  72. package/package.json +3 -3
  73. package/dist-types/client/hmr.d.ts +0 -3
  74. package/dist-types/client/log.d.ts +0 -13
  75. package/dist-types/client/overlay.d.ts +0 -1
@@ -14,94 +14,75 @@ export interface CSSExtractOptions {
14
14
  * A loose PostCSS plugin type that accepts plugins from different
15
15
  * PostCSS versions. This helps avoid type conflicts when user
16
16
  * projects use different PostCSS versions.
17
- */
18
- export type LoosePostCSSPlugin = any;
17
+ */ export type LoosePostCSSPlugin = any;
19
18
  export type PostCSSOptions = ProcessOptions & {
20
19
  config?: boolean;
21
20
  plugins?: LoosePostCSSPlugin[];
22
21
  };
23
22
  export type PostCSSLoaderOptions = {
24
23
  /**
25
- * Enable PostCSS Parser support in CSS-in-JS. If you use JS styles the postcss-js parser, add the execute option.
26
- * @default undefined
27
- */
28
- execute?: boolean;
29
- /**
30
- * Whether to generate source maps.
31
- * @default `rsbuildConfig.output.sourceMap.css`
32
- */
33
- sourceMap?: boolean;
34
- /**
35
- * The special implementation option determines which implementation of PostCSS to use.
36
- * @default `@rsbuild/core/compiled/postcss`
37
- */
38
- implementation?: unknown;
39
- /**
40
- * Allows to set PostCSS options and plugins.
41
- * @default undefined
42
- */
43
- postcssOptions?: PostCSSOptions | ((loaderContext: Rspack.LoaderContext) => PostCSSOptions);
24
+ * Enable PostCSS Parser support in CSS-in-JS. If you use JS styles the postcss-js parser, add the execute option.
25
+ * @default undefined
26
+ */ execute?: boolean;
27
+ /**
28
+ * Whether to generate source maps.
29
+ * @default `rsbuildConfig.output.sourceMap.css`
30
+ */ sourceMap?: boolean;
31
+ /**
32
+ * The special implementation option determines which implementation of PostCSS to use.
33
+ * @default `@rsbuild/core/compiled/postcss`
34
+ */ implementation?: unknown;
35
+ /**
36
+ * Allows to set PostCSS options and plugins.
37
+ * @default undefined
38
+ */ postcssOptions?: PostCSSOptions | ((loaderContext: Rspack.LoaderContext) => PostCSSOptions);
44
39
  };
45
40
  export type PostCSSPlugin = AcceptedPlugin;
46
41
  export type CSSLoaderModulesMode = 'local' | 'global' | 'pure' | 'icss' | ((resourcePath: string) => 'local' | 'global' | 'pure' | 'icss');
47
42
  export type CSSLoaderExportLocalsConvention = 'asIs' | 'as-is' | 'camelCase' | 'camel-case' | 'camelCaseOnly' | 'camel-case-only' | 'dashes' | 'dashesOnly' | 'dashes-only' | ((name: string) => string);
48
43
  export interface CSSLoaderModulesOptions {
49
44
  /**
50
- * Allows auto enable CSS Modules/ICSS based on the filename, query or fragment.
51
- */
52
- auto?: boolean | RegExp | ((resourcePath: string, resourceQuery: string, resourceFragment: string) => boolean);
45
+ * Allows auto enable CSS Modules/ICSS based on the filename, query or fragment.
46
+ */ auto?: boolean | RegExp | ((resourcePath: string, resourceQuery: string, resourceFragment: string) => boolean);
53
47
  /**
54
- * Allow `css-loader` to export names from global class or id, so you can use that as local name.
55
- */
56
- exportGlobals?: boolean;
48
+ * Allow `css-loader` to export names from global class or id, so you can use that as local name.
49
+ */ exportGlobals?: boolean;
57
50
  /**
58
- * Style of exported class names.
59
- */
60
- exportLocalsConvention?: CSSLoaderExportLocalsConvention;
51
+ * Style of exported class names.
52
+ */ exportLocalsConvention?: CSSLoaderExportLocalsConvention;
61
53
  /**
62
- * Export only locals.
63
- */
64
- exportOnlyLocals?: boolean;
54
+ * Export only locals.
55
+ */ exportOnlyLocals?: boolean;
65
56
  /**
66
- * Allows to specify a function to generate the classname.
67
- */
68
- getLocalIdent?: (context: Rspack.LoaderContext, localIdentName: string, localName: string) => string;
57
+ * Allows to specify a function to generate the classname.
58
+ */ getLocalIdent?: (context: Rspack.LoaderContext, localIdentName: string, localName: string) => string;
69
59
  /**
70
- * Allows to configure the generated local ident name.
71
- */
72
- localIdentName?: string;
60
+ * Allows to configure the generated local ident name.
61
+ */ localIdentName?: string;
73
62
  /**
74
- * Allows to redefine basic loader context for local ident name.
75
- */
76
- localIdentContext?: string;
63
+ * Allows to redefine basic loader context for local ident name.
64
+ */ localIdentContext?: string;
77
65
  /**
78
- * Allows to add custom hash to generate more unique classes.
79
- */
80
- localIdentHashSalt?: string;
66
+ * Allows to add custom hash to generate more unique classes.
67
+ */ localIdentHashSalt?: string;
81
68
  /**
82
- * Allows to specify hash function to generate classes.
83
- */
84
- localIdentHashFunction?: string;
69
+ * Allows to specify hash function to generate classes.
70
+ */ localIdentHashFunction?: string;
85
71
  /**
86
- * Allows to specify hash digest to generate classes.
87
- */
88
- localIdentHashDigest?: string;
72
+ * Allows to specify hash digest to generate classes.
73
+ */ localIdentHashDigest?: string;
89
74
  /**
90
- * Allows to specify custom RegExp for local ident name.
91
- */
92
- localIdentRegExp?: string | RegExp;
75
+ * Allows to specify custom RegExp for local ident name.
76
+ */ localIdentRegExp?: string | RegExp;
93
77
  /**
94
- * Controls the level of compilation applied to the input styles.
95
- */
96
- mode?: CSSLoaderModulesMode;
78
+ * Controls the level of compilation applied to the input styles.
79
+ */ mode?: CSSLoaderModulesMode;
97
80
  /**
98
- * Enables/disables ES modules named export for locals.
99
- */
100
- namedExport?: boolean;
81
+ * Enables/disables ES modules named export for locals.
82
+ */ namedExport?: boolean;
101
83
  /**
102
- * Enables a callback to output the CSS Modules mapping JSON.
103
- */
104
- getJSON?: (context: {
84
+ * Enables a callback to output the CSS Modules mapping JSON.
85
+ */ getJSON?: (context: {
105
86
  resourcePath: string;
106
87
  imports: object[];
107
88
  exports: object[];
@@ -110,83 +91,71 @@ export interface CSSLoaderModulesOptions {
110
91
  }
111
92
  export interface CSSLoaderOptions {
112
93
  /**
113
- * Allow to enable/disables handling the CSS functions url and image-set.
114
- * If set to false, css-loader will not parse any paths specified in url or image-set
115
- * @default true
116
- */
117
- url?: boolean | {
94
+ * Allow to enable/disables handling the CSS functions url and image-set.
95
+ * If set to false, css-loader will not parse any paths specified in url or image-set
96
+ * @default true
97
+ */ url?: boolean | {
118
98
  filter: (url: string, resourcePath: string) => boolean;
119
99
  };
120
100
  /**
121
- * Allows to enables/disables @import at-rules handling.
122
- * @default true
123
- */
124
- import?: boolean | {
101
+ * Allows to enables/disables @import at-rules handling.
102
+ * @default true
103
+ */ import?: boolean | {
125
104
  filter: (url: string, media: string, resourcePath: string, supports?: string, layer?: string) => boolean;
126
105
  };
127
106
  /**
128
- * Allows to enable/disable CSS Modules or ICSS and setup configuration:
129
- */
130
- modules?: boolean | LiteralUnion<'local' | 'global' | 'pure' | 'icss', string> | CSSLoaderModulesOptions;
131
- /**
132
- * By default generation of source maps depends on the devtool option.
133
- */
134
- sourceMap?: boolean;
135
- /**
136
- * Allows to enables/disables or setups number of loaders applied before CSS loader for @import at-rules,
137
- * CSS Modules and ICSS imports, i.e. @import/composes/@value value from './values.css'/etc.
138
- * @default 0
139
- */
140
- importLoaders?: number;
141
- /**
142
- * By default, css-loader generates JS modules that use the ES modules syntax.
143
- * There are some cases in which using ES modules is beneficial, like in the case of module concatenation and tree shaking.
144
- * @default true
145
- */
146
- esModule?: boolean;
147
- /**
148
- * Allows exporting styles as array with modules, string or constructable stylesheet (i.e. CSSStyleSheet)
149
- * @default 'array'
150
- */
151
- exportType?: 'array' | 'string' | 'css-style-sheet';
107
+ * Allows to enable/disable CSS Modules or ICSS and setup configuration:
108
+ */ modules?: boolean | LiteralUnion<'local' | 'global' | 'pure' | 'icss', string> | CSSLoaderModulesOptions;
109
+ /**
110
+ * By default generation of source maps depends on the devtool option.
111
+ */ sourceMap?: boolean;
112
+ /**
113
+ * Allows to enables/disables or setups number of loaders applied before CSS loader for @import at-rules,
114
+ * CSS Modules and ICSS imports, i.e. @import/composes/@value value from './values.css'/etc.
115
+ * @default 0
116
+ */ importLoaders?: number;
117
+ /**
118
+ * By default, css-loader generates JS modules that use the ES modules syntax.
119
+ * There are some cases in which using ES modules is beneficial, like in the case of module concatenation and tree shaking.
120
+ * @default true
121
+ */ esModule?: boolean;
122
+ /**
123
+ * Allows exporting styles as array with modules, string or constructable stylesheet (i.e. CSSStyleSheet)
124
+ * @default 'array'
125
+ */ exportType?: 'array' | 'string' | 'css-style-sheet';
152
126
  }
153
127
  export type StyleLoaderInjectType = 'styleTag' | 'singletonStyleTag' | 'lazyStyleTag' | 'lazySingletonStyleTag' | 'linkTag';
154
128
  export interface StyleLoaderOptions {
155
129
  /**
156
- * By default, style-loader generates JS modules that use the ES modules syntax.
157
- * There are some cases in which using ES modules is beneficial, like in the case of module concatenation and tree shaking.
158
- * @default true
159
- */
160
- esModule?: boolean;
161
- /**
162
- * Allows to setup how styles will be injected into the DOM.
163
- * @default 'styleTag'
164
- */
165
- injectType?: StyleLoaderInjectType;
166
- /**
167
- * If defined, the style-loader will attach given attributes with their values on <style> / <link> element.
168
- * @default {}
169
- */
170
- attributes?: Record<string, string>;
171
- /**
172
- * By default, style-loader appends <style>/<link> elements to the end of the style target,
173
- * which is the <head> tag of the page unless specified by insert.
174
- * This will cause CSS created by the loader to take priority over CSS already present in the target.
175
- * You can use other values if the standard behavior is not suitable for you, but we do not recommend doing this.
176
- * If you target an iframe, make sure you have sufficient access rights.
177
- *
178
- * Supports:
179
- * - a CSS selector where styles are injected
180
- * - an absolute path to a custom insert module
181
- *
182
- * @default 'head'
183
- */
184
- insert?: LiteralUnion<'head' | 'body', string>;
185
- /**
186
- * Allows to setup an absolute path to a custom module that overrides
187
- * the default styleTagTransform behavior.
188
- *
189
- * @default undefined
190
- */
191
- styleTagTransform?: string;
130
+ * By default, style-loader generates JS modules that use the ES modules syntax.
131
+ * There are some cases in which using ES modules is beneficial, like in the case of module concatenation and tree shaking.
132
+ * @default true
133
+ */ esModule?: boolean;
134
+ /**
135
+ * Allows to setup how styles will be injected into the DOM.
136
+ * @default 'styleTag'
137
+ */ injectType?: StyleLoaderInjectType;
138
+ /**
139
+ * If defined, the style-loader will attach given attributes with their values on <style> / <link> element.
140
+ * @default {}
141
+ */ attributes?: Record<string, string>;
142
+ /**
143
+ * By default, style-loader appends <style>/<link> elements to the end of the style target,
144
+ * which is the <head> tag of the page unless specified by insert.
145
+ * This will cause CSS created by the loader to take priority over CSS already present in the target.
146
+ * You can use other values if the standard behavior is not suitable for you, but we do not recommend doing this.
147
+ * If you target an iframe, make sure you have sufficient access rights.
148
+ *
149
+ * Supports:
150
+ * - a CSS selector where styles are injected
151
+ * - an absolute path to a custom insert module
152
+ *
153
+ * @default 'head'
154
+ */ insert?: LiteralUnion<'head' | 'body', string>;
155
+ /**
156
+ * Allows to setup an absolute path to a custom module that overrides
157
+ * the default styleTagTransform behavior.
158
+ *
159
+ * @default undefined
160
+ */ styleTagTransform?: string;
192
161
  }
@@ -2,11 +2,11 @@ export type Falsy = false | null | undefined;
2
2
  export type OneOrMany<T> = T | T[];
3
3
  export type MaybePromise<T> = T | Promise<T>;
4
4
  export type Optional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
5
+ // https://github.com/microsoft/TypeScript/issues/29729
5
6
  export type LiteralUnion<T extends U, U> = T | (U & Record<never, never>);
6
7
  /**
7
8
  * Creates a type with readonly properties at the first and second levels only.
8
- */
9
- export type TwoLevelReadonly<T> = keyof T extends never ? T : {
9
+ */ export type TwoLevelReadonly<T> = keyof T extends never ? T : {
10
10
  readonly [k in keyof T]: T[k] extends object ? {
11
11
  readonly [p in keyof T[k]]: T[k][p];
12
12
  } : T[k];
@@ -14,6 +14,3 @@ export type TwoLevelReadonly<T> = keyof T extends never ? T : {
14
14
  export type ConfigChain<T> = OneOrMany<T | ((config: T) => T | void)>;
15
15
  export type ConfigChainWithContext<T, Ctx> = OneOrMany<T | ((config: T, ctx: Ctx) => T | void)>;
16
16
  export type ConfigChainAsyncWithContext<T, Ctx> = OneOrMany<T | ((config: T, ctx: Ctx) => MaybePromise<T | void>)>;
17
- export type ConfigChainMergeContext<T, Ctx> = OneOrMany<T | ((merged: {
18
- value: T;
19
- } & Ctx) => T | void)>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsbuild/core",
3
- "version": "2.0.8",
3
+ "version": "2.0.9",
4
4
  "description": "The Rspack-based build tool.",
5
5
  "homepage": "https://rsbuild.rs",
6
6
  "bugs": {
@@ -50,7 +50,7 @@
50
50
  "devDependencies": {
51
51
  "@jridgewell/remapping": "^2.3.5",
52
52
  "@jridgewell/trace-mapping": "^0.3.31",
53
- "@rslib/core": "0.21.5",
53
+ "@rslib/core": "0.22.0",
54
54
  "@types/cors": "^2.8.19",
55
55
  "@types/node": "^24.12.4",
56
56
  "@types/on-finished": "2.3.5",
@@ -82,7 +82,7 @@
82
82
  "rslog": "^2.1.1",
83
83
  "rspack-chain": "^2.0.1",
84
84
  "rspack-manifest-plugin": "5.2.1",
85
- "rspack-merge": "0.1.1",
85
+ "rspack-merge": "1.0.1",
86
86
  "sirv": "^3.0.2",
87
87
  "stacktrace-parser": "^0.1.11",
88
88
  "style-loader": "^4.0.0",
@@ -1,3 +0,0 @@
1
- import type { LogLevel, NormalizedClientConfig } from '../types';
2
- export declare const registerOverlay: (createFn: (title: string, content: string) => void, clearFn: () => void) => void;
3
- export declare function init(token: string, config: NormalizedClientConfig, serverHost: string, serverPort: number, serverBase: string, liveReload: boolean, browserLogs: boolean, logLevel: LogLevel): void;
@@ -1,13 +0,0 @@
1
- import type { LogLevel } from '../types';
2
- export declare const LOG_LEVEL: {
3
- readonly silent: -1;
4
- readonly error: 0;
5
- readonly warn: 1;
6
- readonly info: 2;
7
- };
8
- export declare const logger: {
9
- level: LogLevel;
10
- info(...messages: unknown[]): void;
11
- warn(...messages: unknown[]): void;
12
- error(...messages: unknown[]): void;
13
- };
@@ -1 +0,0 @@
1
- export {};