@ohos-ports/rsbuild-core 2.2.9-beta.0 → 2.3.3-beta.0
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/README.md +10 -0
- package/bin/rsbuild.js +3 -1
- package/compiled/@rstackjs/load-config/index.d.ts +10 -1
- package/compiled/@rstackjs/load-config/package.json +1 -1
- package/compiled/chokidar/index.d.ts +448 -161
- package/compiled/chokidar/package.json +1 -1
- package/compiled/css-loader/index.js +2 -2
- package/compiled/html-rspack-plugin/index.d.ts +16 -2
- package/compiled/html-rspack-plugin/index.js +78 -28
- package/compiled/http-proxy-middleware/index.d.ts +10 -10
- package/compiled/http-proxy-middleware/package.json +1 -1
- package/compiled/jiti/dist/babel.cjs +1 -1
- package/compiled/jiti/lib/jiti-cli.mjs +0 -0
- package/compiled/postcss/index.js +1 -1
- package/compiled/postcss/lib/declaration.d.ts +2 -2
- package/compiled/postcss/package.json +1 -1
- package/compiled/postcss-loader/index.js +6 -6
- package/compiled/rspack-chain/package.json +1 -1
- package/compiled/rspack-chain/types/index.d.ts +1 -0
- package/compiled/ws/index.d.ts +4 -0
- package/compiled/ws/package.json +1 -1
- package/dist/1.js +85 -0
- package/dist/chokidar.js +1 -1
- package/dist/client/hmr.js +31 -8
- package/dist/client/overlay.js +15 -11
- package/dist/cssUrlLoader.mjs +18 -7
- package/dist/defaultConfig.d.ts +7 -2
- package/dist/helpers/compilation.d.ts +2 -0
- package/dist/helpers/index.d.ts +1 -0
- package/dist/helpers/path.d.ts +9 -0
- package/dist/helpers/stats.d.ts +1 -0
- package/dist/helpers/workspace.d.ts +1 -0
- package/dist/hooks.d.ts +2 -1
- package/dist/http-proxy-middleware.js +4 -4
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -1
- package/dist/launch-editor-middleware.js +1 -1
- package/dist/loader/cssUrlLoader.d.ts +1 -0
- package/dist/m.js +1902 -1681
- package/dist/m.js.LICENSE.txt +0 -13
- package/dist/manifest-plugin.js +1 -1
- package/dist/memfs.js +1 -1
- package/dist/open.js +2 -2
- package/dist/plugins/fileSize.d.ts +11 -0
- package/dist/server/assets-middleware/getFileFromUrl.d.ts +4 -1
- package/dist/server/assets-middleware/index.d.ts +2 -1
- package/dist/server/assets-middleware/middleware.d.ts +4 -6
- package/dist/server/assets-middleware/setupMemoryFileSystemCleanup.d.ts +3 -0
- package/dist/server/assets-middleware/setupOutputFileSystem.d.ts +1 -2
- package/dist/server/assets-middleware/setupWriteToDisk.d.ts +19 -7
- package/dist/server/browserLogs.d.ts +5 -2
- package/dist/server/devMiddlewares.d.ts +1 -1
- package/dist/server/gracefulShutdown.d.ts +1 -2
- package/dist/server/helper.d.ts +6 -3
- package/dist/server/hostCheck.d.ts +7 -0
- package/dist/server/socketServer.d.ts +18 -2
- package/dist/server/watchFiles.d.ts +3 -1
- package/dist/sirv.js +3 -2
- package/dist/trace-mapping.js +16 -14
- package/dist/transformLoader.mjs +10 -10
- package/dist/transformRawLoader.mjs +2 -2
- package/dist/types/config.d.ts +38 -6
- package/dist/types/hooks.d.ts +1 -0
- package/dist/types/plugin.d.ts +27 -4
- package/dist/types/rsbuild.d.ts +1 -1
- package/dist/workerLoader.mjs +3 -3
- package/dist/ws.js +2 -2
- package/package.json +9 -50
package/dist/open.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
let e,r,o,t,
|
|
2
|
-
tell application "System Events" to get value of property list item "CFBundleName" of property list file (app_path & ":Contents:Info.plist")`)}
|
|
1
|
+
let e,r,o,t,i;import a from"node:process";import n from"node:path";import{fileURLToPath as s}from"node:url";import l,{execFile as c}from"node:child_process";import m,{constants as p}from"node:fs/promises";import{promisify as d}from"node:util";import f from"node:os";import u from"node:fs";import{Buffer as w}from"node:buffer";function g(){return void 0===r&&(r=(()=>{try{return u.statSync("/run/.containerenv"),!0}catch{return!1}})()||(void 0===e&&(e=function(){try{return u.statSync("/.dockerenv"),!0}catch{return!1}}()||function(){try{return u.readFileSync("/proc/self/cgroup","utf8").includes("docker")}catch{return!1}}()),e)),r}let h=()=>{if("linux"!==a.platform)return!1;if(f.release().toLowerCase().includes("microsoft"))return!g();try{if(u.readFileSync("/proc/version","utf8").toLowerCase().includes("microsoft"))return!g()}catch{}return!!(u.existsSync("/proc/sys/fs/binfmt_misc/WSLInterop")||u.existsSync("/run/WSL"))&&!g()},v=a.env.__IS_WSL_TEST__?h:h(),S=d(l.execFile),x=()=>`${a.env.SYSTEMROOT||a.env.windir||String.raw`C:\Windows`}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`,y=async(e,r={})=>{let{powerShellPath:o,...t}=r,i=y.encodeCommand(e);return S(o??x(),[...y.argumentsPrefix,i],{encoding:"utf8",...t})};y.argumentsPrefix=["-NoProfile","-NonInteractive","-ExecutionPolicy","Bypass","-EncodedCommand"],y.encodeCommand=e=>w.from(e,"utf16le").toString("base64"),y.escapeArgument=e=>`'${String(e).replaceAll("'","''")}'`;let b=d(l.execFile),E=(i="/mnt/",async function(){if(t)return t;let e="/etc/wsl.conf",r=!1;try{await m.access(e,p.F_OK),r=!0}catch{}if(!r)return i;let o=function(e){for(let r of e.split("\n")){if(/^\s*#/.test(r))continue;let e=/^\s*root\s*=\s*(?<mountPoint>"[^"]*"|'[^']*'|[^#]*)/.exec(r);if(e)return e.groups.mountPoint.trim().replaceAll(/^["']|["']$/g,"")}}(await m.readFile(e,{encoding:"utf8"}));return void 0===o?i:t=(t=o).endsWith("/")?t:`${t}/`}),P=v?async()=>{let e=await E();return`${e}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`}:x,C=e=>/^[a-z]+:\/\//i.test(e),A=d(l.execFile),B=["-NoProfile","-NonInteractive","-ExecutionPolicy","Bypass","-EncodedCommand"],T=e=>w.from(e,"utf16le").toString("base64"),O=e=>[...B,T(e)],F=async(e,r={})=>{let{powerShellPath:o,...t}=r;return A(o??`${a.env.SYSTEMROOT||a.env.windir||String.raw`C:\Windows`}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`,O(e),{encoding:"utf8",...t,shell:!1})};function L(e,r,o){let t=o=>Object.defineProperty(e,r,{value:o,enumerable:!0,writable:!0});return Object.defineProperty(e,r,{configurable:!0,enumerable:!0,get(){let e=o();return t(e),e},set(e){t(e)}}),e}F.argumentsPrefix=B,F.encodeCommand=T,F.escapeArgument=e=>`'${String(e).replaceAll(/['‘’‚‛]/g,e=>e+e)}'`,F.createArguments=O;let M=d(c),H=d(c),_=d(c),I={MSEdgeHTM:{name:"Edge",id:"com.microsoft.edge"},MSEdgeBHTML:{name:"Edge Beta",id:"com.microsoft.edge.beta"},MSEdgeDHTML:{name:"Edge Dev",id:"com.microsoft.edge.dev"},AppXq0fevzme2pys62n3e0fbqa7peapykr8v:{name:"Edge",id:"com.microsoft.edge.old"},ChromeHTML:{name:"Chrome",id:"com.google.chrome"},ChromeBHTML:{name:"Chrome Beta",id:"com.google.chrome.beta"},ChromeDHTML:{name:"Chrome Dev",id:"com.google.chrome.dev"},ChromiumHTM:{name:"Chromium",id:"org.chromium.Chromium"},BraveHTML:{name:"Brave",id:"com.brave.Browser"},BraveBHTML:{name:"Brave Beta",id:"com.brave.Browser.beta"},BraveDHTML:{name:"Brave Dev",id:"com.brave.Browser.dev"},BraveSSHTM:{name:"Brave Nightly",id:"com.brave.Browser.nightly"},FirefoxURL:{name:"Firefox",id:"org.mozilla.firefox"},OperaStable:{name:"Opera",id:"com.operasoftware.Opera"},VivaldiHTM:{name:"Vivaldi",id:"com.vivaldi.Vivaldi"},"IE.HTTP":{name:"Internet Explorer",id:"com.microsoft.ie"}},$=new Map(Object.entries(I));class W extends Error{}let N=d(c),k=!!(a.env.SSH_CONNECTION||a.env.SSH_CLIENT||a.env.SSH_TTY),R=Symbol("fallbackAttempt"),U=import.meta.url?n.dirname(s(import.meta.url)):"",z=n.join(U,"xdg-open"),{platform:j,arch:D}=a,Y=async(e,r)=>{if(0===e.length)return;let o=[];for(let t of e)try{return await r(t)}catch(e){o.push(e)}throw AggregateError(o,"Failed to open in all supported apps")},G=async e=>{let r,t=!0===(e={wait:!1,background:!1,newInstance:!1,allowNonzeroExitCode:!1,...e})[R];if(delete e[R],Array.isArray(e.app))return Y(e.app,r=>G({...e,app:r,[R]:!0}));let{name:i,arguments:s=[]}=e.app??{};if(s=[...s],Array.isArray(i))return Y(i,r=>G({...e,app:{name:r,arguments:s},[R]:!0}));if("browser"===i||"browserPrivate"===i){let r,o={"com.google.chrome":"chrome","google-chrome.desktop":"chrome","com.brave.browser":"brave","org.mozilla.firefox":"firefox","firefox.desktop":"firefox","com.microsoft.msedge":"edge","com.microsoft.edge":"edge","com.microsoft.edgemac":"edge","microsoft-edge.desktop":"edge","com.apple.safari":"safari"};if(v){let e=await (async()=>{let e=await P(),r=String.raw`(Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice").ProgId`,{stdout:o}=await y(r,{powerShellPath:e,cwd:n.dirname(e)});return o.trim()})();r=$.get(e)??{}}else r=await async function(){if("darwin"===a.platform){let e=await async function(){if("darwin"!==a.platform)throw Error("macOS only");let{stdout:e}=await M("defaults",["read","com.apple.LaunchServices/com.apple.launchservices.secure","LSHandlers"]),r=/LSHandlerRoleAll = "(?!-)(?<id>[^"]+?)";\s+?LSHandlerURLScheme = (?:http|https);/.exec(e),o=r?.groups.id??"com.apple.Safari";return"com.apple.safari"===o?"com.apple.Safari":o}();return{name:await async function(e){return async function(e,{humanReadableOutput:r=!0,signal:o}={}){if("darwin"!==a.platform)throw Error("macOS only");let t={};o&&(t.signal=o);let{stdout:i}=await H("osascript",["-e",e,r?[]:["-ss"]],t);return i.trim()}(`tell application "Finder" to set app_path to application file id "${e}" as string
|
|
2
|
+
tell application "System Events" to get value of property list item "CFBundleName" of property list file (app_path & ":Contents:Info.plist")`)}(e),id:e}}if("linux"===a.platform){let{stdout:e}=await N("xdg-mime",["query","default","x-scheme-handler/http"]),r=e.trim();return{name:r.replace(/.desktop$/,"").replace("-"," ").toLowerCase().replaceAll(/(?:^|\s|-)\S/g,e=>e.toUpperCase()),id:r}}if("win32"===a.platform)return async function(e=_){let r=`${a.env.SYSTEMROOT??a.env.windir??"C:\\Windows"}\\System32\\reg.exe`,{stdout:o}=await e(r,["QUERY"," HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice","/v","ProgId"]),t=/ProgId\s*REG_SZ\s*(?<id>\S+)/.exec(o);if(!t)throw new W(`Cannot find Windows browser in stdout: ${JSON.stringify(o)}`);let{id:i}=t.groups,n=i.lastIndexOf("."),s=i.lastIndexOf("-"),l=-1===n?void 0:i.slice(0,n),c=-1===s?void 0:i.slice(0,s);return I[i]??I[l]??I[c]??{name:i,id:i}}();throw Error("Only macOS, Linux, and Windows are supported")}();let t=r.id?.toLowerCase();if(Object.hasOwn(o,t)){let r=o[t];if("browserPrivate"===i){if("safari"===r)throw Error("Safari doesn't support opening in private mode via command line");s.push({chrome:"--incognito",brave:"--incognito",firefox:"--private-window",edge:"--inPrivate"}[r])}return G({...e,app:{name:q[r],arguments:s}})}throw Error(`${r.name} is not supported as a default browser`)}let c=[],d={},f=!1;if(!v||g()||k||i||(f=await (async()=>o??=(async()=>{try{let e=await P();return await m.access(e,p.X_OK),!0}catch{return!1}})())()),"darwin"===j)r="open",e.wait&&c.push("--wait-apps"),e.background&&c.push("--background"),e.newInstance&&c.push("--new"),i&&c.push("-a",i);else if("win32"===j||f){r=await P(),c.push(...F.argumentsPrefix),v||(d.windowsVerbatimArguments=!0),v&&e.target&&(e.target=await (async e=>{let r=Array.isArray(e),o=r?e:[e],t=[],i=[];for(let[e,r]of o.entries())C(r)||(t.push(e),i.push(r));let a=[...o];if(i.length>0)try{let{stdout:e}=await b("wslpath",["-aw",...i],{encoding:"utf8"}),r=e.split(/\r?\n/).filter(Boolean);for(let[e,i]of t.entries())a[i]=r[e]??o[i]}catch{}return r?a:a[0]})(e.target));let o=["$ProgressPreference = 'SilentlyContinue';","Start"];e.wait&&o.push("-Wait"),i?(o.push(F.escapeArgument(i)),e.target&&s.push(e.target)):e.target&&o.push(F.escapeArgument(e.target)),s.length>0&&o.push("-ArgumentList",(s=s.map(e=>F.escapeArgument(e))).join(",")),e.target=F.encodeCommand(o.join(" ")),e.wait||(d.stdio="ignore"),v&&(d.cwd=n.dirname(r))}else{if(i)r=i;else{let e=!1;try{await m.access(z,p.X_OK),e=!0}catch{}r=a.versions.electron??("android"===j||!U||"/"===U||!e)?"xdg-open":z}s.length>0&&c.push(...s),e.wait||(d.stdio="ignore",d.detached=!0)}"darwin"===j&&s.length>0&&c.push("--args",...s),e.target&&c.push(e.target);let u=l.spawn(r,c,d);return e.wait?new Promise((r,o)=>{u.once("error",o),u.once("close",t=>{e.allowNonzeroExitCode||0===t?r(u):o(Error(`Exited with code ${t}`))})}):t||"win32"===j||f?new Promise((e,r)=>{u.once("error",r),u.once("spawn",()=>{u.once("close",o=>{(u.off("error",r),t&&0!==o)?r(Error(`Exited with code ${o}`)):(u.unref(),e(u))})})}):(u.unref(),new Promise((e,r)=>{u.once("error",r),u.once("spawn",()=>{u.off("error",r),e(u)})}))};function K(e){if("string"==typeof e||Array.isArray(e))return e;let{[D]:r}=e;if(!r)throw Error(`${D} is not supported`);return r}function V({[j]:e},{wsl:r}={}){if(r&&v)return K(r);if(!e)throw Error(`${j} is not supported`);return K(e)}let q={browser:"browser",browserPrivate:"browserPrivate"};L(q,"chrome",()=>V({darwin:"google chrome",win32:"chrome",linux:["google-chrome","google-chrome-stable","chromium","chromium-browser"]},{wsl:{ia32:"/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe",x64:["/mnt/c/Program Files/Google/Chrome/Application/chrome.exe","/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe"]}})),L(q,"brave",()=>V({darwin:"brave browser",win32:"brave",linux:["brave-browser","brave"]},{wsl:{ia32:"/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe",x64:["/mnt/c/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe","/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe"]}})),L(q,"firefox",()=>V({darwin:"firefox",win32:String.raw`C:\Program Files\Mozilla Firefox\firefox.exe`,linux:"firefox"},{wsl:"/mnt/c/Program Files/Mozilla Firefox/firefox.exe"})),L(q,"edge",()=>V({darwin:"microsoft edge",win32:"msedge",linux:["microsoft-edge","microsoft-edge-dev"]},{wsl:"/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe"})),L(q,"safari",()=>V({darwin:"Safari"}));export default((e,r)=>{if("string"!=typeof e)throw TypeError("Expected a `target`");return G({...r,target:e})});export{q as apps};
|
|
@@ -2,6 +2,17 @@
|
|
|
2
2
|
* modified from https://github.com/facebook/create-react-app
|
|
3
3
|
* license at https://github.com/facebook/create-react-app/blob/master/LICENSE
|
|
4
4
|
*/ import type { InternalContext, PrintFileSizeAsset, RsbuildPlugin } from '../types/index.js';
|
|
5
|
+
type AssetProcessor = (names: string[], processAsset: (name: string, index: number) => Promise<void>) => Promise<void>;
|
|
6
|
+
/**
|
|
7
|
+
* Processes up to 16 assets at a time across all environments in one build.
|
|
8
|
+
* Reads each asset only when a slot is available and starts the next asset
|
|
9
|
+
* as soon as one finishes. Passes the original index to preserve result order.
|
|
10
|
+
*
|
|
11
|
+
* On failure, stops starting new tasks. Each call waits for its running tasks
|
|
12
|
+
* to finish before throwing the first error. Create a new processor for each
|
|
13
|
+
* build to reset this error state.
|
|
14
|
+
*/ export declare function createAssetProcessor(): AssetProcessor;
|
|
5
15
|
/** Normalize file path by removing hash for comparison across builds */ export declare function normalizeFilePath(filePath: string): string;
|
|
6
16
|
/** Exclude source map, license, and type declaration files by default */ export declare const excludeAsset: (asset: PrintFileSizeAsset) => boolean;
|
|
7
17
|
export declare const pluginFileSize: (context: InternalContext) => RsbuildPlugin;
|
|
18
|
+
export { };
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import type { Stats as FSStats } from 'node:fs';
|
|
2
2
|
import type { InternalContext, Rspack } from '../../types/index.js';
|
|
3
|
+
export declare const UP_PATH_REGEXP: RegExp;
|
|
4
|
+
type FileStats = Pick<FSStats, 'isFile' | 'isDirectory' | 'mtime' | 'size'>;
|
|
3
5
|
/**
|
|
4
6
|
* Resolves URL to file path with security checks and retrieves file from
|
|
5
7
|
* the build output directories.
|
|
6
8
|
*/ export declare function getFileFromUrl(url: string, outputFileSystem: Rspack.OutputFileSystem, context: InternalContext): Promise<{
|
|
7
9
|
filename: string;
|
|
8
|
-
fsStats:
|
|
10
|
+
fsStats: FileStats;
|
|
9
11
|
} | {
|
|
10
12
|
errorCode: number;
|
|
11
13
|
} | undefined>;
|
|
14
|
+
export { };
|
|
@@ -14,12 +14,13 @@ export type AssetsMiddleware = RequestHandler & {
|
|
|
14
14
|
watch: () => void;
|
|
15
15
|
close: AssetsMiddlewareClose;
|
|
16
16
|
};
|
|
17
|
-
export declare const setupServerHooks: ({ context, compiler, token, socketServer, liveReload }: {
|
|
17
|
+
export declare const setupServerHooks: ({ context, compiler, token, socketServer, liveReload, earlyWebUpdates }: {
|
|
18
18
|
context: InternalContext;
|
|
19
19
|
compiler: Compiler;
|
|
20
20
|
token: string;
|
|
21
21
|
socketServer: SocketServer;
|
|
22
22
|
liveReload: LiveReload;
|
|
23
|
+
earlyWebUpdates: boolean;
|
|
23
24
|
}) => void;
|
|
24
25
|
/**
|
|
25
26
|
* The assets middleware handles compiler setup for development:
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import type { InternalContext, RequestHandler, Rspack } from '../../types/index.js';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
*/ export declare const filterWebEnvironments: (environmentList: InternalContext['environmentList']) => InternalContext['environmentList'];
|
|
7
|
-
export declare function createAssetsMiddleware(context: InternalContext, ready: (callback: () => void) => void, outputFileSystem: Rspack.OutputFileSystem): RequestHandler;
|
|
2
|
+
export declare function createAssetsMiddleware(context: InternalContext, { waitForAssets, waitForBuild }: {
|
|
3
|
+
waitForAssets: (callback: () => void) => void;
|
|
4
|
+
waitForBuild: (callback: () => void) => void;
|
|
5
|
+
}, outputFileSystem: Rspack.OutputFileSystem): RequestHandler;
|
|
@@ -1,3 +1,2 @@
|
|
|
1
1
|
import type { Compiler, OutputFileSystem } from '@rspack/core';
|
|
2
|
-
|
|
3
|
-
export declare function setupOutputFileSystem(writeToDisk: ResolvedWriteToDisk, compilers: Compiler[]): Promise<OutputFileSystem>;
|
|
2
|
+
export declare function setupOutputFileSystem(writeAllToDisk: boolean, compilers: Compiler[]): Promise<OutputFileSystem>;
|
|
@@ -1,15 +1,27 @@
|
|
|
1
1
|
import type { Compiler } from '@rspack/core';
|
|
2
2
|
import type { Logger } from '../../logger.js';
|
|
3
|
-
import type {
|
|
3
|
+
import type { WriteToDisk } from '../../types/index.js';
|
|
4
4
|
declare module '@rspack/core' {
|
|
5
5
|
interface Compiler {
|
|
6
6
|
__hasRsbuildAssetEmittedCallback?: boolean;
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
|
-
export type ResolvedWriteToDisk = boolean | ((filePath: string, name?: string) => boolean);
|
|
10
9
|
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
* Copy selected assets from the compiler's output file system to disk.
|
|
11
|
+
* Rspack always writes to compiler.outputFileSystem; this hook handles any
|
|
12
|
+
* additional disk writes requested by each environment's dev.writeToDisk:
|
|
13
|
+
*
|
|
14
|
+
* - With `false`, no hook is registered, so the environment's assets are
|
|
15
|
+
* never read for disk writes.
|
|
16
|
+
* - With `true` and the native Node.js fs, Rspack already writes to disk,
|
|
17
|
+
* so no extra write is needed.
|
|
18
|
+
* - With a predicate, Rspack writes to memory and this hook copies only
|
|
19
|
+
* the files accepted by the predicate to disk.
|
|
20
|
+
* - With `true` and a non-native output file system, copy every file to disk.
|
|
21
|
+
* This happens when environments have different settings and share the
|
|
22
|
+
* memory fs, or with a custom output file system that may store assets
|
|
23
|
+
* somewhere else.
|
|
24
|
+
*
|
|
25
|
+
* `writeToDiskList` holds the writeToDisk value for each compiler, in order.
|
|
26
|
+
* When all environments disable writeToDisk, the caller skips this setup.
|
|
27
|
+
*/ export declare function setupWriteToDisk(compilers: Compiler[], writeToDiskList: WriteToDisk[], logger: Logger): void;
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import type { TraceMap } from '@jridgewell/trace-mapping';
|
|
2
2
|
import type { StackFrame } from 'stacktrace-parser';
|
|
3
3
|
import type { BrowserLogsStackTrace, InternalContext, Rspack } from '../types/index.js';
|
|
4
|
-
export type
|
|
4
|
+
export type BrowserLogsCache = {
|
|
5
|
+
sourceMapPaths: Map<string, Promise<string | undefined>>;
|
|
6
|
+
traceMaps: Map<string, TraceMap>;
|
|
7
|
+
};
|
|
5
8
|
/**
|
|
6
9
|
* Formats error messages received from the browser into a log string with
|
|
7
10
|
* source location information.
|
|
8
|
-
*/ export declare const formatBrowserErrorLog: (message: string, context: InternalContext, fs: Rspack.OutputFileSystem, stackTrace: BrowserLogsStackTrace, stackFrames: StackFrame[] | null,
|
|
11
|
+
*/ export declare const formatBrowserErrorLog: (message: string, context: InternalContext, fs: Rspack.OutputFileSystem, stackTrace: BrowserLogsStackTrace, stackFrames: StackFrame[] | null, cache: BrowserLogsCache) => Promise<string>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { InternalContext, NormalizedConfig } from '../types/index.js';
|
|
2
2
|
import type { BuildManager } from './buildManager.js';
|
|
3
3
|
import type { RsbuildDevServer } from './devServer.js';
|
|
4
|
-
import type
|
|
4
|
+
import { type UpgradeEvent } from './helper.js';
|
|
5
5
|
export type RsbuildDevMiddlewareOptions = {
|
|
6
6
|
config: NormalizedConfig;
|
|
7
7
|
context: InternalContext;
|
|
@@ -3,6 +3,5 @@
|
|
|
3
3
|
*/ export declare const registerCleanup: (callback: () => Promise<void>) => void;
|
|
4
4
|
export declare const removeCleanup: (callback: () => Promise<void>) => void;
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
7
|
-
* This should be called once during application initialization
|
|
6
|
+
* Share termination listeners until the last active server is closed.
|
|
8
7
|
*/ export declare const setupGracefulShutdown: () => (() => void);
|
package/dist/server/helper.d.ts
CHANGED
|
@@ -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 {
|
|
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
|
|
@@ -92,7 +93,8 @@ export declare const HttpCode: {
|
|
|
92
93
|
*/ export type RsbuildServerBase = {
|
|
93
94
|
/**
|
|
94
95
|
* Close the server.
|
|
95
|
-
*
|
|
96
|
+
* Calls the `onCloseDevServer` or `onClosePreviewServer` hook and waits for
|
|
97
|
+
* async cleanup callbacks to complete.
|
|
96
98
|
*/ close: () => Promise<void>;
|
|
97
99
|
/**
|
|
98
100
|
* The Node.js HTTP server instance.
|
|
@@ -102,7 +104,7 @@ export declare const HttpCode: {
|
|
|
102
104
|
/**
|
|
103
105
|
* The `connect` app instance.
|
|
104
106
|
* Can be used to attach custom middlewares to the server.
|
|
105
|
-
*/ middlewares:
|
|
107
|
+
*/ middlewares: RsbuildMiddlewares;
|
|
106
108
|
/**
|
|
107
109
|
* Open URL in the browser after starting the server.
|
|
108
110
|
*/ open: () => Promise<void>;
|
|
@@ -115,4 +117,5 @@ export declare const HttpCode: {
|
|
|
115
117
|
* Print the server URLs.
|
|
116
118
|
*/ printUrls: () => void;
|
|
117
119
|
};
|
|
120
|
+
export declare const getPublicDirPaths: (config: NormalizedConfig, watchOnly?: boolean) => string[];
|
|
118
121
|
export { };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { IncomingHttpHeaders } from 'node:http';
|
|
2
|
+
import type { Connect } from '../types/index.js';
|
|
3
|
+
import type { UpgradeEvent } from './helper.js';
|
|
4
|
+
export declare function createHostCheckMiddleware(allowedHosts: readonly string[]): Connect.NextHandleFunction;
|
|
5
|
+
export declare function withHostCheck(onUpgrade: UpgradeEvent, allowedHosts: readonly string[]): UpgradeEvent;
|
|
6
|
+
export declare function isRequestHostAllowed(headers: IncomingHttpHeaders, allowedHosts: readonly string[]): boolean;
|
|
7
|
+
/** Check a Host header against local hosts, IP addresses, and additional hosts. */ export declare function isHostAllowed(hostHeader: string | undefined, allowedHosts: readonly string[]): boolean;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { IncomingMessage } from 'node:http';
|
|
2
2
|
import type { Socket } from 'node:net';
|
|
3
3
|
import type { WebSocket } from '../../compiled/ws/index.js';
|
|
4
|
-
import type { DevConfig, InternalContext, Rspack } from '../types/index.js';
|
|
4
|
+
import type { DevConfig, InternalContext, RsbuildStats, Rspack } from '../types/index.js';
|
|
5
5
|
export type ServerMessageFullReload = {
|
|
6
6
|
type: 'full-reload';
|
|
7
7
|
data?: {
|
|
@@ -20,6 +20,11 @@ export type ServerMessageHash = {
|
|
|
20
20
|
type: 'hash';
|
|
21
21
|
data: string;
|
|
22
22
|
};
|
|
23
|
+
// Apply an early web update without settling full-build diagnostics.
|
|
24
|
+
export type ServerMessageEarlyUpdate = {
|
|
25
|
+
type: 'early-update';
|
|
26
|
+
data: string;
|
|
27
|
+
};
|
|
23
28
|
export type ServerMessageOk = {
|
|
24
29
|
type: 'ok';
|
|
25
30
|
};
|
|
@@ -50,7 +55,7 @@ export type ServerCustomMessage = {
|
|
|
50
55
|
data?: any;
|
|
51
56
|
};
|
|
52
57
|
};
|
|
53
|
-
export type ServerMessage = ServerMessageOk | ServerMessageFullReload | ServerMessageStaticChanged | ServerMessageHash | ServerMessageWarnings | ServerMessageErrors | ServerMessageResolvedClientError | ServerCustomMessage;
|
|
58
|
+
export type ServerMessage = ServerMessageOk | ServerMessageFullReload | ServerMessageStaticChanged | ServerMessageHash | ServerMessageEarlyUpdate | ServerMessageWarnings | ServerMessageErrors | ServerMessageResolvedClientError | ServerCustomMessage;
|
|
54
59
|
export type ClientMessageError = {
|
|
55
60
|
type: 'client-error';
|
|
56
61
|
id: string;
|
|
@@ -73,6 +78,10 @@ export declare class SocketServer {
|
|
|
73
78
|
private getOutputFileSystem;
|
|
74
79
|
private reportedBrowserLogs;
|
|
75
80
|
private currentHash;
|
|
81
|
+
/**
|
|
82
|
+
* Stats of web environments that finished compiling before the whole
|
|
83
|
+
* multi-environment build is done, keyed by WebSocket token.
|
|
84
|
+
*/ private environmentStats;
|
|
76
85
|
private onSocketConnect?;
|
|
77
86
|
constructor(context: InternalContext, options: DevConfig, getOutputFileSystem: () => Rspack.OutputFileSystem, onSocketConnect?: SocketConnectionListener);
|
|
78
87
|
// subscribe upgrade event to handle socket
|
|
@@ -83,6 +92,13 @@ export declare class SocketServer {
|
|
|
83
92
|
private clearHeartbeatTimer;
|
|
84
93
|
// create socket, install socket handler, bind socket event
|
|
85
94
|
prepare(): Promise<void>;
|
|
95
|
+
/**
|
|
96
|
+
* Called when a single web environment finishes compiling while other
|
|
97
|
+
* environments (for example, a Node.js SSR bundle) are still compiling.
|
|
98
|
+
* Clients of this environment can apply HMR updates immediately instead of
|
|
99
|
+
* waiting for the slowest environment.
|
|
100
|
+
*/ onEnvironmentDone(token: string, getStats: () => RsbuildStats): void;
|
|
101
|
+
clearEnvironmentStats(token: string): void;
|
|
86
102
|
onBuildDone(): void;
|
|
87
103
|
/**
|
|
88
104
|
* Send error messages to the client.
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import type { FSWatcher } from '../../compiled/chokidar/index.js';
|
|
2
|
+
import type { Logger } from '../logger.js';
|
|
2
3
|
import type { ChokidarOptions, NormalizedConfig, WatchFileEvent } from '../types/index.js';
|
|
3
4
|
import type { BuildManager } from './buildManager.js';
|
|
4
5
|
export declare const DEFAULT_WATCH_FILE_EVENTS: readonly WatchFileEvent[];
|
|
5
6
|
type WatchFilesOptions = {
|
|
6
7
|
root: string;
|
|
8
|
+
logger: Logger;
|
|
7
9
|
config: NormalizedConfig;
|
|
8
10
|
buildManager?: BuildManager;
|
|
9
11
|
};
|
|
@@ -11,5 +13,5 @@ export type WatchFilesResult = {
|
|
|
11
13
|
close(): Promise<void>;
|
|
12
14
|
};
|
|
13
15
|
export declare function setupWatchFiles(options: WatchFilesOptions): Promise<WatchFilesResult | undefined>;
|
|
14
|
-
export declare function createChokidar(pathOrGlobs: string[], root: string, options: ChokidarOptions): Promise<FSWatcher>;
|
|
16
|
+
export declare function createChokidar(pathOrGlobs: string[], root: string, options: ChokidarOptions, logger: Logger): Promise<FSWatcher>;
|
|
15
17
|
export { };
|
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
|
-
|
|
9
|
-
|
|
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;
|
package/dist/trace-mapping.js
CHANGED
|
@@ -24,21 +24,23 @@ for(let i = 0; i < chars.length; i++){
|
|
|
24
24
|
let c = chars.charCodeAt(i);
|
|
25
25
|
intToChar[i] = c, charToInt[c] = i;
|
|
26
26
|
}
|
|
27
|
-
function decodeInteger(reader
|
|
27
|
+
function decodeInteger(reader) {
|
|
28
28
|
let value = 0, shift = 0, integer = 0;
|
|
29
29
|
do value |= (31 & (integer = charToInt[reader.next()])) << shift, shift += 5;
|
|
30
30
|
while (32 & integer);
|
|
31
|
-
|
|
32
|
-
return value >>>= 1, shouldNegate && (value = -2147483648 | -value), relative + value;
|
|
31
|
+
return value;
|
|
33
32
|
}
|
|
34
|
-
function
|
|
35
|
-
|
|
36
|
-
|
|
33
|
+
function decodeSign(num) {
|
|
34
|
+
return 1 & num ? -2147483648 | -(num >>> 1) : num >>> 1;
|
|
35
|
+
}
|
|
36
|
+
function encodeInteger(builder, num) {
|
|
37
37
|
do {
|
|
38
|
-
let clamped = 31 &
|
|
39
|
-
(
|
|
40
|
-
}while (
|
|
41
|
-
|
|
38
|
+
let clamped = 31 & num;
|
|
39
|
+
(num >>>= 5) > 0 && (clamped |= 32), builder.write(intToChar[clamped]);
|
|
40
|
+
}while (num > 0);
|
|
41
|
+
}
|
|
42
|
+
function encodeSign(num) {
|
|
43
|
+
return num < 0 ? -num << 1 | 1 : num << 1;
|
|
42
44
|
}
|
|
43
45
|
function hasMoreVlq(reader, max) {
|
|
44
46
|
return !(reader.pos >= max) && 44 !== reader.peek();
|
|
@@ -84,13 +86,13 @@ function decode(mappings) {
|
|
|
84
86
|
let semi = reader.indexOf(";"), line = [], sorted = !0, lastCol = 0;
|
|
85
87
|
for(genColumn = 0; reader.pos < semi;){
|
|
86
88
|
let seg;
|
|
87
|
-
(genColumn
|
|
89
|
+
(genColumn += decodeSign(decodeInteger(reader))) < lastCol && (sorted = !1), lastCol = genColumn, hasMoreVlq(reader, semi) ? (sourcesIndex += decodeSign(decodeInteger(reader)), sourceLine += decodeSign(decodeInteger(reader)), sourceColumn += decodeSign(decodeInteger(reader)), hasMoreVlq(reader, semi) ? (namesIndex += decodeSign(decodeInteger(reader)), seg = [
|
|
88
90
|
genColumn,
|
|
89
91
|
sourcesIndex,
|
|
90
92
|
sourceLine,
|
|
91
93
|
sourceColumn,
|
|
92
|
-
namesIndex
|
|
93
|
-
] : [
|
|
94
|
+
namesIndex
|
|
95
|
+
]) : seg = [
|
|
94
96
|
genColumn,
|
|
95
97
|
sourcesIndex,
|
|
96
98
|
sourceLine,
|
|
@@ -117,7 +119,7 @@ function encode(decoded) {
|
|
|
117
119
|
let genColumn = 0;
|
|
118
120
|
for(let j = 0; j < line.length; j++){
|
|
119
121
|
let segment = line[j];
|
|
120
|
-
j > 0 && writer.write(44),
|
|
122
|
+
j > 0 && writer.write(44), encodeInteger(writer, encodeSign(segment[0] - genColumn)), genColumn = segment[0], 1 !== segment.length && (encodeInteger(writer, encodeSign(segment[1] - sourcesIndex)), encodeInteger(writer, encodeSign(segment[2] - sourceLine)), encodeInteger(writer, encodeSign(segment[3] - sourceColumn)), sourcesIndex = segment[1], sourceLine = segment[2], sourceColumn = segment[3], 4 !== segment.length && (encodeInteger(writer, encodeSign(segment[4] - namesIndex)), namesIndex = segment[4]));
|
|
121
123
|
}
|
|
122
124
|
}
|
|
123
125
|
return writer.flush();
|
package/dist/transformLoader.mjs
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
import { cachedImport } from "./r.js";
|
|
2
|
-
let getRemapping = cachedImport(()=>import("./remapping.js").then((m)=>m.remapping_namespaceObject))
|
|
3
|
-
|
|
4
|
-
return remapping([
|
|
5
|
-
generatedSourceMap,
|
|
6
|
-
originalSourceMap
|
|
7
|
-
], ()=>null);
|
|
8
|
-
}, transformLoader = async function transform(source, map) {
|
|
2
|
+
let getRemapping = cachedImport(()=>import("./remapping.js").then((m)=>m.remapping_namespaceObject));
|
|
3
|
+
export default (async function transform(source, map) {
|
|
9
4
|
let callback = this.async(), { id: transformId, getEnvironment } = this.getOptions();
|
|
10
5
|
if (!transformId) return void callback(null, source, map);
|
|
11
6
|
let transform = this._compiler?.__rsbuildTransformer?.[transformId];
|
|
@@ -27,10 +22,15 @@ let getRemapping = cachedImport(()=>import("./remapping.js").then((m)=>m.remappi
|
|
|
27
22
|
});
|
|
28
23
|
if (null == result) return void callback(null, source, map);
|
|
29
24
|
if ('string' == typeof result || Buffer.isBuffer(result)) return void callback(null, result, map);
|
|
30
|
-
let mergedMap = map && result.map ? await
|
|
25
|
+
let mergedMap = map && result.map ? await (async (originalSourceMap, generatedSourceMap)=>{
|
|
26
|
+
let { default: remapping } = await getRemapping();
|
|
27
|
+
return remapping([
|
|
28
|
+
generatedSourceMap,
|
|
29
|
+
originalSourceMap
|
|
30
|
+
], ()=>null);
|
|
31
|
+
})(map, result.map) : result.map ?? map;
|
|
31
32
|
callback(null, result.code, mergedMap);
|
|
32
33
|
} catch (error) {
|
|
33
34
|
callback(error instanceof Error ? error : Error(String(error)));
|
|
34
35
|
}
|
|
35
|
-
};
|
|
36
|
-
export default transformLoader;
|
|
36
|
+
});
|
package/dist/types/config.d.ts
CHANGED
|
@@ -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;
|
|
@@ -345,6 +350,13 @@ export interface ServerConfig {
|
|
|
345
350
|
* @default 'localhost'
|
|
346
351
|
*/ host?: string | boolean;
|
|
347
352
|
/**
|
|
353
|
+
* Hostnames allowed to access the dev or preview server.
|
|
354
|
+
* `true` disables Host validation.
|
|
355
|
+
* Localhost, IP addresses, and `server.host` are always allowed.
|
|
356
|
+
* A leading dot allows a hostname and all its subdomains.
|
|
357
|
+
* @default true
|
|
358
|
+
*/ allowedHosts?: string[] | true;
|
|
359
|
+
/**
|
|
348
360
|
* Adds headers to all responses.
|
|
349
361
|
*/ headers?: Record<string, string | string[]>;
|
|
350
362
|
/**
|
|
@@ -402,7 +414,7 @@ export interface ServerConfig {
|
|
|
402
414
|
* such as registering custom middleware or running pre-start tasks.
|
|
403
415
|
*
|
|
404
416
|
* When `server.setup` is called, Rsbuild built-in middlewares are not registered yet,
|
|
405
|
-
* so middlewares you add run earlier than built-ins.
|
|
417
|
+
* so middlewares you add run earlier than built-ins, except Host validation.
|
|
406
418
|
*
|
|
407
419
|
* `server.setup` can return a callback function. After built-in middlewares are registered,
|
|
408
420
|
* Rsbuild will execute that callback. Middlewares registered in the callback run later than built-ins.
|
|
@@ -413,7 +425,7 @@ export interface ServerConfig {
|
|
|
413
425
|
export type NormalizedServerConfig = {
|
|
414
426
|
host: string;
|
|
415
427
|
publicDir: Required<PublicDirOptions>[];
|
|
416
|
-
} & Omit<Optional<Required<ServerConfig>, 'headers' | 'https' | 'historyApiFallback' | 'proxy' | 'setup'>, 'host' | 'publicDir'>;
|
|
428
|
+
} & Omit<Optional<Required<ServerConfig>, 'headers' | 'https' | 'historyApiFallback' | 'proxy' | 'setup' | 'serveAssets'>, 'host' | 'publicDir'>;
|
|
417
429
|
export type ServerSetupContext = {
|
|
418
430
|
/**
|
|
419
431
|
* Environment contexts of all environments.
|
|
@@ -500,9 +512,12 @@ export type PrintFileSizeOptions = {
|
|
|
500
512
|
totalBrotliSize?: number;
|
|
501
513
|
}) => string);
|
|
502
514
|
/**
|
|
503
|
-
*
|
|
515
|
+
* Controls how many asset sizes to print in each environment.
|
|
516
|
+
* Set to `true` to print all assets, or `false` or `0` to hide individual assets.
|
|
517
|
+
* A positive integer limits the list to the largest assets by uncompressed size.
|
|
518
|
+
* Omitted assets still contribute to totals and size comparisons when `diff` is enabled.
|
|
504
519
|
* @default true
|
|
505
|
-
*/ detail?: boolean;
|
|
520
|
+
*/ detail?: boolean | number;
|
|
506
521
|
/**
|
|
507
522
|
* Whether to print the compressed size of each static asset.
|
|
508
523
|
* Set to `true` to use gzip, or specify `type` to select gzip or Brotli.
|
|
@@ -1429,7 +1444,19 @@ export type NormalizedHtmlConfig = HtmlConfig & {
|
|
|
1429
1444
|
export type ProgressBarConfig = {
|
|
1430
1445
|
id?: string;
|
|
1431
1446
|
};
|
|
1432
|
-
export
|
|
1447
|
+
export interface RsbuildServerResponse extends ServerResponse {
|
|
1448
|
+
/**
|
|
1449
|
+
* Flush buffered gzip data without ending the response.
|
|
1450
|
+
* May be absent when compression is disabled or the middleware has not run.
|
|
1451
|
+
*/ flush?: () => void;
|
|
1452
|
+
}
|
|
1453
|
+
export type RequestHandler = (req: Connect.IncomingMessage, res: RsbuildServerResponse, next: Connect.NextFunction) => unknown;
|
|
1454
|
+
export interface RsbuildMiddlewares extends Connect.Server {
|
|
1455
|
+
use(fn: RequestHandler): this;
|
|
1456
|
+
use(fn: Connect.ServerHandle): this;
|
|
1457
|
+
use(route: string, fn: RequestHandler): this;
|
|
1458
|
+
use(route: string, fn: Connect.ServerHandle): this;
|
|
1459
|
+
}
|
|
1433
1460
|
export type EnvironmentAPI = Record<string, {
|
|
1434
1461
|
/**
|
|
1435
1462
|
* Get stats info about current environment.
|
|
@@ -1690,6 +1717,10 @@ export type RsbuildConfigMeta = {
|
|
|
1690
1717
|
* The Rsbuild config to run in the specified environment.
|
|
1691
1718
|
*/ export interface EnvironmentConfig {
|
|
1692
1719
|
/**
|
|
1720
|
+
* Configure public directories and build output serving for this environment.
|
|
1721
|
+
* Other server options are shared across environments.
|
|
1722
|
+
*/ server?: Pick<ServerConfig, 'publicDir' | 'serveAssets'>;
|
|
1723
|
+
/**
|
|
1693
1724
|
* Options for local development.
|
|
1694
1725
|
*/ dev?: Pick<DevConfig, AllowedEnvironmentDevKeys>;
|
|
1695
1726
|
/**
|
|
@@ -1768,6 +1799,7 @@ export type LogLevel = 'info' | 'warn' | 'error' | 'silent';
|
|
|
1768
1799
|
*/ _privateMeta?: RsbuildConfigMeta;
|
|
1769
1800
|
}
|
|
1770
1801
|
export type MergedEnvironmentConfig = {
|
|
1802
|
+
server?: NonNullable<EnvironmentConfig['server']>;
|
|
1771
1803
|
mode: RsbuildMode;
|
|
1772
1804
|
root: string;
|
|
1773
1805
|
dev: Pick<NormalizedDevConfig, AllowedEnvironmentDevKeys>;
|
|
@@ -1786,7 +1818,7 @@ export type MergedEnvironmentConfig = {
|
|
|
1786
1818
|
};
|
|
1787
1819
|
/**
|
|
1788
1820
|
* The normalized Rsbuild environment config.
|
|
1789
|
-
*/ export type NormalizedEnvironmentConfig = TwoLevelReadonly<Omit<MergedEnvironmentConfig, 'dev'> & {
|
|
1821
|
+
*/ export type NormalizedEnvironmentConfig = TwoLevelReadonly<Omit<MergedEnvironmentConfig, 'dev' | 'server'> & {
|
|
1790
1822
|
dev: NormalizedDevConfig;
|
|
1791
1823
|
server: NormalizedServerConfig;
|
|
1792
1824
|
_privateMeta?: RsbuildConfigMeta;
|
package/dist/types/hooks.d.ts
CHANGED
|
@@ -43,6 +43,7 @@ export type OnAfterBuildFn = (params: CompileCommonParams & {
|
|
|
43
43
|
*/ environments: Record<string, EnvironmentContext>;
|
|
44
44
|
}) => MaybePromise<void>;
|
|
45
45
|
export type OnCloseDevServerFn = () => MaybePromise<void>;
|
|
46
|
+
export type OnClosePreviewServerFn = () => MaybePromise<void>;
|
|
46
47
|
export type OnAfterDevCompileFn = (params: {
|
|
47
48
|
isFirstCompile: boolean;
|
|
48
49
|
stats: Rspack.Stats | Rspack.MultiStats;
|