@rsbuild/core 2.0.0-beta.0 → 2.0.0-beta.10
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.
- package/compiled/chokidar/index.d.ts +197 -29
- package/compiled/chokidar/package.json +1 -1
- package/compiled/connect-next/index.d.ts +56 -0
- package/compiled/connect-next/license +26 -0
- package/compiled/connect-next/package.json +1 -0
- package/compiled/cors/index.d.ts +56 -0
- package/compiled/cors/license +22 -0
- package/compiled/cors/package.json +1 -0
- package/compiled/css-loader/index.js +2 -2
- package/compiled/css-loader/package.json +1 -1
- package/compiled/html-rspack-plugin/index.d.ts +102 -1
- package/compiled/html-rspack-plugin/index.js +863 -20
- package/compiled/html-rspack-plugin/package.json +1 -1
- package/compiled/http-proxy-middleware/index.d.ts +268 -43
- package/compiled/http-proxy-middleware/package.json +1 -1
- package/compiled/jiti/LICENSE +21 -0
- package/compiled/jiti/README.md +243 -0
- package/compiled/jiti/dist/babel.cjs +46699 -0
- package/compiled/jiti/dist/jiti.cjs +4842 -0
- package/compiled/jiti/lib/jiti-cli.mjs +19 -0
- package/compiled/jiti/lib/jiti-hooks.mjs +89 -0
- package/compiled/jiti/lib/jiti-native.mjs +76 -0
- package/compiled/jiti/lib/jiti-register.d.mts +1 -0
- package/compiled/jiti/lib/jiti-register.mjs +2 -0
- package/compiled/jiti/lib/jiti.cjs +24 -0
- package/compiled/jiti/lib/jiti.d.cts +8 -0
- package/compiled/jiti/lib/jiti.d.mts +8 -0
- package/compiled/jiti/lib/jiti.mjs +23 -0
- package/compiled/jiti/lib/types.d.ts +363 -0
- package/compiled/jiti/package.json +133 -0
- package/compiled/postcss/index.js +1 -1
- package/compiled/postcss/lib/at-rule.d.ts +1 -1
- package/compiled/postcss/lib/comment.d.ts +1 -1
- package/compiled/postcss/lib/container.d.ts +1 -1
- package/compiled/postcss/lib/css-syntax-error.d.ts +1 -1
- package/compiled/postcss/lib/declaration.d.ts +1 -1
- package/compiled/postcss/lib/document.d.ts +1 -1
- package/compiled/postcss/lib/input.d.ts +1 -1
- package/compiled/postcss/lib/lazy-result.d.ts +1 -1
- package/compiled/postcss/lib/no-work-result.d.ts +1 -1
- package/compiled/postcss/lib/node.d.ts +1 -1
- package/compiled/postcss/lib/previous-map.d.ts +1 -1
- package/compiled/postcss/lib/processor.d.ts +1 -1
- package/compiled/postcss/lib/result.d.ts +1 -1
- package/compiled/postcss/lib/root.d.ts +1 -1
- package/compiled/postcss/lib/rule.d.ts +1 -1
- package/compiled/postcss/lib/stringifier.d.ts +1 -1
- package/compiled/postcss/lib/warning.d.ts +1 -1
- package/compiled/postcss/package.json +1 -1
- package/compiled/postcss-loader/index.js +10 -9
- package/compiled/postcss-loader/package.json +1 -1
- package/compiled/rslog/index.d.ts +33 -2
- package/compiled/rslog/package.json +1 -1
- package/compiled/rspack-chain/package.json +1 -1
- package/compiled/rspack-chain/types/index.d.ts +0 -5
- package/compiled/rspack-manifest-plugin/index.d.ts +48 -0
- package/compiled/rspack-manifest-plugin/license +21 -0
- package/compiled/rspack-manifest-plugin/package.json +1 -0
- package/compiled/style-loader/index.js +37 -94
- package/compiled/style-loader/package.json +1 -1
- package/dist/{131.js → 958.js} +1706 -1655
- package/dist/chokidar.js +59 -57
- package/dist/client/hmr.js +3 -3
- package/dist/client/overlay.js +2 -2
- package/dist/connect-next.js +268 -0
- package/dist/{connect.js.LICENSE.txt → connect-next.js.LICENSE.txt} +3 -13
- package/dist/cors.js +2 -2
- package/dist/http-proxy-middleware.js +2985 -0
- package/dist/http-proxy-middleware.js.LICENSE.txt +69 -0
- package/dist/index.js +1 -1
- package/dist/launch-editor-middleware.js +96 -16
- package/dist/manifest-plugin.js +543 -21
- package/dist/memfs.js +241 -776
- package/dist/{710.js → mrmime.js} +2 -1
- package/dist/open.js +32 -28
- package/dist/range-parser.js +2 -2
- package/dist/remapping.js +2 -2
- package/dist/rslib-runtime.js +4 -4
- package/dist/sirv.js +14 -14
- package/dist/src.js +510 -0
- package/dist/tinyglobby.js +114 -69
- package/dist/transformLoader.mjs +38 -1
- package/dist/transformRawLoader.mjs +1 -1
- package/dist/ws.js +1549 -0
- package/dist-types/createContext.d.ts +3 -2
- package/dist-types/helpers/format.d.ts +2 -1
- package/dist-types/helpers/fs.d.ts +2 -1
- package/dist-types/helpers/index.d.ts +1 -1
- package/dist-types/helpers/stats.d.ts +4 -3
- package/dist-types/helpers/vendors.d.ts +0 -2
- package/dist-types/hooks.d.ts +3 -3
- package/dist-types/index.d.ts +4 -3
- package/dist-types/initPlugins.d.ts +2 -1
- package/dist-types/logger.d.ts +9 -3
- package/dist-types/pluginManager.d.ts +2 -1
- package/dist-types/restart.d.ts +4 -2
- package/dist-types/server/assets-middleware/index.d.ts +3 -2
- package/dist-types/server/assets-middleware/setupWriteToDisk.d.ts +2 -1
- package/dist-types/server/cliShortcuts.d.ts +4 -1
- package/dist-types/server/devMiddlewares.d.ts +4 -6
- package/dist-types/server/devServer.d.ts +8 -42
- package/dist-types/server/helper.d.ts +50 -16
- package/dist-types/server/historyApiFallback.d.ts +2 -1
- package/dist-types/server/middlewares.d.ts +5 -3
- package/dist-types/server/open.d.ts +4 -2
- package/dist-types/server/previewServer.d.ts +4 -0
- package/dist-types/server/proxy.d.ts +3 -2
- package/dist-types/server/runner/asModule.d.ts +1 -1
- package/dist-types/server/serverSetup.d.ts +2 -0
- package/dist-types/server/socketServer.d.ts +4 -1
- package/dist-types/server/watchFiles.d.ts +1 -1
- package/dist-types/types/config.d.ts +123 -25
- package/dist-types/types/context.d.ts +3 -0
- package/dist-types/types/hooks.d.ts +17 -15
- package/dist-types/types/plugin.d.ts +14 -11
- package/dist-types/types/rsbuild.d.ts +11 -4
- package/dist-types/types/thirdParty.d.ts +15 -6
- package/package.json +23 -26
- package/compiled/chokidar/handler.d.ts +0 -90
- package/compiled/http-proxy-middleware/index.js +0 -5284
- package/compiled/ws/index.d.ts +0 -437
- package/compiled/ws/index.js +0 -3166
- package/compiled/ws/license +0 -20
- package/compiled/ws/package.json +0 -1
- package/dist/397.js +0 -11
- package/dist/7.js +0 -1
- package/dist/743.js +0 -7
- package/dist/88.js +0 -40
- package/dist/connect.js +0 -581
- package/dist-types/server/prodServer.d.ts +0 -24
- /package/compiled/html-rspack-plugin/{loader.js → htmlLoader.js} +0 -0
- /package/dist/{131.js.LICENSE.txt → 958.js.LICENSE.txt} +0 -0
- /package/dist/client/{59.js → 797.js} +0 -0
- /package/dist/{31.js → trace-mapping.js} +0 -0
|
@@ -3,12 +3,14 @@ import type { SecureServerSessionOptions } from 'node:http2';
|
|
|
3
3
|
import type { ServerOptions as HttpsServerOptions } from 'node:https';
|
|
4
4
|
import type { URL } from 'node:url';
|
|
5
5
|
import type { CopyRspackPluginOptions, DefinePluginOptions, Externals, LightningCssMinimizerRspackPluginOptions, ModuleFederationPluginOptions, RuleSetCondition, SwcJsMinimizerRspackPluginOptions, SwcLoaderOptions } from '@rspack/core';
|
|
6
|
-
import type {
|
|
6
|
+
import type { ChokidarOptions } from '../../compiled/chokidar';
|
|
7
|
+
import type Cors from '../../compiled/cors';
|
|
8
|
+
import type { Options as HttpProxyOptions, Filter as ProxyFilter } from '../../compiled/http-proxy-middleware';
|
|
7
9
|
import type RspackChain from '../../compiled/rspack-chain/types';
|
|
8
|
-
import type { FileDescriptor } from 'rspack-manifest-plugin';
|
|
9
|
-
import type { ChokidarOptions } from '../../compiled/chokidar/index.js';
|
|
10
|
-
import type { Options as HttpProxyOptions, Filter as ProxyFilter } from '../../compiled/http-proxy-middleware/index.js';
|
|
10
|
+
import type { FileDescriptor } from '../../compiled/rspack-manifest-plugin';
|
|
11
11
|
import type { RsbuildDevServer } from '../server/devServer';
|
|
12
|
+
import type { RsbuildPreviewServer } from '../server/previewServer';
|
|
13
|
+
import type { Logger } from '../logger';
|
|
12
14
|
import type { EnvironmentContext, ModifyBundlerChainUtils, ModifyChainUtils, Routes } from './hooks';
|
|
13
15
|
import type { RsbuildPlugins } from './plugin';
|
|
14
16
|
import type { RsbuildEntry, RsbuildMode, RsbuildTarget } from './rsbuild';
|
|
@@ -230,20 +232,17 @@ export type ProxyBypass = (req: IncomingMessage, res: ServerResponse, proxyOptio
|
|
|
230
232
|
export type { ProxyFilter };
|
|
231
233
|
export type ProxyOptions = HttpProxyOptions & {
|
|
232
234
|
/**
|
|
233
|
-
*
|
|
235
|
+
* Use the `bypass` function to skip the proxy.
|
|
236
|
+
* Inside the function, you have access to the request, response, and proxy options.
|
|
234
237
|
* - Return `null` or `undefined` to continue processing the request with proxy.
|
|
235
|
-
* - Return `true` to continue processing the request
|
|
238
|
+
* - Return `true` to skip the proxy and continue processing the request.
|
|
236
239
|
* - Return `false` to produce a 404 error for the request.
|
|
237
|
-
* - Return a path to
|
|
240
|
+
* - Return a specific path to replace the original request path.
|
|
238
241
|
* - Return a Promise to handle the request asynchronously.
|
|
239
242
|
*/
|
|
240
243
|
bypass?: ProxyBypass;
|
|
241
|
-
/**
|
|
242
|
-
* Used to proxy multiple specified paths to the same target.
|
|
243
|
-
*/
|
|
244
|
-
context?: ProxyFilter;
|
|
245
244
|
};
|
|
246
|
-
export type ProxyConfig = Record<string, string | ProxyOptions> | ProxyOptions[]
|
|
245
|
+
export type ProxyConfig = Record<string, string | ProxyOptions> | ProxyOptions[];
|
|
247
246
|
export type HistoryApiFallbackContext = {
|
|
248
247
|
match: RegExpMatchArray;
|
|
249
248
|
parsedUrl: URL;
|
|
@@ -312,8 +311,9 @@ export type PublicDirOptions = {
|
|
|
312
311
|
*/
|
|
313
312
|
watch?: boolean;
|
|
314
313
|
/**
|
|
315
|
-
* Glob patterns
|
|
316
|
-
*
|
|
314
|
+
* Glob patterns for files or directories to ignore when copying the public directory
|
|
315
|
+
* during production builds.
|
|
316
|
+
* @default []
|
|
317
317
|
*/
|
|
318
318
|
ignore?: string[];
|
|
319
319
|
};
|
|
@@ -416,7 +416,7 @@ export interface ServerConfig {
|
|
|
416
416
|
*
|
|
417
417
|
* @link https://github.com/expressjs/cors
|
|
418
418
|
*/
|
|
419
|
-
cors?: boolean | CorsOptions;
|
|
419
|
+
cors?: boolean | Cors.CorsOptions;
|
|
420
420
|
/**
|
|
421
421
|
* Configure proxy rules for the dev server or preview server to proxy requests to
|
|
422
422
|
* the specified service.
|
|
@@ -438,11 +438,53 @@ export interface ServerConfig {
|
|
|
438
438
|
* @default false
|
|
439
439
|
*/
|
|
440
440
|
middlewareMode?: boolean;
|
|
441
|
+
/**
|
|
442
|
+
* Run setup logic when the Rsbuild dev server or preview server starts,
|
|
443
|
+
* such as registering custom middleware or running pre-start tasks.
|
|
444
|
+
*
|
|
445
|
+
* When `server.setup` is called, Rsbuild built-in middlewares are not registered yet,
|
|
446
|
+
* so middlewares you add run earlier than built-ins.
|
|
447
|
+
*
|
|
448
|
+
* `server.setup` can return a callback function. After built-in middlewares are registered,
|
|
449
|
+
* Rsbuild will execute that callback. Middlewares registered in the callback run later than built-ins.
|
|
450
|
+
*
|
|
451
|
+
* @default undefined
|
|
452
|
+
*/
|
|
453
|
+
setup?: ServerSetupFn | ServerSetupFn[];
|
|
441
454
|
}
|
|
442
455
|
export type NormalizedServerConfig = {
|
|
443
456
|
host: string;
|
|
444
457
|
publicDir: Required<PublicDirOptions>[];
|
|
445
|
-
} & Omit<Optional<Required<ServerConfig>, 'headers' | 'https' | 'historyApiFallback' | 'proxy'>, 'host' | 'publicDir'>;
|
|
458
|
+
} & Omit<Optional<Required<ServerConfig>, 'headers' | 'https' | 'historyApiFallback' | 'proxy' | 'setup'>, 'host' | 'publicDir'>;
|
|
459
|
+
export type ServerSetupContext = {
|
|
460
|
+
/**
|
|
461
|
+
* Environment contexts of all environments.
|
|
462
|
+
*/
|
|
463
|
+
environments: Record<string, EnvironmentContext>;
|
|
464
|
+
} & ({
|
|
465
|
+
/**
|
|
466
|
+
* Action type of current server.
|
|
467
|
+
*/
|
|
468
|
+
action: 'dev';
|
|
469
|
+
/**
|
|
470
|
+
* Dev server instance, only available in dev mode.
|
|
471
|
+
*/
|
|
472
|
+
server: RsbuildDevServer;
|
|
473
|
+
} | {
|
|
474
|
+
/**
|
|
475
|
+
* Action type of current server.
|
|
476
|
+
*/
|
|
477
|
+
action: 'preview';
|
|
478
|
+
/**
|
|
479
|
+
* Preview server instance, only available in preview mode.
|
|
480
|
+
*/
|
|
481
|
+
server: RsbuildPreviewServer;
|
|
482
|
+
});
|
|
483
|
+
/**
|
|
484
|
+
* Server setup function.
|
|
485
|
+
* Return a callback to run after built-in middlewares are registered.
|
|
486
|
+
*/
|
|
487
|
+
export type ServerSetupFn = (context: ServerSetupContext) => MaybePromise<(() => MaybePromise<void>) | void>;
|
|
446
488
|
export type SriAlgorithm = 'sha256' | 'sha384' | 'sha512';
|
|
447
489
|
export type SriOptions = {
|
|
448
490
|
/**
|
|
@@ -665,7 +707,15 @@ export interface NormalizedPerformanceConfig extends PerformanceConfig {
|
|
|
665
707
|
printFileSize: PrintFileSizeOptions | boolean;
|
|
666
708
|
}
|
|
667
709
|
export type SplitChunks = Rspack.OptimizationSplitChunksOptions | false;
|
|
668
|
-
|
|
710
|
+
/**
|
|
711
|
+
* Split chunks preset rules.
|
|
712
|
+
* - `default`: splits polyfills when enabled and applies extra groups when using
|
|
713
|
+
* framework plugins.
|
|
714
|
+
* - `per-package`: splits dependencies in `node_modules` by npm package.
|
|
715
|
+
* - `single-vendor`: splits all `node_modules` dependencies into one vendor chunk.
|
|
716
|
+
* - `none`: disables Rsbuild preset rules.
|
|
717
|
+
*/
|
|
718
|
+
export type SplitChunksPreset = 'default' | 'single-vendor' | 'per-package' | 'none';
|
|
669
719
|
export type SplitChunksConfig = Rspack.OptimizationSplitChunksOptions & {
|
|
670
720
|
preset?: SplitChunksPreset;
|
|
671
721
|
};
|
|
@@ -766,34 +816,34 @@ export type FilenameConfig = {
|
|
|
766
816
|
* The name of the JavaScript files.
|
|
767
817
|
* @default
|
|
768
818
|
* - dev: '[name].js'
|
|
769
|
-
* - prod: '[name].[contenthash:
|
|
819
|
+
* - prod: '[name].[contenthash:10].js'
|
|
770
820
|
*/
|
|
771
821
|
js?: Rspack.Filename;
|
|
772
822
|
/**
|
|
773
823
|
* The name of the CSS files.
|
|
774
824
|
* @default
|
|
775
825
|
* - dev: '[name].css'
|
|
776
|
-
* - prod: '[name].[contenthash:
|
|
826
|
+
* - prod: '[name].[contenthash:10].css'
|
|
777
827
|
*/
|
|
778
828
|
css?: Rspack.CssFilename;
|
|
779
829
|
/**
|
|
780
830
|
* The name of the SVG images.
|
|
781
|
-
* @default '[name].[contenthash:
|
|
831
|
+
* @default '[name].[contenthash:10].svg'
|
|
782
832
|
*/
|
|
783
833
|
svg?: Rspack.AssetModuleFilename;
|
|
784
834
|
/**
|
|
785
835
|
* The name of the font files.
|
|
786
|
-
* @default '[name].[contenthash:
|
|
836
|
+
* @default '[name].[contenthash:10][ext]'
|
|
787
837
|
*/
|
|
788
838
|
font?: Rspack.AssetModuleFilename;
|
|
789
839
|
/**
|
|
790
840
|
* The name of non-SVG images.
|
|
791
|
-
* @default '[name].[contenthash:
|
|
841
|
+
* @default '[name].[contenthash:10][ext]'
|
|
792
842
|
*/
|
|
793
843
|
image?: Rspack.AssetModuleFilename;
|
|
794
844
|
/**
|
|
795
845
|
* The name of media assets, such as video.
|
|
796
|
-
* @default '[name].[contenthash:
|
|
846
|
+
* @default '[name].[contenthash:10][ext]'
|
|
797
847
|
*/
|
|
798
848
|
media?: Rspack.AssetModuleFilename;
|
|
799
849
|
/**
|
|
@@ -803,7 +853,7 @@ export type FilenameConfig = {
|
|
|
803
853
|
wasm?: Rspack.WebassemblyModuleFilename;
|
|
804
854
|
/**
|
|
805
855
|
* The name of other assets, except for above (image, svg, font, html, wasm...)
|
|
806
|
-
* @default '[name].[contenthash:
|
|
856
|
+
* @default '[name].[contenthash:10][ext]'
|
|
807
857
|
*/
|
|
808
858
|
assets?: Rspack.AssetModuleFilename;
|
|
809
859
|
};
|
|
@@ -838,6 +888,33 @@ export type Charset = 'ascii' | 'utf8';
|
|
|
838
888
|
export type LegalComments = 'none' | 'inline' | 'linked';
|
|
839
889
|
export type NormalizedDataUriLimit = Required<DataUriLimit>;
|
|
840
890
|
export type Polyfill = 'usage' | 'entry' | 'off';
|
|
891
|
+
export type SourceMapExtractTarget = {
|
|
892
|
+
/**
|
|
893
|
+
* Include matched JavaScript files whose existing source maps should be
|
|
894
|
+
* extracted.
|
|
895
|
+
*/
|
|
896
|
+
include?: RuleSetCondition[];
|
|
897
|
+
/**
|
|
898
|
+
* Exclude matched JavaScript files whose existing source maps should not be
|
|
899
|
+
* extracted.
|
|
900
|
+
*/
|
|
901
|
+
exclude?: RuleSetCondition[];
|
|
902
|
+
};
|
|
903
|
+
export type SourceMapExtract = boolean | {
|
|
904
|
+
/**
|
|
905
|
+
* Whether to extract existing source maps from matching JavaScript files.
|
|
906
|
+
* This is useful when a third-party package already ships both `.js` and
|
|
907
|
+
* `.js.map` files.
|
|
908
|
+
*
|
|
909
|
+
* `true` means extract from all JavaScript files. You can also use `include`
|
|
910
|
+
* or `exclude` to limit extraction to specific files.
|
|
911
|
+
*
|
|
912
|
+
* This option is implemented based on Rspack's
|
|
913
|
+
* `module.rules[].extractSourceMap` and can replace `source-map-loader`.
|
|
914
|
+
* @default false
|
|
915
|
+
*/
|
|
916
|
+
js?: boolean | SourceMapExtractTarget;
|
|
917
|
+
};
|
|
841
918
|
export type SourceMap = {
|
|
842
919
|
/**
|
|
843
920
|
* The source map type for JavaScript files.
|
|
@@ -849,6 +926,12 @@ export type SourceMap = {
|
|
|
849
926
|
* @default false
|
|
850
927
|
*/
|
|
851
928
|
css?: boolean;
|
|
929
|
+
/**
|
|
930
|
+
* Whether to extract existing source maps from matching input files.
|
|
931
|
+
* Currently only JavaScript files are supported.
|
|
932
|
+
* @default false
|
|
933
|
+
*/
|
|
934
|
+
extract?: SourceMapExtract;
|
|
852
935
|
};
|
|
853
936
|
export type CSSModulesLocalsConvention = 'asIs' | 'camelCase' | 'camelCaseOnly' | 'dashes' | 'dashesOnly';
|
|
854
937
|
export type CSSModules = {
|
|
@@ -1104,6 +1187,7 @@ export interface OutputConfig {
|
|
|
1104
1187
|
* const defaultSourceMap = {
|
|
1105
1188
|
* js: isDev ? 'cheap-module-source-map' : false,
|
|
1106
1189
|
* css: false,
|
|
1190
|
+
* extract: false,
|
|
1107
1191
|
* };
|
|
1108
1192
|
* ```
|
|
1109
1193
|
*/
|
|
@@ -1164,6 +1248,7 @@ export interface NormalizedOutputConfig extends OutputConfig {
|
|
|
1164
1248
|
sourceMap: boolean | {
|
|
1165
1249
|
js?: Rspack.Configuration['devtool'];
|
|
1166
1250
|
css: boolean;
|
|
1251
|
+
extract: SourceMapExtract;
|
|
1167
1252
|
};
|
|
1168
1253
|
cleanDistPath: CleanDistPath;
|
|
1169
1254
|
filenameHash: boolean | string;
|
|
@@ -1571,6 +1656,13 @@ export type CliShortcut = {
|
|
|
1571
1656
|
};
|
|
1572
1657
|
export type WriteToDisk = boolean | ((filename: string) => boolean);
|
|
1573
1658
|
export type BrowserLogsStackTrace = 'summary' | 'full' | 'none';
|
|
1659
|
+
export type LiveReload = boolean | {
|
|
1660
|
+
/**
|
|
1661
|
+
* Whether to trigger a full page reload when the HTML template changes.
|
|
1662
|
+
* @default true
|
|
1663
|
+
*/
|
|
1664
|
+
html?: boolean;
|
|
1665
|
+
};
|
|
1574
1666
|
export interface DevConfig {
|
|
1575
1667
|
/**
|
|
1576
1668
|
* Controls whether to forward browser runtime errors to the terminal. When `true`, the dev
|
|
@@ -1599,7 +1691,7 @@ export interface DevConfig {
|
|
|
1599
1691
|
* Whether to reload the page when file changes are detected.
|
|
1600
1692
|
* @default true
|
|
1601
1693
|
*/
|
|
1602
|
-
liveReload?:
|
|
1694
|
+
liveReload?: LiveReload;
|
|
1603
1695
|
/**
|
|
1604
1696
|
* Set the URL prefix of static assets in development mode,
|
|
1605
1697
|
* similar to the [output.publicPath](https://rspack.rs/config/output#outputpublicpath)
|
|
@@ -1638,6 +1730,7 @@ export interface DevConfig {
|
|
|
1638
1730
|
};
|
|
1639
1731
|
/**
|
|
1640
1732
|
* Used to add custom middleware to the dev server.
|
|
1733
|
+
* @deprecated Use `server.setup` instead
|
|
1641
1734
|
* @default undefined
|
|
1642
1735
|
*/
|
|
1643
1736
|
setupMiddlewares?: SetupMiddlewaresFn | SetupMiddlewaresFn[];
|
|
@@ -1798,6 +1891,11 @@ export interface RsbuildConfig extends EnvironmentConfig {
|
|
|
1798
1891
|
* @default 'info'
|
|
1799
1892
|
*/
|
|
1800
1893
|
logLevel?: LogLevel;
|
|
1894
|
+
/**
|
|
1895
|
+
* Use a custom logger instance for the current Rsbuild instance.
|
|
1896
|
+
* You can create one via `createLogger()`.
|
|
1897
|
+
*/
|
|
1898
|
+
customLogger?: Logger;
|
|
1801
1899
|
/**
|
|
1802
1900
|
* Options for local development.
|
|
1803
1901
|
*/
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Hooks } from '../hooks';
|
|
2
|
+
import type { Logger } from '../logger';
|
|
2
3
|
import type { SocketServer } from '../server/socketServer';
|
|
3
4
|
import type { NormalizedConfig, RsbuildConfig } from './config';
|
|
4
5
|
import type { EnvironmentContext } from './hooks';
|
|
@@ -79,6 +80,8 @@ export type BuildState = {
|
|
|
79
80
|
};
|
|
80
81
|
/** The inner context. */
|
|
81
82
|
export type InternalContext = RsbuildContext & {
|
|
83
|
+
/** The logger associated with current Rsbuild instance. */
|
|
84
|
+
logger: Logger;
|
|
82
85
|
/** All hooks. */
|
|
83
86
|
hooks: Readonly<Hooks>;
|
|
84
87
|
/** Current Rsbuild config. */
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { rspack } from '@rspack/core';
|
|
2
2
|
import type { ChainIdentifier, ManifestData } from '..';
|
|
3
3
|
import type { RsbuildDevServer } from '../server/devServer';
|
|
4
|
+
import type { RsbuildPreviewServer } from '../server/previewServer';
|
|
4
5
|
import type { RspackChain } from '../types';
|
|
5
6
|
import type { EnvironmentConfig, HtmlBasicTag, MergedEnvironmentConfig, NormalizedEnvironmentConfig, RsbuildConfig } from './config';
|
|
6
7
|
import type { RsbuildEntry, RsbuildTarget } from './rsbuild';
|
|
@@ -67,8 +68,17 @@ export type OnBeforeStartDevServerFn = (params: {
|
|
|
67
68
|
* Context information for all environments.
|
|
68
69
|
*/
|
|
69
70
|
environments: Record<string, EnvironmentContext>;
|
|
70
|
-
}) => MaybePromise<(() => void) | void>;
|
|
71
|
-
export type
|
|
71
|
+
}) => MaybePromise<(() => MaybePromise<void>) | void>;
|
|
72
|
+
export type OnBeforeStartPreviewServerFn = (params: {
|
|
73
|
+
/**
|
|
74
|
+
* The preview server instance.
|
|
75
|
+
*/
|
|
76
|
+
server: RsbuildPreviewServer;
|
|
77
|
+
/**
|
|
78
|
+
* Context information for all environments.
|
|
79
|
+
*/
|
|
80
|
+
environments: Record<string, EnvironmentContext>;
|
|
81
|
+
}) => MaybePromise<void>;
|
|
72
82
|
export type Routes = {
|
|
73
83
|
entryName: string;
|
|
74
84
|
pathname: string;
|
|
@@ -81,7 +91,7 @@ export type OnAfterStartDevServerFn = (params: {
|
|
|
81
91
|
*/
|
|
82
92
|
environments: Record<string, EnvironmentContext>;
|
|
83
93
|
}) => MaybePromise<void>;
|
|
84
|
-
export type
|
|
94
|
+
export type OnAfterStartPreviewServerFn = (params: {
|
|
85
95
|
port: number;
|
|
86
96
|
routes: Routes;
|
|
87
97
|
/**
|
|
@@ -253,19 +263,11 @@ export type ModifyChainUtils = {
|
|
|
253
263
|
*/
|
|
254
264
|
HtmlPlugin: typeof HtmlRspackPlugin;
|
|
255
265
|
};
|
|
256
|
-
interface PluginInstance {
|
|
257
|
-
apply: (compiler: any) => void;
|
|
258
|
-
[k: string]: any;
|
|
259
|
-
}
|
|
260
266
|
export type ModifyBundlerChainUtils = ModifyChainUtils & {
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
ProvidePlugin: PluginInstance;
|
|
266
|
-
SourceMapDevToolPlugin: PluginInstance;
|
|
267
|
-
HotModuleReplacementPlugin: PluginInstance;
|
|
268
|
-
};
|
|
267
|
+
/**
|
|
268
|
+
* @deprecated Use `rspack` instead.
|
|
269
|
+
*/
|
|
270
|
+
bundler: typeof rspack;
|
|
269
271
|
};
|
|
270
272
|
export type ModifyBundlerChainFn = (chain: RspackChain, utils: ModifyBundlerChainUtils) => MaybePromise<void>;
|
|
271
273
|
export type CreateAsyncHook<Callback extends (...args: any[]) => any> = {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Logger } from '../logger';
|
|
2
2
|
import type { ModifyRspackConfigUtils, NarrowedRspackConfig, NormalizedConfig, NormalizedEnvironmentConfig, RsbuildConfig } from './config';
|
|
3
3
|
import type { RsbuildContext } from './context';
|
|
4
|
-
import type { EnvironmentContext, ModifyBundlerChainFn, ModifyEnvironmentConfigFn, ModifyHTMLFn, ModifyHTMLTagsFn, ModifyRsbuildConfigFn, OnAfterBuildFn, OnAfterCreateCompilerFn, OnAfterDevCompileFn, OnAfterEnvironmentCompileFn, OnAfterStartDevServerFn,
|
|
4
|
+
import type { EnvironmentContext, ModifyBundlerChainFn, ModifyEnvironmentConfigFn, ModifyHTMLFn, ModifyHTMLTagsFn, ModifyRsbuildConfigFn, OnAfterBuildFn, OnAfterCreateCompilerFn, OnAfterDevCompileFn, OnAfterEnvironmentCompileFn, OnAfterStartDevServerFn, OnAfterStartPreviewServerFn, OnBeforeBuildFn, OnBeforeCreateCompilerFn, OnBeforeDevCompileFn, OnBeforeEnvironmentCompileFn, OnBeforeStartDevServerFn, OnBeforeStartPreviewServerFn, OnCloseBuildFn, OnCloseDevServerFn, OnExitFn } from './hooks';
|
|
5
5
|
import type { AddPluginsOptions, RsbuildInstance, RsbuildTarget } from './rsbuild';
|
|
6
6
|
import type { Rspack } from './rspack';
|
|
7
7
|
import type { Falsy, MaybePromise } from './utils';
|
|
@@ -365,10 +365,12 @@ export type ResolveHandler = (context: {
|
|
|
365
365
|
}) => Promise<void> | void;
|
|
366
366
|
export type ResolveHook = (handler: ResolveHandler) => void;
|
|
367
367
|
export type ProcessAssetsHook = (descriptor: ProcessAssetsDescriptor, handler: ProcessAssetsHandler) => void;
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
368
|
+
export type GetNormalizedConfig = {
|
|
369
|
+
(): NormalizedConfig;
|
|
370
|
+
(options: {
|
|
371
|
+
environment: string;
|
|
372
|
+
}): NormalizedEnvironmentConfig;
|
|
373
|
+
};
|
|
372
374
|
/**
|
|
373
375
|
* The API interface provided to Rsbuild plugins through the `setup` function.
|
|
374
376
|
* It allows plugins to interact with the build process, modify configurations,
|
|
@@ -394,11 +396,12 @@ export type RsbuildPluginAPI = Readonly<{
|
|
|
394
396
|
* environment, this method must be called after the
|
|
395
397
|
* `modifyRsbuildConfig` hook is executed.
|
|
396
398
|
*/
|
|
397
|
-
getNormalizedConfig:
|
|
399
|
+
getNormalizedConfig: GetNormalizedConfig;
|
|
398
400
|
/**
|
|
399
401
|
* A logger instance used to output log information in a unified format.
|
|
400
402
|
* Use this instead of `console.log` to maintain consistent logging with Rsbuild.
|
|
401
|
-
*
|
|
403
|
+
* It is associated with the current Rsbuild instance and reflects
|
|
404
|
+
* `config.customLogger` when provided.
|
|
402
405
|
*/
|
|
403
406
|
logger: Logger;
|
|
404
407
|
/**
|
|
@@ -471,11 +474,11 @@ export type RsbuildPluginAPI = Readonly<{
|
|
|
471
474
|
*/
|
|
472
475
|
onAfterStartDevServer: PluginHook<OnAfterStartDevServerFn>;
|
|
473
476
|
/**
|
|
474
|
-
* Called after starting the
|
|
477
|
+
* Called after starting the preview server, you can get the port
|
|
475
478
|
* number with the `port` parameter, and the page routes info with the
|
|
476
479
|
* `routes` parameter.
|
|
477
480
|
*/
|
|
478
|
-
|
|
481
|
+
onAfterStartPreviewServer: PluginHook<OnAfterStartPreviewServerFn>;
|
|
479
482
|
/**
|
|
480
483
|
* A callback function that is triggered before the production build is executed.
|
|
481
484
|
*/
|
|
@@ -499,9 +502,9 @@ export type RsbuildPluginAPI = Readonly<{
|
|
|
499
502
|
*/
|
|
500
503
|
onBeforeStartDevServer: PluginHook<OnBeforeStartDevServerFn>;
|
|
501
504
|
/**
|
|
502
|
-
* Called before starting the
|
|
505
|
+
* Called before starting the preview server.
|
|
503
506
|
*/
|
|
504
|
-
|
|
507
|
+
onBeforeStartPreviewServer: PluginHook<OnBeforeStartPreviewServerFn>;
|
|
505
508
|
/**
|
|
506
509
|
* Called when closing the build instance. Can be used to perform cleanup
|
|
507
510
|
* operations when the building is closed.
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { Compiler, MultiCompiler } from '@rspack/core';
|
|
2
2
|
import type { LoadEnvOptions } from '../loadEnv';
|
|
3
|
+
import type { Logger } from '../logger';
|
|
3
4
|
import type { RsbuildDevServer } from '../server/devServer';
|
|
4
|
-
import type {
|
|
5
|
+
import type { StartDevServerResult, StartPreviewServerResult } from '../server/helper';
|
|
5
6
|
import type { NormalizedConfig, NormalizedEnvironmentConfig, RsbuildConfig } from './config';
|
|
6
7
|
import type { RsbuildContext } from './context';
|
|
7
8
|
import type { RsbuildPlugin, RsbuildPluginAPI } from './plugin';
|
|
@@ -141,7 +142,7 @@ export type ResolvedCreateRsbuildOptions = Required<Pick<CreateRsbuildOptions, '
|
|
|
141
142
|
rsbuildConfig: RsbuildConfig;
|
|
142
143
|
};
|
|
143
144
|
export type CreateDevServer = (options?: CreateDevServerOptions) => Promise<RsbuildDevServer>;
|
|
144
|
-
export type StartDevServer = (options?: StartDevServerOptions) => Promise<
|
|
145
|
+
export type StartDevServer = (options?: StartDevServerOptions) => Promise<StartDevServerResult>;
|
|
145
146
|
export type InspectConfig = (options?: InspectConfigOptions) => Promise<InspectConfigResult>;
|
|
146
147
|
export type AddPluginsOptions = {
|
|
147
148
|
/**
|
|
@@ -157,6 +158,12 @@ export type AddPluginsOptions = {
|
|
|
157
158
|
};
|
|
158
159
|
export type AddPlugins = (plugins: (RsbuildPlugin | Falsy)[], options?: AddPluginsOptions) => void;
|
|
159
160
|
export type RsbuildInstance = {
|
|
161
|
+
/**
|
|
162
|
+
* The logger associated with the current Rsbuild instance.
|
|
163
|
+
* It reflects `config.customLogger` when provided, otherwise uses a logger
|
|
164
|
+
* created specifically for the current Rsbuild instance.
|
|
165
|
+
*/
|
|
166
|
+
logger: Logger;
|
|
160
167
|
/**
|
|
161
168
|
* Register one or more Rsbuild plugins, which can be called multiple times.
|
|
162
169
|
* This method needs to be called before compiling. If it is called after
|
|
@@ -194,7 +201,7 @@ export type RsbuildInstance = {
|
|
|
194
201
|
* Start a server to preview the production build locally.
|
|
195
202
|
* This method should be executed after `rsbuild.build`.
|
|
196
203
|
*/
|
|
197
|
-
preview: (options?: PreviewOptions) => Promise<
|
|
204
|
+
preview: (options?: PreviewOptions) => Promise<StartPreviewServerResult>;
|
|
198
205
|
/**
|
|
199
206
|
* Initialize and return the internal Rspack configurations used by Rsbuild.
|
|
200
207
|
* This method processes all plugins and configurations to generate the final
|
|
@@ -240,7 +247,7 @@ export type RsbuildInstance = {
|
|
|
240
247
|
* 2. Watch for file changes and trigger recompilation.
|
|
241
248
|
*/
|
|
242
249
|
startDevServer: StartDevServer;
|
|
243
|
-
} & Pick<RsbuildPluginAPI, 'context' | 'expose' | 'getNormalizedConfig' | 'getRsbuildConfig' | 'isPluginExists' | 'modifyEnvironmentConfig' | 'modifyRsbuildConfig' | 'onAfterBuild' | 'onAfterCreateCompiler' | 'onAfterDevCompile' | 'onAfterEnvironmentCompile' | 'onAfterStartDevServer' | '
|
|
250
|
+
} & Pick<RsbuildPluginAPI, 'context' | 'expose' | 'getNormalizedConfig' | 'getRsbuildConfig' | 'isPluginExists' | 'modifyEnvironmentConfig' | 'modifyRsbuildConfig' | 'onAfterBuild' | 'onAfterCreateCompiler' | 'onAfterDevCompile' | 'onAfterEnvironmentCompile' | 'onAfterStartDevServer' | 'onAfterStartPreviewServer' | 'onBeforeBuild' | 'onBeforeCreateCompiler' | 'onBeforeDevCompile' | 'onBeforeEnvironmentCompile' | 'onBeforeStartDevServer' | 'onBeforeStartPreviewServer' | 'onCloseBuild' | 'onCloseDevServer' | 'onDevCompileDone' | 'onExit'>;
|
|
244
251
|
export type RsbuildTarget = 'web' | 'node' | 'web-worker';
|
|
245
252
|
export type RsbuildEntryDescription = Rspack.EntryDescription & {
|
|
246
253
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { CssExtractRspackLoaderOptions, CssExtractRspackPluginOptions } from '@rspack/core';
|
|
2
|
-
import type Connect from 'connect';
|
|
3
|
-
import type HtmlRspackPlugin from '../../compiled/html-rspack-plugin
|
|
2
|
+
import type * as Connect from '../../compiled/connect-next';
|
|
3
|
+
import type HtmlRspackPlugin from '../../compiled/html-rspack-plugin';
|
|
4
4
|
import type { AcceptedPlugin, ProcessOptions } from '../../compiled/postcss';
|
|
5
5
|
import type { Rspack } from './rspack';
|
|
6
6
|
import type { LiteralUnion } from './utils';
|
|
@@ -169,15 +169,24 @@ export interface StyleLoaderOptions {
|
|
|
169
169
|
*/
|
|
170
170
|
attributes?: Record<string, string>;
|
|
171
171
|
/**
|
|
172
|
-
* By default,
|
|
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.
|
|
173
174
|
* This will cause CSS created by the loader to take priority over CSS already present in the target.
|
|
174
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
|
|
175
181
|
*
|
|
176
182
|
* @default 'head'
|
|
177
183
|
*/
|
|
178
|
-
insert?: LiteralUnion<'head' | 'body', string
|
|
184
|
+
insert?: LiteralUnion<'head' | 'body', string>;
|
|
179
185
|
/**
|
|
180
|
-
* Allows to setup absolute path to custom
|
|
186
|
+
* Allows to setup an absolute path to a custom module that overrides
|
|
187
|
+
* the default styleTagTransform behavior.
|
|
188
|
+
*
|
|
189
|
+
* @default undefined
|
|
181
190
|
*/
|
|
182
|
-
styleTagTransform?: string
|
|
191
|
+
styleTagTransform?: string;
|
|
183
192
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsbuild/core",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.10",
|
|
4
4
|
"description": "The Rspack-based build tool.",
|
|
5
5
|
"homepage": "https://rsbuild.rs",
|
|
6
6
|
"bugs": {
|
|
@@ -36,10 +36,8 @@
|
|
|
36
36
|
"types.d.ts"
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@rspack/core": "2.0.0-
|
|
40
|
-
"@
|
|
41
|
-
"@swc/helpers": "^0.5.18",
|
|
42
|
-
"jiti": "^2.6.1"
|
|
39
|
+
"@rspack/core": "2.0.0-beta.8",
|
|
40
|
+
"@swc/helpers": "^0.5.19"
|
|
43
41
|
},
|
|
44
42
|
"peerDependencies": {
|
|
45
43
|
"core-js": ">= 3.0.0"
|
|
@@ -52,46 +50,45 @@
|
|
|
52
50
|
"devDependencies": {
|
|
53
51
|
"@jridgewell/remapping": "^2.3.5",
|
|
54
52
|
"@jridgewell/trace-mapping": "^0.3.31",
|
|
55
|
-
"@rslib/core": "0.
|
|
56
|
-
"@types/connect": "3.4.38",
|
|
53
|
+
"@rslib/core": "0.20.0",
|
|
57
54
|
"@types/cors": "^2.8.19",
|
|
58
|
-
"@types/node": "^24.
|
|
55
|
+
"@types/node": "^24.12.0",
|
|
59
56
|
"@types/on-finished": "2.3.5",
|
|
60
57
|
"@types/range-parser": "^1.2.7",
|
|
61
58
|
"@types/ws": "^8.18.1",
|
|
62
59
|
"browserslist-load-config": "1.0.1",
|
|
63
|
-
"cac": "^
|
|
60
|
+
"cac": "^7.0.0",
|
|
64
61
|
"chokidar": "^5.0.0",
|
|
65
|
-
"connect": "
|
|
62
|
+
"connect-next": "4.0.0",
|
|
66
63
|
"cors": "^2.8.6",
|
|
67
|
-
"css-loader": "7.1.
|
|
64
|
+
"css-loader": "7.1.4",
|
|
68
65
|
"deepmerge": "^4.3.1",
|
|
69
66
|
"dotenv-expand": "12.0.3",
|
|
70
|
-
"html-rspack-plugin": "6.1.
|
|
71
|
-
"http-proxy-middleware": "^
|
|
72
|
-
"
|
|
73
|
-
"
|
|
67
|
+
"html-rspack-plugin": "6.1.7",
|
|
68
|
+
"http-proxy-middleware": "^3.0.5",
|
|
69
|
+
"jiti": "^2.6.1",
|
|
70
|
+
"launch-editor-middleware": "^2.13.2",
|
|
71
|
+
"memfs": "^4.57.1",
|
|
74
72
|
"mrmime": "^2.0.1",
|
|
75
73
|
"on-finished": "2.4.1",
|
|
76
74
|
"open": "^11.0.0",
|
|
77
|
-
"
|
|
78
|
-
"postcss": "^8.5.6",
|
|
75
|
+
"postcss": "^8.5.8",
|
|
79
76
|
"postcss-load-config": "6.0.1",
|
|
80
|
-
"postcss-loader": "8.2.
|
|
81
|
-
"prebundle": "1.6.
|
|
77
|
+
"postcss-loader": "8.2.1",
|
|
78
|
+
"prebundle": "1.6.4",
|
|
82
79
|
"range-parser": "^1.2.1",
|
|
83
80
|
"reduce-configs": "^1.1.1",
|
|
84
|
-
"rslog": "^1.
|
|
85
|
-
"rspack-chain": "^2.0.0-
|
|
81
|
+
"rslog": "^2.1.0",
|
|
82
|
+
"rspack-chain": "^2.0.0-beta.1",
|
|
86
83
|
"rspack-manifest-plugin": "5.2.1",
|
|
87
84
|
"sirv": "^3.0.2",
|
|
88
85
|
"stacktrace-parser": "^0.1.11",
|
|
89
|
-
"style-loader": "
|
|
90
|
-
"
|
|
91
|
-
"
|
|
92
|
-
"
|
|
86
|
+
"style-loader": "^4.0.0",
|
|
87
|
+
"supports-color": "^10.2.2",
|
|
88
|
+
"tinyglobby": "^0.2.15",
|
|
89
|
+
"typescript": "^6.0.2",
|
|
93
90
|
"webpack-merge": "6.0.1",
|
|
94
|
-
"ws": "^8.
|
|
91
|
+
"ws": "^8.20.0"
|
|
95
92
|
},
|
|
96
93
|
"engines": {
|
|
97
94
|
"node": "^20.19.0 || >=22.12.0"
|