@rsbuild/core 0.3.11 → 0.4.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/dist/cli/commands.js +2 -2
- package/dist/cli/config.d.ts +1 -6
- package/dist/cli/config.js +20 -34
- package/dist/cli/prepare.js +1 -1
- package/dist/constants.d.ts +0 -1
- package/dist/constants.js +0 -3
- package/dist/createRsbuild.js +6 -4
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -3
- package/dist/pluginManager.d.ts +7 -0
- package/dist/pluginManager.js +176 -0
- package/dist/plugins/index.js +2 -1
- package/dist/plugins/moduleFederation.d.ts +2 -0
- package/dist/plugins/moduleFederation.js +123 -0
- package/dist/provider/config.d.ts +1 -1
- package/dist/provider/config.js +108 -8
- package/dist/provider/{core/createCompiler.d.ts → createCompiler.d.ts} +1 -1
- package/dist/provider/{core/createCompiler.js → createCompiler.js} +1 -1
- package/dist/provider/{core/createContext.d.ts → createContext.d.ts} +1 -1
- package/dist/provider/{core/createContext.js → createContext.js} +2 -2
- package/dist/provider/index.d.ts +6 -6
- package/dist/provider/index.js +11 -9
- package/dist/provider/initConfigs.d.ts +11 -0
- package/dist/provider/{core/initConfigs.js → initConfigs.js} +8 -7
- package/dist/provider/{core/initHooks.d.ts → initHooks.d.ts} +2 -1
- package/dist/provider/{core/initHooks.js → initHooks.js} +1 -0
- package/dist/provider/initPlugins.d.ts +7 -0
- package/dist/provider/{core/initPlugins.js → initPlugins.js} +3 -2
- package/dist/provider/{core/inspectConfig.d.ts → inspectConfig.d.ts} +1 -1
- package/dist/provider/{core/inspectConfig.js → inspectConfig.js} +3 -3
- package/dist/provider/plugins/less.js +2 -1
- package/dist/provider/plugins/swc.js +1 -1
- package/dist/provider/provider.js +20 -20
- package/dist/provider/{core/rspackConfig.d.ts → rspackConfig.d.ts} +1 -1
- package/dist/provider/{core/rspackConfig.js → rspackConfig.js} +2 -2
- package/dist/provider/shared.d.ts +1 -1
- package/dist/provider/shared.js +79 -14
- package/dist/server/devServer.js +1 -0
- package/dist/server/helper.d.ts +14 -0
- package/dist/server/helper.js +64 -1
- package/dist/types.d.ts +1 -1
- package/package.json +2 -2
- package/dist/provider/core/initConfigs.d.ts +0 -11
- package/dist/provider/core/initPlugins.d.ts +0 -7
- /package/dist/provider/{core/build.d.ts → build.d.ts} +0 -0
- /package/dist/provider/{core/build.js → build.js} +0 -0
- /package/dist/provider/{core/devMiddleware.d.ts → devMiddleware.d.ts} +0 -0
- /package/dist/provider/{core/devMiddleware.js → devMiddleware.js} +0 -0
package/dist/server/devServer.js
CHANGED
|
@@ -167,6 +167,7 @@ async function startDevServer(options, createDevMiddleware, {
|
|
|
167
167
|
(0, import_shared.debug)("listen dev server done");
|
|
168
168
|
await serverAPIs.afterStart();
|
|
169
169
|
const closeServer = async () => {
|
|
170
|
+
await options.context.hooks.onCloseDevServer.call();
|
|
170
171
|
await devMiddlewares.close();
|
|
171
172
|
httpServer.close();
|
|
172
173
|
};
|
package/dist/server/helper.d.ts
CHANGED
|
@@ -19,6 +19,20 @@ export declare const mergeDevOptions: ({ rsbuildConfig, port, }: {
|
|
|
19
19
|
rsbuildConfig: RsbuildConfig;
|
|
20
20
|
port: number;
|
|
21
21
|
}) => DevConfig;
|
|
22
|
+
/**
|
|
23
|
+
* Get available free port.
|
|
24
|
+
* @param port - Current port want to use.
|
|
25
|
+
* @param tryLimits - Maximum number of retries.
|
|
26
|
+
* @param strictPort - Whether to throw an error when the port is occupied.
|
|
27
|
+
* @returns Available port number.
|
|
28
|
+
*/
|
|
29
|
+
export declare const getPort: ({ host, port, strictPort, tryLimits, silent, }: {
|
|
30
|
+
host: string;
|
|
31
|
+
port: string | number;
|
|
32
|
+
strictPort: boolean;
|
|
33
|
+
tryLimits?: number | undefined;
|
|
34
|
+
silent?: boolean | undefined;
|
|
35
|
+
}) => Promise<number>;
|
|
22
36
|
export declare const getServerOptions: ({ rsbuildConfig, getPortSilently, }: {
|
|
23
37
|
rsbuildConfig: RsbuildConfig;
|
|
24
38
|
getPortSilently?: boolean | undefined;
|
package/dist/server/helper.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __export = (target, all) => {
|
|
7
9
|
for (var name in all)
|
|
@@ -15,17 +17,27 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
17
|
}
|
|
16
18
|
return to;
|
|
17
19
|
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
18
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
29
|
var helper_exports = {};
|
|
20
30
|
__export(helper_exports, {
|
|
21
31
|
HMR_SOCK_PATH: () => HMR_SOCK_PATH,
|
|
22
32
|
formatRoutes: () => formatRoutes,
|
|
23
33
|
getDevOptions: () => getDevOptions,
|
|
34
|
+
getPort: () => getPort,
|
|
24
35
|
getServerOptions: () => getServerOptions,
|
|
25
36
|
mergeDevOptions: () => mergeDevOptions,
|
|
26
37
|
printServerURLs: () => printServerURLs
|
|
27
38
|
});
|
|
28
39
|
module.exports = __toCommonJS(helper_exports);
|
|
40
|
+
var import_node_net = __toESM(require("node:net"));
|
|
29
41
|
var import_shared = require("@rsbuild/shared");
|
|
30
42
|
const formatPrefix = (prefix) => {
|
|
31
43
|
if (!prefix) {
|
|
@@ -129,12 +141,62 @@ const mergeDevOptions = ({
|
|
|
129
141
|
const devConfig = rsbuildConfig.dev ? (0, import_shared.deepmerge)(defaultDevConfig, rsbuildConfig.dev) : defaultDevConfig;
|
|
130
142
|
return devConfig;
|
|
131
143
|
};
|
|
144
|
+
const getPort = async ({
|
|
145
|
+
host,
|
|
146
|
+
port,
|
|
147
|
+
strictPort,
|
|
148
|
+
tryLimits = 20,
|
|
149
|
+
silent = false
|
|
150
|
+
}) => {
|
|
151
|
+
if (typeof port === "string") {
|
|
152
|
+
port = parseInt(port, 10);
|
|
153
|
+
}
|
|
154
|
+
if (strictPort) {
|
|
155
|
+
tryLimits = 1;
|
|
156
|
+
}
|
|
157
|
+
const original = port;
|
|
158
|
+
let found = false;
|
|
159
|
+
let attempts = 0;
|
|
160
|
+
while (!found && attempts <= tryLimits) {
|
|
161
|
+
try {
|
|
162
|
+
await new Promise((resolve, reject) => {
|
|
163
|
+
const server = import_node_net.default.createServer();
|
|
164
|
+
server.unref();
|
|
165
|
+
server.on("error", reject);
|
|
166
|
+
server.listen({ port, host }, () => {
|
|
167
|
+
found = true;
|
|
168
|
+
server.close(resolve);
|
|
169
|
+
});
|
|
170
|
+
});
|
|
171
|
+
} catch (e) {
|
|
172
|
+
if (e.code !== "EADDRINUSE") {
|
|
173
|
+
throw e;
|
|
174
|
+
}
|
|
175
|
+
port++;
|
|
176
|
+
attempts++;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
if (port !== original) {
|
|
180
|
+
if (strictPort) {
|
|
181
|
+
throw new Error(
|
|
182
|
+
`Port "${original}" is occupied, please choose another one.`
|
|
183
|
+
);
|
|
184
|
+
}
|
|
185
|
+
if (!silent) {
|
|
186
|
+
import_shared.logger.info(
|
|
187
|
+
`Port ${original} is in use, ${import_shared.color.yellow(`using port ${port}.`)}
|
|
188
|
+
`
|
|
189
|
+
);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
return port;
|
|
193
|
+
};
|
|
132
194
|
const getServerOptions = async ({
|
|
133
195
|
rsbuildConfig,
|
|
134
196
|
getPortSilently
|
|
135
197
|
}) => {
|
|
136
198
|
const host = rsbuildConfig.server?.host || import_shared.DEFAULT_DEV_HOST;
|
|
137
|
-
const port = await
|
|
199
|
+
const port = await getPort({
|
|
138
200
|
host,
|
|
139
201
|
port: rsbuildConfig.server?.port || import_shared.DEFAULT_PORT,
|
|
140
202
|
strictPort: rsbuildConfig.server?.strictPort || false,
|
|
@@ -167,6 +229,7 @@ const getDevOptions = async ({
|
|
|
167
229
|
HMR_SOCK_PATH,
|
|
168
230
|
formatRoutes,
|
|
169
231
|
getDevOptions,
|
|
232
|
+
getPort,
|
|
170
233
|
getServerOptions,
|
|
171
234
|
mergeDevOptions,
|
|
172
235
|
printServerURLs
|
package/dist/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { RsbuildConfig, RsbuildPlugin, RsbuildPlugins, RsbuildContext, NormalizedConfig, RsbuildPluginAPI } from '@rsbuild/shared';
|
|
2
|
-
import type { Hooks } from './provider/
|
|
2
|
+
import type { Hooks } from './provider/initHooks';
|
|
3
3
|
export type { RsbuildPlugin, RsbuildPlugins, RsbuildPluginAPI };
|
|
4
4
|
/** The inner context. */
|
|
5
5
|
export type InternalContext = RsbuildContext & {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsbuild/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "The Rspack-based build tool.",
|
|
5
5
|
"homepage": "https://rsbuild.dev",
|
|
6
6
|
"bugs": {
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"core-js": "~3.32.2",
|
|
58
58
|
"html-webpack-plugin": "npm:html-rspack-plugin@5.5.7",
|
|
59
59
|
"postcss": "^8.4.33",
|
|
60
|
-
"@rsbuild/shared": "0.
|
|
60
|
+
"@rsbuild/shared": "0.4.0"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
63
|
"@types/node": "16.x",
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { type PluginStore, type RspackConfig, type CreateRsbuildOptions } from '@rsbuild/shared';
|
|
2
|
-
import type { InternalContext, NormalizedConfig } from '../../types';
|
|
3
|
-
export type InitConfigsOptions = {
|
|
4
|
-
context: InternalContext;
|
|
5
|
-
pluginStore: PluginStore;
|
|
6
|
-
rsbuildOptions: Required<CreateRsbuildOptions>;
|
|
7
|
-
};
|
|
8
|
-
export declare function initRsbuildConfig({ context, pluginStore, }: Pick<InitConfigsOptions, 'context' | 'pluginStore'>): Promise<NormalizedConfig>;
|
|
9
|
-
export declare function initConfigs({ context, pluginStore, rsbuildOptions, }: InitConfigsOptions): Promise<{
|
|
10
|
-
rspackConfigs: RspackConfig[];
|
|
11
|
-
}>;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { type PluginStore, type RsbuildPluginAPI } from '@rsbuild/shared';
|
|
2
|
-
import type { InternalContext, NormalizedConfig } from '../../types';
|
|
3
|
-
export declare function getHTMLPathByEntry(entryName: string, config: NormalizedConfig): string;
|
|
4
|
-
export declare function getPluginAPI({ context, pluginStore, }: {
|
|
5
|
-
context: InternalContext;
|
|
6
|
-
pluginStore: PluginStore;
|
|
7
|
-
}): RsbuildPluginAPI;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|