@modern-js/uni-builder 2.67.11 → 2.68.1

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.
@@ -128,12 +128,13 @@ async function parseConfig(uniBuilderConfig, options) {
128
128
  var _uniBuilderConfig_server_rsc;
129
129
  const enableRsc = (_uniBuilderConfig_server_rsc = (_uniBuilderConfig_server = uniBuilderConfig.server) === null || _uniBuilderConfig_server === void 0 ? void 0 : _uniBuilderConfig_server.rsc) !== null && _uniBuilderConfig_server_rsc !== void 0 ? _uniBuilderConfig_server_rsc : false;
130
130
  if (enableRsc) {
131
- const { rscClientRuntimePath, rscServerRuntimePath } = options;
131
+ const { rscClientRuntimePath, rscServerRuntimePath, internalDirectory } = options;
132
132
  rsbuildPlugins.push((0, import_rsbuild_rsc_plugin.rsbuildRscPlugin)({
133
133
  appDir: options.cwd,
134
134
  isRspack: true,
135
135
  rscClientRuntimePath,
136
- rscServerRuntimePath
136
+ rscServerRuntimePath,
137
+ internalDirectory
137
138
  }));
138
139
  }
139
140
  return {
@@ -25,14 +25,21 @@ var import_utils = require("@modern-js/utils");
25
25
  var import_ts_deepmerge = require("ts-deepmerge");
26
26
  const transformDevSetupMiddlewares = (seuptMiddlewares) => {
27
27
  if (seuptMiddlewares) {
28
- const newSetupMiddlewares = seuptMiddlewares.map((handler) => (_, server) => {
28
+ const newSetupMiddlewares = Array.isArray(seuptMiddlewares) ? seuptMiddlewares.map((handler) => (_, server) => {
29
29
  handler({
30
30
  unshift() {
31
31
  },
32
32
  push() {
33
33
  }
34
34
  }, server);
35
- });
35
+ }) : (_, server) => {
36
+ seuptMiddlewares({
37
+ unshift() {
38
+ },
39
+ push() {
40
+ }
41
+ }, server);
42
+ };
36
43
  return newSetupMiddlewares;
37
44
  }
38
45
  return void 0;
@@ -83,7 +90,8 @@ const transformToRsbuildServerOptions = (dev, devServer) => {
83
90
  proxy: newDevServerConfig.proxy,
84
91
  port,
85
92
  host,
86
- https: https ? https : void 0
93
+ https: https ? https : void 0,
94
+ middlewareMode: true
87
95
  };
88
96
  if (!(0, import_utils.isProd)() && startUrl) {
89
97
  server.open = beforeStartUrl ? {
@@ -80,7 +80,7 @@ async function parseCommonConfig(uniBuilderConfig, options) {
80
80
  var _uniBuilderConfig_output, _uniBuilderConfig_tools;
81
81
  var _rsbuildConfig_tools, _output, _output_distPath, _output1, _extraConfig, _html, _extraConfig1;
82
82
  const frameworkConfigPath = options === null || options === void 0 ? void 0 : options.frameworkConfigPath;
83
- const { plugins: [...plugins] = [], performance: { ...performanceConfig } = {}, output: { disableFilenameHash, enableLatestDecorators, cssModuleLocalIdentName, enableInlineScripts, disableCssExtract, enableInlineStyles, enableCssModuleTSDeclaration, disableCssModuleExtension, disableTsChecker, disableSvgr, svgDefaultExport, assetsRetry, enableAssetFallback, enableAssetManifest, disableSourceMap, sourceMap, convertToRem, disableMinimize, polyfill, dataUriLimit = 1e4, distPath = {}, ...outputConfig } = {}, html: { disableHtmlFolder, metaByEntries, titleByEntries, faviconByEntries, injectByEntries, templateByEntries, templateParametersByEntries, tagsByEntries, outputStructure, appIcon, tags, ...htmlConfig } = {}, source: { alias, globalVars, resolveMainFields, resolveExtensionPrefix, transformImport, ...sourceConfig } = {}, dev, security: { checkSyntax, sri, ...securityConfig } = {}, tools: { devServer, tsChecker, minifyCss, less, sass, htmlPlugin, autoprefixer, ...toolsConfig } = {}, environments = {} } = uniBuilderConfig;
83
+ const { plugins: [...plugins] = [], performance: { ...performanceConfig } = {}, output: { disableFilenameHash, enableLatestDecorators, cssModuleLocalIdentName, enableInlineScripts, disableCssExtract, enableInlineStyles, enableCssModuleTSDeclaration, disableCssModuleExtension, disableTsChecker, disableSvgr, svgDefaultExport, assetsRetry, enableAssetFallback, enableAssetManifest, disableSourceMap, sourceMap, convertToRem, disableMinimize, polyfill, dataUriLimit = 1e4, distPath = {}, ...outputConfig } = {}, html: { disableHtmlFolder, metaByEntries, titleByEntries, faviconByEntries, injectByEntries, templateByEntries, templateParametersByEntries, tagsByEntries, outputStructure, appIcon, tags, ...htmlConfig } = {}, source: { alias, globalVars, resolveMainFields, resolveExtensionPrefix, transformImport, ...sourceConfig } = {}, dev, security: { checkSyntax, sri, ...securityConfig } = {}, tools: { devServer, tsChecker, minifyCss, less, sass, htmlPlugin, autoprefixer, ...toolsConfig } = {}, environments = {}, resolve = {} } = uniBuilderConfig;
84
84
  const rsbuildConfig = {
85
85
  plugins,
86
86
  output: {
@@ -89,6 +89,7 @@ async function parseCommonConfig(uniBuilderConfig, options) {
89
89
  sourceMap,
90
90
  ...outputConfig
91
91
  },
92
+ resolve,
92
93
  source: {
93
94
  alias,
94
95
  ...sourceConfig
@@ -99,6 +100,10 @@ async function parseCommonConfig(uniBuilderConfig, options) {
99
100
  security: securityConfig,
100
101
  environments
101
102
  };
103
+ if (typeof alias === "object" && Object.keys(alias).length === 0) {
104
+ var _rsbuildConfig_source;
105
+ (_rsbuildConfig_source = rsbuildConfig.source) === null || _rsbuildConfig_source === void 0 ? true : delete _rsbuildConfig_source.alias;
106
+ }
102
107
  rsbuildConfig.tools.htmlPlugin = htmlPlugin;
103
108
  var _lightningcssLoader;
104
109
  (_lightningcssLoader = (_rsbuildConfig_tools = rsbuildConfig.tools).lightningcssLoader) !== null && _lightningcssLoader !== void 0 ? _lightningcssLoader : _rsbuildConfig_tools.lightningcssLoader = false;
@@ -50,11 +50,15 @@ const sharedData = {
50
50
  }
51
51
  };
52
52
  function setBuildInfo(mod, property) {
53
- mod.buildInfo = mod.buildInfo || {};
53
+ if (!mod.buildInfo) {
54
+ mod.buildInfo = {};
55
+ }
54
56
  Object.assign(mod.buildInfo, property);
55
57
  }
56
58
  function setRscBuildInfo(mod, property) {
57
- mod.buildInfo = mod.buildInfo || {};
59
+ if (!mod.buildInfo) {
60
+ mod.buildInfo = {};
61
+ }
58
62
  const rscBuildInfo = mod.buildInfo[MODERN_RSC_INFO] || {};
59
63
  Object.assign(rscBuildInfo, property);
60
64
  setBuildInfo(mod, {
@@ -1,7 +1,8 @@
1
1
  import type { RsbuildPlugin } from '@rsbuild/core';
2
- export declare const rsbuildRscPlugin: ({ appDir, isRspack, rscClientRuntimePath, rscServerRuntimePath, }: {
2
+ export declare const rsbuildRscPlugin: ({ appDir, isRspack, rscClientRuntimePath, rscServerRuntimePath, internalDirectory, }: {
3
3
  appDir: string;
4
4
  isRspack?: boolean;
5
5
  rscClientRuntimePath?: string;
6
6
  rscServerRuntimePath?: string;
7
+ internalDirectory?: string;
7
8
  }) => RsbuildPlugin;
@@ -67,7 +67,7 @@ const checkReactVersionAtLeast19 = async (appDir) => {
67
67
  }
68
68
  return reactMajor >= 19 && reactDomMajor >= 19;
69
69
  };
70
- const rsbuildRscPlugin = ({ appDir, isRspack = true, rscClientRuntimePath, rscServerRuntimePath }) => ({
70
+ const rsbuildRscPlugin = ({ appDir, isRspack = true, rscClientRuntimePath, rscServerRuntimePath, internalDirectory }) => ({
71
71
  name: "uni-builder:rsc-rsbuild-plugin",
72
72
  setup(api) {
73
73
  api.modifyBundlerChain({
@@ -90,12 +90,14 @@ const rsbuildRscPlugin = ({ appDir, isRspack = true, rscClientRuntimePath, rscSe
90
90
  const jsLoaderOptions = originalJsRule.use(JSRule).get("options");
91
91
  const jsLoaderPath = originalJsRule.use(JSRule).get("loader");
92
92
  originalJsRule.uses.delete(JSRule);
93
- chain.module.rule(CHAIN_ID.RULE.JS).oneOf("rsc-server").issuerLayer(import_common.webpackRscLayerName).use("rsc-server-loader").loader(require.resolve("../rsc-server-loader")).options({
93
+ chain.module.rule(CHAIN_ID.RULE.JS).oneOf("rsc-server").issuerLayer(import_common.webpackRscLayerName).exclude.add(/universal[/\\]async_storage/).end().use("rsc-server-loader").loader(require.resolve("../rsc-server-loader")).options({
94
94
  entryPath2Name,
95
95
  appDir,
96
- runtimePath: rscServerRuntimePath
97
- }).end().use(JSRule).loader(jsLoaderPath).options(jsLoaderOptions).end().end().oneOf("rsc-ssr").use("rsc-ssr-loader").loader(require.resolve("../rsc-ssr-loader")).options({
98
- entryPath2Name
96
+ runtimePath: rscServerRuntimePath,
97
+ internalDirectory
98
+ }).end().use(JSRule).loader(jsLoaderPath).options(jsLoaderOptions).end().end().oneOf("rsc-ssr").exclude.add(/universal[/\\]async_storage/).end().use("rsc-ssr-loader").loader(require.resolve("../rsc-ssr-loader")).options({
99
+ entryPath2Name,
100
+ internalDirectory
99
101
  }).end().use(JSRule).loader(jsLoaderPath).options(jsLoaderOptions).end().end();
100
102
  }
101
103
  };
@@ -104,9 +106,11 @@ const rsbuildRscPlugin = ({ appDir, isRspack = true, rscClientRuntimePath, rscSe
104
106
  ...chain.experiments,
105
107
  layers: true
106
108
  });
109
+ const routesFileReg = new RegExp(`${internalDirectory.replace(/[/\\]/g, "[/\\\\]")}[/\\\\][^/\\\\]*[/\\\\]routes`);
107
110
  chain.module.rule("server-module").resource([
108
111
  /render[/\\].*[/\\]server[/\\]rsc/,
109
- /AppProxy/
112
+ /AppProxy/,
113
+ routesFileReg
110
114
  ]).layer(import_common.webpackRscLayerName).end();
111
115
  chain.module.rule(import_common.webpackRscLayerName).issuerLayer(import_common.webpackRscLayerName).resolve.conditionNames.add(import_common.webpackRscLayerName).add("...");
112
116
  chain.module.rule("rsc-common").resource([
@@ -139,11 +143,6 @@ const rsbuildRscPlugin = ({ appDir, isRspack = true, rscClientRuntimePath, rscSe
139
143
  const ClientPlugin = isRspack ? import_rspack_rsc_client_plugin.RspackRscClientPlugin : import_rsc_client_plugin.RscClientPlugin;
140
144
  chain.plugin("rsc-client-plugin").use(ClientPlugin);
141
145
  };
142
- const configureRuntimeChunk = () => {
143
- chain.optimization.runtimeChunk({
144
- name: (entrypoint) => `runtime-${entrypoint.name}`
145
- });
146
- };
147
146
  if (isServer) {
148
147
  chain.name("server");
149
148
  layerHandler();
@@ -157,7 +156,6 @@ const rsbuildRscPlugin = ({ appDir, isRspack = true, rscClientRuntimePath, rscSe
157
156
  ]);
158
157
  addRscClientLoader();
159
158
  addRscClientPlugin();
160
- configureRuntimeChunk();
161
159
  }
162
160
  },
163
161
  order: "post"
@@ -14,7 +14,15 @@ export declare class RscServerPlugin {
14
14
  private serverManifestFilename;
15
15
  private entryPath2Name;
16
16
  private styles;
17
+ private moduleToEntries;
17
18
  constructor(options: RscServerPluginOptions);
19
+ private isValidModule;
20
+ private hasValidEntries;
21
+ private traverseModulesFromEntry;
18
22
  private findModuleEntries;
23
+ private getEntryNameFromIssuer;
24
+ private createEntryFromIssuer;
25
+ private buildModuleToEntriesMapping;
26
+ private getEntryPathByName;
19
27
  apply(compiler: Webpack.Compiler): void;
20
28
  }
@@ -25,15 +25,50 @@ var import_webpack = require("webpack");
25
25
  var import_common = require("../common");
26
26
  const resourcePath2Entries = /* @__PURE__ */ new Map();
27
27
  class RscServerPlugin {
28
- findModuleEntries(module2, compilation, resourcePath2Entries2, visited = /* @__PURE__ */ new Set()) {
28
+ isValidModule(module2) {
29
+ return Boolean(module2 === null || module2 === void 0 ? void 0 : module2.resource);
30
+ }
31
+ hasValidEntries(entries) {
32
+ return Boolean(entries && entries.length > 0);
33
+ }
34
+ traverseModulesFromEntry(module2, entryName, moduleGraph, visited) {
29
35
  if (!(module2 === null || module2 === void 0 ? void 0 : module2.resource) || visited.has(module2.resource)) {
36
+ return;
37
+ }
38
+ visited.add(module2.resource);
39
+ if (!this.moduleToEntries.has(module2.resource)) {
40
+ this.moduleToEntries.set(module2.resource, /* @__PURE__ */ new Set());
41
+ }
42
+ this.moduleToEntries.get(module2.resource).add(entryName);
43
+ for (const connection of moduleGraph.getOutgoingConnections(module2)) {
44
+ if (connection.module && "resource" in connection.module) {
45
+ this.traverseModulesFromEntry(connection.module, entryName, moduleGraph, visited);
46
+ }
47
+ }
48
+ }
49
+ findModuleEntries(module2, compilation, resourcePath2Entries2, visited = /* @__PURE__ */ new Set()) {
50
+ if (!this.isValidModule(module2) || visited.has(module2.resource)) {
30
51
  return [];
31
52
  }
32
53
  visited.add(module2.resource);
33
54
  const currentEntries = resourcePath2Entries2.get(module2.resource);
34
- if (currentEntries && (currentEntries === null || currentEntries === void 0 ? void 0 : currentEntries.length) > 0) {
55
+ if (this.hasValidEntries(currentEntries)) {
35
56
  return currentEntries;
36
57
  }
58
+ const entryNames = this.moduleToEntries.get(module2.resource);
59
+ if (entryNames && entryNames.size > 0) {
60
+ const entries = [];
61
+ for (const entryName2 of entryNames) {
62
+ const entryPath = this.getEntryPathByName(entryName2, compilation);
63
+ if (entryPath) {
64
+ entries.push({
65
+ entryName: entryName2,
66
+ entryPath
67
+ });
68
+ }
69
+ }
70
+ return entries;
71
+ }
37
72
  const issuer = (0, import_common.findRootIssuer)(compilation.moduleGraph, module2);
38
73
  if (!issuer) {
39
74
  return [];
@@ -42,19 +77,42 @@ class RscServerPlugin {
42
77
  if (issuerEntries.length > 0) {
43
78
  return issuerEntries;
44
79
  }
45
- if (issuer.resource) {
46
- const entryName = this.entryPath2Name.get(issuer.resource);
47
- if (entryName) {
48
- return [
49
- {
50
- entryName,
51
- entryPath: issuer.resource
52
- }
53
- ];
54
- }
80
+ const entryName = this.getEntryNameFromIssuer(issuer);
81
+ if (entryName) {
82
+ return [
83
+ this.createEntryFromIssuer(issuer, entryName)
84
+ ];
55
85
  }
56
86
  return [];
57
87
  }
88
+ getEntryNameFromIssuer(issuer) {
89
+ return issuer.resource ? this.entryPath2Name.get(issuer.resource) : void 0;
90
+ }
91
+ createEntryFromIssuer(issuer, entryName) {
92
+ return {
93
+ entryName,
94
+ entryPath: issuer.resource
95
+ };
96
+ }
97
+ buildModuleToEntriesMapping(compilation) {
98
+ this.moduleToEntries.clear();
99
+ for (const [entryName, entryDependency] of compilation.entries.entries()) {
100
+ const entryModule = compilation.moduleGraph.getModule(entryDependency.dependencies[0]);
101
+ if (!entryModule)
102
+ continue;
103
+ this.traverseModulesFromEntry(entryModule, entryName, compilation.moduleGraph, /* @__PURE__ */ new Set());
104
+ }
105
+ }
106
+ getEntryPathByName(entryName, compilation) {
107
+ const entryDependency = compilation.entries.get(entryName);
108
+ if (entryDependency && entryDependency.dependencies.length > 0) {
109
+ const firstDep = entryDependency.dependencies[0];
110
+ if ("request" in firstDep && typeof firstDep.request === "string") {
111
+ return firstDep.request;
112
+ }
113
+ }
114
+ return void 0;
115
+ }
58
116
  apply(compiler) {
59
117
  const { EntryPlugin, WebpackError, dependencies: { NullDependency }, sources: { RawSource }, RuntimeGlobals } = compiler.webpack;
60
118
  class ServerReferenceDependency extends NullDependency {
@@ -107,6 +165,7 @@ class RscServerPlugin {
107
165
  };
108
166
  let needsAdditionalPass = false;
109
167
  compiler.hooks.finishMake.tapPromise(RscServerPlugin.name, async (compilation) => {
168
+ this.buildModuleToEntriesMapping(compilation);
110
169
  const processModules = (modules) => {
111
170
  let hasChangeReference2 = false;
112
171
  for (const module2 of modules) {
@@ -261,6 +320,7 @@ class RscServerPlugin {
261
320
  this.serverReferencesMap = /* @__PURE__ */ new Map();
262
321
  this.serverManifest = {};
263
322
  this.entryPath2Name = /* @__PURE__ */ new Map();
323
+ this.moduleToEntries = /* @__PURE__ */ new Map();
264
324
  this.styles = /* @__PURE__ */ new Set();
265
325
  this.serverManifestFilename = (options === null || options === void 0 ? void 0 : options.serverManifestFilename) || `react-server-manifest.json`;
266
326
  this.entryPath2Name = (options === null || options === void 0 ? void 0 : options.entryPath2Name) || /* @__PURE__ */ new Map();
@@ -18,11 +18,15 @@ export declare class RscServerPlugin {
18
18
  private serverManifestFilename;
19
19
  private entryPath2Name;
20
20
  private styles;
21
+ private moduleToEntries;
21
22
  constructor(options: RscServerPluginOptions);
22
23
  private isValidModule;
23
24
  private hasValidEntries;
24
25
  private getEntryNameFromIssuer;
25
26
  private createEntryFromIssuer;
27
+ private buildModuleToEntriesMapping;
28
+ private traverseModulesFromEntry;
26
29
  private findModuleEntries;
30
+ private getEntryPathByName;
27
31
  apply(compiler: Webpack.Compiler): void;
28
32
  }
@@ -39,6 +39,30 @@ class RscServerPlugin {
39
39
  entryPath: issuer.resource
40
40
  };
41
41
  }
42
+ buildModuleToEntriesMapping(compilation) {
43
+ this.moduleToEntries.clear();
44
+ for (const [entryName, entryDependency] of compilation.entries.entries()) {
45
+ const entryModule = compilation.moduleGraph.getModule(entryDependency.dependencies[0]);
46
+ if (!entryModule)
47
+ continue;
48
+ this.traverseModulesFromEntry(entryModule, entryName, compilation.moduleGraph, /* @__PURE__ */ new Set());
49
+ }
50
+ }
51
+ traverseModulesFromEntry(module2, entryName, moduleGraph, visited) {
52
+ if (!(module2 === null || module2 === void 0 ? void 0 : module2.resource) || visited.has(module2.resource)) {
53
+ return;
54
+ }
55
+ visited.add(module2.resource);
56
+ if (!this.moduleToEntries.has(module2.resource)) {
57
+ this.moduleToEntries.set(module2.resource, /* @__PURE__ */ new Set());
58
+ }
59
+ this.moduleToEntries.get(module2.resource).add(entryName);
60
+ for (const connection of moduleGraph.getOutgoingConnections(module2)) {
61
+ if (connection.module && "resource" in connection.module) {
62
+ this.traverseModulesFromEntry(connection.module, entryName, moduleGraph, visited);
63
+ }
64
+ }
65
+ }
42
66
  findModuleEntries(module2, compilation, resourcePath2Entries2, visited = /* @__PURE__ */ new Set()) {
43
67
  if (!this.isValidModule(module2) || visited.has(module2.resource)) {
44
68
  return [];
@@ -48,12 +72,26 @@ class RscServerPlugin {
48
72
  if (this.hasValidEntries(currentEntries)) {
49
73
  return currentEntries;
50
74
  }
75
+ const entryNames = this.moduleToEntries.get(module2.resource);
76
+ if (entryNames && entryNames.size > 0) {
77
+ const entries = [];
78
+ for (const entryName2 of entryNames) {
79
+ const entryPath = this.getEntryPathByName(entryName2, compilation);
80
+ if (entryPath) {
81
+ entries.push({
82
+ entryName: entryName2,
83
+ entryPath
84
+ });
85
+ }
86
+ }
87
+ return entries;
88
+ }
51
89
  const issuer = (0, import_common.findRootIssuer)(compilation.moduleGraph, module2);
52
90
  if (!issuer) {
53
91
  return [];
54
92
  }
55
93
  const issuerEntries = this.findModuleEntries(issuer, compilation, resourcePath2Entries2, visited);
56
- if (this.hasValidEntries(issuerEntries)) {
94
+ if (issuerEntries.length > 0) {
57
95
  return issuerEntries;
58
96
  }
59
97
  const entryName = this.getEntryNameFromIssuer(issuer);
@@ -64,6 +102,16 @@ class RscServerPlugin {
64
102
  }
65
103
  return [];
66
104
  }
105
+ getEntryPathByName(entryName, compilation) {
106
+ const entryDependency = compilation.entries.get(entryName);
107
+ if (entryDependency && entryDependency.dependencies.length > 0) {
108
+ const firstDep = entryDependency.dependencies[0];
109
+ if ("request" in firstDep && typeof firstDep.request === "string") {
110
+ return firstDep.request;
111
+ }
112
+ }
113
+ return void 0;
114
+ }
67
115
  apply(compiler) {
68
116
  const { EntryPlugin, WebpackError, sources: { RawSource } } = compiler.webpack;
69
117
  const includeModule = async (compilation, resource, resourceEntryNames, layer) => {
@@ -103,6 +151,7 @@ class RscServerPlugin {
103
151
  };
104
152
  let needsAdditionalPass = false;
105
153
  compiler.hooks.finishMake.tapPromise(RscServerPlugin.name, async (compilation) => {
154
+ this.buildModuleToEntriesMapping(compilation);
106
155
  const processModules = (modules) => {
107
156
  let hasChangeReference2 = false;
108
157
  for (const module2 of modules) {
@@ -231,6 +280,7 @@ class RscServerPlugin {
231
280
  this.serverReferencesMap = /* @__PURE__ */ new Map();
232
281
  this.serverManifest = {};
233
282
  this.entryPath2Name = /* @__PURE__ */ new Map();
283
+ this.moduleToEntries = /* @__PURE__ */ new Map();
234
284
  this.styles = /* @__PURE__ */ new Set();
235
285
  this.serverManifestFilename = (options === null || options === void 0 ? void 0 : options.serverManifestFilename) || `react-server-manifest.json`;
236
286
  this.entryPath2Name = (options === null || options === void 0 ? void 0 : options.entryPath2Name) || /* @__PURE__ */ new Map();
@@ -67,7 +67,8 @@ async function rscServerLoader(source) {
67
67
  ]
68
68
  ]
69
69
  }
70
- }
70
+ },
71
+ isModule: true
71
72
  });
72
73
  const { code, map } = result;
73
74
  const metadata = extractMetadata(code);
package/dist/types.d.ts CHANGED
@@ -41,6 +41,7 @@ export type CreateBuilderCommonOptions = {
41
41
  cwd: string;
42
42
  rscClientRuntimePath?: string;
43
43
  rscServerRuntimePath?: string;
44
+ internalDirectory?: string;
44
45
  };
45
46
  export type BundlerType = 'rspack' | 'webpack';
46
47
  export type CreateUniBuilderOptions = {
@@ -384,6 +385,7 @@ export type UniBuilderConfig = {
384
385
  performance?: RsbuildConfig['performance'];
385
386
  security?: Omit<SecurityConfig, 'sri'>;
386
387
  tools?: Omit<ToolsConfig, 'htmlPlugin'>;
388
+ resolve?: RsbuildConfig['resolve'];
387
389
  source?: Omit<SourceConfig, 'alias' | 'transformImport'>;
388
390
  plugins?: RsbuildPlugins;
389
391
  environments?: {
@@ -39,6 +39,7 @@ var import_postcss = require("../shared/plugins/postcss");
39
39
  var import_rsbuild_rsc_plugin = require("../shared/rsc/plugins/rsbuild-rsc-plugin");
40
40
  var import_utils = require("../shared/utils");
41
41
  var import_babel = require("./plugins/babel");
42
+ var import_include = require("./plugins/include");
42
43
  var import_moduleScopes = require("./plugins/moduleScopes");
43
44
  var import_react = require("./plugins/react");
44
45
  async function parseConfig(uniBuilderConfig, options) {
@@ -100,12 +101,13 @@ async function parseConfig(uniBuilderConfig, options) {
100
101
  var _uniBuilderConfig_server_rsc;
101
102
  const enableRsc = (_uniBuilderConfig_server_rsc = (_uniBuilderConfig_server = uniBuilderConfig.server) === null || _uniBuilderConfig_server === void 0 ? void 0 : _uniBuilderConfig_server.rsc) !== null && _uniBuilderConfig_server_rsc !== void 0 ? _uniBuilderConfig_server_rsc : false;
102
103
  if (enableRsc) {
103
- const { rscClientRuntimePath, rscServerRuntimePath } = options;
104
+ const { rscClientRuntimePath, rscServerRuntimePath, internalDirectory } = options;
104
105
  rsbuildPlugins.push((0, import_rsbuild_rsc_plugin.rsbuildRscPlugin)({
105
106
  appDir: options.cwd,
106
107
  isRspack: false,
107
108
  rscClientRuntimePath,
108
- rscServerRuntimePath
109
+ rscServerRuntimePath,
110
+ internalDirectory
109
111
  }));
110
112
  }
111
113
  if ((_uniBuilderConfig_tools1 = uniBuilderConfig.tools) === null || _uniBuilderConfig_tools1 === void 0 ? void 0 : _uniBuilderConfig_tools1.tsLoader) {
@@ -137,6 +139,7 @@ async function parseConfig(uniBuilderConfig, options) {
137
139
  rsbuildPlugins.push(pluginStyledComponents(options2));
138
140
  }
139
141
  rsbuildPlugins.push((0, import_moduleScopes.pluginModuleScopes)((_uniBuilderConfig_source = uniBuilderConfig.source) === null || _uniBuilderConfig_source === void 0 ? void 0 : _uniBuilderConfig_source.moduleScopes));
142
+ rsbuildPlugins.push((0, import_include.pluginInclude)());
140
143
  return {
141
144
  rsbuildConfig,
142
145
  rsbuildPlugins
@@ -0,0 +1,2 @@
1
+ import type { RsbuildPlugin } from '@rsbuild/core';
2
+ export declare const pluginInclude: () => RsbuildPlugin;
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var include_exports = {};
20
+ __export(include_exports, {
21
+ pluginInclude: () => pluginInclude
22
+ });
23
+ module.exports = __toCommonJS(include_exports);
24
+ const pluginInclude = () => ({
25
+ name: "uni-builder:babel-include",
26
+ setup(api) {
27
+ api.modifyWebpackChain((chain, { CHAIN_ID }) => {
28
+ const includes = chain.module.rule(CHAIN_ID.RULE.JS).include.values();
29
+ includes.forEach((include) => {
30
+ if (typeof include === "object" && !Array.isArray(include) && !(include instanceof RegExp) && include.not && include.not.toString() === /[\\/]node_modules[\\/]/.toString()) {
31
+ include.and = [
32
+ api.context.rootPath || process.cwd(),
33
+ {
34
+ not: include.not
35
+ }
36
+ ];
37
+ delete include.not;
38
+ }
39
+ });
40
+ });
41
+ }
42
+ });
43
+ // Annotate the CommonJS export names for ESM import in node:
44
+ 0 && (module.exports = {
45
+ pluginInclude
46
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@modern-js/uni-builder",
3
- "version": "2.67.11",
3
+ "version": "2.68.1",
4
4
  "description": "Unified builder for Modern.js",
5
5
  "repository": {
6
6
  "type": "git",
@@ -30,19 +30,19 @@
30
30
  "@babel/preset-react": "^7.22.15",
31
31
  "@babel/types": "^7.26.0",
32
32
  "@pmmmwh/react-refresh-webpack-plugin": "0.5.16",
33
- "@rsbuild/core": "1.3.22",
34
- "@rsbuild/plugin-assets-retry": "1.3.0",
33
+ "@rsbuild/core": "1.4.4",
34
+ "@rsbuild/plugin-assets-retry": "1.4.0",
35
35
  "@rsbuild/plugin-babel": "1.0.5",
36
36
  "@rsbuild/plugin-check-syntax": "1.3.0",
37
37
  "@rsbuild/plugin-css-minimizer": "1.0.2",
38
- "@rsbuild/plugin-less": "1.2.4",
38
+ "@rsbuild/plugin-less": "1.2.5",
39
39
  "@rsbuild/plugin-pug": "1.3.1",
40
- "@rsbuild/plugin-react": "1.3.2",
40
+ "@rsbuild/plugin-react": "1.3.4",
41
41
  "@rsbuild/plugin-rem": "1.0.2",
42
- "@rsbuild/plugin-sass": "1.3.2",
42
+ "@rsbuild/plugin-sass": "1.3.3",
43
43
  "@rsbuild/plugin-source-build": "1.0.2",
44
- "@rsbuild/plugin-styled-components": "1.3.0",
45
- "@rsbuild/plugin-svgr": "1.2.0",
44
+ "@rsbuild/plugin-styled-components": "1.4.0",
45
+ "@rsbuild/plugin-svgr": "1.2.1",
46
46
  "@rsbuild/plugin-toml": "1.1.0",
47
47
  "@rsbuild/plugin-type-check": "1.2.3",
48
48
  "@rsbuild/plugin-typed-css-modules": "1.0.2",
@@ -64,8 +64,8 @@
64
64
  "jiti": "1.21.7",
65
65
  "lodash": "^4.17.21",
66
66
  "magic-string": "0.30.17",
67
- "picocolors": "^1.0.1",
68
- "postcss": "^8.4.35",
67
+ "picocolors": "^1.1.1",
68
+ "postcss": "^8.5.6",
69
69
  "postcss-custom-properties": "13.3.12",
70
70
  "postcss-flexbugs-fixes": "5.0.2",
71
71
  "postcss-font-variant": "5.0.0",
@@ -80,9 +80,9 @@
80
80
  "ts-loader": "9.4.4",
81
81
  "webpack": "^5.99.8",
82
82
  "webpack-subresource-integrity": "5.1.0",
83
- "@modern-js/babel-preset": "2.67.11",
84
- "@modern-js/flight-server-transform-plugin": "2.67.11",
85
- "@modern-js/utils": "2.67.11"
83
+ "@modern-js/babel-preset": "2.68.1",
84
+ "@modern-js/flight-server-transform-plugin": "2.68.1",
85
+ "@modern-js/utils": "2.68.1"
86
86
  },
87
87
  "devDependencies": {
88
88
  "@rsbuild/plugin-webpack-swc": "1.1.1",
@@ -93,7 +93,7 @@
93
93
  "react-dom": "^18.2.0",
94
94
  "terser": "^5.31.1",
95
95
  "typescript": "^5.3.0",
96
- "@modern-js/types": "2.67.11",
96
+ "@modern-js/types": "2.68.1",
97
97
  "@scripts/build": "2.66.0",
98
98
  "@scripts/vitest-config": "2.66.0"
99
99
  },