@rsbuild/core 2.0.0 → 2.0.2

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.
@@ -5,129 +5,132 @@ export declare const CHAIN_ID: {
5
5
  /** Predefined rules */
6
6
  readonly RULE: {
7
7
  /** Rule for .mjs */
8
- readonly MJS: "mjs";
8
+ readonly MJS: 'mjs';
9
9
  /** Rule for fonts */
10
- readonly FONT: "font";
10
+ readonly FONT: 'font';
11
11
  /** Rule for JSON */
12
- readonly JSON: "json";
12
+ readonly JSON: 'json';
13
13
  /** Rule for images */
14
- readonly IMAGE: "image";
14
+ readonly IMAGE: 'image';
15
15
  /** Rule for media */
16
- readonly MEDIA: "media";
16
+ readonly MEDIA: 'media';
17
17
  /** Rule for additional assets */
18
- readonly ADDITIONAL_ASSETS: "additional-assets";
18
+ readonly ADDITIONAL_ASSETS: 'additional-assets';
19
19
  /** Rule for JS */
20
- readonly JS: "js";
20
+ readonly JS: 'js';
21
21
  /** Rule for data uri encoded javascript */
22
- readonly JS_DATA_URI: "js-data-uri";
22
+ readonly JS_DATA_URI: 'js-data-uri';
23
23
  /** Rule for CSS */
24
- readonly CSS: "css";
24
+ readonly CSS: 'css';
25
25
  /** Rule for Less */
26
- readonly LESS: "less";
26
+ readonly LESS: 'less';
27
27
  /** Rule for Sass */
28
- readonly SASS: "sass";
28
+ readonly SASS: 'sass';
29
29
  /** Rule for stylus */
30
- readonly STYLUS: "stylus";
30
+ readonly STYLUS: 'stylus';
31
31
  /** Rule for svg */
32
- readonly SVG: "svg";
32
+ readonly SVG: 'svg';
33
33
  /** Rule for Vue */
34
- readonly VUE: "vue";
34
+ readonly VUE: 'vue';
35
35
  /** Rule for wasm */
36
- readonly WASM: "wasm";
36
+ readonly WASM: 'wasm';
37
37
  /** Rule for svelte */
38
- readonly SVELTE: "svelte";
38
+ readonly SVELTE: 'svelte';
39
39
  };
40
40
  /** Predefined rule groups */
41
41
  readonly ONE_OF: {
42
42
  /** JS oneOf rules */
43
- readonly JS_MAIN: "js";
44
- readonly JS_RAW: "js-raw";
43
+ readonly JS_MAIN: 'js';
44
+ readonly JS_RAW: 'js-raw';
45
45
  /** CSS oneOf rules */
46
- readonly CSS_MAIN: "css";
47
- readonly CSS_RAW: "css-raw";
48
- readonly CSS_INLINE: "css-inline";
46
+ readonly CSS_MAIN: 'css';
47
+ readonly CSS_RAW: 'css-raw';
48
+ readonly CSS_URL: 'css-url';
49
+ readonly CSS_INLINE: 'css-inline';
49
50
  /** SVG oneOf rules */
50
- readonly SVG: "svg";
51
- readonly SVG_RAW: "svg-asset-raw";
52
- readonly SVG_URL: "svg-asset-url";
53
- readonly SVG_ASSET: "svg-asset";
54
- readonly SVG_REACT: "svg-react";
55
- readonly SVG_INLINE: "svg-asset-inline";
51
+ readonly SVG: 'svg';
52
+ readonly SVG_RAW: 'svg-asset-raw';
53
+ readonly SVG_URL: 'svg-asset-url';
54
+ readonly SVG_ASSET: 'svg-asset';
55
+ readonly SVG_REACT: 'svg-react';
56
+ readonly SVG_INLINE: 'svg-asset-inline';
56
57
  };
57
58
  /** Predefined loaders */
58
59
  readonly USE: {
59
60
  /** ts-loader */
60
- readonly TS: "ts";
61
+ readonly TS: 'ts';
61
62
  /** css-loader */
62
- readonly CSS: "css";
63
+ readonly CSS: 'css';
64
+ /** CSS URL loader */
65
+ readonly CSS_URL: 'css-url';
63
66
  /** sass-loader */
64
- readonly SASS: "sass";
67
+ readonly SASS: 'sass';
65
68
  /** less-loader */
66
- readonly LESS: "less";
69
+ readonly LESS: 'less';
67
70
  /** stylus-loader */
68
- readonly STYLUS: "stylus";
71
+ readonly STYLUS: 'stylus';
69
72
  /** url-loader */
70
- readonly URL: "url";
73
+ readonly URL: 'url';
71
74
  /** vue-loader */
72
- readonly VUE: "vue";
75
+ readonly VUE: 'vue';
73
76
  /** swc-loader */
74
- readonly SWC: "swc";
77
+ readonly SWC: 'swc';
75
78
  /** svgr */
76
- readonly SVGR: "svgr";
79
+ readonly SVGR: 'svgr';
77
80
  /** babel-loader */
78
- readonly BABEL: "babel";
81
+ readonly BABEL: 'babel';
79
82
  /** style-loader */
80
- readonly STYLE: "style-loader";
83
+ readonly STYLE: 'style-loader';
81
84
  /** svelte-loader */
82
- readonly SVELTE: "svelte";
85
+ readonly SVELTE: 'svelte';
83
86
  /** postcss-loader */
84
- readonly POSTCSS: "postcss";
87
+ readonly POSTCSS: 'postcss';
85
88
  /** lightningcss-loader */
86
- readonly LIGHTNINGCSS: "lightningcss";
89
+ readonly LIGHTNINGCSS: 'lightningcss';
87
90
  /** ignore-css-loader */
88
- readonly IGNORE_CSS: "ignore-css";
91
+ readonly IGNORE_CSS: 'ignore-css';
89
92
  /** CssExtractRspackPlugin.loader */
90
- readonly MINI_CSS_EXTRACT: "mini-css-extract";
93
+ readonly MINI_CSS_EXTRACT: 'mini-css-extract';
91
94
  /** resolve-url-loader */
92
- readonly RESOLVE_URL: "resolve-url-loader";
95
+ readonly RESOLVE_URL: 'resolve-url-loader';
93
96
  };
94
97
  /** Predefined plugins */
95
98
  readonly PLUGIN: {
96
99
  /** HotModuleReplacementPlugin */
97
- readonly HMR: "hmr";
100
+ readonly HMR: 'hmr';
98
101
  /** CopyRspackPlugin */
99
- readonly COPY: "copy";
102
+ readonly COPY: 'copy';
100
103
  /** HtmlRspackPlugin */
101
- readonly HTML: "html";
104
+ readonly HTML: 'html';
102
105
  /** DefinePlugin */
103
- readonly DEFINE: "define";
106
+ readonly DEFINE: 'define';
104
107
  /** ProgressPlugin */
105
- readonly PROGRESS: "progress";
108
+ readonly PROGRESS: 'progress';
106
109
  /** RspackManifestPlugin */
107
- readonly MANIFEST: "rspack-manifest";
110
+ readonly MANIFEST: 'rspack-manifest';
108
111
  /** ForkTsCheckerWebpackPlugin */
109
- readonly TS_CHECKER: "ts-checker";
112
+ readonly TS_CHECKER: 'ts-checker';
110
113
  /** ModuleFederationPlugin */
111
- readonly MODULE_FEDERATION: "module-federation";
114
+ readonly MODULE_FEDERATION: 'module-federation';
112
115
  /** HtmlResourceHintsPlugin (prefetch) */
113
- readonly HTML_PREFETCH: "html-prefetch-plugin";
116
+ readonly HTML_PREFETCH: 'html-prefetch-plugin';
114
117
  /** HtmlResourceHintsPlugin (preload) */
115
- readonly HTML_PRELOAD: "html-preload-plugin";
118
+ readonly HTML_PRELOAD: 'html-preload-plugin';
116
119
  /** CssExtractRspackPlugin */
117
- readonly MINI_CSS_EXTRACT: "mini-css-extract";
120
+ readonly MINI_CSS_EXTRACT: 'mini-css-extract';
118
121
  /** VueLoaderPlugin */
119
- readonly VUE_LOADER_PLUGIN: "vue-loader-plugin";
122
+ readonly VUE_LOADER_PLUGIN: 'vue-loader-plugin';
120
123
  /** ReactFastRefreshPlugin */
121
- readonly REACT_FAST_REFRESH: "react-fast-refresh";
124
+ readonly REACT_FAST_REFRESH: 'react-fast-refresh';
122
125
  /** SubresourceIntegrityPlugin */
123
- readonly SUBRESOURCE_INTEGRITY: "subresource-integrity";
126
+ readonly SUBRESOURCE_INTEGRITY: 'subresource-integrity';
124
127
  };
125
128
  /** Predefined minimizers */
126
129
  readonly MINIMIZER: {
127
130
  /** SwcJsMinimizerRspackPlugin */
128
- readonly JS: "js";
131
+ readonly JS: 'js';
129
132
  /** LightningCssMinimizerRspackPlugin */
130
- readonly CSS: "css";
133
+ readonly CSS: 'css';
131
134
  };
132
135
  };
133
136
  export type ChainIdentifier = typeof CHAIN_ID;
@@ -1,3 +1,3 @@
1
1
  import type { StatsError } from '@rspack/core';
2
2
  import { type Logger } from '../logger';
3
- export declare function formatStatsError(stats: StatsError, root: string, level: "error" | "warning" | undefined, logger: Logger): string;
3
+ export declare function formatStatsError(stats: StatsError, root: string, level: ('error' | 'warning') | undefined, logger: Logger): string;
@@ -25,6 +25,6 @@ export declare const prettyTime: (seconds: number) => string;
25
25
  /**
26
26
  * Check if running in a TTY context
27
27
  */
28
- export declare const isTTY: (type?: "stdin" | "stdout") => boolean;
28
+ export declare const isTTY: (type?: 'stdin' | 'stdout') => boolean;
29
29
  export declare function hash(data: string): Promise<string>;
30
30
  export declare const isRspackRuntimeModule: (identifier: string) => boolean;
@@ -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,9 @@
1
+ import type { AssetInfo, LoaderDefinitionFunction, PathData, PitchLoaderDefinitionFunction } from '@rspack/core';
2
+ import type { CSSLoaderOptions } from '../types';
3
+ type CSSUrlLoaderOptions = {
4
+ filename: string | ((pathData: PathData, assetInfo?: AssetInfo) => string);
5
+ modules: CSSLoaderOptions['modules'];
6
+ };
7
+ declare const cssUrlLoader: LoaderDefinitionFunction<CSSUrlLoaderOptions>;
8
+ export declare const pitch: PitchLoaderDefinitionFunction<CSSUrlLoaderOptions>;
9
+ export default cssUrlLoader;
@@ -19,7 +19,7 @@
19
19
  */
20
20
  import { createLogger as baseCreateLogger, type Logger, logger as defaultLogger } from '../compiled/rslog';
21
21
  export declare const isDebug: () => boolean;
22
- export declare const isVerbose: (targetLogger: Pick<Logger, "level">) => boolean;
22
+ export declare const isVerbose: (targetLogger: Pick<Logger, 'level'>) => boolean;
23
23
  export declare const createLogger: (...args: Parameters<typeof baseCreateLogger>) => ReturnType<typeof baseCreateLogger>;
24
24
  export { defaultLogger };
25
25
  export type { Logger };
@@ -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>;
@@ -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, 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;
@@ -39,6 +39,7 @@ export declare function printServerURLs({ urls: originalUrls, port, routes, prot
39
39
  routes: Routes;
40
40
  protocol: string;
41
41
  printUrls?: PrintUrls;
42
+ fallbackPathname?: string;
42
43
  trailingLineBreak?: boolean;
43
44
  originalConfig?: Readonly<RsbuildConfig>;
44
45
  logger: Logger;
@@ -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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsbuild/core",
3
- "version": "2.0.0",
3
+ "version": "2.0.2",
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.0",
39
+ "@rspack/core": "~2.0.0",
40
40
  "@swc/helpers": "^0.5.21"
41
41
  },
42
42
  "peerDependencies": {
@@ -50,7 +50,7 @@
50
50
  "devDependencies": {
51
51
  "@jridgewell/remapping": "^2.3.5",
52
52
  "@jridgewell/trace-mapping": "^0.3.31",
53
- "@rslib/core": "0.21.2",
53
+ "@rslib/core": "0.21.3",
54
54
  "@types/cors": "^2.8.19",
55
55
  "@types/node": "^24.12.2",
56
56
  "@types/on-finished": "2.3.5",
@@ -65,7 +65,7 @@
65
65
  "deepmerge": "^4.3.1",
66
66
  "dotenv-expand": "13.0.0",
67
67
  "html-rspack-plugin": "6.1.8",
68
- "http-proxy-middleware": "4.0.0-beta.3",
68
+ "http-proxy-middleware": "4.0.0-beta.5",
69
69
  "jiti": "^2.6.1",
70
70
  "launch-editor-middleware": "^2.13.2",
71
71
  "memfs": "^4.57.2",
package/types.d.ts CHANGED
@@ -239,10 +239,13 @@ declare module '*.toml' {
239
239
 
240
240
  /**
241
241
  * Imports the file as a URL string.
242
- * @note Only works for static assets by default.
242
+ * @note Only works for static assets and CSS files by default.
243
243
  * @example
244
244
  * import logoUrl from './logo.png?url'
245
245
  * console.log(logoUrl) // 'http://example.com/logo.123456.png'
246
+ *
247
+ * import cssUrl from './style.css?url'
248
+ * console.log(cssUrl) // 'http://example.com/style.123456.css'
246
249
  */
247
250
  declare module '*?url' {
248
251
  const content: string;