@bleedingdev/modern-js-builder 3.5.0-ultramodern.100 → 3.5.0-ultramodern.102

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.
@@ -37,6 +37,7 @@ var __webpack_require__ = {};
37
37
  var __webpack_exports__ = {};
38
38
  __webpack_require__.r(__webpack_exports__);
39
39
  __webpack_require__.d(__webpack_exports__, {
40
+ createRscLayerMatchers: ()=>createRscLayerMatchers,
40
41
  enrichServerOnlyDiagnostics: ()=>enrichServerOnlyDiagnostics,
41
42
  getRscPlugins: ()=>getRscPlugins,
42
43
  pluginRscConfig: ()=>pluginRscConfig
@@ -54,6 +55,7 @@ const ENTRY_NAME_VAR = '__MODERN_JS_ENTRY_NAME';
54
55
  const SERVER_ONLY_MARKER_PATTERN = /(?:^|[/\\])server-only[/\\]index\.js(?:\?|$)/;
55
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;
56
57
  const SERVER_ONLY_DIAGNOSTIC_PREFIX = '[Modern.js RSC server-only diagnostic context]';
58
+ const ROUTE_DATA_FILE_PATTERN = /[/\\]routes[/\\](?:.*[/\\])?(?:layout|page|\$)\.(?:loader|data)\.[tj]sx?(?:\?.*)?$/;
57
59
  const createVirtualModule = (content)=>`data:text/javascript,${encodeURIComponent(content)}`;
58
60
  const isAsyncStorageExclude = (exclude)=>{
59
61
  if ('string' == typeof exclude) return ASYNC_STORAGE_PATTERN.test(exclude);
@@ -210,7 +212,7 @@ function pluginRscConfig() {
210
212
  } catch {
211
213
  emptyModulePath = external_path_default().resolve(__dirname, '../shared/rsc/rscEmptyModule');
212
214
  }
213
- chain.resolve.alias.set('server-only$', emptyModulePath);
215
+ chain.module.rule('rsc-route-data-server-only').test(ROUTE_DATA_FILE_PATTERN).resolve.alias.set('server-only$', emptyModulePath);
214
216
  const routeFilePattern = /[/\\]routes[/\\](?:.*[/\\])?(?:layout|page|\$)\.[tj]sx?$/;
215
217
  const appFilePattern = /[/\\]App\.[tj]sx?$/;
216
218
  const combinedPattern = new RegExp(`(${routeFilePattern.source}|${appFilePattern.source})`);
@@ -284,8 +286,7 @@ function pluginRscConfig() {
284
286
  }
285
287
  async function getRscPlugins(enableRsc, internalDirectory, environments) {
286
288
  if (enableRsc) {
287
- new RegExp(`${internalDirectory.replace(/[/\\]/g, '[/\\\\]')}[/\\\\][^/\\\\]*[/\\\\]routes`);
288
- const routeDataFileReg = /[/\\]routes[/\\](?:.*[/\\])?(?:layout|page|\$)\.(?:loader|data)\.[tj]sx?(?:\?.*)?$/;
289
+ const rscLayerMatchers = createRscLayerMatchers(internalDirectory);
289
290
  const { pluginRSC } = await import("rsbuild-plugin-rsc");
290
291
  return [
291
292
  pluginRSC({
@@ -298,7 +299,7 @@ async function getRscPlugins(enableRsc, internalDirectory, environments) {
298
299
  RENDER_RSC_SOURCE_PATTERN,
299
300
  RENDER_RSC_RSLIB_ENTRY_PATTERN,
300
301
  /AppProxy/,
301
- routeDataFileReg
302
+ ...rscLayerMatchers
302
303
  ]
303
304
  }
304
305
  }),
@@ -307,10 +308,19 @@ async function getRscPlugins(enableRsc, internalDirectory, environments) {
307
308
  }
308
309
  return [];
309
310
  }
311
+ function createRscLayerMatchers(internalDirectory) {
312
+ const routesFileReg = new RegExp(`${internalDirectory.replace(/[/\\]/g, '[/\\\\]')}[/\\\\][^/\\\\]*[/\\\\]routes`);
313
+ return [
314
+ routesFileReg,
315
+ ROUTE_DATA_FILE_PATTERN
316
+ ];
317
+ }
318
+ exports.createRscLayerMatchers = __webpack_exports__.createRscLayerMatchers;
310
319
  exports.enrichServerOnlyDiagnostics = __webpack_exports__.enrichServerOnlyDiagnostics;
311
320
  exports.getRscPlugins = __webpack_exports__.getRscPlugins;
312
321
  exports.pluginRscConfig = __webpack_exports__.pluginRscConfig;
313
322
  for(var __rspack_i in __webpack_exports__)if (-1 === [
323
+ "createRscLayerMatchers",
314
324
  "enrichServerOnlyDiagnostics",
315
325
  "getRscPlugins",
316
326
  "pluginRscConfig"
@@ -10,6 +10,7 @@ const ENTRY_NAME_VAR = '__MODERN_JS_ENTRY_NAME';
10
10
  const SERVER_ONLY_MARKER_PATTERN = /(?:^|[/\\])server-only[/\\]index\.js(?:\?|$)/;
11
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
12
  const SERVER_ONLY_DIAGNOSTIC_PREFIX = '[Modern.js RSC server-only diagnostic context]';
13
+ const ROUTE_DATA_FILE_PATTERN = /[/\\]routes[/\\](?:.*[/\\])?(?:layout|page|\$)\.(?:loader|data)\.[tj]sx?(?:\?.*)?$/;
13
14
  const createVirtualModule = (content)=>`data:text/javascript,${encodeURIComponent(content)}`;
14
15
  const isAsyncStorageExclude = (exclude)=>{
15
16
  if ('string' == typeof exclude) return ASYNC_STORAGE_PATTERN.test(exclude);
@@ -166,7 +167,7 @@ function pluginRscConfig() {
166
167
  } catch {
167
168
  emptyModulePath = path.resolve(__dirname, '../shared/rsc/rscEmptyModule');
168
169
  }
169
- chain.resolve.alias.set('server-only$', emptyModulePath);
170
+ chain.module.rule('rsc-route-data-server-only').test(ROUTE_DATA_FILE_PATTERN).resolve.alias.set('server-only$', emptyModulePath);
170
171
  const routeFilePattern = /[/\\]routes[/\\](?:.*[/\\])?(?:layout|page|\$)\.[tj]sx?$/;
171
172
  const appFilePattern = /[/\\]App\.[tj]sx?$/;
172
173
  const combinedPattern = new RegExp(`(${routeFilePattern.source}|${appFilePattern.source})`);
@@ -240,8 +241,7 @@ function pluginRscConfig() {
240
241
  }
241
242
  async function getRscPlugins(enableRsc, internalDirectory, environments) {
242
243
  if (enableRsc) {
243
- new RegExp(`${internalDirectory.replace(/[/\\]/g, '[/\\\\]')}[/\\\\][^/\\\\]*[/\\\\]routes`);
244
- const routeDataFileReg = /[/\\]routes[/\\](?:.*[/\\])?(?:layout|page|\$)\.(?:loader|data)\.[tj]sx?(?:\?.*)?$/;
244
+ const rscLayerMatchers = createRscLayerMatchers(internalDirectory);
245
245
  const { pluginRSC } = await import("rsbuild-plugin-rsc");
246
246
  return [
247
247
  pluginRSC({
@@ -254,7 +254,7 @@ async function getRscPlugins(enableRsc, internalDirectory, environments) {
254
254
  RENDER_RSC_SOURCE_PATTERN,
255
255
  RENDER_RSC_RSLIB_ENTRY_PATTERN,
256
256
  /AppProxy/,
257
- routeDataFileReg
257
+ ...rscLayerMatchers
258
258
  ]
259
259
  }
260
260
  }),
@@ -263,4 +263,11 @@ async function getRscPlugins(enableRsc, internalDirectory, environments) {
263
263
  }
264
264
  return [];
265
265
  }
266
- export { enrichServerOnlyDiagnostics, getRscPlugins, pluginRscConfig };
266
+ function createRscLayerMatchers(internalDirectory) {
267
+ const routesFileReg = new RegExp(`${internalDirectory.replace(/[/\\]/g, '[/\\\\]')}[/\\\\][^/\\\\]*[/\\\\]routes`);
268
+ return [
269
+ routesFileReg,
270
+ ROUTE_DATA_FILE_PATTERN
271
+ ];
272
+ }
273
+ export { createRscLayerMatchers, enrichServerOnlyDiagnostics, getRscPlugins, pluginRscConfig };
@@ -15,6 +15,7 @@ const ENTRY_NAME_VAR = '__MODERN_JS_ENTRY_NAME';
15
15
  const SERVER_ONLY_MARKER_PATTERN = /(?:^|[/\\])server-only[/\\]index\.js(?:\?|$)/;
16
16
  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;
17
17
  const SERVER_ONLY_DIAGNOSTIC_PREFIX = '[Modern.js RSC server-only diagnostic context]';
18
+ const ROUTE_DATA_FILE_PATTERN = /[/\\]routes[/\\](?:.*[/\\])?(?:layout|page|\$)\.(?:loader|data)\.[tj]sx?(?:\?.*)?$/;
18
19
  const createVirtualModule = (content)=>`data:text/javascript,${encodeURIComponent(content)}`;
19
20
  const isAsyncStorageExclude = (exclude)=>{
20
21
  if ('string' == typeof exclude) return ASYNC_STORAGE_PATTERN.test(exclude);
@@ -171,7 +172,7 @@ function pluginRscConfig() {
171
172
  } catch {
172
173
  emptyModulePath = path.resolve(__rspack_import_meta_dirname__, '../shared/rsc/rscEmptyModule');
173
174
  }
174
- chain.resolve.alias.set('server-only$', emptyModulePath);
175
+ chain.module.rule('rsc-route-data-server-only').test(ROUTE_DATA_FILE_PATTERN).resolve.alias.set('server-only$', emptyModulePath);
175
176
  const routeFilePattern = /[/\\]routes[/\\](?:.*[/\\])?(?:layout|page|\$)\.[tj]sx?$/;
176
177
  const appFilePattern = /[/\\]App\.[tj]sx?$/;
177
178
  const combinedPattern = new RegExp(`(${routeFilePattern.source}|${appFilePattern.source})`);
@@ -245,8 +246,7 @@ function pluginRscConfig() {
245
246
  }
246
247
  async function getRscPlugins(enableRsc, internalDirectory, environments) {
247
248
  if (enableRsc) {
248
- new RegExp(`${internalDirectory.replace(/[/\\]/g, '[/\\\\]')}[/\\\\][^/\\\\]*[/\\\\]routes`);
249
- const routeDataFileReg = /[/\\]routes[/\\](?:.*[/\\])?(?:layout|page|\$)\.(?:loader|data)\.[tj]sx?(?:\?.*)?$/;
249
+ const rscLayerMatchers = createRscLayerMatchers(internalDirectory);
250
250
  const { pluginRSC } = await import("rsbuild-plugin-rsc");
251
251
  return [
252
252
  pluginRSC({
@@ -259,7 +259,7 @@ async function getRscPlugins(enableRsc, internalDirectory, environments) {
259
259
  RENDER_RSC_SOURCE_PATTERN,
260
260
  RENDER_RSC_RSLIB_ENTRY_PATTERN,
261
261
  /AppProxy/,
262
- routeDataFileReg
262
+ ...rscLayerMatchers
263
263
  ]
264
264
  }
265
265
  }),
@@ -268,4 +268,11 @@ async function getRscPlugins(enableRsc, internalDirectory, environments) {
268
268
  }
269
269
  return [];
270
270
  }
271
- export { enrichServerOnlyDiagnostics, getRscPlugins, pluginRscConfig };
271
+ function createRscLayerMatchers(internalDirectory) {
272
+ const routesFileReg = new RegExp(`${internalDirectory.replace(/[/\\]/g, '[/\\\\]')}[/\\\\][^/\\\\]*[/\\\\]routes`);
273
+ return [
274
+ routesFileReg,
275
+ ROUTE_DATA_FILE_PATTERN
276
+ ];
277
+ }
278
+ export { createRscLayerMatchers, enrichServerOnlyDiagnostics, getRscPlugins, pluginRscConfig };
@@ -56,4 +56,5 @@ export declare function getRscPlugins(enableRsc: boolean, internalDirectory: str
56
56
  server?: string;
57
57
  client?: string;
58
58
  }): Promise<RsbuildPlugin[]>;
59
+ export declare function createRscLayerMatchers(internalDirectory: string): RegExp[];
59
60
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bleedingdev/modern-js-builder",
3
- "version": "3.5.0-ultramodern.100",
3
+ "version": "3.5.0-ultramodern.102",
4
4
  "description": "A builder for Modern.js",
5
5
  "repository": {
6
6
  "type": "git",
@@ -26,7 +26,7 @@
26
26
  "dist"
27
27
  ],
28
28
  "dependencies": {
29
- "@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.5.0-ultramodern.100",
29
+ "@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.5.0-ultramodern.102",
30
30
  "@rsbuild/core": "2.1.5",
31
31
  "@rsbuild/plugin-assets-retry": "2.0.1",
32
32
  "@rsbuild/plugin-check-syntax": "2.0.0",
@@ -62,7 +62,7 @@
62
62
  "ts-deepmerge": "8.0.0"
63
63
  },
64
64
  "devDependencies": {
65
- "@modern-js/types": "npm:@bleedingdev/modern-js-types@3.5.0-ultramodern.100",
65
+ "@modern-js/types": "npm:@bleedingdev/modern-js-types@3.5.0-ultramodern.102",
66
66
  "@rslib/core": "0.23.2",
67
67
  "@scripts/rstest-config": "2.66.0",
68
68
  "@types/html-minifier-terser": "^7.0.2",