@ecopages/react 0.2.0-beta.31 → 0.2.0-beta.33

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 (57) hide show
  1. package/README.md +5 -1
  2. package/package.json +4 -4
  3. package/src/app/client-only.js +13 -17
  4. package/src/app/dynamic.js +7 -10
  5. package/src/app/dynamic.test.browser.js +27 -29
  6. package/src/bundling/bootstrap-package-paths.js +5 -6
  7. package/src/bundling/bundle.js +115 -114
  8. package/src/bundling/discover-layout-runtime-modules.js +166 -155
  9. package/src/bundling/runtime-alias-map.d.ts +4 -1
  10. package/src/bundling/runtime-alias-map.js +107 -95
  11. package/src/bundling/runtime-bundle.js +250 -274
  12. package/src/bundling/runtime-interop-plugin.js +31 -35
  13. package/src/bundling/runtime-mode.js +10 -5
  14. package/src/bundling/runtime-modules.js +46 -35
  15. package/src/client-graph/ast-transform.js +415 -305
  16. package/src/client-graph/boundary-cache.js +146 -104
  17. package/src/client-graph/boundary-plugin.js +122 -104
  18. package/src/client-graph/component-config-traversal.js +70 -49
  19. package/src/client-graph/declared-modules.js +63 -41
  20. package/src/client-graph/reachability-analyzer.js +506 -313
  21. package/src/client-graph/specifier-classification.js +209 -141
  22. package/src/contracts/router-adapter.js +6 -0
  23. package/src/dev-transform/react-dev-transform-contributor.d.ts +17 -0
  24. package/src/dev-transform/react-dev-transform-contributor.js +22 -0
  25. package/src/hmr/hmr-scripts.js +22 -9
  26. package/src/hmr/hmr-strategy.d.ts +12 -181
  27. package/src/hmr/hmr-strategy.js +321 -650
  28. package/src/hmr/page-metadata-cache.js +43 -40
  29. package/src/hmr/react-hmr-dev-transform-plugins.d.ts +23 -0
  30. package/src/hmr/react-hmr-dev-transform-plugins.js +20 -0
  31. package/src/hydration/assert-no-bare-ecopages-imports.js +6 -6
  32. package/src/hydration/bootstrap-imports.js +30 -20
  33. package/src/hydration/hydration-asset.js +216 -213
  34. package/src/hydration/hydration-scripts.d.ts +4 -0
  35. package/src/hydration/hydration-scripts.js +199 -66
  36. package/src/hydration/hydration-scripts.test.browser.js +163 -168
  37. package/src/hydration/page-data-manifest.js +89 -45
  38. package/src/hydration/page-data-reader.js +45 -32
  39. package/src/hydration/page-payload.js +101 -99
  40. package/src/hydration/serialize-page-data-script.js +27 -28
  41. package/src/mdx/mdx-config-dependency.js +108 -112
  42. package/src/mdx/mdx-loader-plugin.js +7 -10
  43. package/src/page/page-module.js +72 -66
  44. package/src/plugin/react.constants.js +1 -4
  45. package/src/plugin/react.plugin.d.ts +1 -0
  46. package/src/plugin/react.plugin.js +227 -216
  47. package/src/plugin/react.types.js +1 -0
  48. package/src/render/component-ownership.js +42 -18
  49. package/src/render/component-ssr.js +168 -190
  50. package/src/render/eco-embed.js +8 -10
  51. package/src/render/errors.js +21 -16
  52. package/src/render/html-boundary.js +55 -51
  53. package/src/render/layout-compose.js +122 -94
  54. package/src/render/react-renderer.js +433 -468
  55. package/src/render/react-runtime.js +25 -20
  56. package/src/render/unified-layout-composition.js +74 -85
  57. package/src/runtime/use-sync-external-store-with-selector.js +52 -54
@@ -1,180 +1,191 @@
1
- import { existsSync, readFileSync, readdirSync } from "node:fs";
2
- import path from "node:path";
3
- import {
4
- isBarePackageImportSpecifier,
5
- resolveProjectModulePath
6
- } from "@ecopages/core/plugins/tsconfig-import-resolver";
7
- import { analyzeReachability } from "../client-graph/reachability-analyzer.js";
8
- import { REACT_RUNTIME_SPECIFIERS } from "./runtime-alias-map.js";
9
- const MODULE_EXTENSIONS = [".tsx", ".ts", ".jsx", ".js", ".mts", ".mjs"];
10
- const AUTO_RUNTIME_EXCLUDED_SPECIFIERS = /* @__PURE__ */ new Set([
11
- ...REACT_RUNTIME_SPECIFIERS,
12
- "react-dom/client",
13
- "use-sync-external-store/shim",
14
- "use-sync-external-store/shim/index.js",
15
- "use-sync-external-store/shim/with-selector",
16
- "use-sync-external-store/shim/with-selector.js"
1
+ /**
2
+ * Discovers npm packages reachable from persisted `eco.layout()` client graphs.
3
+ *
4
+ * @module
5
+ */
6
+ import { existsSync, readFileSync, readdirSync } from 'node:fs';
7
+ import path from 'node:path';
8
+ import { isBarePackageImportSpecifier, resolveProjectModulePath, } from '@ecopages/core/plugins/tsconfig-import-resolver';
9
+ import { analyzeReachability } from '../client-graph/reachability-analyzer.js';
10
+ import { REACT_RUNTIME_SPECIFIERS } from './runtime-alias-map.js';
11
+ const MODULE_EXTENSIONS = ['.tsx', '.ts', '.jsx', '.js', '.mts', '.mjs'];
12
+ const AUTO_RUNTIME_EXCLUDED_SPECIFIERS = new Set([
13
+ ...REACT_RUNTIME_SPECIFIERS,
14
+ 'react-dom/client',
15
+ 'use-sync-external-store/shim',
16
+ 'use-sync-external-store/shim/index.js',
17
+ 'use-sync-external-store/shim/with-selector',
18
+ 'use-sync-external-store/shim/with-selector.js',
17
19
  ]);
18
- const AUTO_RUNTIME_EXCLUDED_PACKAGE_PREFIXES = ["@ecopages/", "@techn.es/"];
20
+ const AUTO_RUNTIME_EXCLUDED_PACKAGE_PREFIXES = ['@ecopages/', '@techn.es/'];
19
21
  const PROVIDER_MODULE_PATH_PATTERN = /(?:^|[/\\])(?:[^/\\]*provider[^/\\]*|[^/\\]*context[^/\\]*)\.(?:tsx?|jsx?|mts?|mjs)$/i;
20
22
  const PROVIDER_MODULE_SOURCE_PATTERN = /\b(?:QueryClientProvider|(?:\w+Provider)|createContext|Context\.Provider)\b/;
21
23
  function isServerModulePath(filePath) {
22
- return /\.server\.(?:tsx?|jsx?|mts?|mjs|cjs)$/.test(filePath);
24
+ return /\.server\.(?:tsx?|jsx?|mts?|mjs|cjs)$/.test(filePath);
23
25
  }
24
26
  function isEcoLayoutSource(source) {
25
- return /\beco\.layout(?:<[^>]*>)?\s*\(/.test(source);
27
+ return /\beco\.layout(?:<[^>]*>)?\s*\(/.test(source);
26
28
  }
27
- function isRuntimeProviderLayoutSource(source) {
28
- return isEcoLayoutSource(source) && /\bruntimeProvider\s*:\s*true\b/.test(source);
29
+ /**
30
+ * Returns true when a layout opts into runtime-provider auto-vendoring discovery.
31
+ */
32
+ export function isRuntimeProviderLayoutSource(source) {
33
+ return isEcoLayoutSource(source) && /\bruntimeProvider\s*:\s*true\b/.test(source);
29
34
  }
30
- function isProviderRuntimeModulePath(filePath, source) {
31
- if (PROVIDER_MODULE_PATH_PATTERN.test(filePath)) {
32
- return true;
33
- }
34
- return PROVIDER_MODULE_SOURCE_PATTERN.test(source);
35
+ /**
36
+ * Returns true when a module looks like it mounts shared client runtime state
37
+ * (React context providers, query clients, etc.).
38
+ */
39
+ export function isProviderRuntimeModulePath(filePath, source) {
40
+ if (PROVIDER_MODULE_PATH_PATTERN.test(filePath)) {
41
+ return true;
42
+ }
43
+ return PROVIDER_MODULE_SOURCE_PATTERN.test(source);
35
44
  }
36
- function normalizeRuntimePackageSpecifier(specifier) {
37
- if (specifier.startsWith("@")) {
38
- const parts = specifier.split("/");
39
- if (parts.length >= 2) {
40
- return `${parts[0]}/${parts[1]}`;
41
- }
42
- return specifier;
43
- }
44
- return specifier.split("/")[0] ?? specifier;
45
+ /**
46
+ * Normalizes import specifiers to the package entry used for browser vendors.
47
+ */
48
+ export function normalizeRuntimePackageSpecifier(specifier) {
49
+ if (specifier.startsWith('@')) {
50
+ const parts = specifier.split('/');
51
+ if (parts.length >= 2) {
52
+ return `${parts[0]}/${parts[1]}`;
53
+ }
54
+ return specifier;
55
+ }
56
+ return specifier.split('/')[0] ?? specifier;
45
57
  }
46
58
  function isAutoRuntimeExcludedPackage(packageRoot) {
47
- if (AUTO_RUNTIME_EXCLUDED_PACKAGE_PREFIXES.some((prefix) => packageRoot.startsWith(prefix))) {
48
- return true;
49
- }
50
- return packageRoot.endsWith("-devtools");
59
+ if (AUTO_RUNTIME_EXCLUDED_PACKAGE_PREFIXES.some((prefix) => packageRoot.startsWith(prefix))) {
60
+ return true;
61
+ }
62
+ return packageRoot.endsWith('-devtools');
51
63
  }
52
64
  function shouldExcludeAutoRuntimeSpecifier(specifier, options) {
53
- if (AUTO_RUNTIME_EXCLUDED_SPECIFIERS.has(specifier)) {
54
- return true;
55
- }
56
- if (options.routerImportPath && specifier === options.routerImportPath) {
57
- return true;
58
- }
59
- return isAutoRuntimeExcludedPackage(normalizeRuntimePackageSpecifier(specifier));
65
+ if (AUTO_RUNTIME_EXCLUDED_SPECIFIERS.has(specifier)) {
66
+ return true;
67
+ }
68
+ if (options.routerImportPath && specifier === options.routerImportPath) {
69
+ return true;
70
+ }
71
+ return isAutoRuntimeExcludedPackage(normalizeRuntimePackageSpecifier(specifier));
60
72
  }
61
73
  function collectLayoutEntryFiles(searchDir, extensions, files) {
62
- if (!existsSync(searchDir)) {
63
- return;
64
- }
65
- for (const entry of readdirSync(searchDir, { withFileTypes: true })) {
66
- const entryPath = path.join(searchDir, entry.name);
67
- if (entry.isDirectory()) {
68
- collectLayoutEntryFiles(entryPath, extensions, files);
69
- continue;
74
+ if (!existsSync(searchDir)) {
75
+ return;
70
76
  }
71
- if (!entry.isFile()) {
72
- continue;
77
+ for (const entry of readdirSync(searchDir, { withFileTypes: true })) {
78
+ const entryPath = path.join(searchDir, entry.name);
79
+ if (entry.isDirectory()) {
80
+ collectLayoutEntryFiles(entryPath, extensions, files);
81
+ continue;
82
+ }
83
+ if (!entry.isFile()) {
84
+ continue;
85
+ }
86
+ if (!extensions.some((extension) => entry.name.endsWith(extension))) {
87
+ continue;
88
+ }
89
+ try {
90
+ const source = readFileSync(entryPath, 'utf8');
91
+ if (!isEcoLayoutSource(source)) {
92
+ continue;
93
+ }
94
+ files.all.push(entryPath);
95
+ if (isRuntimeProviderLayoutSource(source)) {
96
+ files.runtimeProvider.push(entryPath);
97
+ }
98
+ }
99
+ catch {
100
+ continue;
101
+ }
73
102
  }
74
- if (!extensions.some((extension) => entry.name.endsWith(extension))) {
75
- continue;
76
- }
77
- try {
78
- const source = readFileSync(entryPath, "utf8");
79
- if (!isEcoLayoutSource(source)) {
80
- continue;
81
- }
82
- files.all.push(entryPath);
83
- if (isRuntimeProviderLayoutSource(source)) {
84
- files.runtimeProvider.push(entryPath);
85
- }
86
- } catch {
87
- continue;
88
- }
89
- }
90
103
  }
91
104
  function resolveLayoutDiscoveryPlan(layoutEntries) {
92
- if (layoutEntries.runtimeProvider.length > 0) {
105
+ if (layoutEntries.runtimeProvider.length > 0) {
106
+ return {
107
+ entryFiles: layoutEntries.runtimeProvider,
108
+ mode: 'runtime-provider-layouts',
109
+ collectAllReachableNpm: true,
110
+ };
111
+ }
93
112
  return {
94
- entryFiles: layoutEntries.runtimeProvider,
95
- mode: "runtime-provider-layouts",
96
- collectAllReachableNpm: true
113
+ entryFiles: layoutEntries.all,
114
+ mode: 'provider-scoped-fallback',
115
+ collectAllReachableNpm: false,
97
116
  };
98
- }
99
- return {
100
- entryFiles: layoutEntries.all,
101
- mode: "provider-scoped-fallback",
102
- collectAllReachableNpm: false
103
- };
104
117
  }
105
118
  function collectReachableNpmSpecifiersFromFile(filePath, options) {
106
- if (isServerModulePath(filePath)) {
107
- return;
108
- }
109
- if (options.visitedFiles.has(filePath)) {
110
- return;
111
- }
112
- options.visitedFiles.add(filePath);
113
- let source;
114
- try {
115
- source = readFileSync(filePath, "utf8");
116
- } catch {
117
- return;
118
- }
119
- const reachability = analyzeReachability(source, filePath);
120
- if (!reachability.analyzed) {
121
- return;
122
- }
123
- const collectNpmFromModule = options.collectAllReachableNpm || isProviderRuntimeModulePath(filePath, source);
124
- for (const specifier of reachability.reachableImports.keys()) {
125
- if (options.projectRoot) {
126
- const resolvedLocalModule = resolveProjectModulePath(options.projectRoot, filePath, specifier);
127
- if (resolvedLocalModule) {
128
- options.queue.push(resolvedLocalModule);
129
- continue;
130
- }
131
- }
132
- if (!collectNpmFromModule) {
133
- continue;
134
- }
135
- if (!isBarePackageImportSpecifier(specifier, options.projectRoot)) {
136
- continue;
137
- }
138
- if (shouldExcludeAutoRuntimeSpecifier(specifier, options)) {
139
- continue;
140
- }
141
- options.discovered.add(normalizeRuntimePackageSpecifier(specifier));
142
- }
119
+ if (isServerModulePath(filePath)) {
120
+ return;
121
+ }
122
+ if (options.visitedFiles.has(filePath)) {
123
+ return;
124
+ }
125
+ options.visitedFiles.add(filePath);
126
+ let source;
127
+ try {
128
+ source = readFileSync(filePath, 'utf8');
129
+ }
130
+ catch {
131
+ return;
132
+ }
133
+ const reachability = analyzeReachability(source, filePath);
134
+ if (!reachability.analyzed) {
135
+ return;
136
+ }
137
+ const collectNpmFromModule = options.collectAllReachableNpm || isProviderRuntimeModulePath(filePath, source);
138
+ for (const specifier of reachability.reachableImports.keys()) {
139
+ if (options.projectRoot) {
140
+ const resolvedLocalModule = resolveProjectModulePath(options.projectRoot, filePath, specifier);
141
+ if (resolvedLocalModule) {
142
+ options.queue.push(resolvedLocalModule);
143
+ continue;
144
+ }
145
+ }
146
+ if (!collectNpmFromModule) {
147
+ continue;
148
+ }
149
+ if (!isBarePackageImportSpecifier(specifier, options.projectRoot)) {
150
+ continue;
151
+ }
152
+ if (shouldExcludeAutoRuntimeSpecifier(specifier, options)) {
153
+ continue;
154
+ }
155
+ options.discovered.add(normalizeRuntimePackageSpecifier(specifier));
156
+ }
143
157
  }
144
- function discoverLayoutRuntimeModuleSpecifiers(options) {
145
- const extensions = options.extensions ?? MODULE_EXTENSIONS;
146
- const layoutEntries = { all: [], runtimeProvider: [] };
147
- for (const searchDir of options.searchDirs) {
148
- collectLayoutEntryFiles(searchDir, extensions, layoutEntries);
149
- }
150
- const plan = resolveLayoutDiscoveryPlan(layoutEntries);
151
- const discovered = /* @__PURE__ */ new Set();
152
- for (const entryFile of plan.entryFiles) {
153
- const visitedFiles = /* @__PURE__ */ new Set();
154
- const queue = [entryFile];
155
- while (queue.length > 0) {
156
- const filePath = queue.shift();
157
- if (!filePath) {
158
- continue;
159
- }
160
- collectReachableNpmSpecifiersFromFile(filePath, {
161
- projectRoot: options.projectRoot,
162
- routerImportPath: options.routerImportPath,
163
- collectAllReachableNpm: plan.collectAllReachableNpm,
164
- visitedFiles,
165
- queue,
166
- discovered
167
- });
168
- }
169
- }
170
- return {
171
- specifiers: [...discovered].sort(),
172
- mode: plan.mode
173
- };
158
+ /**
159
+ * Finds npm packages imported from persisted layout client graphs under the given directories.
160
+ */
161
+ export function discoverLayoutRuntimeModuleSpecifiers(options) {
162
+ const extensions = options.extensions ?? MODULE_EXTENSIONS;
163
+ const layoutEntries = { all: [], runtimeProvider: [] };
164
+ for (const searchDir of options.searchDirs) {
165
+ collectLayoutEntryFiles(searchDir, extensions, layoutEntries);
166
+ }
167
+ const plan = resolveLayoutDiscoveryPlan(layoutEntries);
168
+ const discovered = new Set();
169
+ for (const entryFile of plan.entryFiles) {
170
+ const visitedFiles = new Set();
171
+ const queue = [entryFile];
172
+ while (queue.length > 0) {
173
+ const filePath = queue.shift();
174
+ if (!filePath) {
175
+ continue;
176
+ }
177
+ collectReachableNpmSpecifiersFromFile(filePath, {
178
+ projectRoot: options.projectRoot,
179
+ routerImportPath: options.routerImportPath,
180
+ collectAllReachableNpm: plan.collectAllReachableNpm,
181
+ visitedFiles,
182
+ queue,
183
+ discovered,
184
+ });
185
+ }
186
+ }
187
+ return {
188
+ specifiers: [...discovered].sort(),
189
+ mode: plan.mode,
190
+ };
174
191
  }
175
- export {
176
- discoverLayoutRuntimeModuleSpecifiers,
177
- isProviderRuntimeModulePath,
178
- isRuntimeProviderLayoutSource,
179
- normalizeRuntimePackageSpecifier
180
- };
@@ -2,9 +2,12 @@ import type { ReactRouterAdapter } from '../contracts/router-adapter.js';
2
2
  import type { ReactRuntimeImports } from './runtime-bundle.js';
3
3
  import type { ResolvedReactPluginRuntimeModule } from './runtime-modules.js';
4
4
  import { type BrowserRuntimeAssetDeclaration, type BrowserRuntimeManifest } from '@ecopages/core/build/browser-runtime-manifest';
5
+ export type BuildReactRuntimeManifestOptions = {
6
+ routerImportPath?: string;
7
+ };
5
8
  export declare const REACT_RUNTIME_SPECIFIERS: readonly ["react", "react-dom", "react/jsx-runtime", "react/jsx-dev-runtime", "react-dom/client"];
6
9
  export declare function buildReactRuntimeAliasMap(runtimeImports: ReactRuntimeImports): Record<string, string>;
7
10
  export declare function buildConfiguredRuntimeModuleManifestEntries(modules: readonly ResolvedReactPluginRuntimeModule[], getPublicPath: (outputName: string) => string): BrowserRuntimeAssetDeclaration[];
8
- export declare function buildReactRuntimeManifest(runtimeImports: ReactRuntimeImports, configuredRuntimeModules?: readonly ResolvedReactPluginRuntimeModule[], getConfiguredRuntimeModulePublicPath?: (outputName: string) => string): BrowserRuntimeManifest;
11
+ export declare function buildReactRuntimeManifest(runtimeImports: ReactRuntimeImports, configuredRuntimeModules?: readonly ResolvedReactPluginRuntimeModule[], getConfiguredRuntimeModulePublicPath?: (outputName: string) => string, options?: BuildReactRuntimeManifestOptions): BrowserRuntimeManifest;
9
12
  export declare function getReactRuntimeExternalSpecifiers(): string[];
10
13
  export declare function getReactClientGraphAllowSpecifiers(runtimeSpecifiers: Iterable<string>, routerAdapter?: ReactRouterAdapter): string[];
@@ -1,101 +1,113 @@
1
- import {
2
- createBrowserRuntimeManifest,
3
- getBrowserRuntimeSpecifierMap
4
- } from "@ecopages/core/build/browser-runtime-manifest";
5
- const REACT_RUNTIME_SPECIFIERS = [
6
- "react",
7
- "react-dom",
8
- "react/jsx-runtime",
9
- "react/jsx-dev-runtime",
10
- "react-dom/client"
1
+ import { createBrowserRuntimeManifest, getBrowserRuntimeSpecifierMap, } from '@ecopages/core/build/browser-runtime-manifest';
2
+ import { LAYOUT_COMPOSE_PACKAGE } from './bootstrap-package-paths.js';
3
+ export const REACT_RUNTIME_SPECIFIERS = [
4
+ 'react',
5
+ 'react-dom',
6
+ 'react/jsx-runtime',
7
+ 'react/jsx-dev-runtime',
8
+ 'react-dom/client',
11
9
  ];
12
- function buildReactRuntimeAliasMap(runtimeImports) {
13
- return Object.fromEntries(getBrowserRuntimeSpecifierMap(buildReactRuntimeManifest(runtimeImports)));
10
+ export function buildReactRuntimeAliasMap(runtimeImports) {
11
+ return Object.fromEntries(getBrowserRuntimeSpecifierMap(buildReactRuntimeManifest(runtimeImports)));
14
12
  }
15
- function buildConfiguredRuntimeModuleManifestEntries(modules, getPublicPath) {
16
- return modules.map((module) => ({
17
- specifier: module.specifier,
18
- owner: "@ecopages/react",
19
- importPath: module.specifier,
20
- publicPath: getPublicPath(module.outputName),
21
- externals: [...getReactRuntimeExternalSpecifiers(), ...module.externals]
22
- }));
13
+ export function buildConfiguredRuntimeModuleManifestEntries(modules, getPublicPath) {
14
+ return modules.map((module) => ({
15
+ specifier: module.specifier,
16
+ owner: '@ecopages/react',
17
+ importPath: module.specifier,
18
+ publicPath: getPublicPath(module.outputName),
19
+ externals: [...getReactRuntimeExternalSpecifiers(), ...module.externals],
20
+ }));
23
21
  }
24
- function buildReactRuntimeManifest(runtimeImports, configuredRuntimeModules = [], getConfiguredRuntimeModulePublicPath = () => "") {
25
- return createBrowserRuntimeManifest([
26
- {
27
- specifier: "react",
28
- owner: "@ecopages/react",
29
- importPath: "react",
30
- publicPath: runtimeImports.react
31
- },
32
- {
33
- specifier: "react/jsx-runtime",
34
- owner: "@ecopages/react",
35
- importPath: "react/jsx-runtime",
36
- publicPath: runtimeImports.reactJsxRuntime
37
- },
38
- {
39
- specifier: "react/jsx-dev-runtime",
40
- owner: "@ecopages/react",
41
- importPath: "react/jsx-dev-runtime",
42
- publicPath: runtimeImports.reactJsxDevRuntime
43
- },
44
- {
45
- specifier: "react-dom",
46
- owner: "@ecopages/react",
47
- importPath: "react-dom",
48
- publicPath: runtimeImports.reactDom
49
- },
50
- {
51
- specifier: "react-dom/client",
52
- owner: "@ecopages/react",
53
- importPath: "react-dom/client",
54
- publicPath: runtimeImports.reactDomClient
55
- },
56
- {
57
- specifier: "use-sync-external-store/shim",
58
- owner: "@ecopages/react",
59
- importPath: "use-sync-external-store/shim",
60
- publicPath: runtimeImports.react
61
- },
62
- {
63
- specifier: "use-sync-external-store/shim/index.js",
64
- owner: "@ecopages/react",
65
- importPath: "use-sync-external-store/shim/index.js",
66
- publicPath: runtimeImports.react
67
- },
68
- {
69
- specifier: "use-sync-external-store/shim/with-selector",
70
- owner: "@ecopages/react",
71
- importPath: "use-sync-external-store/shim/with-selector",
72
- publicPath: runtimeImports.useSyncExternalStoreWithSelector
73
- },
74
- {
75
- specifier: "use-sync-external-store/shim/with-selector.js",
76
- owner: "@ecopages/react",
77
- importPath: "use-sync-external-store/shim/with-selector.js",
78
- publicPath: runtimeImports.useSyncExternalStoreWithSelector
79
- },
80
- ...buildConfiguredRuntimeModuleManifestEntries(configuredRuntimeModules, getConfiguredRuntimeModulePublicPath)
81
- ]);
22
+ export function buildReactRuntimeManifest(runtimeImports, configuredRuntimeModules = [], getConfiguredRuntimeModulePublicPath = () => '', options) {
23
+ const frameworkDeclarations = [
24
+ {
25
+ specifier: LAYOUT_COMPOSE_PACKAGE,
26
+ owner: '@ecopages/react',
27
+ importPath: LAYOUT_COMPOSE_PACKAGE,
28
+ publicPath: runtimeImports.layoutCompose,
29
+ },
30
+ ];
31
+ if (options?.routerImportPath && runtimeImports.router) {
32
+ frameworkDeclarations.push({
33
+ specifier: options.routerImportPath,
34
+ owner: '@ecopages/react-router',
35
+ importPath: options.routerImportPath,
36
+ publicPath: runtimeImports.router,
37
+ }, {
38
+ specifier: '@ecopages/react-router',
39
+ owner: '@ecopages/react-router',
40
+ importPath: options.routerImportPath,
41
+ publicPath: runtimeImports.router,
42
+ });
43
+ }
44
+ return createBrowserRuntimeManifest([
45
+ {
46
+ specifier: 'react',
47
+ owner: '@ecopages/react',
48
+ importPath: 'react',
49
+ publicPath: runtimeImports.react,
50
+ },
51
+ {
52
+ specifier: 'react/jsx-runtime',
53
+ owner: '@ecopages/react',
54
+ importPath: 'react/jsx-runtime',
55
+ publicPath: runtimeImports.reactJsxRuntime,
56
+ },
57
+ {
58
+ specifier: 'react/jsx-dev-runtime',
59
+ owner: '@ecopages/react',
60
+ importPath: 'react/jsx-dev-runtime',
61
+ publicPath: runtimeImports.reactJsxDevRuntime,
62
+ },
63
+ {
64
+ specifier: 'react-dom',
65
+ owner: '@ecopages/react',
66
+ importPath: 'react-dom',
67
+ publicPath: runtimeImports.reactDom,
68
+ },
69
+ {
70
+ specifier: 'react-dom/client',
71
+ owner: '@ecopages/react',
72
+ importPath: 'react-dom/client',
73
+ publicPath: runtimeImports.reactDomClient,
74
+ },
75
+ {
76
+ specifier: 'use-sync-external-store/shim',
77
+ owner: '@ecopages/react',
78
+ importPath: 'use-sync-external-store/shim',
79
+ publicPath: runtimeImports.react,
80
+ },
81
+ {
82
+ specifier: 'use-sync-external-store/shim/index.js',
83
+ owner: '@ecopages/react',
84
+ importPath: 'use-sync-external-store/shim/index.js',
85
+ publicPath: runtimeImports.react,
86
+ },
87
+ {
88
+ specifier: 'use-sync-external-store/shim/with-selector',
89
+ owner: '@ecopages/react',
90
+ importPath: 'use-sync-external-store/shim/with-selector',
91
+ publicPath: runtimeImports.useSyncExternalStoreWithSelector,
92
+ },
93
+ {
94
+ specifier: 'use-sync-external-store/shim/with-selector.js',
95
+ owner: '@ecopages/react',
96
+ importPath: 'use-sync-external-store/shim/with-selector.js',
97
+ publicPath: runtimeImports.useSyncExternalStoreWithSelector,
98
+ },
99
+ ...frameworkDeclarations,
100
+ ...buildConfiguredRuntimeModuleManifestEntries(configuredRuntimeModules, getConfiguredRuntimeModulePublicPath),
101
+ ]);
82
102
  }
83
- function getReactRuntimeExternalSpecifiers() {
84
- return [...REACT_RUNTIME_SPECIFIERS];
103
+ export function getReactRuntimeExternalSpecifiers() {
104
+ return [...REACT_RUNTIME_SPECIFIERS];
85
105
  }
86
- function getReactClientGraphAllowSpecifiers(runtimeSpecifiers, routerAdapter) {
87
- return [
88
- "@ecopages/core",
89
- ...REACT_RUNTIME_SPECIFIERS,
90
- ...routerAdapter ? [routerAdapter.bundle.importPath] : [],
91
- ...Array.from(runtimeSpecifiers)
92
- ];
106
+ export function getReactClientGraphAllowSpecifiers(runtimeSpecifiers, routerAdapter) {
107
+ return [
108
+ '@ecopages/core',
109
+ ...REACT_RUNTIME_SPECIFIERS,
110
+ ...(routerAdapter ? [routerAdapter.bundle.importPath] : []),
111
+ ...Array.from(runtimeSpecifiers),
112
+ ];
93
113
  }
94
- export {
95
- REACT_RUNTIME_SPECIFIERS,
96
- buildConfiguredRuntimeModuleManifestEntries,
97
- buildReactRuntimeAliasMap,
98
- buildReactRuntimeManifest,
99
- getReactClientGraphAllowSpecifiers,
100
- getReactRuntimeExternalSpecifiers
101
- };