@ohos-ports/rsbuild-core 2.2.13-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 +7 -9
- 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.js +14 -14
- 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/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/dist/1.js +1 -0
- package/dist/chokidar.js +1 -1
- package/dist/client/hmr.js +26 -8
- package/dist/client/overlay.js +6 -5
- package/dist/defaultConfig.d.ts +7 -2
- package/dist/helpers/compilation.d.ts +2 -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/m.js +1515 -1387
- 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/server/assets-middleware/getFileFromUrl.d.ts +3 -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/devMiddlewares.d.ts +1 -1
- package/dist/server/helper.d.ts +5 -2
- package/dist/server/socketServer.d.ts +18 -2
- package/dist/server/watchFiles.d.ts +3 -1
- package/dist/sirv.js +3 -2
- package/dist/transformLoader.mjs +10 -10
- package/dist/transformRawLoader.mjs +2 -2
- package/dist/types/config.d.ts +17 -4
- package/dist/types/hooks.d.ts +1 -0
- package/dist/types/plugin.d.ts +26 -4
- package/dist/types/rsbuild.d.ts +1 -1
- package/dist/workerLoader.mjs +3 -3
- package/dist/ws.js +2 -2
- package/package.json +5 -5
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};
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import type { Stats as FSStats } from 'node:fs';
|
|
2
2
|
import type { InternalContext, Rspack } from '../../types/index.js';
|
|
3
3
|
export declare const UP_PATH_REGEXP: RegExp;
|
|
4
|
+
type FileStats = Pick<FSStats, 'isFile' | 'isDirectory' | 'mtime' | 'size'>;
|
|
4
5
|
/**
|
|
5
6
|
* Resolves URL to file path with security checks and retrieves file from
|
|
6
7
|
* the build output directories.
|
|
7
8
|
*/ export declare function getFileFromUrl(url: string, outputFileSystem: Rspack.OutputFileSystem, context: InternalContext): Promise<{
|
|
8
9
|
filename: string;
|
|
9
|
-
fsStats:
|
|
10
|
+
fsStats: FileStats;
|
|
10
11
|
} | {
|
|
11
12
|
errorCode: number;
|
|
12
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,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;
|
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 { 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
|
|
@@ -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.
|
|
@@ -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 { };
|
|
@@ -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/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;
|
|
@@ -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.
|
|
@@ -507,9 +512,12 @@ export type PrintFileSizeOptions = {
|
|
|
507
512
|
totalBrotliSize?: number;
|
|
508
513
|
}) => string);
|
|
509
514
|
/**
|
|
510
|
-
*
|
|
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.
|
|
511
519
|
* @default true
|
|
512
|
-
*/ detail?: boolean;
|
|
520
|
+
*/ detail?: boolean | number;
|
|
513
521
|
/**
|
|
514
522
|
* Whether to print the compressed size of each static asset.
|
|
515
523
|
* Set to `true` to use gzip, or specify `type` to select gzip or Brotli.
|
|
@@ -1709,6 +1717,10 @@ export type RsbuildConfigMeta = {
|
|
|
1709
1717
|
* The Rsbuild config to run in the specified environment.
|
|
1710
1718
|
*/ export interface EnvironmentConfig {
|
|
1711
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
|
+
/**
|
|
1712
1724
|
* Options for local development.
|
|
1713
1725
|
*/ dev?: Pick<DevConfig, AllowedEnvironmentDevKeys>;
|
|
1714
1726
|
/**
|
|
@@ -1787,6 +1799,7 @@ export type LogLevel = 'info' | 'warn' | 'error' | 'silent';
|
|
|
1787
1799
|
*/ _privateMeta?: RsbuildConfigMeta;
|
|
1788
1800
|
}
|
|
1789
1801
|
export type MergedEnvironmentConfig = {
|
|
1802
|
+
server?: NonNullable<EnvironmentConfig['server']>;
|
|
1790
1803
|
mode: RsbuildMode;
|
|
1791
1804
|
root: string;
|
|
1792
1805
|
dev: Pick<NormalizedDevConfig, AllowedEnvironmentDevKeys>;
|
|
@@ -1805,7 +1818,7 @@ export type MergedEnvironmentConfig = {
|
|
|
1805
1818
|
};
|
|
1806
1819
|
/**
|
|
1807
1820
|
* The normalized Rsbuild environment config.
|
|
1808
|
-
*/ export type NormalizedEnvironmentConfig = TwoLevelReadonly<Omit<MergedEnvironmentConfig, 'dev'> & {
|
|
1821
|
+
*/ export type NormalizedEnvironmentConfig = TwoLevelReadonly<Omit<MergedEnvironmentConfig, 'dev' | 'server'> & {
|
|
1809
1822
|
dev: NormalizedDevConfig;
|
|
1810
1823
|
server: NormalizedServerConfig;
|
|
1811
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;
|
package/dist/types/plugin.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Logger } from '../logger.js';
|
|
2
2
|
import type { ModifyRspackConfigUtils, NarrowedRspackConfig, NormalizedConfig, NormalizedEnvironmentConfig, RsbuildConfig } from './config.js';
|
|
3
3
|
import type { RsbuildContext } from './context.js';
|
|
4
|
-
import type { EnvironmentContext, ModifyBundlerChainFn, ModifyEnvironmentConfigFn, ModifyHTMLFn, ModifyHTMLTagsFn, ModifyRsbuildConfigFn, OnAfterBuildFn, OnAfterCreateCompilerFn, OnAfterDevCompileFn, OnAfterEnvironmentCompileFn, OnAfterStartDevServerFn, OnAfterStartPreviewServerFn, OnBeforeBuildFn, OnBeforeCreateCompilerFn, OnBeforeDevCompileFn, OnBeforeEnvironmentCompileFn, OnBeforeStartDevServerFn, OnBeforeStartPreviewServerFn, OnCloseBuildFn, OnCloseDevServerFn, OnExitFn, OnRestartFn } from './hooks.js';
|
|
4
|
+
import type { EnvironmentContext, ModifyBundlerChainFn, ModifyEnvironmentConfigFn, ModifyHTMLFn, ModifyHTMLTagsFn, ModifyRsbuildConfigFn, OnAfterBuildFn, OnAfterCreateCompilerFn, OnAfterDevCompileFn, OnAfterEnvironmentCompileFn, OnAfterStartDevServerFn, OnAfterStartPreviewServerFn, OnBeforeBuildFn, OnBeforeCreateCompilerFn, OnBeforeDevCompileFn, OnBeforeEnvironmentCompileFn, OnBeforeStartDevServerFn, OnBeforeStartPreviewServerFn, OnCloseBuildFn, OnCloseDevServerFn, OnClosePreviewServerFn, OnExitFn, OnRestartFn } from './hooks.js';
|
|
5
5
|
import type { AddPluginsOptions, RsbuildInstance, RsbuildTarget } from './rsbuild.js';
|
|
6
6
|
import type { Rspack } from './rspack.js';
|
|
7
7
|
import type { Falsy, MaybePromise } from './utils.js';
|
|
@@ -224,12 +224,30 @@ export type TransformContext<Raw extends boolean = false> = {
|
|
|
224
224
|
*/ resolve: Rspack.LoaderContext['resolve'];
|
|
225
225
|
};
|
|
226
226
|
export type TransformHandler<Raw extends boolean = false> = (context: TransformContext<Raw>) => MaybePromise<TransformResult>;
|
|
227
|
-
|
|
227
|
+
/**
|
|
228
|
+
* Options that control when and how a transform function runs.
|
|
229
|
+
*/ export type TransformDescriptor = {
|
|
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'];
|
|
228
237
|
/**
|
|
229
238
|
* Include modules that match the test assertion, the same as `rules[].test`
|
|
230
239
|
* @see https://rspack.rs/config/module-rules#rulestest
|
|
231
240
|
*/ test?: Rspack.RuleSetCondition;
|
|
232
241
|
/**
|
|
242
|
+
* Run the transform function registered by this `api.transform` call only when
|
|
243
|
+
* its input code contains the given string or matches the regular expression.
|
|
244
|
+
* If there is no match, skip this transform and pass its input code on unchanged.
|
|
245
|
+
*
|
|
246
|
+
* The filter checks the code this function is about to receive, including
|
|
247
|
+
* changes made by earlier loaders or transforms.
|
|
248
|
+
* @see https://rspack.rs/config/module-rules#rulesusecodefilter
|
|
249
|
+
*/ codeFilter?: Rspack.RuleSetLoaderWithOptions['codeFilter'];
|
|
250
|
+
/**
|
|
233
251
|
* A condition that matches the resource query.
|
|
234
252
|
* @see https://rspack.rs/config/module-rules#rulesresourcequery
|
|
235
253
|
*/ resourceQuery?: Rspack.RuleSetCondition;
|
|
@@ -444,6 +462,10 @@ export type GetNormalizedConfig = {
|
|
|
444
462
|
* operations when the dev server is closed.
|
|
445
463
|
*/ onCloseDevServer: PluginHook<OnCloseDevServerFn>;
|
|
446
464
|
/**
|
|
465
|
+
* Called when closing the preview server.
|
|
466
|
+
* Async callbacks are awaited before `server.close()` resolves.
|
|
467
|
+
*/ onClosePreviewServer: PluginHook<OnClosePreviewServerFn>;
|
|
468
|
+
/**
|
|
447
469
|
* Alias for the `onAfterDevCompile` hook.
|
|
448
470
|
* @deprecated Use `onAfterDevCompile` instead (added in v1.5.0).
|
|
449
471
|
* Both hooks have identical functionality.
|
|
@@ -466,8 +488,8 @@ export type GetNormalizedConfig = {
|
|
|
466
488
|
/**
|
|
467
489
|
* A simplified wrapper around Rspack loaders, `api.transform` lets you
|
|
468
490
|
* easily transform the code of specific modules during the build process.
|
|
469
|
-
*
|
|
470
|
-
*
|
|
491
|
+
* Each call registers a transform function. The descriptor controls which
|
|
492
|
+
* modules to transform and how the function runs.
|
|
471
493
|
*/ transform: TransformHook;
|
|
472
494
|
/**
|
|
473
495
|
* Get the properties or methods exposed by other plugins.
|
package/dist/types/rsbuild.d.ts
CHANGED
|
@@ -221,7 +221,7 @@ export type RsbuildInstance = {
|
|
|
221
221
|
* 1. Start a development server that serves your application.
|
|
222
222
|
* 2. Watch for file changes and trigger recompilation.
|
|
223
223
|
*/ startDevServer: StartDevServer;
|
|
224
|
-
} & Pick<RsbuildPluginAPI, 'context' | 'expose' | 'getNormalizedConfig' | 'getRsbuildConfig' | 'isPluginExists' | 'modifyEnvironmentConfig' | 'modifyRsbuildConfig' | 'onAfterBuild' | 'onAfterCreateCompiler' | 'onAfterDevCompile' | 'onAfterEnvironmentCompile' | 'onAfterStartDevServer' | 'onAfterStartPreviewServer' | 'onBeforeBuild' | 'onBeforeCreateCompiler' | 'onBeforeDevCompile' | 'onBeforeEnvironmentCompile' | 'onBeforeStartDevServer' | 'onBeforeStartPreviewServer' | 'onCloseBuild' | 'onCloseDevServer' | 'onDevCompileDone' | 'onExit' | 'onRestart'>;
|
|
224
|
+
} & Pick<RsbuildPluginAPI, 'context' | 'expose' | 'getNormalizedConfig' | 'getRsbuildConfig' | 'isPluginExists' | 'modifyEnvironmentConfig' | 'modifyRsbuildConfig' | 'onAfterBuild' | 'onAfterCreateCompiler' | 'onAfterDevCompile' | 'onAfterEnvironmentCompile' | 'onAfterStartDevServer' | 'onAfterStartPreviewServer' | 'onBeforeBuild' | 'onBeforeCreateCompiler' | 'onBeforeDevCompile' | 'onBeforeEnvironmentCompile' | 'onBeforeStartDevServer' | 'onBeforeStartPreviewServer' | 'onCloseBuild' | 'onCloseDevServer' | 'onClosePreviewServer' | 'onDevCompileDone' | 'onExit' | 'onRestart'>;
|
|
225
225
|
export type RsbuildTarget = 'web' | 'node' | 'web-worker';
|
|
226
226
|
export type RsbuildEntryDescription = Rspack.EntryDescription & {
|
|
227
227
|
/**
|
package/dist/workerLoader.mjs
CHANGED
|
@@ -4,7 +4,8 @@ let INLINE_QUERY_REGEX = /[?&]inline(?:&|=|$)/, JS_FILE_REGEX = /\.m?js(?:\?.*)?
|
|
|
4
4
|
name: options && options.name
|
|
5
5
|
}`, deleteAsset = (compilation, filename)=>{
|
|
6
6
|
compilation.getAsset(filename) && compilation.deleteAsset(filename);
|
|
7
|
-
}
|
|
7
|
+
};
|
|
8
|
+
export default (async function workerLoader() {
|
|
8
9
|
let callback = this.async(), isModule = !!this._compilation.outputOptions.module;
|
|
9
10
|
try {
|
|
10
11
|
if (!INLINE_QUERY_REGEX.test(this.resourceQuery)) return void callback(null, (({ resourcePath, isModule })=>{
|
|
@@ -90,5 +91,4 @@ export default function WorkerWrapper(options) {
|
|
|
90
91
|
} catch (error) {
|
|
91
92
|
callback(error instanceof Error ? error : Error(String(error)));
|
|
92
93
|
}
|
|
93
|
-
};
|
|
94
|
-
export default workerLoader_workerLoader;
|
|
94
|
+
});
|