@ohos-ports/rsbuild-core 1.1.14-beta.1
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/LICENSE +21 -0
- package/README.md +28 -0
- package/bin/rsbuild.js +20 -0
- package/compiled/chokidar/index.d.ts +345 -0
- package/compiled/chokidar/index.js +1778 -0
- package/compiled/chokidar/license +21 -0
- package/compiled/chokidar/package.json +1 -0
- package/compiled/connect/index.d.ts +90 -0
- package/compiled/connect/index.js +1240 -0
- package/compiled/connect/license +25 -0
- package/compiled/connect/package.json +1 -0
- package/compiled/connect-history-api-fallback/index.d.ts +1 -0
- package/compiled/connect-history-api-fallback/index.js +149 -0
- package/compiled/connect-history-api-fallback/license +21 -0
- package/compiled/connect-history-api-fallback/package.json +1 -0
- package/compiled/cors/index.d.ts +1 -0
- package/compiled/cors/index.js +371 -0
- package/compiled/cors/license +22 -0
- package/compiled/cors/package.json +1 -0
- package/compiled/css-loader/api.js +85 -0
- package/compiled/css-loader/getUrl.js +26 -0
- package/compiled/css-loader/index.d.ts +1 -0
- package/compiled/css-loader/index.js +8008 -0
- package/compiled/css-loader/license +20 -0
- package/compiled/css-loader/noSourceMaps.js +5 -0
- package/compiled/css-loader/package.json +1 -0
- package/compiled/css-loader/sourceMaps.js +16 -0
- package/compiled/html-rspack-plugin/default_index.ejs +9 -0
- package/compiled/html-rspack-plugin/index.d.ts +289 -0
- package/compiled/html-rspack-plugin/index.js +1583 -0
- package/compiled/html-rspack-plugin/license +20 -0
- package/compiled/html-rspack-plugin/loader.js +162 -0
- package/compiled/html-rspack-plugin/package.json +1 -0
- package/compiled/http-proxy-middleware/index.d.ts +318 -0
- package/compiled/http-proxy-middleware/index.js +5280 -0
- package/compiled/http-proxy-middleware/license +22 -0
- package/compiled/http-proxy-middleware/package.json +1 -0
- package/compiled/jiti/index.d.ts +1 -0
- package/compiled/jiti/index.js +416 -0
- package/compiled/jiti/license +21 -0
- package/compiled/jiti/package.json +1 -0
- package/compiled/launch-editor-middleware/index.d.ts +1 -0
- package/compiled/launch-editor-middleware/index.js +694 -0
- package/compiled/launch-editor-middleware/license +21 -0
- package/compiled/launch-editor-middleware/package.json +1 -0
- package/compiled/mrmime/index.d.ts +4 -0
- package/compiled/mrmime/index.js +452 -0
- package/compiled/mrmime/package.json +1 -0
- package/compiled/on-finished/index.d.ts +13 -0
- package/compiled/on-finished/index.js +197 -0
- package/compiled/on-finished/license +23 -0
- package/compiled/on-finished/package.json +1 -0
- package/compiled/open/index.d.ts +153 -0
- package/compiled/open/index.js +409 -0
- package/compiled/open/package.json +1 -0
- package/compiled/open/xdg-open +1066 -0
- package/compiled/picocolors/index.d.ts +55 -0
- package/compiled/picocolors/index.js +108 -0
- package/compiled/picocolors/license +15 -0
- package/compiled/picocolors/package.json +1 -0
- package/compiled/postcss/index.d.ts +1 -0
- package/compiled/postcss/index.js +5997 -0
- package/compiled/postcss/license +20 -0
- package/compiled/postcss/package.json +1 -0
- package/compiled/postcss-load-config/index.d.ts +1 -0
- package/compiled/postcss-load-config/index.js +739 -0
- package/compiled/postcss-load-config/license +20 -0
- package/compiled/postcss-load-config/package.json +1 -0
- package/compiled/postcss-loader/index.d.ts +1 -0
- package/compiled/postcss-loader/index.js +741 -0
- package/compiled/postcss-loader/license +20 -0
- package/compiled/postcss-loader/package.json +1 -0
- package/compiled/rsbuild-dev-middleware/index.d.ts +1 -0
- package/compiled/rsbuild-dev-middleware/index.js +6158 -0
- package/compiled/rsbuild-dev-middleware/license +20 -0
- package/compiled/rsbuild-dev-middleware/package.json +1 -0
- package/compiled/rslog/index.d.ts +66 -0
- package/compiled/rslog/index.js +334 -0
- package/compiled/rslog/license +21 -0
- package/compiled/rslog/package.json +1 -0
- package/compiled/rspack-chain/index.d.ts +611 -0
- package/compiled/rspack-chain/index.js +1740 -0
- package/compiled/rspack-chain/license +373 -0
- package/compiled/rspack-chain/package.json +1 -0
- package/compiled/rspack-manifest-plugin/index.d.ts +44 -0
- package/compiled/rspack-manifest-plugin/index.js +394 -0
- package/compiled/rspack-manifest-plugin/license +21 -0
- package/compiled/rspack-manifest-plugin/package.json +1 -0
- package/compiled/sirv/index.d.ts +1 -0
- package/compiled/sirv/index.js +709 -0
- package/compiled/sirv/package.json +1 -0
- package/compiled/style-loader/index.d.ts +1 -0
- package/compiled/style-loader/index.js +427 -0
- package/compiled/style-loader/license +20 -0
- package/compiled/style-loader/package.json +1 -0
- package/compiled/style-loader/runtime/injectStylesIntoLinkTag.js +29 -0
- package/compiled/style-loader/runtime/injectStylesIntoStyleTag.js +84 -0
- package/compiled/style-loader/runtime/insertBySelector.js +34 -0
- package/compiled/style-loader/runtime/insertStyleElement.js +10 -0
- package/compiled/style-loader/runtime/isEqualLocals.js +28 -0
- package/compiled/style-loader/runtime/isOldIE.js +17 -0
- package/compiled/style-loader/runtime/setAttributesWithAttributes.js +13 -0
- package/compiled/style-loader/runtime/setAttributesWithAttributesAndNonce.js +9 -0
- package/compiled/style-loader/runtime/setAttributesWithoutAttributes.js +10 -0
- package/compiled/style-loader/runtime/singletonStyleDomAPI.js +86 -0
- package/compiled/style-loader/runtime/styleDomAPI.js +61 -0
- package/compiled/style-loader/runtime/styleTagTransform.js +14 -0
- package/compiled/tinyglobby/index.d.ts +25 -0
- package/compiled/tinyglobby/index.js +2749 -0
- package/compiled/tinyglobby/index1.js +17 -0
- package/compiled/tinyglobby/license +21 -0
- package/compiled/tinyglobby/package.json +1 -0
- package/compiled/webpack-bundle-analyzer/index.d.ts +160 -0
- package/compiled/webpack-bundle-analyzer/index.js +13480 -0
- package/compiled/webpack-bundle-analyzer/license +20 -0
- package/compiled/webpack-bundle-analyzer/package.json +1 -0
- package/compiled/webpack-bundle-analyzer/public/viewer.js +16 -0
- package/compiled/webpack-bundle-analyzer/public/viewer.js.LICENSE.txt +10 -0
- package/compiled/webpack-merge/index.d.ts +31 -0
- package/compiled/webpack-merge/index.js +1200 -0
- package/compiled/webpack-merge/license +20 -0
- package/compiled/webpack-merge/package.json +1 -0
- package/compiled/ws/index.d.ts +401 -0
- package/compiled/ws/index.js +3153 -0
- package/compiled/ws/license +20 -0
- package/compiled/ws/package.json +1 -0
- package/dist/client/hmr.js +143 -0
- package/dist/client/overlay.js +210 -0
- package/dist/ignoreCssLoader.mjs +4 -0
- package/dist/index.cjs +7251 -0
- package/dist/index.js +7118 -0
- package/dist/transformLoader.mjs +22 -0
- package/dist/transformRawLoader.mjs +22 -0
- package/dist-types/cli/commands.d.ts +23 -0
- package/dist-types/cli/index.d.ts +1 -0
- package/dist-types/cli/init.d.ts +7 -0
- package/dist-types/cli/prepare.d.ts +1 -0
- package/dist-types/client/hmr.d.ts +1 -0
- package/dist-types/client/overlay.d.ts +1 -0
- package/dist-types/config.d.ts +90 -0
- package/dist-types/configChain.d.ts +139 -0
- package/dist-types/constants.d.ts +37 -0
- package/dist-types/createContext.d.ts +11 -0
- package/dist-types/createRsbuild.d.ts +2 -0
- package/dist-types/helpers/format.d.ts +5 -0
- package/dist-types/helpers/fs.d.ts +13 -0
- package/dist-types/helpers/index.d.ts +47 -0
- package/dist-types/helpers/path.d.ts +11 -0
- package/dist-types/helpers/stats.d.ts +9 -0
- package/dist-types/hooks.d.ts +48 -0
- package/dist-types/index.d.ts +26 -0
- package/dist-types/initPlugins.d.ts +6 -0
- package/dist-types/internal.d.ts +6 -0
- package/dist-types/loadEnv.d.ts +50 -0
- package/dist-types/loader/ignoreCssLoader.d.ts +2 -0
- package/dist-types/loader/transformLoader.d.ts +7 -0
- package/dist-types/loader/transformRawLoader.d.ts +3 -0
- package/dist-types/logger.d.ts +4 -0
- package/dist-types/mergeConfig.d.ts +2 -0
- package/dist-types/package.json +1 -0
- package/dist-types/pluginHelper.d.ts +12 -0
- package/dist-types/pluginManager.d.ts +9 -0
- package/dist-types/plugins/appIcon.d.ts +2 -0
- package/dist-types/plugins/asset.d.ts +3 -0
- package/dist-types/plugins/basic.d.ts +5 -0
- package/dist-types/plugins/bundleAnalyzer.d.ts +2 -0
- package/dist-types/plugins/cache.d.ts +2 -0
- package/dist-types/plugins/cleanOutput.d.ts +3 -0
- package/dist-types/plugins/css.d.ts +3 -0
- package/dist-types/plugins/define.d.ts +2 -0
- package/dist-types/plugins/entry.d.ts +2 -0
- package/dist-types/plugins/externals.d.ts +2 -0
- package/dist-types/plugins/fileSize.d.ts +4 -0
- package/dist-types/plugins/html.d.ts +9 -0
- package/dist-types/plugins/inlineChunk.d.ts +2 -0
- package/dist-types/plugins/lazyCompilation.d.ts +2 -0
- package/dist-types/plugins/manifest.d.ts +2 -0
- package/dist-types/plugins/minimize.d.ts +10 -0
- package/dist-types/plugins/moduleFederation.d.ts +2 -0
- package/dist-types/plugins/moment.d.ts +2 -0
- package/dist-types/plugins/nodeAddons.d.ts +2 -0
- package/dist-types/plugins/nonce.d.ts +2 -0
- package/dist-types/plugins/output.d.ts +2 -0
- package/dist-types/plugins/performance.d.ts +5 -0
- package/dist-types/plugins/progress.d.ts +2 -0
- package/dist-types/plugins/resolve.d.ts +2 -0
- package/dist-types/plugins/resourceHints.d.ts +2 -0
- package/dist-types/plugins/rsdoctor.d.ts +2 -0
- package/dist-types/plugins/rspackProfile.d.ts +2 -0
- package/dist-types/plugins/server.d.ts +2 -0
- package/dist-types/plugins/splitChunks.d.ts +4 -0
- package/dist-types/plugins/sri.d.ts +2 -0
- package/dist-types/plugins/swc.d.ts +7 -0
- package/dist-types/plugins/target.d.ts +2 -0
- package/dist-types/plugins/wasm.d.ts +2 -0
- package/dist-types/provider/build.d.ts +3 -0
- package/dist-types/provider/createCompiler.d.ts +27 -0
- package/dist-types/provider/helpers.d.ts +12 -0
- package/dist-types/provider/initConfigs.d.ts +10 -0
- package/dist-types/provider/inspectConfig.d.ts +6 -0
- package/dist-types/provider/provider.d.ts +2 -0
- package/dist-types/provider/rspackConfig.d.ts +8 -0
- package/dist-types/rspack/RsbuildHtmlPlugin.d.ts +37 -0
- package/dist-types/rspack/preload/HtmlPreloadOrPrefetchPlugin.d.ts +29 -0
- package/dist-types/rspack/preload/helpers/determineAsValue.d.ts +22 -0
- package/dist-types/rspack/preload/helpers/doesChunkBelongToHtml.d.ts +29 -0
- package/dist-types/rspack/preload/helpers/extractChunks.d.ts +28 -0
- package/dist-types/rspack/preload/helpers/index.d.ts +4 -0
- package/dist-types/rspack/preload/helpers/type.d.ts +13 -0
- package/dist-types/server/ansiHTML.d.ts +12 -0
- package/dist-types/server/cliShortcuts.d.ts +10 -0
- package/dist-types/server/compilerDevMiddleware.d.ts +31 -0
- package/dist-types/server/devMiddleware.d.ts +27 -0
- package/dist-types/server/devServer.d.ts +60 -0
- package/dist-types/server/environment.d.ts +8 -0
- package/dist-types/server/getDevMiddlewares.d.ts +25 -0
- package/dist-types/server/gzipMiddleware.d.ts +4 -0
- package/dist-types/server/helper.d.ts +71 -0
- package/dist-types/server/httpServer.d.ts +8 -0
- package/dist-types/server/middlewares.d.ts +34 -0
- package/dist-types/server/open.d.ts +10 -0
- package/dist-types/server/prodServer.d.ts +25 -0
- package/dist-types/server/proxy.d.ts +6 -0
- package/dist-types/server/restart.d.ts +14 -0
- package/dist-types/server/runner/asModule.d.ts +2 -0
- package/dist-types/server/runner/basic.d.ts +25 -0
- package/dist-types/server/runner/cjs.d.ts +10 -0
- package/dist-types/server/runner/esm.d.ts +6 -0
- package/dist-types/server/runner/index.d.ts +8 -0
- package/dist-types/server/runner/type.d.ts +36 -0
- package/dist-types/server/socketServer.d.ts +26 -0
- package/dist-types/server/watchFiles.d.ts +14 -0
- package/dist-types/types/config.d.ts +1309 -0
- package/dist-types/types/context.d.ts +52 -0
- package/dist-types/types/hooks.d.ts +146 -0
- package/dist-types/types/index.d.ts +8 -0
- package/dist-types/types/plugin.d.ts +329 -0
- package/dist-types/types/rsbuild.d.ts +156 -0
- package/dist-types/types/rspack.d.ts +16 -0
- package/dist-types/types/thirdParty.d.ts +176 -0
- package/dist-types/types/utils.d.ts +12 -0
- package/package.json +61 -0
- package/static/openChrome.applescript +95 -0
- package/types.d.ts +221 -0
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type { IncomingMessage, Server } from 'node:http';
|
|
2
|
+
import type { Http2SecureServer } from 'node:http2';
|
|
3
|
+
import type { Socket } from 'node:net';
|
|
4
|
+
import type { InternalContext, NormalizedConfig, OutputStructure, PrintUrls, Routes, RsbuildEntry, Rspack } from '../types';
|
|
5
|
+
/**
|
|
6
|
+
* It used to subscribe http upgrade event
|
|
7
|
+
*/
|
|
8
|
+
export type UpgradeEvent = (req: IncomingMessage, socket: Socket, head: any) => void;
|
|
9
|
+
export type StartServerResult = {
|
|
10
|
+
urls: string[];
|
|
11
|
+
port: number;
|
|
12
|
+
server: {
|
|
13
|
+
close: () => Promise<void>;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
export declare const normalizeUrl: (url: string) => string;
|
|
17
|
+
export declare const joinUrlSegments: (s1: string, s2: string) => string;
|
|
18
|
+
export declare const stripBase: (path: string, base: string) => string;
|
|
19
|
+
export declare const getRoutes: (context: InternalContext) => Routes;
|
|
20
|
+
export declare const formatRoutes: (entry: RsbuildEntry, base: string, distPathPrefix: string | undefined, outputStructure: OutputStructure | undefined) => Routes;
|
|
21
|
+
export declare function printServerURLs({ urls: originalUrls, port, routes, protocol, printUrls, trailingLineBreak, }: {
|
|
22
|
+
urls: Array<{
|
|
23
|
+
url: string;
|
|
24
|
+
label: string;
|
|
25
|
+
}>;
|
|
26
|
+
port: number;
|
|
27
|
+
routes: Routes;
|
|
28
|
+
protocol: string;
|
|
29
|
+
printUrls?: PrintUrls;
|
|
30
|
+
trailingLineBreak?: boolean;
|
|
31
|
+
}): string | null;
|
|
32
|
+
/**
|
|
33
|
+
* Get available free port.
|
|
34
|
+
* @param port - Current port want to use.
|
|
35
|
+
* @param tryLimits - Maximum number of retries.
|
|
36
|
+
* @param strictPort - Whether to throw an error when the port is occupied.
|
|
37
|
+
* @returns Available port number.
|
|
38
|
+
*/
|
|
39
|
+
export declare const getPort: ({ host, port, strictPort, tryLimits, }: {
|
|
40
|
+
host: string;
|
|
41
|
+
port: string | number;
|
|
42
|
+
strictPort: boolean;
|
|
43
|
+
tryLimits?: number;
|
|
44
|
+
}) => Promise<number>;
|
|
45
|
+
export declare const getServerConfig: ({ config, }: {
|
|
46
|
+
config: NormalizedConfig;
|
|
47
|
+
}) => Promise<{
|
|
48
|
+
port: number;
|
|
49
|
+
host: string;
|
|
50
|
+
https: boolean;
|
|
51
|
+
portTip: string | undefined;
|
|
52
|
+
}>;
|
|
53
|
+
export declare const getHostInUrl: (host: string) => string;
|
|
54
|
+
type AddressUrl = {
|
|
55
|
+
label: string;
|
|
56
|
+
url: string;
|
|
57
|
+
};
|
|
58
|
+
export declare const getAddressUrls: ({ protocol, port, host, }: {
|
|
59
|
+
protocol?: string;
|
|
60
|
+
port: number;
|
|
61
|
+
host?: string;
|
|
62
|
+
}) => AddressUrl[];
|
|
63
|
+
export declare const getCompilationId: (compiler: Rspack.Compiler | Rspack.Compilation) => string;
|
|
64
|
+
export declare function getServerTerminator(server: Server | Http2SecureServer): () => Promise<void>;
|
|
65
|
+
/**
|
|
66
|
+
* Escape HTML characters
|
|
67
|
+
* @example
|
|
68
|
+
* escapeHtml('<div>Hello</div>') // '<div>Hello</div>'
|
|
69
|
+
*/
|
|
70
|
+
export declare function escapeHtml(text: string | null | undefined): string;
|
|
71
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Server } from 'node:http';
|
|
2
|
+
import type { Http2SecureServer } from 'node:http2';
|
|
3
|
+
import type Connect from '../../compiled/connect/index.js';
|
|
4
|
+
import type { ServerConfig } from '../types';
|
|
5
|
+
export declare const createHttpServer: ({ serverConfig, middlewares, }: {
|
|
6
|
+
serverConfig: ServerConfig;
|
|
7
|
+
middlewares: Connect.Server;
|
|
8
|
+
}) => Promise<Http2SecureServer | Server>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type Connect from '../../compiled/connect/index.js';
|
|
2
|
+
import type { EnvironmentAPI, HtmlFallback, RequestHandler as Middleware, Rspack } from '../types';
|
|
3
|
+
export declare const faviconFallbackMiddleware: Middleware;
|
|
4
|
+
export declare const getRequestLoggerMiddleware: () => Promise<Connect.NextHandleFunction>;
|
|
5
|
+
export declare const notFoundMiddleware: Middleware;
|
|
6
|
+
/**
|
|
7
|
+
* Support access HTML without suffix
|
|
8
|
+
*/
|
|
9
|
+
export declare const getHtmlCompletionMiddleware: (params: {
|
|
10
|
+
distPath: string;
|
|
11
|
+
callback: Middleware;
|
|
12
|
+
outputFileSystem: Rspack.OutputFileSystem;
|
|
13
|
+
}) => Middleware;
|
|
14
|
+
/**
|
|
15
|
+
* handle `server.base`
|
|
16
|
+
*/
|
|
17
|
+
export declare const getBaseMiddleware: (params: {
|
|
18
|
+
base: string;
|
|
19
|
+
}) => Middleware;
|
|
20
|
+
/**
|
|
21
|
+
* support HTML fallback in some edge cases
|
|
22
|
+
*/
|
|
23
|
+
export declare const getHtmlFallbackMiddleware: (params: {
|
|
24
|
+
distPath: string;
|
|
25
|
+
callback: Middleware;
|
|
26
|
+
htmlFallback?: HtmlFallback;
|
|
27
|
+
outputFileSystem: Rspack.OutputFileSystem;
|
|
28
|
+
}) => Middleware;
|
|
29
|
+
/**
|
|
30
|
+
* Support viewing served files via `/rsbuild-dev-server` route
|
|
31
|
+
*/
|
|
32
|
+
export declare const viewingServedFilesMiddleware: (params: {
|
|
33
|
+
environments: EnvironmentAPI;
|
|
34
|
+
}) => Middleware;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { NormalizedConfig, Routes } from '../types';
|
|
2
|
+
export declare const replacePortPlaceholder: (url: string, port: number) => string;
|
|
3
|
+
export declare function resolveUrl(str: string, base: string): string;
|
|
4
|
+
export declare function open({ https, port, routes, config, clearCache, }: {
|
|
5
|
+
https?: boolean;
|
|
6
|
+
port: number;
|
|
7
|
+
routes: Routes;
|
|
8
|
+
config: NormalizedConfig;
|
|
9
|
+
clearCache?: boolean;
|
|
10
|
+
}): Promise<void>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Server } from 'node:http';
|
|
2
|
+
import type { Http2SecureServer } from 'node:http2';
|
|
3
|
+
import type Connect from '../../compiled/connect/index.js';
|
|
4
|
+
import type { InternalContext, NormalizedConfig, PreviewOptions, ServerConfig } from '../types';
|
|
5
|
+
import { type StartServerResult } from './helper';
|
|
6
|
+
type RsbuildProdServerOptions = {
|
|
7
|
+
pwd: string;
|
|
8
|
+
output: {
|
|
9
|
+
path: string;
|
|
10
|
+
assetPrefixes: string[];
|
|
11
|
+
};
|
|
12
|
+
serverConfig: ServerConfig;
|
|
13
|
+
};
|
|
14
|
+
export declare class RsbuildProdServer {
|
|
15
|
+
private app;
|
|
16
|
+
private options;
|
|
17
|
+
middlewares: Connect.Server;
|
|
18
|
+
constructor(options: RsbuildProdServerOptions, middlewares: Connect.Server);
|
|
19
|
+
onInit(app: Server | Http2SecureServer): Promise<void>;
|
|
20
|
+
private applyDefaultMiddlewares;
|
|
21
|
+
private applyStaticAssetMiddleware;
|
|
22
|
+
close(): Promise<void>;
|
|
23
|
+
}
|
|
24
|
+
export declare function startProdServer(context: InternalContext, config: NormalizedConfig, { getPortSilently }?: PreviewOptions): Promise<StartServerResult>;
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
type Cleaner = () => Promise<unknown> | unknown;
|
|
2
|
+
/**
|
|
3
|
+
* Add a cleaner to handle side effects
|
|
4
|
+
*/
|
|
5
|
+
export declare const onBeforeRestartServer: (cleaner: Cleaner) => void;
|
|
6
|
+
export declare const restartDevServer: ({ filePath, clear, }?: {
|
|
7
|
+
filePath?: string;
|
|
8
|
+
clear?: boolean;
|
|
9
|
+
}) => Promise<void>;
|
|
10
|
+
export declare const restartBuild: ({ filePath, clear, }?: {
|
|
11
|
+
filePath?: string;
|
|
12
|
+
clear?: boolean;
|
|
13
|
+
}) => Promise<void>;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { CompilerOptions, Runner } from './type';
|
|
2
|
+
import type { BasicGlobalContext, BasicModuleScope, BasicRunnerFile, ModuleObject, RunnerRequirer } from './type';
|
|
3
|
+
export interface IBasicRunnerOptions {
|
|
4
|
+
name: string;
|
|
5
|
+
runInNewContext?: boolean;
|
|
6
|
+
readFileSync: (path: string) => string;
|
|
7
|
+
dist: string;
|
|
8
|
+
compilerOptions: CompilerOptions;
|
|
9
|
+
}
|
|
10
|
+
export declare abstract class BasicRunner implements Runner {
|
|
11
|
+
protected _options: IBasicRunnerOptions;
|
|
12
|
+
protected globalContext: BasicGlobalContext | null;
|
|
13
|
+
protected baseModuleScope: BasicModuleScope | null;
|
|
14
|
+
protected requirers: Map<string, RunnerRequirer>;
|
|
15
|
+
constructor(_options: IBasicRunnerOptions);
|
|
16
|
+
run(file: string): Promise<unknown>;
|
|
17
|
+
getRequire(): RunnerRequirer;
|
|
18
|
+
protected abstract createGlobalContext(): BasicGlobalContext;
|
|
19
|
+
protected abstract createBaseModuleScope(): BasicModuleScope;
|
|
20
|
+
protected abstract createModuleScope(requireFn: RunnerRequirer, m: ModuleObject, file: BasicRunnerFile): BasicModuleScope;
|
|
21
|
+
protected getFile(modulePath: string[] | string, currentDirectory: string): BasicRunnerFile | null;
|
|
22
|
+
protected preExecute(_code: string, _file: BasicRunnerFile): void;
|
|
23
|
+
protected postExecute(_m: Record<string, any>, _file: BasicRunnerFile): void;
|
|
24
|
+
protected createRunner(): void;
|
|
25
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { BasicRunner } from './basic';
|
|
2
|
+
import type { BasicGlobalContext, BasicModuleScope, BasicRunnerFile, ModuleObject, RunnerRequirer } from './type';
|
|
3
|
+
export declare class CommonJsRunner extends BasicRunner {
|
|
4
|
+
protected createGlobalContext(): BasicGlobalContext;
|
|
5
|
+
protected createBaseModuleScope(): BasicModuleScope;
|
|
6
|
+
protected createModuleScope(requireFn: RunnerRequirer, m: ModuleObject, file: BasicRunnerFile): BasicModuleScope;
|
|
7
|
+
protected createRunner(): void;
|
|
8
|
+
protected createMissRequirer(): RunnerRequirer;
|
|
9
|
+
protected createCjsRequirer(): RunnerRequirer;
|
|
10
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { CompilerOptions, Runner, RunnerFactory } from './type';
|
|
2
|
+
export declare class BasicRunnerFactory implements RunnerFactory {
|
|
3
|
+
protected name: string;
|
|
4
|
+
constructor(name: string);
|
|
5
|
+
create(compilerOptions: CompilerOptions, dist: string, readFileSync: (path: string) => string): Runner;
|
|
6
|
+
protected createRunner(compilerOptions: CompilerOptions, dist: string, readFileSync: (path: string) => string): Runner;
|
|
7
|
+
}
|
|
8
|
+
export declare const run: <T>(bundlePath: string, outputPath: string, compilerOptions: CompilerOptions, readFileSync: (path: string) => string) => Promise<T>;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { RspackOptionsNormalized } from '@rspack/core';
|
|
2
|
+
export type RunnerRequirer = (currentDirectory: string, modulePath: string[] | string, context?: {
|
|
3
|
+
file?: BasicRunnerFile;
|
|
4
|
+
esmMode?: EsmMode;
|
|
5
|
+
}) => Record<string, any> | Promise<Record<string, any>>;
|
|
6
|
+
export type BasicRunnerFile = {
|
|
7
|
+
path: string;
|
|
8
|
+
content: string;
|
|
9
|
+
subPath: string;
|
|
10
|
+
};
|
|
11
|
+
export declare enum EsmMode {
|
|
12
|
+
Unknown = 0,
|
|
13
|
+
Evaluated = 1,
|
|
14
|
+
Unlinked = 2
|
|
15
|
+
}
|
|
16
|
+
export interface BasicModuleScope {
|
|
17
|
+
console: Console;
|
|
18
|
+
[key: string]: any;
|
|
19
|
+
}
|
|
20
|
+
export interface BasicGlobalContext {
|
|
21
|
+
console: Console;
|
|
22
|
+
setTimeout: typeof setTimeout;
|
|
23
|
+
clearTimeout: typeof clearTimeout;
|
|
24
|
+
[key: string]: any;
|
|
25
|
+
}
|
|
26
|
+
export type ModuleObject = {
|
|
27
|
+
exports: unknown;
|
|
28
|
+
};
|
|
29
|
+
export type CompilerOptions = RspackOptionsNormalized;
|
|
30
|
+
export interface Runner {
|
|
31
|
+
run(file: string): Promise<unknown>;
|
|
32
|
+
getRequire(): RunnerRequirer;
|
|
33
|
+
}
|
|
34
|
+
export interface RunnerFactory {
|
|
35
|
+
create(compilerOptions: CompilerOptions, dist: string, readFileSync: (fileName: string) => string): Runner;
|
|
36
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { IncomingMessage } from 'node:http';
|
|
2
|
+
import type { Socket } from 'node:net';
|
|
3
|
+
import type { DevConfig, Rspack } from '../types';
|
|
4
|
+
export declare class SocketServer {
|
|
5
|
+
private wsServer;
|
|
6
|
+
private readonly sockets;
|
|
7
|
+
private readonly options;
|
|
8
|
+
private stats;
|
|
9
|
+
private initialChunks;
|
|
10
|
+
private timer;
|
|
11
|
+
constructor(options: DevConfig);
|
|
12
|
+
upgrade(req: IncomingMessage, sock: Socket, head: any): void;
|
|
13
|
+
prepare(): Promise<void>;
|
|
14
|
+
updateStats(stats: Rspack.Stats): void;
|
|
15
|
+
sockWrite({ type, compilationId, data, }: {
|
|
16
|
+
type: string;
|
|
17
|
+
compilationId?: string;
|
|
18
|
+
data?: Record<string, any> | string | boolean;
|
|
19
|
+
}): void;
|
|
20
|
+
private singleWrite;
|
|
21
|
+
close(): void;
|
|
22
|
+
private onConnect;
|
|
23
|
+
private getStats;
|
|
24
|
+
private sendStats;
|
|
25
|
+
private send;
|
|
26
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { FSWatcher } from '../../compiled/chokidar/index.js';
|
|
2
|
+
import type { ChokidarOptions, DevConfig, ServerConfig } from '../types';
|
|
3
|
+
import type { CompileMiddlewareAPI } from './getDevMiddlewares';
|
|
4
|
+
type WatchFilesOptions = {
|
|
5
|
+
dev: DevConfig;
|
|
6
|
+
server: ServerConfig;
|
|
7
|
+
compileMiddlewareAPI?: CompileMiddlewareAPI;
|
|
8
|
+
root: string;
|
|
9
|
+
};
|
|
10
|
+
export declare function setupWatchFiles(options: WatchFilesOptions): Promise<{
|
|
11
|
+
close(): Promise<void>;
|
|
12
|
+
} | undefined>;
|
|
13
|
+
export declare function createChokidar(pathOrGlobs: string[], root: string, options: ChokidarOptions): Promise<FSWatcher>;
|
|
14
|
+
export {};
|