@octanejs/tanstack-start 0.1.27 → 0.1.29

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 (38) hide show
  1. package/README.md +19 -1
  2. package/THIRD_PARTY_NOTICES.md +6 -5
  3. package/package.json +18 -6
  4. package/src/client-only-server-strip-loader.js +7 -0
  5. package/src/client-only-server-strip.js +34 -25
  6. package/src/internal/README.md +7 -7
  7. package/src/internal/start-plugin-core/rsbuild/import-protection.d.ts +27 -0
  8. package/src/internal/start-plugin-core/rsbuild/import-protection.js +1193 -0
  9. package/src/internal/start-plugin-core/rsbuild/index.d.ts +9 -0
  10. package/src/internal/start-plugin-core/rsbuild/index.js +3 -0
  11. package/src/internal/start-plugin-core/rsbuild/normalized-client-build.d.ts +20 -0
  12. package/src/internal/start-plugin-core/rsbuild/normalized-client-build.js +261 -0
  13. package/src/internal/start-plugin-core/rsbuild/planning.d.ts +56 -0
  14. package/src/internal/start-plugin-core/rsbuild/planning.js +173 -0
  15. package/src/internal/start-plugin-core/rsbuild/plugin.d.ts +7 -0
  16. package/src/internal/start-plugin-core/rsbuild/plugin.js +504 -0
  17. package/src/internal/start-plugin-core/rsbuild/post-build.d.ts +10 -0
  18. package/src/internal/start-plugin-core/rsbuild/post-build.js +59 -0
  19. package/src/internal/start-plugin-core/rsbuild/schema.d.ts +2441 -0
  20. package/src/internal/start-plugin-core/rsbuild/schema.js +28 -0
  21. package/src/internal/start-plugin-core/rsbuild/server-middleware.d.ts +32 -0
  22. package/src/internal/start-plugin-core/rsbuild/server-middleware.js +139 -0
  23. package/src/internal/start-plugin-core/rsbuild/start-compiler-host.d.ts +36 -0
  24. package/src/internal/start-plugin-core/rsbuild/start-compiler-host.js +322 -0
  25. package/src/internal/start-plugin-core/rsbuild/start-compiler-metadata-loader.d.ts +10 -0
  26. package/src/internal/start-plugin-core/rsbuild/start-compiler-metadata-loader.js +12 -0
  27. package/src/internal/start-plugin-core/rsbuild/start-compiler-metadata.d.ts +14 -0
  28. package/src/internal/start-plugin-core/rsbuild/start-compiler-metadata.js +5 -0
  29. package/src/internal/start-plugin-core/rsbuild/start-router-plugin.d.ts +19 -0
  30. package/src/internal/start-plugin-core/rsbuild/start-router-plugin.js +69 -0
  31. package/src/internal/start-plugin-core/rsbuild/swc-rsc.d.ts +17 -0
  32. package/src/internal/start-plugin-core/rsbuild/swc-rsc.js +118 -0
  33. package/src/internal/start-plugin-core/rsbuild/types.d.ts +17 -0
  34. package/src/internal/start-plugin-core/rsbuild/types.js +0 -0
  35. package/src/internal/start-plugin-core/rsbuild/virtual-modules.d.ts +60 -0
  36. package/src/internal/start-plugin-core/rsbuild/virtual-modules.js +359 -0
  37. package/src/plugin-rsbuild.d.ts +25 -0
  38. package/src/plugin-rsbuild.js +79 -0
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  TanStack Start for Octane. This package owns the renderer integration needed
4
4
  for file-route generation, route code splitting, server functions, streaming
5
- SSR, hydration, and Vite development and production builds.
5
+ SSR, hydration, and Vite or Rsbuild development and production builds.
6
6
 
7
7
  It uses [`@octanejs/tanstack-router`](../tanstack-router) for the public router
8
8
  binding and published renderer-neutral TanStack core packages for shared Start
@@ -25,6 +25,23 @@ The plugin installs Octane compilation before route analysis, generates TSRX
25
25
  file routes with imports from `@octanejs/tanstack-router`, compiles Start's
26
26
  environment-specific APIs, and configures the client and SSR Vite environments.
27
27
 
28
+ ## Rsbuild setup
29
+
30
+ ```ts
31
+ import { defineConfig } from '@rsbuild/core';
32
+ import { tanstackStart } from '@octanejs/tanstack-start/plugin/rsbuild';
33
+
34
+ export default defineConfig({
35
+ plugins: [tanstackStart()],
36
+ });
37
+ ```
38
+
39
+ The Rsbuild plugin installs the Octane Rspack compiler and Start's native
40
+ Rsbuild adapter together. It creates separate `client` and `ssr` environments,
41
+ emits production assets to `dist/client` and the fetch-style server entry to
42
+ `dist/server`, and provides the same route generation, server functions,
43
+ streaming SSR, import protection, and prerendering behavior as the Vite entry.
44
+
28
45
  Application code imports Start APIs from this package and router APIs from the
29
46
  Octane router binding:
30
47
 
@@ -39,6 +56,7 @@ import { createFileRoute } from '@octanejs/tanstack-router';
39
56
  - `@octanejs/tanstack-start/client`
40
57
  - `@octanejs/tanstack-start/server`
41
58
  - `@octanejs/tanstack-start/plugin/vite`
59
+ - `@octanejs/tanstack-start/plugin/rsbuild`
42
60
  - RPC and environment-marker entries used by the Start compiler
43
61
  - `@octanejs/tanstack-start/server-entry`
44
62
 
@@ -1,10 +1,11 @@
1
1
  # Third-party notices
2
2
 
3
- The Start compiler, route generator, router plugin, client runtime, and server
4
- runtime in this package are derived from TanStack Router pull request #7847,
5
- snapshot `753f919e`, and later Octane-specific fixes maintained in this
6
- repository. That work is copyright Tanner Linsley and TanStack contributors and
7
- is used under the MIT License shipped with this package.
3
+ The Start compiler, route generator, router plugin, Vite and Rsbuild adapters,
4
+ client runtime, and server runtime in this package are derived from TanStack
5
+ Router pull request #7847, snapshot `753f919e`, and later Octane-specific fixes
6
+ maintained in this repository. That work is copyright Tanner Linsley and
7
+ TanStack contributors and is used under the MIT License shipped with this
8
+ package.
8
9
 
9
10
  The native streaming path is adapted to Octane's `StreamOptions.injection` API
10
11
  so streamed router HTML is merged by the renderer rather than by a byte-level
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@octanejs/tanstack-start",
3
- "version": "0.1.27",
4
- "description": "TanStack Start for Octane, including file-route generation, server functions, SSR streaming, hydration, and Vite integration.",
3
+ "version": "0.1.29",
4
+ "description": "TanStack Start for Octane, including file-route generation, server functions, SSR streaming, hydration, and Vite or Rsbuild integration.",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
7
  "engines": {
@@ -43,6 +43,7 @@
43
43
  "#tanstack-start/router-plugin/*": "./src/internal/router-plugin/*.js",
44
44
  "#tanstack-start/plugin-core": "./src/internal/start-plugin-core/index.js",
45
45
  "#tanstack-start/plugin-core/vite": "./src/internal/start-plugin-core/vite/index.js",
46
+ "#tanstack-start/plugin-core/rsbuild": "./src/internal/start-plugin-core/rsbuild/index.js",
46
47
  "#tanstack-start/plugin-core/*": "./src/internal/start-plugin-core/*.js"
47
48
  },
48
49
  "exports": {
@@ -96,6 +97,11 @@
96
97
  "import": "./src/plugin-vite.js",
97
98
  "default": "./src/plugin-vite.js"
98
99
  },
100
+ "./plugin/rsbuild": {
101
+ "types": "./src/plugin-rsbuild.d.ts",
102
+ "import": "./src/plugin-rsbuild.js",
103
+ "default": "./src/plugin-rsbuild.js"
104
+ },
99
105
  "./server-entry": {
100
106
  "types": "./src/server-entry.d.ts",
101
107
  "import": "./src/server-entry.js",
@@ -133,24 +139,30 @@
133
139
  "vitefu": "^1.1.1",
134
140
  "xmlbuilder2": "^4.0.3",
135
141
  "zod": "^4.4.3",
136
- "@octanejs/tanstack-router": "0.1.37"
142
+ "@octanejs/rspack-plugin": "0.1.35",
143
+ "@octanejs/tanstack-router": "0.1.39"
137
144
  },
138
145
  "peerDependencies": {
146
+ "@rsbuild/core": "^2.0.0",
139
147
  "vite": ">=7.0.0",
140
- "octane": "0.1.38"
148
+ "octane": "0.1.40"
141
149
  },
142
150
  "peerDependenciesMeta": {
151
+ "@rsbuild/core": {
152
+ "optional": true
153
+ },
143
154
  "vite": {
144
155
  "optional": true
145
156
  }
146
157
  },
147
158
  "devDependencies": {
159
+ "@rsbuild/core": "^2.1.6",
148
160
  "@types/node": "^24.13.3",
149
161
  "vite": "^8.1.5",
150
162
  "vitest": "^4.1.10",
151
- "octane": "0.1.38"
163
+ "octane": "0.1.40"
152
164
  },
153
165
  "scripts": {
154
- "test": "cd ../.. && vitest run --project tanstack-start"
166
+ "test": "cd ../.. && vitest run --project tanstack-start --project tanstack-start-rsbuild"
155
167
  }
156
168
  }
@@ -0,0 +1,7 @@
1
+ import { clientOnlyServerStripTransform } from './client-only-server-strip.js';
2
+
3
+ export default function clientOnlyServerStripLoader(source) {
4
+ const result = clientOnlyServerStripTransform(source, this.resourcePath);
5
+ if (!result) return source;
6
+ this.callback(null, result.code, result.map);
7
+ }
@@ -2,6 +2,39 @@ import MagicString from 'magic-string';
2
2
  import { compileToVolarMappings } from 'octane/compiler/volar';
3
3
  import { START_ENVIRONMENT_NAMES } from '#tanstack-start/plugin-core/vite';
4
4
 
5
+ /**
6
+ * Strip children of `<ClientOnly>` from server TSRX source. Returns
7
+ * `{ code, map }` when a rewrite was applied, or `undefined` when the source
8
+ * needs no changes. Shared by the Vite and Rsbuild integrations.
9
+ */
10
+ export function clientOnlyServerStripTransform(code, id) {
11
+ if (!code.includes('ClientOnly')) return undefined;
12
+
13
+ const filename = id.split('?', 1)[0];
14
+ const { sourceAst } = compileToVolarMappings(code, filename);
15
+ const childReplacements = stripClientOnlyChildren(sourceAst);
16
+ if (childReplacements.length === 0) return undefined;
17
+
18
+ const prunedImportSpecifiers = findImportsUsedOnlyInRanges(sourceAst, childReplacements);
19
+ const replacements = [
20
+ ...rewritePrunedImports(code, sourceAst, prunedImportSpecifiers),
21
+ ...childReplacements,
22
+ ];
23
+ const output = new MagicString(code);
24
+ for (const replacement of replacements.sort((a, b) => b.start - a.start)) {
25
+ output.overwrite(replacement.start, replacement.end, replacement.content);
26
+ }
27
+
28
+ return {
29
+ code: output.toString(),
30
+ map: output.generateMap({
31
+ source: filename,
32
+ includeContent: true,
33
+ hires: true,
34
+ }),
35
+ };
36
+ }
37
+
5
38
  /**
6
39
  * Remove the children of the Router ClientOnly binding before Octane compiles
7
40
  * server TSRX. This keeps client-only imports out of the server module graph,
@@ -20,31 +53,7 @@ export function octaneClientOnlyServerStrip() {
20
53
  code: { include: ['ClientOnly'] },
21
54
  },
22
55
  handler(code, id) {
23
- if (!code.includes('ClientOnly')) return undefined;
24
-
25
- const filename = id.split('?', 1)[0];
26
- const { sourceAst } = compileToVolarMappings(code, filename);
27
- const childReplacements = stripClientOnlyChildren(sourceAst);
28
- if (childReplacements.length === 0) return undefined;
29
-
30
- const prunedImportSpecifiers = findImportsUsedOnlyInRanges(sourceAst, childReplacements);
31
- const replacements = [
32
- ...rewritePrunedImports(code, sourceAst, prunedImportSpecifiers),
33
- ...childReplacements,
34
- ];
35
- const output = new MagicString(code);
36
- for (const replacement of replacements.sort((a, b) => b.start - a.start)) {
37
- output.overwrite(replacement.start, replacement.end, replacement.content);
38
- }
39
-
40
- return {
41
- code: output.toString(),
42
- map: output.generateMap({
43
- source: filename,
44
- includeContent: true,
45
- hires: true,
46
- }),
47
- };
56
+ return clientOnlyServerStripTransform(code, id);
48
57
  },
49
58
  },
50
59
  };
@@ -1,14 +1,14 @@
1
1
  # Start integration internals
2
2
 
3
- These modules are the package-owned Router generator, Router Vite plugin, and
4
- Start compiler/Vite core used by the Octane adapter. They are derived from the
5
- TanStack framework-adapter snapshot identified in the package notice, with
6
- Octane package-name mapping and repository fixes applied.
3
+ These modules are the package-owned Router generator, Router build-tool
4
+ plugins, and Start compiler cores used by the Octane Vite and Rsbuild adapters.
5
+ They are derived from the TanStack framework-adapter snapshot identified in the
6
+ package notice, with Octane package-name mapping and repository fixes applied.
7
7
 
8
- They are committed as executable ESM because `plugin/vite` must load from a
8
+ They are committed as executable ESM because the build plugins must load from a
9
9
  published package in plain Node before an application build exists. Internal
10
- package-import aliases keep the three implementation layers private while
11
- allowing their original module boundaries to remain reviewable.
10
+ package-import aliases keep the implementation layers private while allowing
11
+ their original module boundaries to remain reviewable.
12
12
 
13
13
  When updating the upstream basis, preserve the local package-name helpers,
14
14
  TSRX source masking, compiler-before-router plugin order, native streaming
@@ -0,0 +1,27 @@
1
+ import { FileMatchers } from '../import-protection/utils.js';
2
+ import { CompileStartFrameworkOptions, GetConfigFn } from '../types.js';
3
+ import { RsbuildPluginAPI } from '@rsbuild/core';
4
+ type ResolvedImportProtectionCheck =
5
+ | {
6
+ type: 'file';
7
+ fileMatch: FileMatchers['files'][number];
8
+ }
9
+ | {
10
+ type: 'marker';
11
+ };
12
+ export declare function getRsbuildResolvedImportProtectionCheck(
13
+ relativeResolved: string,
14
+ matchers: FileMatchers,
15
+ ): ResolvedImportProtectionCheck | undefined;
16
+ export declare function registerImportProtection(
17
+ api: RsbuildPluginAPI,
18
+ opts: {
19
+ getConfig: GetConfigFn;
20
+ framework: CompileStartFrameworkOptions;
21
+ environments: Array<{
22
+ name: string;
23
+ type: 'client' | 'server';
24
+ }>;
25
+ },
26
+ ): void;
27
+ export {};