@bleedingdev/modern-js-builder 3.5.0-ultramodern.7 → 3.5.0-ultramodern.75

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.
@@ -204,6 +204,13 @@ function pluginRscConfig() {
204
204
  handler: (chain, { isServer })=>{
205
205
  if (isServer) {
206
206
  chain.resolve.alias.set(`${RENDER_RSC_RUNTIME}$`, RENDER_RSC_WORKER_RUNTIME);
207
+ let emptyModulePath;
208
+ try {
209
+ emptyModulePath = require.resolve('../shared/rsc/rscEmptyModule');
210
+ } catch {
211
+ emptyModulePath = external_path_default().resolve(__dirname, '../shared/rsc/rscEmptyModule');
212
+ }
213
+ chain.resolve.alias.set('server-only$', emptyModulePath);
207
214
  const routeFilePattern = /[/\\]routes[/\\](?:.*[/\\])?(?:layout|page|\$)\.[tj]sx?$/;
208
215
  const appFilePattern = /[/\\]App\.[tj]sx?$/;
209
216
  const combinedPattern = new RegExp(`(${routeFilePattern.source}|${appFilePattern.source})`);
@@ -277,7 +284,8 @@ function pluginRscConfig() {
277
284
  }
278
285
  async function getRscPlugins(enableRsc, internalDirectory, environments) {
279
286
  if (enableRsc) {
280
- const routesFileReg = new RegExp(`${internalDirectory.replace(/[/\\]/g, '[/\\\\]')}[/\\\\][^/\\\\]*[/\\\\]routes`);
287
+ new RegExp(`${internalDirectory.replace(/[/\\]/g, '[/\\\\]')}[/\\\\][^/\\\\]*[/\\\\]routes`);
288
+ const routeDataFileReg = /[/\\]routes[/\\](?:.*[/\\])?(?:layout|page|\$)\.(?:loader|data)\.[tj]sx?(?:\?.*)?$/;
281
289
  const { pluginRSC } = await import("rsbuild-plugin-rsc");
282
290
  return [
283
291
  pluginRSC({
@@ -290,7 +298,7 @@ async function getRscPlugins(enableRsc, internalDirectory, environments) {
290
298
  RENDER_RSC_SOURCE_PATTERN,
291
299
  RENDER_RSC_RSLIB_ENTRY_PATTERN,
292
300
  /AppProxy/,
293
- routesFileReg
301
+ routeDataFileReg
294
302
  ]
295
303
  }
296
304
  }),
@@ -49,6 +49,17 @@ const external_tsgo_js_namespaceObject = require("./tsgo.js");
49
49
  const external_utils_js_namespaceObject = require("./utils.js");
50
50
  const CSS_MODULES_REGEX = /\.modules?\.\w+$/i;
51
51
  const GLOBAL_CSS_REGEX = /\.global\.\w+$/;
52
+ const DEFAULT_CSS_MINIFIER_OPTIONS = {
53
+ minimizerOptions: {
54
+ preset: [
55
+ 'default',
56
+ {
57
+ calc: false,
58
+ mergeLonghand: false
59
+ }
60
+ ]
61
+ }
62
+ };
52
63
  const isLooseCssModules = (path)=>{
53
64
  if (external_utils_js_namespaceObject.NODE_MODULES_REGEX.test(path)) return CSS_MODULES_REGEX.test(path);
54
65
  return !GLOBAL_CSS_REGEX.test(path);
@@ -208,7 +219,7 @@ async function parseCommonConfig(builderConfig, options) {
208
219
  };
209
220
  }
210
221
  rsbuildPlugins.push((0, plugin_css_minimizer_namespaceObject.pluginCssMinimizer)({
211
- pluginOptions: minifyCss
222
+ pluginOptions: minifyCss ?? DEFAULT_CSS_MINIFIER_OPTIONS
212
223
  }));
213
224
  if (enableAssetManifest) {
214
225
  const { pluginManifest } = await import("../plugins/manifest.js");
@@ -50,7 +50,8 @@ const external_node_path_namespaceObject = require("node:path");
50
50
  var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
51
51
  const utils_namespaceObject = require("@modern-js/utils");
52
52
  const builderRequire = (0, external_node_module_namespaceObject.createRequire)(__rslib_import_meta_url__);
53
- const TSGO_PACKAGE = "@typescript/native-preview/package.json";
53
+ const STABLE_TSGO_PACKAGE = "typescript/package.json";
54
+ const NATIVE_PREVIEW_TSGO_PACKAGE = "@typescript/native-preview/package.json";
54
55
  const TSGO_CHECKER_DIR = external_node_path_default().join('.modern-js', 'tsgo');
55
56
  const tryResolve = (request, rootPath)=>{
56
57
  try {
@@ -63,6 +64,20 @@ const tryResolve = (request, rootPath)=>{
63
64
  return;
64
65
  }
65
66
  };
67
+ const readPackageMajorVersion = (packageJsonPath)=>{
68
+ try {
69
+ const packageJson = JSON.parse(external_node_fs_default().readFileSync(packageJsonPath, 'utf8'));
70
+ const major = Number.parseInt(String(packageJson.version).split('.')[0], 10);
71
+ return Number.isFinite(major) ? major : void 0;
72
+ } catch {
73
+ return;
74
+ }
75
+ };
76
+ const resolveTsgoPackagePath = (rootPath)=>{
77
+ const stableTypeScriptPath = tryResolve(STABLE_TSGO_PACKAGE, rootPath);
78
+ if (stableTypeScriptPath && (readPackageMajorVersion(stableTypeScriptPath) ?? 0) >= 7) return stableTypeScriptPath;
79
+ return tryResolve(NATIVE_PREVIEW_TSGO_PACKAGE, rootPath) ?? builderRequire.resolve(NATIVE_PREVIEW_TSGO_PACKAGE);
80
+ };
66
81
  const toPosixPath = (input)=>input.replaceAll(external_node_path_default().sep, '/');
67
82
  const asTsConfigPath = (request)=>{
68
83
  if (external_node_path_default().extname(request)) return [
@@ -169,7 +184,7 @@ const normalizeTsgoConfig = (config, rootPath)=>{
169
184
  return config;
170
185
  };
171
186
  const withTsgoDefaults = (userOptions, rootPath)=>{
172
- const tsgoPath = tryResolve(TSGO_PACKAGE, rootPath) ?? builderRequire.resolve(TSGO_PACKAGE);
187
+ const tsgoPath = resolveTsgoPackagePath(rootPath);
173
188
  const userChain = userOptions ? Array.isArray(userOptions) ? userOptions : [
174
189
  userOptions
175
190
  ] : [];
@@ -160,6 +160,13 @@ function pluginRscConfig() {
160
160
  handler: (chain, { isServer })=>{
161
161
  if (isServer) {
162
162
  chain.resolve.alias.set(`${RENDER_RSC_RUNTIME}$`, RENDER_RSC_WORKER_RUNTIME);
163
+ let emptyModulePath;
164
+ try {
165
+ emptyModulePath = require.resolve('../shared/rsc/rscEmptyModule');
166
+ } catch {
167
+ emptyModulePath = path.resolve(__dirname, '../shared/rsc/rscEmptyModule');
168
+ }
169
+ chain.resolve.alias.set('server-only$', emptyModulePath);
163
170
  const routeFilePattern = /[/\\]routes[/\\](?:.*[/\\])?(?:layout|page|\$)\.[tj]sx?$/;
164
171
  const appFilePattern = /[/\\]App\.[tj]sx?$/;
165
172
  const combinedPattern = new RegExp(`(${routeFilePattern.source}|${appFilePattern.source})`);
@@ -233,7 +240,8 @@ function pluginRscConfig() {
233
240
  }
234
241
  async function getRscPlugins(enableRsc, internalDirectory, environments) {
235
242
  if (enableRsc) {
236
- const routesFileReg = new RegExp(`${internalDirectory.replace(/[/\\]/g, '[/\\\\]')}[/\\\\][^/\\\\]*[/\\\\]routes`);
243
+ new RegExp(`${internalDirectory.replace(/[/\\]/g, '[/\\\\]')}[/\\\\][^/\\\\]*[/\\\\]routes`);
244
+ const routeDataFileReg = /[/\\]routes[/\\](?:.*[/\\])?(?:layout|page|\$)\.(?:loader|data)\.[tj]sx?(?:\?.*)?$/;
237
245
  const { pluginRSC } = await import("rsbuild-plugin-rsc");
238
246
  return [
239
247
  pluginRSC({
@@ -246,7 +254,7 @@ async function getRscPlugins(enableRsc, internalDirectory, environments) {
246
254
  RENDER_RSC_SOURCE_PATTERN,
247
255
  RENDER_RSC_RSLIB_ENTRY_PATTERN,
248
256
  /AppProxy/,
249
- routesFileReg
257
+ routeDataFileReg
250
258
  ]
251
259
  }
252
260
  }),
@@ -16,6 +16,17 @@ import { withTsgoDefaults } from "./tsgo.mjs";
16
16
  import { NODE_MODULES_REGEX } from "./utils.mjs";
17
17
  const CSS_MODULES_REGEX = /\.modules?\.\w+$/i;
18
18
  const GLOBAL_CSS_REGEX = /\.global\.\w+$/;
19
+ const DEFAULT_CSS_MINIFIER_OPTIONS = {
20
+ minimizerOptions: {
21
+ preset: [
22
+ 'default',
23
+ {
24
+ calc: false,
25
+ mergeLonghand: false
26
+ }
27
+ ]
28
+ }
29
+ };
19
30
  const isLooseCssModules = (path)=>{
20
31
  if (NODE_MODULES_REGEX.test(path)) return CSS_MODULES_REGEX.test(path);
21
32
  return !GLOBAL_CSS_REGEX.test(path);
@@ -175,7 +186,7 @@ async function parseCommonConfig(builderConfig, options) {
175
186
  };
176
187
  }
177
188
  rsbuildPlugins.push(pluginCssMinimizer({
178
- pluginOptions: minifyCss
189
+ pluginOptions: minifyCss ?? DEFAULT_CSS_MINIFIER_OPTIONS
179
190
  }));
180
191
  if (enableAssetManifest) {
181
192
  const { pluginManifest } = await import("../plugins/manifest.mjs");
@@ -4,7 +4,8 @@ import { createRequire } from "node:module";
4
4
  import node_path from "node:path";
5
5
  import { json5 } from "@modern-js/utils";
6
6
  const builderRequire = createRequire(import.meta.url);
7
- const TSGO_PACKAGE = "@typescript/native-preview/package.json";
7
+ const STABLE_TSGO_PACKAGE = "typescript/package.json";
8
+ const NATIVE_PREVIEW_TSGO_PACKAGE = "@typescript/native-preview/package.json";
8
9
  const TSGO_CHECKER_DIR = node_path.join('.modern-js', 'tsgo');
9
10
  const tryResolve = (request, rootPath)=>{
10
11
  try {
@@ -17,6 +18,20 @@ const tryResolve = (request, rootPath)=>{
17
18
  return;
18
19
  }
19
20
  };
21
+ const readPackageMajorVersion = (packageJsonPath)=>{
22
+ try {
23
+ const packageJson = JSON.parse(node_fs.readFileSync(packageJsonPath, 'utf8'));
24
+ const major = Number.parseInt(String(packageJson.version).split('.')[0], 10);
25
+ return Number.isFinite(major) ? major : void 0;
26
+ } catch {
27
+ return;
28
+ }
29
+ };
30
+ const resolveTsgoPackagePath = (rootPath)=>{
31
+ const stableTypeScriptPath = tryResolve(STABLE_TSGO_PACKAGE, rootPath);
32
+ if (stableTypeScriptPath && (readPackageMajorVersion(stableTypeScriptPath) ?? 0) >= 7) return stableTypeScriptPath;
33
+ return tryResolve(NATIVE_PREVIEW_TSGO_PACKAGE, rootPath) ?? builderRequire.resolve(NATIVE_PREVIEW_TSGO_PACKAGE);
34
+ };
20
35
  const toPosixPath = (input)=>input.replaceAll(node_path.sep, '/');
21
36
  const asTsConfigPath = (request)=>{
22
37
  if (node_path.extname(request)) return [
@@ -123,7 +138,7 @@ const normalizeTsgoConfig = (config, rootPath)=>{
123
138
  return config;
124
139
  };
125
140
  const withTsgoDefaults = (userOptions, rootPath)=>{
126
- const tsgoPath = tryResolve(TSGO_PACKAGE, rootPath) ?? builderRequire.resolve(TSGO_PACKAGE);
141
+ const tsgoPath = resolveTsgoPackagePath(rootPath);
127
142
  const userChain = userOptions ? Array.isArray(userOptions) ? userOptions : [
128
143
  userOptions
129
144
  ] : [];
@@ -165,6 +165,13 @@ function pluginRscConfig() {
165
165
  handler: (chain, { isServer })=>{
166
166
  if (isServer) {
167
167
  chain.resolve.alias.set(`${RENDER_RSC_RUNTIME}$`, RENDER_RSC_WORKER_RUNTIME);
168
+ let emptyModulePath;
169
+ try {
170
+ emptyModulePath = require.resolve('../shared/rsc/rscEmptyModule');
171
+ } catch {
172
+ emptyModulePath = path.resolve(__rspack_import_meta_dirname__, '../shared/rsc/rscEmptyModule');
173
+ }
174
+ chain.resolve.alias.set('server-only$', emptyModulePath);
168
175
  const routeFilePattern = /[/\\]routes[/\\](?:.*[/\\])?(?:layout|page|\$)\.[tj]sx?$/;
169
176
  const appFilePattern = /[/\\]App\.[tj]sx?$/;
170
177
  const combinedPattern = new RegExp(`(${routeFilePattern.source}|${appFilePattern.source})`);
@@ -238,7 +245,8 @@ function pluginRscConfig() {
238
245
  }
239
246
  async function getRscPlugins(enableRsc, internalDirectory, environments) {
240
247
  if (enableRsc) {
241
- const routesFileReg = new RegExp(`${internalDirectory.replace(/[/\\]/g, '[/\\\\]')}[/\\\\][^/\\\\]*[/\\\\]routes`);
248
+ new RegExp(`${internalDirectory.replace(/[/\\]/g, '[/\\\\]')}[/\\\\][^/\\\\]*[/\\\\]routes`);
249
+ const routeDataFileReg = /[/\\]routes[/\\](?:.*[/\\])?(?:layout|page|\$)\.(?:loader|data)\.[tj]sx?(?:\?.*)?$/;
242
250
  const { pluginRSC } = await import("rsbuild-plugin-rsc");
243
251
  return [
244
252
  pluginRSC({
@@ -251,7 +259,7 @@ async function getRscPlugins(enableRsc, internalDirectory, environments) {
251
259
  RENDER_RSC_SOURCE_PATTERN,
252
260
  RENDER_RSC_RSLIB_ENTRY_PATTERN,
253
261
  /AppProxy/,
254
- routesFileReg
262
+ routeDataFileReg
255
263
  ]
256
264
  }
257
265
  }),
@@ -17,6 +17,17 @@ import { withTsgoDefaults } from "./tsgo.mjs";
17
17
  import { NODE_MODULES_REGEX } from "./utils.mjs";
18
18
  const CSS_MODULES_REGEX = /\.modules?\.\w+$/i;
19
19
  const GLOBAL_CSS_REGEX = /\.global\.\w+$/;
20
+ const DEFAULT_CSS_MINIFIER_OPTIONS = {
21
+ minimizerOptions: {
22
+ preset: [
23
+ 'default',
24
+ {
25
+ calc: false,
26
+ mergeLonghand: false
27
+ }
28
+ ]
29
+ }
30
+ };
20
31
  const isLooseCssModules = (path)=>{
21
32
  if (NODE_MODULES_REGEX.test(path)) return CSS_MODULES_REGEX.test(path);
22
33
  return !GLOBAL_CSS_REGEX.test(path);
@@ -176,7 +187,7 @@ async function parseCommonConfig(builderConfig, options) {
176
187
  };
177
188
  }
178
189
  rsbuildPlugins.push(pluginCssMinimizer({
179
- pluginOptions: minifyCss
190
+ pluginOptions: minifyCss ?? DEFAULT_CSS_MINIFIER_OPTIONS
180
191
  }));
181
192
  if (enableAssetManifest) {
182
193
  const { pluginManifest } = await import("../plugins/manifest.mjs");
@@ -5,7 +5,8 @@ import { createRequire } from "node:module";
5
5
  import node_path from "node:path";
6
6
  import { json5 } from "@modern-js/utils";
7
7
  const builderRequire = createRequire(import.meta.url);
8
- const TSGO_PACKAGE = "@typescript/native-preview/package.json";
8
+ const STABLE_TSGO_PACKAGE = "typescript/package.json";
9
+ const NATIVE_PREVIEW_TSGO_PACKAGE = "@typescript/native-preview/package.json";
9
10
  const TSGO_CHECKER_DIR = node_path.join('.modern-js', 'tsgo');
10
11
  const tryResolve = (request, rootPath)=>{
11
12
  try {
@@ -18,6 +19,20 @@ const tryResolve = (request, rootPath)=>{
18
19
  return;
19
20
  }
20
21
  };
22
+ const readPackageMajorVersion = (packageJsonPath)=>{
23
+ try {
24
+ const packageJson = JSON.parse(node_fs.readFileSync(packageJsonPath, 'utf8'));
25
+ const major = Number.parseInt(String(packageJson.version).split('.')[0], 10);
26
+ return Number.isFinite(major) ? major : void 0;
27
+ } catch {
28
+ return;
29
+ }
30
+ };
31
+ const resolveTsgoPackagePath = (rootPath)=>{
32
+ const stableTypeScriptPath = tryResolve(STABLE_TSGO_PACKAGE, rootPath);
33
+ if (stableTypeScriptPath && (readPackageMajorVersion(stableTypeScriptPath) ?? 0) >= 7) return stableTypeScriptPath;
34
+ return tryResolve(NATIVE_PREVIEW_TSGO_PACKAGE, rootPath) ?? builderRequire.resolve(NATIVE_PREVIEW_TSGO_PACKAGE);
35
+ };
21
36
  const toPosixPath = (input)=>input.replaceAll(node_path.sep, '/');
22
37
  const asTsConfigPath = (request)=>{
23
38
  if (node_path.extname(request)) return [
@@ -124,7 +139,7 @@ const normalizeTsgoConfig = (config, rootPath)=>{
124
139
  return config;
125
140
  };
126
141
  const withTsgoDefaults = (userOptions, rootPath)=>{
127
- const tsgoPath = tryResolve(TSGO_PACKAGE, rootPath) ?? builderRequire.resolve(TSGO_PACKAGE);
142
+ const tsgoPath = resolveTsgoPackagePath(rootPath);
128
143
  const userChain = userOptions ? Array.isArray(userOptions) ? userOptions : [
129
144
  userOptions
130
145
  ] : [];
@@ -4,8 +4,8 @@ type TsCheckerFn = Extract<TsCheckerChain, (config: never) => unknown>;
4
4
  export type TsCheckerOptions = Parameters<TsCheckerFn>[0];
5
5
  /**
6
6
  * Type checking runs on TypeScript Go (`tsgo`) by default. The checker
7
- * prefers the project's own `@typescript/native-preview` and falls back to
8
- * the copy bundled with the builder, so it works without an extra install.
7
+ * prefers the project's stable TypeScript 7 package, then falls back to
8
+ * `@typescript/native-preview` for projects still on the preview lane.
9
9
  * Set `tools.tsChecker.typescript.tsgo: false` to use the classic checker.
10
10
  */
11
11
  export declare const withTsgoDefaults: (userOptions: TsCheckerChain | undefined, rootPath: string) => TsCheckerChain;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bleedingdev/modern-js-builder",
3
- "version": "3.5.0-ultramodern.7",
3
+ "version": "3.5.0-ultramodern.75",
4
4
  "description": "A builder for Modern.js",
5
5
  "repository": {
6
6
  "type": "git",
@@ -26,29 +26,30 @@
26
26
  "dist"
27
27
  ],
28
28
  "dependencies": {
29
- "@rsbuild/core": "2.1.1",
29
+ "@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.5.0-ultramodern.75",
30
+ "@rsbuild/core": "2.1.5",
30
31
  "@rsbuild/plugin-assets-retry": "2.0.1",
31
32
  "@rsbuild/plugin-check-syntax": "2.0.0",
32
33
  "@rsbuild/plugin-css-minimizer": "2.0.1",
33
- "@rsbuild/plugin-less": "2.0.0",
34
+ "@rsbuild/plugin-less": "2.0.1",
34
35
  "@rsbuild/plugin-react": "2.1.0",
35
36
  "@rsbuild/plugin-rem": "1.0.6",
36
- "@rsbuild/plugin-sass": "2.0.0",
37
+ "@rsbuild/plugin-sass": "2.0.1",
37
38
  "@rsbuild/plugin-source-build": "1.0.6",
38
- "@rsbuild/plugin-svgr": "2.0.4",
39
+ "@rsbuild/plugin-svgr": "2.0.5",
39
40
  "@rsbuild/plugin-type-check": "1.5.0",
40
41
  "@rsbuild/plugin-typed-css-modules": "1.2.4",
41
- "@rsdoctor/rspack-plugin": "^1.5.16",
42
+ "@rsdoctor/rspack-plugin": "^1.5.17",
42
43
  "@swc/core": "1.15.43",
43
44
  "@swc/helpers": "^0.5.23",
44
- "@typescript/native-preview": "7.0.0-dev.20260628.1",
45
+ "@typescript/native-preview": "7.0.0-dev.20260707.2",
45
46
  "autoprefixer": "10.5.2",
46
- "browserslist": "4.28.4",
47
+ "browserslist": "4.28.5",
47
48
  "core-js": "^3.49.0",
48
49
  "cssnano": "8.0.2",
49
50
  "html-minifier-terser": "^7.2.0",
50
51
  "lodash": "^4.18.1",
51
- "postcss": "^8.5.15",
52
+ "postcss": "^8.5.16",
52
53
  "postcss-custom-properties": "15.0.1",
53
54
  "postcss-flexbugs-fixes": "5.0.2",
54
55
  "postcss-font-variant": "5.0.0",
@@ -58,22 +59,20 @@
58
59
  "postcss-page-break": "3.0.4",
59
60
  "rsbuild-plugin-rsc": "0.1.1",
60
61
  "rspack-manifest-plugin": "5.2.2",
61
- "ts-deepmerge": "8.0.0",
62
- "@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.5.0-ultramodern.7"
62
+ "ts-deepmerge": "8.0.0"
63
63
  },
64
64
  "devDependencies": {
65
- "@rslib/core": "0.23.1",
65
+ "@modern-js/types": "npm:@bleedingdev/modern-js-types@3.5.0-ultramodern.75",
66
+ "@rslib/core": "0.23.2",
67
+ "@scripts/rstest-config": "2.66.0",
66
68
  "@types/html-minifier-terser": "^7.0.2",
67
69
  "@types/lodash": "^4.17.24",
68
70
  "react": "^19.2.7",
69
71
  "terser": "^5.48.0",
70
- "typescript": "^6.0.3",
71
- "@modern-js/types": "npm:@bleedingdev/modern-js-types@3.5.0-ultramodern.7",
72
- "@scripts/rstest-config": "2.66.0"
72
+ "typescript": "^7.0.2"
73
73
  },
74
74
  "publishConfig": {
75
- "access": "public",
76
- "registry": "https://registry.npmjs.org/"
75
+ "access": "public"
77
76
  },
78
77
  "scripts": {
79
78
  "build": "rslib build && pnpm -w tsgo:dts \"$PWD\"",