@ecopages/react 0.2.0-alpha.1 → 0.2.0-alpha.11
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.
- package/CHANGELOG.md +9 -43
- package/README.md +143 -17
- package/package.json +3 -3
- package/src/react-hmr-strategy.d.ts +25 -21
- package/src/react-hmr-strategy.js +78 -110
- package/src/react-renderer.d.ts +135 -12
- package/src/react-renderer.js +439 -82
- package/src/react.plugin.d.ts +17 -5
- package/src/react.plugin.js +45 -13
- package/src/router-adapter.d.ts +2 -2
- package/src/services/react-bundle.service.d.ts +4 -25
- package/src/services/react-bundle.service.js +37 -91
- package/src/services/react-hydration-asset.service.js +3 -3
- package/src/services/react-page-module.service.d.ts +3 -0
- package/src/services/react-page-module.service.js +24 -17
- package/src/services/react-runtime-bundle.service.d.ts +12 -12
- package/src/services/react-runtime-bundle.service.js +98 -180
- package/src/utils/client-graph-boundary-plugin.js +149 -11
- package/src/utils/declared-modules.js +4 -1
- package/src/utils/foreign-jsx-override-plugin.d.ts +19 -0
- package/src/utils/foreign-jsx-override-plugin.js +43 -0
- package/src/utils/hydration-scripts.d.ts +18 -1
- package/src/utils/hydration-scripts.js +95 -37
- package/src/utils/reachability-analyzer.d.ts +12 -1
- package/src/utils/reachability-analyzer.js +101 -5
- package/src/utils/react-dom-runtime-interop-plugin.d.ts +5 -0
- package/src/utils/react-dom-runtime-interop-plugin.js +29 -0
- package/src/utils/react-mdx-loader-plugin.js +13 -5
- package/src/utils/react-runtime-specifier-map.d.ts +6 -0
- package/src/utils/react-runtime-specifier-map.js +37 -0
- package/src/utils/use-sync-external-store-shim-plugin.d.ts +5 -0
- package/src/utils/use-sync-external-store-shim-plugin.js +41 -0
- package/src/react-hmr-strategy.ts +0 -444
- package/src/react-renderer.ts +0 -403
- package/src/react.plugin.ts +0 -241
- package/src/router-adapter.ts +0 -95
- package/src/services/react-bundle.service.ts +0 -212
- package/src/services/react-hmr-page-metadata-cache.ts +0 -24
- package/src/services/react-hydration-asset.service.ts +0 -260
- package/src/services/react-page-module.service.ts +0 -214
- package/src/services/react-runtime-bundle.service.ts +0 -271
- package/src/utils/client-graph-boundary-plugin.ts +0 -590
- package/src/utils/client-only.ts +0 -27
- package/src/utils/declared-modules.ts +0 -99
- package/src/utils/dynamic.ts +0 -27
- package/src/utils/hmr-scripts.ts +0 -47
- package/src/utils/html-boundary.ts +0 -66
- package/src/utils/hydration-scripts.ts +0 -338
- package/src/utils/reachability-analyzer.ts +0 -440
- package/src/utils/react-mdx-loader-plugin.ts +0 -40
package/CHANGELOG.md
CHANGED
|
@@ -6,57 +6,23 @@ All notable changes to `@ecopages/react` are documented here.
|
|
|
6
6
|
|
|
7
7
|
## [UNRELEASED] — TBD
|
|
8
8
|
|
|
9
|
-
###
|
|
10
|
-
|
|
11
|
-
#### Render Reachability Analysis
|
|
12
|
-
|
|
13
|
-
- **Client render graph (Phase 1)** — Introduces a static reachability analysis step that builds an explicit graph of which components are rendered client-side (`cdfbd69e`).
|
|
14
|
-
- **OXC-powered reachability analyzer** — `reachability-analyzer.ts` uses OXC to parse and walk component ASTs, building a `ClientRenderGraph` that maps exported components to their client-side reach (`5412df6b`).
|
|
15
|
-
- **Explicit client graph boundaries** — Components must now declare explicit boundaries; the analyser enforces these to prevent over-hydration (`2912d6bd`).
|
|
16
|
-
- **Declared modules utility** — `declared-modules.ts` tracks which modules are declared as client boundaries.
|
|
17
|
-
|
|
18
|
-
#### Service Architecture Refactor
|
|
19
|
-
|
|
20
|
-
- **`ReactRuntimeBundleService`** — Manages runtime assets and specifier mapping for the React integration (`cfd3cb05`).
|
|
21
|
-
- **`ReactHydrationAssetService`** — Creates and manages hydration assets for client-side rendering (`cfd3cb05`).
|
|
22
|
-
- **`ReactBundleService`** — Handles esbuild bundle configuration for React components (`cfd3cb05`).
|
|
23
|
-
- **`ReactPageModuleService`** — Loads and compiles MDX/TSX page modules, including config resolution (`cfd3cb05`).
|
|
24
|
-
- The integration no longer builds a monolithic renderer — each concern is handled by a focused service.
|
|
25
|
-
|
|
26
|
-
#### HMR Improvements
|
|
9
|
+
### Bug Fixes
|
|
27
10
|
|
|
28
|
-
-
|
|
29
|
-
-
|
|
30
|
-
- **Client graph HMR stability** — HMR reloads now correctly respect client graph boundaries to avoid partial hydration mismatches (`2912d6bd`).
|
|
11
|
+
- Fixed development hydration, router HMR ownership, and page bootstraps across Bun, Vite, and Nitro flows.
|
|
12
|
+
- Fixed React page and MDX module loading to use host-provided loaders on Vite or Nitro and a lightweight browser `eco` shim in preview and build output.
|
|
31
13
|
|
|
32
|
-
|
|
14
|
+
### Features
|
|
33
15
|
|
|
34
|
-
-
|
|
35
|
-
- **`hydration-scripts.ts`** — Expanded with new helpers for generating and injecting hydration entry scripts.
|
|
16
|
+
- Added built-in React MDX support and reachability-based hydration analysis for React page bundles.
|
|
36
17
|
|
|
37
18
|
### Refactoring
|
|
38
19
|
|
|
39
|
-
-
|
|
40
|
-
- Ambient module declarations cleaned up (`5f46ecc5`).
|
|
41
|
-
- Client graph boundaries and runtime dependency wiring corrected (`4b6cd32e`).
|
|
42
|
-
- Updated test suite for esbuild adapter and Node.js runtime compatibility (`31a44458`).
|
|
43
|
-
|
|
44
|
-
### Bug Fixes
|
|
45
|
-
|
|
46
|
-
- Inlined the React MDX loader so React apps no longer need to install `@ecopages/mdx` when enabling React MDX support (`unreleased`).
|
|
47
|
-
- Fixed stale temp module race during Fast Refresh cycles (`b2cf8466`).
|
|
48
|
-
- Fixed client graph boundary wiring for runtime dependencies (`4b6cd32e`).
|
|
49
|
-
|
|
50
|
-
### Tests
|
|
51
|
-
|
|
52
|
-
- Added `html-boundary.test.ts` covering boundary wrapping utilities.
|
|
53
|
-
- Added `hydration-scripts.test.ts` with hydration script generation coverage.
|
|
54
|
-
- Added `reachability-analyzer.test.ts` (187 lines) covering export declaration reachability.
|
|
55
|
-
- Updated integration tests for esbuild adapter compatibility (`31a44458`).
|
|
20
|
+
- Consolidated React bundling, hydration, and runtime state behind shared service boundaries and `window.__ECO_PAGES__`.
|
|
56
21
|
|
|
57
22
|
---
|
|
58
23
|
|
|
59
24
|
## Migration Notes
|
|
60
25
|
|
|
61
|
-
- The React integration now requires explicit client boundary declarations
|
|
62
|
-
-
|
|
26
|
+
- The React integration now requires explicit client boundary declarations for client-rendered components.
|
|
27
|
+
- React MDX support is built in and no longer requires installing `@ecopages/mdx` just to enable React MDX routes.
|
|
28
|
+
- The internal service layer is not part of the public API and may change between releases.
|
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @ecopages/react
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
First-class integration for [React 19](https://react.dev/) in Ecopages. This plugin enables React SSR and client hydration, allowing you to build component-level React islands or full React Single Page Applications (SPAs).
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Installation
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
8
|
bunx jsr add @ecopages/react
|
|
@@ -10,10 +10,10 @@ bunx jsr add @ecopages/react
|
|
|
10
10
|
|
|
11
11
|
## Usage
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
Configure the plugin in your `eco.config.ts`:
|
|
14
14
|
|
|
15
15
|
```ts
|
|
16
|
-
import { ConfigBuilder } from '@ecopages/core';
|
|
16
|
+
import { ConfigBuilder } from '@ecopages/core/config-builder';
|
|
17
17
|
import { reactPlugin } from '@ecopages/react';
|
|
18
18
|
|
|
19
19
|
const config = await new ConfigBuilder()
|
|
@@ -24,16 +24,27 @@ const config = await new ConfigBuilder()
|
|
|
24
24
|
export default config;
|
|
25
25
|
```
|
|
26
26
|
|
|
27
|
+
## Component-Level Islands
|
|
28
|
+
|
|
29
|
+
By default, Ecopages React acts in island mode:
|
|
30
|
+
|
|
31
|
+
- SSR output preserves the authored DOM structure (no unnecessary wrapper elements).
|
|
32
|
+
- A stable `data-eco-component-id` attribute is attached to the component SSR root.
|
|
33
|
+
- The client bootstrap mounts the component via `createRoot()` strictly within that root boundary.
|
|
34
|
+
|
|
35
|
+
> [!TIP]
|
|
36
|
+
> **Full React SPA Routing:**
|
|
37
|
+
> If you are building full React pages and want client-side navigation (SPA), use [@ecopages/react-router](../react-router/README.md) and pass it to the react plugin: `reactPlugin({ router: ecoRouter() })`.
|
|
38
|
+
|
|
27
39
|
## MDX Support
|
|
28
40
|
|
|
29
|
-
The React plugin includes
|
|
41
|
+
The React plugin includes built-in MDX support. When enabled, you can write `.mdx` pages alongside `.tsx` pages with unified client-side routing, hydration, and HMR.
|
|
30
42
|
|
|
31
43
|
```ts
|
|
32
|
-
import { ConfigBuilder } from '@ecopages/core';
|
|
44
|
+
import { ConfigBuilder } from '@ecopages/core/config-builder';
|
|
33
45
|
import { reactPlugin } from '@ecopages/react';
|
|
34
46
|
|
|
35
47
|
const config = await new ConfigBuilder()
|
|
36
|
-
.setBaseUrl(import.meta.env.ECOPAGES_BASE_URL)
|
|
37
48
|
.setIntegrations([
|
|
38
49
|
reactPlugin({
|
|
39
50
|
mdx: {
|
|
@@ -49,17 +60,132 @@ const config = await new ConfigBuilder()
|
|
|
49
60
|
export default config;
|
|
50
61
|
```
|
|
51
62
|
|
|
52
|
-
|
|
63
|
+
## Server and Client Graph Contract
|
|
53
64
|
|
|
54
|
-
|
|
65
|
+
The React integration supports Node.js modules and server-only code **only on the server execution graph**.
|
|
66
|
+
|
|
67
|
+
- Server rendering can safely import `node:*` modules, database clients, filesystem utilities, etc.
|
|
68
|
+
- Client-hydrated React code must resolve to browser-safe modules only.
|
|
69
|
+
- If a server-only import crosses the boundary and becomes reachable by client code, **the client build will intentionally fail**.
|
|
70
|
+
|
|
71
|
+
Keep server helpers close, but separate them physically or logically so they do not leak into the client bundle.
|
|
72
|
+
|
|
73
|
+
## Client Graph Boundary Architecture
|
|
74
|
+
|
|
75
|
+
This section explains the internal contract used to keep the browser bundle minimal while preventing server-only code and request-only configuration from leaking into client output.
|
|
76
|
+
|
|
77
|
+
### Goal
|
|
78
|
+
|
|
79
|
+
The React integration has two jobs that must hold at the same time:
|
|
80
|
+
|
|
81
|
+
- Produce a browser-safe bundle for hydrated pages and islands.
|
|
82
|
+
- Preserve enough page code for hydration to reconstruct the same React tree the server rendered.
|
|
83
|
+
|
|
84
|
+
That means the client bundle must keep client-safe render logic, but it must drop server-only imports and server-only `eco.page(...)` options such as middleware and build-time metadata.
|
|
85
|
+
|
|
86
|
+
### Mental Model
|
|
87
|
+
|
|
88
|
+
Think about each React page as two related graphs:
|
|
89
|
+
|
|
90
|
+
1. **Server graph**: everything needed to render the page on the server. This graph may include middleware, request locals, database access, filesystem access, and other server-only modules.
|
|
91
|
+
2. **Client graph**: the smallest browser-safe subset needed to hydrate the rendered output in the browser.
|
|
92
|
+
|
|
93
|
+
The React integration builds the client graph conservatively. If a server-only module becomes reachable from the hydrated render path, the build should fail rather than silently shipping unsafe code.
|
|
94
|
+
|
|
95
|
+
### What Stays and What Goes
|
|
96
|
+
|
|
97
|
+
The client bundle keeps:
|
|
98
|
+
|
|
99
|
+
- The page component render path.
|
|
100
|
+
- Client-safe component dependencies reachable from render.
|
|
101
|
+
- Layout wiring needed for hydration.
|
|
102
|
+
- Router runtime state needed by [@ecopages/react-router](../react-router/README.md) when SPA mode is enabled.
|
|
103
|
+
|
|
104
|
+
The client bundle removes or excludes:
|
|
105
|
+
|
|
106
|
+
- Server-only imports that are not reachable from the hydrated render path.
|
|
107
|
+
- Server-only `eco.page(...)` options such as `cache`, `middleware`, `metadata`, `staticProps`, and `staticPaths`.
|
|
108
|
+
- Request-time configuration that has no meaning in the browser.
|
|
109
|
+
|
|
110
|
+
Important:
|
|
111
|
+
|
|
112
|
+
- `render` must stay in the client bundle, because hydration needs it to reconstruct the page tree.
|
|
113
|
+
- `requires` does **not** stay in the browser page config. It is used on the server to decide which `locals` keys may be serialized into the hydration payload.
|
|
114
|
+
|
|
115
|
+
### AST Pipeline Order
|
|
116
|
+
|
|
117
|
+
The browser-bound transform in [packages/integrations/react/src/utils/client-graph-boundary-plugin.ts](packages/integrations/react/src/utils/client-graph-boundary-plugin.ts) follows this order:
|
|
118
|
+
|
|
119
|
+
1. Parse the module and build a reachability view of the client render graph.
|
|
120
|
+
2. Remove imports that are not allowed or not reachable from the client graph.
|
|
121
|
+
3. Reparse the transformed source.
|
|
122
|
+
4. Strip server-only `eco.page(...)` object properties from the reparsed AST.
|
|
123
|
+
5. Return the rewritten source to the bundle step.
|
|
124
|
+
|
|
125
|
+
The reparse step is important. Once import edits change source offsets, the original AST locations are stale. Reusing them for later edits can corrupt the output or remove the wrong code.
|
|
126
|
+
|
|
127
|
+
### Why `eco.page(...)` Options Are Stripped
|
|
128
|
+
|
|
129
|
+
Import pruning alone is not enough.
|
|
130
|
+
|
|
131
|
+
Consider a page like this:
|
|
132
|
+
|
|
133
|
+
```tsx
|
|
134
|
+
import { authMiddleware } from './auth.server';
|
|
135
|
+
|
|
136
|
+
export default eco.page({
|
|
137
|
+
cache: 'dynamic',
|
|
138
|
+
middleware: [authMiddleware],
|
|
139
|
+
requires: ['session'] as const,
|
|
140
|
+
render: () => <div>Dashboard</div>,
|
|
141
|
+
});
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
If the client transform removes the `auth.server` import but leaves `middleware: [authMiddleware]` in place, the browser bundle still contains a dangling identifier. That breaks production hydration even though the import was removed correctly.
|
|
145
|
+
|
|
146
|
+
The fix is to strip server-only `eco.page(...)` options after import pruning, while keeping `render` intact.
|
|
147
|
+
|
|
148
|
+
### Hydration Contract for `locals`
|
|
149
|
+
|
|
150
|
+
The browser must not receive arbitrary request-scoped data.
|
|
151
|
+
|
|
152
|
+
The React renderer in [packages/integrations/react/src/react-renderer.ts](packages/integrations/react/src/react-renderer.ts) serializes only the top-level `locals` keys explicitly declared by `Page.requires`. If a page does not declare `requires`, no `locals` are serialized for hydration.
|
|
153
|
+
|
|
154
|
+
Example:
|
|
155
|
+
|
|
156
|
+
```tsx
|
|
157
|
+
export default eco.page({
|
|
158
|
+
requires: ['session'] as const,
|
|
159
|
+
render: ({ locals }) => <Dashboard user={locals?.session?.user} />,
|
|
160
|
+
});
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
In this case, the hydration payload may include `locals.session`, but it will exclude unrelated request-only keys.
|
|
164
|
+
|
|
165
|
+
Important:
|
|
166
|
+
|
|
167
|
+
- This filtering is currently top-level only.
|
|
168
|
+
- If `locals.session` itself contains sensitive nested fields, those fields will still be serialized.
|
|
169
|
+
- Middleware should therefore expose a client-safe shape for any key declared in `requires`.
|
|
170
|
+
|
|
171
|
+
### Layout Hydration Invariant
|
|
172
|
+
|
|
173
|
+
Hydration must rebuild the same tree the server rendered.
|
|
174
|
+
|
|
175
|
+
That applies to both:
|
|
176
|
+
|
|
177
|
+
- non-router hydration scripts in [packages/integrations/react/src/utils/hydration-scripts.ts](packages/integrations/react/src/utils/hydration-scripts.ts)
|
|
178
|
+
- router-backed hydration in [packages/react-router/src/router.ts](packages/react-router/src/router.ts)
|
|
179
|
+
|
|
180
|
+
If the page render receives `locals` on the server and the layout also depends on those values, the client must pass the same serialized `locals` into the layout during hydration. Otherwise React will detect a mismatch.
|
|
55
181
|
|
|
56
|
-
|
|
182
|
+
### Tests That Guard This Contract
|
|
57
183
|
|
|
58
|
-
|
|
59
|
-
- A stable `data-eco-component-id` attribute is attached to the component SSR root when a single root element is available.
|
|
60
|
-
- Client bootstrap resolves the component export and mounts with `createRoot()` into that root boundary.
|
|
61
|
-
- Component assets are emitted through the shared dependency pipeline and deduplicated with other integrations.
|
|
184
|
+
The main regression coverage lives in:
|
|
62
185
|
|
|
63
|
-
|
|
186
|
+
- [packages/integrations/react/src/utils/client-graph-boundary-plugin.test.ts](packages/integrations/react/src/utils/client-graph-boundary-plugin.test.ts): verifies server-only `eco.page(...)` options are stripped from browser bundles.
|
|
187
|
+
- [packages/integrations/react/src/react-renderer.locals.test.ts](packages/integrations/react/src/react-renderer.locals.test.ts): verifies only declared `requires` keys are serialized into hydration payloads.
|
|
188
|
+
- [packages/integrations/react/src/utils/hydration-scripts.test.ts](packages/integrations/react/src/utils/hydration-scripts.test.ts): verifies non-router hydration passes serialized `locals` into layouts.
|
|
189
|
+
- [packages/react-router/test/hmr-reload.test.browser.ts](packages/react-router/test/hmr-reload.test.browser.ts): verifies router-backed layout hydration receives `locals` with `persistLayouts` both enabled and disabled.
|
|
64
190
|
|
|
65
|
-
|
|
191
|
+
If you change the AST transform or hydration flow, update the corresponding tests in the same change.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ecopages/react",
|
|
3
|
-
"version": "0.2.0-alpha.
|
|
3
|
+
"version": "0.2.0-alpha.11",
|
|
4
4
|
"description": "React integration for Ecopages",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ecopages",
|
|
@@ -53,14 +53,14 @@
|
|
|
53
53
|
"directory": "packages/integrations/react"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
|
-
"@ecopages/core": "0.2.0-alpha.
|
|
56
|
+
"@ecopages/core": "0.2.0-alpha.11",
|
|
57
57
|
"@types/react": "^19",
|
|
58
58
|
"@types/react-dom": "^19",
|
|
59
59
|
"react": "^19",
|
|
60
60
|
"react-dom": "^19"
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
|
-
"@ecopages/file-system": "0.2.0-alpha.
|
|
63
|
+
"@ecopages/file-system": "0.2.0-alpha.11",
|
|
64
64
|
"@ecopages/logger": "latest",
|
|
65
65
|
"@mdx-js/esbuild": "^3.0.1",
|
|
66
66
|
"@mdx-js/mdx": "^3.1.0",
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* @module
|
|
8
8
|
*/
|
|
9
|
-
import { HmrStrategy,
|
|
9
|
+
import { HmrStrategy, type HmrAction } from '@ecopages/core/hmr/hmr-strategy';
|
|
10
10
|
import type { DefaultHmrContext } from '@ecopages/core';
|
|
11
11
|
import type { CompileOptions } from '@mdx-js/mdx';
|
|
12
12
|
import type { ReactHmrPageMetadataCache } from './services/react-hmr-page-metadata-cache.js';
|
|
@@ -19,9 +19,11 @@ import type { ReactHmrPageMetadataCache } from './services/react-hmr-page-metada
|
|
|
19
19
|
* The processing steps are:
|
|
20
20
|
* 1. Check if any React entrypoints are registered
|
|
21
21
|
* 2. Rebuild all React entrypoints (the changed file could be a dependency)
|
|
22
|
-
* 3.
|
|
23
|
-
*
|
|
24
|
-
*
|
|
22
|
+
* 3. Rebuild browser output through the shared browser bundle service while
|
|
23
|
+
* preserving React-specific runtime aliases and graph policy
|
|
24
|
+
* 4. Read page config metadata through the shared server-module loading path
|
|
25
|
+
* 5. Inject HMR acceptance handler
|
|
26
|
+
* 6. Broadcast update events for each rebuilt entrypoint
|
|
25
27
|
*
|
|
26
28
|
* @remarks
|
|
27
29
|
* This strategy has higher priority than generic JsHmrStrategy, allowing it
|
|
@@ -47,14 +49,11 @@ import type { ReactHmrPageMetadataCache } from './services/react-hmr-page-metada
|
|
|
47
49
|
* ```
|
|
48
50
|
*/
|
|
49
51
|
export declare class ReactHmrStrategy extends HmrStrategy {
|
|
50
|
-
|
|
51
|
-
private pageMetadataCache;
|
|
52
|
-
private explicitGraphEnabled;
|
|
53
|
-
readonly type = HmrStrategyType.INTEGRATION;
|
|
52
|
+
readonly type: 100;
|
|
54
53
|
private mdxCompilerOptions?;
|
|
55
|
-
private readonly
|
|
54
|
+
private readonly ownedTemplateExtensions;
|
|
55
|
+
private readonly allTemplateExtensions;
|
|
56
56
|
private importNodePageModule;
|
|
57
|
-
private createUseSyncExternalStoreShimPlugin;
|
|
58
57
|
/**
|
|
59
58
|
* Creates a new React HMR strategy instance.
|
|
60
59
|
*
|
|
@@ -68,7 +67,10 @@ export declare class ReactHmrStrategy extends HmrStrategy {
|
|
|
68
67
|
* @param explicitGraphEnabled - Enables explicit graph mode for React HMR bundling.
|
|
69
68
|
* In explicit mode, HMR builds omit AST server-only stripping plugins in React paths.
|
|
70
69
|
*/
|
|
71
|
-
|
|
70
|
+
private context;
|
|
71
|
+
private pageMetadataCache;
|
|
72
|
+
private explicitGraphEnabled;
|
|
73
|
+
constructor(context: DefaultHmrContext, pageMetadataCache: ReactHmrPageMetadataCache, mdxCompilerOptions?: CompileOptions, ownedTemplateExtensions?: string[], allTemplateExtensions?: string[], explicitGraphEnabled?: boolean);
|
|
72
74
|
/**
|
|
73
75
|
* Returns build plugins for React HMR bundling.
|
|
74
76
|
*
|
|
@@ -77,6 +79,16 @@ export declare class ReactHmrStrategy extends HmrStrategy {
|
|
|
77
79
|
*/
|
|
78
80
|
private getBuildPlugins;
|
|
79
81
|
private isReactEntrypoint;
|
|
82
|
+
/**
|
|
83
|
+
* Returns true when a route file uses a compound extension like `page.foo.tsx`.
|
|
84
|
+
*
|
|
85
|
+
* @remarks
|
|
86
|
+
* React integration owns plain `.tsx` route templates. Compound extensions in
|
|
87
|
+
* pages/layouts are integration-specific route templates and should not be
|
|
88
|
+
* claimed by React HMR strategy.
|
|
89
|
+
*/
|
|
90
|
+
private isRouteTemplate;
|
|
91
|
+
private resolveTemplateExtension;
|
|
80
92
|
/**
|
|
81
93
|
* Determines if the file is a React/MDX entrypoint that's registered for HMR.
|
|
82
94
|
*
|
|
@@ -116,13 +128,14 @@ export declare class ReactHmrStrategy extends HmrStrategy {
|
|
|
116
128
|
* @returns True if bundling was successful
|
|
117
129
|
*/
|
|
118
130
|
private bundleReactEntrypoint;
|
|
131
|
+
private resolveTempOutputPath;
|
|
119
132
|
/**
|
|
120
133
|
* Encodes dynamic route segments (brackets) in file paths.
|
|
121
134
|
* Converts `[slug]` to `_slug_` to avoid filesystem issues.
|
|
122
135
|
*/
|
|
123
136
|
private encodeDynamicSegments;
|
|
124
137
|
/**
|
|
125
|
-
* Processes bundled output
|
|
138
|
+
* Processes bundled output and injects the React HMR handler.
|
|
126
139
|
* Writes to temp file first, then renames atomically to avoid conflicts.
|
|
127
140
|
*
|
|
128
141
|
* @param tempPath - Path to the temporary bundled file
|
|
@@ -131,13 +144,4 @@ export declare class ReactHmrStrategy extends HmrStrategy {
|
|
|
131
144
|
* @returns True if processing was successful
|
|
132
145
|
*/
|
|
133
146
|
private processOutput;
|
|
134
|
-
/**
|
|
135
|
-
* Replaces bare specifiers with runtime URLs.
|
|
136
|
-
*
|
|
137
|
-
* Handles both static imports and dynamic imports.
|
|
138
|
-
*
|
|
139
|
-
* @param code - The bundled code to transform
|
|
140
|
-
* @returns The transformed code with runtime URLs
|
|
141
|
-
*/
|
|
142
|
-
private replaceBareSpecifiers;
|
|
143
147
|
}
|