@bleedingdev/modern-js-builder 3.8.3-ultramodern.1 → 3.8.3-ultramodern.2

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.
Files changed (33) hide show
  1. package/dist/cjs/createBuilder.js +1 -4
  2. package/dist/cjs/plugins/rscConfig.js +0 -138
  3. package/dist/cjs/shared/parseCommonConfig.js +4 -12
  4. package/dist/esm/createBuilder.mjs +1 -4
  5. package/dist/esm/plugins/rscConfig.mjs +1 -136
  6. package/dist/esm/shared/parseCommonConfig.mjs +4 -12
  7. package/dist/esm-node/createBuilder.mjs +1 -4
  8. package/dist/esm-node/plugins/rscConfig.mjs +1 -136
  9. package/dist/esm-node/shared/parseCommonConfig.mjs +4 -12
  10. package/dist/types/plugins/rscConfig.d.ts +0 -32
  11. package/dist/types/shared/parseCommonConfig.d.ts +0 -2
  12. package/dist/types/types.d.ts +1 -12
  13. package/package.json +5 -6
  14. package/dist/cjs/plugins/environmentBuildCache.js +0 -89
  15. package/dist/cjs/plugins/rsdoctor.js +0 -68
  16. package/dist/cjs/plugins/rspack21.js +0 -57
  17. package/dist/cjs/rsdoctorConfig.js +0 -18
  18. package/dist/cjs/shared/tsgo.js +0 -212
  19. package/dist/esm/plugins/environmentBuildCache.mjs +0 -38
  20. package/dist/esm/plugins/rsdoctor.mjs +0 -30
  21. package/dist/esm/plugins/rspack21.mjs +0 -19
  22. package/dist/esm/rsdoctorConfig.mjs +0 -0
  23. package/dist/esm/shared/tsgo.mjs +0 -160
  24. package/dist/esm-node/plugins/environmentBuildCache.mjs +0 -39
  25. package/dist/esm-node/plugins/rsdoctor.mjs +0 -31
  26. package/dist/esm-node/plugins/rspack21.mjs +0 -20
  27. package/dist/esm-node/rsdoctorConfig.mjs +0 -1
  28. package/dist/esm-node/shared/tsgo.mjs +0 -161
  29. package/dist/types/plugins/environmentBuildCache.d.ts +0 -3
  30. package/dist/types/plugins/rsdoctor.d.ts +0 -3
  31. package/dist/types/plugins/rspack21.d.ts +0 -4
  32. package/dist/types/rsdoctorConfig.d.ts +0 -12
  33. package/dist/types/shared/tsgo.d.ts +0 -12
@@ -33,13 +33,12 @@ __webpack_require__.d(__webpack_exports__, {
33
33
  });
34
34
  const core_namespaceObject = require("@rsbuild/core");
35
35
  const rscConfig_js_namespaceObject = require("./plugins/rscConfig.js");
36
- const rsdoctor_js_namespaceObject = require("./plugins/rsdoctor.js");
37
36
  const parseCommonConfig_js_namespaceObject = require("./shared/parseCommonConfig.js");
38
37
  const rscDisabledRuntime_js_namespaceObject = require("./shared/rsc/rscDisabledRuntime.js");
39
38
  async function parseConfig(builderConfig, options) {
40
39
  builderConfig.performance ??= {};
41
40
  builderConfig.performance.buildCache ??= true;
42
- const { rsbuildConfig, rsbuildPlugins, rsdoctorConfig } = await (0, parseCommonConfig_js_namespaceObject.parseCommonConfig)(builderConfig, options);
41
+ const { rsbuildConfig, rsbuildPlugins } = await (0, parseCommonConfig_js_namespaceObject.parseCommonConfig)(builderConfig, options);
43
42
  const { sri } = builderConfig.security || {};
44
43
  if (sri) if (true === sri) rsbuildConfig.security.sri = {
45
44
  enable: 'auto'
@@ -67,8 +66,6 @@ async function parseConfig(builderConfig, options) {
67
66
  ...rsbuildConfig.plugins ?? [],
68
67
  (0, rscDisabledRuntime_js_namespaceObject.rscDisabledRuntimePlugin)()
69
68
  ];
70
- const rsdoctorPlugin = (0, rsdoctor_js_namespaceObject.pluginRsdoctor)(rsdoctorConfig);
71
- if (rsdoctorPlugin) rsbuildPlugins.push(rsdoctorPlugin);
72
69
  return {
73
70
  rsbuildConfig,
74
71
  rsbuildPlugins
@@ -38,7 +38,6 @@ var __webpack_exports__ = {};
38
38
  __webpack_require__.r(__webpack_exports__);
39
39
  __webpack_require__.d(__webpack_exports__, {
40
40
  createRscLayerMatchers: ()=>createRscLayerMatchers,
41
- enrichServerOnlyDiagnostics: ()=>enrichServerOnlyDiagnostics,
42
41
  getRscPlugins: ()=>getRscPlugins,
43
42
  pluginRscConfig: ()=>pluginRscConfig
44
43
  });
@@ -52,9 +51,6 @@ const RENDER_RSC_RUNTIME = '@modern-js/render/rsc';
52
51
  const RENDER_RSC_WORKER_RUNTIME = '@modern-js/render/rsc-worker';
53
52
  const RSC_COMMON_LAYER = 'rsc-common';
54
53
  const ENTRY_NAME_VAR = '__MODERN_JS_ENTRY_NAME';
55
- const SERVER_ONLY_MARKER_PATTERN = /(?:^|[/\\])server-only[/\\]index\.js(?:\?|$)/;
56
- const SERVER_ONLY_MESSAGE_PATTERN = /server-only|server only|only works in a Server Component|cannot be imported (?:directly )?(?:from|into) (?:a )?Client Component/i;
57
- const SERVER_ONLY_DIAGNOSTIC_PREFIX = '[Modern.js RSC server-only diagnostic context]';
58
54
  const ROUTE_DATA_FILE_PATTERN = /[/\\]routes[/\\](?:.*[/\\])?(?:layout|page|\$)\.(?:loader|data)\.[tj]sx?(?:\?.*)?$/;
59
55
  const createVirtualModule = (content)=>`data:text/javascript,${encodeURIComponent(content)}`;
60
56
  const isAsyncStorageExclude = (exclude)=>{
@@ -62,134 +58,6 @@ const isAsyncStorageExclude = (exclude)=>{
62
58
  if (exclude instanceof RegExp) return exclude.test('universal/async_storage') || exclude.test('universal\\async_storage');
63
59
  return false;
64
60
  };
65
- const asRecord = (value)=>{
66
- if (value && 'object' == typeof value && !Array.isArray(value)) return value;
67
- };
68
- const disableReactCompilerInSwcLoaders = (value, seen = new WeakSet())=>{
69
- if (!value || 'object' != typeof value) return;
70
- if (seen.has(value)) return;
71
- seen.add(value);
72
- if (Array.isArray(value)) {
73
- for (const item of value)disableReactCompilerInSwcLoaders(item, seen);
74
- return;
75
- }
76
- const record = value;
77
- if ('builtin:swc-loader' === record.loader) {
78
- let options = asRecord(record.options);
79
- if (!options) {
80
- options = {};
81
- record.options = options;
82
- }
83
- let jsc = asRecord(options.jsc);
84
- if (!jsc) {
85
- jsc = {};
86
- options.jsc = jsc;
87
- }
88
- let transform = asRecord(jsc.transform);
89
- if (!transform) {
90
- transform = {};
91
- jsc.transform = transform;
92
- }
93
- transform.reactCompiler = false;
94
- }
95
- for (const item of Object.values(record))disableReactCompilerInSwcLoaders(item, seen);
96
- };
97
- const normalizeDiagnosticText = (diagnostic)=>[
98
- diagnostic.message,
99
- diagnostic.details,
100
- diagnostic.file,
101
- getModulePath(diagnostic.module),
102
- getModuleIdentifier(diagnostic.module)
103
- ].filter((item)=>Boolean(item)).join('\n');
104
- const isServerOnlyDiagnostic = (diagnostic)=>{
105
- const text = normalizeDiagnosticText(diagnostic);
106
- return SERVER_ONLY_MARKER_PATTERN.test(text) || SERVER_ONLY_MESSAGE_PATTERN.test(text);
107
- };
108
- const isEnrichedServerOnlyDiagnostic = (diagnostic)=>diagnostic.message.includes(SERVER_ONLY_DIAGNOSTIC_PREFIX) || diagnostic.details?.includes(SERVER_ONLY_DIAGNOSTIC_PREFIX);
109
- const getModulePath = (module)=>{
110
- if (!module) return;
111
- return module.resource || module.nameForCondition?.() || module.userRequest;
112
- };
113
- const getModuleIdentifier = (module)=>{
114
- if (!module) return;
115
- return getModulePath(module) || module.readableIdentifier?.() || module.identifier?.() || module.request || module.rawRequest;
116
- };
117
- const formatModuleContext = (module)=>{
118
- const id = getModuleIdentifier(module);
119
- if (!id) return;
120
- const layer = module?.layer ? ` [layer: ${module.layer}]` : '';
121
- return `${id}${layer}`;
122
- };
123
- const getIssuerChain = (compilation, module)=>{
124
- const chain = [];
125
- const seen = new Set();
126
- let current = module;
127
- while(current && !seen.has(current) && chain.length < 8){
128
- seen.add(current);
129
- const issuer = compilation.moduleGraph?.getIssuer?.(current);
130
- const formatted = formatModuleContext(issuer);
131
- if (!issuer || !formatted) break;
132
- chain.push(formatted);
133
- current = issuer;
134
- }
135
- return chain;
136
- };
137
- const getModuleTraceChain = (diagnostic)=>{
138
- const trace = diagnostic.moduleTrace || [];
139
- const chain = [];
140
- for (const item of trace){
141
- const formatted = formatModuleContext(item.origin) || item.originName || formatModuleContext(item.module) || item.moduleName;
142
- if (formatted && !chain.includes(formatted)) chain.push(formatted);
143
- }
144
- return chain.slice(0, 8);
145
- };
146
- const appendDiagnosticDetails = (diagnostic, lines)=>{
147
- const context = `${SERVER_ONLY_DIAGNOSTIC_PREFIX}\n${lines.join('\n')}`;
148
- diagnostic.details = diagnostic.details ? `${diagnostic.details}\n\n${context}` : context;
149
- };
150
- const enrichServerOnlyDiagnostics = (compilation, environmentName)=>{
151
- const diagnostics = [
152
- ...compilation.warnings,
153
- ...compilation.errors
154
- ];
155
- for (const diagnostic of diagnostics){
156
- if (!isServerOnlyDiagnostic(diagnostic) || isEnrichedServerOnlyDiagnostic(diagnostic)) continue;
157
- const lines = [
158
- `Environment: ${environmentName || compilation.name || 'unknown'}`
159
- ];
160
- const markerModule = formatModuleContext(diagnostic.module);
161
- if (markerModule) lines.push(`Matched module: ${markerModule}`);
162
- const issuerChain = getIssuerChain(compilation, diagnostic.module);
163
- const moduleTraceChain = getModuleTraceChain(diagnostic);
164
- const importerChain = issuerChain.length > 0 ? issuerChain : moduleTraceChain;
165
- if (importerChain.length > 0) lines.push(`Importer chain: ${importerChain.join(' -> ')}`);
166
- appendDiagnosticDetails(diagnostic, lines);
167
- }
168
- };
169
- const applyServerOnlyDiagnosticPlugin = (compiler, environmentName)=>{
170
- compiler.hooks.thisCompilation.tap('ModernJsServerOnlyDiagnosticContextPlugin', (compilation)=>{
171
- compilation.hooks.processWarnings.tap('ModernJsServerOnlyDiagnosticContextPlugin', (warnings)=>{
172
- enrichServerOnlyDiagnostics({
173
- errors: compilation.errors,
174
- moduleGraph: compilation.moduleGraph,
175
- warnings
176
- }, environmentName || compilation.name || compiler.name);
177
- return warnings;
178
- });
179
- compilation.hooks.afterSeal.tapPromise('ModernJsServerOnlyDiagnosticContextPlugin', async ()=>{
180
- enrichServerOnlyDiagnostics(compilation, environmentName || compilation.name || compiler.name);
181
- });
182
- });
183
- };
184
- const applyServerOnlyDiagnosticPlugins = (compiler, environments)=>{
185
- const compilers = 'compilers' in compiler ? compiler.compilers : [
186
- compiler
187
- ];
188
- compilers.forEach((childCompiler, index)=>{
189
- const environmentName = childCompiler.name || Object.values(environments).find((environment)=>environment.index === index)?.name;
190
- applyServerOnlyDiagnosticPlugin(childCompiler, environmentName);
191
- });
192
- };
193
61
  function pluginRscConfig() {
194
62
  return {
195
63
  name: 'builder:rsc-config',
@@ -251,7 +119,6 @@ function pluginRscConfig() {
251
119
  }
252
120
  if (config.module?.rules) {
253
121
  const rules = config.module.rules;
254
- disableReactCompilerInSwcLoaders(rules);
255
122
  for (const rule of rules)if (rule.layer === Layers.rsc) {
256
123
  if (rule.exclude) {
257
124
  if (!Array.isArray(rule.exclude)) rule.exclude = [
@@ -268,9 +135,6 @@ function pluginRscConfig() {
268
135
  });
269
136
  }
270
137
  });
271
- api.onAfterCreateCompiler(({ compiler, environments })=>{
272
- applyServerOnlyDiagnosticPlugins(compiler, environments);
273
- });
274
138
  api.modifyBundlerChain((chain, { isServer, isWebWorker })=>{
275
139
  if (!isServer && !isWebWorker) {
276
140
  const entries = chain.entryPoints.entries();
@@ -318,12 +182,10 @@ function createRscLayerMatchers(internalDirectory) {
318
182
  ];
319
183
  }
320
184
  exports.createRscLayerMatchers = __webpack_exports__.createRscLayerMatchers;
321
- exports.enrichServerOnlyDiagnostics = __webpack_exports__.enrichServerOnlyDiagnostics;
322
185
  exports.getRscPlugins = __webpack_exports__.getRscPlugins;
323
186
  exports.pluginRscConfig = __webpack_exports__.pluginRscConfig;
324
187
  for(var __rspack_i in __webpack_exports__)if (-1 === [
325
188
  "createRscLayerMatchers",
326
- "enrichServerOnlyDiagnostics",
327
189
  "getRscPlugins",
328
190
  "pluginRscConfig"
329
191
  ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
@@ -38,14 +38,11 @@ const plugin_react_namespaceObject = require("@rsbuild/plugin-react");
38
38
  const plugin_sass_namespaceObject = require("@rsbuild/plugin-sass");
39
39
  const devtools_js_namespaceObject = require("../plugins/devtools.js");
40
40
  const emitRouteFile_js_namespaceObject = require("../plugins/emitRouteFile.js");
41
- const environmentBuildCache_js_namespaceObject = require("../plugins/environmentBuildCache.js");
42
41
  const environmentDefaults_js_namespaceObject = require("../plugins/environmentDefaults.js");
43
42
  const globalVars_js_namespaceObject = require("../plugins/globalVars.js");
44
43
  const htmlMinify_js_namespaceObject = require("../plugins/htmlMinify.js");
45
- const rspack21_js_namespaceObject = require("../plugins/rspack21.js");
46
44
  const runtimeChunk_js_namespaceObject = require("../plugins/runtimeChunk.js");
47
45
  const external_devServer_js_namespaceObject = require("./devServer.js");
48
- const external_tsgo_js_namespaceObject = require("./tsgo.js");
49
46
  const external_utils_js_namespaceObject = require("./utils.js");
50
47
  const CSS_MODULES_REGEX = /\.modules?\.\w+$/i;
51
48
  const GLOBAL_CSS_REGEX = /\.global\.\w+$/;
@@ -72,7 +69,7 @@ function removeUndefinedKey(obj) {
72
69
  }
73
70
  async function parseCommonConfig(builderConfig, options) {
74
71
  const frameworkConfigPath = options?.frameworkConfigPath;
75
- const { plugins: [...plugins] = [], splitChunks, performance: { rsdoctor: rsdoctorConfig, ...performanceConfig } = {}, output: { module = false, enableCssModuleTSDeclaration, disableCssModuleExtension, disableTsChecker, disableSvgr, svgDefaultExport, assetsRetry, enableAssetManifest, sourceMap, convertToRem, polyfill, dataUriLimit = 10000, distPath = {}, ...outputConfig } = {}, html: { outputStructure, appIcon, ...htmlConfig } = {}, source: { alias, globalVars, transformImport, reactCompiler, ...sourceConfig } = {}, dev = {}, server = {}, security: { checkSyntax, sri, ...securityConfig } = {}, tools: { devServer, tsChecker, minifyCss, less, sass, htmlPlugin, autoprefixer, ...toolsConfig } = {}, environments = {}, resolve = {} } = builderConfig;
72
+ const { plugins: [...plugins] = [], splitChunks, performance: { ...performanceConfig } = {}, output: { module = false, enableCssModuleTSDeclaration, disableCssModuleExtension, disableTsChecker, disableSvgr, svgDefaultExport, assetsRetry, enableAssetManifest, sourceMap, convertToRem, polyfill, dataUriLimit = 10000, distPath = {}, ...outputConfig } = {}, html: { outputStructure, appIcon, ...htmlConfig } = {}, source: { alias, globalVars, transformImport, reactCompiler, ...sourceConfig } = {}, dev = {}, server = {}, security: { checkSyntax, sri, ...securityConfig } = {}, tools: { devServer, tsChecker, minifyCss, less, sass, htmlPlugin, autoprefixer, ...toolsConfig } = {}, environments = {}, resolve = {} } = builderConfig;
76
73
  let combinedAlias;
77
74
  if (alias || resolve.alias) combinedAlias = [].concat(alias ?? []).concat(resolve.alias ?? []);
78
75
  const rsbuildConfig = {
@@ -148,12 +145,8 @@ async function parseCommonConfig(builderConfig, options) {
148
145
  rsbuildConfig.dev = removeUndefinedKey(rsbuildDev);
149
146
  rsbuildConfig.html = html;
150
147
  rsbuildConfig.output = output;
151
- const { sourceBuild, sourceImport } = builderConfig.experiments || {};
148
+ const { sourceBuild } = builderConfig.experiments || {};
152
149
  const rsbuildPlugins = [
153
- (0, rspack21_js_namespaceObject.pluginRspack21)({
154
- sourceImport
155
- }),
156
- (0, environmentBuildCache_js_namespaceObject.pluginEnvironmentBuildCacheIsolation)(),
157
150
  (0, globalVars_js_namespaceObject.pluginGlobalVars)(globalVars),
158
151
  (0, devtools_js_namespaceObject.pluginDevtool)({
159
152
  sourceMap
@@ -175,7 +168,7 @@ async function parseCommonConfig(builderConfig, options) {
175
168
  if (!disableTsChecker) {
176
169
  const { pluginTypeCheck } = await import("@rsbuild/plugin-type-check");
177
170
  rsbuildPlugins.push(pluginTypeCheck({
178
- tsCheckerOptions: (0, external_tsgo_js_namespaceObject.withTsgoDefaults)(tsChecker, options?.cwd ?? process.cwd())
171
+ tsCheckerOptions: tsChecker
179
172
  }));
180
173
  }
181
174
  if (convertToRem) {
@@ -227,8 +220,7 @@ async function parseCommonConfig(builderConfig, options) {
227
220
  }
228
221
  return {
229
222
  rsbuildConfig: (0, core_namespaceObject.mergeRsbuildConfig)(rsbuildConfig, extraConfig),
230
- rsbuildPlugins,
231
- rsdoctorConfig
223
+ rsbuildPlugins
232
224
  };
233
225
  }
234
226
  exports.isLooseCssModules = __webpack_exports__.isLooseCssModules;
@@ -1,12 +1,11 @@
1
1
  import { createRsbuild } from "@rsbuild/core";
2
2
  import { getRscPlugins } from "./plugins/rscConfig.mjs";
3
- import { pluginRsdoctor } from "./plugins/rsdoctor.mjs";
4
3
  import { parseCommonConfig } from "./shared/parseCommonConfig.mjs";
5
4
  import { rscDisabledRuntimePlugin } from "./shared/rsc/rscDisabledRuntime.mjs";
6
5
  async function parseConfig(builderConfig, options) {
7
6
  builderConfig.performance ??= {};
8
7
  builderConfig.performance.buildCache ??= true;
9
- const { rsbuildConfig, rsbuildPlugins, rsdoctorConfig } = await parseCommonConfig(builderConfig, options);
8
+ const { rsbuildConfig, rsbuildPlugins } = await parseCommonConfig(builderConfig, options);
10
9
  const { sri } = builderConfig.security || {};
11
10
  if (sri) if (true === sri) rsbuildConfig.security.sri = {
12
11
  enable: 'auto'
@@ -34,8 +33,6 @@ async function parseConfig(builderConfig, options) {
34
33
  ...rsbuildConfig.plugins ?? [],
35
34
  rscDisabledRuntimePlugin()
36
35
  ];
37
- const rsdoctorPlugin = pluginRsdoctor(rsdoctorConfig);
38
- if (rsdoctorPlugin) rsbuildPlugins.push(rsdoctorPlugin);
39
36
  return {
40
37
  rsbuildConfig,
41
38
  rsbuildPlugins
@@ -7,9 +7,6 @@ const RENDER_RSC_RUNTIME = '@modern-js/render/rsc';
7
7
  const RENDER_RSC_WORKER_RUNTIME = '@modern-js/render/rsc-worker';
8
8
  const RSC_COMMON_LAYER = 'rsc-common';
9
9
  const ENTRY_NAME_VAR = '__MODERN_JS_ENTRY_NAME';
10
- const SERVER_ONLY_MARKER_PATTERN = /(?:^|[/\\])server-only[/\\]index\.js(?:\?|$)/;
11
- const SERVER_ONLY_MESSAGE_PATTERN = /server-only|server only|only works in a Server Component|cannot be imported (?:directly )?(?:from|into) (?:a )?Client Component/i;
12
- const SERVER_ONLY_DIAGNOSTIC_PREFIX = '[Modern.js RSC server-only diagnostic context]';
13
10
  const ROUTE_DATA_FILE_PATTERN = /[/\\]routes[/\\](?:.*[/\\])?(?:layout|page|\$)\.(?:loader|data)\.[tj]sx?(?:\?.*)?$/;
14
11
  const createVirtualModule = (content)=>`data:text/javascript,${encodeURIComponent(content)}`;
15
12
  const isAsyncStorageExclude = (exclude)=>{
@@ -17,134 +14,6 @@ const isAsyncStorageExclude = (exclude)=>{
17
14
  if (exclude instanceof RegExp) return exclude.test('universal/async_storage') || exclude.test('universal\\async_storage');
18
15
  return false;
19
16
  };
20
- const asRecord = (value)=>{
21
- if (value && 'object' == typeof value && !Array.isArray(value)) return value;
22
- };
23
- const disableReactCompilerInSwcLoaders = (value, seen = new WeakSet())=>{
24
- if (!value || 'object' != typeof value) return;
25
- if (seen.has(value)) return;
26
- seen.add(value);
27
- if (Array.isArray(value)) {
28
- for (const item of value)disableReactCompilerInSwcLoaders(item, seen);
29
- return;
30
- }
31
- const record = value;
32
- if ('builtin:swc-loader' === record.loader) {
33
- let options = asRecord(record.options);
34
- if (!options) {
35
- options = {};
36
- record.options = options;
37
- }
38
- let jsc = asRecord(options.jsc);
39
- if (!jsc) {
40
- jsc = {};
41
- options.jsc = jsc;
42
- }
43
- let transform = asRecord(jsc.transform);
44
- if (!transform) {
45
- transform = {};
46
- jsc.transform = transform;
47
- }
48
- transform.reactCompiler = false;
49
- }
50
- for (const item of Object.values(record))disableReactCompilerInSwcLoaders(item, seen);
51
- };
52
- const normalizeDiagnosticText = (diagnostic)=>[
53
- diagnostic.message,
54
- diagnostic.details,
55
- diagnostic.file,
56
- getModulePath(diagnostic.module),
57
- getModuleIdentifier(diagnostic.module)
58
- ].filter((item)=>Boolean(item)).join('\n');
59
- const isServerOnlyDiagnostic = (diagnostic)=>{
60
- const text = normalizeDiagnosticText(diagnostic);
61
- return SERVER_ONLY_MARKER_PATTERN.test(text) || SERVER_ONLY_MESSAGE_PATTERN.test(text);
62
- };
63
- const isEnrichedServerOnlyDiagnostic = (diagnostic)=>diagnostic.message.includes(SERVER_ONLY_DIAGNOSTIC_PREFIX) || diagnostic.details?.includes(SERVER_ONLY_DIAGNOSTIC_PREFIX);
64
- const getModulePath = (module)=>{
65
- if (!module) return;
66
- return module.resource || module.nameForCondition?.() || module.userRequest;
67
- };
68
- const getModuleIdentifier = (module)=>{
69
- if (!module) return;
70
- return getModulePath(module) || module.readableIdentifier?.() || module.identifier?.() || module.request || module.rawRequest;
71
- };
72
- const formatModuleContext = (module)=>{
73
- const id = getModuleIdentifier(module);
74
- if (!id) return;
75
- const layer = module?.layer ? ` [layer: ${module.layer}]` : '';
76
- return `${id}${layer}`;
77
- };
78
- const getIssuerChain = (compilation, module)=>{
79
- const chain = [];
80
- const seen = new Set();
81
- let current = module;
82
- while(current && !seen.has(current) && chain.length < 8){
83
- seen.add(current);
84
- const issuer = compilation.moduleGraph?.getIssuer?.(current);
85
- const formatted = formatModuleContext(issuer);
86
- if (!issuer || !formatted) break;
87
- chain.push(formatted);
88
- current = issuer;
89
- }
90
- return chain;
91
- };
92
- const getModuleTraceChain = (diagnostic)=>{
93
- const trace = diagnostic.moduleTrace || [];
94
- const chain = [];
95
- for (const item of trace){
96
- const formatted = formatModuleContext(item.origin) || item.originName || formatModuleContext(item.module) || item.moduleName;
97
- if (formatted && !chain.includes(formatted)) chain.push(formatted);
98
- }
99
- return chain.slice(0, 8);
100
- };
101
- const appendDiagnosticDetails = (diagnostic, lines)=>{
102
- const context = `${SERVER_ONLY_DIAGNOSTIC_PREFIX}\n${lines.join('\n')}`;
103
- diagnostic.details = diagnostic.details ? `${diagnostic.details}\n\n${context}` : context;
104
- };
105
- const enrichServerOnlyDiagnostics = (compilation, environmentName)=>{
106
- const diagnostics = [
107
- ...compilation.warnings,
108
- ...compilation.errors
109
- ];
110
- for (const diagnostic of diagnostics){
111
- if (!isServerOnlyDiagnostic(diagnostic) || isEnrichedServerOnlyDiagnostic(diagnostic)) continue;
112
- const lines = [
113
- `Environment: ${environmentName || compilation.name || 'unknown'}`
114
- ];
115
- const markerModule = formatModuleContext(diagnostic.module);
116
- if (markerModule) lines.push(`Matched module: ${markerModule}`);
117
- const issuerChain = getIssuerChain(compilation, diagnostic.module);
118
- const moduleTraceChain = getModuleTraceChain(diagnostic);
119
- const importerChain = issuerChain.length > 0 ? issuerChain : moduleTraceChain;
120
- if (importerChain.length > 0) lines.push(`Importer chain: ${importerChain.join(' -> ')}`);
121
- appendDiagnosticDetails(diagnostic, lines);
122
- }
123
- };
124
- const applyServerOnlyDiagnosticPlugin = (compiler, environmentName)=>{
125
- compiler.hooks.thisCompilation.tap('ModernJsServerOnlyDiagnosticContextPlugin', (compilation)=>{
126
- compilation.hooks.processWarnings.tap('ModernJsServerOnlyDiagnosticContextPlugin', (warnings)=>{
127
- enrichServerOnlyDiagnostics({
128
- errors: compilation.errors,
129
- moduleGraph: compilation.moduleGraph,
130
- warnings
131
- }, environmentName || compilation.name || compiler.name);
132
- return warnings;
133
- });
134
- compilation.hooks.afterSeal.tapPromise('ModernJsServerOnlyDiagnosticContextPlugin', async ()=>{
135
- enrichServerOnlyDiagnostics(compilation, environmentName || compilation.name || compiler.name);
136
- });
137
- });
138
- };
139
- const applyServerOnlyDiagnosticPlugins = (compiler, environments)=>{
140
- const compilers = 'compilers' in compiler ? compiler.compilers : [
141
- compiler
142
- ];
143
- compilers.forEach((childCompiler, index)=>{
144
- const environmentName = childCompiler.name || Object.values(environments).find((environment)=>environment.index === index)?.name;
145
- applyServerOnlyDiagnosticPlugin(childCompiler, environmentName);
146
- });
147
- };
148
17
  function pluginRscConfig() {
149
18
  return {
150
19
  name: 'builder:rsc-config',
@@ -206,7 +75,6 @@ function pluginRscConfig() {
206
75
  }
207
76
  if (config.module?.rules) {
208
77
  const rules = config.module.rules;
209
- disableReactCompilerInSwcLoaders(rules);
210
78
  for (const rule of rules)if (rule.layer === Layers.rsc) {
211
79
  if (rule.exclude) {
212
80
  if (!Array.isArray(rule.exclude)) rule.exclude = [
@@ -223,9 +91,6 @@ function pluginRscConfig() {
223
91
  });
224
92
  }
225
93
  });
226
- api.onAfterCreateCompiler(({ compiler, environments })=>{
227
- applyServerOnlyDiagnosticPlugins(compiler, environments);
228
- });
229
94
  api.modifyBundlerChain((chain, { isServer, isWebWorker })=>{
230
95
  if (!isServer && !isWebWorker) {
231
96
  const entries = chain.entryPoints.entries();
@@ -272,4 +137,4 @@ function createRscLayerMatchers(internalDirectory) {
272
137
  isolatedRouteDataReg
273
138
  ];
274
139
  }
275
- export { createRscLayerMatchers, enrichServerOnlyDiagnostics, getRscPlugins, pluginRscConfig };
140
+ export { createRscLayerMatchers, getRscPlugins, pluginRscConfig };
@@ -5,14 +5,11 @@ import { pluginReact } from "@rsbuild/plugin-react";
5
5
  import { pluginSass } from "@rsbuild/plugin-sass";
6
6
  import { pluginDevtool } from "../plugins/devtools.mjs";
7
7
  import { pluginEmitRouteFile } from "../plugins/emitRouteFile.mjs";
8
- import { pluginEnvironmentBuildCacheIsolation } from "../plugins/environmentBuildCache.mjs";
9
8
  import { pluginEnvironmentDefaults } from "../plugins/environmentDefaults.mjs";
10
9
  import { pluginGlobalVars } from "../plugins/globalVars.mjs";
11
10
  import { pluginHtmlMinifierTerser } from "../plugins/htmlMinify.mjs";
12
- import { pluginRspack21 } from "../plugins/rspack21.mjs";
13
11
  import { pluginRuntimeChunk } from "../plugins/runtimeChunk.mjs";
14
12
  import { transformToRsbuildServerOptions } from "./devServer.mjs";
15
- import { withTsgoDefaults } from "./tsgo.mjs";
16
13
  import { NODE_MODULES_REGEX } from "./utils.mjs";
17
14
  const CSS_MODULES_REGEX = /\.modules?\.\w+$/i;
18
15
  const GLOBAL_CSS_REGEX = /\.global\.\w+$/;
@@ -39,7 +36,7 @@ function removeUndefinedKey(obj) {
39
36
  }
40
37
  async function parseCommonConfig(builderConfig, options) {
41
38
  const frameworkConfigPath = options?.frameworkConfigPath;
42
- const { plugins: [...plugins] = [], splitChunks, performance: { rsdoctor: rsdoctorConfig, ...performanceConfig } = {}, output: { module = false, enableCssModuleTSDeclaration, disableCssModuleExtension, disableTsChecker, disableSvgr, svgDefaultExport, assetsRetry, enableAssetManifest, sourceMap, convertToRem, polyfill, dataUriLimit = 10000, distPath = {}, ...outputConfig } = {}, html: { outputStructure, appIcon, ...htmlConfig } = {}, source: { alias, globalVars, transformImport, reactCompiler, ...sourceConfig } = {}, dev = {}, server = {}, security: { checkSyntax, sri, ...securityConfig } = {}, tools: { devServer, tsChecker, minifyCss, less, sass, htmlPlugin, autoprefixer, ...toolsConfig } = {}, environments = {}, resolve = {} } = builderConfig;
39
+ const { plugins: [...plugins] = [], splitChunks, performance: { ...performanceConfig } = {}, output: { module = false, enableCssModuleTSDeclaration, disableCssModuleExtension, disableTsChecker, disableSvgr, svgDefaultExport, assetsRetry, enableAssetManifest, sourceMap, convertToRem, polyfill, dataUriLimit = 10000, distPath = {}, ...outputConfig } = {}, html: { outputStructure, appIcon, ...htmlConfig } = {}, source: { alias, globalVars, transformImport, reactCompiler, ...sourceConfig } = {}, dev = {}, server = {}, security: { checkSyntax, sri, ...securityConfig } = {}, tools: { devServer, tsChecker, minifyCss, less, sass, htmlPlugin, autoprefixer, ...toolsConfig } = {}, environments = {}, resolve = {} } = builderConfig;
43
40
  let combinedAlias;
44
41
  if (alias || resolve.alias) combinedAlias = [].concat(alias ?? []).concat(resolve.alias ?? []);
45
42
  const rsbuildConfig = {
@@ -115,12 +112,8 @@ async function parseCommonConfig(builderConfig, options) {
115
112
  rsbuildConfig.dev = removeUndefinedKey(rsbuildDev);
116
113
  rsbuildConfig.html = html;
117
114
  rsbuildConfig.output = output;
118
- const { sourceBuild, sourceImport } = builderConfig.experiments || {};
115
+ const { sourceBuild } = builderConfig.experiments || {};
119
116
  const rsbuildPlugins = [
120
- pluginRspack21({
121
- sourceImport
122
- }),
123
- pluginEnvironmentBuildCacheIsolation(),
124
117
  pluginGlobalVars(globalVars),
125
118
  pluginDevtool({
126
119
  sourceMap
@@ -142,7 +135,7 @@ async function parseCommonConfig(builderConfig, options) {
142
135
  if (!disableTsChecker) {
143
136
  const { pluginTypeCheck } = await import("@rsbuild/plugin-type-check");
144
137
  rsbuildPlugins.push(pluginTypeCheck({
145
- tsCheckerOptions: withTsgoDefaults(tsChecker, options?.cwd ?? process.cwd())
138
+ tsCheckerOptions: tsChecker
146
139
  }));
147
140
  }
148
141
  if (convertToRem) {
@@ -194,8 +187,7 @@ async function parseCommonConfig(builderConfig, options) {
194
187
  }
195
188
  return {
196
189
  rsbuildConfig: mergeRsbuildConfig(rsbuildConfig, extraConfig),
197
- rsbuildPlugins,
198
- rsdoctorConfig
190
+ rsbuildPlugins
199
191
  };
200
192
  }
201
193
  export { isLooseCssModules, parseCommonConfig };
@@ -1,13 +1,12 @@
1
1
  import "node:module";
2
2
  import { createRsbuild } from "@rsbuild/core";
3
3
  import { getRscPlugins } from "./plugins/rscConfig.mjs";
4
- import { pluginRsdoctor } from "./plugins/rsdoctor.mjs";
5
4
  import { parseCommonConfig } from "./shared/parseCommonConfig.mjs";
6
5
  import { rscDisabledRuntimePlugin } from "./shared/rsc/rscDisabledRuntime.mjs";
7
6
  async function parseConfig(builderConfig, options) {
8
7
  builderConfig.performance ??= {};
9
8
  builderConfig.performance.buildCache ??= true;
10
- const { rsbuildConfig, rsbuildPlugins, rsdoctorConfig } = await parseCommonConfig(builderConfig, options);
9
+ const { rsbuildConfig, rsbuildPlugins } = await parseCommonConfig(builderConfig, options);
11
10
  const { sri } = builderConfig.security || {};
12
11
  if (sri) if (true === sri) rsbuildConfig.security.sri = {
13
12
  enable: 'auto'
@@ -35,8 +34,6 @@ async function parseConfig(builderConfig, options) {
35
34
  ...rsbuildConfig.plugins ?? [],
36
35
  rscDisabledRuntimePlugin()
37
36
  ];
38
- const rsdoctorPlugin = pluginRsdoctor(rsdoctorConfig);
39
- if (rsdoctorPlugin) rsbuildPlugins.push(rsdoctorPlugin);
40
37
  return {
41
38
  rsbuildConfig,
42
39
  rsbuildPlugins