@ecopages/react 0.2.0-beta.30 → 0.2.0-beta.32
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 +5 -1
- package/package.json +4 -4
- package/src/app/client-only.js +13 -17
- package/src/app/dynamic.js +7 -10
- package/src/app/dynamic.test.browser.js +27 -29
- package/src/bundling/bootstrap-package-paths.js +5 -6
- package/src/bundling/bundle.js +115 -114
- package/src/bundling/discover-layout-runtime-modules.js +166 -155
- package/src/bundling/runtime-alias-map.d.ts +4 -1
- package/src/bundling/runtime-alias-map.js +107 -95
- package/src/bundling/runtime-bundle.js +250 -274
- package/src/bundling/runtime-interop-plugin.js +31 -35
- package/src/bundling/runtime-mode.js +10 -5
- package/src/bundling/runtime-modules.js +46 -35
- package/src/client-graph/ast-transform.js +415 -305
- package/src/client-graph/boundary-cache.js +146 -104
- package/src/client-graph/boundary-plugin.js +122 -104
- package/src/client-graph/component-config-traversal.js +70 -49
- package/src/client-graph/declared-modules.js +63 -41
- package/src/client-graph/reachability-analyzer.js +506 -313
- package/src/client-graph/specifier-classification.js +209 -141
- package/src/contracts/router-adapter.js +6 -0
- package/src/dev-transform/react-dev-transform-contributor.d.ts +17 -0
- package/src/dev-transform/react-dev-transform-contributor.js +22 -0
- package/src/hmr/hmr-scripts.js +22 -9
- package/src/hmr/hmr-strategy.d.ts +12 -181
- package/src/hmr/hmr-strategy.js +321 -650
- package/src/hmr/page-metadata-cache.js +43 -40
- package/src/hmr/react-hmr-dev-transform-plugins.d.ts +23 -0
- package/src/hmr/react-hmr-dev-transform-plugins.js +20 -0
- package/src/hydration/assert-no-bare-ecopages-imports.js +6 -6
- package/src/hydration/bootstrap-imports.js +30 -20
- package/src/hydration/hydration-asset.js +216 -213
- package/src/hydration/hydration-scripts.d.ts +4 -0
- package/src/hydration/hydration-scripts.js +199 -66
- package/src/hydration/hydration-scripts.test.browser.js +163 -168
- package/src/hydration/page-data-manifest.js +89 -45
- package/src/hydration/page-data-reader.js +45 -32
- package/src/hydration/page-payload.js +101 -99
- package/src/hydration/serialize-page-data-script.js +27 -28
- package/src/mdx/mdx-config-dependency.js +108 -112
- package/src/mdx/mdx-loader-plugin.js +7 -10
- package/src/page/page-module.js +72 -66
- package/src/plugin/react.constants.js +1 -4
- package/src/plugin/react.plugin.d.ts +1 -0
- package/src/plugin/react.plugin.js +227 -216
- package/src/plugin/react.types.js +1 -0
- package/src/render/component-ownership.js +42 -18
- package/src/render/component-ssr.js +168 -190
- package/src/render/eco-embed.js +8 -10
- package/src/render/errors.js +21 -16
- package/src/render/html-boundary.js +55 -51
- package/src/render/layout-compose.js +122 -94
- package/src/render/react-renderer.js +433 -468
- package/src/render/react-runtime.js +25 -20
- package/src/render/unified-layout-composition.js +74 -85
- package/src/runtime/use-sync-external-store-with-selector.js +52 -54
|
@@ -1,47 +1,69 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Shared utilities for collecting declared module sources from component configs.
|
|
3
|
+
* Used by both the production ReactRenderer and the HMR strategy to ensure
|
|
4
|
+
* the client-graph-boundary plugin receives a consistent set of allowed modules.
|
|
5
|
+
*
|
|
6
|
+
* @module
|
|
7
|
+
*/
|
|
8
|
+
import { collectFromConfigTree } from './component-config-traversal.js';
|
|
9
|
+
/**
|
|
10
|
+
* Extracts the module source (package name) from a declared module string,
|
|
11
|
+
* stripping any `{namedImport,...}` grammar.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* parseDeclaredModuleSource('@ecopages/image-processor/component/react{EcoImage}')
|
|
15
|
+
* // → '@ecopages/image-processor/component/react'
|
|
16
|
+
*/
|
|
17
|
+
export function parseDeclaredModuleSource(value) {
|
|
18
|
+
const source = value.trim();
|
|
19
|
+
if (source.length === 0)
|
|
20
|
+
return undefined;
|
|
21
|
+
const openBraceIndex = source.indexOf('{');
|
|
22
|
+
if (openBraceIndex < 0)
|
|
23
|
+
return source;
|
|
24
|
+
const from = source.slice(0, openBraceIndex).trim();
|
|
25
|
+
return from.length > 0 ? from : undefined;
|
|
9
26
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
27
|
+
/**
|
|
28
|
+
* Normalizes an array of declared module strings into unique source paths.
|
|
29
|
+
*/
|
|
30
|
+
export function normalizeDeclaredModuleSources(modules) {
|
|
31
|
+
const seen = new Set();
|
|
32
|
+
for (const declaration of modules ?? []) {
|
|
33
|
+
const from = parseDeclaredModuleSource(declaration);
|
|
34
|
+
if (from) {
|
|
35
|
+
seen.add(from);
|
|
36
|
+
}
|
|
16
37
|
}
|
|
17
|
-
|
|
18
|
-
return Array.from(seen);
|
|
38
|
+
return Array.from(seen);
|
|
19
39
|
}
|
|
20
|
-
|
|
21
|
-
|
|
40
|
+
/**
|
|
41
|
+
* Recursively walks a component config tree (including layouts and nested
|
|
42
|
+
* `dependencies.components`) to collect all declared module sources.
|
|
43
|
+
*/
|
|
44
|
+
export function collectDeclaredModulesInConfig(config) {
|
|
45
|
+
return collectFromConfigTree(config, (node) => normalizeDeclaredModuleSources(node.dependencies?.modules));
|
|
22
46
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
47
|
+
/**
|
|
48
|
+
* Collects declared module sources from an already imported page module.
|
|
49
|
+
*/
|
|
50
|
+
export function collectPageDeclaredModulesFromModule(pageModule) {
|
|
51
|
+
const declarations = [
|
|
52
|
+
...collectDeclaredModulesInConfig(pageModule.default?.config),
|
|
53
|
+
...collectDeclaredModulesInConfig(pageModule.config),
|
|
54
|
+
];
|
|
55
|
+
return Array.from(new Set(declarations));
|
|
29
56
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
57
|
+
/**
|
|
58
|
+
* Imports a page entrypoint and collects all transitively declared module sources
|
|
59
|
+
* from its config, layout config, and nested component configs.
|
|
60
|
+
*/
|
|
61
|
+
export async function collectPageDeclaredModules(pagePath) {
|
|
62
|
+
try {
|
|
63
|
+
const pageModule = (await import(/* @vite-ignore */ pagePath));
|
|
64
|
+
return collectPageDeclaredModulesFromModule(pageModule);
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
return [];
|
|
68
|
+
}
|
|
40
69
|
}
|
|
41
|
-
export {
|
|
42
|
-
collectDeclaredModulesInConfig,
|
|
43
|
-
collectPageDeclaredModules,
|
|
44
|
-
collectPageDeclaredModulesFromModule,
|
|
45
|
-
normalizeDeclaredModuleSources,
|
|
46
|
-
parseDeclaredModuleSource
|
|
47
|
-
};
|