@ecopages/core 0.2.1-beta.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +176 -101
- package/package.json +74 -205
- package/src/adapters/README.md +25 -6
- package/src/adapters/create-app.d.ts +56 -19
- package/src/adapters/create-app.js +48 -63
- package/src/adapters/node/create-app.d.ts +198 -19
- package/src/adapters/node/create-app.js +582 -89
- package/src/adapters/node/dev-session.d.ts +35 -0
- package/src/adapters/node/dev-session.js +117 -0
- package/src/adapters/node/http-request-bridge.d.ts +2 -2
- package/src/adapters/node/http-request-bridge.js +187 -106
- package/src/adapters/node/node-client-bridge.d.ts +2 -1
- package/src/adapters/node/node-client-bridge.js +62 -61
- package/src/adapters/node/runtime-host.d.ts +11 -11
- package/src/adapters/node/runtime-host.js +101 -89
- package/src/adapters/node/server-adapter.d.ts +124 -71
- package/src/adapters/node/server-adapter.js +411 -297
- package/src/adapters/shared/hmr/dev-transform-entrypoint-registry.d.ts +16 -0
- package/src/adapters/shared/hmr/dev-transform-entrypoint-registry.js +32 -0
- package/src/adapters/shared/hmr/hmr-html-response.d.ts +14 -0
- package/src/adapters/shared/hmr/hmr-html-response.js +25 -0
- package/src/adapters/shared/hmr/hmr-manager.d.ts +116 -0
- package/src/adapters/shared/hmr/hmr-manager.js +464 -0
- package/src/adapters/shared/hmr/hmr-manager.test-helpers.d.ts +28 -0
- package/src/adapters/shared/hmr/hmr-manager.test-helpers.js +53 -0
- package/src/adapters/shared/http/api-request-pipeline.d.ts +50 -0
- package/src/adapters/shared/http/api-request-pipeline.js +204 -0
- package/src/adapters/shared/{api-response.d.ts → http/api-response.d.ts} +3 -2
- package/src/adapters/shared/http/api-response.js +79 -0
- package/src/adapters/shared/http/create-body-response.d.ts +12 -0
- package/src/adapters/shared/http/create-body-response.js +26 -0
- package/src/adapters/shared/http/define-api-handler.d.ts +48 -0
- package/src/adapters/shared/http/define-api-handler.js +49 -0
- package/src/adapters/shared/{explicit-static-route-matcher.d.ts → http/explicit-static-route-matcher.d.ts} +5 -10
- package/src/adapters/shared/http/explicit-static-route-matcher.js +63 -0
- package/src/adapters/shared/{file-route-middleware-pipeline.d.ts → http/file-route-middleware-pipeline.d.ts} +2 -2
- package/src/adapters/shared/http/file-route-middleware-pipeline.js +84 -0
- package/src/adapters/shared/http/fs-server-response-factory.d.ts +9 -0
- package/src/adapters/shared/http/fs-server-response-factory.js +23 -0
- package/src/adapters/shared/{fs-server-response-matcher.d.ts → http/fs-server-response-matcher.d.ts} +35 -12
- package/src/adapters/shared/http/fs-server-response-matcher.js +244 -0
- package/src/adapters/shared/http/run-middleware-chain.d.ts +5 -0
- package/src/adapters/shared/http/run-middleware-chain.js +17 -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/copy-runtime-public-dir.d.ts +8 -0
- package/src/adapters/shared/runtime/copy-runtime-public-dir.js +71 -0
- package/src/adapters/shared/runtime/dev-static-route-prewarm.d.ts +13 -0
- package/src/adapters/shared/runtime/dev-static-route-prewarm.js +56 -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 +116 -0
- package/src/adapters/shared/runtime/port-manager.js +195 -0
- package/src/adapters/shared/{render-context.d.ts → runtime/render-context.d.ts} +3 -3
- package/src/adapters/shared/runtime/render-context.js +94 -0
- package/src/adapters/shared/runtime/runtime-app-bootstrap.d.ts +17 -0
- package/src/adapters/shared/runtime/runtime-app-bootstrap.js +34 -0
- package/src/adapters/shared/{runtime-host.d.ts → runtime/runtime-host.d.ts} +5 -2
- package/src/adapters/shared/runtime/runtime-server-lifecycle.d.ts +45 -0
- package/src/adapters/shared/runtime/runtime-server-lifecycle.js +93 -0
- package/src/adapters/shared/runtime/server-request-pipeline.d.ts +100 -0
- package/src/adapters/shared/runtime/server-request-pipeline.js +276 -0
- package/src/adapters/shared/{server-route-handler.d.ts → runtime/server-route-handler.d.ts} +9 -38
- package/src/adapters/shared/runtime/server-route-handler.js +95 -0
- package/src/adapters/shared/runtime/server-static-builder.d.ts +107 -0
- package/src/adapters/shared/runtime/server-static-builder.js +172 -0
- package/src/adapters/shared/ws/node-http-websocket-upgrades.d.ts +20 -0
- package/src/adapters/shared/ws/node-http-websocket-upgrades.js +122 -0
- package/src/adapters/shared/ws/websocket-lifecycle.d.ts +24 -0
- package/src/adapters/shared/ws/websocket-lifecycle.js +62 -0
- package/src/adapters/shared/ws/ws-pattern-matcher.d.ts +7 -0
- package/src/adapters/shared/ws/ws-pattern-matcher.js +20 -0
- package/src/assets/README.md +35 -0
- package/src/assets/app-browser-client-build.d.ts +18 -0
- package/src/assets/app-browser-client-build.js +476 -0
- package/src/assets/app-browser-client-manifest.d.ts +69 -0
- package/src/assets/app-browser-client-manifest.js +332 -0
- package/src/assets/asset-processing-service/app-browser-client-bundle.d.ts +35 -0
- package/src/assets/asset-processing-service/app-browser-client-bundle.js +41 -0
- package/src/assets/asset-processing-service/asset-dependency-keys.d.ts +16 -0
- package/src/assets/asset-processing-service/asset-dependency-keys.js +80 -0
- package/src/assets/asset-processing-service/asset-package-role.d.ts +2 -0
- package/src/assets/asset-processing-service/asset-package-role.js +3 -0
- package/src/assets/asset-processing-service/asset-processing-integration.d.ts +7 -0
- package/src/assets/asset-processing-service/asset-processing-integration.js +6 -0
- package/src/assets/asset-processing-service/asset-processing.service.d.ts +156 -0
- package/src/assets/asset-processing-service/asset-processing.service.js +555 -0
- package/src/assets/asset-processing-service/asset.factory.js +79 -0
- package/src/assets/asset-processing-service/assets.types.d.ts +1 -0
- package/src/{services/assets → assets}/asset-processing-service/browser-runtime-asset.factory.d.ts +2 -1
- package/src/assets/asset-processing-service/browser-runtime-asset.factory.js +61 -0
- package/src/assets/asset-processing-service/browser-runtime-entry-resolution.d.ts +79 -0
- package/src/assets/asset-processing-service/browser-runtime-entry-resolution.js +200 -0
- package/src/{services/assets → assets}/asset-processing-service/browser-runtime-entry.factory.d.ts +6 -2
- package/src/assets/asset-processing-service/browser-runtime-entry.factory.js +67 -0
- package/src/assets/asset-processing-service/finalize-processed-asset.d.ts +3 -0
- package/src/assets/asset-processing-service/finalize-processed-asset.js +5 -0
- package/src/assets/asset-processing-service/grouped-content-bundles.d.ts +11 -0
- package/src/assets/asset-processing-service/grouped-content-bundles.js +39 -0
- package/src/assets/asset-processing-service/index.d.ts +10 -0
- package/src/{services/assets/asset-processing-service/index.d.ts → assets/asset-processing-service/index.js} +3 -0
- package/src/assets/asset-processing-service/inline-content-script-body.d.ts +11 -0
- package/src/assets/asset-processing-service/inline-content-script-body.js +23 -0
- package/src/assets/asset-processing-service/materialize-content-script-asset.d.ts +9 -0
- package/src/assets/asset-processing-service/materialize-content-script-asset.js +22 -0
- package/src/{services/assets → assets}/asset-processing-service/page-package.d.ts +2 -2
- package/src/assets/asset-processing-service/page-package.js +81 -0
- package/src/assets/asset-processing-service/processor.interface.d.ts +8 -0
- package/src/assets/asset-processing-service/processor.interface.js +1 -0
- package/src/assets/asset-processing-service/processors/base/base-processor.d.ts +13 -0
- package/src/assets/asset-processing-service/processors/base/base-processor.js +22 -0
- package/src/assets/asset-processing-service/processors/base/base-script-processor.d.ts +40 -0
- package/src/assets/asset-processing-service/processors/base/base-script-processor.js +136 -0
- package/src/assets/asset-processing-service/processors/index.js +5 -0
- package/src/assets/asset-processing-service/processors/script/classic-script-compiler.d.ts +26 -0
- package/src/assets/asset-processing-service/processors/script/classic-script-compiler.js +92 -0
- package/src/assets/asset-processing-service/processors/script/content-script.processor.d.ts +21 -0
- package/src/assets/asset-processing-service/processors/script/content-script.processor.js +88 -0
- package/src/assets/asset-processing-service/processors/script/file-script.processor.d.ts +43 -0
- package/src/assets/asset-processing-service/processors/script/file-script.processor.js +165 -0
- package/src/{services/assets → assets}/asset-processing-service/processors/script/node-module-script.processor.d.ts +23 -1
- package/src/assets/asset-processing-service/processors/script/node-module-script.processor.js +135 -0
- package/src/{services/assets → assets}/asset-processing-service/processors/stylesheet/content-stylesheet.processor.d.ts +0 -3
- package/src/assets/asset-processing-service/processors/stylesheet/content-stylesheet.processor.js +36 -0
- package/src/{services/assets → assets}/asset-processing-service/processors/stylesheet/file-stylesheet.processor.d.ts +0 -3
- package/src/assets/asset-processing-service/processors/stylesheet/file-stylesheet.processor.js +40 -0
- package/src/assets/asset-processing-service/processors/stylesheet/stylesheet-processor-pipeline.d.ts +2 -0
- package/src/assets/asset-processing-service/processors/stylesheet/stylesheet-processor-pipeline.js +19 -0
- package/src/assets/browser-bundle.service.d.ts +45 -0
- package/src/assets/browser-bundle.service.js +50 -0
- package/src/assets/browser-runtime-asset-page-cache.d.ts +11 -0
- package/src/assets/browser-runtime-asset-page-cache.js +17 -0
- package/src/assets/hashed-browser-asset.d.ts +25 -0
- package/src/assets/hashed-browser-asset.js +99 -0
- package/src/{route-renderer/orchestration → assets}/processed-asset-dedupe.d.ts +1 -1
- package/src/assets/processed-asset-dedupe.js +24 -0
- package/src/browser-env.d.ts +4 -0
- package/src/browser-env.js +11 -0
- package/src/build/README.md +251 -44
- package/src/build/app-build-manifest-runtime.d.ts +38 -0
- package/src/build/app-build-manifest-runtime.js +126 -0
- package/src/build/{browser-runtime-manifest.d.ts → browser/browser-runtime-manifest.d.ts} +4 -0
- package/src/build/browser/browser-runtime-manifest.js +65 -0
- package/src/build/browser/browser-runtime-plugin-helpers.d.ts +14 -0
- package/src/build/browser/browser-runtime-plugin-helpers.js +21 -0
- package/src/build/browser/browser-runtime-plugin.d.ts +54 -0
- package/src/build/browser/browser-runtime-plugin.js +76 -0
- package/src/build/browser/jsx-ownership-plugins.d.ts +24 -0
- package/src/build/browser/jsx-ownership-plugins.js +55 -0
- package/src/build/browser/lit-static-render-worker-context.d.ts +1 -0
- package/src/build/browser/lit-static-render-worker-context.js +5 -0
- package/src/build/build-adapter.d.ts +16 -490
- package/src/build/build-adapter.js +39 -243
- package/src/build/build-graph.d.ts +34 -0
- package/src/build/build-graph.js +162 -0
- package/src/build/build-log.d.ts +19 -0
- package/src/build/build-log.js +35 -0
- package/src/build/build-parallelism.d.ts +4 -0
- package/src/build/build-parallelism.js +7 -0
- package/src/build/cache/app-config-hash.d.ts +10 -0
- package/src/build/cache/app-config-hash.js +22 -0
- package/src/build/cache/build-input-dependency-index.d.ts +118 -0
- package/src/build/cache/build-input-dependency-index.js +249 -0
- package/src/build/cache/cache-keys.d.ts +9 -0
- package/src/build/cache/cache-keys.js +31 -0
- package/src/build/cache/pages-unified-graph-build.d.ts +54 -0
- package/src/build/cache/pages-unified-graph-build.js +197 -0
- package/src/build/contracts/build-contracts.d.ts +157 -0
- package/src/build/contracts/build-contracts.js +1 -0
- package/src/build/contracts/build-manifest.d.ts +29 -0
- package/src/build/contracts/build-manifest.js +52 -0
- package/src/build/contracts/build-types.d.ts +1 -0
- package/src/build/contracts/build-types.js +1 -0
- package/src/build/contracts/content-virtual-modules.d.ts +14 -0
- package/src/build/contracts/content-virtual-modules.js +37 -0
- package/src/build/contracts/server-only-specifier.d.ts +8 -0
- package/src/build/contracts/server-only-specifier.js +11 -0
- package/src/build/contracts.d.ts +4 -0
- package/src/build/contracts.js +2 -0
- package/src/build/mapped-source-transform.d.ts +22 -0
- package/src/build/mapped-source-transform.js +31 -0
- package/src/build/preserve-import-meta-transform.d.ts +32 -0
- package/src/build/preserve-import-meta-transform.js +138 -0
- package/src/build/rolldown/app-package-declarations.d.ts +8 -0
- package/src/build/rolldown/app-package-declarations.js +81 -0
- package/src/build/rolldown/entry-module-closures.d.ts +8 -0
- package/src/build/rolldown/entry-module-closures.js +39 -0
- package/src/build/rolldown/rolldown-adapter-helpers.d.ts +97 -0
- package/src/build/rolldown/rolldown-adapter-helpers.js +570 -0
- package/src/build/rolldown/rolldown-build-adapter.d.ts +27 -0
- package/src/build/rolldown/rolldown-build-adapter.js +86 -0
- package/src/build/rolldown/rolldown-build-invocation-metrics.d.ts +12 -0
- package/src/build/rolldown/rolldown-build-invocation-metrics.js +40 -0
- package/src/build/rolldown/rolldown-plugin-bridge.d.ts +76 -0
- package/src/build/rolldown/rolldown-plugin-bridge.js +450 -0
- package/src/build/{server-side-css-shim-plugin.d.ts → rolldown/server-side-css-shim-plugin.d.ts} +2 -15
- package/src/build/rolldown/server-side-css-shim-plugin.js +59 -0
- package/src/build/runtime/build-environment-options.d.ts +4 -0
- package/src/build/runtime/build-environment-options.js +20 -0
- package/src/build/runtime/build-queue.d.ts +63 -0
- package/src/build/runtime/build-queue.js +117 -0
- package/src/build/runtime/build-request-identity.d.ts +15 -0
- package/src/build/runtime/build-request-identity.js +52 -0
- package/src/build/runtime/build-request-policy.d.ts +80 -0
- package/src/build/runtime/build-request-policy.js +132 -0
- package/src/build/server/README.md +50 -0
- package/src/build/server/app-module-loader.service.d.ts +35 -0
- package/src/build/server/app-module-loader.service.js +36 -0
- package/src/{services/module-loading → build/server}/page-module-import.service.d.ts +37 -20
- package/src/build/server/page-module-import.service.js +264 -0
- package/src/build/server/route-module-build-cache-registry.d.ts +20 -0
- package/src/build/server/route-module-build-cache-registry.js +41 -0
- package/src/build/server/route-module-build-cache.store.d.ts +49 -0
- package/src/build/server/route-module-build-cache.store.js +75 -0
- package/src/build/server/route-module-build-manifest.d.ts +56 -0
- package/src/build/server/route-module-build-manifest.js +49 -0
- package/src/build/server/route-module-dependency-hasher.d.ts +66 -0
- package/src/build/server/route-module-dependency-hasher.js +131 -0
- package/src/build/server/view-module-loader.d.ts +10 -0
- package/src/build/server/view-module-loader.js +46 -0
- package/src/build/server-bundle-deploy-manifest.d.ts +71 -0
- package/src/build/server-bundle-deploy-manifest.js +164 -0
- package/src/build/server-bundle-publication.d.ts +12 -0
- package/src/build/server-bundle-publication.js +39 -0
- package/src/build/server-module.d.ts +8 -0
- package/src/build/server-module.js +22 -0
- package/src/build/source-maps.d.ts +17 -0
- package/src/build/source-maps.js +29 -0
- package/src/build.d.ts +19 -0
- package/src/build.js +19 -0
- package/src/cache/README.md +5 -0
- package/src/cache/index.d.ts +3 -2
- package/src/cache/index.js +7 -6
- package/src/cache/module-parse-cache.d.ts +4 -26
- package/src/cache/module-parse-cache.js +90 -68
- package/src/cache/module-transform-profiler.d.ts +7 -0
- package/src/cache/module-transform-profiler.js +8 -0
- package/src/client/README.md +5 -0
- package/src/client/navigation-attributes.d.ts +2 -0
- package/src/client/navigation-attributes.js +2 -0
- package/src/client/navigation-scripts/activation.d.ts +36 -0
- package/src/client/navigation-scripts/activation.js +97 -0
- package/src/client/navigation-scripts/classification.d.ts +12 -0
- package/src/client/navigation-scripts/classification.js +49 -0
- package/src/client/navigation-scripts/identity.d.ts +19 -0
- package/src/client/navigation-scripts/identity.js +26 -0
- package/src/client/navigation-scripts/index.d.ts +4 -0
- package/src/client/navigation-scripts/index.js +4 -0
- package/src/client/navigation-scripts/navigation-scripts.test.browser.d.ts +1 -0
- package/src/client/navigation-scripts/navigation-scripts.test.browser.js +111 -0
- package/src/client/navigation-scripts/registry.d.ts +12 -0
- package/src/client/navigation-scripts/registry.js +17 -0
- package/src/client/navigation-scripts/rerun-queue.d.ts +30 -0
- package/src/client/navigation-scripts/rerun-queue.js +84 -0
- package/src/client/scroll.d.ts +17 -0
- package/src/client/scroll.js +33 -0
- package/src/client/scroll.test.browser.d.ts +1 -0
- package/src/client/scroll.test.browser.js +31 -0
- package/src/client/view-transitions.d.ts +28 -0
- package/src/client/view-transitions.js +121 -0
- package/src/client/view-transitions.test.browser.d.ts +1 -0
- package/src/client/view-transitions.test.browser.js +53 -0
- package/src/client.d.ts +15 -0
- package/src/client.js +15 -0
- package/src/config/README.md +34 -12
- package/src/config/assembly/app-runtime.d.ts +73 -0
- package/src/config/assembly/app-runtime.js +82 -0
- package/src/config/assembly/finalize-config.d.ts +26 -0
- package/src/config/assembly/finalize-config.js +243 -0
- package/src/config/config-module-files.d.ts +11 -0
- package/src/config/config-module-files.js +70 -0
- package/src/config/constants.d.ts +1 -45
- package/src/config/constants.js +1 -25
- package/src/config/define-config.d.ts +11 -0
- package/src/config/define-config.js +3 -0
- package/src/config/index.d.ts +6 -0
- package/src/config/index.js +5 -0
- package/src/config/internal-types.d.ts +187 -0
- package/src/config/internal-types.js +1 -0
- package/src/config/load-eco-config.d.ts +15 -0
- package/src/config/load-eco-config.js +72 -0
- package/src/config/resolve-eco-config-path.d.ts +38 -0
- package/src/config/resolve-eco-config-path.js +70 -0
- package/src/config/server-config-bundle.d.ts +14 -0
- package/src/config/server-config-bundle.js +36 -0
- package/src/config/user-config-types.d.ts +156 -0
- package/src/config/user-config-types.js +1 -0
- package/src/config/write-types.d.ts +1 -0
- package/src/config/write-types.js +18 -0
- package/src/constants.d.ts +46 -0
- package/src/constants.js +46 -0
- package/src/css-imports.d.ts +4 -0
- package/src/declarations.d.ts +13 -6
- package/src/dev/README.md +61 -0
- package/src/dev/development-restart-watch-paths.d.ts +13 -0
- package/src/dev/development-restart-watch-paths.js +44 -0
- package/src/dev/development-restart.d.ts +25 -0
- package/src/dev/development-restart.js +45 -0
- package/src/dev/invalidation/README.md +11 -0
- package/src/dev/invalidation/development-invalidation.service.d.ts +153 -0
- package/src/dev/invalidation/development-invalidation.service.js +338 -0
- package/src/dev/runtime-server-started-message.d.ts +10 -0
- package/src/dev/runtime-server-started-message.js +14 -0
- package/src/dev/transform-server/dev-transform-bundler.d.ts +26 -0
- package/src/dev/transform-server/dev-transform-bundler.js +77 -0
- package/src/dev/transform-server/dev-transform-externalize-plugin.d.ts +12 -0
- package/src/dev/transform-server/dev-transform-externalize-plugin.js +29 -0
- package/src/dev/transform-server/dev-transform-import-rewriter.d.ts +17 -0
- package/src/dev/transform-server/dev-transform-import-rewriter.js +128 -0
- package/src/dev/transform-server/dev-transform-module-kind.d.ts +13 -0
- package/src/dev/transform-server/dev-transform-module-kind.js +17 -0
- package/src/dev/transform-server/dev-transform-runtime-specifiers.d.ts +5 -0
- package/src/dev/transform-server/dev-transform-runtime-specifiers.js +16 -0
- package/src/dev/transform-server/dev-transform-server.d.ts +61 -0
- package/src/dev/transform-server/dev-transform-server.js +234 -0
- package/src/dev/transform-server/dev-transform-url.d.ts +18 -0
- package/src/dev/transform-server/dev-transform-url.js +88 -0
- package/src/dev/transform-server/dev-transform-vendor-registry.d.ts +28 -0
- package/src/dev/transform-server/dev-transform-vendor-registry.js +148 -0
- package/src/dev/transform-server/index.d.ts +6 -0
- package/src/dev/transform-server/index.js +4 -0
- package/src/dev/transform-server/types.d.ts +1 -0
- package/src/dev/transform-server/types.js +1 -0
- package/src/dev-toolbar/README.md +66 -0
- package/src/dev-toolbar/build-error-contract.d.ts +12 -0
- package/src/dev-toolbar/build-error-contract.js +3 -0
- package/src/dev-toolbar/define-dev-tool.d.ts +21 -0
- package/src/dev-toolbar/define-dev-tool.js +9 -0
- package/src/dev-toolbar/dev-toolbar-config.d.ts +24 -0
- package/src/dev-toolbar/dev-toolbar-config.js +17 -0
- package/src/dev-toolbar/dev-toolbar-manifest-contract.d.ts +22 -0
- package/src/dev-toolbar/dev-toolbar-manifest-contract.js +2 -0
- package/src/dev-toolbar/dev-toolbar-manifest.d.ts +27 -0
- package/src/dev-toolbar/dev-toolbar-manifest.js +65 -0
- package/src/dev-toolbar/dev-toolbar-package.d.ts +34 -0
- package/src/dev-toolbar/dev-toolbar-package.js +78 -0
- package/src/dev-toolbar/dev-toolbar-runtime-paths.d.ts +8 -0
- package/src/dev-toolbar/dev-toolbar-runtime-paths.js +11 -0
- package/src/dev-toolbar/dev-toolbar-runtime.d.ts +10 -0
- package/src/dev-toolbar/dev-toolbar-runtime.js +26 -0
- package/src/diagnostics/README.md +11 -0
- package/src/diagnostics/request-pipeline-metrics.d.ts +48 -0
- package/src/diagnostics/request-pipeline-metrics.js +113 -0
- package/src/diagnostics/startup-trace.d.ts +71 -0
- package/src/diagnostics/startup-trace.js +247 -0
- package/src/eco/README.md +108 -22
- package/src/eco/component-identity.d.ts +17 -0
- package/src/eco/component-identity.js +25 -0
- package/src/eco/component-internal-state.d.ts +5 -0
- package/src/eco/component-internal-state.js +17 -0
- package/src/eco/component-render-context.d.ts +60 -0
- package/src/eco/component-render-context.js +140 -0
- package/src/{route-renderer/orchestration/render-output.utils.d.ts → eco/component-render-output.d.ts} +7 -19
- package/src/eco/component-render-output.js +123 -0
- package/src/eco/discovered-dependencies.d.ts +45 -0
- package/src/eco/discovered-dependencies.js +87 -0
- package/src/eco/eco-declared-component.d.ts +15 -0
- package/src/eco/eco-declared-component.js +23 -0
- package/src/eco/eco.browser.d.ts +1 -1
- package/src/eco/eco.browser.js +63 -70
- package/src/eco/eco.d.ts +1 -1
- package/src/eco/eco.js +169 -97
- package/src/eco/global-injector-map.d.ts +1 -1
- package/src/eco/global-injector-map.js +55 -41
- package/src/eco/module-dependencies.js +52 -44
- package/src/eco/page-dependency-contributions.d.ts +19 -0
- package/src/eco/page-dependency-contributions.js +52 -0
- package/src/eco/page-layout-normalization.d.ts +21 -0
- package/src/eco/page-layout-normalization.js +69 -0
- package/src/env.d.ts +31 -7
- package/src/env.js +38 -0
- package/src/errors/README.md +5 -0
- package/src/errors/http-error-page-contract.d.ts +77 -0
- package/src/errors/http-error-page-contract.js +106 -0
- package/src/errors/http-error.d.ts +8 -0
- package/src/errors/http-error.js +66 -49
- package/src/errors/index.d.ts +1 -0
- package/src/errors/index.js +3 -6
- package/src/errors/locals-access-error.js +5 -8
- package/src/errors/undeclared-component-dependency-error.d.ts +11 -0
- package/src/errors/undeclared-component-dependency-error.js +17 -0
- package/src/global/README.md +5 -0
- package/src/global/app-logger.js +4 -6
- package/src/hmr/README.md +38 -0
- package/src/hmr/client/build-error-overlay.d.ts +17 -0
- package/src/hmr/client/build-error-overlay.js +79 -0
- package/src/hmr/client/build-error-overlay.test.browser.d.ts +1 -0
- package/src/hmr/client/build-error-overlay.test.browser.js +48 -0
- package/src/hmr/client/build-error-presentation.d.ts +2 -0
- package/src/hmr/client/build-error-presentation.js +30 -0
- package/src/hmr/client/hmr-runtime.js +122 -109
- package/src/hmr/client/hmr-runtime.test.browser.d.ts +1 -0
- package/src/hmr/client/hmr-runtime.test.browser.js +32 -0
- package/src/hmr/client/module-update.d.ts +13 -0
- package/src/hmr/client/module-update.js +39 -0
- package/src/hmr/dev-client-runtime.d.ts +39 -0
- package/src/hmr/dev-client-runtime.js +78 -0
- package/src/hmr/entrypoint-dependency-graph.d.ts +12 -0
- package/src/hmr/entrypoint-dependency-graph.js +27 -0
- package/src/hmr/hmr-asset-paths.d.ts +14 -0
- package/src/hmr/hmr-asset-paths.js +22 -0
- package/src/hmr/hmr-entrypoint-output.d.ts +11 -0
- package/src/hmr/hmr-entrypoint-output.js +34 -0
- package/src/hmr/hmr-file-change-prep.d.ts +9 -0
- package/src/hmr/hmr-file-change-prep.js +11 -0
- package/src/hmr/hmr-registered-entrypoints-context.d.ts +7 -0
- package/src/hmr/hmr-registered-entrypoints-context.js +1 -0
- package/src/hmr/hmr-runtime-paths.d.ts +10 -0
- package/src/hmr/hmr-runtime-paths.js +13 -0
- package/src/hmr/hmr-strategy.d.ts +18 -22
- package/src/hmr/hmr-strategy.js +111 -42
- package/src/hmr/strategies/default-hmr-strategy.js +55 -33
- package/src/hmr/strategies/js-hmr-strategy.d.ts +16 -97
- package/src/hmr/strategies/js-hmr-strategy.js +113 -165
- package/src/hmr/strategies/server-rendered-template-hmr-strategy.d.ts +17 -0
- package/src/hmr/strategies/server-rendered-template-hmr-strategy.js +35 -0
- package/src/html/README.md +15 -0
- package/src/html/html-rewriter.d.ts +77 -0
- package/src/html/html-rewriter.js +590 -0
- package/src/html/html-source-parser.d.ts +59 -0
- package/src/html/html-source-parser.js +203 -0
- package/src/html/html-tokenizer.d.ts +69 -0
- package/src/html/html-tokenizer.js +193 -0
- package/src/html/html-transformer.service.d.ts +74 -0
- package/src/html/html-transformer.service.js +173 -0
- package/src/html-pages/README.md +104 -0
- package/src/html-pages/html-page-classic-script.d.ts +15 -0
- package/src/html-pages/html-page-classic-script.js +25 -0
- package/src/html-pages/html-page-document.d.ts +33 -0
- package/src/html-pages/html-page-document.js +100 -0
- package/src/html-pages/html-page-module-scripts.d.ts +86 -0
- package/src/html-pages/html-page-module-scripts.js +293 -0
- package/src/html-pages/html-page-module.d.ts +32 -0
- package/src/html-pages/html-page-module.js +113 -0
- package/src/html-pages/html-page-renderer.d.ts +69 -0
- package/src/html-pages/html-page-renderer.js +287 -0
- package/src/html-pages/html-page-template.d.ts +128 -0
- package/src/html-pages/html-page-template.js +495 -0
- package/src/html-pages/html-page-warning-state.d.ts +8 -0
- package/src/html-pages/html-page-warning-state.js +6 -0
- package/src/html-pages/html-pages.plugin.d.ts +23 -0
- package/src/html-pages/html-pages.plugin.js +32 -0
- package/src/index.browser.d.ts +4 -1
- package/src/index.browser.js +5 -4
- package/src/index.d.ts +8 -4
- package/src/index.js +9 -21
- package/src/integration.d.ts +25 -0
- package/src/integration.js +23 -0
- package/src/islands/README.md +44 -0
- package/src/islands/island-host.d.ts +43 -0
- package/src/islands/island-host.js +65 -0
- package/src/page-cache/README.md +17 -0
- package/src/page-cache/cache.types.d.ts +1 -0
- package/src/page-cache/cache.types.js +1 -0
- package/src/page-cache/html-page-cache-dependency-index.d.ts +15 -0
- package/src/page-cache/html-page-cache-dependency-index.js +27 -0
- package/src/{services/cache → page-cache}/memory-cache-store.d.ts +3 -3
- package/src/page-cache/memory-cache-store.js +118 -0
- package/src/{services/cache → page-cache}/page-cache-service.d.ts +29 -10
- package/src/page-cache/page-cache-service.js +374 -0
- package/src/{services/cache → page-cache}/page-request-cache-coordinator.service.d.ts +7 -2
- package/src/page-cache/page-request-cache-coordinator.service.js +139 -0
- package/src/plugins/README.md +29 -11
- package/src/plugins/alias-resolver-cache.d.ts +6 -35
- package/src/plugins/alias-resolver-cache.js +56 -100
- package/src/plugins/alias-resolver-plugin.d.ts +3 -6
- package/src/plugins/alias-resolver-plugin.js +34 -62
- package/src/plugins/component-import-discovery.d.ts +28 -0
- package/src/plugins/component-import-discovery.js +244 -0
- package/src/plugins/define-integration.d.ts +24 -0
- package/src/plugins/define-integration.js +20 -0
- package/src/plugins/eco-component-meta-plugin.d.ts +21 -93
- package/src/plugins/eco-component-meta-plugin.js +310 -172
- package/src/plugins/find-integration-for-file.d.ts +16 -0
- package/src/plugins/find-integration-for-file.js +34 -0
- package/src/plugins/foreign-jsx-override-plugin.d.ts +1 -1
- package/src/plugins/foreign-jsx-override-plugin.js +48 -37
- package/src/plugins/integration-plugin.d.ts +98 -121
- package/src/plugins/integration-plugin.js +148 -191
- package/src/plugins/jsx-import-source.utils.d.ts +7 -0
- package/src/plugins/jsx-import-source.utils.js +15 -0
- package/src/plugins/package-specifier.d.ts +8 -0
- package/src/plugins/package-specifier.js +24 -0
- package/src/plugins/processor.d.ts +84 -35
- package/src/plugins/processor.js +159 -130
- package/src/plugins/tsconfig-import-resolver.d.ts +46 -0
- package/src/plugins/tsconfig-import-resolver.js +268 -0
- package/src/processor.d.ts +4 -0
- package/src/processor.js +3 -0
- package/src/route-renderer/GRAPH.md +54 -57
- package/src/route-renderer/README.md +81 -39
- package/src/route-renderer/error-pages/README.md +11 -0
- package/src/route-renderer/error-pages/default-error-pages.d.ts +39 -0
- package/src/route-renderer/error-pages/default-error-pages.js +192 -0
- package/src/route-renderer/error-pages/error-page-renderer.d.ts +51 -0
- package/src/route-renderer/error-pages/error-page-renderer.js +130 -0
- package/src/route-renderer/error-pages/semantic-error-page-exporter.d.ts +22 -0
- package/src/route-renderer/error-pages/semantic-error-page-exporter.js +33 -0
- package/src/{adapters/shared/explicit-static-render-preparation.d.ts → route-renderer/explicit-view-render-preparation.d.ts} +22 -3
- package/src/route-renderer/explicit-view-render-preparation.js +49 -0
- package/src/route-renderer/orchestration/custom-element-scripts/README.md +15 -0
- package/src/route-renderer/orchestration/custom-element-scripts/custom-element-script-preload-invalidation.d.ts +8 -0
- package/src/route-renderer/orchestration/custom-element-scripts/custom-element-script-preload-invalidation.js +24 -0
- package/src/route-renderer/orchestration/custom-element-scripts/custom-element-script-preloader.d.ts +78 -0
- package/src/route-renderer/orchestration/custom-element-scripts/custom-element-script-preloader.js +164 -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 +34 -0
- package/src/route-renderer/orchestration/custom-element-scripts/custom-element-ssr-preload-entrypoint.d.ts +15 -0
- package/src/route-renderer/orchestration/custom-element-scripts/custom-element-ssr-preload-entrypoint.js +65 -0
- package/src/route-renderer/orchestration/document-shell/document-shell-render.service.d.ts +114 -0
- package/src/route-renderer/orchestration/document-shell/document-shell-render.service.js +161 -0
- package/src/route-renderer/orchestration/document-shell/layout-shell-props.service.d.ts +32 -0
- package/src/route-renderer/orchestration/document-shell/layout-shell-props.service.js +52 -0
- package/src/route-renderer/orchestration/foreign-child/foreign-child-output.utils.d.ts +4 -0
- package/src/route-renderer/orchestration/foreign-child/foreign-child-output.utils.js +27 -0
- package/src/route-renderer/orchestration/foreign-child/foreign-subtree-execution.service.d.ts +127 -0
- package/src/route-renderer/orchestration/foreign-child/foreign-subtree-execution.service.js +319 -0
- package/src/route-renderer/orchestration/foreign-child/owning-renderer-resolution.d.ts +18 -0
- package/src/route-renderer/orchestration/foreign-child/owning-renderer-resolution.js +33 -0
- package/src/route-renderer/orchestration/foreign-child/render-session.d.ts +27 -0
- package/src/route-renderer/orchestration/foreign-child/render-session.js +9 -0
- package/src/route-renderer/orchestration/integration-renderer.d.ts +280 -290
- package/src/route-renderer/orchestration/integration-renderer.js +1210 -987
- package/src/route-renderer/orchestration/integration-renderer.test-fixtures.d.ts +39 -0
- package/src/route-renderer/orchestration/integration-renderer.test-fixtures.js +94 -0
- package/src/route-renderer/orchestration/ownership-graph/component-graph-collectors.d.ts +15 -0
- package/src/route-renderer/orchestration/ownership-graph/component-graph-collectors.js +49 -0
- package/src/route-renderer/orchestration/ownership-graph/component-graph.d.ts +70 -0
- package/src/route-renderer/orchestration/ownership-graph/component-graph.js +177 -0
- package/src/route-renderer/orchestration/ownership-graph/ownership-validation.service.d.ts +26 -0
- package/src/route-renderer/orchestration/ownership-graph/ownership-validation.service.js +74 -0
- package/src/route-renderer/orchestration/ownership-graph/page-client-browser-assets.d.ts +28 -0
- package/src/route-renderer/orchestration/ownership-graph/page-client-browser-assets.js +44 -0
- package/src/route-renderer/orchestration/ownership-graph/page-client-plan.d.ts +40 -0
- package/src/route-renderer/orchestration/ownership-graph/page-client-plan.js +175 -0
- package/src/route-renderer/orchestration/page-browser-graph/global-injector-assets.service.d.ts +7 -0
- package/src/route-renderer/orchestration/page-browser-graph/global-injector-assets.service.js +31 -0
- package/src/route-renderer/orchestration/page-browser-graph/grouped-graph-build-plan.d.ts +33 -0
- package/src/route-renderer/orchestration/page-browser-graph/grouped-graph-build-plan.js +14 -0
- package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph-contribution.merge.d.ts +5 -0
- package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph-contribution.merge.js +30 -0
- package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph-merge.utils.d.ts +12 -0
- package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph-merge.utils.js +32 -0
- package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph-session.d.ts +113 -0
- package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph-session.js +492 -0
- package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph.service.d.ts +58 -0
- package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph.service.js +360 -0
- package/src/route-renderer/orchestration/page-browser-graph/route-instance-key.d.ts +26 -0
- package/src/route-renderer/orchestration/page-browser-graph/route-instance-key.js +32 -0
- package/src/route-renderer/orchestration/route-pipeline/marker-artifact.utils.d.ts +5 -0
- package/src/route-renderer/orchestration/route-pipeline/marker-artifact.utils.js +11 -0
- package/src/route-renderer/orchestration/route-pipeline/robots-meta.contribution.d.ts +15 -0
- package/src/route-renderer/orchestration/route-pipeline/robots-meta.contribution.js +43 -0
- package/src/route-renderer/orchestration/route-pipeline/route-html-finalization.service.d.ts +26 -0
- package/src/route-renderer/orchestration/route-pipeline/route-html-finalization.service.js +43 -0
- package/src/route-renderer/orchestration/route-pipeline/route-prepared-options.builder.d.ts +26 -0
- package/src/route-renderer/orchestration/route-pipeline/route-prepared-options.builder.js +44 -0
- package/src/route-renderer/orchestration/route-pipeline/route-prepared-options.utils.d.ts +4 -0
- package/src/route-renderer/orchestration/route-pipeline/route-prepared-options.utils.js +30 -0
- package/src/route-renderer/orchestration/route-pipeline/route-render-orchestrator.d.ts +131 -0
- package/src/route-renderer/orchestration/route-pipeline/route-render-orchestrator.js +350 -0
- package/src/route-renderer/orchestration/route-pipeline/route-render-orchestrator.test-fixtures.d.ts +35 -0
- package/src/route-renderer/orchestration/route-pipeline/route-render-orchestrator.test-fixtures.js +69 -0
- package/src/route-renderer/orchestration/string-markup-renderer.d.ts +11 -0
- package/src/route-renderer/orchestration/string-markup-renderer.js +10 -0
- package/src/route-renderer/page-loading/component-dependency-collection.d.ts +18 -5
- package/src/route-renderer/page-loading/component-dependency-collection.js +165 -100
- package/src/route-renderer/page-loading/declared-asset-collection.d.ts +2 -2
- package/src/route-renderer/page-loading/declared-asset-collection.js +66 -94
- package/src/route-renderer/page-loading/dependency-resolver.d.ts +41 -6
- package/src/route-renderer/page-loading/dependency-resolver.js +248 -104
- package/src/route-renderer/page-loading/ecopages-virtual-imports.d.ts +1 -0
- package/src/route-renderer/page-loading/ecopages-virtual-imports.js +87 -44
- package/src/route-renderer/page-loading/file-scoped-dependency-components.d.ts +41 -0
- package/src/route-renderer/page-loading/file-scoped-dependency-components.js +120 -0
- package/src/route-renderer/page-loading/lazy-entry-collection.d.ts +2 -3
- package/src/route-renderer/page-loading/lazy-entry-collection.js +67 -98
- package/src/route-renderer/page-loading/lazy-trigger-planning.d.ts +1 -1
- package/src/route-renderer/page-loading/lazy-trigger-planning.js +47 -36
- package/src/route-renderer/page-loading/module-declaration-aggregation.js +39 -28
- package/src/route-renderer/page-loading/module-declaration-scripts.js +10 -15
- package/src/route-renderer/page-loading/page-dependency-bundling.d.ts +6 -7
- package/src/route-renderer/page-loading/page-dependency-bundling.js +175 -112
- package/src/route-renderer/page-loading/page-module-loader.d.ts +9 -10
- package/src/route-renderer/page-loading/page-module-loader.js +136 -124
- package/src/route-renderer/page-loading/resolved-page-dependencies.d.ts +11 -0
- package/src/route-renderer/page-loading/resolved-page-dependencies.js +39 -0
- package/src/route-renderer/route-renderer.d.ts +15 -17
- package/src/route-renderer/route-renderer.js +50 -76
- package/src/router/README.md +73 -7
- package/src/router/client/link-intent.d.ts +11 -21
- package/src/router/client/link-intent.js +56 -30
- package/src/router/client/link-intent.test.browser.js +30 -40
- package/src/router/client/link-navigation-policy.d.ts +45 -0
- package/src/router/client/link-navigation-policy.js +102 -0
- package/src/router/client/link-navigation-policy.test.browser.d.ts +1 -0
- package/src/router/client/link-navigation-policy.test.browser.js +142 -0
- package/src/router/client/navigation-commit.d.ts +22 -0
- package/src/router/client/navigation-commit.js +57 -0
- package/src/router/client/navigation-commit.test.browser.d.ts +1 -0
- package/src/router/client/navigation-commit.test.browser.js +116 -0
- package/src/router/client/navigation-coordinator.d.ts +1 -20
- package/src/router/client/navigation-coordinator.js +194 -204
- package/src/router/client/navigation-document.d.ts +37 -0
- package/src/router/client/navigation-document.js +106 -0
- package/src/router/client/navigation-document.test.browser.d.ts +1 -0
- package/src/router/client/navigation-document.test.browser.js +77 -0
- package/src/router/client/navigation-head.d.ts +13 -0
- package/src/router/client/navigation-head.js +238 -0
- package/src/router/client/navigation-head.test.browser.d.ts +1 -0
- package/src/router/client/navigation-head.test.browser.js +101 -0
- package/src/router/client/navigation-lifecycle.d.ts +49 -0
- package/src/router/client/navigation-lifecycle.js +50 -0
- package/src/router/client/navigation-lifecycle.test.browser.d.ts +1 -0
- package/src/router/client/navigation-lifecycle.test.browser.js +97 -0
- package/src/router/client/navigation-pipeline.d.ts +8 -0
- package/src/router/client/navigation-pipeline.js +8 -0
- package/src/router/client/navigation-replay.d.ts +16 -0
- package/src/router/client/navigation-replay.js +17 -0
- package/src/router/client/navigation-view-transition.d.ts +9 -0
- package/src/router/client/navigation-view-transition.js +61 -0
- package/src/router/client/navigation-view-transition.test.browser.d.ts +1 -0
- package/src/router/client/navigation-view-transition.test.browser.js +189 -0
- package/src/router/client/staged-stylesheets.test-fixtures.d.ts +18 -0
- package/src/router/client/staged-stylesheets.test-fixtures.js +31 -0
- package/src/router/server/parse-search-params.d.ts +9 -0
- package/src/router/server/parse-search-params.js +16 -0
- package/src/router/server/route-registry.d.ts +32 -7
- package/src/router/server/route-registry.js +220 -243
- package/src/router/server/segment-path-matcher.d.ts +27 -0
- package/src/router/server/segment-path-matcher.js +149 -0
- package/src/static-site-generator/README.md +41 -0
- package/src/static-site-generator/production-page-browser-graph-prebuild.d.ts +36 -0
- package/src/static-site-generator/production-page-browser-graph-prebuild.js +196 -0
- package/src/static-site-generator/sitemap-routes.d.ts +14 -0
- package/src/static-site-generator/sitemap-routes.js +36 -0
- package/src/static-site-generator/sitemap.d.ts +15 -0
- package/src/static-site-generator/sitemap.js +42 -0
- package/src/static-site-generator/static-export-context.d.ts +33 -0
- package/src/static-site-generator/static-export-context.js +1 -0
- package/src/static-site-generator/static-site-generator.d.ts +38 -28
- package/src/static-site-generator/static-site-generator.js +556 -295
- package/src/static-site-generator/static-site-generator.test-utils.d.ts +2 -0
- package/src/static-site-generator/static-site-generator.test-utils.js +41 -0
- package/src/types/README.md +5 -0
- package/src/types/api-response.d.ts +9 -0
- package/src/types/api-response.js +1 -0
- package/src/{services/assets/asset-processing-service/assets.types.d.ts → types/asset-types.d.ts} +22 -4
- package/src/types/asset-types.js +1 -0
- package/src/types/build-types.d.ts +104 -0
- package/src/types/build-types.js +1 -0
- package/src/{services/cache/cache.types.d.ts → types/cache-types.d.ts} +20 -9
- package/src/types/cache-types.js +5 -0
- package/src/types/component-identity.d.ts +6 -0
- package/src/types/component-identity.js +1 -0
- package/src/types/contracts.d.ts +1523 -0
- package/src/types/contracts.js +1 -0
- package/src/types/dev-transform-types.d.ts +15 -0
- package/src/types/dev-transform-types.js +1 -0
- package/src/{eco/eco.types.d.ts → types/eco-api-types.d.ts} +21 -38
- package/src/types/eco-api-types.js +5 -0
- package/src/types/integration-types.d.ts +3 -0
- package/src/types/integration-types.js +1 -0
- package/src/types/public-types.d.ts +3 -1307
- package/src/types/public-types.js +1 -0
- package/src/types/standard-schema-types.d.ts +12 -0
- package/src/types/standard-schema-types.js +1 -0
- package/src/utils/README.md +7 -0
- package/src/utils/additional-watch-paths.d.ts +25 -0
- package/src/utils/additional-watch-paths.js +49 -0
- package/src/utils/app-runtime.d.ts +9 -0
- package/src/utils/app-runtime.js +13 -0
- package/src/utils/content-hash.d.ts +8 -0
- package/src/utils/content-hash.js +16 -0
- package/src/utils/deep-merge.js +39 -26
- package/src/utils/ecopages-route-info.d.ts +22 -0
- package/src/utils/ecopages-route-info.js +20 -0
- package/src/utils/html-entities.d.ts +10 -0
- package/src/utils/html-entities.js +34 -0
- package/src/utils/html-escaping.d.ts +14 -0
- package/src/utils/html-escaping.js +42 -5
- package/src/utils/invariant.js +11 -10
- package/src/utils/locals-utils.d.ts +1 -1
- package/src/utils/locals-utils.js +32 -22
- package/src/utils/parse-cli-args.d.ts +3 -6
- package/src/utils/parse-cli-args.js +55 -60
- package/src/utils/path-containment.d.ts +15 -0
- package/src/utils/path-containment.js +27 -0
- package/src/utils/path-pattern.d.ts +23 -0
- package/src/utils/path-pattern.js +42 -0
- package/src/utils/regex-escaping.d.ts +2 -0
- package/src/utils/regex-escaping.js +4 -0
- package/src/utils/resolve-entry-file.d.ts +72 -0
- package/src/utils/resolve-entry-file.js +74 -0
- package/src/utils/resolve-work-dir.js +23 -27
- package/src/utils/runtime.d.ts +12 -9
- package/src/utils/runtime.js +14 -39
- package/src/utils/server-utils.module.d.ts +13 -2
- package/src/utils/server-utils.module.js +74 -53
- package/src/utils/static-file-extensions.d.ts +12 -0
- package/src/utils/static-file-extensions.js +54 -0
- package/src/validation/README.md +9 -0
- package/src/validation/standard-schema.types.d.ts +1 -0
- package/src/validation/standard-schema.types.js +1 -0
- package/src/validation/validate-request.d.ts +36 -0
- package/src/validation/validate-request.js +56 -0
- package/src/validation/validate-standard-schema.d.ts +7 -0
- package/src/validation/validate-standard-schema.js +14 -0
- package/src/watchers/README.md +15 -0
- package/src/watchers/project-watcher-ignore.d.ts +13 -0
- package/src/watchers/project-watcher-ignore.js +27 -0
- package/src/watchers/project-watcher.d.ts +80 -84
- package/src/watchers/project-watcher.js +489 -258
- package/src/watchers/project-watcher.test-helpers.d.ts +59 -3
- package/src/watchers/project-watcher.test-helpers.js +106 -50
- package/src/watchers/workspace-package-watch-roots.d.ts +9 -0
- package/src/watchers/workspace-package-watch-roots.js +44 -0
- package/src/adapters/abstract/application-adapter.d.ts +0 -194
- package/src/adapters/abstract/application-adapter.js +0 -121
- package/src/adapters/abstract/router-adapter.d.ts +0 -26
- package/src/adapters/abstract/router-adapter.js +0 -5
- package/src/adapters/abstract/server-adapter.d.ts +0 -69
- package/src/adapters/abstract/server-adapter.js +0 -15
- package/src/adapters/bun/client-bridge.d.ts +0 -34
- package/src/adapters/bun/client-bridge.js +0 -48
- package/src/adapters/bun/create-app.d.ts +0 -60
- package/src/adapters/bun/create-app.js +0 -140
- package/src/adapters/bun/hmr-manager.d.ts +0 -47
- package/src/adapters/bun/hmr-manager.js +0 -58
- package/src/adapters/bun/index.d.ts +0 -2
- package/src/adapters/bun/index.js +0 -8
- package/src/adapters/bun/runtime-host.d.ts +0 -52
- package/src/adapters/bun/runtime-host.js +0 -56
- package/src/adapters/bun/server-adapter.d.ts +0 -223
- package/src/adapters/bun/server-adapter.js +0 -450
- package/src/adapters/bun/static-preview-host.d.ts +0 -28
- package/src/adapters/bun/static-preview-host.js +0 -45
- package/src/adapters/index.d.ts +0 -2
- package/src/adapters/index.js +0 -8
- package/src/adapters/node/node-hmr-manager.d.ts +0 -52
- package/src/adapters/node/node-hmr-manager.js +0 -49
- package/src/adapters/node/server-adapter-dependencies.d.ts +0 -19
- package/src/adapters/node/server-adapter-dependencies.js +0 -18
- package/src/adapters/node/static-content-server.d.ts +0 -60
- package/src/adapters/node/static-content-server.js +0 -194
- package/src/adapters/node/static-preview-host.d.ts +0 -55
- package/src/adapters/node/static-preview-host.js +0 -68
- package/src/adapters/shared/api-response.js +0 -96
- package/src/adapters/shared/application-adapter.d.ts +0 -18
- package/src/adapters/shared/application-adapter.js +0 -90
- package/src/adapters/shared/define-api-handler.d.ts +0 -25
- package/src/adapters/shared/define-api-handler.js +0 -15
- package/src/adapters/shared/explicit-static-render-preparation.js +0 -26
- package/src/adapters/shared/explicit-static-route-matcher.js +0 -101
- package/src/adapters/shared/file-route-middleware-pipeline.js +0 -90
- package/src/adapters/shared/fs-server-response-factory.d.ts +0 -23
- package/src/adapters/shared/fs-server-response-factory.js +0 -81
- package/src/adapters/shared/fs-server-response-matcher.js +0 -186
- package/src/adapters/shared/hmr-entrypoint-registrar.d.ts +0 -55
- package/src/adapters/shared/hmr-entrypoint-registrar.js +0 -87
- package/src/adapters/shared/hmr-html-response.d.ts +0 -22
- package/src/adapters/shared/hmr-html-response.js +0 -33
- package/src/adapters/shared/render-context.js +0 -93
- package/src/adapters/shared/runtime-app-bootstrap.d.ts +0 -26
- package/src/adapters/shared/runtime-app-bootstrap.js +0 -46
- package/src/adapters/shared/runtime-host.js +0 -0
- package/src/adapters/shared/server-adapter.d.ts +0 -108
- package/src/adapters/shared/server-adapter.js +0 -436
- package/src/adapters/shared/server-route-handler.js +0 -111
- package/src/adapters/shared/server-static-builder.d.ts +0 -71
- package/src/adapters/shared/server-static-builder.js +0 -100
- package/src/adapters/shared/shared-hmr-manager.d.ts +0 -59
- package/src/adapters/shared/shared-hmr-manager.js +0 -241
- package/src/adapters/shared/static-preview-host.d.ts +0 -10
- package/src/adapters/shared/static-preview-host.js +0 -0
- package/src/build/browser-runtime-manifest.js +0 -61
- package/src/build/browser-runtime-plugin-helpers.d.ts +0 -26
- package/src/build/browser-runtime-plugin-helpers.js +0 -14
- package/src/build/browser-runtime-plugin.d.ts +0 -78
- package/src/build/browser-runtime-plugin.js +0 -173
- package/src/build/build-manifest.d.ts +0 -33
- package/src/build/build-manifest.js +0 -49
- package/src/build/build-types.d.ts +0 -57
- package/src/build/build-types.js +0 -0
- package/src/build/rolldown-adapter-helpers.d.ts +0 -58
- package/src/build/rolldown-adapter-helpers.js +0 -265
- package/src/build/rolldown-build-adapter.d.ts +0 -28
- package/src/build/rolldown-build-adapter.js +0 -65
- package/src/build/rolldown-dev-build-adapter.d.ts +0 -82
- package/src/build/rolldown-dev-build-adapter.js +0 -166
- package/src/build/rolldown-plugin-bridge.d.ts +0 -59
- package/src/build/rolldown-plugin-bridge.js +0 -199
- package/src/build/runtime-build-executor.d.ts +0 -21
- package/src/build/runtime-build-executor.js +0 -19
- package/src/build/runtime-build-output-normalizer.d.ts +0 -3
- package/src/build/runtime-build-output-normalizer.js +0 -111
- package/src/build/serialized-build-executor.d.ts +0 -64
- package/src/build/serialized-build-executor.js +0 -63
- package/src/build/server-side-css-shim-plugin.js +0 -35
- package/src/config/config-builder.d.ts +0 -266
- package/src/config/config-builder.js +0 -603
- package/src/dev/host-runtime.d.ts +0 -10
- package/src/dev/host-runtime.js +0 -24
- package/src/dev/sc-server.d.ts +0 -30
- package/src/dev/sc-server.js +0 -111
- package/src/eco/eco.types.js +0 -0
- package/src/eco/eco.utils.d.ts +0 -1
- package/src/eco/eco.utils.js +0 -10
- package/src/eco/lazy-injector-map.d.ts +0 -8
- package/src/eco/lazy-injector-map.js +0 -70
- package/src/hmr/hmr.postcss.test.e2e.js +0 -31
- package/src/hmr/hmr.test.e2e.js +0 -43
- package/src/integrations/ghtml/ghtml-renderer.d.ts +0 -16
- package/src/integrations/ghtml/ghtml-renderer.js +0 -57
- package/src/integrations/ghtml/ghtml.constants.d.ts +0 -1
- package/src/integrations/ghtml/ghtml.constants.js +0 -4
- package/src/integrations/ghtml/ghtml.plugin.d.ts +0 -16
- package/src/integrations/ghtml/ghtml.plugin.js +0 -20
- package/src/plugins/runtime-capability.d.ts +0 -9
- package/src/plugins/runtime-capability.js +0 -0
- package/src/plugins/source-transform.d.ts +0 -46
- package/src/plugins/source-transform.js +0 -71
- package/src/route-renderer/orchestration/component-render-context.d.ts +0 -97
- package/src/route-renderer/orchestration/component-render-context.js +0 -147
- package/src/route-renderer/orchestration/declared-ownership-graph.d.ts +0 -18
- package/src/route-renderer/orchestration/declared-ownership-graph.js +0 -34
- package/src/route-renderer/orchestration/foreign-subtree-execution.service.d.ts +0 -110
- package/src/route-renderer/orchestration/foreign-subtree-execution.service.js +0 -233
- package/src/route-renderer/orchestration/ownership-planning.service.d.ts +0 -24
- package/src/route-renderer/orchestration/ownership-planning.service.js +0 -63
- package/src/route-renderer/orchestration/ownership-validation.service.d.ts +0 -29
- package/src/route-renderer/orchestration/ownership-validation.service.js +0 -53
- package/src/route-renderer/orchestration/processed-asset-dedupe.js +0 -27
- package/src/route-renderer/orchestration/queued-foreign-subtree-resolution.service.d.ts +0 -91
- package/src/route-renderer/orchestration/queued-foreign-subtree-resolution.service.js +0 -170
- package/src/route-renderer/orchestration/render-output.utils.js +0 -171
- package/src/route-renderer/orchestration/route-render-orchestrator.d.ts +0 -156
- package/src/route-renderer/orchestration/route-render-orchestrator.js +0 -577
- package/src/route-renderer/orchestration/template-serialization.d.ts +0 -38
- package/src/route-renderer/orchestration/template-serialization.js +0 -45
- package/src/services/README.md +0 -28
- package/src/services/assets/asset-processing-service/asset-dependency-keys.d.ts +0 -3
- package/src/services/assets/asset-processing-service/asset-dependency-keys.js +0 -56
- package/src/services/assets/asset-processing-service/asset-processing.service.d.ts +0 -103
- package/src/services/assets/asset-processing-service/asset-processing.service.js +0 -285
- package/src/services/assets/asset-processing-service/asset.factory.js +0 -82
- package/src/services/assets/asset-processing-service/assets.types.js +0 -0
- package/src/services/assets/asset-processing-service/browser-runtime-asset.factory.js +0 -49
- package/src/services/assets/asset-processing-service/browser-runtime-entry.factory.js +0 -41
- package/src/services/assets/asset-processing-service/grouped-content-bundles.d.ts +0 -30
- package/src/services/assets/asset-processing-service/grouped-content-bundles.js +0 -65
- package/src/services/assets/asset-processing-service/index.js +0 -6
- package/src/services/assets/asset-processing-service/page-package.js +0 -80
- package/src/services/assets/asset-processing-service/processor.interface.d.ts +0 -22
- package/src/services/assets/asset-processing-service/processor.interface.js +0 -6
- package/src/services/assets/asset-processing-service/processor.registry.d.ts +0 -8
- package/src/services/assets/asset-processing-service/processor.registry.js +0 -15
- package/src/services/assets/asset-processing-service/processors/base/base-processor.d.ts +0 -24
- package/src/services/assets/asset-processing-service/processors/base/base-processor.js +0 -65
- package/src/services/assets/asset-processing-service/processors/base/base-script-processor.d.ts +0 -22
- package/src/services/assets/asset-processing-service/processors/base/base-script-processor.js +0 -136
- package/src/services/assets/asset-processing-service/processors/index.js +0 -5
- package/src/services/assets/asset-processing-service/processors/script/content-script.processor.d.ts +0 -6
- package/src/services/assets/asset-processing-service/processors/script/content-script.processor.js +0 -120
- package/src/services/assets/asset-processing-service/processors/script/file-script.processor.d.ts +0 -9
- package/src/services/assets/asset-processing-service/processors/script/file-script.processor.js +0 -97
- package/src/services/assets/asset-processing-service/processors/script/node-module-script.processor.js +0 -126
- package/src/services/assets/asset-processing-service/processors/stylesheet/content-stylesheet.processor.js +0 -59
- package/src/services/assets/asset-processing-service/processors/stylesheet/file-stylesheet.processor.js +0 -69
- package/src/services/assets/asset-processing-service/ungrouped-dependency-processing.d.ts +0 -18
- package/src/services/assets/asset-processing-service/ungrouped-dependency-processing.js +0 -45
- package/src/services/assets/browser-bundle.service.d.ts +0 -73
- package/src/services/assets/browser-bundle.service.js +0 -41
- package/src/services/cache/cache.types.js +0 -0
- package/src/services/cache/index.d.ts +0 -7
- package/src/services/cache/index.js +0 -7
- package/src/services/cache/memory-cache-store.js +0 -98
- package/src/services/cache/page-cache-service.js +0 -152
- package/src/services/cache/page-request-cache-coordinator.service.js +0 -109
- 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/html/html-transformer.service.d.ts +0 -96
- package/src/services/html/html-transformer.service.js +0 -287
- package/src/services/invalidation/development-invalidation.service.d.ts +0 -74
- package/src/services/invalidation/development-invalidation.service.js +0 -190
- package/src/services/module-loading/app-module-loader.service.d.ts +0 -7
- package/src/services/module-loading/app-module-loader.service.js +0 -0
- package/src/services/module-loading/app-server-module-transpiler.service.d.ts +0 -24
- package/src/services/module-loading/app-server-module-transpiler.service.js +0 -130
- package/src/services/module-loading/host-module-loader-registry.d.ts +0 -4
- package/src/services/module-loading/host-module-loader-registry.js +0 -15
- package/src/services/module-loading/module-loading-types.d.ts +0 -2
- package/src/services/module-loading/module-loading-types.js +0 -0
- package/src/services/module-loading/page-module-import.service.js +0 -193
- package/src/services/module-loading/server-module-transpiler.service.d.ts +0 -63
- package/src/services/module-loading/server-module-transpiler.service.js +0 -64
- package/src/services/module-loading/source-module-support.d.ts +0 -5
- package/src/services/module-loading/source-module-support.js +0 -8
- package/src/services/runtime-state/dev-graph.service.d.ts +0 -118
- package/src/services/runtime-state/dev-graph.service.js +0 -162
- package/src/services/runtime-state/entrypoint-dependency-graph.service.d.ts +0 -41
- package/src/services/runtime-state/entrypoint-dependency-graph.service.js +0 -85
- package/src/services/runtime-state/server-invalidation-state.service.d.ts +0 -26
- package/src/services/runtime-state/server-invalidation-state.service.js +0 -35
- package/src/services/validation/schema-validation-service.d.ts +0 -122
- package/src/services/validation/schema-validation-service.js +0 -101
- package/src/services/validation/standard-schema.types.d.ts +0 -65
- package/src/services/validation/standard-schema.types.js +0 -0
- package/src/types/internal-types.d.ts +0 -232
- package/src/types/internal-types.js +0 -0
- package/src/utils/hash.d.ts +0 -1
- package/src/utils/hash.js +0 -7
- package/src/utils/html.d.ts +0 -1
- package/src/utils/html.js +0 -4
- package/src/utils/path-utils.module.d.ts +0 -5
- package/src/utils/path-utils.module.js +0 -14
- /package/src/{hmr/hmr.postcss.test.e2e.d.ts → adapters/shared/runtime/runtime-host.js} +0 -0
- /package/src/{services/assets → assets}/asset-processing-service/asset.factory.d.ts +0 -0
- /package/src/{hmr/hmr.test.e2e.d.ts → assets/asset-processing-service/assets.types.js} +0 -0
- /package/src/{services/assets → assets}/asset-processing-service/processors/index.d.ts +0 -0
|
@@ -0,0 +1,570 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared helpers for the Rolldown-backed build adapters.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* The standard {@link RolldownBuildAdapter} uses these helpers for
|
|
6
|
+
* BuildOptions → Rolldown mapping and dependency-graph extraction. Rolldown's
|
|
7
|
+
* node platform keeps Node builtins external, so named output hashes cover
|
|
8
|
+
* the bytes that are written.
|
|
9
|
+
*
|
|
10
|
+
* @module
|
|
11
|
+
*/
|
|
12
|
+
import { builtinModules, createRequire } from 'node:module';
|
|
13
|
+
import { readFileSync } from 'node:fs';
|
|
14
|
+
import path from 'node:path';
|
|
15
|
+
import { fileURLToPath } from 'node:url';
|
|
16
|
+
import { stripVTControlCharacters } from 'node:util';
|
|
17
|
+
import { recordBuildEntryOutput, resolveBuildEntryPath } from '../build-graph.js';
|
|
18
|
+
import { id as idFilter, include } from 'rolldown/filter';
|
|
19
|
+
import { escapeRegExp } from '../../utils/regex-escaping.js';
|
|
20
|
+
import { isPathInside } from '../../utils/path-containment.js';
|
|
21
|
+
import { isEcopagesEnvEnabled } from '../../env.js';
|
|
22
|
+
import { isBarePackageImportSpecifier } from '../../plugins/tsconfig-import-resolver.js';
|
|
23
|
+
import { toPackageRootSpecifier } from '../../plugins/package-specifier.js';
|
|
24
|
+
import { isServerOnlyModuleSpecifier } from '../contracts/server-only-specifier.js';
|
|
25
|
+
import { createServerSideCssShimPlugin } from './server-side-css-shim-plugin.js';
|
|
26
|
+
import { appLogger } from '../../global/app-logger.js';
|
|
27
|
+
import { realpathOfDirectory } from '../preserve-import-meta-transform.js';
|
|
28
|
+
import { createRolldownPluginBridge, getEcoBuildPluginName } from './rolldown-plugin-bridge.js';
|
|
29
|
+
import { isDeclaredAppPackageImport, isWorkspacePackageImport } from './app-package-declarations.js';
|
|
30
|
+
const coreSourceFile = fileURLToPath(import.meta.url);
|
|
31
|
+
const nodeBuiltinSpecifiers = new Set(builtinModules);
|
|
32
|
+
let corePackageNames;
|
|
33
|
+
const CORE_RUNTIME_BUNDLED_PACKAGES = new Set(['ws']);
|
|
34
|
+
/**
|
|
35
|
+
* Returns the set of packages declared as direct dependencies in core's own
|
|
36
|
+
* `package.json` (all dependency fields combined).
|
|
37
|
+
*
|
|
38
|
+
* @remarks
|
|
39
|
+
* Result is cached for the lifetime of the process. This is safe because
|
|
40
|
+
* core's own package.json does not change at runtime.
|
|
41
|
+
*/
|
|
42
|
+
function getCorePackageNames() {
|
|
43
|
+
if (corePackageNames) {
|
|
44
|
+
return corePackageNames;
|
|
45
|
+
}
|
|
46
|
+
const packageJsonPath = new URL('../../../package.json', import.meta.url);
|
|
47
|
+
corePackageNames = new Set();
|
|
48
|
+
try {
|
|
49
|
+
const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8'));
|
|
50
|
+
for (const field of ['dependencies', 'devDependencies', 'peerDependencies', 'optionalDependencies']) {
|
|
51
|
+
const entries = packageJson[field];
|
|
52
|
+
if (!entries || typeof entries !== 'object') {
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
for (const name of Object.keys(entries)) {
|
|
56
|
+
corePackageNames.add(name);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
catch {
|
|
61
|
+
// Return empty set on read/parse failure; packages will be bundled.
|
|
62
|
+
}
|
|
63
|
+
return corePackageNames;
|
|
64
|
+
}
|
|
65
|
+
function isPackageImport(id, contextRoot) {
|
|
66
|
+
return isBarePackageImportSpecifier(id, contextRoot);
|
|
67
|
+
}
|
|
68
|
+
function tryResolveModule(id, resolver) {
|
|
69
|
+
try {
|
|
70
|
+
return resolver.resolve(id);
|
|
71
|
+
}
|
|
72
|
+
catch {
|
|
73
|
+
return undefined;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
function getAppRootRequire(cache, contextRoot) {
|
|
77
|
+
const cacheKey = path.resolve(contextRoot);
|
|
78
|
+
let req = cache.get(cacheKey);
|
|
79
|
+
if (!req) {
|
|
80
|
+
req = createRequire(path.join(cacheKey, 'package.json'));
|
|
81
|
+
cache.set(cacheKey, req);
|
|
82
|
+
}
|
|
83
|
+
return req;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Determines whether a package import stays an external bare specifier.
|
|
87
|
+
*
|
|
88
|
+
* @remarks
|
|
89
|
+
* Only packages the app declares and ships compiled qualify: the app's own
|
|
90
|
+
* `node_modules` resolves them at runtime, so Integration renderers and
|
|
91
|
+
* server bundles share one instance (for example one React). Workspace
|
|
92
|
+
* packages and source (TypeScript or JSX) packages are bundled. Undeclared
|
|
93
|
+
* compiled packages are handled by {@link createInstalledPackageExternalPlugin},
|
|
94
|
+
* because isolated installs (pnpm, Bun's isolated linker) do not expose them
|
|
95
|
+
* as bare specifiers to output directories like `.eco/` or `dist/.server/`.
|
|
96
|
+
*/
|
|
97
|
+
function isAppPackageExternal(id, contextRoot, appRootRequireCache) {
|
|
98
|
+
if (isWorkspacePackageImport(id, contextRoot) || !isDeclaredAppPackageImport(id, contextRoot)) {
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
const appResolvedPath = tryResolveModule(id, getAppRootRequire(appRootRequireCache, contextRoot));
|
|
102
|
+
return !appResolvedPath || !/\.(?:[cm]?ts|tsx|jsx)$/u.test(appResolvedPath);
|
|
103
|
+
}
|
|
104
|
+
function createExternalMatcher(options, appRootRequireCache) {
|
|
105
|
+
const explicitExternals = new Set(options.external ?? []);
|
|
106
|
+
const externalPackages = options.externalPackages === true;
|
|
107
|
+
const contextRoot = options.root ? path.resolve(options.root) : process.cwd();
|
|
108
|
+
return (id) => {
|
|
109
|
+
if (explicitExternals.has(id)) {
|
|
110
|
+
return true;
|
|
111
|
+
}
|
|
112
|
+
if (!externalPackages || !isPackageImport(id, contextRoot)) {
|
|
113
|
+
return false;
|
|
114
|
+
}
|
|
115
|
+
return isAppPackageExternal(id, contextRoot, appRootRequireCache);
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
const DEPLOY_LAYOUT_DOCS_URL = 'https://ecopages.app/docs/reference/deployment';
|
|
119
|
+
const MAX_WARNED_PACKAGE_NAMES = 5;
|
|
120
|
+
/**
|
|
121
|
+
* Logs one line for a deployed server output file whose imports resolve
|
|
122
|
+
* outside the app folder.
|
|
123
|
+
*
|
|
124
|
+
* @remarks
|
|
125
|
+
* Such a package (in a workspace root `node_modules`, a global package store,
|
|
126
|
+
* behind a symlinked root) is not copied with the app folder, so a moved
|
|
127
|
+
* server build cannot load it. Only builds with
|
|
128
|
+
* {@link BuildOptions.reportPackagesOutsideRoot} report it: the server entry
|
|
129
|
+
* and the emitted config that `ecopages build` writes, one complete line per
|
|
130
|
+
* output file. Module builds that the running server makes on the deploy
|
|
131
|
+
* target stay silent. The line names the first
|
|
132
|
+
* {@link MAX_WARNED_PACKAGE_NAMES} packages and counts the rest.
|
|
133
|
+
*/
|
|
134
|
+
function warnPackagesOutsideAppRoot(outputLabel, packageNames) {
|
|
135
|
+
const sorted = [...packageNames].sort();
|
|
136
|
+
if (sorted.length === 0)
|
|
137
|
+
return;
|
|
138
|
+
const hidden = sorted.length - MAX_WARNED_PACKAGE_NAMES;
|
|
139
|
+
const names = sorted.slice(0, MAX_WARNED_PACKAGE_NAMES).join(', ');
|
|
140
|
+
const count = sorted.length === 1 ? '1 package' : `${sorted.length} packages`;
|
|
141
|
+
appLogger.warn(`${outputLabel} imports ${count} from outside the app folder (${hidden > 0 ? `${names} and ${hidden} more` : names}); copy them with the app or build from a standalone install: ${DEPLOY_LAYOUT_DOCS_URL}`);
|
|
142
|
+
}
|
|
143
|
+
function isUndeclaredPackageImport(id, contextRoot) {
|
|
144
|
+
return (!isNodeBuiltinSpecifier(id) &&
|
|
145
|
+
!CORE_RUNTIME_BUNDLED_PACKAGES.has(toPackageRootSpecifier(id)) &&
|
|
146
|
+
isPackageImport(id, contextRoot) &&
|
|
147
|
+
!isDeclaredAppPackageImport(id, contextRoot));
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* @remarks
|
|
151
|
+
* A store whose real path has no `node_modules` segment is not recognised, so
|
|
152
|
+
* its packages are bundled. Yarn Plug'n'Play archives (`.zip` paths) are
|
|
153
|
+
* bundled too: Node cannot import a path into an archive without the PnP
|
|
154
|
+
* loader, so PnP installs are not supported for relocated server output.
|
|
155
|
+
*/
|
|
156
|
+
function isInstalledCompiledModule(filePath) {
|
|
157
|
+
return /\.[cm]?js$/u.test(filePath) && /[\\/]node_modules[\\/]/u.test(filePath) && !/\.zip[\\/]/u.test(filePath);
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Keeps installed compiled packages external as paths relative to the output
|
|
161
|
+
* directory.
|
|
162
|
+
*
|
|
163
|
+
* @remarks
|
|
164
|
+
* A compiled package can depend on its location on disk: it loads a native
|
|
165
|
+
* binding (`sharp`, `oxc-parser`), a platform package, or a sibling file
|
|
166
|
+
* through `createRequire(import.meta.url)` or `__dirname`. Bundled into
|
|
167
|
+
* `dist/.server/`, that lookup starts from the wrong folder and fails at
|
|
168
|
+
* runtime, and the bundle cannot tell which packages do it. So server builds
|
|
169
|
+
* bundle source code only (the app, workspace packages, TypeScript or JSX
|
|
170
|
+
* packages) and keep every compiled package installed in `node_modules`
|
|
171
|
+
* external, including the dependencies of bundled workspace packages and of
|
|
172
|
+
* Core itself.
|
|
173
|
+
*
|
|
174
|
+
* Under isolated installs (pnpm, Bun's isolated linker) a package the app does
|
|
175
|
+
* not declare is not reachable as a bare specifier from `dist/.server`, so the
|
|
176
|
+
* hook resolves it through Rolldown, from the importer (or, for Core's own
|
|
177
|
+
* dependencies, from Core), so the `node` and `import` conditions apply and
|
|
178
|
+
* the result is a real path, and returns a `./` or `../` path that Rolldown
|
|
179
|
+
* writes unchanged. The output keeps working when `dist` and `node_modules`
|
|
180
|
+
* move together, for example into a container image.
|
|
181
|
+
*
|
|
182
|
+
* The path is computed here rather than with `external: 'relative'`, because
|
|
183
|
+
* Rolldown 1.2 computes that path from `cwd` instead of the output directory.
|
|
184
|
+
* It is relative to `outdir`, so `generateBundle` rejects a chunk written in a
|
|
185
|
+
* subdirectory that imports one of these paths. With `reportDir` (the
|
|
186
|
+
* directory the output runs from) it also reports the packages that resolve
|
|
187
|
+
* outside the app folder, naming the entry files by their path in that
|
|
188
|
+
* directory.
|
|
189
|
+
*
|
|
190
|
+
* Packages the app declares stay bare specifiers through the `external`
|
|
191
|
+
* option, which Rolldown checks before this hook. Packages in
|
|
192
|
+
* `CORE_RUNTIME_BUNDLED_PACKAGES`, workspace and source packages, anything
|
|
193
|
+
* that does not resolve and anything on another drive than `outdir` are
|
|
194
|
+
* bundled.
|
|
195
|
+
*/
|
|
196
|
+
export function createInstalledPackageExternalPlugin(contextRoot, outdir, reportDir) {
|
|
197
|
+
const coreNames = getCorePackageNames();
|
|
198
|
+
const externalIds = new Set();
|
|
199
|
+
const outsideRootPackages = new Set();
|
|
200
|
+
let realOutdir;
|
|
201
|
+
let realContextRoot;
|
|
202
|
+
return {
|
|
203
|
+
name: 'ecopages-installed-package-external',
|
|
204
|
+
resolveId: {
|
|
205
|
+
filter: { id: /^[^./\\\0]/u },
|
|
206
|
+
async handler(id, importer, extraOptions) {
|
|
207
|
+
if (!isUndeclaredPackageImport(id, contextRoot)) {
|
|
208
|
+
return null;
|
|
209
|
+
}
|
|
210
|
+
const packageName = toPackageRootSpecifier(id);
|
|
211
|
+
const resolveOptions = { kind: extraOptions.kind, skipSelf: true };
|
|
212
|
+
const resolved = (importer ? await this.resolve(id, importer, resolveOptions) : null) ??
|
|
213
|
+
(coreNames.has(packageName) ? await this.resolve(id, coreSourceFile, resolveOptions) : null);
|
|
214
|
+
if (!resolved || resolved.external || !isInstalledCompiledModule(resolved.id)) {
|
|
215
|
+
return null;
|
|
216
|
+
}
|
|
217
|
+
realOutdir ??= realpathOfDirectory(outdir);
|
|
218
|
+
const relativePath = path.relative(realOutdir, resolved.id).split(path.sep).join('/');
|
|
219
|
+
if (path.isAbsolute(relativePath)) {
|
|
220
|
+
return null;
|
|
221
|
+
}
|
|
222
|
+
realContextRoot ??= realpathOfDirectory(contextRoot);
|
|
223
|
+
if (reportDir && !isPathInside(resolved.id, realContextRoot)) {
|
|
224
|
+
outsideRootPackages.add(packageName);
|
|
225
|
+
}
|
|
226
|
+
const externalId = relativePath.startsWith('../') ? relativePath : `./${relativePath}`;
|
|
227
|
+
externalIds.add(externalId);
|
|
228
|
+
return { id: externalId, external: true };
|
|
229
|
+
},
|
|
230
|
+
},
|
|
231
|
+
generateBundle(_outputOptions, bundle) {
|
|
232
|
+
const entryFileNames = [];
|
|
233
|
+
for (const output of Object.values(bundle)) {
|
|
234
|
+
if (output.type === 'chunk' && output.isEntry)
|
|
235
|
+
entryFileNames.push(output.fileName);
|
|
236
|
+
if (output.type !== 'chunk' || !output.fileName.includes('/'))
|
|
237
|
+
continue;
|
|
238
|
+
const nested = [...output.imports, ...output.dynamicImports].find((id) => externalIds.has(id));
|
|
239
|
+
if (nested) {
|
|
240
|
+
this.error(`[installed-package-external] "${output.fileName}" is written below the output directory but imports "${nested}", a path relative to the output directory. Use flat entry and chunk file names for builds with externalPackages.`);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
if (reportDir) {
|
|
244
|
+
const outputLabel = entryFileNames
|
|
245
|
+
.map((fileName) => path.relative(contextRoot, path.join(reportDir, fileName)).split(path.sep).join('/'))
|
|
246
|
+
.join(', ');
|
|
247
|
+
warnPackagesOutsideAppRoot(outputLabel, outsideRootPackages);
|
|
248
|
+
}
|
|
249
|
+
},
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
function isNodeBuiltinSpecifier(id) {
|
|
253
|
+
return id.startsWith('node:') || nodeBuiltinSpecifiers.has(id);
|
|
254
|
+
}
|
|
255
|
+
const nodeBuiltinFilter = new RegExp(`^(?:node:.*|${[...nodeBuiltinSpecifiers].map((specifier) => escapeRegExp(specifier)).join('|')})$`);
|
|
256
|
+
/**
|
|
257
|
+
* Rejects Node builtins and `.server` modules in browser-target builds.
|
|
258
|
+
*
|
|
259
|
+
* @remarks
|
|
260
|
+
* With `platform: 'browser'`, Rolldown leaves `node:*` imports in the output as
|
|
261
|
+
* bare specifiers. This plugin fails the build instead so server-only graphs
|
|
262
|
+
* cannot reach the browser as silent CORS errors.
|
|
263
|
+
*
|
|
264
|
+
* The `.server` check reads the resolved ids a module imports once it is parsed,
|
|
265
|
+
* not the specifiers as written, so an alias such as a `package.json` `imports`
|
|
266
|
+
* entry or a tsconfig path is rejected like a relative import. Rolldown has no
|
|
267
|
+
* importer at `load`, so `moduleParsed` is the earliest hook that can name it.
|
|
268
|
+
*/
|
|
269
|
+
export function createBrowserServerOnlyGuardPlugin() {
|
|
270
|
+
const rejectServerOnly = (id, importer) => {
|
|
271
|
+
const from = importer ? ` (imported from ${importer})` : '';
|
|
272
|
+
throw new Error(`[browser-build] server-only module "${id}" cannot be bundled for the browser${from}. Check the browser graph boundary for the importer.`);
|
|
273
|
+
};
|
|
274
|
+
return {
|
|
275
|
+
name: 'ecopages-browser-server-only-guard',
|
|
276
|
+
resolveId: {
|
|
277
|
+
filter: [include(idFilter(nodeBuiltinFilter))],
|
|
278
|
+
handler(id, importer) {
|
|
279
|
+
if (!isNodeBuiltinSpecifier(id)) {
|
|
280
|
+
return null;
|
|
281
|
+
}
|
|
282
|
+
const from = importer ? ` (imported from ${importer})` : '';
|
|
283
|
+
throw new Error(`[browser-build] Node builtin "${id}" cannot be bundled for the browser${from}. Check package "browser" exports and the client-graph boundary for the importer.`);
|
|
284
|
+
},
|
|
285
|
+
},
|
|
286
|
+
moduleParsed(info) {
|
|
287
|
+
if (info.isEntry && isServerOnlyModuleSpecifier(info.id)) {
|
|
288
|
+
rejectServerOnly(info.id, undefined);
|
|
289
|
+
}
|
|
290
|
+
for (const imported of [...info.importedIds, ...info.dynamicallyImportedIds]) {
|
|
291
|
+
if (isServerOnlyModuleSpecifier(imported)) {
|
|
292
|
+
rejectServerOnly(imported, info.id);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
},
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
function mapRolldownFormat(value) {
|
|
299
|
+
switch (value) {
|
|
300
|
+
case 'cjs':
|
|
301
|
+
return 'cjs';
|
|
302
|
+
case 'iife':
|
|
303
|
+
return 'iife';
|
|
304
|
+
default:
|
|
305
|
+
return 'esm';
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
function mapRolldownSourcemap(value) {
|
|
309
|
+
switch (value) {
|
|
310
|
+
case 'none':
|
|
311
|
+
return false;
|
|
312
|
+
case 'inline':
|
|
313
|
+
return 'inline';
|
|
314
|
+
case 'external':
|
|
315
|
+
case 'hidden':
|
|
316
|
+
return 'hidden';
|
|
317
|
+
case 'linked':
|
|
318
|
+
return true;
|
|
319
|
+
default:
|
|
320
|
+
return true;
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
function mapRolldownJsx(jsx) {
|
|
324
|
+
const { factory, fragment, ...rest } = jsx;
|
|
325
|
+
const out = { ...rest };
|
|
326
|
+
if (factory !== undefined) {
|
|
327
|
+
out.pragma = factory;
|
|
328
|
+
}
|
|
329
|
+
if (fragment !== undefined) {
|
|
330
|
+
out.pragmaFrag = fragment;
|
|
331
|
+
}
|
|
332
|
+
return out;
|
|
333
|
+
}
|
|
334
|
+
function toEntryFileNamesPattern(value) {
|
|
335
|
+
if (!value) {
|
|
336
|
+
return undefined;
|
|
337
|
+
}
|
|
338
|
+
const literal = !/\[[^\]]+\]/u.test(value);
|
|
339
|
+
const stripped = value.replaceAll(/\.?\[ext\]/g, '');
|
|
340
|
+
if (stripped.length === 0) {
|
|
341
|
+
return undefined;
|
|
342
|
+
}
|
|
343
|
+
return { pattern: stripped, literal };
|
|
344
|
+
}
|
|
345
|
+
function getJavaScriptOutExtension(options, literal) {
|
|
346
|
+
if (literal) {
|
|
347
|
+
return undefined;
|
|
348
|
+
}
|
|
349
|
+
if (options.environment === 'browser') {
|
|
350
|
+
return '.js';
|
|
351
|
+
}
|
|
352
|
+
if (options.format === 'cjs') {
|
|
353
|
+
return '.cjs';
|
|
354
|
+
}
|
|
355
|
+
return '.mjs';
|
|
356
|
+
}
|
|
357
|
+
function normalizeOutputPath(outputPath, outdir) {
|
|
358
|
+
return path.isAbsolute(outputPath) ? path.normalize(outputPath) : path.normalize(path.join(outdir, outputPath));
|
|
359
|
+
}
|
|
360
|
+
const BUILD_LOG_KEYS = ['code', 'hook', 'id', 'loc', 'plugin'];
|
|
361
|
+
/**
|
|
362
|
+
* Copies the {@link BuildLog} fields of a Rolldown error or warning into a plain log.
|
|
363
|
+
*
|
|
364
|
+
* @remarks
|
|
365
|
+
* Other own fields, such as a PostCSS error's `source` or `postcssNode` or Rolldown's `binding` and `ids`, are left out. `message` and
|
|
366
|
+
* `stack` are read explicitly because they are not enumerable on `Error` instances. Terminal colour codes
|
|
367
|
+
* are stripped from `message` and `frame` so the log can be shown outside a terminal.
|
|
368
|
+
*/
|
|
369
|
+
export function toBuildLog(entry) {
|
|
370
|
+
if (!entry || typeof entry !== 'object' || typeof entry.message !== 'string') {
|
|
371
|
+
return { message: 'Unknown build error' };
|
|
372
|
+
}
|
|
373
|
+
const source = entry;
|
|
374
|
+
const log = { message: stripVTControlCharacters(source.message) };
|
|
375
|
+
for (const key of BUILD_LOG_KEYS) {
|
|
376
|
+
if (source[key] !== undefined) {
|
|
377
|
+
Object.assign(log, { [key]: source[key] });
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
if (typeof source.frame === 'string') {
|
|
381
|
+
log.frame = stripVTControlCharacters(source.frame);
|
|
382
|
+
}
|
|
383
|
+
if (typeof source.stack === 'string') {
|
|
384
|
+
log.stack = source.stack;
|
|
385
|
+
}
|
|
386
|
+
const ecoBuildPluginName = getEcoBuildPluginName(entry);
|
|
387
|
+
if (ecoBuildPluginName) {
|
|
388
|
+
log.plugin = ecoBuildPluginName;
|
|
389
|
+
}
|
|
390
|
+
return log;
|
|
391
|
+
}
|
|
392
|
+
/**
|
|
393
|
+
* Converts a build failure into logs, one per underlying error of a Rolldown `BundleError`.
|
|
394
|
+
*
|
|
395
|
+
* @remarks
|
|
396
|
+
* Only an unattributed `BundleError` is expanded. An `AggregateError` or an error an `EcoBuildPlugin`
|
|
397
|
+
* threw is one failure and becomes one log.
|
|
398
|
+
*/
|
|
399
|
+
export function toBuildLogs(error) {
|
|
400
|
+
const errors = error instanceof Error && !(error instanceof AggregateError) && !getEcoBuildPluginName(error)
|
|
401
|
+
? error.errors
|
|
402
|
+
: undefined;
|
|
403
|
+
return (Array.isArray(errors) && errors.length > 0 ? errors : [error]).map(toBuildLog);
|
|
404
|
+
}
|
|
405
|
+
function buildRolldownTransformOptions(options) {
|
|
406
|
+
const transformOptions = {};
|
|
407
|
+
if (options.define) {
|
|
408
|
+
transformOptions.define = options.define;
|
|
409
|
+
}
|
|
410
|
+
if (options.jsx) {
|
|
411
|
+
transformOptions.jsx = mapRolldownJsx(options.jsx);
|
|
412
|
+
}
|
|
413
|
+
if (options.target && /^(?:es|chrome|edge|firefox|safari|hermes|deno|ios)/.test(options.target)) {
|
|
414
|
+
transformOptions.target = options.target;
|
|
415
|
+
}
|
|
416
|
+
return Object.keys(transformOptions).length > 0 ? transformOptions : undefined;
|
|
417
|
+
}
|
|
418
|
+
async function buildRolldownInputPlugins(options, contextRoot, outdir, rolldownPlatform, recordBuildInput) {
|
|
419
|
+
const entrypoints = Array.isArray(options.entrypoints)
|
|
420
|
+
? Object.fromEntries(options.entrypoints.map((entry, index) => [String(index), entry]))
|
|
421
|
+
: options.entrypoints;
|
|
422
|
+
const appPlugins = await createRolldownPluginBridge((options.plugins ?? []).filter((plugin) => plugin.environments?.includes(options.environment) ?? true), contextRoot, recordBuildInput, entrypoints);
|
|
423
|
+
return [
|
|
424
|
+
...(options.externalPackages === true
|
|
425
|
+
? [
|
|
426
|
+
createInstalledPackageExternalPlugin(contextRoot, outdir, options.reportPackagesOutsideRoot === true ? (options.runtimeOutdir ?? outdir) : undefined),
|
|
427
|
+
]
|
|
428
|
+
: []),
|
|
429
|
+
...(rolldownPlatform === 'browser' ? [createBrowserServerOnlyGuardPlugin()] : []),
|
|
430
|
+
...(options.environment === 'server' ? [createServerSideCssShimPlugin()] : []),
|
|
431
|
+
...appPlugins,
|
|
432
|
+
];
|
|
433
|
+
}
|
|
434
|
+
async function buildRolldownInputOptions(options, contextRoot, outdir, external, rolldownPlatform, recordBuildInput) {
|
|
435
|
+
return {
|
|
436
|
+
input: options.entrypoints,
|
|
437
|
+
cwd: contextRoot,
|
|
438
|
+
external,
|
|
439
|
+
platform: rolldownPlatform,
|
|
440
|
+
transform: buildRolldownTransformOptions(options),
|
|
441
|
+
resolve: options.conditions ? { conditionNames: options.conditions } : undefined,
|
|
442
|
+
treeshake: typeof options.treeshaking === 'boolean' ? options.treeshaking : true,
|
|
443
|
+
...(isEcopagesEnvEnabled('ECOPAGES_PROFILE_BUILD')
|
|
444
|
+
? {}
|
|
445
|
+
: {
|
|
446
|
+
checks: {
|
|
447
|
+
pluginTimings: false,
|
|
448
|
+
},
|
|
449
|
+
}),
|
|
450
|
+
experimental: {
|
|
451
|
+
nativeMagicString: true,
|
|
452
|
+
},
|
|
453
|
+
plugins: await buildRolldownInputPlugins(options, contextRoot, outdir, rolldownPlatform, recordBuildInput),
|
|
454
|
+
};
|
|
455
|
+
}
|
|
456
|
+
function resolveRolldownEntryFileNames(options) {
|
|
457
|
+
const entryFileNames = toEntryFileNamesPattern(options.naming);
|
|
458
|
+
const jsExtension = getJavaScriptOutExtension(options, entryFileNames?.literal ?? false);
|
|
459
|
+
if (entryFileNames) {
|
|
460
|
+
return jsExtension ? `${entryFileNames.pattern}${jsExtension}` : entryFileNames.pattern;
|
|
461
|
+
}
|
|
462
|
+
return jsExtension ? `[name]${jsExtension}` : '[name]';
|
|
463
|
+
}
|
|
464
|
+
function shouldDisableRolldownCodeSplitting(options) {
|
|
465
|
+
if (options.splitting !== false) {
|
|
466
|
+
return false;
|
|
467
|
+
}
|
|
468
|
+
const entrypointCount = Array.isArray(options.entrypoints)
|
|
469
|
+
? options.entrypoints.length
|
|
470
|
+
: Object.keys(options.entrypoints).length;
|
|
471
|
+
return entrypointCount === 1;
|
|
472
|
+
}
|
|
473
|
+
function buildRolldownOutputOptions(options, outdir) {
|
|
474
|
+
return {
|
|
475
|
+
dir: outdir,
|
|
476
|
+
format: mapRolldownFormat(options.format),
|
|
477
|
+
minify: !!options.minify,
|
|
478
|
+
entryFileNames: resolveRolldownEntryFileNames(options),
|
|
479
|
+
chunkFileNames: '[name]-[hash].js',
|
|
480
|
+
assetFileNames: '[name]-[hash][extname]',
|
|
481
|
+
sourcemap: mapRolldownSourcemap(options.sourcemap),
|
|
482
|
+
...(shouldDisableRolldownCodeSplitting(options) ? { codeSplitting: false } : {}),
|
|
483
|
+
};
|
|
484
|
+
}
|
|
485
|
+
/**
|
|
486
|
+
* Translates a {@link BuildOptions} into Rolldown's `InputOptions` and
|
|
487
|
+
* `OutputOptions`. Always sets `experimental.nativeMagicString: true`
|
|
488
|
+
* and always consolidates eco plugins via the bridge, which runs every
|
|
489
|
+
* plugin `setup`.
|
|
490
|
+
*/
|
|
491
|
+
export async function resolveRolldownOptions(options, contextRoot, outdir, appRootRequireCache, recordBuildInput) {
|
|
492
|
+
const rolldownPlatform = options.environment === 'browser' ? 'browser' : 'node';
|
|
493
|
+
const external = createExternalMatcher(options, appRootRequireCache);
|
|
494
|
+
return {
|
|
495
|
+
inputOptions: await buildRolldownInputOptions(options, contextRoot, outdir, external, rolldownPlatform, recordBuildInput),
|
|
496
|
+
outputOptions: buildRolldownOutputOptions(options, outdir),
|
|
497
|
+
};
|
|
498
|
+
}
|
|
499
|
+
/**
|
|
500
|
+
* Whether Rolldown put a content hash in the name of this output.
|
|
501
|
+
*
|
|
502
|
+
* @remarks
|
|
503
|
+
* Chunks that are not entries use `chunkFileNames` (`[name]-[hash].js`), and entries only hash when the request's
|
|
504
|
+
* naming template has `[hash]`. A named asset follows `assetFileNames` (`[name]-[hash][extname]`), so it counts
|
|
505
|
+
* when its file name is its own name plus a hash; an asset emitted with a fixed `fileName` does not. Source maps
|
|
506
|
+
* are decided with their chunk by {@link isHashedSourceMap}.
|
|
507
|
+
*/
|
|
508
|
+
function isContentHashedOutput(entry, entryNamingHashed) {
|
|
509
|
+
if (entry.type === 'chunk')
|
|
510
|
+
return entry.isEntry ? entryNamingHashed : true;
|
|
511
|
+
const fileName = path.posix.basename(entry.fileName);
|
|
512
|
+
return entry.names.some((name) => {
|
|
513
|
+
const extension = path.posix.extname(name);
|
|
514
|
+
const stem = path.posix.basename(name, extension);
|
|
515
|
+
return (fileName.startsWith(`${stem}-`) &&
|
|
516
|
+
fileName.endsWith(extension) &&
|
|
517
|
+
/^[A-Za-z0-9_-]+$/u.test(fileName.slice(stem.length + 1, fileName.length - extension.length)));
|
|
518
|
+
});
|
|
519
|
+
}
|
|
520
|
+
/** A `.map` file is as content-hashed as the output it describes. */
|
|
521
|
+
function isHashedSourceMap(fileName, hashedFileNames) {
|
|
522
|
+
return fileName.endsWith('.map') && hashedFileNames.has(fileName.slice(0, -'.map'.length));
|
|
523
|
+
}
|
|
524
|
+
/** Maps a Rolldown `output` to the output fields of a {@link BuildSuccess}. */
|
|
525
|
+
export function buildResultFromRolldownOutput(output, outdir, contextRoot, dependencyGraph, entrypoints, naming, includeContent = false) {
|
|
526
|
+
const entryNamingHashed = Boolean(naming?.includes('[hash]'));
|
|
527
|
+
const hashedFileNames = new Set(output.output.filter((entry) => isContentHashedOutput(entry, entryNamingHashed)).map((entry) => entry.fileName));
|
|
528
|
+
const outputs = output.output.map((entry) => {
|
|
529
|
+
const contentHashed = hashedFileNames.has(entry.fileName) || isHashedSourceMap(entry.fileName, hashedFileNames);
|
|
530
|
+
const normalized = {
|
|
531
|
+
path: normalizeOutputPath(entry.fileName, outdir),
|
|
532
|
+
contentHashed,
|
|
533
|
+
};
|
|
534
|
+
if (includeContent)
|
|
535
|
+
normalized.content = entry.type === 'chunk' ? entry.code : entry.source;
|
|
536
|
+
return normalized;
|
|
537
|
+
});
|
|
538
|
+
const chunks = output.output.filter((entry) => entry.type === 'chunk');
|
|
539
|
+
const chunkNames = new Set(chunks.map((chunk) => chunk.fileName));
|
|
540
|
+
const outputImport = (id) => (chunkNames.has(id) ? normalizeOutputPath(id, outdir) : id);
|
|
541
|
+
const outputGraph = Object.fromEntries(chunks.map((chunk) => [
|
|
542
|
+
normalizeOutputPath(chunk.fileName, outdir),
|
|
543
|
+
{
|
|
544
|
+
fileName: normalizeOutputPath(chunk.fileName, outdir),
|
|
545
|
+
imports: chunk.imports.map(outputImport),
|
|
546
|
+
dynamicImports: chunk.dynamicImports.map(outputImport),
|
|
547
|
+
isEntry: chunk.isEntry,
|
|
548
|
+
facadeModuleId: chunk.facadeModuleId ? resolveBuildEntryPath(chunk.facadeModuleId, contextRoot) : null,
|
|
549
|
+
},
|
|
550
|
+
]));
|
|
551
|
+
const entryOutputs = {};
|
|
552
|
+
for (const chunk of chunks) {
|
|
553
|
+
if (!chunk.isEntry || !chunk.facadeModuleId) {
|
|
554
|
+
continue;
|
|
555
|
+
}
|
|
556
|
+
recordBuildEntryOutput(entryOutputs, normalizeOutputPath(chunk.fileName, outdir), {
|
|
557
|
+
facadeModuleId: resolveBuildEntryPath(chunk.facadeModuleId, contextRoot),
|
|
558
|
+
chunkName: chunk.name,
|
|
559
|
+
entrypoints,
|
|
560
|
+
root: contextRoot,
|
|
561
|
+
});
|
|
562
|
+
}
|
|
563
|
+
return {
|
|
564
|
+
success: true,
|
|
565
|
+
outputs,
|
|
566
|
+
dependencyGraph,
|
|
567
|
+
outputGraph,
|
|
568
|
+
entryOutputs,
|
|
569
|
+
};
|
|
570
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bundler-backed build adapter.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* Implements {@link BuildAdapter} on top of Rolldown. This is the
|
|
6
|
+
* default adapter installed by config finalization and the adapter that
|
|
7
|
+
* issues real builds in production.
|
|
8
|
+
*
|
|
9
|
+
* Each `build()` creates a fresh `rolldown()` bundler.
|
|
10
|
+
*/
|
|
11
|
+
import type { BuildAdapter, BuildOptions, BuildResult, BuildSuccess } from '../build-adapter.js';
|
|
12
|
+
export declare class RolldownBuildAdapter implements BuildAdapter {
|
|
13
|
+
readonly ownership: "rolldown";
|
|
14
|
+
/** Per-adapter require cache, keyed on resolved context root. */
|
|
15
|
+
private readonly appRootRequireCache;
|
|
16
|
+
/**
|
|
17
|
+
* Issues one build. Creates a fresh `rolldown()` bundler per call.
|
|
18
|
+
*
|
|
19
|
+
* @remarks
|
|
20
|
+
* Warnings are collected on the result and still printed by Rolldown's default handler. Rolldown
|
|
21
|
+
* reports them only once a build completes, so a failed build has none.
|
|
22
|
+
*/
|
|
23
|
+
buildOrThrow(options: BuildOptions): Promise<BuildSuccess>;
|
|
24
|
+
build(options: BuildOptions): Promise<BuildResult>;
|
|
25
|
+
resolve(importPath: string, rootDir: string): string;
|
|
26
|
+
}
|
|
27
|
+
export declare function createRolldownBuildAdapter(): BuildAdapter;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bundler-backed build adapter.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* Implements {@link BuildAdapter} on top of Rolldown. This is the
|
|
6
|
+
* default adapter installed by config finalization and the adapter that
|
|
7
|
+
* issues real builds in production.
|
|
8
|
+
*
|
|
9
|
+
* Each `build()` creates a fresh `rolldown()` bundler.
|
|
10
|
+
*/
|
|
11
|
+
import { createRequire } from 'node:module';
|
|
12
|
+
import path from 'node:path';
|
|
13
|
+
import { rolldown } from 'rolldown';
|
|
14
|
+
import { buildResultFromRolldownOutput, resolveRolldownOptions, toBuildLog, toBuildLogs, } from './rolldown-adapter-helpers.js';
|
|
15
|
+
import { recordRolldownBuildInvocation } from './rolldown-build-invocation-metrics.js';
|
|
16
|
+
import { createEntryModuleClosuresPlugin } from './entry-module-closures.js';
|
|
17
|
+
import { createBuildInputRecorder, getBuildInputRecordingContext } from '../cache/build-input-dependency-index.js';
|
|
18
|
+
const moduleRequire = createRequire(import.meta.url);
|
|
19
|
+
export class RolldownBuildAdapter {
|
|
20
|
+
ownership = 'rolldown';
|
|
21
|
+
/** Per-adapter require cache, keyed on resolved context root. */
|
|
22
|
+
appRootRequireCache = new Map();
|
|
23
|
+
/**
|
|
24
|
+
* Issues one build. Creates a fresh `rolldown()` bundler per call.
|
|
25
|
+
*
|
|
26
|
+
* @remarks
|
|
27
|
+
* Warnings are collected on the result and still printed by Rolldown's default handler. Rolldown
|
|
28
|
+
* reports them only once a build completes, so a failed build has none.
|
|
29
|
+
*/
|
|
30
|
+
async buildOrThrow(options) {
|
|
31
|
+
if (options.environment !== 'server' && options.environment !== 'browser') {
|
|
32
|
+
throw new Error('Build requests require environment: "server" or "browser".');
|
|
33
|
+
}
|
|
34
|
+
recordRolldownBuildInvocation('rolldown');
|
|
35
|
+
const contextRoot = options.root ? path.resolve(options.root) : process.cwd();
|
|
36
|
+
const outdir = path.resolve(options.outdir ?? 'dist/assets');
|
|
37
|
+
const recordingContext = getBuildInputRecordingContext();
|
|
38
|
+
const loadedInputs = new Set();
|
|
39
|
+
const loadedInputsByModule = new Map();
|
|
40
|
+
const recordBuildInput = createBuildInputRecorder(recordingContext, loadedInputs, loadedInputsByModule);
|
|
41
|
+
const { inputOptions, outputOptions } = await resolveRolldownOptions(options, contextRoot, outdir, this.appRootRequireCache, recordBuildInput);
|
|
42
|
+
const dependencyGraph = { entrypoints: {} };
|
|
43
|
+
inputOptions.plugins = [inputOptions.plugins, createEntryModuleClosuresPlugin(dependencyGraph, contextRoot)];
|
|
44
|
+
const warnings = [];
|
|
45
|
+
const bundle = await rolldown({
|
|
46
|
+
...inputOptions,
|
|
47
|
+
onLog: (level, log, defaultHandler) => {
|
|
48
|
+
if (level === 'warn') {
|
|
49
|
+
warnings.push(toBuildLog(log));
|
|
50
|
+
}
|
|
51
|
+
defaultHandler(level, log);
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
try {
|
|
55
|
+
const output = options.writeToDisk === false
|
|
56
|
+
? await bundle.generate(outputOptions)
|
|
57
|
+
: await bundle.write(outputOptions);
|
|
58
|
+
return {
|
|
59
|
+
...buildResultFromRolldownOutput(output, outdir, contextRoot, dependencyGraph, options.entrypoints, options.naming, options.writeToDisk === false),
|
|
60
|
+
loadedInputs: [...loadedInputs],
|
|
61
|
+
loadedInputsByModule: Object.fromEntries([...loadedInputsByModule].map(([moduleId, paths]) => [moduleId, [...paths]])),
|
|
62
|
+
warnings,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
finally {
|
|
66
|
+
await bundle.close();
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
async build(options) {
|
|
70
|
+
try {
|
|
71
|
+
return await this.buildOrThrow(options);
|
|
72
|
+
}
|
|
73
|
+
catch (error) {
|
|
74
|
+
return {
|
|
75
|
+
success: false,
|
|
76
|
+
logs: toBuildLogs(error),
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
resolve(importPath, rootDir) {
|
|
81
|
+
return moduleRequire.resolve(importPath, { paths: [rootDir] });
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
export function createRolldownBuildAdapter() {
|
|
85
|
+
return new RolldownBuildAdapter();
|
|
86
|
+
}
|