@ecopages/core 0.2.0-rc.0 → 0.2.0-rc.10
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 +52 -33
- package/package.json +58 -4
- package/src/adapters/README.md +3 -1
- package/src/adapters/abstract/application-adapter.d.ts +28 -6
- package/src/adapters/abstract/application-adapter.js +58 -5
- package/src/adapters/abstract/segment-path-matcher.js +56 -38
- package/src/adapters/abstract/server-adapter.d.ts +14 -0
- package/src/adapters/abstract/server-adapter.js +10 -0
- package/src/adapters/bun/create-app.d.ts +10 -6
- package/src/adapters/bun/create-app.js +64 -37
- package/src/adapters/bun/server-adapter.d.ts +6 -2
- package/src/adapters/bun/server-adapter.js +14 -1
- package/src/adapters/create-app.d.ts +62 -7
- package/src/adapters/create-app.js +61 -5
- package/src/adapters/node/create-app.d.ts +5 -5
- package/src/adapters/node/create-app.js +18 -5
- package/src/adapters/node/runtime-host.js +9 -4
- package/src/adapters/node/server-adapter.d.ts +5 -1
- package/src/adapters/node/server-adapter.js +16 -1
- package/src/adapters/shared/http/define-api-handler.d.ts +7 -49
- package/src/adapters/shared/http/explicit-static-route-matcher.js +5 -2
- package/src/adapters/shared/http/fs-server-response-factory.d.ts +2 -8
- package/src/adapters/shared/http/fs-server-response-factory.js +5 -30
- package/src/adapters/shared/http/fs-server-response-matcher.d.ts +24 -24
- package/src/adapters/shared/http/fs-server-response-matcher.js +59 -83
- package/src/adapters/shared/runtime/application-adapter.d.ts +1 -0
- package/src/adapters/shared/runtime/application-adapter.js +12 -0
- package/src/adapters/shared/runtime/bind-runtime-server.d.ts +17 -0
- package/src/adapters/shared/runtime/bind-runtime-server.js +50 -0
- package/src/adapters/shared/runtime/port-manager-default-prompt.d.ts +6 -0
- package/src/adapters/shared/runtime/port-manager-default-prompt.js +41 -0
- package/src/adapters/shared/runtime/port-manager.d.ts +3 -3
- package/src/adapters/shared/runtime/port-manager.js +14 -45
- package/src/adapters/shared/runtime/server-adapter.d.ts +14 -5
- package/src/adapters/shared/runtime/server-adapter.js +22 -30
- package/src/adapters/shared/runtime/server-route-handler.js +11 -3
- package/src/adapters/shared/runtime/server-static-builder.d.ts +9 -3
- package/src/adapters/shared/runtime/server-static-builder.js +59 -37
- package/src/build/README.md +5 -1
- package/src/build/cache/server-entry-build-cache.d.ts +24 -1
- package/src/build/cache/server-entry-build-cache.js +125 -8
- package/src/build/contracts/content-virtual-modules.d.ts +3 -1
- package/src/build/contracts/content-virtual-modules.js +8 -0
- package/src/build/rolldown/rolldown-adapter-helpers.js +56 -31
- package/src/build/rolldown/rolldown-plugin-bridge.js +25 -21
- package/src/build/rolldown/runtime-build-output-normalizer.js +3 -29
- package/src/build/runtime/build-request-policy.js +1 -1
- package/src/build/server-bundle-publication.d.ts +14 -0
- package/src/build/server-bundle-publication.js +49 -0
- package/src/config/README.md +17 -2
- package/src/config/apply-user-config.d.ts +6 -0
- package/src/config/apply-user-config.js +67 -0
- package/src/config/config-builder.d.ts +10 -1
- package/src/config/config-builder.js +51 -10
- package/src/config/constants.d.ts +4 -0
- package/src/config/constants.js +4 -0
- package/src/config/define-config.d.ts +9 -0
- package/src/config/define-config.js +10 -0
- package/src/config/index.d.ts +5 -0
- package/src/config/index.js +4 -0
- package/src/config/is-finalized-app-config.d.ts +6 -0
- package/src/config/is-finalized-app-config.js +11 -0
- package/src/config/load-eco-config.d.ts +21 -0
- package/src/config/load-eco-config.js +100 -0
- package/src/config/resolve-eco-config-path.d.ts +23 -0
- package/src/config/resolve-eco-config-path.js +47 -0
- package/src/config/server-config-bundle.d.ts +25 -0
- package/src/config/server-config-bundle.js +148 -0
- package/src/config/user-config-types.d.ts +164 -0
- package/src/config/user-config-types.js +1 -0
- package/src/css-imports.d.ts +4 -0
- package/src/declarations.d.ts +11 -5
- package/src/dev/README.md +6 -0
- package/src/dev/development-restart-watch-paths.d.ts +13 -0
- package/src/dev/development-restart-watch-paths.js +37 -0
- package/src/dev/development-restart.d.ts +13 -0
- package/src/dev/development-restart.js +21 -0
- package/src/dev/transform-server/dev-transform-server.d.ts +6 -0
- package/src/dev/transform-server/dev-transform-server.js +16 -5
- package/src/eco/README.md +73 -5
- package/src/eco/component-identity.d.ts +3 -2
- package/src/eco/component-identity.js +5 -2
- package/src/eco/discovered-dependencies.d.ts +45 -0
- package/src/eco/discovered-dependencies.js +87 -0
- package/src/eco/eco.js +6 -0
- package/src/eco/eco.types.d.ts +18 -2
- package/src/eco/lazy-injector-map.js +57 -41
- package/src/eco/page-dependency-contributions.d.ts +19 -0
- package/src/eco/page-dependency-contributions.js +52 -0
- package/src/errors/http-error-page-contract.d.ts +77 -0
- package/src/errors/http-error-page-contract.js +106 -0
- package/src/hmr/strategies/js-hmr-strategy.d.ts +2 -0
- package/src/hmr/strategies/js-hmr-strategy.js +24 -16
- package/src/index.browser.d.ts +3 -0
- package/src/index.browser.js +3 -0
- package/src/index.d.ts +4 -1
- package/src/index.js +4 -1
- package/src/islands/README.md +5 -1
- package/src/plugins/README.md +10 -2
- package/src/plugins/component-import-discovery.d.ts +19 -0
- package/src/plugins/component-import-discovery.js +241 -0
- package/src/plugins/eco-component-meta-plugin.d.ts +3 -1
- package/src/plugins/eco-component-meta-plugin.js +118 -16
- package/src/plugins/integration-plugin.d.ts +4 -9
- package/src/plugins/processor.d.ts +23 -2
- package/src/plugins/processor.js +25 -0
- package/src/plugins/tsconfig-import-resolver.d.ts +3 -1
- package/src/plugins/tsconfig-import-resolver.js +4 -2
- package/src/route-renderer/GRAPH.md +1 -1
- package/src/route-renderer/README.md +16 -3
- package/src/{adapters/shared/http/explicit-static-render-preparation.d.ts → route-renderer/explicit-view-render-preparation.d.ts} +3 -3
- package/src/route-renderer/orchestration/custom-element-scripts/README.md +9 -0
- package/src/route-renderer/orchestration/custom-element-scripts/custom-element-script-preload-invalidation.d.ts +16 -0
- package/src/route-renderer/orchestration/custom-element-scripts/custom-element-script-preload-invalidation.js +34 -0
- package/src/route-renderer/orchestration/custom-element-scripts/custom-element-script-preloader.d.ts +80 -0
- package/src/route-renderer/orchestration/custom-element-scripts/custom-element-script-preloader.js +190 -0
- package/src/route-renderer/orchestration/custom-element-scripts/custom-element-server-module-importer.d.ts +17 -0
- package/src/route-renderer/orchestration/custom-element-scripts/custom-element-server-module-importer.js +41 -0
- package/src/route-renderer/orchestration/custom-element-scripts/custom-element-ssr-preload-entrypoint.d.ts +10 -0
- package/src/route-renderer/orchestration/custom-element-scripts/custom-element-ssr-preload-entrypoint.js +46 -0
- package/src/route-renderer/orchestration/document-shell/document-shell-render.service.d.ts +7 -2
- package/src/route-renderer/orchestration/document-shell/document-shell-render.service.js +2 -0
- package/src/route-renderer/orchestration/document-shell/layout-shell-props.service.d.ts +13 -1
- package/src/route-renderer/orchestration/document-shell/layout-shell-props.service.js +15 -0
- package/src/route-renderer/orchestration/foreign-child/foreign-subtree-execution.service.d.ts +11 -2
- package/src/route-renderer/orchestration/foreign-child/foreign-subtree-execution.service.js +10 -2
- package/src/route-renderer/orchestration/integration-renderer.d.ts +11 -5
- package/src/route-renderer/orchestration/integration-renderer.js +42 -29
- package/src/route-renderer/orchestration/ownership-graph/component-graph-collectors.d.ts +2 -5
- package/src/route-renderer/orchestration/ownership-graph/component-graph-collectors.js +2 -68
- package/src/route-renderer/orchestration/ownership-graph/component-graph.js +55 -39
- package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph.service.d.ts +6 -0
- package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph.service.js +59 -36
- package/src/route-renderer/orchestration/route-pipeline/route-render-orchestrator.js +8 -10
- package/src/route-renderer/orchestration/string-markup-renderer.d.ts +1 -1
- package/src/route-renderer/orchestration/string-markup-renderer.js +10 -8
- package/src/route-renderer/page-loading/component-dependency-collection.d.ts +6 -2
- package/src/route-renderer/page-loading/component-dependency-collection.js +113 -68
- package/src/route-renderer/page-loading/ecopages-virtual-imports.js +41 -28
- package/src/route-renderer/page-loading/file-scoped-dependency-components.d.ts +10 -3
- package/src/route-renderer/page-loading/file-scoped-dependency-components.js +62 -25
- package/src/route-renderer/page-loading/page-dependency-bundling.js +14 -8
- package/src/route-renderer/page-loading/resolved-page-dependencies.d.ts +1 -2
- package/src/route-renderer/page-loading/resolved-page-dependencies.js +8 -7
- package/src/route-renderer/route-renderer.d.ts +9 -0
- package/src/route-renderer/route-renderer.js +18 -0
- package/src/router/README.md +7 -1
- package/src/router/server/route-registry.d.ts +13 -0
- package/src/router/server/route-registry.js +46 -32
- package/src/services/README.md +5 -0
- package/src/services/assets/asset-processing-service/browser-runtime-entry-resolution.d.ts +36 -9
- package/src/services/assets/asset-processing-service/browser-runtime-entry-resolution.js +122 -37
- package/src/services/assets/asset-processing-service/browser-runtime-entry.factory.d.ts +2 -0
- package/src/services/assets/asset-processing-service/browser-runtime-entry.factory.js +13 -2
- package/src/services/assets/asset-processing-service/page-package.js +42 -39
- package/src/services/error-pages/README.md +9 -0
- package/src/services/error-pages/default-error-pages.d.ts +44 -0
- package/src/services/error-pages/default-error-pages.js +207 -0
- package/src/services/error-pages/error-page-renderer.d.ts +58 -0
- package/src/services/error-pages/error-page-renderer.js +146 -0
- package/src/services/error-pages/semantic-error-page-exporter.d.ts +23 -0
- package/src/services/error-pages/semantic-error-page-exporter.js +35 -0
- package/src/services/invalidation/development-invalidation.service.d.ts +7 -1
- package/src/services/invalidation/development-invalidation.service.js +35 -3
- package/src/services/module-loading/README.md +16 -13
- package/src/services/module-loading/app-server-module-transpiler.service.js +2 -0
- package/src/services/module-loading/collection-server-module-build.service.d.ts +1 -0
- package/src/services/module-loading/collection-server-module-build.service.js +5 -2
- package/src/services/module-loading/page-module-import.service.d.ts +8 -0
- package/src/services/module-loading/page-module-import.service.js +62 -28
- package/src/services/module-loading/route-module-dependency-hasher.js +13 -1
- package/src/services/module-loading/view-module-loader.d.ts +10 -0
- package/src/services/module-loading/view-module-loader.js +46 -0
- package/src/services/validation/schema-validation-service.d.ts +1 -0
- package/src/services/validation/schema-validation-service.js +23 -36
- package/src/static-site-generator/README.md +6 -1
- package/src/static-site-generator/static-site-generator.d.ts +7 -2
- package/src/static-site-generator/static-site-generator.js +90 -49
- package/src/types/internal-types.d.ts +6 -1
- package/src/types/public-types.d.ts +34 -24
- package/src/utils/parse-cli-args.js +29 -22
- package/src/watchers/project-watcher.d.ts +14 -1
- package/src/watchers/project-watcher.js +85 -34
- /package/src/{adapters/shared/http/explicit-static-render-preparation.js → route-renderer/explicit-view-render-preparation.js} +0 -0
|
@@ -21,6 +21,24 @@ export class RouteRendererFactory {
|
|
|
21
21
|
this.rendererModules = rendererModules;
|
|
22
22
|
this.runtimeOrigin = runtimeOrigin;
|
|
23
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* Rebinds renderer creation to the actual listening origin.
|
|
26
|
+
*
|
|
27
|
+
* @remarks
|
|
28
|
+
* A development server may select a fallback port after this factory is
|
|
29
|
+
* constructed. Cached renderers retain their original page-module loader, so
|
|
30
|
+
* they must be discarded when the origin changes.
|
|
31
|
+
*/
|
|
32
|
+
setRuntimeOrigin(runtimeOrigin) {
|
|
33
|
+
if (this.runtimeOrigin === runtimeOrigin) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
this.runtimeOrigin = runtimeOrigin;
|
|
37
|
+
this.rendererCache.clear();
|
|
38
|
+
for (const integration of this.appConfig.integrations) {
|
|
39
|
+
integration.setRuntimeOrigin?.(runtimeOrigin);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
24
42
|
/**
|
|
25
43
|
* Returns a route renderer for the supplied route file.
|
|
26
44
|
*/
|
package/src/router/README.md
CHANGED
|
@@ -56,7 +56,11 @@ Match priority:
|
|
|
56
56
|
|
|
57
57
|
1. `exact` — the pathname must equal the route pathname exactly.
|
|
58
58
|
2. `dynamic` — the clean (bracket-stripped) prefix must appear in the pathname, and the segment counts must match.
|
|
59
|
-
3. `catch-all` — the
|
|
59
|
+
3. `catch-all` — the prefix segments must match the pathname. When multiple
|
|
60
|
+
catch-all routes match, shared prefix segments are compared from left to right
|
|
61
|
+
so an earlier static segment wins over a dynamic one; when those patterns tie,
|
|
62
|
+
the route with the longer prefix wins, then pathname order provides a
|
|
63
|
+
deterministic tie-breaker.
|
|
60
64
|
|
|
61
65
|
## `client/`
|
|
62
66
|
|
|
@@ -110,6 +114,8 @@ import {
|
|
|
110
114
|
|
|
111
115
|
This is separate from coordinator `subscribe()` events, which track runtime ownership rather than page lifecycle.
|
|
112
116
|
|
|
117
|
+
Scripts listening to client navigation events (`eco:after-swap`, `eco:page-load`) should be registered as client scripts (e.g., using `scripts: ['./component.script.ts']`) or guarded by `isServer` from `@ecopages/radiant/is-server` when used in Radiant projects where `document` is defined during SSR.
|
|
118
|
+
|
|
113
119
|
### Link Intent (`link-intent.ts`)
|
|
114
120
|
|
|
115
121
|
Shared helpers for locating anchors and recovering stale navigation intent.
|
|
@@ -62,6 +62,19 @@ export declare class RouteRegistry {
|
|
|
62
62
|
reload(): Promise<void>;
|
|
63
63
|
onReload(listener: () => void): () => void;
|
|
64
64
|
matchRequest(requestUrl: string): RouteMatch | null;
|
|
65
|
+
/**
|
|
66
|
+
* Orders overlapping catch-all routes by the specificity of their prefix.
|
|
67
|
+
*
|
|
68
|
+
* @remarks
|
|
69
|
+
* Prefix segments are compared from left to right because an earlier static
|
|
70
|
+
* segment constrains a request more strongly than a later one. A longer
|
|
71
|
+
* prefix wins only after the shared segment pattern ties. The pathname tie
|
|
72
|
+
* breaker keeps equal patterns deterministic without depending on discovery
|
|
73
|
+
* order.
|
|
74
|
+
*/
|
|
75
|
+
private compareCatchAllSpecificity;
|
|
76
|
+
private getCatchAllPrefix;
|
|
77
|
+
private isDynamicRouteSegment;
|
|
65
78
|
listStaticPathExpansions(input: {
|
|
66
79
|
runtimeOrigin: string;
|
|
67
80
|
}): Promise<readonly StaticPathExpansion[]>;
|
|
@@ -49,49 +49,60 @@ export class RouteRegistry {
|
|
|
49
49
|
const requestedPathname = normalizePathname(url.pathname);
|
|
50
50
|
const query = this.getSearchParams(url);
|
|
51
51
|
for (const route of this.templateRouteList) {
|
|
52
|
-
if (route.kind
|
|
52
|
+
if (route.kind === 'exact') {
|
|
53
|
+
if (requestedPathname === route.pathname || requestedPathname === `${route.pathname}/`) {
|
|
54
|
+
return {
|
|
55
|
+
requestedPathname,
|
|
56
|
+
templateRoute: route,
|
|
57
|
+
params: {},
|
|
58
|
+
query,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
53
61
|
continue;
|
|
54
62
|
}
|
|
55
|
-
|
|
63
|
+
const params = this.tryExtractParams(route, requestedPathname);
|
|
64
|
+
if (params) {
|
|
56
65
|
return {
|
|
57
66
|
requestedPathname,
|
|
58
67
|
templateRoute: route,
|
|
59
|
-
params
|
|
68
|
+
params,
|
|
60
69
|
query,
|
|
61
70
|
};
|
|
62
71
|
}
|
|
63
72
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
continue;
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Orders overlapping catch-all routes by the specificity of their prefix.
|
|
77
|
+
*
|
|
78
|
+
* @remarks
|
|
79
|
+
* Prefix segments are compared from left to right because an earlier static
|
|
80
|
+
* segment constrains a request more strongly than a later one. A longer
|
|
81
|
+
* prefix wins only after the shared segment pattern ties. The pathname tie
|
|
82
|
+
* breaker keeps equal patterns deterministic without depending on discovery
|
|
83
|
+
* order.
|
|
84
|
+
*/
|
|
85
|
+
compareCatchAllSpecificity(left, right) {
|
|
86
|
+
const leftPrefix = this.getCatchAllPrefix(left.pathname);
|
|
87
|
+
const rightPrefix = this.getCatchAllPrefix(right.pathname);
|
|
88
|
+
const sharedLength = Math.min(leftPrefix.length, rightPrefix.length);
|
|
89
|
+
for (let index = 0; index < sharedLength; index += 1) {
|
|
90
|
+
const leftIsDynamic = this.isDynamicRouteSegment(leftPrefix[index]);
|
|
91
|
+
const rightIsDynamic = this.isDynamicRouteSegment(rightPrefix[index]);
|
|
92
|
+
if (leftIsDynamic !== rightIsDynamic) {
|
|
93
|
+
return leftIsDynamic ? 1 : -1;
|
|
86
94
|
}
|
|
87
|
-
return {
|
|
88
|
-
requestedPathname,
|
|
89
|
-
templateRoute: route,
|
|
90
|
-
params,
|
|
91
|
-
query,
|
|
92
|
-
};
|
|
93
95
|
}
|
|
94
|
-
|
|
96
|
+
const prefixLengthDifference = rightPrefix.length - leftPrefix.length;
|
|
97
|
+
return prefixLengthDifference !== 0 ? prefixLengthDifference : left.pathname.localeCompare(right.pathname);
|
|
98
|
+
}
|
|
99
|
+
getCatchAllPrefix(pathname) {
|
|
100
|
+
const segments = pathname.split('/').filter(Boolean);
|
|
101
|
+
const catchAllIndex = segments.findIndex((segment) => segment.startsWith('[...') && segment.endsWith(']'));
|
|
102
|
+
return catchAllIndex === -1 ? segments : segments.slice(0, catchAllIndex);
|
|
103
|
+
}
|
|
104
|
+
isDynamicRouteSegment(segment) {
|
|
105
|
+
return segment.startsWith('[') && segment.endsWith(']');
|
|
95
106
|
}
|
|
96
107
|
async listStaticPathExpansions(input) {
|
|
97
108
|
const expansions = [];
|
|
@@ -168,6 +179,9 @@ export class RouteRegistry {
|
|
|
168
179
|
if (priorityDifference !== 0) {
|
|
169
180
|
return priorityDifference;
|
|
170
181
|
}
|
|
182
|
+
if (left.kind === 'catch-all' && right.kind === 'catch-all') {
|
|
183
|
+
return this.compareCatchAllSpecificity(left, right);
|
|
184
|
+
}
|
|
171
185
|
if (left.pathname === '/') {
|
|
172
186
|
return -1;
|
|
173
187
|
}
|
package/src/services/README.md
CHANGED
|
@@ -23,11 +23,16 @@ Typical responsibilities include:
|
|
|
23
23
|
- `runtime-state/`: app-owned invalidation state and dependency graphs
|
|
24
24
|
- `runtime-manifest/`: node runtime manifest derivation and persistence
|
|
25
25
|
- `html/`: final HTML dependency injection and rewriter selection
|
|
26
|
+
- `error-pages/`: shared semantic 404/500 source precedence, rendering, built-in documents, and static export artifacts
|
|
26
27
|
|
|
27
28
|
The asset-processing service caches emitted file assets by source identity in development as well as production.
|
|
28
29
|
When a source file changes, its source hash or explicit invalidation removes the cached asset before the next render,
|
|
29
30
|
so shared layout styles do not need to be rebuilt for every navigated page while HMR remains fresh.
|
|
30
31
|
|
|
32
|
+
Browser runtime module assets resolve bare package roots through their ESM import target. For legacy packages without an `exports` map, they prefer `package.json#module` over CJS `main`; CJS resolution is only a compatibility fallback. Generated entries use `export *` for ESM files and explicit named re-exports for CJS files (so bindings such as React `jsx` exist on the vendor). A default binding is added only when the selected entry exposes one. Runtime vendors are package-root contracts: subpath imports need their own vendor declaration or remain in the consuming bundle.
|
|
33
|
+
|
|
34
|
+
Package entry lookup is rooted at the application directory, so a framework-local dependency with the same name cannot shadow the application's installed package. ESM export conditions are evaluated in the same order as the generated vendor import (`node`, `import`, then `default`).
|
|
35
|
+
|
|
31
36
|
## Design Rule
|
|
32
37
|
|
|
33
38
|
If a concern affects more than one integration or more than one runtime adapter, it usually belongs here instead of in a package-specific implementation.
|
|
@@ -2,9 +2,27 @@ import type { createRequire } from 'node:module';
|
|
|
2
2
|
export type BrowserRuntimeDefaultExportPolicy = 'emit-default' | 'skip-default';
|
|
3
3
|
type RequireFromRoot = ReturnType<typeof createRequire>;
|
|
4
4
|
/**
|
|
5
|
-
* Resolves a package specifier
|
|
5
|
+
* Resolves a package specifier through Node's ESM import conditions from the app root.
|
|
6
|
+
*
|
|
7
|
+
* @remarks
|
|
8
|
+
* The resolver is rooted at the application directory so package lookup cannot
|
|
9
|
+
* accidentally use a dependency with the same name from the framework's own
|
|
10
|
+
* installation. The condition order matches the generated vendor import: Node
|
|
11
|
+
* compatibility first, then ESM import, then the package default.
|
|
6
12
|
*/
|
|
7
13
|
export declare function resolvePackageEsmEntryPath(specifier: string, rootDir: string): string | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* Resolves a browser runtime specifier to the absolute file that the generated
|
|
16
|
+
* vendor entry will import, when that import is a path.
|
|
17
|
+
*
|
|
18
|
+
* @remarks
|
|
19
|
+
* `node:` specifiers have no file path. `file:` URLs are converted to paths.
|
|
20
|
+
*/
|
|
21
|
+
export declare function resolveBrowserRuntimeEntryPath(options: {
|
|
22
|
+
specifier: string;
|
|
23
|
+
requireFromRoot: RequireFromRoot;
|
|
24
|
+
rootDir: string;
|
|
25
|
+
}): string | undefined;
|
|
8
26
|
/**
|
|
9
27
|
* Builds a relative import path from a generated runtime entry file to a resolved module path.
|
|
10
28
|
*/
|
|
@@ -13,10 +31,9 @@ export declare function toRelativeEntryImport(entryDir: string, resolvedPath: st
|
|
|
13
31
|
* Resolves a browser runtime entry import to an ESM file path when possible.
|
|
14
32
|
*
|
|
15
33
|
* @remarks
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* a `.cjs` → `.js` sibling fallback.
|
|
34
|
+
* Browser vendor entries resolve through ESM import conditions first. A package
|
|
35
|
+
* root without `exports` may instead select its legacy `module` field; CJS
|
|
36
|
+
* resolution is the final compatibility fallback.
|
|
20
37
|
*/
|
|
21
38
|
export declare function resolveBrowserRuntimeEntryImport(options: {
|
|
22
39
|
specifier: string;
|
|
@@ -42,11 +59,21 @@ export declare function inferBrowserRuntimeDefaultExportPolicy(options: {
|
|
|
42
59
|
rootDir: string;
|
|
43
60
|
}): BrowserRuntimeDefaultExportPolicy;
|
|
44
61
|
/**
|
|
45
|
-
*
|
|
62
|
+
* Returns true when the resolved vendor file is an ESM module that Rolldown can
|
|
63
|
+
* re-export with `export *`.
|
|
64
|
+
*
|
|
65
|
+
* @remarks
|
|
66
|
+
* React's published "import" files are still CJS wrappers. `export *` from those
|
|
67
|
+
* files does not emit named ESM bindings such as `jsx`.
|
|
68
|
+
*/
|
|
69
|
+
export declare function browserRuntimeEntryHasEsmExports(entryPath: string | undefined): boolean;
|
|
70
|
+
/**
|
|
71
|
+
* Reads enumerable CJS exports from the same file the generated entry imports.
|
|
46
72
|
*
|
|
47
73
|
* @remarks
|
|
48
|
-
*
|
|
49
|
-
*
|
|
74
|
+
* Used only when {@link browserRuntimeEntryHasEsmExports} is false. ESM entries
|
|
75
|
+
* must not harvest names from `require()`, which copies class statics that are
|
|
76
|
+
* not ESM named exports.
|
|
50
77
|
*/
|
|
51
|
-
export declare function
|
|
78
|
+
export declare function listBrowserRuntimeCjsExportNames(moduleId: string, requireFromRoot: RequireFromRoot): string[];
|
|
52
79
|
export {};
|
|
@@ -1,13 +1,98 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
|
-
import {
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
import { ResolverFactory } from 'oxc-resolver';
|
|
4
5
|
import { isBarePackageImportSpecifier } from '../../../plugins/tsconfig-import-resolver.js';
|
|
6
|
+
import { toPackageRootSpecifier } from '../../../plugins/package-specifier.js';
|
|
7
|
+
const esmEntryResolvers = new Map();
|
|
8
|
+
function getEsmEntryResolver(rootDir) {
|
|
9
|
+
const normalizedRoot = path.resolve(rootDir);
|
|
10
|
+
const cached = esmEntryResolvers.get(normalizedRoot);
|
|
11
|
+
if (cached) {
|
|
12
|
+
return cached;
|
|
13
|
+
}
|
|
14
|
+
const resolver = new ResolverFactory({ conditionNames: ['node', 'import', 'default'] });
|
|
15
|
+
esmEntryResolvers.set(normalizedRoot, resolver);
|
|
16
|
+
return resolver;
|
|
17
|
+
}
|
|
5
18
|
/**
|
|
6
|
-
* Resolves a package specifier
|
|
19
|
+
* Resolves a package specifier through Node's ESM import conditions from the app root.
|
|
20
|
+
*
|
|
21
|
+
* @remarks
|
|
22
|
+
* The resolver is rooted at the application directory so package lookup cannot
|
|
23
|
+
* accidentally use a dependency with the same name from the framework's own
|
|
24
|
+
* installation. The condition order matches the generated vendor import: Node
|
|
25
|
+
* compatibility first, then ESM import, then the package default.
|
|
7
26
|
*/
|
|
8
27
|
export function resolvePackageEsmEntryPath(specifier, rootDir) {
|
|
9
28
|
try {
|
|
10
|
-
|
|
29
|
+
const result = getEsmEntryResolver(rootDir).sync(path.resolve(rootDir), specifier);
|
|
30
|
+
return result.path;
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
return undefined;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
function resolveLegacyPackageModuleEntry(options) {
|
|
37
|
+
if (!isBarePackageImportSpecifier(options.specifier, options.rootDir)) {
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
40
|
+
const packageRoot = toPackageRootSpecifier(options.specifier);
|
|
41
|
+
if (options.specifier !== packageRoot) {
|
|
42
|
+
return undefined;
|
|
43
|
+
}
|
|
44
|
+
try {
|
|
45
|
+
const packageJsonPath = options.requireFromRoot.resolve(`${packageRoot}/package.json`);
|
|
46
|
+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
|
47
|
+
if (packageJson.exports !== undefined || typeof packageJson.module !== 'string') {
|
|
48
|
+
return undefined;
|
|
49
|
+
}
|
|
50
|
+
const modulePath = path.resolve(path.dirname(packageJsonPath), packageJson.module);
|
|
51
|
+
return fs.existsSync(modulePath) ? modulePath : undefined;
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
return undefined;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
const ESM_DEFAULT_EXPORT = /\bexport\s+default\b/;
|
|
58
|
+
const ESM_NAMED_EXPORT = /\bexport\s+(?:[\w*{]|const|let|var|function|class)/;
|
|
59
|
+
const EXPORTABLE_BINDING_NAME = /^[$A-Z_a-z][$\w]*$/;
|
|
60
|
+
/**
|
|
61
|
+
* Resolves a browser runtime specifier to the absolute file that the generated
|
|
62
|
+
* vendor entry will import, when that import is a path.
|
|
63
|
+
*
|
|
64
|
+
* @remarks
|
|
65
|
+
* `node:` specifiers have no file path. `file:` URLs are converted to paths.
|
|
66
|
+
*/
|
|
67
|
+
export function resolveBrowserRuntimeEntryPath(options) {
|
|
68
|
+
const { specifier, requireFromRoot, rootDir } = options;
|
|
69
|
+
if (specifier.startsWith('node:')) {
|
|
70
|
+
return undefined;
|
|
71
|
+
}
|
|
72
|
+
if (specifier.startsWith('file:')) {
|
|
73
|
+
return fileURLToPath(specifier);
|
|
74
|
+
}
|
|
75
|
+
if (specifier.startsWith('.')) {
|
|
76
|
+
return requireFromRoot.resolve(specifier);
|
|
77
|
+
}
|
|
78
|
+
const legacyModulePath = resolveLegacyPackageModuleEntry({ specifier, requireFromRoot, rootDir });
|
|
79
|
+
if (legacyModulePath) {
|
|
80
|
+
return legacyModulePath;
|
|
81
|
+
}
|
|
82
|
+
const esmResolvedPath = isBarePackageImportSpecifier(specifier, rootDir)
|
|
83
|
+
? resolvePackageEsmEntryPath(specifier, rootDir)
|
|
84
|
+
: undefined;
|
|
85
|
+
if (esmResolvedPath) {
|
|
86
|
+
return esmResolvedPath;
|
|
87
|
+
}
|
|
88
|
+
try {
|
|
89
|
+
const resolvedPath = requireFromRoot.resolve(specifier);
|
|
90
|
+
const esmSibling = resolvedPath.endsWith('.cjs')
|
|
91
|
+
? `${resolvedPath.slice(0, -4)}.js`
|
|
92
|
+
: resolvedPath.endsWith('.cts')
|
|
93
|
+
? `${resolvedPath.slice(0, -4)}.ts`
|
|
94
|
+
: undefined;
|
|
95
|
+
return esmSibling && fs.existsSync(esmSibling) ? esmSibling : resolvedPath;
|
|
11
96
|
}
|
|
12
97
|
catch {
|
|
13
98
|
return undefined;
|
|
@@ -27,36 +112,20 @@ export function toRelativeEntryImport(entryDir, resolvedPath) {
|
|
|
27
112
|
* Resolves a browser runtime entry import to an ESM file path when possible.
|
|
28
113
|
*
|
|
29
114
|
* @remarks
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
* a `.cjs` → `.js` sibling fallback.
|
|
115
|
+
* Browser vendor entries resolve through ESM import conditions first. A package
|
|
116
|
+
* root without `exports` may instead select its legacy `module` field; CJS
|
|
117
|
+
* resolution is the final compatibility fallback.
|
|
34
118
|
*/
|
|
35
119
|
export function resolveBrowserRuntimeEntryImport(options) {
|
|
36
120
|
const { specifier, requireFromRoot, entryDir, rootDir } = options;
|
|
37
121
|
if (specifier.startsWith('node:') || specifier.startsWith('file:')) {
|
|
38
122
|
return specifier;
|
|
39
123
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
if (isBarePackageImportSpecifier(specifier, rootDir)) {
|
|
45
|
-
const esmResolvedPath = resolvePackageEsmEntryPath(specifier, rootDir);
|
|
46
|
-
if (esmResolvedPath) {
|
|
47
|
-
return toRelativeEntryImport(entryDir, esmResolvedPath);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
const resolvedPath = requireFromRoot.resolve(specifier);
|
|
51
|
-
const esmSibling = resolvedPath.endsWith('.cjs')
|
|
52
|
-
? `${resolvedPath.slice(0, -4)}.js`
|
|
53
|
-
: resolvedPath.endsWith('.cts')
|
|
54
|
-
? `${resolvedPath.slice(0, -4)}.ts`
|
|
55
|
-
: undefined;
|
|
56
|
-
if (esmSibling && fs.existsSync(esmSibling)) {
|
|
57
|
-
return toRelativeEntryImport(entryDir, esmSibling);
|
|
124
|
+
const entryPath = resolveBrowserRuntimeEntryPath({ specifier, requireFromRoot, rootDir });
|
|
125
|
+
if (!entryPath) {
|
|
126
|
+
throw new Error(`Unable to resolve browser runtime entry for "${specifier}" from "${rootDir}"`);
|
|
58
127
|
}
|
|
59
|
-
return toRelativeEntryImport(entryDir,
|
|
128
|
+
return toRelativeEntryImport(entryDir, entryPath);
|
|
60
129
|
}
|
|
61
130
|
/**
|
|
62
131
|
* Decides whether a generated runtime entry should re-export a default binding.
|
|
@@ -72,13 +141,13 @@ export function resolveBrowserRuntimeEntryImport(options) {
|
|
|
72
141
|
*/
|
|
73
142
|
export function inferBrowserRuntimeDefaultExportPolicy(options) {
|
|
74
143
|
const { specifier, requireFromRoot, rootDir } = options;
|
|
75
|
-
const
|
|
76
|
-
if (
|
|
77
|
-
const source = fs.readFileSync(
|
|
78
|
-
if (
|
|
144
|
+
const entryPath = resolveBrowserRuntimeEntryPath({ specifier, requireFromRoot, rootDir });
|
|
145
|
+
if (entryPath && fs.existsSync(entryPath)) {
|
|
146
|
+
const source = fs.readFileSync(entryPath, 'utf8');
|
|
147
|
+
if (ESM_DEFAULT_EXPORT.test(source)) {
|
|
79
148
|
return 'emit-default';
|
|
80
149
|
}
|
|
81
|
-
if (
|
|
150
|
+
if (ESM_NAMED_EXPORT.test(source)) {
|
|
82
151
|
return 'skip-default';
|
|
83
152
|
}
|
|
84
153
|
}
|
|
@@ -94,22 +163,38 @@ export function inferBrowserRuntimeDefaultExportPolicy(options) {
|
|
|
94
163
|
}
|
|
95
164
|
}
|
|
96
165
|
/**
|
|
97
|
-
*
|
|
166
|
+
* Returns true when the resolved vendor file is an ESM module that Rolldown can
|
|
167
|
+
* re-export with `export *`.
|
|
168
|
+
*
|
|
169
|
+
* @remarks
|
|
170
|
+
* React's published "import" files are still CJS wrappers. `export *` from those
|
|
171
|
+
* files does not emit named ESM bindings such as `jsx`.
|
|
172
|
+
*/
|
|
173
|
+
export function browserRuntimeEntryHasEsmExports(entryPath) {
|
|
174
|
+
if (!entryPath || !fs.existsSync(entryPath)) {
|
|
175
|
+
return true;
|
|
176
|
+
}
|
|
177
|
+
const source = fs.readFileSync(entryPath, 'utf8');
|
|
178
|
+
return ESM_DEFAULT_EXPORT.test(source) || ESM_NAMED_EXPORT.test(source);
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Reads enumerable CJS exports from the same file the generated entry imports.
|
|
98
182
|
*
|
|
99
183
|
* @remarks
|
|
100
|
-
*
|
|
101
|
-
*
|
|
184
|
+
* Used only when {@link browserRuntimeEntryHasEsmExports} is false. ESM entries
|
|
185
|
+
* must not harvest names from `require()`, which copies class statics that are
|
|
186
|
+
* not ESM named exports.
|
|
102
187
|
*/
|
|
103
|
-
export function
|
|
188
|
+
export function listBrowserRuntimeCjsExportNames(moduleId, requireFromRoot) {
|
|
104
189
|
let moduleExports;
|
|
105
190
|
try {
|
|
106
|
-
moduleExports = requireFromRoot(
|
|
191
|
+
moduleExports = requireFromRoot(moduleId);
|
|
107
192
|
}
|
|
108
193
|
catch {
|
|
109
194
|
return [];
|
|
110
195
|
}
|
|
111
196
|
return Object.keys(moduleExports)
|
|
112
197
|
.filter((name) => name !== '__esModule' && name !== 'default')
|
|
113
|
-
.filter((name) =>
|
|
198
|
+
.filter((name) => EXPORTABLE_BINDING_NAME.test(name))
|
|
114
199
|
.sort();
|
|
115
200
|
}
|
|
@@ -12,6 +12,8 @@ export type BrowserRuntimeEntryModuleConfig = {
|
|
|
12
12
|
* logic themselves. The generated file lives under the app work directory so
|
|
13
13
|
* repeated runs can reuse the same location without placing sources inside
|
|
14
14
|
* `node_modules`, which can cause bundlers to externalize bare imports.
|
|
15
|
+
* ESM entries use `export *`. CJS entries emit explicit named re-exports from
|
|
16
|
+
* that same file so Rolldown can synthesize ESM bindings such as `jsx`.
|
|
15
17
|
*/
|
|
16
18
|
export declare function createBrowserRuntimeEntryModule(options: {
|
|
17
19
|
modules: BrowserRuntimeEntryModuleConfig[];
|
|
@@ -2,7 +2,7 @@ import fs from 'node:fs';
|
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { createRequire } from 'node:module';
|
|
4
4
|
import { DEFAULT_ECOPAGES_WORK_DIR } from '../../../config/constants.js';
|
|
5
|
-
import { inferBrowserRuntimeDefaultExportPolicy,
|
|
5
|
+
import { browserRuntimeEntryHasEsmExports, inferBrowserRuntimeDefaultExportPolicy, listBrowserRuntimeCjsExportNames, resolveBrowserRuntimeEntryImport, resolveBrowserRuntimeEntryPath, } from './browser-runtime-entry-resolution.js';
|
|
6
6
|
/**
|
|
7
7
|
* Creates a generated ESM entry module that re-exports runtime modules through
|
|
8
8
|
* one stable file.
|
|
@@ -13,6 +13,8 @@ import { inferBrowserRuntimeDefaultExportPolicy, listBrowserRuntimeModuleExportN
|
|
|
13
13
|
* logic themselves. The generated file lives under the app work directory so
|
|
14
14
|
* repeated runs can reuse the same location without placing sources inside
|
|
15
15
|
* `node_modules`, which can cause bundlers to externalize bare imports.
|
|
16
|
+
* ESM entries use `export *`. CJS entries emit explicit named re-exports from
|
|
17
|
+
* that same file so Rolldown can synthesize ESM bindings such as `jsx`.
|
|
16
18
|
*/
|
|
17
19
|
export function createBrowserRuntimeEntryModule(options) {
|
|
18
20
|
if (options.modules.some((module) => !module.specifier.startsWith('node:')) && !options.rootDir) {
|
|
@@ -34,13 +36,22 @@ export function createBrowserRuntimeEntryModule(options) {
|
|
|
34
36
|
entryDir,
|
|
35
37
|
rootDir,
|
|
36
38
|
});
|
|
39
|
+
const entryPath = resolveBrowserRuntimeEntryPath({
|
|
40
|
+
specifier: module.specifier,
|
|
41
|
+
requireFromRoot,
|
|
42
|
+
rootDir,
|
|
43
|
+
});
|
|
37
44
|
if (module.defaultExport &&
|
|
38
45
|
inferBrowserRuntimeDefaultExportPolicy({ specifier: module.specifier, requireFromRoot, rootDir }) ===
|
|
39
46
|
'emit-default') {
|
|
40
47
|
statements.push(`import __ecopages_default_export__ from '${importSpecifier}';`);
|
|
41
48
|
statements.push('export default __ecopages_default_export__;');
|
|
42
49
|
}
|
|
43
|
-
|
|
50
|
+
if (browserRuntimeEntryHasEsmExports(entryPath)) {
|
|
51
|
+
statements.push(`export * from '${importSpecifier}';`);
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
const exportNames = listBrowserRuntimeCjsExportNames(entryPath ?? module.specifier, requireFromRoot).filter((name) => !seenExports.has(name));
|
|
44
55
|
if (exportNames.length > 0) {
|
|
45
56
|
statements.push(`export { ${exportNames.join(', ')} } from '${importSpecifier}';`);
|
|
46
57
|
for (const exportName of exportNames) {
|
|
@@ -10,58 +10,61 @@ function getSuppressedSourceFilepaths(assets) {
|
|
|
10
10
|
}
|
|
11
11
|
return suppressed;
|
|
12
12
|
}
|
|
13
|
+
function classifyProcessedAsset(asset, buckets) {
|
|
14
|
+
if (asset.inline) {
|
|
15
|
+
buckets.inlineAssets.push(asset);
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
if (asset.packageRole === 'dynamic-chunk') {
|
|
19
|
+
buckets.dynamicChunks.push(asset);
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
if (!buckets.pageScript && asset.packageRole === 'page-script') {
|
|
23
|
+
buckets.pageScript = asset;
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
if (!buckets.pageStylesheet && asset.packageRole === 'page-style') {
|
|
27
|
+
buckets.pageStylesheet = asset;
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
if (asset.packageRole === 'keep-separate' || asset.packageRole === 'runtime') {
|
|
31
|
+
buckets.separateAssets.push(asset);
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
if (!buckets.pageScript && asset.kind === 'script' && !asset.excludeFromHtml) {
|
|
35
|
+
buckets.pageScript = asset;
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
if (!buckets.pageStylesheet && asset.kind === 'stylesheet') {
|
|
39
|
+
buckets.pageStylesheet = asset;
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
buckets.separateAssets.push(asset);
|
|
43
|
+
}
|
|
13
44
|
export function createPagePackage(assets, options = {}) {
|
|
14
45
|
const allAssets = [
|
|
15
46
|
...assets,
|
|
16
47
|
...(options.pageBrowserGraph?.entryAssets ?? []),
|
|
17
48
|
...(options.pageBrowserGraph?.chunkAssets ?? []),
|
|
18
49
|
];
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
50
|
+
const buckets = {
|
|
51
|
+
inlineAssets: [],
|
|
52
|
+
separateAssets: [],
|
|
53
|
+
dynamicChunks: [],
|
|
54
|
+
};
|
|
24
55
|
const suppressedSourceFilepaths = getSuppressedSourceFilepaths(allAssets);
|
|
25
56
|
for (const asset of allAssets) {
|
|
26
|
-
|
|
27
|
-
inlineAssets.push(asset);
|
|
28
|
-
continue;
|
|
29
|
-
}
|
|
30
|
-
if (asset.packageRole === 'dynamic-chunk') {
|
|
31
|
-
dynamicChunks.push(asset);
|
|
32
|
-
continue;
|
|
33
|
-
}
|
|
34
|
-
if (!pageScript && asset.packageRole === 'page-script') {
|
|
35
|
-
pageScript = asset;
|
|
36
|
-
continue;
|
|
37
|
-
}
|
|
38
|
-
if (!pageStylesheet && asset.packageRole === 'page-style') {
|
|
39
|
-
pageStylesheet = asset;
|
|
40
|
-
continue;
|
|
41
|
-
}
|
|
42
|
-
if (asset.packageRole === 'keep-separate' || asset.packageRole === 'runtime') {
|
|
43
|
-
separateAssets.push(asset);
|
|
44
|
-
continue;
|
|
45
|
-
}
|
|
46
|
-
if (!pageScript && asset.kind === 'script' && !asset.excludeFromHtml) {
|
|
47
|
-
pageScript = asset;
|
|
48
|
-
continue;
|
|
49
|
-
}
|
|
50
|
-
if (!pageStylesheet && asset.kind === 'stylesheet') {
|
|
51
|
-
pageStylesheet = asset;
|
|
52
|
-
continue;
|
|
53
|
-
}
|
|
54
|
-
separateAssets.push(asset);
|
|
57
|
+
classifyProcessedAsset(asset, buckets);
|
|
55
58
|
}
|
|
56
59
|
return {
|
|
57
60
|
assets: allAssets,
|
|
58
61
|
pageBrowserGraph: options.pageBrowserGraph,
|
|
59
62
|
htmlAssets: allAssets.filter((asset) => shouldIncludeInHtml(asset, suppressedSourceFilepaths)),
|
|
60
|
-
pageScript,
|
|
61
|
-
pageStylesheet,
|
|
62
|
-
inlineAssets,
|
|
63
|
-
separateAssets,
|
|
64
|
-
dynamicChunks,
|
|
63
|
+
pageScript: buckets.pageScript,
|
|
64
|
+
pageStylesheet: buckets.pageStylesheet,
|
|
65
|
+
inlineAssets: buckets.inlineAssets,
|
|
66
|
+
separateAssets: buckets.separateAssets,
|
|
67
|
+
dynamicChunks: buckets.dynamicChunks,
|
|
65
68
|
};
|
|
66
69
|
}
|
|
67
70
|
function shouldIncludeInHtml(asset, suppressedSourceFilepaths) {
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# Error pages
|
|
2
|
+
|
|
3
|
+
This directory owns semantic 404/500 page behavior shared by request-time rendering and static export.
|
|
4
|
+
|
|
5
|
+
- `error-page-renderer.ts` applies filesystem → registered-loader → built-in precedence. Registered views reuse `prepareExplicitStaticRender`. Callers that need a guaranteed built-in document after a custom-page failure use `renderBuiltIn()`. Static export asks `resolveSourceFile()` before rendering so unchanged sources can skip work.
|
|
6
|
+
- `default-error-pages.ts` renders self-contained fallback documents with development-only diagnostics.
|
|
7
|
+
- `semantic-error-page-exporter.ts` writes `/404.html` and `/500.html` exactly once during static export.
|
|
8
|
+
|
|
9
|
+
Runtime adapters only wrap the rendered body in an HTTP response; they do not decide error-page source precedence.
|