@ecopages/react 0.2.0-alpha.5 → 0.2.0-alpha.8
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 +11 -51
- package/README.md +135 -29
- package/package.json +3 -3
- package/src/react-hmr-strategy.d.ts +22 -30
- package/src/react-hmr-strategy.js +57 -120
- package/src/react-hmr-strategy.ts +76 -145
- package/src/react-renderer.d.ts +130 -11
- package/src/react-renderer.js +368 -64
- package/src/react-renderer.ts +490 -90
- package/src/react.plugin.d.ts +17 -5
- package/src/react.plugin.js +44 -13
- package/src/react.plugin.ts +49 -14
- package/src/router-adapter.d.ts +2 -2
- package/src/router-adapter.ts +2 -2
- package/src/services/react-bundle.service.d.ts +2 -30
- package/src/services/react-bundle.service.js +19 -94
- package/src/services/react-bundle.service.ts +20 -129
- package/src/services/react-hydration-asset.service.js +3 -3
- package/src/services/react-hydration-asset.service.ts +7 -4
- package/src/services/react-page-module.service.d.ts +3 -0
- package/src/services/react-page-module.service.js +20 -16
- package/src/services/react-page-module.service.ts +27 -17
- package/src/services/react-runtime-bundle.service.d.ts +12 -12
- package/src/services/react-runtime-bundle.service.js +98 -180
- package/src/services/react-runtime-bundle.service.ts +112 -211
- package/src/utils/client-graph-boundary-plugin.js +78 -1
- package/src/utils/client-graph-boundary-plugin.ts +122 -1
- package/src/utils/hydration-scripts.d.ts +18 -1
- package/src/utils/hydration-scripts.js +83 -32
- package/src/utils/hydration-scripts.ts +159 -38
- 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-dom-runtime-interop-plugin.ts +33 -0
- package/src/utils/react-mdx-loader-plugin.js +13 -5
- package/src/utils/react-mdx-loader-plugin.ts +28 -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/react-runtime-specifier-map.ts +45 -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/utils/use-sync-external-store-shim-plugin.ts +45 -0
package/CHANGELOG.md
CHANGED
|
@@ -6,62 +6,22 @@ All notable changes to `@ecopages/react` are documented here.
|
|
|
6
6
|
|
|
7
7
|
## [UNRELEASED] — TBD
|
|
8
8
|
|
|
9
|
-
### Features
|
|
9
|
+
### Features & Performance
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
- **Performance Hydration**: Introduced static reachability analysis to enforce explicit hydration boundaries and optimized HMR via metadata caching.
|
|
12
|
+
- **Service-Oriented Internals**: Refactored the integration into focused core-backed services for bundling, hydration, and page-module loading.
|
|
13
|
+
- **React MDX**: Inlined MDX support directly into the React integration for a zero-config setup, including Node-native compatibility for experimental startup.
|
|
12
14
|
|
|
13
|
-
|
|
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.
|
|
15
|
+
### Bug Fixes & Refactoring
|
|
17
16
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
-
|
|
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
|
|
27
|
-
|
|
28
|
-
- **HMR page metadata caching** — Page metadata is now cached between HMR refreshes, preventing unnecessary re-fetches during Fast Refresh (`a663788c`).
|
|
29
|
-
- **Stale temp module race fix** — HMR no longer incorrectly reads a stale temporary module during rapid refresh cycles (`b2cf8466`).
|
|
30
|
-
- **Client graph HMR stability** — HMR reloads now correctly respect client graph boundaries to avoid partial hydration mismatches (`2912d6bd`).
|
|
31
|
-
|
|
32
|
-
#### HTML Boundary Utilities
|
|
33
|
-
|
|
34
|
-
- **`html-boundary.ts`** — New utility that wraps rendered output in explicit boundary markers for the cross-integration boundary rendering policy (`ec1e4d66`).
|
|
35
|
-
- **`hydration-scripts.ts`** — Expanded with new helpers for generating and injecting hydration entry scripts.
|
|
36
|
-
|
|
37
|
-
### Refactoring
|
|
38
|
-
|
|
39
|
-
- Aligned React renderer to full orchestration mode — removed legacy rendering path (`fc07bdb0`).
|
|
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
|
-
- Fixed shared React barrel handling so client-reachable server-only re-exports now fail the build instead of being silently pruned (`unreleased`).
|
|
50
|
-
|
|
51
|
-
### Documentation
|
|
52
|
-
|
|
53
|
-
- Documented the React integration server/client graph contract for shared modules and barrel exports (`unreleased`).
|
|
54
|
-
|
|
55
|
-
### Tests
|
|
56
|
-
|
|
57
|
-
- Added `html-boundary.test.ts` covering boundary wrapping utilities.
|
|
58
|
-
- Added `hydration-scripts.test.ts` with hydration script generation coverage.
|
|
59
|
-
- Added `reachability-analyzer.test.ts` (187 lines) covering export declaration reachability.
|
|
60
|
-
- Updated integration tests for esbuild adapter compatibility (`31a44458`).
|
|
17
|
+
- **Handoff Stability**: Standardized router-backed page payloads and document owner markers for mixed-router stability during navigation.
|
|
18
|
+
- **Hydration Hardening**: Fixed island remount races, prop collisions, and layout metadata resolution during development and route handoffs.
|
|
19
|
+
- **Architecture**: Centralized runtime specifiers and consolidated browser-side integration state under `window.__ECO_PAGES__`.
|
|
61
20
|
|
|
62
21
|
---
|
|
63
22
|
|
|
64
23
|
## Migration Notes
|
|
65
24
|
|
|
66
|
-
- The React integration now requires explicit client boundary declarations
|
|
67
|
-
-
|
|
25
|
+
- The React integration now requires explicit client boundary declarations for client-rendered components.
|
|
26
|
+
- React MDX support is built in and no longer requires installing `@ecopages/mdx` just to enable React MDX routes.
|
|
27
|
+
- 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,37 +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**.
|
|
55
66
|
|
|
56
|
-
|
|
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**.
|
|
57
70
|
|
|
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.
|
|
71
|
+
Keep server helpers close, but separate them physically or logically so they do not leak into the client bundle.
|
|
62
72
|
|
|
63
|
-
|
|
73
|
+
## Client Graph Boundary Architecture
|
|
64
74
|
|
|
65
|
-
|
|
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.
|
|
66
76
|
|
|
67
|
-
|
|
77
|
+
### Goal
|
|
68
78
|
|
|
69
|
-
The React integration
|
|
79
|
+
The React integration has two jobs that must hold at the same time:
|
|
70
80
|
|
|
71
|
-
-
|
|
72
|
-
-
|
|
73
|
-
- Shared files and barrel files are allowed when the exports that become client-reachable are browser-safe.
|
|
74
|
-
- If a server-only import becomes client-reachable, the client build fails instead of silently replacing the import.
|
|
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.
|
|
75
83
|
|
|
76
|
-
|
|
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.
|
|
77
85
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
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
|
+
});
|
|
81
142
|
```
|
|
82
143
|
|
|
83
|
-
If
|
|
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.
|
|
181
|
+
|
|
182
|
+
### Tests That Guard This Contract
|
|
183
|
+
|
|
184
|
+
The main regression coverage lives in:
|
|
185
|
+
|
|
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.
|
|
84
190
|
|
|
85
|
-
|
|
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.8",
|
|
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.8",
|
|
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.8",
|
|
64
64
|
"@ecopages/logger": "latest",
|
|
65
65
|
"@mdx-js/esbuild": "^3.0.1",
|
|
66
66
|
"@mdx-js/mdx": "^3.1.0",
|
|
@@ -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,25 +49,11 @@ import type { ReactHmrPageMetadataCache } from './services/react-hmr-page-metada
|
|
|
47
49
|
* ```
|
|
48
50
|
*/
|
|
49
51
|
export declare class ReactHmrStrategy extends HmrStrategy {
|
|
50
|
-
private context;
|
|
51
|
-
private pageMetadataCache;
|
|
52
|
-
private explicitGraphEnabled;
|
|
53
52
|
readonly type = HmrStrategyType.INTEGRATION;
|
|
54
53
|
private mdxCompilerOptions?;
|
|
55
|
-
private readonly
|
|
54
|
+
private readonly ownedTemplateExtensions;
|
|
55
|
+
private readonly allTemplateExtensions;
|
|
56
56
|
private importNodePageModule;
|
|
57
|
-
/**
|
|
58
|
-
* Redirects `use-sync-external-store/shim` imports to React's built-in
|
|
59
|
-
* `useSyncExternalStore`.
|
|
60
|
-
*
|
|
61
|
-
* Libraries like React Aria still list `use-sync-external-store` as a
|
|
62
|
-
* dependency to support React 16/17. On React 18+ the `/shim` export is
|
|
63
|
-
* already a pass-through, but without this plugin esbuild would bundle
|
|
64
|
-
* the full CJS shim (including `process.env` branching) into the browser
|
|
65
|
-
* bundle. The plugin short-circuits the resolution so only a single clean
|
|
66
|
-
* ESM re-export is emitted.
|
|
67
|
-
*/
|
|
68
|
-
private createUseSyncExternalStoreShimPlugin;
|
|
69
57
|
/**
|
|
70
58
|
* Creates a new React HMR strategy instance.
|
|
71
59
|
*
|
|
@@ -79,7 +67,10 @@ export declare class ReactHmrStrategy extends HmrStrategy {
|
|
|
79
67
|
* @param explicitGraphEnabled - Enables explicit graph mode for React HMR bundling.
|
|
80
68
|
* In explicit mode, HMR builds omit AST server-only stripping plugins in React paths.
|
|
81
69
|
*/
|
|
82
|
-
|
|
70
|
+
private context;
|
|
71
|
+
private pageMetadataCache;
|
|
72
|
+
private explicitGraphEnabled;
|
|
73
|
+
constructor(context: DefaultHmrContext, pageMetadataCache: ReactHmrPageMetadataCache, mdxCompilerOptions?: CompileOptions, ownedTemplateExtensions?: string[], allTemplateExtensions?: string[], explicitGraphEnabled?: boolean);
|
|
83
74
|
/**
|
|
84
75
|
* Returns build plugins for React HMR bundling.
|
|
85
76
|
*
|
|
@@ -88,6 +79,16 @@ export declare class ReactHmrStrategy extends HmrStrategy {
|
|
|
88
79
|
*/
|
|
89
80
|
private getBuildPlugins;
|
|
90
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;
|
|
91
92
|
/**
|
|
92
93
|
* Determines if the file is a React/MDX entrypoint that's registered for HMR.
|
|
93
94
|
*
|
|
@@ -133,7 +134,7 @@ export declare class ReactHmrStrategy extends HmrStrategy {
|
|
|
133
134
|
*/
|
|
134
135
|
private encodeDynamicSegments;
|
|
135
136
|
/**
|
|
136
|
-
* Processes bundled output
|
|
137
|
+
* Processes bundled output and injects the React HMR handler.
|
|
137
138
|
* Writes to temp file first, then renames atomically to avoid conflicts.
|
|
138
139
|
*
|
|
139
140
|
* @param tempPath - Path to the temporary bundled file
|
|
@@ -142,13 +143,4 @@ export declare class ReactHmrStrategy extends HmrStrategy {
|
|
|
142
143
|
* @returns True if processing was successful
|
|
143
144
|
*/
|
|
144
145
|
private processOutput;
|
|
145
|
-
/**
|
|
146
|
-
* Replaces bare specifiers with runtime URLs.
|
|
147
|
-
*
|
|
148
|
-
* Handles both static imports and dynamic imports.
|
|
149
|
-
*
|
|
150
|
-
* @param code - The bundled code to transform
|
|
151
|
-
* @returns The transformed code with runtime URLs
|
|
152
|
-
*/
|
|
153
|
-
private replaceBareSpecifiers;
|
|
154
146
|
}
|