@rsbuild/core 2.0.13 → 2.0.14
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/756.js +45 -23
- package/dist-types/server/compileState.d.ts +5 -0
- package/package.json +1 -1
package/dist/756.js
CHANGED
|
@@ -3483,7 +3483,7 @@ function createPublicContext(context) {
|
|
|
3483
3483
|
async function createContext(options, userConfig, logger) {
|
|
3484
3484
|
let { cwd } = options, rootPath = userConfig.root ? ensureAbsolutePath(cwd, userConfig.root) : cwd, rsbuildConfig = await withDefaultConfig(rootPath, userConfig), cachePath = join(rootPath, 'node_modules', '.cache'), specifiedEnvironments = options.environment && options.environment.length > 0 ? options.environment : void 0;
|
|
3485
3485
|
return {
|
|
3486
|
-
version: "2.0.
|
|
3486
|
+
version: "2.0.14",
|
|
3487
3487
|
rootPath,
|
|
3488
3488
|
distPath: '',
|
|
3489
3489
|
cachePath,
|
|
@@ -7343,7 +7343,12 @@ async function setupCliShortcuts({ help = !0, openPage, closeServer, printUrls,
|
|
|
7343
7343
|
rl.close();
|
|
7344
7344
|
};
|
|
7345
7345
|
}
|
|
7346
|
-
let
|
|
7346
|
+
let createDeferred = ()=>{
|
|
7347
|
+
let deferred = {};
|
|
7348
|
+
return deferred.promise = new Promise((resolve)=>{
|
|
7349
|
+
deferred.resolve = resolve;
|
|
7350
|
+
}), deferred;
|
|
7351
|
+
}, ENCODING_REGEX = /\bgzip\b/, CONTENT_TYPE_REGEX = /text|javascript|\/json|xml/i;
|
|
7347
7352
|
function gzipMiddleware_gzipMiddleware({ filter, level = node_zlib.constants.Z_BEST_SPEED } = {}) {
|
|
7348
7353
|
return function gzipMiddleware(req, res, next) {
|
|
7349
7354
|
let gzip, writeHeadStatus, writeHeadMessage;
|
|
@@ -8065,7 +8070,8 @@ async function startWatchFiles({ paths, options, type = 'reload-page' }, buildMa
|
|
|
8065
8070
|
}), watcher;
|
|
8066
8071
|
}
|
|
8067
8072
|
async function devServer_createDevServer(options, createCompiler, config, { getPortSilently, runCompile = !0 } = {}) {
|
|
8068
|
-
|
|
8073
|
+
var environmentCount;
|
|
8074
|
+
let stats, waiters, { context } = options, { logger } = context;
|
|
8069
8075
|
logger.debug('create dev server');
|
|
8070
8076
|
let { port, portTip } = await resolvePort(config), { middlewareMode, host } = config.server, isHttps = !!config.server.https, routes = getRoutes(context), fallbackPathname = 0 === routes.length && context.environmentList.some((item)=>'web' === item.config.output.target) ? config.server.base : void 0;
|
|
8071
8077
|
context.devServer = {
|
|
@@ -8073,24 +8079,40 @@ async function devServer_createDevServer(options, createCompiler, config, { getP
|
|
|
8073
8079
|
port,
|
|
8074
8080
|
https: isHttps
|
|
8075
8081
|
};
|
|
8076
|
-
let
|
|
8077
|
-
|
|
8078
|
-
})
|
|
8079
|
-
|
|
8080
|
-
|
|
8081
|
-
|
|
8082
|
-
|
|
8083
|
-
|
|
8084
|
-
|
|
8082
|
+
let compileState = (stats = Array(environmentCount = context.environmentList.length), waiters = Array.from({
|
|
8083
|
+
length: environmentCount
|
|
8084
|
+
}, createDeferred), {
|
|
8085
|
+
reset (index) {
|
|
8086
|
+
stats[index] && (stats[index] = void 0, waiters[index] = createDeferred());
|
|
8087
|
+
},
|
|
8088
|
+
done (index, nextStats) {
|
|
8089
|
+
stats[index] = nextStats, waiters[index].resolve(nextStats);
|
|
8090
|
+
},
|
|
8091
|
+
async wait (index) {
|
|
8092
|
+
let currentStats = stats[index];
|
|
8093
|
+
return currentStats || waiters[index].promise;
|
|
8094
|
+
}
|
|
8095
|
+
}), startCompile = async ()=>{
|
|
8085
8096
|
let compiler = await createCompiler();
|
|
8086
8097
|
if (!compiler) throw Error(`${color.dim('[rsbuild:server]')} Failed to get compiler instance.`);
|
|
8087
8098
|
context.publicPathnames = getPublicPathnames(compiler_isMultiCompiler(compiler) ? compiler.compilers.map(getPublicPathFromCompiler) : [
|
|
8088
8099
|
getPublicPathFromCompiler(compiler)
|
|
8089
|
-
], config.server.base)
|
|
8090
|
-
|
|
8091
|
-
|
|
8092
|
-
|
|
8093
|
-
}
|
|
8100
|
+
], config.server.base);
|
|
8101
|
+
let hookOptions = {
|
|
8102
|
+
name: 'rsbuild:environment-api',
|
|
8103
|
+
stage: -10000
|
|
8104
|
+
};
|
|
8105
|
+
compiler_isMultiCompiler(compiler) ? compiler.compilers.forEach((compiler, index)=>{
|
|
8106
|
+
compiler.hooks.watchRun.tap(hookOptions, ()=>{
|
|
8107
|
+
compileState.reset(index);
|
|
8108
|
+
}), compiler.hooks.done.tap(hookOptions, (stats)=>{
|
|
8109
|
+
compileState.done(index, stats);
|
|
8110
|
+
});
|
|
8111
|
+
}) : (compiler.hooks.watchRun.tap(hookOptions, ()=>{
|
|
8112
|
+
compileState.reset(0);
|
|
8113
|
+
}), compiler.hooks.done.tap(hookOptions, (stats)=>{
|
|
8114
|
+
compileState.done(0, stats);
|
|
8115
|
+
}));
|
|
8094
8116
|
let buildManager = new BuildManager({
|
|
8095
8117
|
context,
|
|
8096
8118
|
config,
|
|
@@ -8160,18 +8182,18 @@ async function devServer_createDevServer(options, createCompiler, config, { getP
|
|
|
8160
8182
|
},
|
|
8161
8183
|
getStats: async ()=>{
|
|
8162
8184
|
if (!state.buildManager) throw Error(getErrorMsg('getStats'));
|
|
8163
|
-
return
|
|
8185
|
+
return compileState.wait(index);
|
|
8164
8186
|
},
|
|
8165
8187
|
loadBundle: async (entryName)=>{
|
|
8166
8188
|
if (!state.buildManager) throw Error(getErrorMsg('loadBundle'));
|
|
8167
|
-
return await
|
|
8189
|
+
return cacheableLoadBundle(await compileState.wait(index), entryName, {
|
|
8168
8190
|
readFileSync: state.buildManager.readFileSync,
|
|
8169
8191
|
environment
|
|
8170
8192
|
});
|
|
8171
8193
|
},
|
|
8172
8194
|
getTransformedHtml: async (entryName)=>{
|
|
8173
8195
|
if (!state.buildManager) throw Error(getErrorMsg('getTransformedHtml'));
|
|
8174
|
-
return await
|
|
8196
|
+
return cacheableTransformedHtml(await compileState.wait(index), entryName, {
|
|
8175
8197
|
readFileSync: state.buildManager.readFileSync,
|
|
8176
8198
|
environment
|
|
8177
8199
|
});
|
|
@@ -9970,7 +9992,7 @@ let applyServerOptions = (command)=>{
|
|
|
9970
9992
|
};
|
|
9971
9993
|
function setupCommands() {
|
|
9972
9994
|
let cli = ((name = "")=>new CAC(name))('rsbuild');
|
|
9973
|
-
cli.version("2.0.
|
|
9995
|
+
cli.version("2.0.14"), cli.option('--base <base>', 'Set the base path of the server').option('-c, --config <config>', 'Set the configuration file (relative or absolute path)').option('--config-loader <loader>', 'Set the config file loader (auto | jiti | native)', {
|
|
9974
9996
|
default: 'auto'
|
|
9975
9997
|
}).option('--env-dir <dir>', 'Set the directory for loading `.env` files').option('--env-mode <mode>', 'Set the env mode to load the `.env.[mode]` file').option('--environment <name>', 'Set the environment name(s) to build', {
|
|
9976
9998
|
type: [
|
|
@@ -10041,7 +10063,7 @@ function initNodeEnv(command) {
|
|
|
10041
10063
|
}
|
|
10042
10064
|
function showGreeting() {
|
|
10043
10065
|
let { npm_execpath, npm_lifecycle_event, NODE_RUN_SCRIPT_NAME } = process.env, isBun = npm_execpath?.includes('.bun');
|
|
10044
|
-
src_logger.greet(`${'npx' === npm_lifecycle_event || isBun || NODE_RUN_SCRIPT_NAME ? '\n' : ''}Rsbuild v2.0.
|
|
10066
|
+
src_logger.greet(`${'npx' === npm_lifecycle_event || isBun || NODE_RUN_SCRIPT_NAME ? '\n' : ''}Rsbuild v2.0.14\n`);
|
|
10045
10067
|
}
|
|
10046
10068
|
function setupLogLevel() {
|
|
10047
10069
|
if (cli_argv.length <= 3) return;
|
|
@@ -10063,5 +10085,5 @@ function runCLI() {
|
|
|
10063
10085
|
src_logger.error('Failed to start Rsbuild CLI.'), src_logger.error(err), process.exit(1);
|
|
10064
10086
|
}
|
|
10065
10087
|
}
|
|
10066
|
-
let src_version = "2.0.
|
|
10088
|
+
let src_version = "2.0.14";
|
|
10067
10089
|
export { PLUGIN_CSS_NAME, PLUGIN_SWC_NAME, core_rspack as rspack, createRsbuild, defaultAllowedOrigins, defineConfig, ensureAssetPrefix, loadConfig_loadConfig as loadConfig, loadEnv, logger_createLogger as createLogger, mergeRsbuildConfig, mrmime_lookup, runCLI, src_logger as logger, src_version as version };
|