@rsbuild/core 0.6.4 → 0.6.6
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/init.js +1 -1
- package/dist/cli/prepare.js +1 -1
- package/dist/client/hmr.mjs +2 -0
- package/dist/config.d.ts +1 -1
- package/dist/config.js +3 -2
- package/dist/createContext.d.ts +1 -1
- package/dist/createContext.js +2 -2
- package/dist/createRsbuild.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/initHooks.d.ts +1 -1
- package/dist/plugins/basic.js +1 -0
- package/dist/plugins/html.d.ts +1 -1
- package/dist/plugins/server.js +1 -1
- package/dist/plugins/startUrl.js +4 -3
- package/dist/provider/build.d.ts +1 -1
- package/dist/provider/build.js +1 -1
- package/dist/provider/createCompiler.d.ts +2 -2
- package/dist/provider/css-modules-typescript-pre-loader/index.js +1 -1
- package/dist/provider/css-modules-typescript-pre-loader/postcssIcssExtractPlugin.js +1 -1
- package/dist/provider/initConfigs.d.ts +1 -1
- package/dist/provider/initConfigs.js +3 -3
- package/dist/provider/inspectConfig.d.ts +1 -1
- package/dist/provider/inspectConfig.js +1 -1
- package/dist/provider/plugins/css.d.ts +2 -2
- package/dist/provider/plugins/rspackProfile.d.ts +1 -1
- package/dist/provider/plugins/rspackProfile.js +1 -1
- package/dist/provider/plugins/swc.d.ts +5 -4
- package/dist/provider/plugins/swc.js +2 -3
- package/dist/provider/provider.js +1 -1
- package/dist/provider/rspackConfig.d.ts +1 -1
- package/dist/provider/rspackConfig.js +1 -1
- package/dist/provider/shared.d.ts +1 -1
- package/dist/provider/shared.js +3 -3
- package/dist/rspack/HtmlBasicPlugin.d.ts +2 -2
- package/dist/rspack/InlineChunkHtmlPlugin.d.ts +1 -1
- package/dist/rspack/preload/HtmlPreloadOrPrefetchPlugin.d.ts +1 -1
- package/dist/rspack/preload/HtmlPreloadOrPrefetchPlugin.js +1 -1
- package/dist/rspack/preload/helpers/doesChunkBelongToHtml.d.ts +1 -1
- package/dist/rspack/preload/helpers/extractChunks.d.ts +1 -1
- package/dist/rspack/transformLoader.d.ts +1 -1
- package/dist/server/compilerDevMiddleware.d.ts +1 -1
- package/dist/server/devMiddleware.js +1 -1
- package/dist/server/devServer.d.ts +1 -1
- package/dist/server/devServer.js +10 -3
- package/dist/server/getDevMiddlewares.d.ts +1 -1
- package/dist/server/getDevMiddlewares.js +1 -1
- package/dist/server/helper.d.ts +1 -1
- package/dist/server/middlewares.js +3 -3
- package/dist/server/prodServer.d.ts +1 -1
- package/dist/server/prodServer.js +3 -3
- package/dist/server/proxy.d.ts +1 -1
- package/dist/server/proxy.js +3 -1
- package/dist/server/socketServer.d.ts +1 -1
- package/dist/server/socketServer.js +1 -1
- package/dist/server/watchFiles.d.ts +10 -0
- package/dist/server/watchFiles.js +90 -0
- package/dist/types.d.ts +1 -1
- package/package.json +4 -4
package/dist/cli/commands.js
CHANGED
|
@@ -21,8 +21,8 @@ __export(commands_exports, {
|
|
|
21
21
|
runCli: () => runCli
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(commands_exports);
|
|
24
|
-
var import_node_path = require("node:path");
|
|
25
24
|
var import_node_fs = require("node:fs");
|
|
25
|
+
var import_node_path = require("node:path");
|
|
26
26
|
var import_shared = require("@rsbuild/shared");
|
|
27
27
|
var import_commander = require("../../compiled/commander");
|
|
28
28
|
var import_init = require("./init");
|
|
@@ -39,7 +39,7 @@ const applyServerOptions = (command) => {
|
|
|
39
39
|
command.option("-o --open [url]", "open the page in browser on startup").option("--port <port>", "specify a port number for server to listen").option("--host <host>", "specify the host that the server listens to");
|
|
40
40
|
};
|
|
41
41
|
function runCli() {
|
|
42
|
-
import_commander.program.name("rsbuild").usage("<command> [options]").version("0.6.
|
|
42
|
+
import_commander.program.name("rsbuild").usage("<command> [options]").version("0.6.6");
|
|
43
43
|
const devCommand = import_commander.program.command("dev");
|
|
44
44
|
const buildCommand = import_commander.program.command("build");
|
|
45
45
|
const previewCommand = import_commander.program.command("preview");
|
package/dist/cli/init.js
CHANGED
|
@@ -32,8 +32,8 @@ __export(init_exports, {
|
|
|
32
32
|
});
|
|
33
33
|
module.exports = __toCommonJS(init_exports);
|
|
34
34
|
var import_shared = require("@rsbuild/shared");
|
|
35
|
-
var import_loadEnv = require("../loadEnv");
|
|
36
35
|
var import_config = require("../config");
|
|
36
|
+
var import_loadEnv = require("../loadEnv");
|
|
37
37
|
var import_restart = require("../server/restart");
|
|
38
38
|
let commonOpts = {};
|
|
39
39
|
async function init({
|
package/dist/cli/prepare.js
CHANGED
|
@@ -34,7 +34,7 @@ function prepareCli() {
|
|
|
34
34
|
if (!npm_execpath || npm_execpath.includes("npx-cli.js") || npm_execpath.includes(".bun")) {
|
|
35
35
|
console.log();
|
|
36
36
|
}
|
|
37
|
-
import_rslog.logger.greet(` ${`Rsbuild v${"0.6.
|
|
37
|
+
import_rslog.logger.greet(` ${`Rsbuild v${"0.6.6"}`}
|
|
38
38
|
`);
|
|
39
39
|
}
|
|
40
40
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/client/hmr.mjs
CHANGED
package/dist/config.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { NormalizedConfig, RsbuildConfig } from '@rsbuild/shared';
|
|
2
2
|
export declare const withDefaultConfig: (rootPath: string, config: RsbuildConfig) => Promise<RsbuildConfig>;
|
|
3
3
|
/** #__PURE__
|
|
4
4
|
* 1. May used by multiple plugins.
|
package/dist/config.js
CHANGED
|
@@ -37,9 +37,9 @@ __export(config_exports, {
|
|
|
37
37
|
module.exports = __toCommonJS(config_exports);
|
|
38
38
|
var import_node_fs = __toESM(require("node:fs"));
|
|
39
39
|
var import_node_path = require("node:path");
|
|
40
|
-
var import_restart = require("./server/restart");
|
|
41
40
|
var import_shared = require("@rsbuild/shared");
|
|
42
41
|
var import_mergeConfig = require("./mergeConfig");
|
|
42
|
+
var import_restart = require("./server/restart");
|
|
43
43
|
const getDefaultDevConfig = () => ({
|
|
44
44
|
hmr: true,
|
|
45
45
|
liveReload: true,
|
|
@@ -58,7 +58,8 @@ const getDefaultServerConfig = () => ({
|
|
|
58
58
|
strictPort: false,
|
|
59
59
|
publicDir: {
|
|
60
60
|
name: "public",
|
|
61
|
-
copyOnBuild: true
|
|
61
|
+
copyOnBuild: true,
|
|
62
|
+
watch: false
|
|
62
63
|
}
|
|
63
64
|
});
|
|
64
65
|
const getDefaultSourceConfig = () => ({
|
package/dist/createContext.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type BundlerType, type
|
|
1
|
+
import { type BundlerType, type CreateRsbuildOptions, type NormalizedConfig, type RsbuildConfig, type RsbuildContext } from '@rsbuild/shared';
|
|
2
2
|
import type { InternalContext } from './types';
|
|
3
3
|
export declare function updateContextByNormalizedConfig(context: RsbuildContext, config: NormalizedConfig): void;
|
|
4
4
|
export declare function createPublicContext(context: RsbuildContext): Readonly<RsbuildContext>;
|
package/dist/createContext.js
CHANGED
|
@@ -25,8 +25,8 @@ __export(createContext_exports, {
|
|
|
25
25
|
module.exports = __toCommonJS(createContext_exports);
|
|
26
26
|
var import_node_path = require("node:path");
|
|
27
27
|
var import_shared = require("@rsbuild/shared");
|
|
28
|
-
var import_initHooks = require("./initHooks");
|
|
29
28
|
var import_config = require("./config");
|
|
29
|
+
var import_initHooks = require("./initHooks");
|
|
30
30
|
var import_entry = require("./plugins/entry");
|
|
31
31
|
function getAbsolutePath(root, filepath) {
|
|
32
32
|
return (0, import_node_path.isAbsolute)(filepath) ? filepath : (0, import_node_path.join)(root, filepath);
|
|
@@ -44,7 +44,7 @@ async function createContextByConfig(options, bundlerType, config = {}) {
|
|
|
44
44
|
const context = {
|
|
45
45
|
entry: (0, import_entry.getEntryObject)(config, "web"),
|
|
46
46
|
targets: config.output?.targets || [],
|
|
47
|
-
version: "0.6.
|
|
47
|
+
version: "0.6.6",
|
|
48
48
|
rootPath,
|
|
49
49
|
distPath,
|
|
50
50
|
cachePath,
|
package/dist/createRsbuild.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type CreateRsbuildOptions, type RsbuildInstance } from '@rsbuild/shared';
|
|
2
2
|
export declare function createRsbuild(options?: CreateRsbuildOptions): Promise<RsbuildInstance>;
|
package/dist/index.js
CHANGED
|
@@ -38,7 +38,7 @@ var import_config = require("./config");
|
|
|
38
38
|
var import_shared = require("@rsbuild/shared");
|
|
39
39
|
var import_mergeConfig = require("./mergeConfig");
|
|
40
40
|
var import_constants = require("./constants");
|
|
41
|
-
const version = "0.6.
|
|
41
|
+
const version = "0.6.6";
|
|
42
42
|
// Annotate the CommonJS export names for ESM import in node:
|
|
43
43
|
0 && (module.exports = {
|
|
44
44
|
PLUGIN_CSS_NAME,
|
package/dist/initHooks.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AsyncHook, ModifyBundlerChainFn, ModifyHTMLTagsFn, ModifyRsbuildConfigFn, ModifyRspackConfigFn, ModifyWebpackChainFn, ModifyWebpackConfigFn, OnAfterBuildFn, OnAfterCreateCompilerFn, OnAfterStartDevServerFn, OnAfterStartProdServerFn, OnBeforeBuildFn, OnBeforeCreateCompilerFn, OnBeforeStartDevServerFn, OnBeforeStartProdServerFn, OnCloseDevServerFn, OnDevCompileDoneFn, OnExitFn } from '@rsbuild/shared';
|
|
2
2
|
export declare function createAsyncHook<Callback extends (...args: any[]) => any>(): AsyncHook<Callback>;
|
|
3
3
|
export declare function initHooks(): {
|
|
4
4
|
onExit: AsyncHook<OnExitFn>;
|
package/dist/plugins/basic.js
CHANGED
package/dist/plugins/html.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { HtmlConfig,
|
|
1
|
+
import type { HtmlConfig, ModifyHTMLTagsFn, NormalizedConfig } from '@rsbuild/shared';
|
|
2
2
|
import type { RsbuildPlugin } from '../types';
|
|
3
3
|
export declare function getTitle(entryName: string, config: NormalizedConfig): string;
|
|
4
4
|
export declare function getInject(entryName: string, config: NormalizedConfig): import("@rsbuild/shared").ScriptInject;
|
package/dist/plugins/server.js
CHANGED
|
@@ -21,8 +21,8 @@ __export(server_exports, {
|
|
|
21
21
|
pluginServer: () => pluginServer
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(server_exports);
|
|
24
|
-
var import_shared = require("@rsbuild/shared");
|
|
25
24
|
var import_node_path = require("node:path");
|
|
25
|
+
var import_shared = require("@rsbuild/shared");
|
|
26
26
|
const pluginServer = () => ({
|
|
27
27
|
name: "rsbuild:server",
|
|
28
28
|
setup(api) {
|
package/dist/plugins/startUrl.js
CHANGED
|
@@ -33,10 +33,10 @@ __export(startUrl_exports, {
|
|
|
33
33
|
replacePlaceholder: () => replacePlaceholder
|
|
34
34
|
});
|
|
35
35
|
module.exports = __toCommonJS(startUrl_exports);
|
|
36
|
-
var import_node_path = require("node:path");
|
|
37
|
-
var import_shared = require("@rsbuild/shared");
|
|
38
36
|
var import_node_child_process = require("node:child_process");
|
|
37
|
+
var import_node_path = require("node:path");
|
|
39
38
|
var import_node_util = require("node:util");
|
|
39
|
+
var import_shared = require("@rsbuild/shared");
|
|
40
40
|
const execAsync = (0, import_node_util.promisify)(import_node_child_process.exec);
|
|
41
41
|
const supportedChromiumBrowsers = [
|
|
42
42
|
"Google Chrome Canary",
|
|
@@ -99,7 +99,8 @@ function pluginStartUrl() {
|
|
|
99
99
|
const config = api.getNormalizedConfig();
|
|
100
100
|
const { startUrl, beforeStartUrl } = config.dev;
|
|
101
101
|
const { https } = api.context.devServer || {};
|
|
102
|
-
const
|
|
102
|
+
const isCodesandbox = process.env.CSB === "true";
|
|
103
|
+
const shouldOpen = Boolean(startUrl) && !isCodesandbox;
|
|
103
104
|
if (!shouldOpen) {
|
|
104
105
|
return;
|
|
105
106
|
}
|
package/dist/provider/build.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { type InitConfigsOptions } from './initConfigs';
|
|
2
1
|
import type { BuildOptions } from '@rsbuild/shared';
|
|
2
|
+
import { type InitConfigsOptions } from './initConfigs';
|
|
3
3
|
export declare const build: (initOptions: InitConfigsOptions, { mode, watch, compiler: customCompiler }?: BuildOptions) => Promise<void>;
|
package/dist/provider/build.js
CHANGED
|
@@ -31,9 +31,9 @@ __export(build_exports, {
|
|
|
31
31
|
build: () => build
|
|
32
32
|
});
|
|
33
33
|
module.exports = __toCommonJS(build_exports);
|
|
34
|
+
var import_shared = require("@rsbuild/shared");
|
|
34
35
|
var import_createCompiler = require("./createCompiler");
|
|
35
36
|
var import_initConfigs = require("./initConfigs");
|
|
36
|
-
var import_shared = require("@rsbuild/shared");
|
|
37
37
|
const build = async (initOptions, { mode = "production", watch, compiler: customCompiler } = {}) => {
|
|
38
38
|
if (!(0, import_shared.getNodeEnv)()) {
|
|
39
39
|
(0, import_shared.setNodeEnv)(mode);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
import { type InitConfigsOptions } from './initConfigs';
|
|
1
|
+
import { type CreateDevMiddlewareReturns, type RspackCompiler, type RspackConfig, type RspackMultiCompiler } from '@rsbuild/shared';
|
|
3
2
|
import type { InternalContext } from '../types';
|
|
3
|
+
import { type InitConfigsOptions } from './initConfigs';
|
|
4
4
|
export declare function createCompiler({ context, rspackConfigs, }: {
|
|
5
5
|
context: InternalContext;
|
|
6
6
|
rspackConfigs: RspackConfig[];
|
|
@@ -31,8 +31,8 @@ __export(css_modules_typescript_pre_loader_exports, {
|
|
|
31
31
|
default: () => css_modules_typescript_pre_loader_default
|
|
32
32
|
});
|
|
33
33
|
module.exports = __toCommonJS(css_modules_typescript_pre_loader_exports);
|
|
34
|
-
var import_css_modules_typescript_loader = __toESM(require("@rsbuild/shared/css-modules-typescript-loader"));
|
|
35
34
|
var import_shared = require("@rsbuild/shared");
|
|
35
|
+
var import_css_modules_typescript_loader = __toESM(require("@rsbuild/shared/css-modules-typescript-loader"));
|
|
36
36
|
async function processCss(inputSource, {
|
|
37
37
|
exportLocalsConvention
|
|
38
38
|
}) {
|
|
@@ -21,8 +21,8 @@ __export(postcssIcssExtractPlugin_exports, {
|
|
|
21
21
|
default: () => postcssIcssExtractPlugin_default
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(postcssIcssExtractPlugin_exports);
|
|
24
|
-
var import_icss_utils = require("@rsbuild/shared/icss-utils");
|
|
25
24
|
var import_shared = require("@rsbuild/shared");
|
|
25
|
+
var import_icss_utils = require("@rsbuild/shared/icss-utils");
|
|
26
26
|
const dashesCamelCase = (str) => str.replace(/-+(\w)/g, (_match, firstLetter) => firstLetter.toUpperCase());
|
|
27
27
|
const getExportLocalsConvention = (name, exportLocalsConventionType) => {
|
|
28
28
|
switch (exportLocalsConventionType) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type CreateRsbuildOptions, type PluginManager, type RspackConfig } from '@rsbuild/shared';
|
|
2
2
|
import type { InternalContext, NormalizedConfig } from '../types';
|
|
3
3
|
export type InitConfigsOptions = {
|
|
4
4
|
context: InternalContext;
|
|
@@ -23,12 +23,12 @@ __export(initConfigs_exports, {
|
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(initConfigs_exports);
|
|
25
25
|
var import_shared = require("@rsbuild/shared");
|
|
26
|
-
var
|
|
26
|
+
var import_config = require("../config");
|
|
27
27
|
var import_createContext = require("../createContext");
|
|
28
|
+
var import_mergeConfig = require("../mergeConfig");
|
|
29
|
+
var import_pluginManager = require("../pluginManager");
|
|
28
30
|
var import_inspectConfig = require("./inspectConfig");
|
|
29
31
|
var import_rspackConfig = require("./rspackConfig");
|
|
30
|
-
var import_config = require("../config");
|
|
31
|
-
var import_pluginManager = require("../pluginManager");
|
|
32
32
|
async function modifyRsbuildConfig(context) {
|
|
33
33
|
(0, import_shared.debug)("modify Rsbuild config");
|
|
34
34
|
const [modified] = await context.hooks.modifyRsbuildConfig.call(
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { type InspectConfigOptions, type InspectConfigResult, type RspackConfig } from '@rsbuild/shared';
|
|
1
2
|
import { type InitConfigsOptions } from './initConfigs';
|
|
2
|
-
import { type RspackConfig, type InspectConfigResult, type InspectConfigOptions } from '@rsbuild/shared';
|
|
3
3
|
export declare function inspectConfig({ context, pluginManager, rsbuildOptions, bundlerConfigs, inspectOptions, }: InitConfigsOptions & {
|
|
4
4
|
inspectOptions?: InspectConfigOptions;
|
|
5
5
|
bundlerConfigs?: RspackConfig[];
|
|
@@ -22,8 +22,8 @@ __export(inspectConfig_exports, {
|
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(inspectConfig_exports);
|
|
24
24
|
var import_node_path = require("node:path");
|
|
25
|
-
var import_initConfigs = require("./initConfigs");
|
|
26
25
|
var import_shared = require("@rsbuild/shared");
|
|
26
|
+
var import_initConfigs = require("./initConfigs");
|
|
27
27
|
async function inspectConfig({
|
|
28
28
|
context,
|
|
29
29
|
pluginManager,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type BundlerChain, type
|
|
2
|
-
import type {
|
|
1
|
+
import { type BundlerChain, type ModifyBundlerChainUtils, type RsbuildContext, type RspackRule } from '@rsbuild/shared';
|
|
2
|
+
import type { NormalizedConfig, RsbuildPlugin } from '../../types';
|
|
3
3
|
export declare const enableNativeCss: (config: NormalizedConfig) => boolean;
|
|
4
4
|
export declare function applyBaseCSSRule({ rule, config, context, utils: { target, isProd, isServer, isWebWorker, CHAIN_ID }, importLoaders, }: {
|
|
5
5
|
rule: ReturnType<BundlerChain['module']['rule']>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import type { RsbuildPlugin } from '../../types';
|
|
3
2
|
import inspector from 'node:inspector';
|
|
3
|
+
import type { RsbuildPlugin } from '../../types';
|
|
4
4
|
export declare const stopProfiler: (output: string, profileSession?: inspector.Session) => void;
|
|
5
5
|
export declare const pluginRspackProfile: () => RsbuildPlugin;
|
|
@@ -32,8 +32,8 @@ __export(rspackProfile_exports, {
|
|
|
32
32
|
stopProfiler: () => stopProfiler
|
|
33
33
|
});
|
|
34
34
|
module.exports = __toCommonJS(rspackProfile_exports);
|
|
35
|
-
var import_node_path = __toESM(require("node:path"));
|
|
36
35
|
var import_node_inspector = __toESM(require("node:inspector"));
|
|
36
|
+
var import_node_path = __toESM(require("node:path"));
|
|
37
37
|
var import_shared = require("@rsbuild/shared");
|
|
38
38
|
var import_shared2 = require("@rsbuild/shared");
|
|
39
39
|
const stopProfiler = (output, profileSession) => {
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { type RsbuildTarget
|
|
2
|
-
import type {
|
|
3
|
-
|
|
1
|
+
import { type RsbuildTarget } from '@rsbuild/shared';
|
|
2
|
+
import type { SwcLoaderOptions } from '@rspack/core';
|
|
3
|
+
import type { NormalizedConfig, RsbuildPlugin } from '../../types';
|
|
4
|
+
export declare function getDefaultSwcConfig(config: NormalizedConfig, rootPath: string, target: RsbuildTarget): Promise<SwcLoaderOptions>;
|
|
4
5
|
/**
|
|
5
6
|
* Provide some swc configs of rspack
|
|
6
7
|
*/
|
|
7
8
|
export declare const pluginSwc: () => RsbuildPlugin;
|
|
8
|
-
export declare function applySwcDecoratorConfig(swcConfig:
|
|
9
|
+
export declare function applySwcDecoratorConfig(swcConfig: SwcLoaderOptions, config: NormalizedConfig): void;
|
|
@@ -33,8 +33,8 @@ __export(swc_exports, {
|
|
|
33
33
|
pluginSwc: () => pluginSwc
|
|
34
34
|
});
|
|
35
35
|
module.exports = __toCommonJS(swc_exports);
|
|
36
|
-
var import_shared = require("@rsbuild/shared");
|
|
37
36
|
var import_node_path = __toESM(require("node:path"));
|
|
37
|
+
var import_shared = require("@rsbuild/shared");
|
|
38
38
|
var import_constants = require("../../constants");
|
|
39
39
|
const builtinSwcLoaderName = "builtin:swc-loader";
|
|
40
40
|
async function getDefaultSwcConfig(config, rootPath, target) {
|
|
@@ -53,8 +53,7 @@ async function getDefaultSwcConfig(config, rootPath, target) {
|
|
|
53
53
|
isModule: "unknown",
|
|
54
54
|
env: {
|
|
55
55
|
targets: await (0, import_shared.getBrowserslistWithDefault)(rootPath, config, target)
|
|
56
|
-
}
|
|
57
|
-
sourceMaps: Boolean((0, import_shared.getJsSourceMap)(config))
|
|
56
|
+
}
|
|
58
57
|
};
|
|
59
58
|
}
|
|
60
59
|
const pluginSwc = () => ({
|
|
@@ -33,9 +33,9 @@ __export(provider_exports, {
|
|
|
33
33
|
module.exports = __toCommonJS(provider_exports);
|
|
34
34
|
var import_shared = require("@rsbuild/shared");
|
|
35
35
|
var import_createContext = require("../createContext");
|
|
36
|
-
var import_initConfigs = require("./initConfigs");
|
|
37
36
|
var import_initPlugins = require("../initPlugins");
|
|
38
37
|
var import_plugins = require("../plugins");
|
|
38
|
+
var import_initConfigs = require("./initConfigs");
|
|
39
39
|
const rspackProvider = async ({
|
|
40
40
|
pluginManager,
|
|
41
41
|
rsbuildOptions
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type ModifyChainUtils, type RsbuildTarget, type RspackConfig } from '@rsbuild/shared';
|
|
2
2
|
import type { InternalContext } from '../types';
|
|
3
3
|
export declare function getChainUtils(target: RsbuildTarget): ModifyChainUtils;
|
|
4
4
|
export declare function generateRspackConfig({ target, context, }: {
|
|
@@ -33,8 +33,8 @@ __export(rspackConfig_exports, {
|
|
|
33
33
|
});
|
|
34
34
|
module.exports = __toCommonJS(rspackConfig_exports);
|
|
35
35
|
var import_shared = require("@rsbuild/shared");
|
|
36
|
-
var import_shared2 = require("./shared");
|
|
37
36
|
var import_htmlUtils = require("../htmlUtils");
|
|
37
|
+
var import_shared2 = require("./shared");
|
|
38
38
|
async function modifyRspackConfig(context, rspackConfig, utils) {
|
|
39
39
|
(0, import_shared.debug)("modify Rspack config");
|
|
40
40
|
let [modifiedConfig] = await context.hooks.modifyRspackConfig.call(
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { type MultiStats, type Stats, type StatsError, isMultiCompiler } from '@rsbuild/shared';
|
|
2
2
|
import type { StatsCompilation, StatsValue } from '@rspack/core';
|
|
3
3
|
export declare const rspackMinVersion = "0.6.2";
|
|
4
4
|
export declare const isSatisfyRspackVersion: (originalVersion: string) => Promise<boolean>;
|
package/dist/provider/shared.js
CHANGED
|
@@ -192,11 +192,11 @@ function formatStats(stats, options = {}) {
|
|
|
192
192
|
level: "error"
|
|
193
193
|
};
|
|
194
194
|
}
|
|
195
|
-
if (
|
|
195
|
+
if (warnings.length) {
|
|
196
196
|
const title = import_shared.color.bold(import_shared.color.yellow("Compile Warning: \n"));
|
|
197
197
|
return {
|
|
198
|
-
message: `${title}${
|
|
199
|
-
|
|
198
|
+
message: `${title}${warnings.join("\n\n")}
|
|
199
|
+
`,
|
|
200
200
|
level: "warning"
|
|
201
201
|
};
|
|
202
202
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { type HtmlTag, type HtmlTagDescriptor, type ModifyHTMLTagsFn } from '@rsbuild/shared';
|
|
2
|
+
import type { Compiler } from '@rspack/core';
|
|
1
3
|
import type HtmlWebpackPlugin from 'html-webpack-plugin';
|
|
2
4
|
import type { HtmlTagObject } from 'html-webpack-plugin';
|
|
3
|
-
import type { Compiler } from '@rspack/core';
|
|
4
|
-
import { type HtmlTag, type HtmlTagDescriptor, type ModifyHTMLTagsFn } from '@rsbuild/shared';
|
|
5
5
|
export type TagConfig = {
|
|
6
6
|
tags?: HtmlTagDescriptor[];
|
|
7
7
|
hash?: HtmlTag['hash'];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type InlineChunkTest } from '@rsbuild/shared';
|
|
2
|
-
import type {
|
|
2
|
+
import type { Compilation, Compiler } from '@rspack/core';
|
|
3
3
|
import type { HtmlTagObject } from 'html-webpack-plugin';
|
|
4
4
|
export type InlineChunkHtmlPluginOptions = {
|
|
5
5
|
styleTests: InlineChunkTest[];
|
|
@@ -14,9 +14,9 @@
|
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
|
+
import { type PreloadOrPreFetchOption } from '@rsbuild/shared';
|
|
17
18
|
import type { Compiler, RspackPluginInstance } from '@rspack/core';
|
|
18
19
|
import type HtmlWebpackPlugin from 'html-webpack-plugin';
|
|
19
|
-
import { type PreloadOrPreFetchOption } from '@rsbuild/shared';
|
|
20
20
|
type LinkType = 'preload' | 'prefetch';
|
|
21
21
|
export declare class HtmlPreloadOrPrefetchPlugin implements RspackPluginInstance {
|
|
22
22
|
readonly options: PreloadOrPreFetchOption;
|
|
@@ -27,8 +27,8 @@ __export(HtmlPreloadOrPrefetchPlugin_exports, {
|
|
|
27
27
|
});
|
|
28
28
|
module.exports = __toCommonJS(HtmlPreloadOrPrefetchPlugin_exports);
|
|
29
29
|
var import_shared = require("@rsbuild/shared");
|
|
30
|
-
var import_helpers = require("./helpers");
|
|
31
30
|
var import_htmlUtils = require("../../htmlUtils");
|
|
31
|
+
var import_helpers = require("./helpers");
|
|
32
32
|
/**
|
|
33
33
|
* @license
|
|
34
34
|
* Copyright 2018 Google Inc.
|
|
@@ -14,9 +14,9 @@
|
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
|
+
import type { PreloadOrPreFetchOption } from '@rsbuild/shared';
|
|
17
18
|
import type { Compilation } from '@rspack/core';
|
|
18
19
|
import type { Chunk } from 'webpack';
|
|
19
|
-
import type { PreloadOrPreFetchOption } from '@rsbuild/shared';
|
|
20
20
|
import type { BeforeAssetTagGenerationHtmlPluginData } from './type';
|
|
21
21
|
interface DoesChunkBelongToHtmlOptions {
|
|
22
22
|
chunk: Chunk;
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
|
-
import type { Chunk, Compilation } from 'webpack';
|
|
18
17
|
import type { PreloadIncludeType } from '@rsbuild/shared';
|
|
18
|
+
import type { Chunk, Compilation } from 'webpack';
|
|
19
19
|
export type ChunkGroup = Compilation['chunkGroups'][0];
|
|
20
20
|
interface ExtractChunks {
|
|
21
21
|
compilation: Compilation;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { LoaderContext } from '@rspack/core';
|
|
2
1
|
import type { RspackSourceMap } from '@rsbuild/shared';
|
|
2
|
+
import type { LoaderContext } from '@rspack/core';
|
|
3
3
|
export default function transform(this: LoaderContext<{
|
|
4
4
|
id: string;
|
|
5
5
|
}>, source: string, map?: string | RspackSourceMap): Promise<void>;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/// <reference types="node" />
|
|
3
3
|
import type { IncomingMessage } from 'node:http';
|
|
4
4
|
import type { Socket } from 'node:net';
|
|
5
|
-
import type {
|
|
5
|
+
import type { DevMiddleware as CustomDevMiddleware, DevConfig, DevMiddlewareAPI, ServerConfig } from '@rsbuild/shared';
|
|
6
6
|
type Options = {
|
|
7
7
|
publicPaths: string[];
|
|
8
8
|
dev: DevConfig;
|
|
@@ -31,8 +31,8 @@ __export(devMiddleware_exports, {
|
|
|
31
31
|
getDevMiddleware: () => getDevMiddleware
|
|
32
32
|
});
|
|
33
33
|
module.exports = __toCommonJS(devMiddleware_exports);
|
|
34
|
-
var import_webpack_dev_middleware = __toESM(require("@rsbuild/shared/webpack-dev-middleware"));
|
|
35
34
|
var import_shared = require("@rsbuild/shared");
|
|
35
|
+
var import_webpack_dev_middleware = __toESM(require("@rsbuild/shared/webpack-dev-middleware"));
|
|
36
36
|
function applyHMREntry({
|
|
37
37
|
compiler,
|
|
38
38
|
clientPaths,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type CreateDevMiddlewareReturns, type CreateDevServerOptions, type RsbuildDevServer, type StartDevServerOptions } from '@rsbuild/shared';
|
|
2
2
|
import type { InternalContext } from '../types';
|
|
3
3
|
export declare function createDevServer<Options extends {
|
|
4
4
|
context: InternalContext;
|
package/dist/server/devServer.js
CHANGED
|
@@ -32,12 +32,13 @@ __export(devServer_exports, {
|
|
|
32
32
|
});
|
|
33
33
|
module.exports = __toCommonJS(devServer_exports);
|
|
34
34
|
var import_shared = require("@rsbuild/shared");
|
|
35
|
-
var import_helper = require("./helper");
|
|
36
35
|
var import_connect = __toESM(require("@rsbuild/shared/connect"));
|
|
37
|
-
var import_restart = require("./restart");
|
|
38
|
-
var import_httpServer = require("./httpServer");
|
|
39
36
|
var import_getDevMiddlewares = require("./getDevMiddlewares");
|
|
37
|
+
var import_helper = require("./helper");
|
|
38
|
+
var import_httpServer = require("./httpServer");
|
|
40
39
|
var import_middlewares = require("./middlewares");
|
|
40
|
+
var import_restart = require("./restart");
|
|
41
|
+
var import_watchFiles = require("./watchFiles");
|
|
41
42
|
async function createDevServer(options, createDevMiddleware, {
|
|
42
43
|
compiler: customCompiler,
|
|
43
44
|
getPortSilently,
|
|
@@ -106,6 +107,11 @@ async function createDevServer(options, createDevMiddleware, {
|
|
|
106
107
|
});
|
|
107
108
|
}
|
|
108
109
|
const compileMiddlewareAPI = runCompile ? await startCompile() : void 0;
|
|
110
|
+
const fileWatcher = await (0, import_watchFiles.setupWatchFiles)({
|
|
111
|
+
dev: devConfig,
|
|
112
|
+
server: serverConfig,
|
|
113
|
+
compileMiddlewareAPI
|
|
114
|
+
});
|
|
109
115
|
const devMiddlewares = await (0, import_getDevMiddlewares.getMiddlewares)({
|
|
110
116
|
pwd: options.context.rootPath,
|
|
111
117
|
compileMiddlewareAPI,
|
|
@@ -172,6 +178,7 @@ async function createDevServer(options, createDevMiddleware, {
|
|
|
172
178
|
close: async () => {
|
|
173
179
|
await options.context.hooks.onCloseDevServer.call();
|
|
174
180
|
await devMiddlewares.close();
|
|
181
|
+
await fileWatcher?.close();
|
|
175
182
|
}
|
|
176
183
|
};
|
|
177
184
|
(0, import_shared.debug)("create dev server done");
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { CompileMiddlewareAPI, DevConfig, Middlewares, ServerConfig, UpgradeEvent } from '@rsbuild/shared';
|
|
2
2
|
export type RsbuildDevMiddlewareOptions = {
|
|
3
3
|
pwd: string;
|
|
4
4
|
dev: DevConfig;
|
|
@@ -31,10 +31,10 @@ __export(getDevMiddlewares_exports, {
|
|
|
31
31
|
getMiddlewares: () => getMiddlewares
|
|
32
32
|
});
|
|
33
33
|
module.exports = __toCommonJS(getDevMiddlewares_exports);
|
|
34
|
+
var import_node_path = require("node:path");
|
|
34
35
|
var import_node_url = __toESM(require("node:url"));
|
|
35
36
|
var import_shared = require("@rsbuild/shared");
|
|
36
37
|
var import_middlewares = require("./middlewares");
|
|
37
|
-
var import_node_path = require("node:path");
|
|
38
38
|
const applySetupMiddlewares = (dev, compileMiddlewareAPI) => {
|
|
39
39
|
const setupMiddlewares = dev.setupMiddlewares || [];
|
|
40
40
|
const serverOptions = {
|
package/dist/server/helper.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { DevConfig, OutputStructure, PrintUrls, Routes, RsbuildConfig, RsbuildEntry } from '@rsbuild/shared';
|
|
2
2
|
export declare const formatRoutes: (entry: RsbuildEntry, prefix: string | undefined, outputStructure: OutputStructure | undefined) => Routes;
|
|
3
3
|
export declare function printServerURLs({ urls: originalUrls, port, routes, protocol, printUrls, }: {
|
|
4
4
|
urls: Array<{
|
|
@@ -34,10 +34,10 @@ __export(middlewares_exports, {
|
|
|
34
34
|
notFoundMiddleware: () => notFoundMiddleware
|
|
35
35
|
});
|
|
36
36
|
module.exports = __toCommonJS(middlewares_exports);
|
|
37
|
-
var import_shared = require("@rsbuild/shared");
|
|
38
|
-
var import_node_url = require("node:url");
|
|
39
|
-
var import_node_path = __toESM(require("node:path"));
|
|
40
37
|
var import_node_fs = __toESM(require("node:fs"));
|
|
38
|
+
var import_node_path = __toESM(require("node:path"));
|
|
39
|
+
var import_node_url = require("node:url");
|
|
40
|
+
var import_shared = require("@rsbuild/shared");
|
|
41
41
|
const faviconFallbackMiddleware = (req, res, next) => {
|
|
42
42
|
if (req.url === "/favicon.ico") {
|
|
43
43
|
res.statusCode = 204;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import type { Server } from 'node:http';
|
|
3
|
+
import { type PreviewServerOptions, type RsbuildConfig, type ServerConfig, type StartServerResult } from '@rsbuild/shared';
|
|
3
4
|
import connect from '@rsbuild/shared/connect';
|
|
4
|
-
import { type ServerConfig, type RsbuildConfig, type StartServerResult, type PreviewServerOptions } from '@rsbuild/shared';
|
|
5
5
|
import type { InternalContext } from '../types';
|
|
6
6
|
type RsbuildProdServerOptions = {
|
|
7
7
|
pwd: string;
|
|
@@ -37,13 +37,13 @@ __export(prodServer_exports, {
|
|
|
37
37
|
startProdServer: () => startProdServer
|
|
38
38
|
});
|
|
39
39
|
module.exports = __toCommonJS(prodServer_exports);
|
|
40
|
-
var import_connect = __toESM(require("@rsbuild/shared/connect"));
|
|
41
40
|
var import_node_path = require("node:path");
|
|
42
|
-
var import_sirv = __toESM(require("../../compiled/sirv"));
|
|
43
41
|
var import_shared = require("@rsbuild/shared");
|
|
42
|
+
var import_connect = __toESM(require("@rsbuild/shared/connect"));
|
|
43
|
+
var import_sirv = __toESM(require("../../compiled/sirv"));
|
|
44
44
|
var import_helper = require("./helper");
|
|
45
|
-
var import_middlewares = require("./middlewares");
|
|
46
45
|
var import_httpServer = require("./httpServer");
|
|
46
|
+
var import_middlewares = require("./middlewares");
|
|
47
47
|
class RsbuildProdServer {
|
|
48
48
|
constructor(options) {
|
|
49
49
|
__publicField(this, "app");
|
package/dist/server/proxy.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type RequestHandler as Middleware, type ProxyDetail, type ProxyOptions, type UpgradeEvent } from '@rsbuild/shared';
|
|
2
2
|
export declare function formatProxyOptions(proxyOptions: ProxyOptions): ProxyDetail[];
|
|
3
3
|
export declare const createProxyMiddleware: (proxyOptions: ProxyOptions) => {
|
|
4
4
|
middlewares: Middleware[];
|
package/dist/server/proxy.js
CHANGED
|
@@ -22,8 +22,8 @@ __export(proxy_exports, {
|
|
|
22
22
|
formatProxyOptions: () => formatProxyOptions
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(proxy_exports);
|
|
25
|
-
var import_http_proxy_middleware = require("@rsbuild/shared/http-proxy-middleware");
|
|
26
25
|
var import_shared = require("@rsbuild/shared");
|
|
26
|
+
var import_http_proxy_middleware = require("@rsbuild/shared/http-proxy-middleware");
|
|
27
27
|
function formatProxyOptions(proxyOptions) {
|
|
28
28
|
const ret = [];
|
|
29
29
|
if (Array.isArray(proxyOptions)) {
|
|
@@ -65,6 +65,8 @@ const createProxyMiddleware = (proxyOptions) => {
|
|
|
65
65
|
} else if (typeof bypassUrl === "string") {
|
|
66
66
|
req.url = bypassUrl;
|
|
67
67
|
next();
|
|
68
|
+
} else if (bypassUrl === true) {
|
|
69
|
+
next();
|
|
68
70
|
} else {
|
|
69
71
|
proxyMiddleware(req, res, next);
|
|
70
72
|
}
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
/// <reference types="node" />
|
|
3
3
|
import type { IncomingMessage } from 'node:http';
|
|
4
4
|
import type { Socket } from 'node:net';
|
|
5
|
+
import { type DevConfig, type Stats } from '@rsbuild/shared';
|
|
5
6
|
import ws from '../../compiled/ws';
|
|
6
|
-
import { type Stats, type DevConfig } from '@rsbuild/shared';
|
|
7
7
|
export declare class SocketServer {
|
|
8
8
|
private wsServer;
|
|
9
9
|
private readonly sockets;
|
|
@@ -36,8 +36,8 @@ __export(socketServer_exports, {
|
|
|
36
36
|
SocketServer: () => SocketServer
|
|
37
37
|
});
|
|
38
38
|
module.exports = __toCommonJS(socketServer_exports);
|
|
39
|
-
var import_ws = __toESM(require("../../compiled/ws"));
|
|
40
39
|
var import_shared = require("@rsbuild/shared");
|
|
40
|
+
var import_ws = __toESM(require("../../compiled/ws"));
|
|
41
41
|
var import_shared2 = require("../provider/shared");
|
|
42
42
|
class SocketServer {
|
|
43
43
|
constructor(options) {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { CompileMiddlewareAPI, DevConfig, ServerConfig } from '@rsbuild/shared';
|
|
2
|
+
type WatchFilesOptions = {
|
|
3
|
+
dev: DevConfig;
|
|
4
|
+
server: ServerConfig;
|
|
5
|
+
compileMiddlewareAPI?: CompileMiddlewareAPI;
|
|
6
|
+
};
|
|
7
|
+
export declare function setupWatchFiles(options: WatchFilesOptions): Promise<{
|
|
8
|
+
close(): Promise<void>;
|
|
9
|
+
} | undefined>;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
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
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var watchFiles_exports = {};
|
|
30
|
+
__export(watchFiles_exports, {
|
|
31
|
+
setupWatchFiles: () => setupWatchFiles
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(watchFiles_exports);
|
|
34
|
+
async function setupWatchFiles(options) {
|
|
35
|
+
const { dev, server, compileMiddlewareAPI } = options;
|
|
36
|
+
const { hmr, liveReload } = dev;
|
|
37
|
+
if (!hmr && !liveReload || !compileMiddlewareAPI) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
const devFilesWatcher = await watchDevFiles(dev, compileMiddlewareAPI);
|
|
41
|
+
const serverFilesWatcher = await watchServerFiles(
|
|
42
|
+
server,
|
|
43
|
+
compileMiddlewareAPI
|
|
44
|
+
);
|
|
45
|
+
return {
|
|
46
|
+
async close() {
|
|
47
|
+
await Promise.all([
|
|
48
|
+
devFilesWatcher?.close(),
|
|
49
|
+
serverFilesWatcher?.close()
|
|
50
|
+
]);
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
async function watchDevFiles(devConfig, compileMiddlewareAPI) {
|
|
55
|
+
const { watchFiles } = devConfig;
|
|
56
|
+
if (!watchFiles) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
const watchOptions = prepareWatchOptions(
|
|
60
|
+
watchFiles.paths,
|
|
61
|
+
watchFiles.options
|
|
62
|
+
);
|
|
63
|
+
return startWatchFiles(watchOptions, compileMiddlewareAPI);
|
|
64
|
+
}
|
|
65
|
+
function watchServerFiles(serverConfig, compileMiddlewareAPI) {
|
|
66
|
+
const { publicDir } = serverConfig;
|
|
67
|
+
if (!publicDir || !publicDir.watch || !publicDir.name) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
const watchOptions = prepareWatchOptions(publicDir.name);
|
|
71
|
+
return startWatchFiles(watchOptions, compileMiddlewareAPI);
|
|
72
|
+
}
|
|
73
|
+
function prepareWatchOptions(paths, options = {}) {
|
|
74
|
+
return {
|
|
75
|
+
paths: typeof paths === "string" ? [paths] : paths,
|
|
76
|
+
options
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
async function startWatchFiles({ paths, options }, compileMiddlewareAPI) {
|
|
80
|
+
const chokidar = await Promise.resolve().then(() => __toESM(require("@rsbuild/shared/chokidar")));
|
|
81
|
+
const watcher = chokidar.watch(paths, options);
|
|
82
|
+
watcher.on("change", () => {
|
|
83
|
+
compileMiddlewareAPI.sockWrite("static-changed");
|
|
84
|
+
});
|
|
85
|
+
return watcher;
|
|
86
|
+
}
|
|
87
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
88
|
+
0 && (module.exports = {
|
|
89
|
+
setupWatchFiles
|
|
90
|
+
});
|
package/dist/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { NormalizedConfig, RsbuildConfig, RsbuildContext, RsbuildPlugin, RsbuildPluginAPI, RsbuildPlugins, TransformHandler } from '@rsbuild/shared';
|
|
2
2
|
import type { Hooks } from './initHooks';
|
|
3
3
|
declare module '@rspack/core' {
|
|
4
4
|
interface Compiler {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsbuild/core",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.6",
|
|
4
4
|
"description": "The Rspack-based build tool.",
|
|
5
5
|
"homepage": "https://rsbuild.dev",
|
|
6
6
|
"bugs": {
|
|
@@ -48,15 +48,15 @@
|
|
|
48
48
|
"types.d.ts"
|
|
49
49
|
],
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@rspack/core": "0.6.
|
|
51
|
+
"@rspack/core": "0.6.3",
|
|
52
52
|
"@swc/helpers": "0.5.3",
|
|
53
53
|
"core-js": "~3.36.0",
|
|
54
54
|
"html-webpack-plugin": "npm:html-rspack-plugin@5.6.2",
|
|
55
55
|
"postcss": "^8.4.38",
|
|
56
|
-
"@rsbuild/shared": "0.6.
|
|
56
|
+
"@rsbuild/shared": "0.6.6"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
|
-
"@types/node": "
|
|
59
|
+
"@types/node": "18.x",
|
|
60
60
|
"typescript": "^5.4.2",
|
|
61
61
|
"webpack": "^5.91.0"
|
|
62
62
|
},
|