@rsbuild/core 2.0.0-beta.1 → 2.0.0-beta.11
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.js +29 -74
- package/compiled/html-rspack-plugin/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 +34 -3
- 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/{rslib-runtime.js → 1~rslib-runtime.js} +4 -4
- package/dist/{131.js → 552.js} +1753 -1573
- package/dist/chokidar.js +60 -57
- package/dist/client/hmr.js +3 -3
- package/dist/client/overlay.js +2 -2
- package/dist/connect-next.js +264 -0
- package/dist/{connect.js.LICENSE.txt → connect-next.js.LICENSE.txt} +3 -13
- package/dist/cors.js +3 -3
- package/dist/debug.js +503 -0
- package/dist/http-proxy-middleware.js +2947 -0
- package/dist/http-proxy-middleware.js.LICENSE.txt +69 -0
- package/dist/index.js +1 -1
- package/dist/launch-editor-middleware.js +81 -20
- package/dist/manifest-plugin.js +12 -19
- package/dist/memfs.js +223 -781
- package/dist/open.js +32 -28
- package/dist/range-parser.js +3 -3
- package/dist/remapping.js +2 -2
- package/dist/sirv.js +18 -18
- package/dist/tinyglobby.js +115 -70
- package/dist/transformLoader.mjs +38 -1
- package/dist/transformRawLoader.mjs +1 -1
- package/dist/ws.js +1513 -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 +110 -17
- 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 +25 -28
- package/types.d.ts +1 -1
- package/compiled/chokidar/handler.d.ts +0 -90
- package/compiled/http-proxy-middleware/index.js +0 -6132
- 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 → 552.js.LICENSE.txt} +0 -0
- /package/dist/client/{59.js → 797.js} +0 -0
- /package/dist/{710.js → mrmime.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';
|
|
@@ -139,7 +141,7 @@ export type Decorators = {
|
|
|
139
141
|
* Specify the version of decorators to use.
|
|
140
142
|
* @default '2022-03'
|
|
141
143
|
*/
|
|
142
|
-
version?: 'legacy' | '2022-03';
|
|
144
|
+
version?: 'legacy' | '2022-03' | '2023-11';
|
|
143
145
|
};
|
|
144
146
|
export interface SourceConfig {
|
|
145
147
|
/**
|
|
@@ -309,8 +311,9 @@ export type PublicDirOptions = {
|
|
|
309
311
|
*/
|
|
310
312
|
watch?: boolean;
|
|
311
313
|
/**
|
|
312
|
-
* Glob patterns
|
|
313
|
-
*
|
|
314
|
+
* Glob patterns for files or directories to ignore when copying the public directory
|
|
315
|
+
* during production builds.
|
|
316
|
+
* @default []
|
|
314
317
|
*/
|
|
315
318
|
ignore?: string[];
|
|
316
319
|
};
|
|
@@ -413,7 +416,7 @@ export interface ServerConfig {
|
|
|
413
416
|
*
|
|
414
417
|
* @link https://github.com/expressjs/cors
|
|
415
418
|
*/
|
|
416
|
-
cors?: boolean | CorsOptions;
|
|
419
|
+
cors?: boolean | Cors.CorsOptions;
|
|
417
420
|
/**
|
|
418
421
|
* Configure proxy rules for the dev server or preview server to proxy requests to
|
|
419
422
|
* the specified service.
|
|
@@ -435,11 +438,53 @@ export interface ServerConfig {
|
|
|
435
438
|
* @default false
|
|
436
439
|
*/
|
|
437
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[];
|
|
438
454
|
}
|
|
439
455
|
export type NormalizedServerConfig = {
|
|
440
456
|
host: string;
|
|
441
457
|
publicDir: Required<PublicDirOptions>[];
|
|
442
|
-
} & 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>;
|
|
443
488
|
export type SriAlgorithm = 'sha256' | 'sha384' | 'sha512';
|
|
444
489
|
export type SriOptions = {
|
|
445
490
|
/**
|
|
@@ -771,34 +816,34 @@ export type FilenameConfig = {
|
|
|
771
816
|
* The name of the JavaScript files.
|
|
772
817
|
* @default
|
|
773
818
|
* - dev: '[name].js'
|
|
774
|
-
* - prod: '[name].[contenthash:
|
|
819
|
+
* - prod: '[name].[contenthash:10].js'
|
|
775
820
|
*/
|
|
776
821
|
js?: Rspack.Filename;
|
|
777
822
|
/**
|
|
778
823
|
* The name of the CSS files.
|
|
779
824
|
* @default
|
|
780
825
|
* - dev: '[name].css'
|
|
781
|
-
* - prod: '[name].[contenthash:
|
|
826
|
+
* - prod: '[name].[contenthash:10].css'
|
|
782
827
|
*/
|
|
783
828
|
css?: Rspack.CssFilename;
|
|
784
829
|
/**
|
|
785
830
|
* The name of the SVG images.
|
|
786
|
-
* @default '[name].[contenthash:
|
|
831
|
+
* @default '[name].[contenthash:10].svg'
|
|
787
832
|
*/
|
|
788
833
|
svg?: Rspack.AssetModuleFilename;
|
|
789
834
|
/**
|
|
790
835
|
* The name of the font files.
|
|
791
|
-
* @default '[name].[contenthash:
|
|
836
|
+
* @default '[name].[contenthash:10][ext]'
|
|
792
837
|
*/
|
|
793
838
|
font?: Rspack.AssetModuleFilename;
|
|
794
839
|
/**
|
|
795
840
|
* The name of non-SVG images.
|
|
796
|
-
* @default '[name].[contenthash:
|
|
841
|
+
* @default '[name].[contenthash:10][ext]'
|
|
797
842
|
*/
|
|
798
843
|
image?: Rspack.AssetModuleFilename;
|
|
799
844
|
/**
|
|
800
845
|
* The name of media assets, such as video.
|
|
801
|
-
* @default '[name].[contenthash:
|
|
846
|
+
* @default '[name].[contenthash:10][ext]'
|
|
802
847
|
*/
|
|
803
848
|
media?: Rspack.AssetModuleFilename;
|
|
804
849
|
/**
|
|
@@ -808,7 +853,7 @@ export type FilenameConfig = {
|
|
|
808
853
|
wasm?: Rspack.WebassemblyModuleFilename;
|
|
809
854
|
/**
|
|
810
855
|
* The name of other assets, except for above (image, svg, font, html, wasm...)
|
|
811
|
-
* @default '[name].[contenthash:
|
|
856
|
+
* @default '[name].[contenthash:10][ext]'
|
|
812
857
|
*/
|
|
813
858
|
assets?: Rspack.AssetModuleFilename;
|
|
814
859
|
};
|
|
@@ -843,6 +888,33 @@ export type Charset = 'ascii' | 'utf8';
|
|
|
843
888
|
export type LegalComments = 'none' | 'inline' | 'linked';
|
|
844
889
|
export type NormalizedDataUriLimit = Required<DataUriLimit>;
|
|
845
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
|
+
};
|
|
846
918
|
export type SourceMap = {
|
|
847
919
|
/**
|
|
848
920
|
* The source map type for JavaScript files.
|
|
@@ -854,6 +926,12 @@ export type SourceMap = {
|
|
|
854
926
|
* @default false
|
|
855
927
|
*/
|
|
856
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;
|
|
857
935
|
};
|
|
858
936
|
export type CSSModulesLocalsConvention = 'asIs' | 'camelCase' | 'camelCaseOnly' | 'dashes' | 'dashesOnly';
|
|
859
937
|
export type CSSModules = {
|
|
@@ -1109,6 +1187,7 @@ export interface OutputConfig {
|
|
|
1109
1187
|
* const defaultSourceMap = {
|
|
1110
1188
|
* js: isDev ? 'cheap-module-source-map' : false,
|
|
1111
1189
|
* css: false,
|
|
1190
|
+
* extract: false,
|
|
1112
1191
|
* };
|
|
1113
1192
|
* ```
|
|
1114
1193
|
*/
|
|
@@ -1169,6 +1248,7 @@ export interface NormalizedOutputConfig extends OutputConfig {
|
|
|
1169
1248
|
sourceMap: boolean | {
|
|
1170
1249
|
js?: Rspack.Configuration['devtool'];
|
|
1171
1250
|
css: boolean;
|
|
1251
|
+
extract: SourceMapExtract;
|
|
1172
1252
|
};
|
|
1173
1253
|
cleanDistPath: CleanDistPath;
|
|
1174
1254
|
filenameHash: boolean | string;
|
|
@@ -1576,6 +1656,13 @@ export type CliShortcut = {
|
|
|
1576
1656
|
};
|
|
1577
1657
|
export type WriteToDisk = boolean | ((filename: string) => boolean);
|
|
1578
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
|
+
};
|
|
1579
1666
|
export interface DevConfig {
|
|
1580
1667
|
/**
|
|
1581
1668
|
* Controls whether to forward browser runtime errors to the terminal. When `true`, the dev
|
|
@@ -1604,7 +1691,7 @@ export interface DevConfig {
|
|
|
1604
1691
|
* Whether to reload the page when file changes are detected.
|
|
1605
1692
|
* @default true
|
|
1606
1693
|
*/
|
|
1607
|
-
liveReload?:
|
|
1694
|
+
liveReload?: LiveReload;
|
|
1608
1695
|
/**
|
|
1609
1696
|
* Set the URL prefix of static assets in development mode,
|
|
1610
1697
|
* similar to the [output.publicPath](https://rspack.rs/config/output#outputpublicpath)
|
|
@@ -1643,6 +1730,7 @@ export interface DevConfig {
|
|
|
1643
1730
|
};
|
|
1644
1731
|
/**
|
|
1645
1732
|
* Used to add custom middleware to the dev server.
|
|
1733
|
+
* @deprecated Use `server.setup` instead
|
|
1646
1734
|
* @default undefined
|
|
1647
1735
|
*/
|
|
1648
1736
|
setupMiddlewares?: SetupMiddlewaresFn | SetupMiddlewaresFn[];
|
|
@@ -1803,6 +1891,11 @@ export interface RsbuildConfig extends EnvironmentConfig {
|
|
|
1803
1891
|
* @default 'info'
|
|
1804
1892
|
*/
|
|
1805
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;
|
|
1806
1899
|
/**
|
|
1807
1900
|
* Options for local development.
|
|
1808
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.11",
|
|
4
4
|
"description": "The Rspack-based build tool.",
|
|
5
5
|
"homepage": "https://rsbuild.rs",
|
|
6
6
|
"bugs": {
|
|
@@ -36,9 +36,8 @@
|
|
|
36
36
|
"types.d.ts"
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@rspack/core": "2.0.0-
|
|
40
|
-
"@swc/helpers": "^0.5.
|
|
41
|
-
"jiti": "^2.6.1"
|
|
39
|
+
"@rspack/core": "2.0.0-beta.9",
|
|
40
|
+
"@swc/helpers": "^0.5.20"
|
|
42
41
|
},
|
|
43
42
|
"peerDependencies": {
|
|
44
43
|
"core-js": ">= 3.0.0"
|
|
@@ -51,46 +50,45 @@
|
|
|
51
50
|
"devDependencies": {
|
|
52
51
|
"@jridgewell/remapping": "^2.3.5",
|
|
53
52
|
"@jridgewell/trace-mapping": "^0.3.31",
|
|
54
|
-
"@rslib/core": "0.
|
|
55
|
-
"@types/connect": "3.4.38",
|
|
53
|
+
"@rslib/core": "0.20.1",
|
|
56
54
|
"@types/cors": "^2.8.19",
|
|
57
|
-
"@types/node": "^24.
|
|
55
|
+
"@types/node": "^24.12.0",
|
|
58
56
|
"@types/on-finished": "2.3.5",
|
|
59
57
|
"@types/range-parser": "^1.2.7",
|
|
60
58
|
"@types/ws": "^8.18.1",
|
|
61
59
|
"browserslist-load-config": "1.0.1",
|
|
62
|
-
"cac": "^
|
|
60
|
+
"cac": "^7.0.0",
|
|
63
61
|
"chokidar": "^5.0.0",
|
|
64
|
-
"connect": "
|
|
62
|
+
"connect-next": "4.0.0",
|
|
65
63
|
"cors": "^2.8.6",
|
|
66
|
-
"css-loader": "7.1.
|
|
64
|
+
"css-loader": "7.1.4",
|
|
67
65
|
"deepmerge": "^4.3.1",
|
|
68
66
|
"dotenv-expand": "12.0.3",
|
|
69
|
-
"html-rspack-plugin": "6.1.
|
|
67
|
+
"html-rspack-plugin": "6.1.8",
|
|
70
68
|
"http-proxy-middleware": "^3.0.5",
|
|
71
|
-
"
|
|
72
|
-
"
|
|
69
|
+
"jiti": "^2.6.1",
|
|
70
|
+
"launch-editor-middleware": "^2.13.2",
|
|
71
|
+
"memfs": "^4.57.1",
|
|
73
72
|
"mrmime": "^2.0.1",
|
|
74
73
|
"on-finished": "2.4.1",
|
|
75
74
|
"open": "^11.0.0",
|
|
76
|
-
"
|
|
77
|
-
"postcss": "^8.5.6",
|
|
75
|
+
"postcss": "^8.5.8",
|
|
78
76
|
"postcss-load-config": "6.0.1",
|
|
79
|
-
"postcss-loader": "8.2.
|
|
80
|
-
"prebundle": "1.6.
|
|
77
|
+
"postcss-loader": "8.2.1",
|
|
78
|
+
"prebundle": "1.6.4",
|
|
81
79
|
"range-parser": "^1.2.1",
|
|
82
80
|
"reduce-configs": "^1.1.1",
|
|
83
|
-
"rslog": "^1.
|
|
84
|
-
"rspack-chain": "^2.0.0-
|
|
81
|
+
"rslog": "^2.1.1",
|
|
82
|
+
"rspack-chain": "^2.0.0-beta.1",
|
|
85
83
|
"rspack-manifest-plugin": "5.2.1",
|
|
86
84
|
"sirv": "^3.0.2",
|
|
87
85
|
"stacktrace-parser": "^0.1.11",
|
|
88
|
-
"style-loader": "
|
|
89
|
-
"
|
|
90
|
-
"
|
|
91
|
-
"
|
|
86
|
+
"style-loader": "^4.0.0",
|
|
87
|
+
"supports-color": "^10.2.2",
|
|
88
|
+
"tinyglobby": "^0.2.15",
|
|
89
|
+
"typescript": "^6.0.2",
|
|
92
90
|
"webpack-merge": "6.0.1",
|
|
93
|
-
"ws": "^8.
|
|
91
|
+
"ws": "^8.20.0"
|
|
94
92
|
},
|
|
95
93
|
"engines": {
|
|
96
94
|
"node": "^20.19.0 || >=22.12.0"
|
|
@@ -100,9 +98,8 @@
|
|
|
100
98
|
"registry": "https://registry.npmjs.org/"
|
|
101
99
|
},
|
|
102
100
|
"scripts": {
|
|
103
|
-
"build": "rslib
|
|
104
|
-
"dev": "rslib
|
|
105
|
-
"prebundle": "prebundle"
|
|
106
|
-
"bump": "pnpx bumpp --no-tag"
|
|
101
|
+
"build": "rslib",
|
|
102
|
+
"dev": "rslib -w",
|
|
103
|
+
"prebundle": "prebundle"
|
|
107
104
|
}
|
|
108
105
|
}
|