@ecopages/core 0.2.0-alpha.8 → 0.2.1-beta.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 +79 -28
- package/package.json +94 -116
- package/src/adapters/README.md +2 -2
- package/src/adapters/abstract/application-adapter.d.ts +28 -2
- package/src/adapters/abstract/application-adapter.js +14 -2
- package/src/adapters/abstract/router-adapter.d.ts +1 -1
- package/src/adapters/abstract/server-adapter.d.ts +2 -2
- package/src/adapters/bun/client-bridge.d.ts +1 -1
- package/src/adapters/bun/create-app.d.ts +12 -12
- package/src/adapters/bun/create-app.js +64 -41
- package/src/adapters/bun/hmr-manager.d.ts +19 -115
- package/src/adapters/bun/hmr-manager.js +25 -301
- package/src/adapters/bun/index.d.ts +1 -1
- package/src/adapters/bun/index.js +2 -2
- package/src/adapters/bun/runtime-host.d.ts +52 -0
- package/src/adapters/bun/runtime-host.js +56 -0
- package/src/adapters/bun/server-adapter.d.ts +100 -32
- package/src/adapters/bun/server-adapter.js +142 -65
- package/src/adapters/bun/static-preview-host.d.ts +28 -0
- package/src/adapters/bun/static-preview-host.js +45 -0
- package/src/{create-app.d.ts → adapters/create-app.d.ts} +9 -6
- package/src/{create-app.js → adapters/create-app.js} +4 -4
- package/src/adapters/index.d.ts +1 -5
- package/src/adapters/index.js +1 -7
- package/src/adapters/node/create-app.d.ts +15 -12
- package/src/adapters/node/create-app.js +34 -85
- package/src/adapters/node/http-request-bridge.d.ts +57 -0
- package/src/adapters/node/http-request-bridge.js +118 -0
- package/src/adapters/node/node-client-bridge.d.ts +1 -1
- package/src/adapters/node/node-hmr-manager.d.ts +22 -103
- package/src/adapters/node/node-hmr-manager.js +26 -289
- package/src/adapters/node/runtime-host.d.ts +57 -0
- package/src/adapters/node/runtime-host.js +92 -0
- package/src/adapters/node/server-adapter-dependencies.d.ts +19 -0
- package/src/adapters/node/server-adapter-dependencies.js +18 -0
- package/src/adapters/node/server-adapter.d.ts +19 -42
- package/src/adapters/node/server-adapter.js +94 -139
- package/src/adapters/node/static-content-server.d.ts +1 -1
- package/src/adapters/node/static-content-server.js +1 -1
- package/src/adapters/node/static-preview-host.d.ts +55 -0
- package/src/adapters/node/static-preview-host.js +68 -0
- package/src/adapters/shared/application-adapter.d.ts +1 -1
- package/src/adapters/shared/define-api-handler.d.ts +1 -1
- package/src/adapters/shared/explicit-static-render-preparation.d.ts +25 -0
- package/src/adapters/shared/explicit-static-render-preparation.js +26 -0
- package/src/adapters/shared/explicit-static-route-matcher.d.ts +7 -4
- package/src/adapters/shared/explicit-static-route-matcher.js +14 -16
- package/src/adapters/shared/file-route-middleware-pipeline.d.ts +7 -10
- package/src/adapters/shared/file-route-middleware-pipeline.js +2 -11
- package/src/adapters/shared/fs-server-response-factory.d.ts +14 -10
- package/src/adapters/shared/fs-server-response-factory.js +11 -27
- package/src/adapters/shared/fs-server-response-matcher.d.ts +18 -18
- package/src/adapters/shared/fs-server-response-matcher.js +72 -46
- package/src/adapters/shared/hmr-entrypoint-registrar.js +1 -1
- package/src/adapters/shared/hmr-html-response.d.ts +1 -1
- package/src/adapters/shared/hmr-html-response.js +4 -3
- package/src/adapters/shared/render-context.d.ts +5 -3
- package/src/adapters/shared/render-context.js +24 -1
- package/src/adapters/shared/runtime-app-bootstrap.d.ts +26 -0
- package/src/adapters/shared/runtime-app-bootstrap.js +46 -0
- package/src/adapters/shared/runtime-host.d.ts +12 -0
- package/src/adapters/shared/server-adapter.d.ts +22 -11
- package/src/adapters/shared/server-adapter.js +183 -133
- package/src/adapters/shared/server-route-handler.d.ts +5 -5
- package/src/adapters/shared/server-route-handler.js +4 -4
- package/src/adapters/shared/server-static-builder.d.ts +8 -7
- package/src/adapters/shared/server-static-builder.js +6 -5
- package/src/adapters/shared/shared-hmr-manager.d.ts +59 -0
- package/src/adapters/shared/shared-hmr-manager.js +241 -0
- package/src/adapters/shared/static-preview-host.d.ts +10 -0
- package/src/build/README.md +57 -67
- package/src/build/browser-runtime-manifest.d.ts +31 -0
- package/src/build/browser-runtime-manifest.js +61 -0
- package/src/build/browser-runtime-plugin-helpers.d.ts +26 -0
- package/src/build/browser-runtime-plugin-helpers.js +14 -0
- package/src/build/browser-runtime-plugin.d.ts +78 -0
- package/src/build/browser-runtime-plugin.js +173 -0
- package/src/build/build-adapter.d.ts +384 -63
- package/src/build/build-adapter.js +129 -54
- package/src/build/build-manifest.d.ts +6 -0
- package/src/build/build-manifest.js +21 -2
- package/src/build/build-types.d.ts +2 -2
- package/src/build/rolldown-adapter-helpers.d.ts +58 -0
- package/src/build/rolldown-adapter-helpers.js +265 -0
- package/src/build/rolldown-build-adapter.d.ts +28 -0
- package/src/build/rolldown-build-adapter.js +65 -0
- package/src/build/rolldown-dev-build-adapter.d.ts +82 -0
- package/src/build/rolldown-dev-build-adapter.js +166 -0
- package/src/build/rolldown-plugin-bridge.d.ts +59 -0
- package/src/build/rolldown-plugin-bridge.js +199 -0
- package/src/build/runtime-build-executor.d.ts +15 -7
- package/src/build/runtime-build-executor.js +8 -9
- package/src/build/runtime-build-output-normalizer.d.ts +3 -0
- package/src/build/runtime-build-output-normalizer.js +111 -0
- package/src/build/serialized-build-executor.d.ts +64 -0
- package/src/build/serialized-build-executor.js +63 -0
- package/src/build/server-side-css-shim-plugin.d.ts +41 -0
- package/src/build/server-side-css-shim-plugin.js +35 -0
- package/src/cache/index.d.ts +6 -0
- package/src/cache/index.js +6 -0
- package/src/cache/module-parse-cache.d.ts +65 -0
- package/src/cache/module-parse-cache.js +75 -0
- package/src/config/README.md +5 -2
- package/src/config/config-builder.d.ts +41 -13
- package/src/config/config-builder.js +62 -24
- package/src/declarations.d.ts +1 -1
- package/src/dev/host-runtime.d.ts +10 -0
- package/src/dev/host-runtime.js +24 -0
- package/src/dev/sc-server.d.ts +1 -1
- package/src/dev/sc-server.js +1 -1
- package/src/eco/eco.browser.d.ts +2 -0
- package/src/eco/eco.browser.js +88 -0
- package/src/eco/eco.js +50 -45
- package/src/eco/eco.types.d.ts +60 -8
- package/src/eco/eco.utils.d.ts +1 -40
- package/src/eco/eco.utils.js +5 -35
- package/src/eco/global-injector-map.d.ts +3 -3
- package/src/eco/global-injector-map.js +2 -2
- package/src/eco/lazy-injector-map.d.ts +2 -2
- package/src/errors/index.d.ts +1 -0
- package/src/errors/index.js +3 -1
- package/src/hmr/client/hmr-runtime.js +9 -1
- package/src/hmr/hmr-strategy.d.ts +16 -13
- package/src/hmr/hmr-strategy.js +22 -7
- package/src/hmr/strategies/default-hmr-strategy.d.ts +2 -2
- package/src/hmr/strategies/default-hmr-strategy.js +1 -1
- package/src/hmr/strategies/js-hmr-strategy.d.ts +4 -9
- package/src/hmr/strategies/js-hmr-strategy.js +5 -10
- package/src/index.browser.d.ts +2 -2
- package/src/index.browser.js +1 -1
- package/src/index.d.ts +3 -2
- package/src/index.js +15 -4
- package/src/integrations/ghtml/ghtml-renderer.d.ts +2 -1
- package/src/integrations/ghtml/ghtml-renderer.js +24 -29
- package/src/integrations/ghtml/ghtml.constants.d.ts +1 -0
- package/src/integrations/ghtml/ghtml.constants.js +4 -0
- package/src/integrations/ghtml/ghtml.plugin.d.ts +2 -6
- package/src/integrations/ghtml/ghtml.plugin.js +3 -4
- package/src/plugins/README.md +1 -0
- package/src/plugins/alias-resolver-cache.d.ts +68 -0
- package/src/plugins/alias-resolver-cache.js +106 -0
- package/src/plugins/alias-resolver-plugin.d.ts +5 -1
- package/src/plugins/alias-resolver-plugin.js +19 -7
- package/src/plugins/eco-component-meta-plugin.d.ts +12 -1
- package/src/plugins/eco-component-meta-plugin.js +43 -25
- package/src/plugins/foreign-jsx-override-plugin.d.ts +33 -0
- package/src/plugins/foreign-jsx-override-plugin.js +41 -0
- package/src/plugins/integration-plugin.d.ts +136 -42
- package/src/plugins/integration-plugin.js +99 -31
- package/src/plugins/processor.d.ts +4 -2
- package/src/plugins/processor.js +8 -3
- package/src/plugins/source-transform.d.ts +46 -0
- package/src/plugins/source-transform.js +71 -0
- package/src/route-renderer/GRAPH.md +80 -318
- package/src/route-renderer/README.md +74 -78
- package/src/route-renderer/orchestration/component-render-context.d.ts +97 -0
- package/src/route-renderer/orchestration/component-render-context.js +147 -0
- package/src/route-renderer/orchestration/declared-ownership-graph.d.ts +18 -0
- package/src/route-renderer/orchestration/declared-ownership-graph.js +34 -0
- package/src/route-renderer/orchestration/foreign-subtree-execution.service.d.ts +110 -0
- package/src/route-renderer/orchestration/foreign-subtree-execution.service.js +233 -0
- package/src/route-renderer/orchestration/integration-renderer.d.ts +290 -128
- package/src/route-renderer/orchestration/integration-renderer.js +660 -258
- package/src/route-renderer/orchestration/ownership-planning.service.d.ts +24 -0
- package/src/route-renderer/orchestration/ownership-planning.service.js +63 -0
- package/src/route-renderer/orchestration/ownership-validation.service.d.ts +29 -0
- package/src/route-renderer/orchestration/ownership-validation.service.js +53 -0
- package/src/route-renderer/orchestration/processed-asset-dedupe.d.ts +3 -0
- package/src/route-renderer/orchestration/processed-asset-dedupe.js +27 -0
- package/src/route-renderer/orchestration/queued-foreign-subtree-resolution.service.d.ts +91 -0
- package/src/route-renderer/orchestration/queued-foreign-subtree-resolution.service.js +170 -0
- package/src/route-renderer/orchestration/render-output.utils.d.ts +66 -0
- package/src/route-renderer/orchestration/render-output.utils.js +171 -0
- package/src/route-renderer/orchestration/route-render-orchestrator.d.ts +156 -0
- package/src/route-renderer/orchestration/route-render-orchestrator.js +577 -0
- package/src/route-renderer/orchestration/template-serialization.d.ts +38 -0
- package/src/route-renderer/orchestration/template-serialization.js +45 -0
- package/src/route-renderer/page-loading/component-dependency-collection.d.ts +37 -0
- package/src/route-renderer/page-loading/component-dependency-collection.js +132 -0
- package/src/route-renderer/page-loading/declared-asset-collection.d.ts +24 -0
- package/src/route-renderer/page-loading/declared-asset-collection.js +106 -0
- package/src/route-renderer/page-loading/dependency-resolver.d.ts +2 -2
- package/src/route-renderer/page-loading/dependency-resolver.js +27 -354
- package/src/route-renderer/page-loading/ecopages-virtual-imports.d.ts +11 -0
- package/src/route-renderer/page-loading/ecopages-virtual-imports.js +57 -0
- package/src/route-renderer/page-loading/lazy-entry-collection.d.ts +45 -0
- package/src/route-renderer/page-loading/lazy-entry-collection.js +105 -0
- package/src/route-renderer/page-loading/lazy-trigger-planning.d.ts +19 -0
- package/src/route-renderer/page-loading/lazy-trigger-planning.js +40 -0
- package/src/route-renderer/page-loading/module-declaration-aggregation.d.ts +5 -0
- package/src/route-renderer/page-loading/module-declaration-aggregation.js +33 -0
- package/src/route-renderer/page-loading/module-declaration-scripts.d.ts +3 -0
- package/src/route-renderer/page-loading/module-declaration-scripts.js +18 -0
- package/src/route-renderer/page-loading/page-dependency-bundling.d.ts +13 -0
- package/src/route-renderer/page-loading/page-dependency-bundling.js +137 -0
- package/src/route-renderer/page-loading/page-module-loader.d.ts +7 -4
- package/src/route-renderer/page-loading/page-module-loader.js +8 -5
- package/src/route-renderer/route-renderer.d.ts +31 -23
- package/src/route-renderer/route-renderer.js +17 -24
- package/src/router/README.md +76 -8
- package/src/router/client/navigation-coordinator.d.ts +20 -0
- package/src/router/client/navigation-coordinator.js +2 -2
- package/src/router/server/route-registry.d.ts +78 -0
- package/src/router/server/route-registry.js +262 -0
- package/src/services/README.md +1 -2
- package/src/services/assets/asset-processing-service/asset-dependency-keys.d.ts +3 -0
- package/src/services/assets/asset-processing-service/asset-dependency-keys.js +56 -0
- package/src/services/assets/asset-processing-service/asset-processing.service.d.ts +3 -20
- package/src/services/assets/asset-processing-service/asset-processing.service.js +52 -98
- package/src/services/assets/asset-processing-service/asset.factory.d.ts +1 -1
- package/src/services/assets/asset-processing-service/asset.factory.js +2 -2
- package/src/services/assets/asset-processing-service/assets.types.d.ts +14 -0
- package/src/services/assets/asset-processing-service/browser-runtime-asset.factory.d.ts +2 -0
- package/src/services/assets/asset-processing-service/browser-runtime-asset.factory.js +1 -0
- package/src/services/assets/asset-processing-service/grouped-content-bundles.d.ts +30 -0
- package/src/services/assets/asset-processing-service/grouped-content-bundles.js +65 -0
- package/src/services/assets/asset-processing-service/index.d.ts +6 -5
- package/src/services/assets/asset-processing-service/index.js +6 -5
- package/src/services/assets/asset-processing-service/page-package.d.ts +6 -0
- package/src/services/assets/asset-processing-service/page-package.js +80 -0
- package/src/services/assets/asset-processing-service/processor.interface.d.ts +2 -2
- package/src/services/assets/asset-processing-service/processor.registry.d.ts +2 -2
- package/src/services/assets/asset-processing-service/processors/base/base-processor.d.ts +1 -1
- package/src/services/assets/asset-processing-service/processors/base/base-processor.js +3 -2
- package/src/services/assets/asset-processing-service/processors/base/base-script-processor.d.ts +10 -5
- package/src/services/assets/asset-processing-service/processors/base/base-script-processor.js +69 -5
- package/src/services/assets/asset-processing-service/processors/index.d.ts +5 -5
- package/src/services/assets/asset-processing-service/processors/index.js +5 -5
- package/src/services/assets/asset-processing-service/processors/script/content-script.processor.d.ts +3 -2
- package/src/services/assets/asset-processing-service/processors/script/content-script.processor.js +66 -3
- package/src/services/assets/asset-processing-service/processors/script/file-script.processor.d.ts +4 -3
- package/src/services/assets/asset-processing-service/processors/script/file-script.processor.js +27 -6
- package/src/services/assets/asset-processing-service/processors/script/node-module-script.processor.d.ts +38 -3
- package/src/services/assets/asset-processing-service/processors/script/node-module-script.processor.js +57 -6
- package/src/services/assets/asset-processing-service/processors/stylesheet/content-stylesheet.processor.d.ts +5 -2
- package/src/services/assets/asset-processing-service/processors/stylesheet/content-stylesheet.processor.js +39 -5
- package/src/services/assets/asset-processing-service/processors/stylesheet/file-stylesheet.processor.d.ts +2 -2
- package/src/services/assets/asset-processing-service/processors/stylesheet/file-stylesheet.processor.js +5 -2
- package/src/services/assets/asset-processing-service/ungrouped-dependency-processing.d.ts +18 -0
- package/src/services/assets/asset-processing-service/ungrouped-dependency-processing.js +45 -0
- package/src/services/assets/browser-bundle.service.d.ts +44 -3
- package/src/services/assets/browser-bundle.service.js +15 -7
- package/src/services/html/html-rewriter-provider.service.d.ts +3 -0
- package/src/services/html/html-rewriter-provider.service.js +4 -1
- package/src/services/html/html-transformer.service.d.ts +22 -3
- package/src/services/html/html-transformer.service.js +101 -35
- package/src/services/invalidation/development-invalidation.service.d.ts +1 -1
- package/src/services/invalidation/development-invalidation.service.js +1 -0
- package/src/services/module-loading/app-module-loader.service.d.ts +7 -0
- package/src/services/module-loading/app-module-loader.service.js +0 -0
- package/src/services/module-loading/app-server-module-transpiler.service.d.ts +9 -1
- package/src/services/module-loading/app-server-module-transpiler.service.js +102 -6
- package/src/services/module-loading/host-module-loader-registry.d.ts +4 -0
- package/src/services/module-loading/host-module-loader-registry.js +15 -0
- package/src/services/module-loading/module-loading-types.d.ts +2 -0
- package/src/services/module-loading/module-loading-types.js +0 -0
- package/src/services/module-loading/page-module-import.service.d.ts +32 -8
- package/src/services/module-loading/page-module-import.service.js +83 -22
- package/src/services/module-loading/server-module-transpiler.service.d.ts +8 -14
- package/src/services/module-loading/server-module-transpiler.service.js +5 -2
- package/src/services/module-loading/source-module-support.d.ts +5 -0
- package/src/services/module-loading/source-module-support.js +8 -0
- package/src/services/runtime-state/dev-graph.service.d.ts +6 -6
- package/src/services/runtime-state/dev-graph.service.js +10 -10
- package/src/services/runtime-state/entrypoint-dependency-graph.service.d.ts +1 -1
- package/src/services/runtime-state/server-invalidation-state.service.d.ts +1 -1
- package/src/static-site-generator/static-site-generator.d.ts +23 -28
- package/src/static-site-generator/static-site-generator.js +119 -156
- package/src/{internal-types.d.ts → types/internal-types.d.ts} +34 -23
- package/src/types/internal-types.js +0 -0
- package/src/{public-types.d.ts → types/public-types.d.ts} +195 -37
- package/src/types/public-types.js +0 -0
- package/src/utils/html-escaping.d.ts +7 -0
- package/src/utils/html-escaping.js +6 -0
- package/src/utils/locals-utils.d.ts +1 -1
- package/src/utils/parse-cli-args.d.ts +4 -1
- package/src/utils/parse-cli-args.js +16 -1
- package/src/utils/resolve-work-dir.js +1 -1
- package/src/watchers/project-watcher.d.ts +4 -4
- package/src/watchers/project-watcher.js +35 -41
- package/src/watchers/project-watcher.test-helpers.d.ts +2 -2
- package/src/watchers/project-watcher.test-helpers.js +5 -5
- package/CHANGELOG.md +0 -31
- package/src/adapters/abstract/application-adapter.ts +0 -337
- package/src/adapters/abstract/router-adapter.ts +0 -30
- package/src/adapters/abstract/server-adapter.ts +0 -79
- package/src/adapters/bun/client-bridge.ts +0 -62
- package/src/adapters/bun/create-app.ts +0 -189
- package/src/adapters/bun/hmr-manager.ts +0 -409
- package/src/adapters/bun/index.ts +0 -2
- package/src/adapters/bun/server-adapter.ts +0 -499
- package/src/adapters/bun/server-lifecycle.d.ts +0 -63
- package/src/adapters/bun/server-lifecycle.js +0 -92
- package/src/adapters/bun/server-lifecycle.ts +0 -124
- package/src/adapters/index.ts +0 -6
- package/src/adapters/node/bootstrap-dependency-resolver.d.ts +0 -44
- package/src/adapters/node/bootstrap-dependency-resolver.js +0 -172
- package/src/adapters/node/bootstrap-dependency-resolver.ts +0 -301
- package/src/adapters/node/create-app.ts +0 -179
- package/src/adapters/node/index.d.ts +0 -6
- package/src/adapters/node/index.js +0 -11
- package/src/adapters/node/index.ts +0 -16
- package/src/adapters/node/node-client-bridge.ts +0 -79
- package/src/adapters/node/node-hmr-manager.ts +0 -381
- package/src/adapters/node/runtime-adapter.d.ts +0 -46
- package/src/adapters/node/runtime-adapter.js +0 -306
- package/src/adapters/node/runtime-adapter.ts +0 -439
- package/src/adapters/node/server-adapter.ts +0 -488
- package/src/adapters/node/static-content-server.ts +0 -239
- package/src/adapters/node/write-runtime-manifest.d.ts +0 -26
- package/src/adapters/node/write-runtime-manifest.js +0 -12
- package/src/adapters/node/write-runtime-manifest.ts +0 -38
- package/src/adapters/shared/api-response.ts +0 -104
- package/src/adapters/shared/application-adapter.ts +0 -199
- package/src/adapters/shared/define-api-handler.ts +0 -66
- package/src/adapters/shared/explicit-static-route-matcher.ts +0 -140
- package/src/adapters/shared/file-route-middleware-pipeline.ts +0 -127
- package/src/adapters/shared/fs-server-response-factory.ts +0 -118
- package/src/adapters/shared/fs-server-response-matcher.ts +0 -205
- package/src/adapters/shared/hmr-entrypoint-registrar.ts +0 -149
- package/src/adapters/shared/hmr-html-response.ts +0 -52
- package/src/adapters/shared/render-context.ts +0 -120
- package/src/adapters/shared/runtime-bootstrap.d.ts +0 -38
- package/src/adapters/shared/runtime-bootstrap.js +0 -43
- package/src/adapters/shared/runtime-bootstrap.ts +0 -79
- package/src/adapters/shared/server-adapter.ts +0 -489
- package/src/adapters/shared/server-route-handler.ts +0 -153
- package/src/adapters/shared/server-static-builder.ts +0 -166
- package/src/build/build-adapter.ts +0 -361
- package/src/build/build-manifest.ts +0 -54
- package/src/build/build-types.ts +0 -83
- package/src/build/dev-build-coordinator.d.ts +0 -74
- package/src/build/dev-build-coordinator.js +0 -161
- package/src/build/dev-build-coordinator.ts +0 -221
- package/src/build/esbuild-build-adapter.d.ts +0 -72
- package/src/build/esbuild-build-adapter.js +0 -422
- package/src/build/esbuild-build-adapter.ts +0 -559
- package/src/build/runtime-build-executor.ts +0 -34
- package/src/build/runtime-specifier-alias-plugin.d.ts +0 -15
- package/src/build/runtime-specifier-alias-plugin.js +0 -31
- package/src/build/runtime-specifier-alias-plugin.ts +0 -58
- package/src/config/config-builder.ts +0 -706
- package/src/constants.ts +0 -54
- package/src/create-app.ts +0 -87
- package/src/dev/sc-server.ts +0 -143
- package/src/eco/component-render-context.d.ts +0 -105
- package/src/eco/component-render-context.js +0 -87
- package/src/eco/component-render-context.ts +0 -224
- package/src/eco/eco.ts +0 -242
- package/src/eco/eco.types.ts +0 -221
- package/src/eco/eco.utils.ts +0 -89
- package/src/eco/global-injector-map.ts +0 -112
- package/src/eco/lazy-injector-map.ts +0 -120
- package/src/eco/module-dependencies.ts +0 -75
- package/src/errors/http-error.ts +0 -72
- package/src/errors/index.ts +0 -2
- package/src/errors/locals-access-error.ts +0 -7
- package/src/global/app-logger.ts +0 -4
- package/src/hmr/client/hmr-runtime.ts +0 -152
- package/src/hmr/hmr-strategy.ts +0 -172
- package/src/hmr/hmr.postcss.test.e2e.ts +0 -41
- package/src/hmr/hmr.test.e2e.ts +0 -66
- package/src/hmr/strategies/default-hmr-strategy.ts +0 -60
- package/src/hmr/strategies/js-hmr-strategy.ts +0 -320
- package/src/index.browser.ts +0 -3
- package/src/index.ts +0 -5
- package/src/integrations/ghtml/ghtml-renderer.ts +0 -96
- package/src/integrations/ghtml/ghtml.plugin.ts +0 -32
- package/src/internal-types.ts +0 -232
- package/src/plugins/alias-resolver-plugin.ts +0 -63
- package/src/plugins/eco-component-meta-plugin.ts +0 -481
- package/src/plugins/integration-plugin.ts +0 -226
- package/src/plugins/processor.ts +0 -240
- package/src/plugins/runtime-capability.ts +0 -14
- package/src/public-types.ts +0 -1317
- package/src/route-renderer/component-graph/component-graph-executor.d.ts +0 -32
- package/src/route-renderer/component-graph/component-graph-executor.js +0 -31
- package/src/route-renderer/component-graph/component-graph-executor.ts +0 -84
- package/src/route-renderer/component-graph/component-graph.d.ts +0 -42
- package/src/route-renderer/component-graph/component-graph.js +0 -72
- package/src/route-renderer/component-graph/component-graph.ts +0 -159
- package/src/route-renderer/component-graph/component-marker.d.ts +0 -52
- package/src/route-renderer/component-graph/component-marker.js +0 -46
- package/src/route-renderer/component-graph/component-marker.ts +0 -117
- package/src/route-renderer/component-graph/component-reference.d.ts +0 -10
- package/src/route-renderer/component-graph/component-reference.js +0 -19
- package/src/route-renderer/component-graph/component-reference.ts +0 -29
- package/src/route-renderer/component-graph/marker-graph-resolver.d.ts +0 -77
- package/src/route-renderer/component-graph/marker-graph-resolver.js +0 -95
- package/src/route-renderer/component-graph/marker-graph-resolver.ts +0 -155
- package/src/route-renderer/orchestration/integration-renderer.ts +0 -790
- package/src/route-renderer/orchestration/render-execution.service.d.ts +0 -103
- package/src/route-renderer/orchestration/render-execution.service.js +0 -121
- package/src/route-renderer/orchestration/render-execution.service.ts +0 -230
- package/src/route-renderer/orchestration/render-preparation.service.d.ts +0 -121
- package/src/route-renderer/orchestration/render-preparation.service.js +0 -332
- package/src/route-renderer/orchestration/render-preparation.service.ts +0 -476
- package/src/route-renderer/page-loading/dependency-resolver.ts +0 -612
- package/src/route-renderer/page-loading/page-module-loader.ts +0 -181
- package/src/route-renderer/route-renderer.ts +0 -115
- package/src/router/client/link-intent.test.browser.ts +0 -51
- package/src/router/client/link-intent.ts +0 -92
- package/src/router/client/navigation-coordinator.ts +0 -433
- package/src/router/server/fs-router-scanner.d.ts +0 -41
- package/src/router/server/fs-router-scanner.js +0 -156
- package/src/router/server/fs-router-scanner.ts +0 -219
- package/src/router/server/fs-router.d.ts +0 -26
- package/src/router/server/fs-router.js +0 -100
- package/src/router/server/fs-router.ts +0 -122
- package/src/services/assets/asset-processing-service/asset-processing.service.ts +0 -401
- package/src/services/assets/asset-processing-service/asset.factory.ts +0 -105
- package/src/services/assets/asset-processing-service/assets.types.ts +0 -113
- package/src/services/assets/asset-processing-service/browser-runtime-asset.factory.ts +0 -95
- package/src/services/assets/asset-processing-service/browser-runtime-entry.factory.ts +0 -78
- package/src/services/assets/asset-processing-service/index.ts +0 -5
- package/src/services/assets/asset-processing-service/processor.interface.ts +0 -27
- package/src/services/assets/asset-processing-service/processor.registry.ts +0 -18
- package/src/services/assets/asset-processing-service/processors/base/base-processor.ts +0 -82
- package/src/services/assets/asset-processing-service/processors/base/base-script-processor.ts +0 -95
- package/src/services/assets/asset-processing-service/processors/index.ts +0 -5
- package/src/services/assets/asset-processing-service/processors/script/content-script.processor.ts +0 -66
- package/src/services/assets/asset-processing-service/processors/script/file-script.processor.ts +0 -88
- package/src/services/assets/asset-processing-service/processors/script/node-module-script.processor.ts +0 -85
- package/src/services/assets/asset-processing-service/processors/stylesheet/content-stylesheet.processor.ts +0 -27
- package/src/services/assets/asset-processing-service/processors/stylesheet/file-stylesheet.processor.ts +0 -80
- package/src/services/assets/browser-bundle.service.ts +0 -53
- package/src/services/cache/cache.types.ts +0 -126
- package/src/services/cache/index.ts +0 -18
- package/src/services/cache/memory-cache-store.ts +0 -130
- package/src/services/cache/page-cache-service.ts +0 -202
- package/src/services/cache/page-request-cache-coordinator.service.ts +0 -131
- package/src/services/html/html-rewriter-provider.service.ts +0 -103
- package/src/services/html/html-transformer.service.ts +0 -279
- package/src/services/invalidation/development-invalidation.service.ts +0 -261
- package/src/services/module-loading/app-server-module-transpiler.service.ts +0 -52
- package/src/services/module-loading/page-module-import.service.ts +0 -200
- package/src/services/module-loading/server-loader.service.d.ts +0 -96
- package/src/services/module-loading/server-loader.service.js +0 -32
- package/src/services/module-loading/server-loader.service.ts +0 -130
- package/src/services/module-loading/server-module-transpiler.service.ts +0 -105
- package/src/services/runtime-manifest/node-runtime-manifest.service.d.ts +0 -35
- package/src/services/runtime-manifest/node-runtime-manifest.service.js +0 -60
- package/src/services/runtime-manifest/node-runtime-manifest.service.ts +0 -101
- package/src/services/runtime-state/dev-graph.service.ts +0 -217
- package/src/services/runtime-state/entrypoint-dependency-graph.service.ts +0 -136
- package/src/services/runtime-state/runtime-specifier-registry.service.d.ts +0 -69
- package/src/services/runtime-state/runtime-specifier-registry.service.js +0 -37
- package/src/services/runtime-state/runtime-specifier-registry.service.ts +0 -96
- package/src/services/runtime-state/server-invalidation-state.service.ts +0 -68
- package/src/services/validation/schema-validation-service.ts +0 -204
- package/src/services/validation/standard-schema.types.ts +0 -68
- package/src/static-site-generator/static-site-generator.ts +0 -462
- package/src/utils/css.d.ts +0 -1
- package/src/utils/css.js +0 -7
- package/src/utils/css.ts +0 -5
- package/src/utils/deep-merge.ts +0 -47
- package/src/utils/hash.ts +0 -5
- package/src/utils/html.ts +0 -1
- package/src/utils/invariant.ts +0 -15
- package/src/utils/locals-utils.ts +0 -37
- package/src/utils/parse-cli-args.ts +0 -83
- package/src/utils/path-utils.module.ts +0 -14
- package/src/utils/resolve-work-dir.ts +0 -45
- package/src/utils/runtime.ts +0 -44
- package/src/utils/server-utils.module.ts +0 -67
- package/src/watchers/project-watcher.test-helpers.ts +0 -41
- package/src/watchers/project-watcher.ts +0 -363
- /package/src/{internal-types.js → adapters/shared/runtime-host.js} +0 -0
- /package/src/{public-types.js → adapters/shared/static-preview-host.js} +0 -0
- /package/src/{constants.d.ts → config/constants.d.ts} +0 -0
- /package/src/{constants.js → config/constants.js} +0 -0
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import { RESOLVED_ASSETS_DIR } from "../../config/constants.js";
|
|
5
|
+
import { getAppBuildExecutor } from "../../build/build-adapter.js";
|
|
6
|
+
import { fileSystem } from "@ecopages/file-system";
|
|
7
|
+
import { HmrStrategyType } from "../../hmr/hmr-strategy.js";
|
|
8
|
+
import { DefaultHmrStrategy } from "../../hmr/strategies/default-hmr-strategy.js";
|
|
9
|
+
import { JsHmrStrategy } from "../../hmr/strategies/js-hmr-strategy.js";
|
|
10
|
+
import { appLogger } from "../../global/app-logger.js";
|
|
11
|
+
import { HmrEntrypointRegistrar } from "./hmr-entrypoint-registrar.js";
|
|
12
|
+
import { BrowserBundleService } from "../../services/assets/browser-bundle.service.js";
|
|
13
|
+
import { getAppServerModuleTranspiler } from "../../services/module-loading/app-server-module-transpiler.service.js";
|
|
14
|
+
import {
|
|
15
|
+
getAppEntrypointDependencyGraph,
|
|
16
|
+
setAppEntrypointDependencyGraph
|
|
17
|
+
} from "../../services/runtime-state/entrypoint-dependency-graph.service.js";
|
|
18
|
+
import { resolveInternalExecutionDir, resolveInternalWorkDir } from "../../utils/resolve-work-dir.js";
|
|
19
|
+
class SharedHmrManager {
|
|
20
|
+
appConfig;
|
|
21
|
+
bridge;
|
|
22
|
+
watchers = /* @__PURE__ */ new Map();
|
|
23
|
+
watchedFiles = /* @__PURE__ */ new Map();
|
|
24
|
+
entrypointRegistrations = /* @__PURE__ */ new Map();
|
|
25
|
+
distDir;
|
|
26
|
+
plugins = [];
|
|
27
|
+
enabled = true;
|
|
28
|
+
strategies = [];
|
|
29
|
+
entrypointRegistrar;
|
|
30
|
+
browserBundleService;
|
|
31
|
+
entrypointDependencyGraph;
|
|
32
|
+
serverModuleTranspiler;
|
|
33
|
+
constructor({ appConfig, bridge, registrationTimeoutMs = 4e3 }) {
|
|
34
|
+
this.appConfig = appConfig;
|
|
35
|
+
this.bridge = bridge;
|
|
36
|
+
this.distDir = path.join(resolveInternalWorkDir(this.appConfig), RESOLVED_ASSETS_DIR, "_hmr");
|
|
37
|
+
this.entrypointRegistrar = new HmrEntrypointRegistrar({
|
|
38
|
+
srcDir: this.appConfig.absolutePaths.srcDir,
|
|
39
|
+
distDir: this.distDir,
|
|
40
|
+
entrypointRegistrations: this.entrypointRegistrations,
|
|
41
|
+
watchedFiles: this.watchedFiles,
|
|
42
|
+
clearFailedRegistration: (entrypointPath) => this.clearFailedEntrypointRegistration(entrypointPath),
|
|
43
|
+
registrationTimeoutMs
|
|
44
|
+
});
|
|
45
|
+
this.browserBundleService = new BrowserBundleService(appConfig);
|
|
46
|
+
this.entrypointDependencyGraph = this.createEntrypointDependencyGraph(
|
|
47
|
+
getAppEntrypointDependencyGraph(appConfig)
|
|
48
|
+
);
|
|
49
|
+
setAppEntrypointDependencyGraph(this.appConfig, this.entrypointDependencyGraph);
|
|
50
|
+
this.serverModuleTranspiler = getAppServerModuleTranspiler(this.appConfig);
|
|
51
|
+
this.ensureDistDir();
|
|
52
|
+
this.initializeStrategies();
|
|
53
|
+
}
|
|
54
|
+
shouldSkipMissingFileChange(_filePath) {
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
onRuntimeBundleFailure(error) {
|
|
58
|
+
appLogger.error("[HMR] Failed to build runtime script:", error);
|
|
59
|
+
}
|
|
60
|
+
ensureDistDir() {
|
|
61
|
+
fileSystem.ensureDir(this.distDir);
|
|
62
|
+
}
|
|
63
|
+
shouldJsStrategyProcessEntrypoint(entrypointPath) {
|
|
64
|
+
return !this.strategies.some((strategy) => {
|
|
65
|
+
if (strategy.type !== HmrStrategyType.INTEGRATION || strategy.priority <= HmrStrategyType.SCRIPT) {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
try {
|
|
69
|
+
return strategy.matches(entrypointPath);
|
|
70
|
+
} catch (error) {
|
|
71
|
+
appLogger.error(error);
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
initializeStrategies() {
|
|
77
|
+
const jsContext = {
|
|
78
|
+
getWatchedFiles: () => this.watchedFiles,
|
|
79
|
+
getDistDir: () => this.distDir,
|
|
80
|
+
getPlugins: () => this.plugins,
|
|
81
|
+
getSrcDir: () => this.appConfig.absolutePaths.srcDir,
|
|
82
|
+
getPagesDir: () => this.appConfig.absolutePaths.pagesDir,
|
|
83
|
+
getLayoutsDir: () => this.appConfig.absolutePaths.layoutsDir,
|
|
84
|
+
getTemplateExtensions: () => this.appConfig.templatesExt,
|
|
85
|
+
getBrowserBundleService: () => this.browserBundleService,
|
|
86
|
+
getEntrypointDependencyGraph: () => this.entrypointDependencyGraph,
|
|
87
|
+
shouldProcessEntrypoint: (entrypointPath) => this.shouldJsStrategyProcessEntrypoint(entrypointPath)
|
|
88
|
+
};
|
|
89
|
+
this.strategies = [new JsHmrStrategy(jsContext), new DefaultHmrStrategy()];
|
|
90
|
+
}
|
|
91
|
+
registerStrategy(strategy) {
|
|
92
|
+
this.strategies.push(strategy);
|
|
93
|
+
}
|
|
94
|
+
setPlugins(plugins) {
|
|
95
|
+
this.plugins = [...plugins];
|
|
96
|
+
}
|
|
97
|
+
setEnabled(enabled) {
|
|
98
|
+
this.enabled = enabled;
|
|
99
|
+
}
|
|
100
|
+
isEnabled() {
|
|
101
|
+
return this.enabled;
|
|
102
|
+
}
|
|
103
|
+
async buildRuntime() {
|
|
104
|
+
const runtimeSource = fileURLToPath(import.meta.resolve("@ecopages/core/hmr/client/hmr-runtime"));
|
|
105
|
+
try {
|
|
106
|
+
const result = await this.browserBundleService.bundle({
|
|
107
|
+
profile: "hmr-runtime",
|
|
108
|
+
entrypoints: [runtimeSource],
|
|
109
|
+
outdir: this.distDir,
|
|
110
|
+
naming: "_hmr_runtime.js",
|
|
111
|
+
minify: false,
|
|
112
|
+
plugins: this.plugins
|
|
113
|
+
});
|
|
114
|
+
if (!result.success) {
|
|
115
|
+
this.onRuntimeBundleFailure(result.logs);
|
|
116
|
+
}
|
|
117
|
+
} catch (error) {
|
|
118
|
+
this.onRuntimeBundleFailure(error);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
getRuntimePath() {
|
|
122
|
+
return path.join(this.distDir, "_hmr_runtime.js");
|
|
123
|
+
}
|
|
124
|
+
broadcast(event) {
|
|
125
|
+
appLogger.debug(
|
|
126
|
+
`[HMR] Broadcasting ${event.type} event, path=${event.path || "all"}, subscribers=${this.bridge.subscriberCount}`
|
|
127
|
+
);
|
|
128
|
+
this.bridge.broadcast(event);
|
|
129
|
+
}
|
|
130
|
+
async handleFileChange(filePath, options = {}) {
|
|
131
|
+
if (this.shouldSkipMissingFileChange(filePath) && !fileSystem.exists(filePath)) {
|
|
132
|
+
appLogger.debug(`[${this.constructor.name}] Skipping missing file change: ${filePath}`);
|
|
133
|
+
this.clearFailedEntrypointRegistration(filePath);
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
const sorted = [...this.strategies].sort((a, b) => b.priority - a.priority);
|
|
137
|
+
const strategy = sorted.find((candidate) => {
|
|
138
|
+
try {
|
|
139
|
+
return candidate.matches(filePath);
|
|
140
|
+
} catch (error) {
|
|
141
|
+
appLogger.error(error);
|
|
142
|
+
return false;
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
if (!strategy) {
|
|
146
|
+
appLogger.warn(`[HMR] No strategy found for ${filePath}`);
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
appLogger.debug(`[${this.constructor.name}] Selected strategy: ${strategy.constructor.name}`);
|
|
150
|
+
const action = await strategy.process(filePath);
|
|
151
|
+
const shouldBroadcast = options.broadcast ?? true;
|
|
152
|
+
if (shouldBroadcast && action.type === "broadcast" && action.events) {
|
|
153
|
+
for (const event of action.events) {
|
|
154
|
+
this.broadcast(event);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
getOutputUrl(entrypointPath) {
|
|
159
|
+
return this.watchedFiles.get(entrypointPath);
|
|
160
|
+
}
|
|
161
|
+
getWatchedFiles() {
|
|
162
|
+
return this.watchedFiles;
|
|
163
|
+
}
|
|
164
|
+
getDistDir() {
|
|
165
|
+
return this.distDir;
|
|
166
|
+
}
|
|
167
|
+
getPlugins() {
|
|
168
|
+
return this.plugins;
|
|
169
|
+
}
|
|
170
|
+
getDefaultContext() {
|
|
171
|
+
return {
|
|
172
|
+
getWatchedFiles: () => this.watchedFiles,
|
|
173
|
+
getDistDir: () => this.distDir,
|
|
174
|
+
getPlugins: () => this.plugins,
|
|
175
|
+
getSrcDir: () => this.appConfig.absolutePaths.srcDir,
|
|
176
|
+
getLayoutsDir: () => this.appConfig.absolutePaths.layoutsDir,
|
|
177
|
+
getPagesDir: () => this.appConfig.absolutePaths.pagesDir,
|
|
178
|
+
getBuildExecutor: () => getAppBuildExecutor(this.appConfig),
|
|
179
|
+
getBrowserBundleService: () => this.browserBundleService,
|
|
180
|
+
getEntrypointDependencyGraph: () => this.entrypointDependencyGraph,
|
|
181
|
+
importServerModule: async (filePath) => await this.serverModuleTranspiler.importModule({
|
|
182
|
+
filePath,
|
|
183
|
+
outdir: path.join(resolveInternalExecutionDir(this.appConfig), ".server-modules"),
|
|
184
|
+
externalPackages: true
|
|
185
|
+
})
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
clearFailedEntrypointRegistration(entrypointPath) {
|
|
189
|
+
this.watchedFiles.delete(entrypointPath);
|
|
190
|
+
this.entrypointDependencyGraph.clearEntrypointDependencies(entrypointPath);
|
|
191
|
+
}
|
|
192
|
+
async registerEntrypoint(entrypointPath) {
|
|
193
|
+
return await this.entrypointRegistrar.registerEntrypoint(entrypointPath, {
|
|
194
|
+
emit: async (normalizedEntrypoint) => await this.emitStrictEntrypoint(normalizedEntrypoint),
|
|
195
|
+
getMissingOutputError: (normalizedEntrypoint, outputPath) => new Error(
|
|
196
|
+
`[HMR] Integration failed to emit entrypoint ${normalizedEntrypoint} to ${outputPath}. Page entrypoints must be produced by their owning integration.`
|
|
197
|
+
)
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
async registerScriptEntrypoint(entrypointPath) {
|
|
201
|
+
return await this.entrypointRegistrar.registerEntrypoint(entrypointPath, {
|
|
202
|
+
emit: async (normalizedEntrypoint, outputPath) => await this.emitScriptEntrypoint(normalizedEntrypoint, outputPath),
|
|
203
|
+
getMissingOutputError: (normalizedEntrypoint) => new Error(`[HMR] Failed to register script entrypoint: ${normalizedEntrypoint}`)
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
async emitStrictEntrypoint(entrypointPath) {
|
|
207
|
+
await this.handleFileChange(entrypointPath, { broadcast: false });
|
|
208
|
+
}
|
|
209
|
+
async emitScriptEntrypoint(entrypointPath, outputPath) {
|
|
210
|
+
const naming = path.relative(this.distDir, outputPath).split(path.sep).join("/");
|
|
211
|
+
const buildResult = await this.browserBundleService.bundle({
|
|
212
|
+
profile: "hmr-entrypoint",
|
|
213
|
+
entrypoints: [entrypointPath],
|
|
214
|
+
outdir: this.distDir,
|
|
215
|
+
naming,
|
|
216
|
+
minify: false,
|
|
217
|
+
plugins: this.plugins
|
|
218
|
+
});
|
|
219
|
+
if (!buildResult.success) {
|
|
220
|
+
appLogger.error(`[HMR] Generic script entrypoint build failed for ${entrypointPath}:`, buildResult.logs);
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
const entrypointDependencies = buildResult.dependencyGraph?.entrypoints?.[entrypointPath];
|
|
224
|
+
if (entrypointDependencies) {
|
|
225
|
+
this.entrypointDependencyGraph.setEntrypointDependencies(entrypointPath, entrypointDependencies);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
stop() {
|
|
229
|
+
this.entrypointRegistrations.clear();
|
|
230
|
+
for (const watcher of this.watchers.values()) {
|
|
231
|
+
watcher.close();
|
|
232
|
+
}
|
|
233
|
+
this.watchers.clear();
|
|
234
|
+
this.watchedFiles.clear();
|
|
235
|
+
this.entrypointDependencyGraph.reset();
|
|
236
|
+
this.plugins = [];
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
export {
|
|
240
|
+
SharedHmrManager
|
|
241
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { EcoPagesAppConfig } from '../../types/internal-types.js';
|
|
2
|
+
export interface StaticPreviewHost {
|
|
3
|
+
start(options: StaticPreviewHostStartOptions): Promise<number | null>;
|
|
4
|
+
stop(force?: boolean): Promise<void>;
|
|
5
|
+
}
|
|
6
|
+
export interface StaticPreviewHostStartOptions {
|
|
7
|
+
appConfig: EcoPagesAppConfig;
|
|
8
|
+
hostname: string;
|
|
9
|
+
port: number;
|
|
10
|
+
}
|
package/src/build/README.md
CHANGED
|
@@ -1,101 +1,91 @@
|
|
|
1
1
|
# Build Layer
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The build layer is the bundler contract for Ecopages. One bundled adapter is the default; one host-owned boundary marker covers the Vite-host path.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Mental Model
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
- `build-types.ts`: plugin bridge types used by integrations and processors.
|
|
9
|
-
- `esbuild-build-adapter.ts`: the concrete esbuild backend.
|
|
10
|
-
- `dev-build-coordinator.ts`: development-only orchestration around the shared esbuild backend.
|
|
11
|
-
- `*.test.ts`: focused regression coverage for plain builds and development serialization and recovery.
|
|
7
|
+
Three concentric shapes, plus a serializer and a plugin injector:
|
|
12
8
|
|
|
13
|
-
|
|
9
|
+
| Shape | Lives in | Purpose |
|
|
10
|
+
| -------------------------- | ------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
11
|
+
| `BuildAdapter` | `build-adapter.ts` | Low-level backend. Two implementations: the bundled adapter (the real bundler) and `ViteHostBuildAdapter` (a host-owned boundary marker that throws on direct use). |
|
|
12
|
+
| `BuildExecutor` | `build-adapter.ts` | Narrower runtime facade. Only `build` is exposed. Stored on `appConfig.runtime.buildExecutor`. |
|
|
13
|
+
| `SerializedBuildExecutor` | `serialized-build-executor.ts` | FIFO queue around any `BuildExecutor`. Used by the dev watch pipeline. |
|
|
14
|
+
| `withBuildExecutorPlugins` | `build-adapter.ts` | Merges app-owned plugins into every `build` call. The single point of plugin injection. |
|
|
14
15
|
|
|
15
|
-
|
|
16
|
+
Plus one translation bridge:
|
|
16
17
|
|
|
17
|
-
`
|
|
18
|
+
- `rolldown-plugin-bridge.ts` — converts the runtime-agnostic `EcoBuildPlugin[]` array (the contract integrations and processors register) into the bundler's native `Plugin` array. Each `EcoBuildPlugin` becomes its own plugin entry to preserve plugin-priority order.
|
|
18
19
|
|
|
19
|
-
|
|
20
|
-
- It answers only how a given app instance should execute builds right now.
|
|
21
|
-
- `EsbuildBuildAdapter` satisfies this contract directly in plain flows.
|
|
22
|
-
- `DevBuildCoordinator` also satisfies this contract by wrapping the shared esbuild adapter with development-only serialization and recovery policy.
|
|
20
|
+
## Files
|
|
23
21
|
|
|
24
|
-
`
|
|
22
|
+
- `build-adapter.ts`: types, factories, app-owned helpers, `withBuildExecutorPlugins`.
|
|
23
|
+
- `build-types.ts`: the `EcoBuildPlugin` contract used by integrations and processors.
|
|
24
|
+
- `rolldown-build-adapter.ts`: the production `BuildAdapter`. Wraps the bundler and exposes a normalized `BuildResult` (outputs, dependency graph, logs).
|
|
25
|
+
- `rolldown-plugin-bridge.ts`: `EcoBuildPlugin[]` → bundler-plugin translation.
|
|
26
|
+
- `serialized-build-executor.ts`: FIFO queue primitive.
|
|
27
|
+
- `runtime-build-executor.ts`: dev-watch entrypoint that wraps the app-owned adapter in a `SerializedBuildExecutor + withBuildExecutorPlugins` chain.
|
|
28
|
+
- `*.test.ts`: regression coverage.
|
|
25
29
|
|
|
26
|
-
|
|
27
|
-
- translate Ecopages `BuildOptions` into esbuild options
|
|
28
|
-
- bridge Ecopages build plugins into esbuild hooks
|
|
29
|
-
- normalize build output, logs, and dependency graph metadata
|
|
30
|
-
- detect the subset of runtime faults that mean the esbuild worker protocol is corrupted
|
|
30
|
+
## Default Flow
|
|
31
31
|
|
|
32
|
-
`
|
|
32
|
+
`ConfigBuilder.build()` creates one app-owned adapter, manifest, executor, dev graph, and runtime registry. The executor it stores is the raw `BuildAdapter`; the plugin-wrap step lives in the runtime path.
|
|
33
33
|
|
|
34
|
-
-
|
|
35
|
-
- HMR entrypoint builds
|
|
36
|
-
- script and asset processors
|
|
37
|
-
- React integration build paths
|
|
34
|
+
When a server adapter initializes, it calls `installAppRuntimeBuildExecutor(appConfig)`. That function reads the existing executor (or falls back to the app-owned adapter) and stores a fresh wrapper:
|
|
38
35
|
|
|
39
|
-
|
|
36
|
+
```
|
|
37
|
+
BuildExecutor
|
|
38
|
+
└─ SerializedBuildExecutor // FIFO queue
|
|
39
|
+
└─ withBuildExecutorPlugins // injects app plugins
|
|
40
|
+
└─ BuildAdapter (bundled adapter or Vite-host)
|
|
41
|
+
```
|
|
40
42
|
|
|
41
|
-
-
|
|
42
|
-
- recycling warm Node-target esbuild sessions between builds
|
|
43
|
-
- recovery from known esbuild worker protocol faults
|
|
43
|
+
Every dev-watch caller reads `appConfig.runtime.buildExecutor` and gets the merged plugin set without further ceremony.
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
The exported `defaultBuildAdapter` and the top-level `build()` / `getTranspileOptions()` helpers are non-app-aware escape hatches. New runtime code should prefer `getAppBuildAdapter()`, `getAppBuildExecutor()`, and `getAppTranspileOptions()`.
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
## Vite-Host Boundary
|
|
48
48
|
|
|
49
|
-
|
|
49
|
+
`ViteHostBuildAdapter` is not a real backend. It exists so `appConfig.runtime.buildAdapter` can carry the `'vite-host'` ownership without falling back to a framework-owned bundler path. Every method throws a clear `Vite-hosted builds are owned by the host runtime. Core cannot …` error so misrouted calls fail loudly.
|
|
50
50
|
|
|
51
|
-
|
|
51
|
+
Vite-based apps (or any future host runtime) should:
|
|
52
52
|
|
|
53
|
-
|
|
53
|
+
1. Construct a `ViteHostBuildAdapter` via `createViteHostBuildAdapter()` and install it on the app config with `setAppBuildAdapter`.
|
|
54
|
+
2. Run their own build pipeline outside the core.
|
|
55
|
+
3. Reuse the core's `BuildExecutor`-shaped surface where possible so call-sites stay backend-neutral.
|
|
54
56
|
|
|
55
|
-
##
|
|
57
|
+
## Plugin Authoring
|
|
56
58
|
|
|
57
|
-
|
|
58
|
-
flowchart TD
|
|
59
|
-
Config["ConfigBuilder.build()"] --> DefaultExec["appConfig.runtime.buildExecutor = createAppBuildExecutor(app adapter, manifest)"]
|
|
60
|
-
Adapter["Server adapter initialize() in watch mode"] --> DevExec["appConfig.runtime.buildExecutor = DevBuildCoordinator"]
|
|
61
|
-
Caller["Any build caller with app/runtime context"] --> Build["executor.build(options) or build(options, executor)"]
|
|
62
|
-
Build --> Executor["BuildExecutor"]
|
|
63
|
-
Executor --> Coordinator["DevBuildCoordinator.build()"]
|
|
64
|
-
Coordinator --> Backend["EsbuildBuildAdapter.buildOrThrow()"]
|
|
65
|
-
Executor -->|plain flow| Direct["EsbuildBuildAdapter.build()"]
|
|
66
|
-
Backend --> Result["BuildResult"]
|
|
67
|
-
Direct --> Result["BuildResult"]
|
|
68
|
-
Result --> Browser["Browser consumes emitted bundle directly"]
|
|
69
|
-
```
|
|
59
|
+
`EcoBuildPlugin` is the runtime-agnostic contract integrations and processors register. The shape:
|
|
70
60
|
|
|
71
|
-
|
|
61
|
+
- `name: string`
|
|
62
|
+
- `setup(build: EcoBuildPluginBuilder): void | Promise<void>`
|
|
72
63
|
|
|
73
|
-
|
|
64
|
+
`EcoBuildPluginBuilder` exposes three hooks:
|
|
74
65
|
|
|
75
|
-
|
|
66
|
+
- `onResolve({ filter, namespace? }, callback)` — the bundler's `resolveId` mapped to the shared plugin shape.
|
|
67
|
+
- `onLoad({ filter, namespace? }, callback)` — the bundler's `load` mapped the same way.
|
|
68
|
+
- `module(specifier, callback)` — declares a virtual module by name, with bundler-side namespace encoding.
|
|
76
69
|
|
|
77
|
-
|
|
78
|
-
2. Stop the current esbuild service instance.
|
|
79
|
-
3. Increment the esbuild module generation so the next import gets a fresh worker instance.
|
|
70
|
+
Namespace handling: the shared plugin contract scopes handlers with a `namespace` string; the bundler encodes namespaces into the module id. The bridge prepends `<namespace>:` to resolved ids and matches filters against that prefix, then strips it before forwarding back to callbacks. Plugin code keeps the same `path` shape it had on the shared contract.
|
|
80
71
|
|
|
81
|
-
|
|
72
|
+
Plugin ordering: the bundler's `resolveId` and `load` are "first" hooks. The bridge translates each `EcoBuildPlugin` into its own plugin and preserves the array order, so position determines priority: index 0 wins first, the last index is the lowest priority. Security-critical plugins (e.g. `ecopages-client-graph-boundary`) should be placed before general-purpose loaders in the array.
|
|
82
73
|
|
|
83
|
-
##
|
|
74
|
+
## BuildOptions Caveats
|
|
84
75
|
|
|
85
|
-
|
|
76
|
+
`BuildOptions` is modeled on the bundler's options shape. Most fields map cleanly. The exceptions:
|
|
86
77
|
|
|
87
|
-
The
|
|
78
|
+
- `splitting` — accepted but currently ignored. The bundler splits by default. The per-chunk naming is fixed to `[name]-[hash]`. If you need to disable splitting or rename chunks, the adapter will need a new option.
|
|
79
|
+
- `bundle` — accepted but ignored. The bundler always bundles.
|
|
80
|
+
- `outbase` — accepted but ignored. The adapter derives the base from `options.root` directly.
|
|
88
81
|
|
|
89
|
-
-
|
|
90
|
-
- development policy stays in one place (`DevBuildCoordinator`)
|
|
91
|
-
- callers with app context use that executor explicitly instead of consulting global state
|
|
92
|
-
- tests can still instantiate `EsbuildBuildAdapter` or `DevBuildCoordinator` directly when they want the raw backend only
|
|
82
|
+
These fields are kept in the type so existing call-sites compile. The proper fix is a more focused `BuildOptions` schema in a follow-up.
|
|
93
83
|
|
|
94
84
|
## Testing Strategy
|
|
95
85
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
- `build-adapter.test.ts`
|
|
99
|
-
- `build-
|
|
86
|
+
- `rolldown-build-adapter.test.ts` covers the adapter's `build`, `resolve`, `getTranspileOptions`, and dependency-graph extraction end-to-end.
|
|
87
|
+
- `rolldown-plugin-bridge.test.ts` covers the `EcoBuildPlugin[]` → plugin translation in isolation.
|
|
88
|
+
- `build-adapter.test.ts` covers the app-owned helpers, the `BuildOwnership` routing, the `withBuildExecutorPlugins` injection, and the default-fallback behaviour.
|
|
89
|
+
- `runtime-build-executor.test.ts` covers the dev-watch wrapper: serialization, plugin injection, and the Vite-host rejection path.
|
|
100
90
|
|
|
101
|
-
If you change
|
|
91
|
+
If you change option mapping or plugin-bridge semantics, update the adapter and bridge tests first. If you change the app-owned helper contracts, update `build-adapter.test.ts` first.
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export type BrowserRuntimeMode = 'development' | 'production';
|
|
2
|
+
export type BrowserRuntimeAssetDeclaration = {
|
|
3
|
+
/** Bare or virtual specifier used by authored/generated browser modules. */
|
|
4
|
+
specifier: string;
|
|
5
|
+
/** Integration, processor, or core subsystem that owns this runtime asset. */
|
|
6
|
+
owner: string;
|
|
7
|
+
/** Source import path used to build or resolve the runtime asset. */
|
|
8
|
+
importPath: string;
|
|
9
|
+
/** Concrete browser URL emitted or served for this runtime asset. */
|
|
10
|
+
publicPath: string;
|
|
11
|
+
/** Runtime mode this declaration applies to. Omit when the URL is mode-independent. */
|
|
12
|
+
mode?: BrowserRuntimeMode;
|
|
13
|
+
/** Specifiers that should be treated as external while building this runtime asset. */
|
|
14
|
+
externals?: readonly string[];
|
|
15
|
+
};
|
|
16
|
+
export type BrowserRuntimeAsset = BrowserRuntimeAssetDeclaration & {
|
|
17
|
+
externals: readonly string[];
|
|
18
|
+
};
|
|
19
|
+
export type BrowserRuntimeManifest = {
|
|
20
|
+
assets: readonly BrowserRuntimeAsset[];
|
|
21
|
+
bySpecifier: ReadonlyMap<string, BrowserRuntimeAsset>;
|
|
22
|
+
};
|
|
23
|
+
export declare class BrowserRuntimeManifestConflictError extends Error {
|
|
24
|
+
readonly specifier: string;
|
|
25
|
+
readonly existing: BrowserRuntimeAsset;
|
|
26
|
+
readonly incoming: BrowserRuntimeAsset;
|
|
27
|
+
constructor(specifier: string, existing: BrowserRuntimeAsset, incoming: BrowserRuntimeAsset);
|
|
28
|
+
}
|
|
29
|
+
export declare function createBrowserRuntimeManifest(declarations?: readonly BrowserRuntimeAssetDeclaration[]): BrowserRuntimeManifest;
|
|
30
|
+
export declare function mergeBrowserRuntimeManifests(...manifests: Array<BrowserRuntimeManifest | undefined>): BrowserRuntimeManifest;
|
|
31
|
+
export declare function getBrowserRuntimeSpecifierMap(manifest: BrowserRuntimeManifest): ReadonlyMap<string, string>;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
class BrowserRuntimeManifestConflictError extends Error {
|
|
2
|
+
specifier;
|
|
3
|
+
existing;
|
|
4
|
+
incoming;
|
|
5
|
+
constructor(specifier, existing, incoming) {
|
|
6
|
+
super(
|
|
7
|
+
`Browser runtime asset conflict for ${specifier}: ${existing.owner} maps to ${existing.publicPath}, ${incoming.owner} maps to ${incoming.publicPath}`
|
|
8
|
+
);
|
|
9
|
+
this.name = "BrowserRuntimeManifestConflictError";
|
|
10
|
+
this.specifier = specifier;
|
|
11
|
+
this.existing = existing;
|
|
12
|
+
this.incoming = incoming;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function normalizeDeclaration(declaration) {
|
|
16
|
+
return {
|
|
17
|
+
...declaration,
|
|
18
|
+
externals: declaration.externals ?? []
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
function hasCompatibleRuntimeAsset(existing, incoming) {
|
|
22
|
+
return existing.owner === incoming.owner && existing.importPath === incoming.importPath && existing.publicPath === incoming.publicPath && existing.mode === incoming.mode && arrayEquals(existing.externals, incoming.externals);
|
|
23
|
+
}
|
|
24
|
+
function arrayEquals(left, right) {
|
|
25
|
+
if (left.length !== right.length) {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
return left.every((value, index) => value === right[index]);
|
|
29
|
+
}
|
|
30
|
+
function createBrowserRuntimeManifest(declarations = []) {
|
|
31
|
+
const assets = [];
|
|
32
|
+
const bySpecifier = /* @__PURE__ */ new Map();
|
|
33
|
+
for (const declaration of declarations) {
|
|
34
|
+
const asset = normalizeDeclaration(declaration);
|
|
35
|
+
const existing = bySpecifier.get(asset.specifier);
|
|
36
|
+
if (existing) {
|
|
37
|
+
if (!hasCompatibleRuntimeAsset(existing, asset)) {
|
|
38
|
+
throw new BrowserRuntimeManifestConflictError(asset.specifier, existing, asset);
|
|
39
|
+
}
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
assets.push(asset);
|
|
43
|
+
bySpecifier.set(asset.specifier, asset);
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
assets,
|
|
47
|
+
bySpecifier
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
function mergeBrowserRuntimeManifests(...manifests) {
|
|
51
|
+
return createBrowserRuntimeManifest(manifests.flatMap((manifest) => manifest?.assets ?? []));
|
|
52
|
+
}
|
|
53
|
+
function getBrowserRuntimeSpecifierMap(manifest) {
|
|
54
|
+
return new Map(manifest.assets.map((asset) => [asset.specifier, asset.publicPath]));
|
|
55
|
+
}
|
|
56
|
+
export {
|
|
57
|
+
BrowserRuntimeManifestConflictError,
|
|
58
|
+
createBrowserRuntimeManifest,
|
|
59
|
+
getBrowserRuntimeSpecifierMap,
|
|
60
|
+
mergeBrowserRuntimeManifests
|
|
61
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared helpers for the browser-runtime plugin.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* `createBrowserRuntimePlugin` needs to:
|
|
6
|
+
*
|
|
7
|
+
* 1. Escape each specifier for inclusion in a regex filter.
|
|
8
|
+
* 2. Build a `RegExp` whose alternation matches any of those specifiers.
|
|
9
|
+
*
|
|
10
|
+
* These utilities are extracted here so the plugin does not duplicate
|
|
11
|
+
* the same code path.
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Escapes a literal specifier for inclusion in a regular expression.
|
|
15
|
+
*
|
|
16
|
+
* Only the regex metacharacters are escaped: `. * + ? ^ $ { } ( ) | [ ] \`
|
|
17
|
+
*/
|
|
18
|
+
export declare function escapeRegExp(value: string): string;
|
|
19
|
+
/**
|
|
20
|
+
* Builds a `RegExp` whose alternation matches any of the keys in
|
|
21
|
+
* `specifierMap`.
|
|
22
|
+
*
|
|
23
|
+
* Returns `null` for an empty map so callers can short-circuit and
|
|
24
|
+
* avoid registering a no-op `onResolve` / `onLoad` filter.
|
|
25
|
+
*/
|
|
26
|
+
export declare function buildSpecifierFilter(specifierMap: ReadonlyMap<string, string>): RegExp | null;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
function escapeRegExp(value) {
|
|
2
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
3
|
+
}
|
|
4
|
+
function buildSpecifierFilter(specifierMap) {
|
|
5
|
+
if (specifierMap.size === 0) {
|
|
6
|
+
return null;
|
|
7
|
+
}
|
|
8
|
+
const alternation = Array.from(specifierMap.keys()).map(escapeRegExp).join("|");
|
|
9
|
+
return new RegExp(`^(${alternation})$`);
|
|
10
|
+
}
|
|
11
|
+
export {
|
|
12
|
+
buildSpecifierFilter,
|
|
13
|
+
escapeRegExp
|
|
14
|
+
};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unified browser-runtime plugin factory.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* Single factory that exposes the union of behaviors for the browser
|
|
6
|
+
* runtime:
|
|
7
|
+
*
|
|
8
|
+
* - `onResolve` for manifest specifiers → mapped public URL, marked external
|
|
9
|
+
* - `onResolve` for paths starting with `/` whose target is in the manifest's
|
|
10
|
+
* public path set → marked external
|
|
11
|
+
* - `onLoad` for JS/TS files → AST-walking import/export rewrite against the
|
|
12
|
+
* manifest specifier set, with a `code.includes(specifier)` fast path
|
|
13
|
+
*
|
|
14
|
+
* The plugin object carries the manifest's `specifier → publicPath` map
|
|
15
|
+
* under `BROWSER_RUNTIME_IMPORT_REWRITE_MAP` so
|
|
16
|
+
* `collectBrowserRuntimeImportRewriteMap` and the post-build rewriter can
|
|
17
|
+
* read it without re-walking the manifest.
|
|
18
|
+
*
|
|
19
|
+
* This is the single source of truth for browser-runtime plugin behavior.
|
|
20
|
+
* Per-bundler bridges can treat it as a single plugin.
|
|
21
|
+
*/
|
|
22
|
+
import type { EcoBuildPlugin } from './build-types.js';
|
|
23
|
+
import { type BrowserRuntimeManifest } from './browser-runtime-manifest.js';
|
|
24
|
+
/**
|
|
25
|
+
* Symbol used to attach the manifest's `specifier → publicPath` map to a
|
|
26
|
+
* plugin instance. Consumers read it via `getBrowserRuntimeImportRewriteMap`
|
|
27
|
+
* or `collectBrowserRuntimeImportRewriteMap`.
|
|
28
|
+
*/
|
|
29
|
+
export declare const BROWSER_RUNTIME_IMPORT_REWRITE_MAP: unique symbol;
|
|
30
|
+
/**
|
|
31
|
+
* Default name used by `createBrowserRuntimePlugin` when the caller
|
|
32
|
+
* does not provide one.
|
|
33
|
+
*/
|
|
34
|
+
export declare const DEFAULT_BROWSER_RUNTIME_PLUGIN_NAME = "browser-runtime-plugin";
|
|
35
|
+
export type CreateBrowserRuntimePluginOptions = {
|
|
36
|
+
/** Manifest whose specifier → publicPath entries drive the plugin. */
|
|
37
|
+
manifest: BrowserRuntimeManifest;
|
|
38
|
+
/** Stable build plugin name used for deduplication and selective exclusion. */
|
|
39
|
+
name?: string;
|
|
40
|
+
/**
|
|
41
|
+
* Whether alias `onResolve` results should be marked `external`.
|
|
42
|
+
* Default `true`. Pass `false` to let the bundler try to bundle the
|
|
43
|
+
* mapped URL.
|
|
44
|
+
*/
|
|
45
|
+
external?: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Enable source-level AST import/export rewrite via the `onLoad`
|
|
48
|
+
* hook. Default `true`. Set `false` for alias-only consumers
|
|
49
|
+
* (e.g. `react`/`react-dom` externals in vendor assets).
|
|
50
|
+
*/
|
|
51
|
+
rewriteImports?: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Register an `onResolve` for paths starting with `/` whose target
|
|
54
|
+
* is in the manifest's public path set. Marks them external so the
|
|
55
|
+
* bundler does not try to resolve them as source modules. Default
|
|
56
|
+
* `true`.
|
|
57
|
+
*/
|
|
58
|
+
matchPublicPaths?: boolean;
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* Rewrites static ESM import/export specifiers and string-literal dynamic imports
|
|
62
|
+
* from manifest-owned runtime specifiers to concrete browser public URLs.
|
|
63
|
+
*
|
|
64
|
+
* Exposed for the post-build rewriter and for tests.
|
|
65
|
+
*/
|
|
66
|
+
export declare function rewriteBrowserRuntimeImports(code: string, specifierMap: ReadonlyMap<string, string>, filePath?: string): string;
|
|
67
|
+
export declare function getBrowserRuntimeImportRewriteMap(plugin: EcoBuildPlugin): ReadonlyMap<string, string> | undefined;
|
|
68
|
+
export declare function collectBrowserRuntimeImportRewriteMap(plugins: EcoBuildPlugin[] | undefined): ReadonlyMap<string, string>;
|
|
69
|
+
/**
|
|
70
|
+
* Creates a build plugin that exposes the union of browser-runtime
|
|
71
|
+
* manifest behaviors (alias resolution, public-path matching, and source
|
|
72
|
+
* import/export rewrite). See {@link CreateBrowserRuntimePluginOptions}
|
|
73
|
+
* for per-behavior toggles.
|
|
74
|
+
*
|
|
75
|
+
* Returns `null` for an empty manifest so callers can short-circuit
|
|
76
|
+
* registration without sprinkling `if (plugin)` everywhere.
|
|
77
|
+
*/
|
|
78
|
+
export declare function createBrowserRuntimePlugin(options: CreateBrowserRuntimePluginOptions): EcoBuildPlugin | null;
|