@rsbuild/core 0.7.10 → 1.0.0-alpha.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/compiled/css-loader/index.js +46 -46
- package/compiled/launch-editor-middleware/index.js +58 -22
- package/compiled/launch-editor-middleware/package.json +1 -1
- package/compiled/postcss-load-config/index.js +10 -10
- package/compiled/postcss-loader/index.js +43 -43
- package/compiled/rspack-manifest-plugin/index.js +4 -4
- package/compiled/style-loader/index.js +10 -10
- package/compiled/webpack-dev-middleware/index.js +31 -31
- package/dist/client/hmr.js +1 -3
- package/dist/index.cjs +4208 -1299
- package/dist/index.js +4125 -1239
- package/dist-types/cli/init.d.ts +2 -1
- package/dist-types/client/hmr.d.ts +0 -4
- package/dist-types/config.d.ts +25 -6
- package/dist-types/configChain.d.ts +1 -1
- package/dist-types/constants.d.ts +6 -4
- package/dist-types/createContext.d.ts +6 -3
- package/dist-types/createRsbuild.d.ts +1 -5
- package/dist-types/helpers/path.d.ts +10 -0
- package/dist-types/helpers.d.ts +21 -19
- package/dist-types/index.d.ts +3 -3
- package/dist-types/initHooks.d.ts +2 -1
- package/dist-types/initPlugins.d.ts +3 -3
- package/dist-types/internal.d.ts +2 -3
- package/dist-types/mergeConfig.d.ts +1 -1
- package/dist-types/plugins/css.d.ts +3 -4
- package/dist-types/plugins/entry.d.ts +1 -3
- package/dist-types/plugins/html.d.ts +2 -11
- package/dist-types/plugins/minimize.d.ts +4 -4
- package/dist-types/plugins/rspackProfile.d.ts +0 -3
- package/dist-types/plugins/swc.d.ts +2 -2
- package/dist-types/provider/inspectConfig.d.ts +1 -1
- package/dist-types/provider/rspackConfig.d.ts +4 -3
- package/dist-types/rspack/HtmlBasicPlugin.d.ts +3 -6
- package/dist-types/rspack/InlineChunkHtmlPlugin.d.ts +7 -24
- package/dist-types/rspack/preload/HtmlPreloadOrPrefetchPlugin.d.ts +1 -1
- package/dist-types/rspack/preload/helpers/extractChunks.d.ts +4 -1
- package/dist-types/server/compilerDevMiddleware.d.ts +0 -2
- package/dist-types/server/devMiddleware.d.ts +5 -11
- package/dist-types/server/devServer.d.ts +3 -1
- package/dist-types/server/environment.d.ts +7 -0
- package/dist-types/server/getDevMiddlewares.d.ts +2 -1
- package/dist-types/server/helper.d.ts +4 -13
- package/dist-types/server/httpServer.d.ts +3 -4
- package/dist-types/server/prodServer.d.ts +2 -4
- package/dist-types/server/proxy.d.ts +1 -2
- package/dist-types/server/restart.d.ts +1 -1
- 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 +1 -4
- package/dist-types/types.d.ts +4 -3
- package/package.json +12 -10
- package/types.d.ts +0 -4
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node" />
|
|
3
1
|
import type { Server } from 'node:http';
|
|
4
2
|
import type { Http2SecureServer } from 'node:http2';
|
|
5
|
-
import {
|
|
3
|
+
import type { PreviewServerOptions, ServerConfig } from '@rsbuild/shared';
|
|
6
4
|
import type Connect from '../../compiled/connect';
|
|
7
5
|
import type { InternalContext, NormalizedConfig } from '../types';
|
|
8
6
|
import { type StartServerResult } from './helper';
|
|
@@ -10,7 +8,7 @@ type RsbuildProdServerOptions = {
|
|
|
10
8
|
pwd: string;
|
|
11
9
|
output: {
|
|
12
10
|
path: string;
|
|
13
|
-
|
|
11
|
+
assetPrefixes: string[];
|
|
14
12
|
};
|
|
15
13
|
serverConfig: ServerConfig;
|
|
16
14
|
};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import type { RequestHandler as Middleware,
|
|
1
|
+
import type { RequestHandler as Middleware, ProxyOptions } from '@rsbuild/shared';
|
|
2
2
|
import type { UpgradeEvent } from './helper';
|
|
3
|
-
export declare function formatProxyOptions(proxyOptions: ProxyOptions): ProxyDetail[];
|
|
4
3
|
export declare const createProxyMiddleware: (proxyOptions: ProxyOptions) => {
|
|
5
4
|
middlewares: Middleware[];
|
|
6
5
|
upgrade: UpgradeEvent;
|
|
@@ -3,7 +3,7 @@ type Cleaner = () => Promise<unknown> | unknown;
|
|
|
3
3
|
* Add a cleaner to handle side effects
|
|
4
4
|
*/
|
|
5
5
|
export declare const onBeforeRestartServer: (cleaner: Cleaner) => void;
|
|
6
|
-
export declare const restartDevServer: ({ filePath }: {
|
|
6
|
+
export declare const restartDevServer: ({ filePath, }: {
|
|
7
7
|
filePath: string;
|
|
8
8
|
}) => Promise<void>;
|
|
9
9
|
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
|
+
}
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node" />
|
|
3
1
|
import type { IncomingMessage } from 'node:http';
|
|
4
2
|
import type { Socket } from 'node:net';
|
|
5
3
|
import type { DevConfig, Stats } from '@rsbuild/shared';
|
|
6
|
-
import type Ws from '../../compiled/ws';
|
|
7
4
|
export declare class SocketServer {
|
|
8
5
|
private wsServer;
|
|
9
6
|
private readonly sockets;
|
|
@@ -15,7 +12,7 @@ export declare class SocketServer {
|
|
|
15
12
|
prepare(): Promise<void>;
|
|
16
13
|
updateStats(stats: Stats): void;
|
|
17
14
|
sockWrite(type: string, data?: Record<string, any> | string | boolean): void;
|
|
18
|
-
singleWrite
|
|
15
|
+
private singleWrite;
|
|
19
16
|
close(): void;
|
|
20
17
|
private onConnect;
|
|
21
18
|
private getStats;
|
package/dist-types/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BuildOptions, Bundler, CreateCompiler, CreateDevServerOptions, InspectConfigOptions, InspectConfigResult, NormalizedConfig, PluginManager, PreviewServerOptions, RsbuildConfig, RsbuildContext, RsbuildPlugin, RsbuildPluginAPI, RsbuildPlugins, RspackConfig, StartDevServerOptions, TransformHandler, WebpackConfig } from '@rsbuild/shared';
|
|
1
|
+
import type { BuildOptions, Bundler, CreateCompiler, CreateDevServerOptions, EnvironmentContext, InspectConfigOptions, InspectConfigResult, NormalizedConfig, PluginManager, PreviewServerOptions, RsbuildConfig, RsbuildContext, RsbuildPlugin, RsbuildPluginAPI, RsbuildPlugins, RspackConfig, StartDevServerOptions, TransformHandler, WebpackConfig } from '@rsbuild/shared';
|
|
2
2
|
import type { Hooks } from './initHooks';
|
|
3
3
|
import type { RsbuildDevServer } from './server/devServer';
|
|
4
4
|
import type { StartServerResult } from './server/helper';
|
|
@@ -29,6 +29,8 @@ export type InternalContext = RsbuildContext & {
|
|
|
29
29
|
normalizedConfig?: NormalizedConfig;
|
|
30
30
|
/** The plugin API. */
|
|
31
31
|
pluginAPI?: RsbuildPluginAPI;
|
|
32
|
+
/** The environment context. */
|
|
33
|
+
environments: Record<string, EnvironmentContext>;
|
|
32
34
|
};
|
|
33
35
|
export type CreateRsbuildOptions = {
|
|
34
36
|
/** The root path of current project. */
|
|
@@ -67,7 +69,6 @@ export type RsbuildInstance = {
|
|
|
67
69
|
createCompiler: ProviderInstance['createCompiler'];
|
|
68
70
|
createDevServer: ProviderInstance['createDevServer'];
|
|
69
71
|
startDevServer: ProviderInstance['startDevServer'];
|
|
70
|
-
getHTMLPaths: RsbuildPluginAPI['getHTMLPaths'];
|
|
71
72
|
getRsbuildConfig: RsbuildPluginAPI['getRsbuildConfig'];
|
|
72
73
|
getNormalizedConfig: RsbuildPluginAPI['getNormalizedConfig'];
|
|
73
74
|
onBeforeBuild: RsbuildPluginAPI['onBeforeBuild'];
|
|
@@ -82,4 +83,4 @@ export type RsbuildInstance = {
|
|
|
82
83
|
onDevCompileDone: RsbuildPluginAPI['onDevCompileDone'];
|
|
83
84
|
onExit: RsbuildPluginAPI['onExit'];
|
|
84
85
|
};
|
|
85
|
-
export type { RsbuildConfig, NormalizedConfig, DevConfig, HtmlConfig, ToolsConfig, SourceConfig, ServerConfig, OutputConfig, SecurityConfig, PerformanceConfig, ModuleFederationConfig, NormalizedDevConfig, NormalizedHtmlConfig, NormalizedToolsConfig, NormalizedSourceConfig, NormalizedServerConfig, NormalizedOutputConfig, NormalizedSecurityConfig, NormalizedPerformanceConfig, NormalizedModuleFederationConfig, } from '@rsbuild/shared';
|
|
86
|
+
export type { RsbuildConfig, NormalizedConfig, DevConfig, HtmlConfig, ToolsConfig, SourceConfig, ServerConfig, OutputConfig, SecurityConfig, PerformanceConfig, ModuleFederationConfig, NormalizedDevConfig, NormalizedHtmlConfig, NormalizedToolsConfig, NormalizedSourceConfig, NormalizedServerConfig, NormalizedOutputConfig, NormalizedSecurityConfig, NormalizedPerformanceConfig, NormalizedModuleFederationConfig, NormalizedEnvironmentConfig, } from '@rsbuild/shared';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsbuild/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0-alpha.1",
|
|
4
4
|
"description": "The Rspack-based build tool.",
|
|
5
5
|
"homepage": "https://rsbuild.dev",
|
|
6
6
|
"bugs": {
|
|
@@ -46,12 +46,12 @@
|
|
|
46
46
|
"types.d.ts"
|
|
47
47
|
],
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@rspack/core": "0.
|
|
50
|
-
"@swc/helpers": "0.5.
|
|
51
|
-
"core-js": "~3.
|
|
49
|
+
"@rspack/core": "1.0.0-alpha.1",
|
|
50
|
+
"@swc/helpers": "0.5.11",
|
|
51
|
+
"core-js": "~3.37.1",
|
|
52
52
|
"html-webpack-plugin": "npm:html-rspack-plugin@5.7.2",
|
|
53
|
-
"postcss": "^8.4.
|
|
54
|
-
"@rsbuild/shared": "0.
|
|
53
|
+
"postcss": "^8.4.39",
|
|
54
|
+
"@rsbuild/shared": "1.0.0-alpha.1"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@types/connect": "3.4.38",
|
|
@@ -59,6 +59,7 @@
|
|
|
59
59
|
"@types/node": "18.x",
|
|
60
60
|
"@types/on-finished": "2.3.4",
|
|
61
61
|
"@types/ws": "^8.5.10",
|
|
62
|
+
"browserslist-to-es-version": "^1.0.0",
|
|
62
63
|
"commander": "^12.1.0",
|
|
63
64
|
"connect": "3.7.0",
|
|
64
65
|
"connect-history-api-fallback": "^2.0.0",
|
|
@@ -68,26 +69,27 @@
|
|
|
68
69
|
"fs-extra": "^11.2.0",
|
|
69
70
|
"http-compression": "1.0.20",
|
|
70
71
|
"jiti": "^1.21.6",
|
|
71
|
-
"launch-editor-middleware": "^2.
|
|
72
|
+
"launch-editor-middleware": "^2.8.0",
|
|
72
73
|
"on-finished": "2.4.1",
|
|
73
74
|
"open": "^8.4.0",
|
|
74
75
|
"postcss-load-config": "6.0.1",
|
|
75
76
|
"postcss-loader": "8.1.1",
|
|
76
77
|
"postcss-value-parser": "4.2.0",
|
|
77
78
|
"prebundle": "1.1.0",
|
|
79
|
+
"reduce-configs": "^1.0.0",
|
|
78
80
|
"rslog": "^1.2.2",
|
|
79
81
|
"rspack-manifest-plugin": "5.0.0",
|
|
80
82
|
"semver": "^7.6.2",
|
|
81
83
|
"sirv": "^2.0.4",
|
|
82
84
|
"style-loader": "3.3.4",
|
|
83
85
|
"tsc-alias": "^1.8.10",
|
|
84
|
-
"typescript": "^5.
|
|
85
|
-
"webpack": "^5.92.
|
|
86
|
+
"typescript": "^5.5.2",
|
|
87
|
+
"webpack": "^5.92.1",
|
|
86
88
|
"webpack-dev-middleware": "7.2.1",
|
|
87
89
|
"ws": "^8.17.1"
|
|
88
90
|
},
|
|
89
91
|
"engines": {
|
|
90
|
-
"node": ">=16.
|
|
92
|
+
"node": ">=16.7.0"
|
|
91
93
|
},
|
|
92
94
|
"publishConfig": {
|
|
93
95
|
"access": "public",
|
package/types.d.ts
CHANGED