rsbuild-plugin-react-router 0.2.0 → 0.3.0

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 (96) hide show
  1. package/README.md +185 -204
  2. package/dist/451.js +1087 -0
  3. package/dist/bounded-cache.d.ts +1 -0
  4. package/dist/build-manifest.d.ts +1 -1
  5. package/dist/build-output-transforms.d.ts +30 -0
  6. package/dist/concurrency.d.ts +2 -0
  7. package/dist/config-imports.d.ts +3 -0
  8. package/dist/constants.d.ts +3 -0
  9. package/dist/dev-generation.d.ts +25 -0
  10. package/dist/dev-runtime-artifacts.d.ts +39 -0
  11. package/dist/dev-runtime-compilation.d.ts +32 -0
  12. package/dist/dev-runtime-controller.d.ts +14 -0
  13. package/dist/dev-runtime-session.d.ts +34 -0
  14. package/dist/dev-server.d.ts +11 -2
  15. package/dist/export-utils.d.ts +15 -7
  16. package/dist/index.cjs +3050 -1244
  17. package/dist/index.d.ts +4 -1
  18. package/dist/index.js +2015 -1279
  19. package/dist/lazy-compilation.d.ts +5 -0
  20. package/dist/manifest.d.ts +32 -9
  21. package/dist/modify-browser-manifest.d.ts +30 -13
  22. package/dist/parallel-route-transform-protocol.d.ts +25 -0
  23. package/dist/parallel-route-transform-worker.d.ts +1 -0
  24. package/dist/parallel-route-transform-worker.js +38 -0
  25. package/dist/parallel-route-transforms.d.ts +14 -0
  26. package/dist/performance.d.ts +26 -0
  27. package/dist/plugin-utils.d.ts +2 -12
  28. package/dist/prerender-build.d.ts +32 -0
  29. package/dist/prerender.d.ts +28 -2
  30. package/dist/react-router-config.d.ts +8 -1
  31. package/dist/route-artifacts.d.ts +33 -0
  32. package/dist/route-ast.d.ts +21 -0
  33. package/dist/route-chunks.d.ts +9 -1
  34. package/dist/route-component-transform.d.ts +5 -0
  35. package/dist/route-export-pruning.d.ts +6 -0
  36. package/dist/route-export-resolution.d.ts +5 -0
  37. package/dist/route-transform-tasks.d.ts +47 -0
  38. package/dist/route-watch.d.ts +27 -0
  39. package/dist/server-build-plan.d.ts +22 -0
  40. package/dist/server-utils.d.ts +3 -2
  41. package/dist/templates/entry.server.cjs +3 -3
  42. package/dist/templates/entry.server.js +3 -3
  43. package/dist/typegen.d.ts +2 -0
  44. package/dist/types.d.ts +30 -12
  45. package/dist/virtual-modules.d.ts +2 -0
  46. package/dist/warnings/warn-on-client-source-maps.d.ts +1 -0
  47. package/dist/yuku.d.ts +15 -0
  48. package/package.json +22 -19
  49. package/src/bounded-cache.ts +18 -0
  50. package/src/build-manifest.ts +168 -0
  51. package/src/build-output-transforms.ts +273 -0
  52. package/src/concurrency.ts +34 -0
  53. package/src/config-imports.ts +45 -0
  54. package/src/constants.ts +91 -0
  55. package/src/dev-generation.ts +700 -0
  56. package/src/dev-runtime-artifacts.ts +207 -0
  57. package/src/dev-runtime-compilation.ts +92 -0
  58. package/src/dev-runtime-controller.ts +462 -0
  59. package/src/dev-runtime-session.ts +184 -0
  60. package/src/dev-server.ts +58 -0
  61. package/src/export-utils.ts +219 -0
  62. package/src/index.ts +1025 -0
  63. package/src/lazy-compilation.ts +94 -0
  64. package/src/manifest.ts +480 -0
  65. package/src/modify-browser-manifest.ts +245 -0
  66. package/src/parallel-route-transform-protocol.ts +35 -0
  67. package/src/parallel-route-transform-worker.ts +82 -0
  68. package/src/parallel-route-transforms.ts +332 -0
  69. package/src/performance.ts +254 -0
  70. package/src/plugin-utils.ts +82 -0
  71. package/src/prerender-build.ts +623 -0
  72. package/src/prerender.ts +367 -0
  73. package/src/react-router-config.ts +220 -0
  74. package/src/route-artifacts.ts +155 -0
  75. package/src/route-ast.ts +163 -0
  76. package/src/route-chunks.ts +857 -0
  77. package/src/route-component-transform.ts +314 -0
  78. package/src/route-config.ts +106 -0
  79. package/src/route-export-pruning.ts +668 -0
  80. package/src/route-export-resolution.ts +329 -0
  81. package/src/route-transform-tasks.ts +249 -0
  82. package/src/route-watch.ts +322 -0
  83. package/src/server-build-plan.ts +91 -0
  84. package/src/server-utils.ts +210 -0
  85. package/src/ssr-externals.ts +59 -0
  86. package/src/templates/context.ts +12 -0
  87. package/src/templates/entry.client.tsx +12 -0
  88. package/src/templates/entry.server.tsx +76 -0
  89. package/src/typegen.ts +49 -0
  90. package/src/types.ts +82 -0
  91. package/src/validation/validate-plugin-order.ts +76 -0
  92. package/src/virtual-modules.ts +30 -0
  93. package/src/warnings/warn-on-client-source-maps.ts +96 -0
  94. package/src/yuku.ts +67 -0
  95. package/dist/0~rslib-runtime.js +0 -16
  96. package/dist/babel.d.ts +0 -8
@@ -0,0 +1,45 @@
1
+ import type { ModuleCache } from 'jiti';
2
+ import { resolve } from 'pathe';
3
+
4
+ const normalizePath = (filePath: string): string => resolve(filePath);
5
+
6
+ const isNodeModulePath = (filePath: string): boolean =>
7
+ filePath.split(/[\\/]/).includes('node_modules');
8
+
9
+ export const collectConfigImportWatchPaths = (
10
+ configPath: string,
11
+ moduleCache: ModuleCache,
12
+ previousCacheKeys: ReadonlySet<string>
13
+ ): string[] => {
14
+ const normalizedConfigPath = normalizePath(configPath);
15
+ const watchPaths = new Set<string>();
16
+
17
+ for (const [cacheKey, module] of Object.entries(moduleCache)) {
18
+ if (previousCacheKeys.has(cacheKey)) {
19
+ continue;
20
+ }
21
+
22
+ const importPath = normalizePath(module?.filename ?? cacheKey);
23
+ if (importPath === normalizedConfigPath || isNodeModulePath(importPath)) {
24
+ continue;
25
+ }
26
+
27
+ watchPaths.add(importPath);
28
+ }
29
+
30
+ return Array.from(watchPaths);
31
+ };
32
+
33
+ export const clearConfigImportCache = (
34
+ moduleCache: ModuleCache,
35
+ filePaths: readonly string[]
36
+ ): void => {
37
+ const normalizedFilePaths = new Set(filePaths.map(normalizePath));
38
+
39
+ for (const [cacheKey, module] of Object.entries(moduleCache)) {
40
+ const cachedPath = normalizePath(module?.filename ?? cacheKey);
41
+ if (normalizedFilePaths.has(cachedPath)) {
42
+ delete moduleCache[cacheKey];
43
+ }
44
+ }
45
+ };
@@ -0,0 +1,91 @@
1
+ export const PLUGIN_NAME = 'rsbuild:react-router';
2
+
3
+ export const JS_EXTENSIONS = [
4
+ '.tsx',
5
+ '.ts',
6
+ '.jsx',
7
+ '.js',
8
+ '.mjs',
9
+ '.mts',
10
+ ] as const;
11
+
12
+ export const JS_LOADERS = {
13
+ '.ts': 'ts',
14
+ '.tsx': 'tsx',
15
+ '.js': 'js',
16
+ '.jsx': 'jsx',
17
+ '.mjs': 'js',
18
+ '.mts': 'ts',
19
+ } as const;
20
+
21
+ export const BUILD_CLIENT_ROUTE_QUERY_STRING =
22
+ '?__react-router-build-client-route';
23
+
24
+ export const SERVER_ONLY_ROUTE_EXPORTS = [
25
+ 'loader',
26
+ 'action',
27
+ 'middleware',
28
+ 'headers',
29
+ ] as const;
30
+
31
+ export const SERVER_ONLY_ROUTE_EXPORTS_SET: ReadonlySet<string> = new Set(
32
+ SERVER_ONLY_ROUTE_EXPORTS
33
+ );
34
+
35
+ // Client route exports are split into non-component exports and component exports.
36
+ // This mirrors upstream React Router Vite plugin intent and is used for export filtering.
37
+ export const CLIENT_NON_COMPONENT_EXPORTS = [
38
+ 'clientAction',
39
+ 'clientLoader',
40
+ 'clientMiddleware',
41
+ 'handle',
42
+ 'meta',
43
+ 'links',
44
+ 'shouldRevalidate',
45
+ ] as const;
46
+
47
+ export const CLIENT_COMPONENT_EXPORTS = [
48
+ 'default',
49
+ 'ErrorBoundary',
50
+ 'HydrateFallback',
51
+ 'Layout',
52
+ ] as const;
53
+
54
+ export const CLIENT_ROUTE_EXPORTS: readonly (
55
+ | (typeof CLIENT_NON_COMPONENT_EXPORTS)[number]
56
+ | (typeof CLIENT_COMPONENT_EXPORTS)[number]
57
+ )[] = [...CLIENT_NON_COMPONENT_EXPORTS, ...CLIENT_COMPONENT_EXPORTS];
58
+
59
+ export const CLIENT_ROUTE_EXPORTS_SET: ReadonlySet<string> = new Set(
60
+ CLIENT_ROUTE_EXPORTS
61
+ );
62
+
63
+ export const NAMED_COMPONENT_EXPORTS = [
64
+ 'HydrateFallback',
65
+ 'ErrorBoundary',
66
+ ] as const;
67
+
68
+ export const NAMED_COMPONENT_EXPORTS_SET: ReadonlySet<string> = new Set(
69
+ NAMED_COMPONENT_EXPORTS
70
+ );
71
+
72
+ export const SERVER_EXPORTS = {
73
+ loader: 'loader',
74
+ action: 'action',
75
+ middleware: 'middleware',
76
+ headers: 'headers',
77
+ } as const;
78
+
79
+ export const CLIENT_EXPORTS = {
80
+ clientAction: 'clientAction',
81
+ clientLoader: 'clientLoader',
82
+ clientMiddleware: 'clientMiddleware',
83
+ default: 'default',
84
+ ErrorBoundary: 'ErrorBoundary',
85
+ handle: 'handle',
86
+ HydrateFallback: 'HydrateFallback',
87
+ Layout: 'Layout',
88
+ links: 'links',
89
+ meta: 'meta',
90
+ shouldRevalidate: 'shouldRevalidate',
91
+ } as const;