Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/cli/builder/src/rspack/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import type {
} from '@rsbuild/core';
import type { PluginBabelOptions } from '@rsbuild/plugin-babel';
import { parseCommonConfig } from '../shared/parseCommonConfig';
import { pluginNativeWatcher } from '../shared/plugins/nativeWatcher';
import { rsbuildRscPlugin } from '../shared/rsc/plugins/rsbuild-rsc-plugin';
import { castArray } from '../shared/utils';
import type {
Expand Down Expand Up @@ -121,6 +122,8 @@ export async function parseConfig(
);
}

rsbuildPlugins.push(pluginNativeWatcher());

return {
rsbuildConfig,
rsbuildPlugins,
Expand Down Expand Up @@ -148,6 +151,8 @@ export async function createRspackBuilder(
// builder plugins should be registered earlier than user plugins
rsbuildConfig.plugins = [...rsbuildPlugins, ...(rsbuildConfig.plugins || [])];

// rsbuildPlugins.push

const rsbuild = await createRsbuild({
cwd,
rsbuildConfig,
Expand Down
17 changes: 17 additions & 0 deletions packages/cli/builder/src/shared/plugins/nativeWatcher.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import type { RsbuildPlugin } from '@rsbuild/core';

/**
* Enable native watcher for Rspack.
*/
export const pluginNativeWatcher = (): RsbuildPlugin => ({
name: 'builder:native-watcher',

setup(api) {
api.modifyRspackConfig(config => {
config.experiments = {
...(config.experiments || {}),
nativeWatcher: true,
};
});
},
});
5 changes: 5 additions & 0 deletions packages/cli/builder/tests/__snapshots__/default.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ exports[`builder rspack > should generator rspack config correctly 1`] = `
},
"experiments": {
"asyncWebAssembly": true,
"nativeWatcher": true,
"rspackFuture": {
"bundlerInfo": {
"force": false,
Expand Down Expand Up @@ -1281,6 +1282,7 @@ exports[`builder rspack > should generator rspack config correctly 2`] = `
"rsbuild:svgr",
"rsbuild:css-minimizer",
"builder:postcss-plugins",
"builder:native-watcher",
"user-plugin",
]
`;
Expand All @@ -1296,6 +1298,7 @@ exports[`builder rspack > should generator rspack config correctly when node 1`]
},
"experiments": {
"asyncWebAssembly": true,
"nativeWatcher": true,
"rspackFuture": {
"bundlerInfo": {
"force": false,
Expand Down Expand Up @@ -2141,6 +2144,7 @@ exports[`builder rspack > should generator rspack config correctly when prod 1`]
},
"experiments": {
"asyncWebAssembly": true,
"nativeWatcher": true,
"rspackFuture": {
"bundlerInfo": {
"force": false,
Expand Down Expand Up @@ -3419,6 +3423,7 @@ exports[`builder rspack > should generator rspack config correctly when service-
},
"experiments": {
"asyncWebAssembly": true,
"nativeWatcher": true,
"rspackFuture": {
"bundlerInfo": {
"force": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ exports[`builder environment compat > should generator environment config correc
},
"experiments": {
"asyncWebAssembly": true,
"nativeWatcher": true,
"rspackFuture": {
"bundlerInfo": {
"force": false,
Expand Down Expand Up @@ -1255,6 +1256,7 @@ exports[`builder environment compat > should generator environment config correc
},
"experiments": {
"asyncWebAssembly": true,
"nativeWatcher": true,
"rspackFuture": {
"bundlerInfo": {
"force": false,
Expand Down Expand Up @@ -2061,6 +2063,7 @@ exports[`builder environment compat > should generator environment config correc
},
"experiments": {
"asyncWebAssembly": true,
"nativeWatcher": true,
"rspackFuture": {
"bundlerInfo": {
"force": false,
Expand Down
Loading