@rsbuild/core 2.0.5 → 2.0.7

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 (43) hide show
  1. package/compiled/css-loader/index.js +2 -2
  2. package/compiled/html-rspack-plugin/index.js +14 -14
  3. package/compiled/http-proxy-middleware/index.d.ts +4 -4
  4. package/compiled/http-proxy-middleware/package.json +1 -1
  5. package/compiled/postcss/index.js +1 -1
  6. package/compiled/postcss/package.json +1 -1
  7. package/compiled/postcss-loader/index.js +8 -8
  8. package/compiled/style-loader/index.js +10 -10
  9. package/dist/753.js +129 -66
  10. package/dist/chokidar.js +2 -2
  11. package/dist/http-proxy-middleware.js +14 -113
  12. package/dist/manifest-plugin.js +6 -6
  13. package/dist/memfs.js +6 -8
  14. package/dist/workerLoader.mjs +94 -0
  15. package/dist/ws.js +41 -40
  16. package/dist-types/cli/init.d.ts +1 -1
  17. package/dist-types/configChain.d.ts +3 -0
  18. package/dist-types/constants.d.ts +5 -0
  19. package/dist-types/helpers/packageJson.d.ts +9 -0
  20. package/dist-types/index.d.ts +1 -1
  21. package/dist-types/initConfigs.d.ts +2 -2
  22. package/dist-types/initPlugins.d.ts +1 -1
  23. package/dist-types/inspectConfig.d.ts +1 -1
  24. package/dist-types/loadConfig.d.ts +1 -1
  25. package/dist-types/loadEnv.d.ts +1 -1
  26. package/dist-types/loader/workerLoader.d.ts +6 -0
  27. package/dist-types/mergeConfig.d.ts +6 -0
  28. package/dist-types/pluginManager.d.ts +1 -1
  29. package/dist-types/plugins/externals.d.ts +8 -1
  30. package/dist-types/plugins/worker.d.ts +2 -0
  31. package/dist-types/restart.d.ts +1 -1
  32. package/dist-types/rspack-plugins/resource-hints/doesChunkBelongToHtml.d.ts +1 -1
  33. package/dist-types/rspack-plugins/resource-hints/getResourceType.d.ts +1 -1
  34. package/dist-types/rspackConfig.d.ts +1 -1
  35. package/dist-types/server/cliShortcuts.d.ts +1 -1
  36. package/dist-types/server/gzipMiddleware.d.ts +1 -1
  37. package/dist-types/server/helper.d.ts +1 -1
  38. package/dist-types/server/open.d.ts +1 -1
  39. package/dist-types/types/config.d.ts +28 -0
  40. package/dist-types/types/plugin.d.ts +3 -3
  41. package/dist-types/types/rsbuild.d.ts +1 -1
  42. package/package.json +8 -8
  43. package/types.d.ts +42 -0
@@ -45,6 +45,11 @@ export declare const INLINE_QUERY_REGEX: RegExp;
45
45
  * Matches patterns like: `?url`, `?url&other=value`, `?other=value&url`, `?url=value`
46
46
  */
47
47
  export declare const URL_QUERY_REGEX: RegExp;
48
+ /**
49
+ * Regular expression to match the 'worker' query parameter.
50
+ * Matches patterns like: `?worker`, `?worker&inline`, `?inline&worker`, `?worker=value`
51
+ */
52
+ export declare const WORKER_QUERY_REGEX: RegExp;
48
53
  export declare const NODE_MODULES_REGEX: RegExp;
49
54
  export declare const PLUGIN_SWC_NAME = "rsbuild:swc";
50
55
  export declare const PLUGIN_CSS_NAME = "rsbuild:css";
@@ -0,0 +1,9 @@
1
+ export type PackageJson = Partial<{
2
+ name: string;
3
+ type: string;
4
+ dependencies: Record<string, string>;
5
+ optionalDependencies: Record<string, string>;
6
+ peerDependencies: Record<string, string>;
7
+ devDependencies: Record<string, string>;
8
+ }>;
9
+ export declare const readPackageJson: (rootPath: string) => Promise<PackageJson | undefined>;
@@ -20,4 +20,4 @@ export { mergeRsbuildConfig } from './mergeConfig';
20
20
  export type { RsbuildDevServer } from './server/devServer';
21
21
  export type { RsbuildServerBase, ServerStartResult, StartDevServerResult, StartPreviewServerResult, } from './server/helper';
22
22
  export type { RsbuildPreviewServer } from './server/previewServer';
23
- export type { AliasStrategy, AppIcon, AppIconItem, Build, BuildOptions, BuildResult, Charset, CleanDistPath, CleanDistPathObject, ClientConfig, CliShortcut, CompressOptions, ConfigChain, ConfigChainWithContext, Connect, ConsoleType, CreateCompiler, CreateRsbuildOptions, CrossOrigin, CSSLoaderOptions, CSSModules, CSSModulesLocalsConvention, DataUriLimit, Decorators, DevConfig, DistPathConfig, EnvironmentConfig, EnvironmentContext, FilenameConfig, FilenameHash, HistoryApiFallbackContext, HistoryApiFallbackOptions, HtmlBasicTag, HtmlConfig, HtmlFallback, HtmlRspackPlugin, HtmlTag, HtmlTagContext, HtmlTagDescriptor, HtmlTagHandler, InitConfigsOptions, InlineChunkConfig, InlineChunkTest, InlineChunkTestFunction, InspectConfigOptions, InspectConfigResult, InternalContext, LegalComments, LogLevel, ManifestConfig, ManifestData, ManifestObjectConfig, MergedEnvironmentConfig, MetaAttrs, MetaOptions, Minify, ModifyBundlerChainFn, ModifyBundlerChainUtils, ModifyChainUtils, ModifyEnvironmentConfigFn, ModifyEnvironmentConfigUtils, ModifyHTMLContext, ModifyHTMLFn, ModifyHTMLTagsContext, ModifyHTMLTagsFn, ModifyRsbuildConfigFn, ModifyRsbuildConfigUtils, ModifyRspackConfigFn, ModifyRspackConfigUtils, ModuleFederationConfig, NormalizedConfig, NormalizedDevConfig, NormalizedEnvironmentConfig, NormalizedHtmlConfig, NormalizedModuleFederationConfig, NormalizedOutputConfig, NormalizedPerformanceConfig, NormalizedResolveConfig, NormalizedSecurityConfig, NormalizedServerConfig, NormalizedSourceConfig, NormalizedSplitChunksConfig, NormalizedToolsConfig, OnAfterBuildFn, OnAfterCreateCompilerFn, OnAfterDevCompileFn, OnAfterEnvironmentCompileFn, OnAfterStartDevServerFn, OnAfterStartPreviewServerFn, OnBeforeBuildFn, OnBeforeCreateCompilerFn, OnBeforeDevCompileFn, OnBeforeEnvironmentCompileFn, OnBeforeStartDevServerFn, OnBeforeStartPreviewServerFn, OnCloseBuildFn, OnCloseDevServerFn, OnDevCompileDoneFn, OnExitFn, OutputConfig, OverlayOptions, OutputStructure, PerformanceConfig, PluginManager, Polyfill, PostCSSLoaderOptions, PostCSSOptions, PostCSSPlugin, PreconnectOption, PreviewOptions, PrintUrls, ProcessAssetsDescriptor, ProcessAssetsHandler, ProcessAssetsHook, ProgressBarConfig, ProxyBypass, ProxyConfig, ProxyFilter, ProxyOptions, PublicDir, PublicDirOptions, RequestHandler, ResolveConfig, ResolvedCreateRsbuildOptions, ResolveHandler, ResolveHook, ResourceHintsIncludeType, RsbuildConfig, RsbuildContext, RsbuildEntry, RsbuildEntryDescription, RsbuildInstance, RsbuildMode, RsbuildPlugin, RsbuildPluginAPI, RsbuildPlugins, RsbuildTarget, RspackChain, RspackRule, ScriptInject, ScriptLoading, SecurityConfig, ServerConfig, SetupMiddlewaresContext, SetupMiddlewaresFn, SourceConfig, SourceMap, SourceMapExtract, SourceMapExtractOptions, SourceMapExtractTarget, SplitChunks, SplitChunksConfig, SplitChunksPreset, SriAlgorithm, SriOptions, StartDevServerOptions, StyleLoaderOptions, ToolsConfig, TransformContext, TransformDescriptor, TransformHandler, TransformHook, TransformImport, WatchFiles, } from './types';
23
+ export type { AliasStrategy, AppIcon, AppIconItem, AutoExternal, Build, BuildOptions, BuildResult, Charset, CleanDistPath, CleanDistPathObject, ClientConfig, CliShortcut, CompressOptions, ConfigChain, ConfigChainWithContext, Connect, ConsoleType, CreateCompiler, CreateRsbuildOptions, CrossOrigin, CSSLoaderOptions, CSSModules, CSSModulesLocalsConvention, DataUriLimit, Decorators, DevConfig, DistPathConfig, EnvironmentConfig, EnvironmentContext, FilenameConfig, FilenameHash, HistoryApiFallbackContext, HistoryApiFallbackOptions, HtmlBasicTag, HtmlConfig, HtmlFallback, HtmlRspackPlugin, HtmlTag, HtmlTagContext, HtmlTagDescriptor, HtmlTagHandler, InitConfigsOptions, InlineChunkConfig, InlineChunkTest, InlineChunkTestFunction, InspectConfigOptions, InspectConfigResult, InternalContext, LegalComments, LogLevel, ManifestConfig, ManifestData, ManifestObjectConfig, MergedEnvironmentConfig, MetaAttrs, MetaOptions, Minify, ModifyBundlerChainFn, ModifyBundlerChainUtils, ModifyChainUtils, ModifyEnvironmentConfigFn, ModifyEnvironmentConfigUtils, ModifyHTMLContext, ModifyHTMLFn, ModifyHTMLTagsContext, ModifyHTMLTagsFn, ModifyRsbuildConfigFn, ModifyRsbuildConfigUtils, ModifyRspackConfigFn, ModifyRspackConfigUtils, ModuleFederationConfig, NormalizedConfig, NormalizedDevConfig, NormalizedEnvironmentConfig, NormalizedHtmlConfig, NormalizedModuleFederationConfig, NormalizedOutputConfig, NormalizedPerformanceConfig, NormalizedResolveConfig, NormalizedSecurityConfig, NormalizedServerConfig, NormalizedSourceConfig, NormalizedSplitChunksConfig, NormalizedToolsConfig, OnAfterBuildFn, OnAfterCreateCompilerFn, OnAfterDevCompileFn, OnAfterEnvironmentCompileFn, OnAfterStartDevServerFn, OnAfterStartPreviewServerFn, OnBeforeBuildFn, OnBeforeCreateCompilerFn, OnBeforeDevCompileFn, OnBeforeEnvironmentCompileFn, OnBeforeStartDevServerFn, OnBeforeStartPreviewServerFn, OnCloseBuildFn, OnCloseDevServerFn, OnDevCompileDoneFn, OnExitFn, OutputConfig, OverlayOptions, OutputStructure, PerformanceConfig, PluginManager, Polyfill, PostCSSLoaderOptions, PostCSSOptions, PostCSSPlugin, PreconnectOption, PreviewOptions, PrintUrls, ProcessAssetsDescriptor, ProcessAssetsHandler, ProcessAssetsHook, ProgressBarConfig, ProxyBypass, ProxyConfig, ProxyFilter, ProxyOptions, PublicDir, PublicDirOptions, RequestHandler, ResolveConfig, ResolvedCreateRsbuildOptions, ResolveHandler, ResolveHook, ResourceHintsIncludeType, RsbuildConfig, RsbuildContext, RsbuildEntry, RsbuildEntryDescription, RsbuildInstance, RsbuildMode, RsbuildPlugin, RsbuildPluginAPI, RsbuildPlugins, RsbuildTarget, RspackChain, RspackRule, ScriptInject, ScriptLoading, SecurityConfig, ServerConfig, SetupMiddlewaresContext, SetupMiddlewaresFn, SourceConfig, SourceMap, SourceMapExtract, SourceMapExtractOptions, SourceMapExtractTarget, SplitChunks, SplitChunksConfig, SplitChunksPreset, SriAlgorithm, SriOptions, StartDevServerOptions, StyleLoaderOptions, ToolsConfig, TransformContext, TransformDescriptor, TransformHandler, TransformHook, TransformImport, WatchFiles, } from './types';
@@ -13,7 +13,7 @@ export type InitConfigsOptions = {
13
13
  * 5. Run all the `modifyEnvironmentConfig` hooks
14
14
  * 6. Validate the final Rsbuild config
15
15
  */
16
- export declare function initRsbuildConfig({ context, pluginManager }: Pick<InitConfigsOptions, 'context' | 'pluginManager'>): Promise<NormalizedConfig>;
17
- export declare function initConfigs({ context, pluginManager, rsbuildOptions }: InitConfigsOptions): Promise<{
16
+ export declare function initRsbuildConfig({ context, pluginManager, }: Pick<InitConfigsOptions, 'context' | 'pluginManager'>): Promise<NormalizedConfig>;
17
+ export declare function initConfigs({ context, pluginManager, rsbuildOptions, }: InitConfigsOptions): Promise<{
18
18
  rspackConfigs: Rspack.Configuration[];
19
19
  }>;
@@ -1,7 +1,7 @@
1
1
  import type { Logger } from './logger';
2
2
  import type { InternalContext, NormalizedEnvironmentConfig, PluginManager, RsbuildPluginAPI } from './types';
3
3
  export declare function getHTMLPathByEntry(entryName: string, config: NormalizedEnvironmentConfig, logger: Logger): string;
4
- export declare function initPluginAPI({ context, pluginManager }: {
4
+ export declare function initPluginAPI({ context, pluginManager, }: {
5
5
  context: InternalContext;
6
6
  pluginManager: PluginManager;
7
7
  }): (environment?: string) => RsbuildPluginAPI;
@@ -1,7 +1,7 @@
1
1
  import type { InitConfigsOptions } from './initConfigs';
2
2
  import type { InspectConfigOptions, InspectConfigResult, Rspack } from './types';
3
3
  export declare function stringifyConfig(config: unknown, verbose?: boolean): string;
4
- export declare function inspectConfig({ context, pluginManager, bundlerConfigs, inspectOptions }: InitConfigsOptions & {
4
+ export declare function inspectConfig({ context, pluginManager, bundlerConfigs, inspectOptions, }: InitConfigsOptions & {
5
5
  inspectOptions?: InspectConfigOptions;
6
6
  bundlerConfigs: Rspack.Configuration[];
7
7
  }): Promise<InspectConfigResult>;
@@ -57,4 +57,4 @@ export declare function defineConfig(config: RsbuildConfigSyncFn): RsbuildConfig
57
57
  export declare function defineConfig(config: RsbuildConfigAsyncFn): RsbuildConfigAsyncFn;
58
58
  export declare function defineConfig(config: RsbuildConfigExport): RsbuildConfigExport;
59
59
  export type ConfigLoader = 'auto' | 'jiti' | 'native';
60
- export declare function loadConfig({ cwd, path, envMode, meta, loader }?: LoadConfigOptions): Promise<LoadConfigResult>;
60
+ export declare function loadConfig({ cwd, path, envMode, meta, loader, }?: LoadConfigOptions): Promise<LoadConfigResult>;
@@ -60,4 +60,4 @@ export type LoadEnvResult = {
60
60
  */
61
61
  cleanup: () => void;
62
62
  };
63
- export declare function loadEnv({ cwd, mode, prefixes, processEnv }?: LoadEnvOptions): LoadEnvResult;
63
+ export declare function loadEnv({ cwd, mode, prefixes, processEnv, }?: LoadEnvOptions): LoadEnvResult;
@@ -0,0 +1,6 @@
1
+ import type { LoaderDefinition } from '@rspack/core';
2
+ type WorkerLoaderOptions = {
3
+ name?: string;
4
+ };
5
+ declare const workerLoader: LoaderDefinition<WorkerLoaderOptions>;
6
+ export default workerLoader;
@@ -1,2 +1,8 @@
1
1
  import type { RsbuildConfig } from './types';
2
+ /**
3
+ * Deeply merges multiple Rsbuild configuration objects.
4
+ *
5
+ * This function returns a new merged configuration object and does not modify
6
+ * the input configuration objects.
7
+ */
2
8
  export declare const mergeRsbuildConfig: <T = RsbuildConfig>(...originalConfigs: (T | undefined)[]) => T;
@@ -16,7 +16,7 @@ export declare const sortPluginsByEnforce: (plugins: PluginMeta[]) => PluginMeta
16
16
  * execution order.
17
17
  */
18
18
  export declare const sortPluginsByDependencies: (plugins: PluginMeta[]) => PluginMeta[];
19
- export declare function initPlugins({ context, pluginManager }: {
19
+ export declare function initPlugins({ context, pluginManager, }: {
20
20
  context: InternalContext;
21
21
  pluginManager: PluginManager;
22
22
  }): Promise<void>;
@@ -1,2 +1,9 @@
1
- import type { RsbuildPlugin } from '../types';
1
+ import type { Externals } from '@rspack/core';
2
+ import { type PackageJson } from '../helpers/packageJson';
3
+ import type { AutoExternal, RsbuildPlugin } from '../types';
4
+ export declare const composeAutoExternalRules: (options: {
5
+ autoExternal?: AutoExternal;
6
+ pkgJson?: PackageJson;
7
+ userExternals?: Externals;
8
+ }) => (string | RegExp)[] | undefined;
2
9
  export declare function pluginExternals(): RsbuildPlugin;
@@ -0,0 +1,2 @@
1
+ import type { RsbuildPlugin } from '../types';
2
+ export declare const pluginWorker: () => RsbuildPlugin;
@@ -11,7 +11,7 @@ export declare const restartDevServer: ({ filePath, clear, logger, }: {
11
11
  clear?: boolean;
12
12
  logger: Logger;
13
13
  }) => Promise<boolean>;
14
- export declare function watchFilesForRestart({ files, rsbuild, isBuildWatch, watchOptions }: {
14
+ export declare function watchFilesForRestart({ files, rsbuild, isBuildWatch, watchOptions, }: {
15
15
  files: string[];
16
16
  rsbuild: RsbuildInstance;
17
17
  isBuildWatch: boolean;
@@ -24,5 +24,5 @@ interface DoesChunkBelongToHtmlOptions {
24
24
  pluginOptions?: ResourceHintsOptions;
25
25
  }
26
26
  export declare function recursiveChunkEntryNames(chunk: Chunk): string[];
27
- export declare function doesChunkBelongToHtml({ chunk, htmlPluginData }: DoesChunkBelongToHtmlOptions): boolean;
27
+ export declare function doesChunkBelongToHtml({ chunk, htmlPluginData, }: DoesChunkBelongToHtmlOptions): boolean;
28
28
  export {};
@@ -16,7 +16,7 @@
16
16
  * limitations under the License.
17
17
  */
18
18
  export type ResourceType = 'audio' | 'document' | 'embed' | 'fetch' | 'font' | 'image' | 'object' | 'script' | 'style' | 'track' | 'worker' | 'video';
19
- export declare function getResourceType({ href, file }: {
19
+ export declare function getResourceType({ href, file, }: {
20
20
  href: string;
21
21
  file: string;
22
22
  }): ResourceType;
@@ -1,7 +1,7 @@
1
1
  import type { EnvironmentContext, InternalContext, ModifyChainUtils, ModifyRspackConfigUtils, RsbuildTarget, Rspack } from './types';
2
2
  export declare function getConfigUtils(getCurrentConfig: () => Rspack.Configuration, chainUtils: ModifyChainUtils): ModifyRspackConfigUtils;
3
3
  export declare function getChainUtils(target: RsbuildTarget, environment: EnvironmentContext, environments: Record<string, EnvironmentContext>): ModifyChainUtils;
4
- export declare function generateRspackConfig({ target, context, environmentName }: {
4
+ export declare function generateRspackConfig({ target, context, environmentName, }: {
5
5
  target: RsbuildTarget;
6
6
  context: InternalContext;
7
7
  environmentName: string;
@@ -2,7 +2,7 @@ import type { Logger } from '../logger';
2
2
  import type { CliShortcut, NormalizedConfig } from '../types/config';
3
3
  export declare const isCliShortcutsEnabled: (config: NormalizedConfig) => boolean;
4
4
  export declare const normalizeShortcutInput: (input: string) => string;
5
- export declare function setupCliShortcuts({ help, openPage, closeServer, printUrls, restartServer, customShortcuts, logger }: {
5
+ export declare function setupCliShortcuts({ help, openPage, closeServer, printUrls, restartServer, customShortcuts, logger, }: {
6
6
  help?: boolean | string;
7
7
  openPage: () => Promise<void>;
8
8
  closeServer: () => Promise<void>;
@@ -1,2 +1,2 @@
1
1
  import type { CompressOptions, RequestHandler } from '../types';
2
- export declare function gzipMiddleware({ filter, level }?: CompressOptions): RequestHandler;
2
+ export declare function gzipMiddleware({ filter, level, }?: CompressOptions): RequestHandler;
@@ -30,7 +30,7 @@ export declare const joinUrlSegments: (s1: string, s2: string) => string;
30
30
  export declare const stripBase: (path: string, base: string) => string;
31
31
  export declare const getRoutes: (context: InternalContext) => Routes;
32
32
  export declare const formatRoutes: (entry: RsbuildEntry, base: string, distPathPrefix: string | undefined, outputStructure: OutputStructure | undefined) => Routes;
33
- export declare function printServerURLs({ urls: originalUrls, port, routes, protocol, printUrls, fallbackPathname, trailingLineBreak, originalConfig, logger }: {
33
+ export declare function printServerURLs({ urls: originalUrls, port, routes, protocol, printUrls, fallbackPathname, trailingLineBreak, originalConfig, logger, }: {
34
34
  urls: {
35
35
  url: string;
36
36
  label: string;
@@ -2,7 +2,7 @@ import type { Logger } from '../logger';
2
2
  import type { NormalizedConfig, Routes } from '../types';
3
3
  export declare const replacePortPlaceholder: (url: string, port: number) => string;
4
4
  export declare function resolveUrl(str: string, base: string): string;
5
- export declare function open({ port, routes, config, protocol, clearCache, logger }: {
5
+ export declare function open({ port, routes, config, protocol, clearCache, logger, }: {
6
6
  port: number;
7
7
  routes: Routes;
8
8
  config: NormalizedConfig;
@@ -1104,6 +1104,28 @@ export type CleanDistPathObject = {
1104
1104
  keep?: RegExp[];
1105
1105
  };
1106
1106
  export type CleanDistPath = boolean | 'auto' | CleanDistPathObject;
1107
+ export type AutoExternal = boolean | {
1108
+ /**
1109
+ * Whether to automatically externalize dependencies of type `dependencies`.
1110
+ * @default true
1111
+ */
1112
+ dependencies?: boolean;
1113
+ /**
1114
+ * Whether to automatically externalize dependencies of type `optionalDependencies`.
1115
+ * @default true
1116
+ */
1117
+ optionalDependencies?: boolean;
1118
+ /**
1119
+ * Whether to automatically externalize dependencies of type `peerDependencies`.
1120
+ * @default true
1121
+ */
1122
+ peerDependencies?: boolean;
1123
+ /**
1124
+ * Whether to automatically externalize dependencies of type `devDependencies`.
1125
+ * @default false
1126
+ */
1127
+ devDependencies?: boolean;
1128
+ };
1107
1129
  export interface OutputConfig {
1108
1130
  /**
1109
1131
  * Setting the build target for Rsbuild.
@@ -1117,6 +1139,12 @@ export interface OutputConfig {
1117
1139
  * @default undefined
1118
1140
  */
1119
1141
  externals?: Externals;
1142
+ /**
1143
+ * Automatically externalize dependencies declared in the root package.json.
1144
+ * This option will generate `externals` rules for matching dependencies and their subpath imports.
1145
+ * @default false
1146
+ */
1147
+ autoExternal?: AutoExternal;
1120
1148
  /**
1121
1149
  * Set the directory of the output files.
1122
1150
  * Rsbuild will emit files to the specified subdirectory according to the file type.
@@ -452,7 +452,7 @@ export type RsbuildPluginAPI = Readonly<{
452
452
  */
453
453
  onAfterBuild: PluginHook<OnAfterBuildFn>;
454
454
  /**
455
- * A callback function that is triggered after the compiler instance has been
455
+ * A callback function that is triggered after the Rspack Compiler instance has been
456
456
  * created, but before the build process. This hook is called when you run
457
457
  * `rsbuild.startDevServer`, `rsbuild.build`, or `rsbuild.createCompiler`.
458
458
  */
@@ -488,8 +488,8 @@ export type RsbuildPluginAPI = Readonly<{
488
488
  */
489
489
  onBeforeDevCompile: PluginHook<OnBeforeDevCompileFn>;
490
490
  /**
491
- * A callback function that is triggered after the Compiler instance has been
492
- * created, but before the build process begins. This hook is called when you
491
+ * A callback function that is triggered before the Rspack Compiler instance is
492
+ * created. This hook is called when you
493
493
  * run `rsbuild.startDevServer`, `rsbuild.build`, or `rsbuild.createCompiler`.
494
494
  */
495
495
  onBeforeCreateCompiler: PluginHook<OnBeforeCreateCompilerFn>;
@@ -190,7 +190,7 @@ export type RsbuildInstance = {
190
190
  * Remove the plugin in the specified environment.
191
191
  * If environment is not specified, remove it in all environments.
192
192
  */
193
- environment: string;
193
+ environment?: string;
194
194
  }) => void;
195
195
  /**
196
196
  * Perform a production mode build. This method will generate optimized
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsbuild/core",
3
- "version": "2.0.5",
3
+ "version": "2.0.7",
4
4
  "description": "The Rspack-based build tool.",
5
5
  "homepage": "https://rsbuild.rs",
6
6
  "bugs": {
@@ -36,7 +36,7 @@
36
36
  "types.d.ts"
37
37
  ],
38
38
  "dependencies": {
39
- "@rspack/core": "~2.0.2",
39
+ "@rspack/core": "~2.0.4",
40
40
  "@swc/helpers": "^0.5.21"
41
41
  },
42
42
  "peerDependencies": {
@@ -50,9 +50,9 @@
50
50
  "devDependencies": {
51
51
  "@jridgewell/remapping": "^2.3.5",
52
52
  "@jridgewell/trace-mapping": "^0.3.31",
53
- "@rslib/core": "0.21.3",
53
+ "@rslib/core": "0.21.5",
54
54
  "@types/cors": "^2.8.19",
55
- "@types/node": "^24.12.2",
55
+ "@types/node": "^24.12.4",
56
56
  "@types/on-finished": "2.3.5",
57
57
  "@types/range-parser": "^1.2.7",
58
58
  "@types/ws": "^8.18.1",
@@ -60,19 +60,20 @@
60
60
  "cac": "^7.0.0",
61
61
  "chokidar": "^5.0.0",
62
62
  "connect-next": "4.0.1",
63
+ "core-js": "^3.49.0",
63
64
  "cors": "^2.8.6",
64
65
  "css-loader": "7.1.4",
65
66
  "deepmerge": "^4.3.1",
66
67
  "dotenv-expand": "13.0.0",
67
68
  "html-rspack-plugin": "6.1.8",
68
- "http-proxy-middleware": "4.0.0-beta.6",
69
+ "http-proxy-middleware": "4.0.0",
69
70
  "jiti": "^2.7.0",
70
71
  "launch-editor-middleware": "^2.13.2",
71
72
  "memfs": "^4.57.2",
72
73
  "mrmime": "^2.0.1",
73
74
  "on-finished": "2.4.1",
74
75
  "open": "^11.0.0",
75
- "postcss": "^8.5.13",
76
+ "postcss": "^8.5.14",
76
77
  "postcss-load-config": "6.0.1",
77
78
  "postcss-loader": "8.2.1",
78
79
  "prebundle": "1.6.4",
@@ -85,10 +86,9 @@
85
86
  "sirv": "^3.0.2",
86
87
  "stacktrace-parser": "^0.1.11",
87
88
  "style-loader": "^4.0.0",
88
- "supports-color": "^10.2.2",
89
89
  "tinyglobby": "^0.2.16",
90
90
  "typescript": "^6.0.3",
91
- "ws": "^8.20.0"
91
+ "ws": "^8.20.1"
92
92
  },
93
93
  "engines": {
94
94
  "node": "^20.19.0 || >=22.12.0"
package/types.d.ts CHANGED
@@ -45,6 +45,15 @@ interface ImportMetaEnv extends Record<ImportMetaEnvFallbackKey, any> {
45
45
  * }
46
46
  */
47
47
  PROD: boolean;
48
+ /**
49
+ * Whether the current build is for the server (SSR).
50
+ * If `output.target` is `'node'`, the value is `true`; otherwise, it is `false`.
51
+ * @example
52
+ * if (import.meta.env.SSR) {
53
+ * console.log('SSR build');
54
+ * }
55
+ */
56
+ SSR: boolean;
48
57
  /**
49
58
  * The value of the `server.base` configuration.
50
59
  * @example
@@ -252,6 +261,39 @@ declare module '*?url' {
252
261
  export default content;
253
262
  }
254
263
 
264
+ /**
265
+ * Imports the file as a Web Worker constructor.
266
+ * @example
267
+ * import MyWorker from './worker.ts?worker';
268
+ * const worker = new MyWorker();
269
+ */
270
+ declare module '*?worker' {
271
+ const WorkerConstructor: {
272
+ new (options?: { name?: string }): Worker;
273
+ };
274
+ export default WorkerConstructor;
275
+ }
276
+
277
+ /**
278
+ * Imports the file as an inline Web Worker constructor.
279
+ * @example
280
+ * import MyWorker from './worker.ts?worker&inline';
281
+ * const worker = new MyWorker();
282
+ */
283
+ declare module '*?worker&inline' {
284
+ const WorkerConstructor: {
285
+ new (options?: { name?: string }): Worker;
286
+ };
287
+ export default WorkerConstructor;
288
+ }
289
+
290
+ declare module '*?inline&worker' {
291
+ const WorkerConstructor: {
292
+ new (options?: { name?: string }): Worker;
293
+ };
294
+ export default WorkerConstructor;
295
+ }
296
+
255
297
  /**
256
298
  * Imports the file content as a base64 encoded string.
257
299
  * @note Only works for static assets and CSS files by default.