@rsbuild/core 2.3.1 → 2.3.3

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.
@@ -1,9 +1,4 @@
1
1
  import type { InternalContext, RequestHandler, Rspack } from '../../types/index.js';
2
- /**
3
- * Filters environments to those whose outputs may be exposed by the HTTP assets
4
- * middleware. Node-targeted outputs are intended for server-side execution,
5
- * such as through `loadBundle`, and must not participate in URL resolution.
6
- */ export declare const filterWebEnvironments: (environmentList: InternalContext['environmentList']) => InternalContext['environmentList'];
7
2
  export declare function createAssetsMiddleware(context: InternalContext, { waitForAssets, waitForBuild }: {
8
3
  waitForAssets: (callback: () => void) => void;
9
4
  waitForBuild: (callback: () => void) => void;
@@ -2,7 +2,7 @@ import type { IncomingMessage, Server } from 'node:http';
2
2
  import type { Http2SecureServer } from 'node:http2';
3
3
  import type { Socket } from 'node:net';
4
4
  import type { Logger } from '../logger.js';
5
- import type { InternalContext, NormalizedConfig, OutputStructure, PrintUrls, Routes, RsbuildConfig, RsbuildEntry, RsbuildMiddlewares } from '../types/index.js';
5
+ import type { InternalContext, NormalizedConfig, NormalizedEnvironmentConfig, OutputStructure, PrintUrls, Routes, RsbuildConfig, RsbuildEntry, RsbuildMiddlewares } from '../types/index.js';
6
6
  import type { RsbuildDevServer } from './devServer.js';
7
7
  import type { RsbuildPreviewServer } from './previewServer.js';
8
8
  /**
@@ -27,6 +27,7 @@ export declare const normalizeUrl: (url: string) => string;
27
27
  export declare const joinUrlPath: (basePath: string, pathname: string) => string;
28
28
  export declare const isUrlPathUnderBase: (pathname: string, base: string) => boolean;
29
29
  export declare const removeBasePath: (url: string, base: string) => string;
30
+ export declare const isServingAssets: (config: NormalizedEnvironmentConfig) => boolean;
30
31
  export declare const getRoutes: (context: InternalContext) => Routes;
31
32
  /*
32
33
  * format route by entry and adjust the index route to be the first
package/dist/sirv.js CHANGED
@@ -5,8 +5,9 @@ import { mrmime_lookup } from "./m.js";
5
5
  import * as __rspack_external_node_fs_1b05aee1 from "node:fs";
6
6
  import * as __rspack_external_node_querystring_5092a520 from "node:querystring";
7
7
  function totalist(dir, callback, pre = '') {
8
- let arr = readdirSync(dir = external_path_resolve('.', dir)), i = 0, abs, stats;
9
- for(; i < arr.length; i++)(stats = statSync(abs = external_path_join(dir, arr[i]))).isDirectory() ? totalist(abs, callback, external_path_join(pre, arr[i])) : callback(external_path_join(pre, arr[i]), abs, stats);
8
+ dir = external_path_resolve('.', dir);
9
+ let arr = readdirSync(dir), i = 0, abs, stats;
10
+ for(; i < arr.length; i++)abs = external_path_join(dir, arr[i]), (stats = statSync(abs)).isDirectory() ? totalist(abs, callback, external_path_join(pre, arr[i])) : callback(external_path_join(pre, arr[i]), abs, stats);
10
11
  }
11
12
  function parse(req) {
12
13
  let raw = req.url;
@@ -1,4 +1,4 @@
1
1
  import loader_transformLoader from "./transformLoader.mjs";
2
- let raw = !0;
3
- export default loader_transformLoader;
2
+ let transformRawLoader = loader_transformLoader, raw = !0;
3
+ export default transformRawLoader;
4
4
  export { raw };
@@ -329,6 +329,11 @@ export interface ServerConfig {
329
329
  * @default { name: 'public', copyOnBuild: 'auto', watch: false }
330
330
  */ publicDir?: PublicDir;
331
331
  /**
332
+ * Whether the dev and preview servers serve this environment's build output.
333
+ * Does not affect compilation or programmatic access to the output.
334
+ * @default true for 'web' and 'web-worker' targets, false for 'node'
335
+ */ serveAssets?: boolean;
336
+ /**
332
337
  * Specify a port number for Rsbuild server to listen.
333
338
  * @default 3000
334
339
  */ port?: number;
@@ -420,7 +425,7 @@ export interface ServerConfig {
420
425
  export type NormalizedServerConfig = {
421
426
  host: string;
422
427
  publicDir: Required<PublicDirOptions>[];
423
- } & Omit<Optional<Required<ServerConfig>, 'headers' | 'https' | 'historyApiFallback' | 'proxy' | 'setup'>, 'host' | 'publicDir'>;
428
+ } & Omit<Optional<Required<ServerConfig>, 'headers' | 'https' | 'historyApiFallback' | 'proxy' | 'setup' | 'serveAssets'>, 'host' | 'publicDir'>;
424
429
  export type ServerSetupContext = {
425
430
  /**
426
431
  * Environment contexts of all environments.
@@ -1712,9 +1717,9 @@ export type RsbuildConfigMeta = {
1712
1717
  * The Rsbuild config to run in the specified environment.
1713
1718
  */ export interface EnvironmentConfig {
1714
1719
  /**
1715
- * Configure public directories for this environment.
1720
+ * Configure public directories and build output serving for this environment.
1716
1721
  * Other server options are shared across environments.
1717
- */ server?: Pick<ServerConfig, 'publicDir'>;
1722
+ */ server?: Pick<ServerConfig, 'publicDir' | 'serveAssets'>;
1718
1723
  /**
1719
1724
  * Options for local development.
1720
1725
  */ dev?: Pick<DevConfig, AllowedEnvironmentDevKeys>;
@@ -228,6 +228,13 @@ export type TransformHandler<Raw extends boolean = false> = (context: TransformC
228
228
  * Options that control when and how a transform function runs.
229
229
  */ export type TransformDescriptor = {
230
230
  /**
231
+ * A path template used to match subsequent rules, the same as `rules[].as`.
232
+ * When combined with `order: 'pre'`, the rule matches before the built-in rules
233
+ * so the transformed code can reuse their compilation pipeline.
234
+ * Does not change the execution order or the original resource passed to the handler.
235
+ * @see https://rspack.rs/config/module-rules#rulesas
236
+ */ as?: Rspack.RuleSetRule['as'];
237
+ /**
231
238
  * Include modules that match the test assertion, the same as `rules[].test`
232
239
  * @see https://rspack.rs/config/module-rules#rulestest
233
240
  */ test?: Rspack.RuleSetCondition;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsbuild/core",
3
- "version": "2.3.1",
3
+ "version": "2.3.3",
4
4
  "description": "The Rspack-based build tool.",
5
5
  "homepage": "https://rsbuild.rs",
6
6
  "bugs": {
@@ -39,13 +39,13 @@
39
39
  "types.d.ts"
40
40
  ],
41
41
  "dependencies": {
42
- "@rspack/core": "~2.3.1",
43
- "@swc/helpers": "^0.5.23"
42
+ "@rspack/core": "~2.3.3",
43
+ "@swc/helpers": "^0.5.24"
44
44
  },
45
45
  "devDependencies": {
46
46
  "@jridgewell/remapping": "^2.3.5",
47
47
  "@jridgewell/trace-mapping": "^0.3.31",
48
- "@jsonjoy.com/fs-core": "4.80.0",
48
+ "@jsonjoy.com/fs-core": "4.80.1",
49
49
  "@rstackjs/load-config": "^1.0.2",
50
50
  "@types/cors": "^2.8.19",
51
51
  "@types/node": "^26.6.6",
@@ -65,17 +65,17 @@
65
65
  "http-proxy-middleware": "4.2.1",
66
66
  "jiti": "^2.7.0",
67
67
  "launch-editor-middleware": "^2.14.2",
68
- "memfs": "4.80.0",
68
+ "memfs": "4.80.1",
69
69
  "mrmime": "^2.0.1",
70
70
  "open": "^11.0.4",
71
- "postcss": "^8.5.32",
71
+ "postcss": "^8.5.33",
72
72
  "postcss-load-config": "6.0.1",
73
73
  "postcss-loader": "8.2.1",
74
74
  "prebundle": "1.6.5",
75
75
  "range-parser": "^1.3.0",
76
76
  "reduce-configs": "^2.0.1",
77
77
  "rslog": "^2.3.0",
78
- "rspack-chain": "^2.3.2",
78
+ "rspack-chain": "^2.3.3",
79
79
  "rspack-manifest-plugin": "5.2.2",
80
80
  "rspack-merge": "1.0.1",
81
81
  "sirv": "^3.0.2",