@ecopages/react 0.6.0 → 0.7.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.
- package/README.md +50 -87
- package/package.json +32 -14
- package/src/bundling/bootstrap-package-paths.d.ts +13 -1
- package/src/bundling/bootstrap-package-paths.js +25 -3
- package/src/bundling/bundle.d.ts +8 -36
- package/src/bundling/bundle.js +42 -73
- package/src/client-graph/ast-transform-eco-page.d.ts +10 -6
- package/src/client-graph/ast-transform-eco-page.js +56 -35
- package/src/client-graph/ast-transform-import-edits.d.ts +10 -2
- package/src/client-graph/ast-transform-import-edits.js +36 -6
- package/src/client-graph/ast-transform-stripped-imports.d.ts +37 -0
- package/src/client-graph/ast-transform-stripped-imports.js +191 -0
- package/src/client-graph/ast-transform-walk-imports.d.ts +4 -0
- package/src/client-graph/ast-transform-walk-imports.js +15 -1
- package/src/client-graph/ast-transform.d.ts +12 -3
- package/src/client-graph/ast-transform.js +41 -56
- package/src/client-graph/boundary-plugin-read-file-inline.d.ts +3 -0
- package/src/client-graph/boundary-plugin-read-file-inline.js +14 -10
- package/src/client-graph/boundary-plugin-transform.d.ts +5 -4
- package/src/client-graph/boundary-plugin-transform.js +6 -13
- package/src/client-graph/boundary-plugin.d.ts +47 -1
- package/src/client-graph/boundary-plugin.js +267 -53
- package/src/client-graph/foreign-boundary-rewrite.d.ts +31 -0
- package/src/client-graph/foreign-boundary-rewrite.js +360 -0
- package/src/client-graph/foreign-jsx-reach.d.ts +25 -0
- package/src/client-graph/foreign-jsx-reach.js +68 -0
- package/src/client-graph/module-classification.js +3 -10
- package/src/client-graph/reachability-traverse.js +35 -105
- package/src/client-graph/requested-exports-plan.d.ts +62 -0
- package/src/client-graph/requested-exports-plan.js +125 -0
- package/src/client-graph/scope-walk.d.ts +37 -0
- package/src/client-graph/scope-walk.js +407 -0
- package/src/client-graph/specifier-classification.d.ts +2 -1
- package/src/client-graph/specifier-classification.js +9 -7
- package/src/contracts/router-adapter.d.ts +9 -24
- package/src/dev-transform/react-dev-transform-contributor.d.ts +4 -4
- package/src/dev-transform/react-dev-transform-contributor.js +6 -7
- package/src/hmr/hmr-strategy-process.d.ts +7 -5
- package/src/hmr/hmr-strategy-process.js +21 -16
- package/src/hmr/hmr-strategy.d.ts +11 -10
- package/src/hmr/hmr-strategy.js +32 -53
- package/src/hmr/page-metadata-cache.js +1 -1
- package/src/hydration/browser/foreign-boundary.d.ts +29 -0
- package/src/hydration/browser/foreign-boundary.js +128 -0
- package/src/hydration/browser/island-hydration.d.ts +3 -4
- package/src/hydration/browser/island-hydration.js +3 -4
- package/src/hydration/browser/page-hydration-hmr.d.ts +8 -7
- package/src/hydration/browser/page-hydration-hmr.js +53 -10
- package/src/hydration/browser/page-hydration.d.ts +6 -5
- package/src/hydration/browser/page-hydration.js +8 -6
- package/src/hydration/foreign-subtree.d.ts +27 -0
- package/src/hydration/foreign-subtree.js +69 -0
- package/src/hydration/hydration-asset.d.ts +37 -29
- package/src/hydration/hydration-asset.js +74 -138
- package/src/hydration/hydration-island-entry-source.d.ts +17 -0
- package/src/hydration/hydration-island-entry-source.js +32 -0
- package/src/hydration/hydration-page-entry-source.d.ts +20 -2
- package/src/hydration/hydration-page-entry-source.js +17 -12
- package/src/hydration/page-data-reader.d.ts +4 -7
- package/src/hydration/page-data-reader.js +5 -10
- package/src/mdx/mdx-config-dependency.d.ts +10 -15
- package/src/mdx/mdx-config-dependency.js +9 -22
- package/src/mdx/mdx-loader-plugin.d.ts +2 -0
- package/src/mdx/mdx-loader-plugin.js +1 -0
- package/src/page/page-module.js +1 -1
- package/src/plugin/react.plugin.d.ts +0 -7
- package/src/plugin/react.plugin.js +4 -33
- package/src/plugin/react.types.d.ts +0 -29
- package/src/render/component-ssr.d.ts +18 -0
- package/src/render/component-ssr.js +37 -0
- package/src/render/layout-compose.d.ts +4 -2
- package/src/render/layout-compose.js +13 -6
- package/src/render/layout-render-tracker.d.ts +20 -0
- package/src/render/layout-render-tracker.js +33 -0
- package/src/render/react-renderer.d.ts +28 -10
- package/src/render/react-renderer.js +103 -38
- package/src/render/react-runtime.js +2 -2
- package/src/bundling/runtime-alias-map.d.ts +0 -12
- package/src/bundling/runtime-alias-map.js +0 -110
- package/src/bundling/runtime-bundle.d.ts +0 -70
- package/src/bundling/runtime-bundle.js +0 -233
- package/src/bundling/runtime-interop-plugin.d.ts +0 -5
- package/src/bundling/runtime-interop-plugin.js +0 -32
- package/src/bundling/runtime-mode.d.ts +0 -1
- package/src/bundling/runtime-mode.js +0 -10
- package/src/bundling/runtime-modules.d.ts +0 -21
- package/src/bundling/runtime-modules.js +0 -28
- package/src/hydration/bootstrap-imports.d.ts +0 -25
- package/src/hydration/bootstrap-imports.js +0 -33
- package/src/hydration/compiled-page-hydration-options.d.ts +0 -19
- package/src/hydration/compiled-page-hydration-options.js +0 -1
- package/src/hydration/hydration-script-compiler.d.ts +0 -47
- package/src/hydration/hydration-script-compiler.js +0 -213
- package/src/runtime/use-sync-external-store-with-selector.d.ts +0 -3
- package/src/runtime/use-sync-external-store-with-selector.js +0 -54
|
@@ -1,233 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Runtime bundle service for React integration.
|
|
3
|
-
*
|
|
4
|
-
* Owns creation of the browser runtime assets for React and React DOM,
|
|
5
|
-
* including shared runtime entry generation and specifier mapping.
|
|
6
|
-
*
|
|
7
|
-
* @module
|
|
8
|
-
*/
|
|
9
|
-
import { createBrowserRuntimePlugin, isDevelopmentRuntime } from '@ecopages/core/build';
|
|
10
|
-
import { DEFAULT_BROWSER_RUNTIME_PLUGIN_NAME } from '@ecopages/core/build';
|
|
11
|
-
import { buildBrowserRuntimeAssetUrl, createBrowserRuntimeModuleAsset, createBrowserRuntimeScriptAsset, } from '@ecopages/core/integration';
|
|
12
|
-
import { createReactDomRuntimeInteropPlugin } from './runtime-interop-plugin.js';
|
|
13
|
-
import { buildReactRuntimeManifest } from './runtime-alias-map.js';
|
|
14
|
-
import { createBrowserRuntimeManifest, getBrowserRuntimeSpecifierMap, } from '@ecopages/core/build';
|
|
15
|
-
import { LAYOUT_COMPOSE_PACKAGE, PAGE_LAYOUT_NORMALIZATION_PACKAGE } from './bootstrap-package-paths.js';
|
|
16
|
-
export class RuntimeBundleService {
|
|
17
|
-
config;
|
|
18
|
-
constructor(config) {
|
|
19
|
-
this.config = config;
|
|
20
|
-
}
|
|
21
|
-
setRootDir(rootDir) {
|
|
22
|
-
this.config.rootDir = rootDir;
|
|
23
|
-
}
|
|
24
|
-
setWorkDir(workDir) {
|
|
25
|
-
this.config.workDir = workDir;
|
|
26
|
-
}
|
|
27
|
-
setRuntimeModules(runtimeModules) {
|
|
28
|
-
this.config.runtimeModules = runtimeModules;
|
|
29
|
-
}
|
|
30
|
-
get isDevelopment() {
|
|
31
|
-
return isDevelopmentRuntime();
|
|
32
|
-
}
|
|
33
|
-
getCurrentRuntimeMode() {
|
|
34
|
-
return this.isDevelopment ? 'development' : 'production';
|
|
35
|
-
}
|
|
36
|
-
createRuntimeDefines(mode) {
|
|
37
|
-
const nodeEnv = JSON.stringify(mode);
|
|
38
|
-
return {
|
|
39
|
-
'process.env.NODE_ENV': nodeEnv,
|
|
40
|
-
'import.meta.env.NODE_ENV': nodeEnv,
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
getVendorFileName(name, mode) {
|
|
44
|
-
return `${name}${mode === 'development' ? '.development' : ''}.js`;
|
|
45
|
-
}
|
|
46
|
-
getConfiguredRuntimeModules() {
|
|
47
|
-
return this.config.runtimeModules ?? [];
|
|
48
|
-
}
|
|
49
|
-
getConfiguredRuntimeModuleSpecifiers() {
|
|
50
|
-
return this.getConfiguredRuntimeModules().map((module) => module.specifier);
|
|
51
|
-
}
|
|
52
|
-
createReactVendorImportRewritePlugin(mode) {
|
|
53
|
-
return createBrowserRuntimePlugin({
|
|
54
|
-
name: `react-plugin-vendor-runtime-import-rewrite-${mode}`,
|
|
55
|
-
manifest: createBrowserRuntimeManifest([
|
|
56
|
-
{
|
|
57
|
-
specifier: 'react',
|
|
58
|
-
owner: '@ecopages/react',
|
|
59
|
-
importPath: 'react',
|
|
60
|
-
publicPath: buildBrowserRuntimeAssetUrl(this.getVendorFileName('react', mode)),
|
|
61
|
-
},
|
|
62
|
-
]),
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
getRuntimeImports(mode = this.getCurrentRuntimeMode()) {
|
|
66
|
-
const reactVendorFileName = this.getVendorFileName('react', mode);
|
|
67
|
-
const reactDomVendorFileName = this.getVendorFileName('react-dom', mode);
|
|
68
|
-
const runtimeImports = {
|
|
69
|
-
react: buildBrowserRuntimeAssetUrl(reactVendorFileName),
|
|
70
|
-
reactDomClient: buildBrowserRuntimeAssetUrl(reactDomVendorFileName),
|
|
71
|
-
reactJsxRuntime: buildBrowserRuntimeAssetUrl(reactVendorFileName),
|
|
72
|
-
reactJsxDevRuntime: buildBrowserRuntimeAssetUrl(reactVendorFileName),
|
|
73
|
-
reactDom: buildBrowserRuntimeAssetUrl(reactDomVendorFileName),
|
|
74
|
-
useSyncExternalStoreWithSelector: buildBrowserRuntimeAssetUrl(this.getVendorFileName('use-sync-external-store-with-selector', mode)),
|
|
75
|
-
pageLayoutNormalization: buildBrowserRuntimeAssetUrl(this.getVendorFileName('page-layout-normalization', mode)),
|
|
76
|
-
layoutCompose: buildBrowserRuntimeAssetUrl(this.getVendorFileName('layout-compose', mode)),
|
|
77
|
-
};
|
|
78
|
-
if (this.config.routerAdapter) {
|
|
79
|
-
runtimeImports.router = buildBrowserRuntimeAssetUrl(this.getVendorFileName(this.config.routerAdapter.bundle.outputName, mode));
|
|
80
|
-
}
|
|
81
|
-
return runtimeImports;
|
|
82
|
-
}
|
|
83
|
-
getRuntimeAliasMap(mode = this.getCurrentRuntimeMode()) {
|
|
84
|
-
return Object.fromEntries(getBrowserRuntimeSpecifierMap(this.getRuntimeManifest(mode)));
|
|
85
|
-
}
|
|
86
|
-
getRuntimeManifest(mode = this.getCurrentRuntimeMode()) {
|
|
87
|
-
return buildReactRuntimeManifest(this.getRuntimeImports(mode), this.getConfiguredRuntimeModules(), (outputName) => buildBrowserRuntimeAssetUrl(this.getVendorFileName(outputName, mode)), { routerImportPath: this.config.routerAdapter?.bundle.importPath });
|
|
88
|
-
}
|
|
89
|
-
getDependencies(options) {
|
|
90
|
-
const dependencies = [];
|
|
91
|
-
const modes = options?.modes ?? [this.getCurrentRuntimeMode()];
|
|
92
|
-
for (const mode of modes) {
|
|
93
|
-
const reactVendorImportRewritePlugin = this.createReactVendorImportRewritePlugin(mode);
|
|
94
|
-
const reactDomRuntimeInteropPlugin = createReactDomRuntimeInteropPlugin({
|
|
95
|
-
reactSpecifier: buildBrowserRuntimeAssetUrl(this.getVendorFileName('react', mode)),
|
|
96
|
-
});
|
|
97
|
-
const reactRuntimeAliasPlugin = createBrowserRuntimePlugin({
|
|
98
|
-
name: `react-plugin-runtime-specifier-alias-${mode}`,
|
|
99
|
-
manifest: createBrowserRuntimeManifest([
|
|
100
|
-
{
|
|
101
|
-
specifier: 'react',
|
|
102
|
-
owner: '',
|
|
103
|
-
importPath: 'react',
|
|
104
|
-
publicPath: buildBrowserRuntimeAssetUrl(this.getVendorFileName('react', mode)),
|
|
105
|
-
},
|
|
106
|
-
]),
|
|
107
|
-
});
|
|
108
|
-
const reactDomBundlePlugins = [reactRuntimeAliasPlugin, reactDomRuntimeInteropPlugin].filter((plugin) => plugin !== null);
|
|
109
|
-
const mappedSpecifiers = new Set(this.getRuntimeManifest(mode).bySpecifier.keys());
|
|
110
|
-
dependencies.push(createBrowserRuntimeModuleAsset({
|
|
111
|
-
modules: [
|
|
112
|
-
{ specifier: 'react', defaultExport: true },
|
|
113
|
-
{ specifier: 'react/jsx-runtime' },
|
|
114
|
-
{ specifier: 'react/jsx-dev-runtime' },
|
|
115
|
-
],
|
|
116
|
-
name: 'react',
|
|
117
|
-
fileName: this.getVendorFileName('react', mode),
|
|
118
|
-
cacheDirName: `ecopages-react-runtime-${mode}`,
|
|
119
|
-
rootDir: this.config.rootDir,
|
|
120
|
-
workDir: this.config.workDir,
|
|
121
|
-
bundleOptions: {
|
|
122
|
-
define: this.createRuntimeDefines(mode),
|
|
123
|
-
excludeAppBuildPlugins: [DEFAULT_BROWSER_RUNTIME_PLUGIN_NAME],
|
|
124
|
-
},
|
|
125
|
-
}), createBrowserRuntimeModuleAsset({
|
|
126
|
-
modules: [{ specifier: 'react-dom', defaultExport: true }, { specifier: 'react-dom/client' }],
|
|
127
|
-
name: 'react-dom',
|
|
128
|
-
fileName: this.getVendorFileName('react-dom', mode),
|
|
129
|
-
cacheDirName: `ecopages-react-runtime-${mode}`,
|
|
130
|
-
rootDir: this.config.rootDir,
|
|
131
|
-
workDir: this.config.workDir,
|
|
132
|
-
bundleOptions: {
|
|
133
|
-
define: this.createRuntimeDefines(mode),
|
|
134
|
-
excludeAppBuildPlugins: [DEFAULT_BROWSER_RUNTIME_PLUGIN_NAME],
|
|
135
|
-
plugins: reactDomBundlePlugins,
|
|
136
|
-
},
|
|
137
|
-
}), createBrowserRuntimeScriptAsset({
|
|
138
|
-
importPath: '@ecopages/react/runtime/use-sync-external-store-with-selector',
|
|
139
|
-
name: 'use-sync-external-store-with-selector',
|
|
140
|
-
fileName: this.getVendorFileName('use-sync-external-store-with-selector', mode),
|
|
141
|
-
bundleOptions: {
|
|
142
|
-
define: this.createRuntimeDefines(mode),
|
|
143
|
-
excludeAppBuildPlugins: [DEFAULT_BROWSER_RUNTIME_PLUGIN_NAME],
|
|
144
|
-
plugins: [reactVendorImportRewritePlugin],
|
|
145
|
-
},
|
|
146
|
-
}), createBrowserRuntimeScriptAsset({
|
|
147
|
-
importPath: LAYOUT_COMPOSE_PACKAGE,
|
|
148
|
-
name: 'layout-compose',
|
|
149
|
-
fileName: this.getVendorFileName('layout-compose', mode),
|
|
150
|
-
bundleOptions: {
|
|
151
|
-
define: this.createRuntimeDefines(mode),
|
|
152
|
-
excludeAppBuildPlugins: [DEFAULT_BROWSER_RUNTIME_PLUGIN_NAME],
|
|
153
|
-
plugins: [reactVendorImportRewritePlugin],
|
|
154
|
-
},
|
|
155
|
-
}));
|
|
156
|
-
if (this.config.routerAdapter) {
|
|
157
|
-
const unresolvedExternals = this.config.routerAdapter.bundle.externals.filter((external) => !mappedSpecifiers.has(external));
|
|
158
|
-
dependencies.push(createBrowserRuntimeScriptAsset({
|
|
159
|
-
importPath: this.config.routerAdapter.bundle.importPath,
|
|
160
|
-
name: this.config.routerAdapter.bundle.outputName,
|
|
161
|
-
fileName: this.getVendorFileName(this.config.routerAdapter.bundle.outputName, mode),
|
|
162
|
-
bundleOptions: {
|
|
163
|
-
define: this.createRuntimeDefines(mode),
|
|
164
|
-
external: unresolvedExternals,
|
|
165
|
-
plugins: [
|
|
166
|
-
this.createRuntimeAliasPlugin(mode, [
|
|
167
|
-
this.config.routerAdapter.bundle.importPath,
|
|
168
|
-
'@ecopages/react-router',
|
|
169
|
-
]),
|
|
170
|
-
],
|
|
171
|
-
},
|
|
172
|
-
}));
|
|
173
|
-
}
|
|
174
|
-
for (const runtimeModule of this.getConfiguredRuntimeModules()) {
|
|
175
|
-
dependencies.push(createBrowserRuntimeModuleAsset({
|
|
176
|
-
modules: [{ specifier: runtimeModule.specifier, defaultExport: true }],
|
|
177
|
-
name: runtimeModule.outputName,
|
|
178
|
-
fileName: this.getVendorFileName(runtimeModule.outputName, mode),
|
|
179
|
-
cacheDirName: `ecopages-react-runtime-module-${runtimeModule.outputName}-${mode}`,
|
|
180
|
-
rootDir: this.config.rootDir,
|
|
181
|
-
workDir: this.config.workDir,
|
|
182
|
-
bundleOptions: {
|
|
183
|
-
define: this.createRuntimeDefines(mode),
|
|
184
|
-
excludeAppBuildPlugins: [DEFAULT_BROWSER_RUNTIME_PLUGIN_NAME],
|
|
185
|
-
plugins: [this.createRuntimeAliasPlugin(mode, [runtimeModule.specifier])],
|
|
186
|
-
},
|
|
187
|
-
}));
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
return dependencies;
|
|
191
|
-
}
|
|
192
|
-
/**
|
|
193
|
-
* Declares the MDX-only page-layout-normalization vendor for the current runtime mode.
|
|
194
|
-
*
|
|
195
|
-
* @remarks
|
|
196
|
-
* Kept out of {@link getDependencies} so non-MDX pages do not pay for this vendor during
|
|
197
|
-
* integration setup. Callers process these assets once when an MDX page graph is prepared.
|
|
198
|
-
*/
|
|
199
|
-
getPageLayoutNormalizationDependencies(options) {
|
|
200
|
-
const dependencies = [];
|
|
201
|
-
const modes = options?.modes ?? [this.getCurrentRuntimeMode()];
|
|
202
|
-
for (const mode of modes) {
|
|
203
|
-
dependencies.push(createBrowserRuntimeScriptAsset({
|
|
204
|
-
importPath: PAGE_LAYOUT_NORMALIZATION_PACKAGE,
|
|
205
|
-
name: 'page-layout-normalization',
|
|
206
|
-
fileName: this.getVendorFileName('page-layout-normalization', mode),
|
|
207
|
-
bundleOptions: {
|
|
208
|
-
define: this.createRuntimeDefines(mode),
|
|
209
|
-
excludeAppBuildPlugins: [DEFAULT_BROWSER_RUNTIME_PLUGIN_NAME],
|
|
210
|
-
},
|
|
211
|
-
}));
|
|
212
|
-
}
|
|
213
|
-
return dependencies;
|
|
214
|
-
}
|
|
215
|
-
/**
|
|
216
|
-
* Builds the vendor import-rewrite plugin for one runtime asset.
|
|
217
|
-
*
|
|
218
|
-
* @remarks
|
|
219
|
-
* `omitSpecifiers` drops the module being bundled so a self-import cannot
|
|
220
|
-
* rewrite to the file currently being emitted.
|
|
221
|
-
*/
|
|
222
|
-
createRuntimeAliasPlugin(mode = this.getCurrentRuntimeMode(), omitSpecifiers = []) {
|
|
223
|
-
const manifest = this.getRuntimeManifest(mode);
|
|
224
|
-
const omitted = new Set(omitSpecifiers);
|
|
225
|
-
const pluginManifest = omitted.size === 0
|
|
226
|
-
? manifest
|
|
227
|
-
: createBrowserRuntimeManifest(manifest.assets.filter((asset) => !omitted.has(asset.specifier)));
|
|
228
|
-
return createBrowserRuntimePlugin({
|
|
229
|
-
name: `react-plugin-runtime-alias-${mode}`,
|
|
230
|
-
manifest: pluginManifest,
|
|
231
|
-
});
|
|
232
|
-
}
|
|
233
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { fileSystem } from '@ecopages/file-system';
|
|
2
|
-
function escapeRegExp(value) {
|
|
3
|
-
return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
4
|
-
}
|
|
5
|
-
export function createReactDomRuntimeInteropPlugin(options) {
|
|
6
|
-
const reactDomFileFilter = /[\\/]react-dom[\\/].*\.js$/;
|
|
7
|
-
const reactRequirePattern = /\brequire\((['"])react\1\)/g;
|
|
8
|
-
const reactSpecifier = options?.reactSpecifier ?? 'react';
|
|
9
|
-
return {
|
|
10
|
-
name: options?.name ?? 'react-dom-runtime-interop',
|
|
11
|
-
setup(build) {
|
|
12
|
-
if (reactSpecifier.startsWith('/')) {
|
|
13
|
-
build.onResolve({ filter: new RegExp(`^${escapeRegExp(reactSpecifier)}$`) }, (args) => ({
|
|
14
|
-
path: args.path,
|
|
15
|
-
external: true,
|
|
16
|
-
}));
|
|
17
|
-
}
|
|
18
|
-
build.onLoad({ filter: reactDomFileFilter }, (args) => {
|
|
19
|
-
const content = fileSystem.readFileSync(args.path);
|
|
20
|
-
if (!reactRequirePattern.test(content)) {
|
|
21
|
-
return undefined;
|
|
22
|
-
}
|
|
23
|
-
reactRequirePattern.lastIndex = 0;
|
|
24
|
-
const rewritten = content.replace(reactRequirePattern, '__ecopages_react_runtime');
|
|
25
|
-
return {
|
|
26
|
-
contents: `import * as __ecopages_react_runtime from '${reactSpecifier}';\n${rewritten}`,
|
|
27
|
-
loader: 'js',
|
|
28
|
-
};
|
|
29
|
-
});
|
|
30
|
-
},
|
|
31
|
-
};
|
|
32
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function isReactProductionRuntime(): boolean;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Production runtime check for React bundle and hydration policy.
|
|
3
|
-
*
|
|
4
|
-
* @remarks
|
|
5
|
-
* Uses the same runtime mode helper as the build and request pipelines.
|
|
6
|
-
*/
|
|
7
|
-
import { isProductionRuntime } from '@ecopages/core/build';
|
|
8
|
-
export function isReactProductionRuntime() {
|
|
9
|
-
return isProductionRuntime();
|
|
10
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Normalizes `reactPlugin({ runtimeModules })` entries for vendor bundling.
|
|
3
|
-
*
|
|
4
|
-
* @module
|
|
5
|
-
*/
|
|
6
|
-
export type ReactPluginRuntimeModule = string | {
|
|
7
|
-
specifier: string;
|
|
8
|
-
outputName?: string;
|
|
9
|
-
};
|
|
10
|
-
export type ResolvedReactPluginRuntimeModule = {
|
|
11
|
-
specifier: string;
|
|
12
|
-
outputName: string;
|
|
13
|
-
};
|
|
14
|
-
/**
|
|
15
|
-
* Builds a stable vendor filename stem from a package specifier.
|
|
16
|
-
*/
|
|
17
|
-
export declare function resolveReactPluginRuntimeModuleSlug(specifier: string): string;
|
|
18
|
-
/**
|
|
19
|
-
* Resolves user-facing runtime module declarations into vendor bundle config.
|
|
20
|
-
*/
|
|
21
|
-
export declare function resolveReactPluginRuntimeModules(modules: ReactPluginRuntimeModule[] | undefined): ResolvedReactPluginRuntimeModule[];
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Normalizes `reactPlugin({ runtimeModules })` entries for vendor bundling.
|
|
3
|
-
*
|
|
4
|
-
* @module
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* Builds a stable vendor filename stem from a package specifier.
|
|
8
|
-
*/
|
|
9
|
-
export function resolveReactPluginRuntimeModuleSlug(specifier) {
|
|
10
|
-
return specifier.replace(/^@/, '').replace(/\//g, '-');
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Resolves user-facing runtime module declarations into vendor bundle config.
|
|
14
|
-
*/
|
|
15
|
-
export function resolveReactPluginRuntimeModules(modules) {
|
|
16
|
-
return (modules ?? []).map((entry) => {
|
|
17
|
-
if (typeof entry === 'string') {
|
|
18
|
-
return {
|
|
19
|
-
specifier: entry,
|
|
20
|
-
outputName: resolveReactPluginRuntimeModuleSlug(entry),
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
return {
|
|
24
|
-
specifier: entry.specifier,
|
|
25
|
-
outputName: entry.outputName ?? resolveReactPluginRuntimeModuleSlug(entry.specifier),
|
|
26
|
-
};
|
|
27
|
-
});
|
|
28
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Resolves browser import paths for React page hydration bootstraps.
|
|
3
|
-
*
|
|
4
|
-
* @remarks
|
|
5
|
-
* When `useBrowserRuntimeImports` is true, helpers and runtimes resolve to shared
|
|
6
|
-
* `/assets/vendors/*.js` URLs so unbundled HMR bootstraps evaluate as native ESM.
|
|
7
|
-
* When false, bare package names are emitted for the production page bundler.
|
|
8
|
-
*/
|
|
9
|
-
import type { ReactRuntimeImports } from '../bundling/runtime-bundle.js';
|
|
10
|
-
export type HydrationBootstrapImportPaths = {
|
|
11
|
-
reactImportPath: string;
|
|
12
|
-
reactDomClientImportPath: string;
|
|
13
|
-
routerImportPath?: string;
|
|
14
|
-
layoutComposeImportPath: string;
|
|
15
|
-
pageLayoutNormalizationImportPath: string;
|
|
16
|
-
};
|
|
17
|
-
export type ResolveHydrationBootstrapImportsOptions = {
|
|
18
|
-
useBrowserRuntimeImports: boolean;
|
|
19
|
-
runtimeImports: ReactRuntimeImports;
|
|
20
|
-
routerAdapterImportPath?: string;
|
|
21
|
-
};
|
|
22
|
-
/**
|
|
23
|
-
* Returns import paths for React page hydration scripts.
|
|
24
|
-
*/
|
|
25
|
-
export declare function resolveHydrationBootstrapImports(options: ResolveHydrationBootstrapImportsOptions): HydrationBootstrapImportPaths;
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Resolves browser import paths for React page hydration bootstraps.
|
|
3
|
-
*
|
|
4
|
-
* @remarks
|
|
5
|
-
* When `useBrowserRuntimeImports` is true, helpers and runtimes resolve to shared
|
|
6
|
-
* `/assets/vendors/*.js` URLs so unbundled HMR bootstraps evaluate as native ESM.
|
|
7
|
-
* When false, bare package names are emitted for the production page bundler.
|
|
8
|
-
*/
|
|
9
|
-
import { LAYOUT_COMPOSE_PACKAGE, PAGE_LAYOUT_NORMALIZATION_PACKAGE } from '../bundling/bootstrap-package-paths.js';
|
|
10
|
-
/**
|
|
11
|
-
* Returns import paths for React page hydration scripts.
|
|
12
|
-
*/
|
|
13
|
-
export function resolveHydrationBootstrapImports(options) {
|
|
14
|
-
const { useBrowserRuntimeImports, runtimeImports, routerAdapterImportPath } = options;
|
|
15
|
-
if (useBrowserRuntimeImports) {
|
|
16
|
-
return {
|
|
17
|
-
reactImportPath: runtimeImports.react,
|
|
18
|
-
reactDomClientImportPath: runtimeImports.reactDomClient,
|
|
19
|
-
...(runtimeImports.router || routerAdapterImportPath
|
|
20
|
-
? { routerImportPath: runtimeImports.router ?? routerAdapterImportPath }
|
|
21
|
-
: {}),
|
|
22
|
-
layoutComposeImportPath: runtimeImports.layoutCompose,
|
|
23
|
-
pageLayoutNormalizationImportPath: runtimeImports.pageLayoutNormalization,
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
return {
|
|
27
|
-
reactImportPath: 'react',
|
|
28
|
-
reactDomClientImportPath: 'react-dom/client',
|
|
29
|
-
...(routerAdapterImportPath ? { routerImportPath: routerAdapterImportPath } : {}),
|
|
30
|
-
layoutComposeImportPath: LAYOUT_COMPOSE_PACKAGE,
|
|
31
|
-
pageLayoutNormalizationImportPath: PAGE_LAYOUT_NORMALIZATION_PACKAGE,
|
|
32
|
-
};
|
|
33
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/** Complete inputs that affect a Page hydration script's generated source. */
|
|
2
|
-
export type CompiledPageHydrationOptions = {
|
|
3
|
-
importPath: string;
|
|
4
|
-
pageModuleUrlExpression: string;
|
|
5
|
-
scriptId: string;
|
|
6
|
-
reactImportPath: string;
|
|
7
|
-
reactDomClientImportPath: string;
|
|
8
|
-
routerImportPath?: string;
|
|
9
|
-
layoutComposeImportPath: string;
|
|
10
|
-
pageLayoutNormalizationImportPath: string;
|
|
11
|
-
routerComponents?: {
|
|
12
|
-
router: string;
|
|
13
|
-
pageContent: string;
|
|
14
|
-
};
|
|
15
|
-
routerPropsExpression?: string;
|
|
16
|
-
hmrEnabled: boolean;
|
|
17
|
-
isMdx: boolean;
|
|
18
|
-
minify: boolean;
|
|
19
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
/** Complete inputs that affect an Island Host script's generated source. */
|
|
2
|
-
export type CompiledIslandHydrationOptions = {
|
|
3
|
-
importPath: string;
|
|
4
|
-
scriptId: string;
|
|
5
|
-
reactImportPath: string;
|
|
6
|
-
reactDomClientImportPath: string;
|
|
7
|
-
targetSelector: string;
|
|
8
|
-
componentRef?: string;
|
|
9
|
-
minify: boolean;
|
|
10
|
-
hmrEnabled?: boolean;
|
|
11
|
-
};
|
|
12
|
-
export type { CompiledPageHydrationOptions } from './compiled-page-hydration-options.js';
|
|
13
|
-
import type { CompiledPageHydrationOptions } from './compiled-page-hydration-options.js';
|
|
14
|
-
/**
|
|
15
|
-
* Compiles the editable React Island Host lifecycle into a browser ESM string.
|
|
16
|
-
*
|
|
17
|
-
* @remarks
|
|
18
|
-
* Compilation is cached by the complete entry configuration. Rejected promises
|
|
19
|
-
* are removed so a transient filesystem or bundler error can recover.
|
|
20
|
-
*/
|
|
21
|
-
export declare class IslandHydrationScriptCompiler {
|
|
22
|
-
private readonly compilationCache;
|
|
23
|
-
/**
|
|
24
|
-
* Compiles and caches one readable or minified Island Host entry.
|
|
25
|
-
*
|
|
26
|
-
* @param options - Complete entry imports, selector, identity, and output mode.
|
|
27
|
-
* @returns A browser ESM source string.
|
|
28
|
-
*/
|
|
29
|
-
compile(options: CompiledIslandHydrationOptions): Promise<string>;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Compiles editable Page lifecycle modules into browser ESM strings.
|
|
33
|
-
*
|
|
34
|
-
* @remarks
|
|
35
|
-
* The cache belongs to the service instance, allowing development restarts to
|
|
36
|
-
* discard framework-source changes without sharing stale output globally.
|
|
37
|
-
*/
|
|
38
|
-
export declare class PageHydrationScriptCompiler {
|
|
39
|
-
private readonly compilationCache;
|
|
40
|
-
/**
|
|
41
|
-
* Compiles and caches one readable or minified Page entry.
|
|
42
|
-
*
|
|
43
|
-
* @param options - Complete page imports, router contract, and output mode.
|
|
44
|
-
* @returns A browser ESM source string.
|
|
45
|
-
*/
|
|
46
|
-
compile(options: CompiledPageHydrationOptions): Promise<string>;
|
|
47
|
-
}
|