@ecopages/core 0.2.0-rc.1 → 0.2.0-rc.11
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 -41
- package/package.json +50 -145
- package/src/adapters/README.md +11 -3
- package/src/adapters/abstract/application-adapter.d.ts +32 -36
- package/src/adapters/abstract/application-adapter.js +61 -47
- 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/abstract/ws-pattern-matcher.d.ts +0 -5
- package/src/adapters/abstract/ws-pattern-matcher.js +0 -9
- package/src/adapters/bun/create-app.d.ts +15 -15
- package/src/adapters/bun/create-app.js +52 -67
- package/src/adapters/bun/hmr-manager.d.ts +0 -1
- package/src/adapters/bun/hmr-manager.js +2 -4
- package/src/adapters/bun/server-adapter.d.ts +15 -21
- package/src/adapters/bun/server-adapter.js +33 -67
- package/src/adapters/bun/static-preview-host.d.ts +1 -0
- package/src/adapters/bun/static-preview-host.js +1 -1
- package/src/adapters/create-app.d.ts +63 -8
- package/src/adapters/create-app.js +62 -5
- package/src/adapters/node/create-app.d.ts +8 -12
- package/src/adapters/node/create-app.js +22 -14
- package/src/adapters/node/runtime-host.d.ts +10 -10
- package/src/adapters/node/runtime-host.js +13 -8
- package/src/adapters/node/server-adapter-dependencies.d.ts +2 -10
- package/src/adapters/node/server-adapter-dependencies.js +8 -13
- package/src/adapters/node/server-adapter.d.ts +30 -32
- package/src/adapters/node/server-adapter.js +59 -65
- package/src/adapters/shared/hmr/shared-hmr-manager.d.ts +0 -4
- package/src/adapters/shared/hmr/shared-hmr-manager.js +0 -12
- package/src/adapters/shared/http/api-request-pipeline.d.ts +27 -1
- package/src/adapters/shared/http/api-request-pipeline.js +31 -16
- package/src/adapters/shared/http/explicit-static-route-matcher.js +5 -2
- package/src/adapters/shared/http/fs-server-response-factory.d.ts +2 -9
- package/src/adapters/shared/http/fs-server-response-factory.js +5 -33
- 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/collect-dev-prewarm-plan.d.ts +1 -3
- package/src/adapters/shared/runtime/collect-dev-prewarm-plan.js +1 -4
- 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/runtime-app-bootstrap.d.ts +0 -10
- package/src/adapters/shared/runtime/runtime-app-bootstrap.js +0 -7
- package/src/adapters/shared/runtime/runtime-host.d.ts +5 -2
- package/src/adapters/shared/runtime/runtime-server-lifecycle.d.ts +1 -1
- package/src/adapters/shared/runtime/runtime-server-lifecycle.js +1 -1
- package/src/adapters/shared/runtime/server-adapter.d.ts +27 -5
- package/src/adapters/shared/runtime/server-adapter.js +44 -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/adapters/shared/ws/node-http-websocket-upgrades.d.ts +9 -1
- package/src/adapters/shared/ws/node-http-websocket-upgrades.js +8 -2
- package/src/build/README.md +9 -6
- package/src/build/cache/cache-constants.d.ts +0 -2
- package/src/build/cache/cache-constants.js +0 -2
- package/src/build/cache/cache-keys.d.ts +0 -2
- package/src/build/cache/cache-keys.js +0 -2
- package/src/build/cache/output-imports.d.ts +27 -0
- package/src/build/cache/output-imports.js +80 -0
- package/src/build/cache/pages-unified-graph-build.d.ts +6 -1
- package/src/build/cache/pages-unified-graph-build.js +42 -17
- package/src/build/cache/production-build-cache.d.ts +2 -2
- package/src/build/cache/production-build-cache.js +2 -2
- package/src/build/cache/server-entry-build-cache.d.ts +25 -3
- package/src/build/cache/server-entry-build-cache.js +129 -13
- package/src/build/contracts/build-contracts.d.ts +1 -13
- 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 +41 -25
- package/src/build/rolldown/rolldown-plugin-bridge.js +25 -21
- package/src/build/rolldown/runtime-build-output-normalizer.js +3 -6
- package/src/build/runtime/build-request-identity.d.ts +2 -6
- package/src/build/runtime/build-request-identity.js +2 -8
- package/src/build/runtime/build-request-policy.js +1 -1
- package/src/build/runtime/deduping-build-executor.d.ts +0 -1
- package/src/build/runtime/deduping-build-executor.js +0 -1
- package/src/build/server-bundle-publication.d.ts +14 -0
- package/src/build/server-bundle-publication.js +49 -0
- package/src/cache/index.d.ts +1 -1
- package/src/cache/index.js +1 -1
- package/src/cache/module-parse-cache.d.ts +2 -29
- package/src/cache/module-parse-cache.js +6 -39
- package/src/config/README.md +17 -2
- package/src/config/apply-user-config.d.ts +8 -0
- package/src/config/apply-user-config.js +68 -0
- package/src/config/config-builder.d.ts +11 -1
- package/src/config/config-builder.js +53 -12
- package/src/config/constants.d.ts +4 -4
- package/src/config/constants.js +4 -4
- 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 +107 -0
- package/src/config/resolve-eco-config-path.d.ts +32 -0
- package/src/config/resolve-eco-config-path.js +58 -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 +170 -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/host-runtime.d.ts +0 -1
- package/src/dev/host-runtime.js +0 -3
- package/src/dev/sc-server.d.ts +4 -1
- package/src/dev/sc-server.js +11 -20
- package/src/dev/transform-server/dev-transform-import-rewriter.js +2 -2
- 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/hmr-file-change-prep.d.ts +0 -1
- package/src/hmr/hmr-file-change-prep.js +2 -5
- package/src/hmr/hmr-strategy.d.ts +3 -8
- package/src/hmr/hmr-strategy.js +3 -8
- 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 +2 -0
- package/src/index.browser.js +2 -0
- package/src/index.d.ts +5 -3
- package/src/index.js +5 -3
- package/src/islands/README.md +5 -1
- package/src/islands/island-host.d.ts +0 -9
- package/src/islands/island-host.js +1 -13
- package/src/plugins/README.md +8 -1
- 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 +120 -18
- package/src/plugins/integration-plugin.d.ts +0 -1
- package/src/plugins/integration-plugin.js +0 -4
- package/src/plugins/processor.d.ts +10 -2
- package/src/plugins/processor.js +4 -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 +15 -2
- 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 +3 -4
- 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 +9 -11
- package/src/route-renderer/orchestration/integration-renderer.js +43 -40
- package/src/route-renderer/orchestration/integration-renderer.test-fixtures.js +1 -1
- 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-session.d.ts +1 -1
- package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph-session.js +1 -1
- 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 +2 -1
- 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 +6 -1
- 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/assets/browser-bundle.service.d.ts +1 -6
- package/src/services/error-pages/README.md +9 -0
- package/src/services/error-pages/default-error-pages.d.ts +39 -0
- package/src/services/error-pages/default-error-pages.js +199 -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/html/html-rewriter.d.ts +77 -0
- package/src/services/html/html-rewriter.js +751 -0
- package/src/services/html/html-rewriter.parity.test.bun.d.ts +1 -0
- package/src/services/html/html-rewriter.parity.test.bun.js +74 -0
- package/src/services/html/html-transformer.service.d.ts +26 -39
- package/src/services/html/html-transformer.service.js +81 -153
- package/src/services/invalidation/development-invalidation.service.d.ts +9 -20
- package/src/services/invalidation/development-invalidation.service.js +35 -41
- package/src/services/module-loading/README.md +17 -14
- package/src/services/module-loading/app-module-loader.service.d.ts +0 -2
- package/src/services/module-loading/app-server-module-transpiler.service.d.ts +1 -1
- package/src/services/module-loading/app-server-module-transpiler.service.js +2 -10
- package/src/services/module-loading/collection-server-module-build.service.d.ts +1 -1
- package/src/services/module-loading/collection-server-module-build.service.js +5 -5
- package/src/services/module-loading/host-module-loader-registry.d.ts +0 -1
- package/src/services/module-loading/host-module-loader-registry.js +0 -3
- 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-build-cache-registry.d.ts +0 -4
- package/src/services/module-loading/route-module-build-cache-registry.js +0 -4
- package/src/services/module-loading/route-module-build-cache.store.d.ts +3 -0
- package/src/services/module-loading/route-module-build-cache.store.js +18 -5
- package/src/services/module-loading/route-module-build-manifest.d.ts +6 -1
- package/src/services/module-loading/route-module-build-manifest.js +1 -2
- package/src/services/module-loading/route-module-dependency-hasher.d.ts +3 -2
- package/src/services/module-loading/route-module-dependency-hasher.js +13 -1
- package/src/services/module-loading/server-module-transpiler.service.d.ts +1 -15
- package/src/services/module-loading/server-module-transpiler.service.js +0 -24
- 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/runtime-state/entrypoint-dependency-graph.service.js +0 -12
- package/src/services/runtime-state/server-invalidation-state.service.d.ts +4 -2
- package/src/services/runtime-state/server-invalidation-state.service.js +7 -14
- 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 -39
- package/src/types/public-types.d.ts +29 -131
- package/src/utils/parse-cli-args.js +29 -22
- package/src/watchers/project-watcher.d.ts +14 -16
- package/src/watchers/project-watcher.js +86 -61
- package/src/watchers/project-watcher.test-helpers.d.ts +10 -1
- package/src/watchers/project-watcher.test-helpers.js +12 -0
- package/src/adapters/abstract/router-adapter.d.ts +0 -26
- package/src/adapters/abstract/router-adapter.js +0 -13
- package/src/adapters/bun/index.d.ts +0 -2
- package/src/adapters/bun/index.js +0 -2
- package/src/adapters/index.d.ts +0 -2
- package/src/adapters/index.js +0 -2
- package/src/eco/eco.utils.d.ts +0 -1
- package/src/eco/eco.utils.js +0 -1
- package/src/services/cache/index.d.ts +0 -9
- package/src/services/cache/index.js +0 -8
- package/src/services/html/html-rewriter-provider.service.d.ts +0 -40
- package/src/services/html/html-rewriter-provider.service.js +0 -68
- package/src/services/module-loading/route-module-build-cache.d.ts +0 -4
- package/src/services/module-loading/route-module-build-cache.js +0 -3
- package/src/services/runtime-state/dev-graph.service.d.ts +0 -118
- package/src/services/runtime-state/dev-graph.service.js +0 -170
- /package/src/{adapters/shared/http/explicit-static-render-preparation.js → route-renderer/explicit-view-render-preparation.js} +0 -0
|
@@ -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
|
@@ -22,12 +22,17 @@ Typical responsibilities include:
|
|
|
22
22
|
- `invalidation/`: file-change classification and invalidation policy
|
|
23
23
|
- `runtime-state/`: app-owned invalidation state and dependency graphs
|
|
24
24
|
- `runtime-manifest/`: node runtime manifest derivation and persistence
|
|
25
|
-
- `html/`: final HTML dependency injection and rewriter
|
|
25
|
+
- `html/`: final HTML dependency injection and attribute stamping through `HtmlRewriter`, an in-house streaming rewriter with a subset of Bun's `HTMLRewriter` API that matches lol-html output (tag-name selectors; `before`/`prepend`/`append`/`after`; attributes). It runs the same way on Bun and Node, and `html-rewriter.parity.test.bun.ts` checks it against the native rewriter.
|
|
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) {
|
|
@@ -22,7 +22,6 @@ import type { EcoPagesAppConfig } from '../../types/internal-types.js';
|
|
|
22
22
|
export type BrowserBundleOptions = {
|
|
23
23
|
entrypoints: string[] | Record<string, string>;
|
|
24
24
|
outdir?: string;
|
|
25
|
-
outbase?: string;
|
|
26
25
|
naming?: string;
|
|
27
26
|
conditions?: string[];
|
|
28
27
|
define?: Record<string, string>;
|
|
@@ -30,7 +29,6 @@ export type BrowserBundleOptions = {
|
|
|
30
29
|
treeshaking?: boolean;
|
|
31
30
|
splitting?: boolean;
|
|
32
31
|
root?: string;
|
|
33
|
-
bundle?: boolean;
|
|
34
32
|
externalPackages?: boolean;
|
|
35
33
|
external?: string[];
|
|
36
34
|
plugins?: EcoBuildPlugin[];
|
|
@@ -39,9 +37,6 @@ export type BrowserBundleOptions = {
|
|
|
39
37
|
excludeAppBuildPlugins?: string[];
|
|
40
38
|
};
|
|
41
39
|
type BrowserBundleGroupedOptions = Omit<BrowserBundleOptions, 'entrypoints'>;
|
|
42
|
-
export interface BrowserBundleExecutor {
|
|
43
|
-
bundle(options: BrowserBundleOptions): Promise<BuildResult>;
|
|
44
|
-
}
|
|
45
40
|
export type BrowserBundleGroupedEntry = {
|
|
46
41
|
entrypoint: string;
|
|
47
42
|
entryName: string;
|
|
@@ -54,7 +49,7 @@ export type BrowserBundleGroupedEntry = {
|
|
|
54
49
|
* the app-owned executor rather than direct backend calls. Assembles a complete
|
|
55
50
|
* request via {@link createBrowserBuildRequest} before scheduling.
|
|
56
51
|
*/
|
|
57
|
-
export declare class BrowserBundleService
|
|
52
|
+
export declare class BrowserBundleService {
|
|
58
53
|
private readonly appConfig;
|
|
59
54
|
constructor(appConfig: EcoPagesAppConfig);
|
|
60
55
|
/**
|
|
@@ -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.
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/** Stable class hooks exposed by the framework-owned error documents. */
|
|
2
|
+
export declare const DEFAULT_ERROR_PAGE_CLASS_NAMES: {
|
|
3
|
+
readonly root: "eco-error-page";
|
|
4
|
+
readonly notFoundModifier: "eco-error-page--not-found";
|
|
5
|
+
readonly serverErrorModifier: "eco-error-page--server-error";
|
|
6
|
+
readonly badRequestModifier: "eco-error-page--bad-request";
|
|
7
|
+
readonly unauthorizedModifier: "eco-error-page--unauthorized";
|
|
8
|
+
readonly forbiddenModifier: "eco-error-page--forbidden";
|
|
9
|
+
readonly conflictModifier: "eco-error-page--conflict";
|
|
10
|
+
readonly content: "eco-error-page__content";
|
|
11
|
+
readonly status: "eco-error-page__status";
|
|
12
|
+
readonly title: "eco-error-page__title";
|
|
13
|
+
readonly message: "eco-error-page__message";
|
|
14
|
+
readonly diagnostics: "eco-error-page__diagnostics";
|
|
15
|
+
readonly diagnosticsHeader: "eco-error-page__diagnostics-header";
|
|
16
|
+
readonly diagnosticsLabel: "eco-error-page__diagnostics-label";
|
|
17
|
+
readonly stack: "eco-error-page__stack";
|
|
18
|
+
readonly copyButton: "eco-error-page__copy";
|
|
19
|
+
readonly copyButtonCopied: "eco-error-page__copy--copied";
|
|
20
|
+
readonly copyButtonFailed: "eco-error-page__copy--failed";
|
|
21
|
+
readonly copyIcon: "eco-error-page__copy-icon";
|
|
22
|
+
readonly copyIconClipboard: "eco-error-page__copy-icon--clipboard";
|
|
23
|
+
readonly copyIconSuccess: "eco-error-page__copy-icon--success";
|
|
24
|
+
readonly copyLabel: "eco-error-page__copy-label";
|
|
25
|
+
};
|
|
26
|
+
export type DefaultErrorPageDetails = {
|
|
27
|
+
message?: string;
|
|
28
|
+
stack?: string;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Self-contained HTML for a framework default error response.
|
|
32
|
+
*
|
|
33
|
+
* @remarks
|
|
34
|
+
* Development 5xx pages may include escaped `message` / `stack` and a copy
|
|
35
|
+
* button. 4xx pages never serialize a stack.
|
|
36
|
+
*/
|
|
37
|
+
export declare function buildDefaultErrorHtml(status: number, details?: DefaultErrorPageDetails): string;
|
|
38
|
+
export declare function getDefaultServerErrorDetails(error: unknown): DefaultErrorPageDetails | undefined;
|
|
39
|
+
export declare function getPublicErrorMessage(error: unknown): string | undefined;
|