@rsbuild/core 2.1.7 → 2.1.8
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/cors/index.d.ts +1 -1
- package/compiled/html-rspack-plugin/index.d.ts +1 -1
- package/dist/{711.js → 626.js} +92 -69
- package/dist/build.d.ts +4 -0
- package/dist/chokidar.js +1 -1046
- package/{dist-types → dist}/cli/commands.d.ts +2 -2
- package/{dist-types → dist}/cli/init.d.ts +2 -2
- package/dist/client/hmr.js +1 -1
- package/dist/client/overlay.js +1 -1
- package/{dist-types → dist}/configChain.d.ts +2 -2
- package/dist/connect-next.js +1 -876
- package/dist/cors.js +1 -1
- package/{dist-types → dist}/createCompiler.d.ts +2 -2
- package/{dist-types → dist}/createContext.d.ts +3 -3
- package/{dist-types → dist}/createRsbuild.d.ts +1 -1
- package/{dist-types → dist}/defaultConfig.d.ts +1 -1
- package/{dist-types → dist}/helpers/compiler.d.ts +1 -1
- package/{dist-types → dist}/helpers/css.d.ts +1 -1
- package/{dist-types → dist}/helpers/format.d.ts +1 -1
- package/{dist-types → dist}/helpers/fs.d.ts +2 -2
- package/{dist-types → dist}/helpers/index.d.ts +4 -4
- package/{dist-types → dist}/helpers/overlayConfig.d.ts +1 -1
- package/{dist-types → dist}/helpers/path.d.ts +1 -1
- package/{dist-types → dist}/helpers/restartManager.d.ts +2 -2
- package/{dist-types → dist}/helpers/stats.d.ts +2 -2
- package/{dist-types → dist}/helpers/url.d.ts +2 -2
- package/{dist-types → dist}/helpers/vendors.d.ts +1 -1
- package/{dist-types → dist}/hooks.d.ts +1 -1
- package/dist/http-proxy-middleware.js +5 -3010
- package/{dist-types → dist}/index.d.ts +14 -14
- package/dist/index.js +1 -1
- package/{dist-types → dist}/initConfigs.d.ts +1 -1
- package/{dist-types → dist}/initPlugins.d.ts +2 -2
- package/{dist-types → dist}/inspectConfig.d.ts +2 -2
- package/dist/launch-editor-middleware.js +1 -544
- package/{dist-types → dist}/loadConfig.d.ts +6 -6
- package/{dist-types → dist}/loader/cssUrlLoader.d.ts +1 -1
- package/{dist-types → dist}/loader/ignoreCssLoader.d.ts +1 -1
- package/{dist-types → dist}/loader/transformLoader.d.ts +1 -1
- package/{dist-types → dist}/loader/transformRawLoader.d.ts +1 -1
- package/{dist-types → dist}/logger.d.ts +1 -1
- package/dist/manifest-plugin.js +1 -692
- package/dist/memfs.js +1 -5695
- package/{dist-types → dist}/mergeConfig.d.ts +1 -1
- package/dist/open.js +2 -439
- package/{dist-types → dist}/pluginHelper.d.ts +1 -1
- package/{dist-types → dist}/pluginManager.d.ts +2 -2
- package/{dist-types → dist}/plugins/appIcon.d.ts +1 -1
- package/{dist-types → dist}/plugins/asset.d.ts +1 -1
- package/{dist-types → dist}/plugins/basic.d.ts +1 -1
- package/dist/plugins/cache.d.ts +2 -0
- package/{dist-types → dist}/plugins/cleanOutput.d.ts +1 -1
- package/{dist-types → dist}/plugins/css.d.ts +1 -1
- package/{dist-types → dist}/plugins/define.d.ts +1 -1
- package/dist/plugins/entry.d.ts +2 -0
- package/{dist-types → dist}/plugins/externals.d.ts +2 -2
- package/{dist-types → dist}/plugins/fileSize.d.ts +1 -1
- package/{dist-types → dist}/plugins/html.d.ts +1 -1
- package/{dist-types → dist}/plugins/inlineChunk.d.ts +1 -1
- package/{dist-types → dist}/plugins/lazyCompilation.d.ts +1 -1
- package/{dist-types → dist}/plugins/manifest.d.ts +1 -1
- package/{dist-types → dist}/plugins/minimize.d.ts +2 -2
- package/{dist-types → dist}/plugins/moduleFederation.d.ts +1 -1
- package/{dist-types → dist}/plugins/nodeAddons.d.ts +1 -1
- package/dist/plugins/nonce.d.ts +2 -0
- package/{dist-types → dist}/plugins/output.d.ts +1 -1
- package/{dist-types → dist}/plugins/progress.d.ts +1 -1
- package/{dist-types → dist}/plugins/resolve.d.ts +1 -1
- package/{dist-types → dist}/plugins/resourceHints.d.ts +1 -1
- package/{dist-types → dist}/plugins/rsdoctor.d.ts +1 -1
- package/{dist-types → dist}/plugins/rspackProfile.d.ts +1 -1
- package/{dist-types → dist}/plugins/server.d.ts +1 -1
- package/{dist-types → dist}/plugins/sourceMap.d.ts +1 -1
- package/{dist-types → dist}/plugins/splitChunks.d.ts +1 -1
- package/dist/plugins/sri.d.ts +2 -0
- package/{dist-types → dist}/plugins/swc.d.ts +1 -1
- package/{dist-types → dist}/plugins/target.d.ts +1 -1
- package/dist/plugins/wasm.d.ts +2 -0
- package/{dist-types → dist}/plugins/worker.d.ts +1 -1
- package/dist/range-parser.js +1 -1
- package/dist/restart.d.ts +15 -0
- package/{dist-types → dist}/rspack-plugins/RsbuildHtmlPlugin.d.ts +1 -1
- package/{dist-types → dist}/rspack-plugins/resource-hints/HtmlResourceHintsPlugin.d.ts +1 -1
- package/{dist-types → dist}/rspack-plugins/resource-hints/doesChunkBelongToHtml.d.ts +1 -1
- package/{dist-types → dist}/rspack-plugins/resource-hints/extractChunks.d.ts +1 -1
- package/{dist-types → dist}/rspackConfig.d.ts +1 -1
- package/{dist-types → dist}/server/assets-middleware/getFileFromUrl.d.ts +1 -1
- package/{dist-types → dist}/server/assets-middleware/index.d.ts +2 -2
- package/{dist-types → dist}/server/assets-middleware/middleware.d.ts +1 -1
- package/{dist-types → dist}/server/assets-middleware/setupOutputFileSystem.d.ts +1 -1
- package/{dist-types → dist}/server/assets-middleware/setupWriteToDisk.d.ts +2 -2
- package/{dist-types → dist}/server/browserLogs.d.ts +1 -1
- package/{dist-types → dist}/server/buildManager.d.ts +3 -3
- package/{dist-types → dist}/server/cliShortcuts.d.ts +2 -2
- package/{dist-types → dist}/server/devMiddlewares.d.ts +4 -4
- package/{dist-types → dist}/server/devServer.d.ts +4 -4
- package/{dist-types → dist}/server/environment.d.ts +1 -1
- package/{dist-types → dist}/server/gzipMiddleware.d.ts +1 -1
- package/{dist-types → dist}/server/helper.d.ts +4 -4
- package/{dist-types → dist}/server/historyApiFallback.d.ts +2 -2
- package/{dist-types → dist}/server/httpServer.d.ts +1 -1
- package/{dist-types → dist}/server/middlewares.d.ts +2 -2
- package/{dist-types → dist}/server/open.d.ts +2 -2
- package/{dist-types → dist}/server/previewServer.d.ts +2 -2
- package/{dist-types → dist}/server/proxy.d.ts +3 -3
- package/{dist-types → dist}/server/runner/basic.d.ts +1 -1
- package/{dist-types → dist}/server/runner/cjs.d.ts +2 -2
- package/{dist-types → dist}/server/runner/esm.d.ts +2 -2
- package/{dist-types → dist}/server/runner/index.d.ts +1 -1
- package/{dist-types → dist}/server/serverSetup.d.ts +1 -1
- package/{dist-types → dist}/server/socketServer.d.ts +1 -1
- package/{dist-types → dist}/server/watchFiles.d.ts +4 -3
- package/dist/sirv.js +1 -1
- package/dist/tinyglobby.js +1 -1670
- package/{dist-types → dist}/types/config.d.ts +24 -15
- package/{dist-types → dist}/types/context.d.ts +8 -8
- package/{dist-types → dist}/types/hooks.d.ts +29 -13
- package/dist/types/index.d.ts +8 -0
- package/{dist-types → dist}/types/plugin.d.ts +7 -7
- package/{dist-types → dist}/types/rsbuild.d.ts +11 -11
- package/{dist-types → dist}/types/rspack.d.ts +2 -2
- package/{dist-types → dist}/types/thirdParty.d.ts +5 -5
- package/dist/ws.js +2 -1524
- package/package.json +7 -8
- package/dist-types/build.d.ts +0 -4
- package/dist-types/package.json +0 -1
- package/dist-types/plugins/cache.d.ts +0 -2
- package/dist-types/plugins/entry.d.ts +0 -2
- package/dist-types/plugins/nonce.d.ts +0 -2
- package/dist-types/plugins/sri.d.ts +0 -2
- package/dist-types/plugins/wasm.d.ts +0 -2
- package/dist-types/restart.d.ts +0 -14
- package/dist-types/types/index.d.ts +0 -8
- /package/dist/{711.js.LICENSE.txt → 626.js.LICENSE.txt} +0 -0
- /package/{dist-types → dist}/cli/index.d.ts +0 -0
- /package/dist/client/{307.js → 307~0.js} +0 -0
- /package/{dist-types → dist}/constants.d.ts +0 -0
- /package/{dist-types → dist}/helpers/exitHook.d.ts +0 -0
- /package/{dist-types → dist}/helpers/packageJson.d.ts +0 -0
- /package/{dist-types → dist}/helpers/version.d.ts +0 -0
- /package/{dist-types → dist}/loadEnv.d.ts +0 -0
- /package/{dist-types → dist}/loader/workerLoader.d.ts +0 -0
- /package/dist/{1~rslib-runtime.js → rslib-runtime.js} +0 -0
- /package/{dist-types → dist}/rspack-plugins/resource-hints/getResourceType.d.ts +0 -0
- /package/{dist-types → dist}/server/ansiHTML.d.ts +0 -0
- /package/{dist-types → dist}/server/assets-middleware/parseTokenList.d.ts +0 -0
- /package/{dist-types → dist}/server/compileState.d.ts +0 -0
- /package/{dist-types → dist}/server/gracefulShutdown.d.ts +0 -0
- /package/{dist-types → dist}/server/hmrFallback.d.ts +0 -0
- /package/{dist-types → dist}/server/overlay.d.ts +0 -0
- /package/{dist-types → dist}/server/publicPathnames.d.ts +0 -0
- /package/{dist-types → dist}/server/runner/asModule.d.ts +0 -0
- /package/{dist-types → dist}/server/runner/type.d.ts +0 -0
- /package/{dist-types → dist}/types/utils.d.ts +0 -0
package/compiled/cors/index.d.ts
CHANGED
package/dist/{711.js → 626.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! LICENSE:
|
|
1
|
+
/*! LICENSE: 626.js.LICENSE.txt */
|
|
2
2
|
let runtimeProcessArgs, runtimeInfo, swcHelpersPath, pluginHelper_htmlPlugin;
|
|
3
3
|
import { rspack as core_rspack } from "@rspack/core";
|
|
4
4
|
import node_util, { stripVTControlCharacters } from "node:util";
|
|
@@ -11,7 +11,7 @@ import { URL as external_node_url_URL, pathToFileURL, fileURLToPath as __rspack_
|
|
|
11
11
|
import { isPromise, isRegExp } from "node:util/types";
|
|
12
12
|
import { readFile } from "node:fs/promises";
|
|
13
13
|
import node_zlib from "node:zlib";
|
|
14
|
-
import { __webpack_require__ } from "./
|
|
14
|
+
import { __webpack_require__ } from "./rslib-runtime.js";
|
|
15
15
|
var superClass, superClass1, __rspack_import_meta_filename__ = __rspack_fileURLToPath(import.meta.url);
|
|
16
16
|
let __rspack_createRequire_require = __rspack_createRequire(import.meta.url);
|
|
17
17
|
__webpack_require__.add({
|
|
@@ -151,7 +151,7 @@ __webpack_require__.add({
|
|
|
151
151
|
};
|
|
152
152
|
},
|
|
153
153
|
"../../node_modules/.pnpm/lilconfig@3.1.3/node_modules/lilconfig/src/index.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
154
|
-
let path = __webpack_require__("path?
|
|
154
|
+
let path = __webpack_require__("path?37f5"), fs = __webpack_require__("fs?cdbd"), os = __webpack_require__("os"), url = __webpack_require__("url?5f07"), fsReadFileAsync = fs.promises.readFile;
|
|
155
155
|
function getDefaultSearchPlaces(name, sync) {
|
|
156
156
|
return [
|
|
157
157
|
'package.json',
|
|
@@ -387,7 +387,7 @@ __webpack_require__.add({
|
|
|
387
387
|
}
|
|
388
388
|
},
|
|
389
389
|
"../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.7.0_postcss@8.5.19/node_modules/postcss-load-config/src/index.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
390
|
-
let yaml, { resolve } = __webpack_require__("node:path?
|
|
390
|
+
let yaml, { resolve } = __webpack_require__("node:path?815c"), config = __webpack_require__("../../node_modules/.pnpm/lilconfig@3.1.3/node_modules/lilconfig/src/index.js"), loadOptions = __webpack_require__("../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.7.0_postcss@8.5.19/node_modules/postcss-load-config/src/options.js"), loadPlugins = __webpack_require__("../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.7.0_postcss@8.5.19/node_modules/postcss-load-config/src/plugins.js"), req = __webpack_require__("../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.7.0_postcss@8.5.19/node_modules/postcss-load-config/src/req.js");
|
|
391
391
|
async function processResult(ctx, result) {
|
|
392
392
|
let obj, file = result.filepath || '', projectConfig = ((obj = result.config) && obj.__esModule ? obj : {
|
|
393
393
|
default: obj
|
|
@@ -499,7 +499,7 @@ __webpack_require__.add({
|
|
|
499
499
|
};
|
|
500
500
|
},
|
|
501
501
|
"../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.7.0_postcss@8.5.19/node_modules/postcss-load-config/src/req.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
502
|
-
let tsx, jiti, { createRequire } = __webpack_require__("node:module?
|
|
502
|
+
let tsx, jiti, { createRequire } = __webpack_require__("node:module?f56b"), { pathToFileURL } = __webpack_require__("node:url?5295"), TS_EXT_RE = /\.[mc]?ts$/, importError = [];
|
|
503
503
|
module.exports = async function req(name, rootFile = __rspack_import_meta_filename__) {
|
|
504
504
|
let url = createRequire(rootFile).resolve(name);
|
|
505
505
|
try {
|
|
@@ -539,7 +539,7 @@ __webpack_require__.add({
|
|
|
539
539
|
crypto (module) {
|
|
540
540
|
module.exports = __rspack_createRequire_require("crypto");
|
|
541
541
|
},
|
|
542
|
-
"fs?
|
|
542
|
+
"fs?cdbd" (module) {
|
|
543
543
|
module.exports = __rspack_createRequire_require("fs");
|
|
544
544
|
},
|
|
545
545
|
http (module) {
|
|
@@ -551,31 +551,31 @@ __webpack_require__.add({
|
|
|
551
551
|
net (module) {
|
|
552
552
|
module.exports = __rspack_createRequire_require("net");
|
|
553
553
|
},
|
|
554
|
-
"node:buffer?
|
|
554
|
+
"node:buffer?4a79" (module) {
|
|
555
555
|
module.exports = __rspack_createRequire_require("node:buffer");
|
|
556
556
|
},
|
|
557
|
-
|
|
557
|
+
events (module) {
|
|
558
558
|
module.exports = __rspack_createRequire_require("node:events");
|
|
559
559
|
},
|
|
560
|
-
"node:fs?
|
|
560
|
+
"node:fs?31c0" (module) {
|
|
561
561
|
module.exports = __rspack_createRequire_require("node:fs");
|
|
562
562
|
},
|
|
563
|
-
"node:module?
|
|
563
|
+
"node:module?f56b" (module) {
|
|
564
564
|
module.exports = __rspack_createRequire_require("node:module");
|
|
565
565
|
},
|
|
566
|
-
"node:path?
|
|
566
|
+
"node:path?815c" (module) {
|
|
567
567
|
module.exports = __rspack_createRequire_require("node:path");
|
|
568
568
|
},
|
|
569
|
-
"node:stream?
|
|
569
|
+
"node:stream?be04" (module) {
|
|
570
570
|
module.exports = __rspack_createRequire_require("node:stream");
|
|
571
571
|
},
|
|
572
|
-
"node:url?
|
|
572
|
+
"node:url?5295" (module) {
|
|
573
573
|
module.exports = __rspack_createRequire_require("node:url");
|
|
574
574
|
},
|
|
575
575
|
os (module) {
|
|
576
576
|
module.exports = __rspack_createRequire_require("os");
|
|
577
577
|
},
|
|
578
|
-
"path?
|
|
578
|
+
"path?37f5" (module) {
|
|
579
579
|
module.exports = __rspack_createRequire_require("path");
|
|
580
580
|
},
|
|
581
581
|
process (module) {
|
|
@@ -584,13 +584,16 @@ __webpack_require__.add({
|
|
|
584
584
|
stream (module) {
|
|
585
585
|
module.exports = __rspack_createRequire_require("stream");
|
|
586
586
|
},
|
|
587
|
+
"supports-color" (module) {
|
|
588
|
+
module.exports = __rspack_createRequire_require("supports-color");
|
|
589
|
+
},
|
|
587
590
|
tls (module) {
|
|
588
591
|
module.exports = __rspack_createRequire_require("tls");
|
|
589
592
|
},
|
|
590
593
|
tty (module) {
|
|
591
594
|
module.exports = __rspack_createRequire_require("tty");
|
|
592
595
|
},
|
|
593
|
-
"url?
|
|
596
|
+
"url?5f07" (module) {
|
|
594
597
|
module.exports = __rspack_createRequire_require("url");
|
|
595
598
|
},
|
|
596
599
|
util (module) {
|
|
@@ -598,12 +601,6 @@ __webpack_require__.add({
|
|
|
598
601
|
},
|
|
599
602
|
zlib (module) {
|
|
600
603
|
module.exports = __rspack_createRequire_require("zlib");
|
|
601
|
-
},
|
|
602
|
-
events (module) {
|
|
603
|
-
module.exports = __rspack_createRequire_require("node:events");
|
|
604
|
-
},
|
|
605
|
-
"supports-color" (module) {
|
|
606
|
-
module.exports = __rspack_createRequire_require("supports-color");
|
|
607
604
|
}
|
|
608
605
|
}), function checkNodeVersion() {
|
|
609
606
|
let { versions } = process;
|
|
@@ -3410,7 +3407,7 @@ function createPublicContext(context) {
|
|
|
3410
3407
|
async function createContext(options, userConfig, logger, loadConfigResult) {
|
|
3411
3408
|
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, hooks = initHooks();
|
|
3412
3409
|
return {
|
|
3413
|
-
version: "2.1.
|
|
3410
|
+
version: "2.1.8",
|
|
3414
3411
|
rootPath,
|
|
3415
3412
|
configFile: loadConfigResult?.filePath ?? userConfig._privateMeta?.configFilePath,
|
|
3416
3413
|
configFileDependencies: loadConfigResult?.dependencies ?? userConfig._privateMeta?.configFileDependencies ?? [],
|
|
@@ -4187,6 +4184,11 @@ async function createCompiler_createCompiler(options) {
|
|
|
4187
4184
|
rspackConfigs
|
|
4188
4185
|
};
|
|
4189
4186
|
}
|
|
4187
|
+
let DEFAULT_WATCH_FILE_EVENTS = [
|
|
4188
|
+
'add',
|
|
4189
|
+
'change',
|
|
4190
|
+
'unlink'
|
|
4191
|
+
];
|
|
4190
4192
|
async function setupWatchFiles(options) {
|
|
4191
4193
|
let { config, root, buildManager } = options, { hmr, liveReload } = config.dev;
|
|
4192
4194
|
if (!hmr && !liveReload || !buildManager) return;
|
|
@@ -4204,8 +4206,8 @@ async function watchDevFiles(devConfig, buildManager, root) {
|
|
|
4204
4206
|
let { watchFiles } = devConfig;
|
|
4205
4207
|
if (!watchFiles) return;
|
|
4206
4208
|
let watchers = [];
|
|
4207
|
-
for (let { paths, options, type } of helpers_castArray(watchFiles)){
|
|
4208
|
-
let watchOptions = prepareWatchOptions(paths, options, type), watcher = await startWatchFiles(watchOptions, buildManager, root);
|
|
4209
|
+
for (let { paths, events, options, type } of helpers_castArray(watchFiles)){
|
|
4210
|
+
let watchOptions = prepareWatchOptions(paths, options, type, events), watcher = await startWatchFiles(watchOptions, buildManager, root);
|
|
4209
4211
|
watcher && watchers.push(watcher);
|
|
4210
4212
|
}
|
|
4211
4213
|
return async ()=>{
|
|
@@ -4217,11 +4219,12 @@ function watchServerFiles({ publicDir }, buildManager, root) {
|
|
|
4217
4219
|
let watchPaths = publicDir.filter((item)=>item.watch).map((item)=>item.name);
|
|
4218
4220
|
if (watchPaths.length) return startWatchFiles(prepareWatchOptions(watchPaths), buildManager, root);
|
|
4219
4221
|
}
|
|
4220
|
-
function prepareWatchOptions(paths, options = {}, type) {
|
|
4222
|
+
function prepareWatchOptions(paths, options = {}, type, events) {
|
|
4221
4223
|
return {
|
|
4222
4224
|
paths: 'string' == typeof paths ? [
|
|
4223
4225
|
paths
|
|
4224
4226
|
] : paths,
|
|
4227
|
+
events,
|
|
4225
4228
|
options,
|
|
4226
4229
|
type
|
|
4227
4230
|
};
|
|
@@ -4238,16 +4241,21 @@ async function createChokidar(pathOrGlobs, root, options) {
|
|
|
4238
4241
|
}
|
|
4239
4242
|
return chokidar.watch(Array.from(watchFiles), options);
|
|
4240
4243
|
}
|
|
4241
|
-
async function startWatchFiles({ paths, options, type = 'reload-page' }, buildManager, root) {
|
|
4242
|
-
if ('reload-page' !== type) return;
|
|
4243
|
-
let watcher = await createChokidar(paths, root,
|
|
4244
|
-
|
|
4244
|
+
async function startWatchFiles({ paths, events, options, type = 'reload-page' }, buildManager, root) {
|
|
4245
|
+
if ('reload-page' !== type || events?.length === 0) return;
|
|
4246
|
+
let watcher = await createChokidar(paths, root, {
|
|
4247
|
+
ignoreInitial: !0,
|
|
4248
|
+
...options
|
|
4249
|
+
}), reloadPage = ()=>{
|
|
4245
4250
|
buildManager.socketServer.sendMessage({
|
|
4246
4251
|
type: 'full-reload'
|
|
4247
4252
|
});
|
|
4248
|
-
}
|
|
4253
|
+
};
|
|
4254
|
+
for (let event of events ? new Set(events) : DEFAULT_WATCH_FILE_EVENTS)watcher.on(event, reloadPage);
|
|
4255
|
+
return watcher;
|
|
4249
4256
|
}
|
|
4250
|
-
let requestRestart = ({
|
|
4257
|
+
let requestRestart = ({ clear = !0, logger, restartContext, restartManager })=>{
|
|
4258
|
+
let { action, filePath } = restartContext;
|
|
4251
4259
|
if (restartManager.canRestart) {
|
|
4252
4260
|
clear && isTTY() && !process.env.DEBUG && process.stdout.write('\x1B[H\x1B[2J');
|
|
4253
4261
|
let id = 'dev' === action ? 'server' : 'build';
|
|
@@ -4256,53 +4264,55 @@ let requestRestart = ({ filePath, clear = !0, action, logger, restartManager })=
|
|
|
4256
4264
|
logger.info(`restarting ${id} as ${color.yellow(filename)} changed\n`);
|
|
4257
4265
|
} else logger.info(`restarting ${id}...\n`);
|
|
4258
4266
|
}
|
|
4259
|
-
return restartManager.requestRestart(
|
|
4260
|
-
action,
|
|
4261
|
-
filePath
|
|
4262
|
-
});
|
|
4267
|
+
return restartManager.requestRestart(restartContext);
|
|
4263
4268
|
};
|
|
4264
|
-
function watchFilesForRestart({ watchFiles, context,
|
|
4269
|
+
function watchFilesForRestart({ watchFiles, context, restartContext }) {
|
|
4265
4270
|
let closePromise, defaultFiles = context.configFile ? [
|
|
4266
4271
|
context.configFile,
|
|
4267
4272
|
...context.configFileDependencies
|
|
4268
4273
|
] : [];
|
|
4269
4274
|
if (!watchFiles.length && !defaultFiles.length) return;
|
|
4270
4275
|
let watchGroups = [];
|
|
4271
|
-
for (let { paths, options, type } of watchFiles){
|
|
4272
|
-
if ('restart' !== type && 'reload-server' !== type) continue;
|
|
4276
|
+
for (let { paths, events, options, type } of watchFiles){
|
|
4277
|
+
if ('restart' !== type && 'reload-server' !== type || events?.length === 0) continue;
|
|
4273
4278
|
let files = helpers_castArray(paths);
|
|
4274
|
-
files.length && (options ? watchGroups.push({
|
|
4279
|
+
files.length && (options || events ? watchGroups.push({
|
|
4275
4280
|
files,
|
|
4281
|
+
events,
|
|
4276
4282
|
options
|
|
4277
4283
|
}) : defaultFiles.push(...files));
|
|
4278
4284
|
}
|
|
4279
4285
|
if (defaultFiles.length && watchGroups.push({
|
|
4280
4286
|
files: defaultFiles
|
|
4281
4287
|
}), !watchGroups.length) return;
|
|
4282
|
-
let { logger, restartManager, rootPath: root } = context, restarting = !1,
|
|
4288
|
+
let { logger, restartManager, rootPath: root } = context, restarting = !1, onWatchEvent = async (event, filePath, cwd)=>{
|
|
4283
4289
|
if (restarting || closePromise) return;
|
|
4284
4290
|
restarting = !0;
|
|
4285
4291
|
let absoluteFilePath = node_path.resolve(cwd, filePath);
|
|
4286
4292
|
try {
|
|
4287
4293
|
await requestRestart({
|
|
4288
|
-
|
|
4289
|
-
|
|
4294
|
+
restartContext: {
|
|
4295
|
+
...restartContext,
|
|
4296
|
+
event,
|
|
4297
|
+
filePath: absoluteFilePath
|
|
4298
|
+
},
|
|
4290
4299
|
logger,
|
|
4291
4300
|
restartManager
|
|
4292
|
-
}) ? await close() : restartManager.canRestart && logger.error('build' === action ? 'Restart build failed.' : 'Restart server failed.');
|
|
4301
|
+
}) ? await close() : restartManager.canRestart && logger.error('build' === restartContext.action ? 'Restart build failed.' : 'Restart server failed.');
|
|
4293
4302
|
} catch (error) {
|
|
4294
4303
|
logger.error(error);
|
|
4295
4304
|
} finally{
|
|
4296
4305
|
restarting = !1;
|
|
4297
4306
|
}
|
|
4298
|
-
}, watchersPromise = Promise.all(watchGroups.map(async ({ files, options })=>{
|
|
4307
|
+
}, watchersPromise = Promise.all(watchGroups.map(async ({ files, events, options })=>{
|
|
4299
4308
|
try {
|
|
4300
4309
|
let watcher = await createChokidar(files, root, {
|
|
4301
4310
|
ignoreInitial: !0,
|
|
4302
4311
|
ignorePermissionErrors: !0,
|
|
4303
4312
|
...options
|
|
4304
|
-
}), cwd = options?.cwd
|
|
4305
|
-
|
|
4313
|
+
}), cwd = options?.cwd ?? root;
|
|
4314
|
+
for (let event of events ? new Set(events) : DEFAULT_WATCH_FILE_EVENTS)watcher.on(event, (filePath)=>onWatchEvent(event, filePath, cwd));
|
|
4315
|
+
return watcher;
|
|
4306
4316
|
} catch (error) {
|
|
4307
4317
|
logger.error(error);
|
|
4308
4318
|
}
|
|
@@ -4311,8 +4321,8 @@ function watchFilesForRestart({ watchFiles, context, action }) {
|
|
|
4311
4321
|
close
|
|
4312
4322
|
};
|
|
4313
4323
|
}
|
|
4314
|
-
let RSPACK_BUILD_ERROR = 'Rspack build failed.', build_build = async (initOptions,
|
|
4315
|
-
let stats, closeCompiler, closingPromise, unregisterRestart, restartWatcher, { context } = initOptions, { logger } = context, { compiler, rspackConfigs } = await createCompiler_createCompiler(initOptions);
|
|
4324
|
+
let RSPACK_BUILD_ERROR = 'Rspack build failed.', build_build = async (initOptions, buildOptions = {})=>{
|
|
4325
|
+
let stats, closeCompiler, closingPromise, unregisterRestart, restartWatcher, { watch } = buildOptions, { context } = initOptions, { logger } = context, { compiler, rspackConfigs } = await createCompiler_createCompiler(initOptions);
|
|
4316
4326
|
if ((({ context, isWatch, compiler, rspackConfigs, MultiStatsCtor })=>{
|
|
4317
4327
|
let isFirstCompile = !0, { environmentList } = context, onDone = async (stats)=>{
|
|
4318
4328
|
let promise = context.hooks.onAfterBuild.callBatch({
|
|
@@ -4394,7 +4404,10 @@ let RSPACK_BUILD_ERROR = 'Rspack build failed.', build_build = async (initOption
|
|
|
4394
4404
|
return watch && (unregisterRestart = context.restartManager.registerCleanup(closeBuild), restartWatcher = watchFilesForRestart({
|
|
4395
4405
|
watchFiles: context.normalizedConfig.dev.watchFiles,
|
|
4396
4406
|
context,
|
|
4397
|
-
|
|
4407
|
+
restartContext: {
|
|
4408
|
+
action: 'build',
|
|
4409
|
+
options: buildOptions
|
|
4410
|
+
}
|
|
4398
4411
|
})), {
|
|
4399
4412
|
stats,
|
|
4400
4413
|
close: async ()=>{
|
|
@@ -8128,9 +8141,14 @@ async function applyServerSetup(setup, context) {
|
|
|
8128
8141
|
}
|
|
8129
8142
|
return postCallbacks;
|
|
8130
8143
|
}
|
|
8131
|
-
async function devServer_createDevServer(options, createCompiler, config,
|
|
8144
|
+
async function devServer_createDevServer(options, createCompiler, config, devServerOptions = {}) {
|
|
8132
8145
|
var environmentCount;
|
|
8133
|
-
let closingPromise, unregisterRestart, stats, waiters, {
|
|
8146
|
+
let closingPromise, unregisterRestart, stats, waiters, { getPortSilently, runCompile = !0 } = devServerOptions, restartContext = {
|
|
8147
|
+
action: 'dev',
|
|
8148
|
+
options: pick(devServerOptions, [
|
|
8149
|
+
'getPortSilently'
|
|
8150
|
+
])
|
|
8151
|
+
}, { context } = options, { logger } = context;
|
|
8134
8152
|
logger.debug('create dev server');
|
|
8135
8153
|
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;
|
|
8136
8154
|
context.devServer = {
|
|
@@ -8210,7 +8228,7 @@ async function devServer_createDevServer(options, createCompiler, config, { getP
|
|
|
8210
8228
|
await state.restartWatcher?.close(), await closeServerResources();
|
|
8211
8229
|
}, restartServer = async ()=>{
|
|
8212
8230
|
let restarted = await requestRestart({
|
|
8213
|
-
|
|
8231
|
+
restartContext,
|
|
8214
8232
|
clear: !1,
|
|
8215
8233
|
logger,
|
|
8216
8234
|
restartManager: context.restartManager
|
|
@@ -8330,7 +8348,7 @@ async function devServer_createDevServer(options, createCompiler, config, { getP
|
|
|
8330
8348
|
}), state.buildManager?.watch(), unregisterRestart = context.restartManager.registerCleanup(closeServerResources), state.restartWatcher = watchFilesForRestart({
|
|
8331
8349
|
watchFiles: config.dev.watchFiles,
|
|
8332
8350
|
context,
|
|
8333
|
-
|
|
8351
|
+
restartContext
|
|
8334
8352
|
}), logger.debug('create dev server done'), devServer;
|
|
8335
8353
|
}
|
|
8336
8354
|
async function startPreviewServer(context, config, { getPortSilently } = {}) {
|
|
@@ -9186,8 +9204,8 @@ try {
|
|
|
9186
9204
|
chain.optimization.minimizer(minimizerId).use(rspack.SwcJsMinimizerRspackPlugin, [
|
|
9187
9205
|
getSwcMinimizerOptions(config, jsOptionsItem)
|
|
9188
9206
|
]).end();
|
|
9189
|
-
}
|
|
9190
|
-
|
|
9207
|
+
};
|
|
9208
|
+
Array.isArray(jsOptions) ? 0 === jsOptions.length ? registerJsMinimizer() : jsOptions.forEach(registerJsMinimizer) : registerJsMinimizer(jsOptions);
|
|
9191
9209
|
}
|
|
9192
9210
|
if (minifyCss) {
|
|
9193
9211
|
let loaderOptions = await getLightningCSSLoaderOptions(config, environment.browserslist, !0), defaultOptions = {
|
|
@@ -9203,10 +9221,13 @@ try {
|
|
|
9203
9221
|
'errorRecovery'
|
|
9204
9222
|
])
|
|
9205
9223
|
}
|
|
9206
|
-
},
|
|
9207
|
-
|
|
9208
|
-
|
|
9209
|
-
|
|
9224
|
+
}, registerCssMinimizer = (cssOptionsItem, index = 0)=>{
|
|
9225
|
+
let options = cssOptionsItem ? cjs_0_default()(defaultOptions, cssOptionsItem) : defaultOptions, minimizerId = 0 === index ? CHAIN_ID.MINIMIZER.CSS : `${CHAIN_ID.MINIMIZER.CSS}-${index}`;
|
|
9226
|
+
chain.optimization.minimizer(minimizerId).use(rspack.LightningCssMinimizerRspackPlugin, [
|
|
9227
|
+
options
|
|
9228
|
+
]).end();
|
|
9229
|
+
};
|
|
9230
|
+
Array.isArray(cssOptions) ? 0 === cssOptions.length ? registerCssMinimizer() : cssOptions.forEach(registerCssMinimizer) : registerCssMinimizer(cssOptions);
|
|
9210
9231
|
}
|
|
9211
9232
|
});
|
|
9212
9233
|
}
|
|
@@ -9788,11 +9809,13 @@ async function createRsbuild(options = {}) {
|
|
|
9788
9809
|
if (isEmptyDir(distPath)) throw Error(`${color.dim('[rsbuild:preview]')} The output directory ${color.yellow(distPath)} is empty, please build the project before previewing.`);
|
|
9789
9810
|
}
|
|
9790
9811
|
return startPreviewServer(context, config, options);
|
|
9791
|
-
}, build = async (options)=>(context.action = 'build', process.env.NODE_ENV || setNodeEnv('production'), build_build({
|
|
9812
|
+
}, build = async (options = {})=>(context.action = 'build', process.env.NODE_ENV || setNodeEnv('production'), build_build({
|
|
9792
9813
|
context,
|
|
9793
9814
|
pluginManager,
|
|
9794
9815
|
rsbuildOptions: resolvedOptions
|
|
9795
|
-
},
|
|
9816
|
+
}, {
|
|
9817
|
+
...options
|
|
9818
|
+
})), startDevServer = async (options = {})=>{
|
|
9796
9819
|
context.action = 'dev', process.env.NODE_ENV || setNodeEnv('development');
|
|
9797
9820
|
let config = await initRsbuildConfig({
|
|
9798
9821
|
context,
|
|
@@ -9802,7 +9825,9 @@ async function createRsbuild(options = {}) {
|
|
|
9802
9825
|
context,
|
|
9803
9826
|
pluginManager,
|
|
9804
9827
|
rsbuildOptions: resolvedOptions
|
|
9805
|
-
}, createCompiler, config,
|
|
9828
|
+
}, createCompiler, config, {
|
|
9829
|
+
...options
|
|
9830
|
+
})).listen();
|
|
9806
9831
|
}, createDevServer = async (options)=>{
|
|
9807
9832
|
context.action = 'dev', process.env.NODE_ENV || setNodeEnv('development');
|
|
9808
9833
|
let config = await initRsbuildConfig({
|
|
@@ -10059,13 +10084,11 @@ let cliState = {
|
|
|
10059
10084
|
config.output ||= {}, config.output.sourceMap = sourceMap;
|
|
10060
10085
|
}
|
|
10061
10086
|
return void 0 === config.dev.cliShortcuts && (config.dev.cliShortcuts = !0), result;
|
|
10062
|
-
}, init_restart = async (
|
|
10087
|
+
}, init_restart = async (context)=>{
|
|
10063
10088
|
let rsbuild = await init_init({
|
|
10064
10089
|
isRestart: !0
|
|
10065
10090
|
});
|
|
10066
|
-
return !!rsbuild && ('build' === action ? await rsbuild.build(
|
|
10067
|
-
watch: !0
|
|
10068
|
-
}) : await rsbuild.startDevServer(), !0);
|
|
10091
|
+
return !!rsbuild && ('build' === context.action ? await rsbuild.build(context.options) : await rsbuild.startDevServer(context.options), !0);
|
|
10069
10092
|
};
|
|
10070
10093
|
async function init_init({ isRestart } = {}) {
|
|
10071
10094
|
let logger = src_logger, { options } = cliState;
|
|
@@ -10092,7 +10115,7 @@ let applyServerOptions = (command)=>{
|
|
|
10092
10115
|
};
|
|
10093
10116
|
function setupCommands(argv) {
|
|
10094
10117
|
let cli = ((name = "")=>new CAC(name))('rsbuild');
|
|
10095
|
-
cli.version("2.1.
|
|
10118
|
+
cli.version("2.1.8"), 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)', {
|
|
10096
10119
|
default: 'auto'
|
|
10097
10120
|
}).option('--dist-path <dir>', 'Set the root directory of output files').option('--source-map', 'Enable source map').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', {
|
|
10098
10121
|
type: [
|
|
@@ -10157,7 +10180,7 @@ function setupCommands(argv) {
|
|
|
10157
10180
|
}
|
|
10158
10181
|
function showGreeting() {
|
|
10159
10182
|
let { npm_execpath, npm_lifecycle_event, NODE_RUN_SCRIPT_NAME } = process.env, isBun = npm_execpath?.includes('.bun');
|
|
10160
|
-
src_logger.greet(`${'npx' === npm_lifecycle_event || isBun || NODE_RUN_SCRIPT_NAME ? '\n' : ''}Rsbuild v2.1.
|
|
10183
|
+
src_logger.greet(`${'npx' === npm_lifecycle_event || isBun || NODE_RUN_SCRIPT_NAME ? '\n' : ''}Rsbuild v2.1.8\n`);
|
|
10161
10184
|
}
|
|
10162
10185
|
function setupLogLevel(argv) {
|
|
10163
10186
|
if (argv.length <= 3) return;
|
|
@@ -10179,5 +10202,5 @@ function runCLI({ argv = process.argv } = {}) {
|
|
|
10179
10202
|
src_logger.error('Failed to start Rsbuild CLI.'), src_logger.error(err), process.exit(1);
|
|
10180
10203
|
}
|
|
10181
10204
|
}
|
|
10182
|
-
let src_version = "2.1.
|
|
10205
|
+
let src_version = "2.1.8";
|
|
10183
10206
|
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 };
|
package/dist/build.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { InitConfigsOptions } from './initConfigs.js';
|
|
2
|
+
import type { Build, BuildOptions } from './types/index.js';
|
|
3
|
+
export declare const RSPACK_BUILD_ERROR = 'Rspack build failed.';
|
|
4
|
+
export declare const build: (initOptions: InitConfigsOptions, buildOptions?: BuildOptions) => Promise<ReturnType<Build>>;
|