@ecopages/core 0.2.0-alpha.27 → 0.2.0-alpha.28
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/CHANGELOG.md +91 -0
- package/package.json +162 -72
- package/src/adapters/abstract/application-adapter.d.ts +194 -0
- package/src/adapters/abstract/application-adapter.js +121 -0
- package/src/adapters/abstract/router-adapter.d.ts +26 -0
- package/src/adapters/abstract/router-adapter.js +5 -0
- package/src/adapters/abstract/server-adapter.d.ts +69 -0
- package/src/adapters/abstract/server-adapter.js +15 -0
- package/src/adapters/bun/client-bridge.d.ts +34 -0
- package/src/adapters/bun/client-bridge.js +48 -0
- package/src/adapters/bun/create-app.d.ts +53 -0
- package/src/adapters/bun/create-app.js +153 -0
- package/src/adapters/bun/hmr-manager.d.ts +131 -0
- package/src/adapters/bun/hmr-manager.js +312 -0
- package/src/adapters/bun/index.d.ts +2 -0
- package/src/adapters/bun/index.js +8 -0
- package/src/adapters/bun/server-adapter.d.ts +155 -0
- package/src/adapters/bun/server-adapter.js +393 -0
- package/src/adapters/bun/server-lifecycle.d.ts +63 -0
- package/src/adapters/bun/server-lifecycle.js +92 -0
- package/src/adapters/create-app.d.ts +20 -0
- package/src/adapters/create-app.js +66 -0
- package/src/adapters/index.d.ts +2 -0
- package/src/adapters/index.js +8 -0
- package/src/adapters/node/create-app.d.ts +18 -0
- package/src/adapters/node/create-app.js +149 -0
- package/src/adapters/node/node-client-bridge.d.ts +26 -0
- package/src/adapters/node/node-client-bridge.js +66 -0
- package/src/adapters/node/node-hmr-manager.d.ts +121 -0
- package/src/adapters/node/node-hmr-manager.js +290 -0
- package/src/adapters/node/server-adapter.d.ts +162 -0
- package/src/adapters/node/server-adapter.js +368 -0
- package/src/adapters/node/static-content-server.d.ts +60 -0
- package/src/adapters/node/static-content-server.js +194 -0
- package/src/adapters/shared/api-response.d.ts +52 -0
- package/src/adapters/shared/api-response.js +96 -0
- package/src/adapters/shared/application-adapter.d.ts +18 -0
- package/src/adapters/shared/application-adapter.js +90 -0
- package/src/adapters/shared/define-api-handler.d.ts +25 -0
- package/src/adapters/shared/define-api-handler.js +15 -0
- 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 +41 -0
- package/src/adapters/shared/explicit-static-route-matcher.js +101 -0
- package/src/adapters/shared/file-route-middleware-pipeline.d.ts +62 -0
- package/src/adapters/shared/file-route-middleware-pipeline.js +90 -0
- package/src/adapters/shared/fs-server-response-factory.d.ts +23 -0
- package/src/adapters/shared/fs-server-response-factory.js +81 -0
- package/src/adapters/shared/fs-server-response-matcher.d.ts +75 -0
- package/src/adapters/shared/fs-server-response-matcher.js +186 -0
- package/src/adapters/shared/hmr-entrypoint-registrar.d.ts +55 -0
- package/src/adapters/shared/hmr-entrypoint-registrar.js +87 -0
- package/src/adapters/shared/hmr-html-response.d.ts +22 -0
- package/src/adapters/shared/hmr-html-response.js +32 -0
- package/src/adapters/shared/render-context.d.ts +15 -0
- package/src/adapters/shared/render-context.js +72 -0
- package/src/adapters/shared/runtime-bootstrap.d.ts +38 -0
- package/src/adapters/shared/runtime-bootstrap.js +43 -0
- package/src/adapters/shared/server-adapter.d.ts +108 -0
- package/src/adapters/shared/server-adapter.js +429 -0
- package/src/adapters/shared/server-route-handler.d.ts +89 -0
- package/src/adapters/shared/server-route-handler.js +111 -0
- package/src/adapters/shared/server-static-builder.d.ts +71 -0
- package/src/adapters/shared/server-static-builder.js +100 -0
- package/src/build/build-adapter.d.ts +239 -0
- package/src/build/build-adapter.js +642 -0
- package/src/build/build-manifest.d.ts +27 -0
- package/src/build/build-manifest.js +30 -0
- package/src/build/build-types.d.ts +57 -0
- package/src/build/build-types.js +0 -0
- package/src/build/dev-build-coordinator.d.ts +72 -0
- package/src/build/dev-build-coordinator.js +154 -0
- package/src/build/esbuild-build-adapter.d.ts +78 -0
- package/src/build/esbuild-build-adapter.js +505 -0
- package/src/build/runtime-build-executor.d.ts +14 -0
- package/src/build/runtime-build-executor.js +22 -0
- package/src/build/runtime-specifier-alias-plugin.d.ts +15 -0
- package/src/build/runtime-specifier-alias-plugin.js +35 -0
- package/src/build/runtime-specifier-aliases.d.ts +5 -0
- package/src/build/runtime-specifier-aliases.js +95 -0
- package/src/config/config-builder.d.ts +252 -0
- package/src/config/config-builder.js +598 -0
- package/src/config/{constants.ts → constants.d.ts} +13 -22
- package/src/config/constants.js +25 -0
- package/src/dev/host-runtime.d.ts +10 -0
- package/src/dev/host-runtime.js +24 -0
- package/src/dev/sc-server.d.ts +30 -0
- package/src/dev/sc-server.js +111 -0
- package/src/eco/eco.browser.d.ts +2 -0
- package/src/eco/eco.browser.js +83 -0
- package/src/eco/eco.d.ts +9 -0
- package/src/eco/eco.js +85 -0
- package/src/eco/eco.types.d.ts +178 -0
- package/src/eco/eco.types.js +0 -0
- package/src/eco/eco.utils.d.ts +1 -0
- package/src/eco/eco.utils.js +10 -0
- package/src/eco/global-injector-map.d.ts +16 -0
- package/src/eco/global-injector-map.js +80 -0
- package/src/eco/lazy-injector-map.d.ts +8 -0
- package/src/eco/lazy-injector-map.js +70 -0
- package/src/eco/module-dependencies.d.ts +18 -0
- package/src/eco/module-dependencies.js +49 -0
- package/src/errors/http-error.d.ts +31 -0
- package/src/errors/http-error.js +50 -0
- package/src/errors/index.d.ts +3 -0
- package/src/errors/index.js +6 -0
- package/src/errors/locals-access-error.d.ts +4 -0
- package/src/errors/locals-access-error.js +9 -0
- package/src/global/app-logger.d.ts +2 -0
- package/src/global/app-logger.js +6 -0
- package/src/hmr/client/hmr-runtime.d.ts +5 -0
- package/src/hmr/client/hmr-runtime.js +117 -0
- package/src/hmr/hmr-strategy.d.ts +162 -0
- package/src/hmr/hmr-strategy.js +44 -0
- package/src/hmr/hmr.postcss.test.e2e.d.ts +1 -0
- package/src/hmr/hmr.postcss.test.e2e.js +31 -0
- package/src/hmr/hmr.test.e2e.d.ts +1 -0
- package/src/hmr/hmr.test.e2e.js +43 -0
- package/src/hmr/strategies/default-hmr-strategy.d.ts +43 -0
- package/src/hmr/strategies/default-hmr-strategy.js +34 -0
- package/src/hmr/strategies/js-hmr-strategy.d.ts +134 -0
- package/src/hmr/strategies/js-hmr-strategy.js +178 -0
- package/src/index.browser.d.ts +3 -0
- package/src/index.browser.js +4 -0
- package/src/index.d.ts +6 -0
- package/src/index.js +21 -0
- package/src/integrations/ghtml/ghtml-renderer.d.ts +16 -0
- package/src/integrations/ghtml/ghtml-renderer.js +57 -0
- 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 +16 -0
- package/src/integrations/ghtml/ghtml.plugin.js +20 -0
- package/src/plugins/alias-resolver-plugin.d.ts +2 -0
- package/src/plugins/alias-resolver-plugin.js +53 -0
- package/src/plugins/eco-component-meta-plugin.d.ts +108 -0
- package/src/plugins/eco-component-meta-plugin.js +162 -0
- package/src/plugins/foreign-jsx-override-plugin.d.ts +31 -0
- package/src/plugins/foreign-jsx-override-plugin.js +35 -0
- package/src/plugins/integration-plugin.d.ts +215 -0
- package/src/plugins/integration-plugin.js +189 -0
- package/src/plugins/processor.d.ts +97 -0
- package/src/plugins/processor.js +141 -0
- package/src/plugins/{runtime-capability.ts → runtime-capability.d.ts} +3 -8
- package/src/plugins/runtime-capability.js +0 -0
- package/src/plugins/source-transform.d.ts +46 -0
- package/src/plugins/source-transform.js +71 -0
- package/src/route-renderer/orchestration/component-render-context.d.ts +89 -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 +108 -0
- package/src/route-renderer/orchestration/foreign-subtree-execution.service.js +206 -0
- package/src/route-renderer/orchestration/integration-renderer.d.ts +516 -0
- package/src/route-renderer/orchestration/integration-renderer.js +909 -0
- 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 +2 -0
- package/src/route-renderer/orchestration/processed-asset-dedupe.js +23 -0
- package/src/route-renderer/orchestration/queued-foreign-subtree-resolution.service.d.ts +90 -0
- package/src/route-renderer/orchestration/queued-foreign-subtree-resolution.service.js +158 -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 +120 -0
- package/src/route-renderer/orchestration/route-render-orchestrator.js +388 -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 +35 -0
- package/src/route-renderer/page-loading/dependency-resolver.js +115 -0
- 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 +90 -0
- package/src/route-renderer/page-loading/page-module-loader.js +127 -0
- package/src/route-renderer/route-renderer.d.ts +69 -0
- package/src/route-renderer/route-renderer.js +80 -0
- package/src/router/client/link-intent.js +34 -0
- package/src/router/client/link-intent.test.browser.d.ts +1 -0
- package/src/router/client/link-intent.test.browser.js +43 -0
- package/src/router/client/navigation-coordinator.d.ts +169 -0
- package/src/router/client/navigation-coordinator.js +215 -0
- package/src/router/server/route-registry.d.ts +78 -0
- package/src/router/server/route-registry.js +262 -0
- 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 +103 -0
- package/src/services/assets/asset-processing-service/asset-processing.service.js +285 -0
- package/src/services/assets/asset-processing-service/asset.factory.d.ts +17 -0
- package/src/services/assets/asset-processing-service/asset.factory.js +82 -0
- package/src/services/assets/asset-processing-service/assets.types.d.ts +103 -0
- package/src/services/assets/asset-processing-service/assets.types.js +0 -0
- package/src/services/assets/asset-processing-service/browser-runtime-asset.factory.d.ts +55 -0
- package/src/services/assets/asset-processing-service/browser-runtime-asset.factory.js +49 -0
- package/src/services/assets/asset-processing-service/browser-runtime-entry.factory.d.ts +20 -0
- package/src/services/assets/asset-processing-service/browser-runtime-entry.factory.js +41 -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 -0
- package/src/services/assets/asset-processing-service/index.js +6 -0
- package/src/services/assets/asset-processing-service/page-package.d.ts +3 -0
- package/src/services/assets/asset-processing-service/page-package.js +74 -0
- package/src/services/assets/asset-processing-service/{processor.interface.ts → processor.interface.d.ts} +5 -10
- package/src/services/assets/asset-processing-service/processor.interface.js +6 -0
- package/src/services/assets/asset-processing-service/processor.registry.d.ts +8 -0
- package/src/services/assets/asset-processing-service/processor.registry.js +15 -0
- package/src/services/assets/asset-processing-service/processors/base/base-processor.d.ts +24 -0
- package/src/services/assets/asset-processing-service/processors/base/base-processor.js +65 -0
- package/src/services/assets/asset-processing-service/processors/base/base-script-processor.d.ts +22 -0
- package/src/services/assets/asset-processing-service/processors/base/base-script-processor.js +136 -0
- package/src/services/assets/asset-processing-service/processors/index.d.ts +5 -0
- package/src/services/assets/asset-processing-service/processors/index.js +5 -0
- package/src/services/assets/asset-processing-service/processors/script/content-script.processor.d.ts +6 -0
- package/src/services/assets/asset-processing-service/processors/script/content-script.processor.js +119 -0
- package/src/services/assets/asset-processing-service/processors/script/file-script.processor.d.ts +9 -0
- package/src/services/assets/asset-processing-service/processors/script/file-script.processor.js +97 -0
- package/src/services/assets/asset-processing-service/processors/script/node-module-script.processor.d.ts +7 -0
- package/src/services/assets/asset-processing-service/processors/script/node-module-script.processor.js +79 -0
- package/src/services/assets/asset-processing-service/processors/stylesheet/content-stylesheet.processor.d.ts +8 -0
- package/src/services/assets/asset-processing-service/processors/stylesheet/content-stylesheet.processor.js +59 -0
- package/src/services/assets/asset-processing-service/processors/stylesheet/file-stylesheet.processor.d.ts +9 -0
- package/src/services/assets/asset-processing-service/processors/stylesheet/file-stylesheet.processor.js +69 -0
- 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 +73 -0
- package/src/services/assets/browser-bundle.service.js +41 -0
- package/src/services/cache/cache.types.d.ts +107 -0
- package/src/services/cache/cache.types.js +0 -0
- package/src/services/cache/index.d.ts +7 -0
- package/src/services/cache/index.js +7 -0
- package/src/services/cache/memory-cache-store.d.ts +42 -0
- package/src/services/cache/memory-cache-store.js +98 -0
- package/src/services/cache/page-cache-service.d.ts +70 -0
- package/src/services/cache/page-cache-service.js +152 -0
- package/src/services/cache/page-request-cache-coordinator.service.d.ts +75 -0
- package/src/services/cache/page-request-cache-coordinator.service.js +109 -0
- package/src/services/html/html-rewriter-provider.service.d.ts +37 -0
- package/src/services/html/html-rewriter-provider.service.js +68 -0
- package/src/services/html/html-transformer.service.d.ts +87 -0
- package/src/services/html/html-transformer.service.js +216 -0
- package/src/services/invalidation/development-invalidation.service.d.ts +74 -0
- package/src/services/invalidation/development-invalidation.service.js +190 -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 +24 -0
- package/src/services/module-loading/app-server-module-transpiler.service.js +115 -0
- 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.ts → module-loading-types.d.ts} +0 -1
- package/src/services/module-loading/module-loading-types.js +0 -0
- package/src/services/module-loading/node-bootstrap-plugin.d.ts +42 -0
- package/src/services/module-loading/node-bootstrap-plugin.js +216 -0
- package/src/services/module-loading/page-module-import.service.d.ts +76 -0
- package/src/services/module-loading/page-module-import.service.js +170 -0
- package/src/services/module-loading/server-module-transpiler.service.d.ts +63 -0
- package/src/services/module-loading/server-module-transpiler.service.js +64 -0
- 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 +118 -0
- package/src/services/runtime-state/dev-graph.service.js +162 -0
- package/src/services/runtime-state/entrypoint-dependency-graph.service.d.ts +41 -0
- package/src/services/runtime-state/entrypoint-dependency-graph.service.js +85 -0
- package/src/services/runtime-state/server-invalidation-state.service.d.ts +26 -0
- package/src/services/runtime-state/server-invalidation-state.service.js +35 -0
- package/src/services/validation/schema-validation-service.d.ts +122 -0
- package/src/services/validation/schema-validation-service.js +101 -0
- package/src/services/validation/{standard-schema.types.ts → standard-schema.types.d.ts} +17 -20
- package/src/services/validation/standard-schema.types.js +0 -0
- package/src/static-site-generator/static-site-generator.d.ts +104 -0
- package/src/static-site-generator/static-site-generator.js +316 -0
- package/src/types/internal-types.d.ts +232 -0
- package/src/types/internal-types.js +0 -0
- package/src/types/public-types.d.ts +1267 -0
- package/src/types/public-types.js +0 -0
- package/src/utils/deep-merge.d.ts +14 -0
- package/src/utils/deep-merge.js +32 -0
- package/src/utils/hash.d.ts +1 -0
- package/src/utils/hash.js +7 -0
- package/src/utils/html-escaping.d.ts +7 -0
- package/src/utils/html-escaping.js +6 -0
- package/src/utils/html.js +4 -0
- package/src/utils/invariant.d.ts +5 -0
- package/src/utils/invariant.js +11 -0
- package/src/utils/locals-utils.d.ts +15 -0
- package/src/utils/locals-utils.js +24 -0
- package/src/utils/parse-cli-args.d.ts +27 -0
- package/src/utils/parse-cli-args.js +62 -0
- package/src/utils/path-utils.module.d.ts +5 -0
- package/src/utils/path-utils.module.js +14 -0
- package/src/utils/resolve-work-dir.d.ts +11 -0
- package/src/utils/resolve-work-dir.js +31 -0
- package/src/utils/runtime.d.ts +11 -0
- package/src/utils/runtime.js +40 -0
- package/src/utils/server-utils.module.d.ts +19 -0
- package/src/utils/server-utils.module.js +56 -0
- package/src/watchers/project-watcher.d.ts +136 -0
- package/src/watchers/project-watcher.js +275 -0
- package/src/watchers/project-watcher.test-helpers.d.ts +4 -0
- package/src/watchers/project-watcher.test-helpers.js +52 -0
- package/src/adapters/abstract/application-adapter.test.ts +0 -172
- package/src/adapters/abstract/application-adapter.ts +0 -379
- 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 -232
- package/src/adapters/bun/hmr-manager.test.ts +0 -265
- package/src/adapters/bun/hmr-manager.ts +0 -383
- package/src/adapters/bun/index.ts +0 -2
- package/src/adapters/bun/server-adapter.ts +0 -526
- package/src/adapters/bun/server-lifecycle.ts +0 -124
- package/src/adapters/create-app.test.ts +0 -10
- package/src/adapters/create-app.ts +0 -91
- package/src/adapters/index.ts +0 -2
- package/src/adapters/node/create-app.test.ts +0 -53
- package/src/adapters/node/create-app.ts +0 -183
- package/src/adapters/node/node-client-bridge.test.ts +0 -198
- package/src/adapters/node/node-client-bridge.ts +0 -79
- package/src/adapters/node/node-hmr-manager.test.ts +0 -320
- package/src/adapters/node/node-hmr-manager.ts +0 -355
- package/src/adapters/node/server-adapter.ts +0 -502
- package/src/adapters/node/static-content-server.test.ts +0 -60
- package/src/adapters/node/static-content-server.ts +0 -239
- package/src/adapters/shared/api-response.test.ts +0 -97
- 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-render-preparation.ts +0 -58
- package/src/adapters/shared/explicit-static-route-matcher.test.ts +0 -381
- package/src/adapters/shared/explicit-static-route-matcher.ts +0 -131
- package/src/adapters/shared/file-route-middleware-pipeline.test.ts +0 -85
- package/src/adapters/shared/file-route-middleware-pipeline.ts +0 -118
- package/src/adapters/shared/fs-server-response-factory.test.ts +0 -176
- package/src/adapters/shared/fs-server-response-factory.ts +0 -96
- package/src/adapters/shared/fs-server-response-matcher.test.ts +0 -311
- package/src/adapters/shared/fs-server-response-matcher.ts +0 -240
- package/src/adapters/shared/hmr-entrypoint-registrar.ts +0 -149
- package/src/adapters/shared/hmr-html-response.ts +0 -52
- package/src/adapters/shared/hmr-manager.contract.test.ts +0 -228
- package/src/adapters/shared/hmr-manager.dispatch.test.ts +0 -220
- package/src/adapters/shared/render-context.test.ts +0 -150
- package/src/adapters/shared/render-context.ts +0 -123
- package/src/adapters/shared/runtime-bootstrap.ts +0 -79
- package/src/adapters/shared/server-adapter.test.ts +0 -130
- package/src/adapters/shared/server-adapter.ts +0 -562
- package/src/adapters/shared/server-route-handler.test.ts +0 -111
- package/src/adapters/shared/server-route-handler.ts +0 -153
- package/src/adapters/shared/server-static-builder.test.ts +0 -338
- package/src/adapters/shared/server-static-builder.ts +0 -170
- package/src/build/build-adapter-serialization.test.ts +0 -281
- package/src/build/build-adapter.test.ts +0 -1240
- package/src/build/build-adapter.ts +0 -1012
- package/src/build/build-manifest.ts +0 -54
- package/src/build/build-types.ts +0 -83
- package/src/build/dev-build-coordinator.ts +0 -220
- package/src/build/esbuild-build-adapter.ts +0 -660
- package/src/build/runtime-build-executor.test.ts +0 -81
- package/src/build/runtime-build-executor.ts +0 -40
- package/src/build/runtime-specifier-alias-plugin.test.ts +0 -67
- package/src/build/runtime-specifier-alias-plugin.ts +0 -62
- package/src/build/runtime-specifier-aliases.ts +0 -135
- package/src/config/config-builder.test.ts +0 -442
- package/src/config/config-builder.ts +0 -737
- package/src/config/config-builder.typecheck.test.ts +0 -96
- package/src/dev/host-runtime.ts +0 -34
- package/src/dev/sc-server.ts +0 -143
- package/src/eco/eco.browser.test.ts +0 -43
- package/src/eco/eco.browser.ts +0 -118
- package/src/eco/eco.test.ts +0 -654
- package/src/eco/eco.ts +0 -205
- package/src/eco/eco.types.ts +0 -221
- package/src/eco/eco.utils.test.ts +0 -219
- package/src/eco/eco.utils.ts +0 -5
- package/src/eco/global-injector-map.test.ts +0 -42
- package/src/eco/global-injector-map.ts +0 -112
- package/src/eco/lazy-injector-map.test.ts +0 -66
- package/src/eco/lazy-injector-map.ts +0 -120
- package/src/eco/module-dependencies.test.ts +0 -30
- package/src/eco/module-dependencies.ts +0 -75
- package/src/errors/http-error.test.ts +0 -134
- package/src/errors/http-error.ts +0 -72
- package/src/errors/index.ts +0 -3
- package/src/errors/locals-access-error.ts +0 -7
- package/src/global/app-logger.ts +0 -4
- package/src/global/utils.test.ts +0 -12
- package/src/hmr/client/__screenshots__/hmr-runtime.test.browser.ts/HMR-Runtime-HMR-Server-Integration-should-have-HMR-script-injected-in-page-1.png +0 -0
- package/src/hmr/client/__screenshots__/hmr-runtime.test.browser.ts/HMR-Runtime-HMR-Server-Integration-should-load-fixture-app-page-1.png +0 -0
- package/src/hmr/client/__screenshots__/hmr-runtime.test.browser.ts/HMR-Runtime-WebSocket-Connection-should-connect-to-correct-HMR-endpoint-1.png +0 -0
- package/src/hmr/client/hmr-runtime.ts +0 -162
- package/src/hmr/hmr-strategy.test.ts +0 -124
- package/src/hmr/hmr-strategy.ts +0 -177
- 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.test.ts +0 -334
- package/src/hmr/strategies/js-hmr-strategy.ts +0 -314
- package/src/index.browser.ts +0 -3
- package/src/index.ts +0 -15
- package/src/integrations/ghtml/ghtml-renderer.test.ts +0 -253
- package/src/integrations/ghtml/ghtml-renderer.ts +0 -87
- package/src/integrations/ghtml/ghtml.constants.ts +0 -1
- package/src/integrations/ghtml/ghtml.plugin.ts +0 -28
- package/src/plugins/alias-resolver-plugin.test.ts +0 -41
- package/src/plugins/alias-resolver-plugin.ts +0 -63
- package/src/plugins/eco-component-meta-plugin.test.ts +0 -406
- package/src/plugins/eco-component-meta-plugin.ts +0 -494
- package/src/plugins/foreign-jsx-override-plugin.test.ts +0 -65
- package/src/plugins/foreign-jsx-override-plugin.ts +0 -67
- package/src/plugins/integration-plugin.test.ts +0 -151
- package/src/plugins/integration-plugin.ts +0 -323
- package/src/plugins/processor.test.ts +0 -148
- package/src/plugins/processor.ts +0 -257
- package/src/plugins/source-transform.test.ts +0 -82
- package/src/plugins/source-transform.ts +0 -123
- package/src/route-renderer/orchestration/component-render-context.ts +0 -325
- package/src/route-renderer/orchestration/declared-ownership-graph.ts +0 -62
- package/src/route-renderer/orchestration/foreign-subtree-execution.service.ts +0 -383
- package/src/route-renderer/orchestration/integration-renderer.test.ts +0 -2085
- package/src/route-renderer/orchestration/integration-renderer.ts +0 -1244
- package/src/route-renderer/orchestration/ownership-planning.service.ts +0 -97
- package/src/route-renderer/orchestration/ownership-validation.service.ts +0 -76
- package/src/route-renderer/orchestration/processed-asset-dedupe.ts +0 -25
- package/src/route-renderer/orchestration/queued-foreign-subtree-resolution.service.test.ts +0 -324
- package/src/route-renderer/orchestration/queued-foreign-subtree-resolution.service.ts +0 -294
- package/src/route-renderer/orchestration/render-output.utils.ts +0 -310
- package/src/route-renderer/orchestration/route-render-orchestrator.prepare-render-options.test.ts +0 -644
- package/src/route-renderer/orchestration/route-render-orchestrator.test.ts +0 -265
- package/src/route-renderer/orchestration/route-render-orchestrator.ts +0 -592
- package/src/route-renderer/orchestration/template-serialization.test.ts +0 -110
- package/src/route-renderer/orchestration/template-serialization.ts +0 -117
- package/src/route-renderer/page-loading/component-dependency-collection.ts +0 -202
- package/src/route-renderer/page-loading/declared-asset-collection.ts +0 -153
- package/src/route-renderer/page-loading/dependency-resolver.test.ts +0 -761
- package/src/route-renderer/page-loading/dependency-resolver.ts +0 -144
- package/src/route-renderer/page-loading/ecopages-virtual-imports.ts +0 -75
- package/src/route-renderer/page-loading/lazy-entry-collection.ts +0 -167
- package/src/route-renderer/page-loading/lazy-trigger-planning.ts +0 -74
- package/src/route-renderer/page-loading/module-declaration-aggregation.ts +0 -60
- package/src/route-renderer/page-loading/module-declaration-scripts.ts +0 -16
- package/src/route-renderer/page-loading/page-dependency-bundling.ts +0 -244
- package/src/route-renderer/page-loading/page-module-loader.test.ts +0 -183
- package/src/route-renderer/page-loading/page-module-loader.ts +0 -184
- package/src/route-renderer/route-renderer.ts +0 -133
- 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.test.ts +0 -237
- package/src/router/client/navigation-coordinator.ts +0 -453
- package/src/router/server/route-registry.test.ts +0 -176
- package/src/router/server/route-registry.ts +0 -382
- package/src/services/assets/asset-processing-service/asset-dependency-keys.ts +0 -66
- package/src/services/assets/asset-processing-service/asset-processing.service.test.ts +0 -473
- package/src/services/assets/asset-processing-service/asset-processing.service.ts +0 -344
- package/src/services/assets/asset-processing-service/asset.factory.test.ts +0 -63
- package/src/services/assets/asset-processing-service/asset.factory.ts +0 -105
- package/src/services/assets/asset-processing-service/assets.types.ts +0 -128
- package/src/services/assets/asset-processing-service/browser-runtime-asset.factory.test.ts +0 -74
- package/src/services/assets/asset-processing-service/browser-runtime-asset.factory.ts +0 -96
- package/src/services/assets/asset-processing-service/browser-runtime-entry.factory.test.ts +0 -67
- package/src/services/assets/asset-processing-service/browser-runtime-entry.factory.ts +0 -78
- package/src/services/assets/asset-processing-service/grouped-content-bundles.ts +0 -104
- package/src/services/assets/asset-processing-service/index.ts +0 -6
- package/src/services/assets/asset-processing-service/page-package.test.ts +0 -100
- package/src/services/assets/asset-processing-service/page-package.ts +0 -93
- package/src/services/assets/asset-processing-service/processor.registry.ts +0 -18
- package/src/services/assets/asset-processing-service/processors/base/base-processor.test.ts +0 -59
- package/src/services/assets/asset-processing-service/processors/base/base-processor.ts +0 -83
- package/src/services/assets/asset-processing-service/processors/base/base-script-processor.ts +0 -173
- package/src/services/assets/asset-processing-service/processors/index.ts +0 -5
- package/src/services/assets/asset-processing-service/processors/script/content-script.processor.test.ts +0 -195
- package/src/services/assets/asset-processing-service/processors/script/content-script.processor.ts +0 -137
- package/src/services/assets/asset-processing-service/processors/script/file-script.processor.test.ts +0 -326
- package/src/services/assets/asset-processing-service/processors/script/file-script.processor.ts +0 -116
- package/src/services/assets/asset-processing-service/processors/script/node-module-script.processor.test.ts +0 -227
- package/src/services/assets/asset-processing-service/processors/script/node-module-script.processor.ts +0 -89
- package/src/services/assets/asset-processing-service/processors/stylesheet/content-stylesheet.processor.test.ts +0 -261
- package/src/services/assets/asset-processing-service/processors/stylesheet/content-stylesheet.processor.ts +0 -72
- package/src/services/assets/asset-processing-service/processors/stylesheet/file-stylesheet.processor.ts +0 -83
- package/src/services/assets/asset-processing-service/ungrouped-dependency-processing.ts +0 -65
- package/src/services/assets/browser-bundle.service.test.ts +0 -66
- package/src/services/assets/browser-bundle.service.ts +0 -109
- package/src/services/cache/cache.types.ts +0 -126
- package/src/services/cache/index.ts +0 -18
- package/src/services/cache/memory-cache-store.test.ts +0 -225
- package/src/services/cache/memory-cache-store.ts +0 -130
- package/src/services/cache/page-cache-service.test.ts +0 -175
- package/src/services/cache/page-cache-service.ts +0 -202
- package/src/services/cache/page-request-cache-coordinator.service.test.ts +0 -79
- package/src/services/cache/page-request-cache-coordinator.service.ts +0 -131
- package/src/services/html/html-rewriter-provider.service.test.ts +0 -183
- package/src/services/html/html-rewriter-provider.service.ts +0 -104
- package/src/services/html/html-transformer.service.test.ts +0 -476
- package/src/services/html/html-transformer.service.ts +0 -275
- package/src/services/invalidation/development-invalidation.service.test.ts +0 -87
- package/src/services/invalidation/development-invalidation.service.ts +0 -262
- package/src/services/module-loading/app-module-loader.service.ts +0 -9
- package/src/services/module-loading/app-server-module-transpiler.service.test.ts +0 -130
- package/src/services/module-loading/app-server-module-transpiler.service.ts +0 -141
- package/src/services/module-loading/host-module-loader-registry.ts +0 -15
- package/src/services/module-loading/node-bootstrap-plugin.test.ts +0 -335
- package/src/services/module-loading/node-bootstrap-plugin.ts +0 -311
- package/src/services/module-loading/page-module-import.service.test.ts +0 -504
- package/src/services/module-loading/page-module-import.service.ts +0 -251
- package/src/services/module-loading/server-module-transpiler.service.test.ts +0 -243
- package/src/services/module-loading/server-module-transpiler.service.ts +0 -104
- package/src/services/module-loading/source-module-support.ts +0 -19
- 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/server-invalidation-state.service.ts +0 -68
- package/src/services/validation/schema-validation-service.test.ts +0 -223
- package/src/services/validation/schema-validation-service.ts +0 -204
- package/src/static-site-generator/static-site-generator.test.ts +0 -408
- package/src/static-site-generator/static-site-generator.ts +0 -445
- package/src/types/internal-types.ts +0 -243
- package/src/types/public-types.ts +0 -1459
- package/src/utils/deep-merge.test.ts +0 -114
- package/src/utils/deep-merge.ts +0 -47
- package/src/utils/hash.ts +0 -5
- package/src/utils/html-escaping.ts +0 -9
- package/src/utils/invariant.test.ts +0 -22
- package/src/utils/invariant.ts +0 -15
- package/src/utils/locals-utils.ts +0 -37
- package/src/utils/parse-cli-args.test.ts +0 -69
- package/src/utils/parse-cli-args.ts +0 -105
- package/src/utils/path-utils.module.ts +0 -14
- package/src/utils/path-utils.test.ts +0 -15
- 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/utils/server-utils.test.ts +0 -38
- package/src/watchers/project-watcher.integration.test.ts +0 -337
- package/src/watchers/project-watcher.test-helpers.ts +0 -42
- package/src/watchers/project-watcher.test.ts +0 -768
- package/src/watchers/project-watcher.ts +0 -357
- /package/src/utils/{html.ts → html.d.ts} +0 -0
|
@@ -1,1012 +0,0 @@
|
|
|
1
|
-
import type { EcoBuildPlugin } from './build-types.ts';
|
|
2
|
-
import {
|
|
3
|
-
createAppBuildManifest,
|
|
4
|
-
getBrowserBuildPlugins,
|
|
5
|
-
getServerBuildPlugins,
|
|
6
|
-
type AppBuildManifest,
|
|
7
|
-
} from './build-manifest.ts';
|
|
8
|
-
import { EsbuildBuildAdapter } from './esbuild-build-adapter.ts';
|
|
9
|
-
import { collectRuntimeSpecifierAliasMap, rewriteRuntimeSpecifierAliases } from './runtime-specifier-aliases.ts';
|
|
10
|
-
import type { EcoPagesAppConfig } from '../types/internal-types.ts';
|
|
11
|
-
import type { IHmrManager } from '../types/public-types.ts';
|
|
12
|
-
import { getBunRuntime } from '../utils/runtime.ts';
|
|
13
|
-
import fs from 'node:fs';
|
|
14
|
-
import path from 'node:path';
|
|
15
|
-
|
|
16
|
-
export { EsbuildBuildAdapter } from './esbuild-build-adapter.ts';
|
|
17
|
-
|
|
18
|
-
export type BuildOwnership = 'bun-native' | 'vite-host';
|
|
19
|
-
|
|
20
|
-
export interface BuildLog {
|
|
21
|
-
message: string;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export interface BuildOutput {
|
|
25
|
-
path: string;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Dependency graph metadata produced by a build backend.
|
|
30
|
-
*
|
|
31
|
-
* @remarks
|
|
32
|
-
* This structure is runtime-neutral at the type level, but current population
|
|
33
|
-
* is Node/esbuild-only. Bun-backed builds may omit this metadata.
|
|
34
|
-
*/
|
|
35
|
-
export interface BuildDependencyGraph {
|
|
36
|
-
/**
|
|
37
|
-
* Normalized absolute entrypoint path mapped to all normalized absolute
|
|
38
|
-
* source inputs that contributed to that entrypoint output.
|
|
39
|
-
*/
|
|
40
|
-
entrypoints: Record<string, string[]>;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export interface BuildResult {
|
|
44
|
-
success: boolean;
|
|
45
|
-
logs: BuildLog[];
|
|
46
|
-
outputs: BuildOutput[];
|
|
47
|
-
/**
|
|
48
|
-
* Optional build dependency metadata for selective invalidation.
|
|
49
|
-
*
|
|
50
|
-
* @remarks
|
|
51
|
-
* This is currently filled by the Node/esbuild adapter. Other runtimes should
|
|
52
|
-
* treat missing graph data as a valid state and fall back deterministically.
|
|
53
|
-
*/
|
|
54
|
-
dependencyGraph?: BuildDependencyGraph;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export interface BuildOptions {
|
|
58
|
-
entrypoints: string[];
|
|
59
|
-
outdir?: string;
|
|
60
|
-
outbase?: string;
|
|
61
|
-
naming?: string;
|
|
62
|
-
conditions?: string[];
|
|
63
|
-
define?: Record<string, string>;
|
|
64
|
-
minify?: boolean;
|
|
65
|
-
treeshaking?: boolean;
|
|
66
|
-
target?: string;
|
|
67
|
-
format?: string;
|
|
68
|
-
sourcemap?: string;
|
|
69
|
-
splitting?: boolean;
|
|
70
|
-
root?: string;
|
|
71
|
-
bundle?: boolean;
|
|
72
|
-
externalPackages?: boolean;
|
|
73
|
-
external?: string[];
|
|
74
|
-
plugins?: EcoBuildPlugin[];
|
|
75
|
-
[key: string]: unknown;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
export type BuildTranspileProfile = 'browser-script' | 'hmr-runtime' | 'hmr-entrypoint';
|
|
79
|
-
|
|
80
|
-
export interface BuildTranspileOptions {
|
|
81
|
-
target: string;
|
|
82
|
-
format: string;
|
|
83
|
-
sourcemap: string;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
export interface BuildAdapter {
|
|
87
|
-
readonly ownership?: BuildOwnership;
|
|
88
|
-
/**
|
|
89
|
-
* Executes one concrete backend build.
|
|
90
|
-
*
|
|
91
|
-
* @remarks
|
|
92
|
-
* `BuildAdapter` is the low-level backend contract. Bun-native execution owns
|
|
93
|
-
* one adapter directly; Vite-hosted execution is represented as an explicit
|
|
94
|
-
* host-owned compatibility path rather than an implicit esbuild default.
|
|
95
|
-
*/
|
|
96
|
-
build(options: BuildOptions): Promise<BuildResult>;
|
|
97
|
-
resolve(importPath: string, rootDir: string): string;
|
|
98
|
-
getTranspileOptions(profile: BuildTranspileProfile): BuildTranspileOptions;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* Runtime-owned facade for issuing builds.
|
|
103
|
-
*
|
|
104
|
-
* @remarks
|
|
105
|
-
* This is intentionally narrower than `BuildAdapter`. A build executor answers
|
|
106
|
-
* only the question "how should this app execute a build right now?".
|
|
107
|
-
*
|
|
108
|
-
* In Bun-native production and non-watch flows the executor is usually the
|
|
109
|
-
* adapter itself. In development watch flows the executor may be a
|
|
110
|
-
* compatibility coordinator around the Bun-native adapter while the Vite host
|
|
111
|
-
* path continues migrating toward host-owned execution.
|
|
112
|
-
*/
|
|
113
|
-
export interface BuildExecutor {
|
|
114
|
-
build(options: BuildOptions): Promise<BuildResult>;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
type RuntimeBun = NonNullable<ReturnType<typeof getBunRuntime>>;
|
|
118
|
-
|
|
119
|
-
type NormalizedBunOutput = {
|
|
120
|
-
concretePath: string;
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
type BunPluginBuilder = {
|
|
124
|
-
config?: {
|
|
125
|
-
external?: string[];
|
|
126
|
-
};
|
|
127
|
-
onResolve(
|
|
128
|
-
options: { filter: RegExp; namespace?: string },
|
|
129
|
-
callback: (args: {
|
|
130
|
-
path: string;
|
|
131
|
-
importer: string;
|
|
132
|
-
namespace?: string;
|
|
133
|
-
}) =>
|
|
134
|
-
| { path?: string; namespace?: string; external?: boolean }
|
|
135
|
-
| undefined
|
|
136
|
-
| Promise<{ path?: string; namespace?: string; external?: boolean } | undefined>,
|
|
137
|
-
): void;
|
|
138
|
-
onLoad(
|
|
139
|
-
options: { filter: RegExp; namespace?: string },
|
|
140
|
-
callback: (args: {
|
|
141
|
-
path: string;
|
|
142
|
-
namespace?: string;
|
|
143
|
-
}) =>
|
|
144
|
-
| { contents?: string | Uint8Array; loader?: string; resolveDir?: string }
|
|
145
|
-
| undefined
|
|
146
|
-
| Promise<{ contents?: string | Uint8Array; loader?: string; resolveDir?: string } | undefined>,
|
|
147
|
-
): void;
|
|
148
|
-
};
|
|
149
|
-
|
|
150
|
-
function transpileProfileToOptions(profile: BuildTranspileProfile): BuildTranspileOptions {
|
|
151
|
-
switch (profile) {
|
|
152
|
-
case 'browser-script':
|
|
153
|
-
return {
|
|
154
|
-
target: 'browser',
|
|
155
|
-
format: 'esm',
|
|
156
|
-
sourcemap: 'none',
|
|
157
|
-
};
|
|
158
|
-
case 'hmr-runtime':
|
|
159
|
-
return {
|
|
160
|
-
target: 'browser',
|
|
161
|
-
format: 'esm',
|
|
162
|
-
sourcemap: 'none',
|
|
163
|
-
};
|
|
164
|
-
case 'hmr-entrypoint':
|
|
165
|
-
return {
|
|
166
|
-
target: 'browser',
|
|
167
|
-
format: 'esm',
|
|
168
|
-
sourcemap: 'none',
|
|
169
|
-
};
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
export class BunBuildAdapter implements BuildAdapter {
|
|
174
|
-
readonly ownership = 'bun-native' as const;
|
|
175
|
-
private readonly fallbackAdapter = new EsbuildBuildAdapter();
|
|
176
|
-
|
|
177
|
-
private getPluginsForBuild(additionalPlugins?: EcoBuildPlugin[]): EcoBuildPlugin[] {
|
|
178
|
-
const byName = new Map<string, EcoBuildPlugin>();
|
|
179
|
-
|
|
180
|
-
for (const plugin of additionalPlugins ?? []) {
|
|
181
|
-
if (!byName.has(plugin.name)) {
|
|
182
|
-
byName.set(plugin.name, plugin);
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
return Array.from(byName.values());
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
private escapeRegExp(value: string): string {
|
|
190
|
-
return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
private resolvePluginPath(value: string, importer: string, contextRoot: string): string {
|
|
194
|
-
if (path.isAbsolute(value)) {
|
|
195
|
-
return value;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
if (value.startsWith('.') || value.startsWith('..')) {
|
|
199
|
-
const baseDir = importer ? path.dirname(importer) : contextRoot;
|
|
200
|
-
return path.resolve(baseDir, value);
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
return value;
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
private inferLoaderFromPath(filePath: string): string {
|
|
207
|
-
const extension = path.extname(filePath).toLowerCase();
|
|
208
|
-
|
|
209
|
-
switch (extension) {
|
|
210
|
-
case '.ts':
|
|
211
|
-
return 'ts';
|
|
212
|
-
case '.tsx':
|
|
213
|
-
return 'tsx';
|
|
214
|
-
case '.jsx':
|
|
215
|
-
return 'jsx';
|
|
216
|
-
case '.json':
|
|
217
|
-
return 'json';
|
|
218
|
-
case '.css':
|
|
219
|
-
return 'css';
|
|
220
|
-
default:
|
|
221
|
-
return 'js';
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
private normalizeBunLoader(loader: unknown): string | undefined {
|
|
226
|
-
switch (loader) {
|
|
227
|
-
case 'js':
|
|
228
|
-
case 'jsx':
|
|
229
|
-
case 'ts':
|
|
230
|
-
case 'tsx':
|
|
231
|
-
case 'json':
|
|
232
|
-
case 'toml':
|
|
233
|
-
case 'text':
|
|
234
|
-
case 'file':
|
|
235
|
-
case 'css':
|
|
236
|
-
return loader;
|
|
237
|
-
case 'global-css':
|
|
238
|
-
case 'local-css':
|
|
239
|
-
return 'css';
|
|
240
|
-
default:
|
|
241
|
-
return undefined;
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
private convertLoadResultToModuleSource(result: unknown): string | undefined {
|
|
246
|
-
if (!result || typeof result !== 'object') {
|
|
247
|
-
return undefined;
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
const candidate = result as {
|
|
251
|
-
contents?: string;
|
|
252
|
-
loader?: unknown;
|
|
253
|
-
exports?: Record<string, unknown>;
|
|
254
|
-
};
|
|
255
|
-
|
|
256
|
-
if (typeof candidate.contents === 'string') {
|
|
257
|
-
return candidate.contents;
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
if (candidate.loader === 'object' && candidate.exports && typeof candidate.exports === 'object') {
|
|
261
|
-
return Object.entries(candidate.exports)
|
|
262
|
-
.map(([key, value]) =>
|
|
263
|
-
key === 'default'
|
|
264
|
-
? `export default ${JSON.stringify(value)};`
|
|
265
|
-
: `export const ${key} = ${JSON.stringify(value)};`,
|
|
266
|
-
)
|
|
267
|
-
.join('\n');
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
return undefined;
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
private convertPluginOnLoadResult(
|
|
274
|
-
args: { path: string },
|
|
275
|
-
result: unknown,
|
|
276
|
-
): { contents?: string | Uint8Array; loader?: string; resolveDir?: string } | undefined {
|
|
277
|
-
if (!result || typeof result !== 'object') {
|
|
278
|
-
return undefined;
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
const candidate = result as {
|
|
282
|
-
contents?: string | Uint8Array;
|
|
283
|
-
loader?: unknown;
|
|
284
|
-
exports?: Record<string, unknown>;
|
|
285
|
-
resolveDir?: unknown;
|
|
286
|
-
};
|
|
287
|
-
|
|
288
|
-
const sourceFromExports =
|
|
289
|
-
candidate.loader === 'object' && candidate.exports && typeof candidate.exports === 'object'
|
|
290
|
-
? this.convertLoadResultToModuleSource(candidate)
|
|
291
|
-
: undefined;
|
|
292
|
-
|
|
293
|
-
if (sourceFromExports) {
|
|
294
|
-
return {
|
|
295
|
-
contents: sourceFromExports,
|
|
296
|
-
loader: 'js',
|
|
297
|
-
...(typeof candidate.resolveDir === 'string' ? { resolveDir: candidate.resolveDir } : {}),
|
|
298
|
-
};
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
if (typeof candidate.contents === 'string' || candidate.contents instanceof Uint8Array) {
|
|
302
|
-
return {
|
|
303
|
-
contents: candidate.contents,
|
|
304
|
-
loader: this.normalizeBunLoader(candidate.loader) ?? this.inferLoaderFromPath(args.path),
|
|
305
|
-
...(typeof candidate.resolveDir === 'string' ? { resolveDir: candidate.resolveDir } : {}),
|
|
306
|
-
};
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
return undefined;
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
private createEcoPluginBridge(
|
|
313
|
-
plugins: EcoBuildPlugin[],
|
|
314
|
-
contextRoot: string,
|
|
315
|
-
): RuntimeBun['plugin'] extends (...args: infer A) => unknown ? A[0] : never {
|
|
316
|
-
return {
|
|
317
|
-
name: 'ecopages-plugin-bridge',
|
|
318
|
-
setup: async (build: BunPluginBuilder) => {
|
|
319
|
-
let moduleCounter = 0;
|
|
320
|
-
|
|
321
|
-
const bridge = {
|
|
322
|
-
onResolve: (options, callback) => {
|
|
323
|
-
build.onResolve(options, async (args) => {
|
|
324
|
-
const result = await callback({
|
|
325
|
-
path: args.path,
|
|
326
|
-
importer: args.importer,
|
|
327
|
-
namespace: args.namespace,
|
|
328
|
-
});
|
|
329
|
-
|
|
330
|
-
if (!result || typeof result !== 'object') {
|
|
331
|
-
return undefined;
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
return {
|
|
335
|
-
...(typeof result.path === 'string'
|
|
336
|
-
? { path: this.resolvePluginPath(result.path, args.importer, contextRoot) }
|
|
337
|
-
: {}),
|
|
338
|
-
...(typeof result.namespace === 'string' ? { namespace: result.namespace } : {}),
|
|
339
|
-
...(typeof result.external === 'boolean' ? { external: result.external } : {}),
|
|
340
|
-
};
|
|
341
|
-
});
|
|
342
|
-
},
|
|
343
|
-
onLoad: (options, callback) => {
|
|
344
|
-
build.onLoad(options, async (args) =>
|
|
345
|
-
this.convertPluginOnLoadResult(
|
|
346
|
-
{ path: args.path },
|
|
347
|
-
await callback({
|
|
348
|
-
path: args.path,
|
|
349
|
-
namespace: args.namespace,
|
|
350
|
-
}),
|
|
351
|
-
),
|
|
352
|
-
);
|
|
353
|
-
},
|
|
354
|
-
module: (specifier, callback) => {
|
|
355
|
-
const namespace = `ecopages-module-${moduleCounter}`;
|
|
356
|
-
moduleCounter += 1;
|
|
357
|
-
const filter = new RegExp(`^${this.escapeRegExp(specifier)}$`);
|
|
358
|
-
|
|
359
|
-
build.onResolve({ filter }, async () => ({
|
|
360
|
-
path: specifier,
|
|
361
|
-
namespace,
|
|
362
|
-
}));
|
|
363
|
-
|
|
364
|
-
build.onLoad({ filter, namespace }, async () =>
|
|
365
|
-
this.convertPluginOnLoadResult({ path: specifier }, await callback()),
|
|
366
|
-
);
|
|
367
|
-
},
|
|
368
|
-
} satisfies import('./build-types.ts').EcoBuildPluginBuilder;
|
|
369
|
-
|
|
370
|
-
for (const plugin of plugins) {
|
|
371
|
-
await plugin.setup(bridge);
|
|
372
|
-
}
|
|
373
|
-
},
|
|
374
|
-
} as RuntimeBun['plugin'] extends (...args: infer A) => unknown ? A[0] : never;
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
private toBuildLogs(error: unknown): BuildLog[] {
|
|
378
|
-
if (error instanceof Error) {
|
|
379
|
-
return [{ message: error.message }];
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
return [{ message: 'Unknown Bun build error' }];
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
private mapBunTarget(value: string | undefined): 'browser' | 'bun' {
|
|
386
|
-
return value === 'browser' ? 'browser' : 'bun';
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
private mapBunFormat(value: string | undefined): 'esm' | 'cjs' | undefined {
|
|
390
|
-
switch (value) {
|
|
391
|
-
case 'cjs':
|
|
392
|
-
return 'cjs';
|
|
393
|
-
case 'esm':
|
|
394
|
-
default:
|
|
395
|
-
return 'esm';
|
|
396
|
-
}
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
private getOutputExtension(options: BuildOptions, entrypointPath: string): string {
|
|
400
|
-
const entryExtension = path.extname(entrypointPath).toLowerCase();
|
|
401
|
-
|
|
402
|
-
if (entryExtension === '.css') {
|
|
403
|
-
return '.css';
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
if (entryExtension === '.json') {
|
|
407
|
-
return '.json';
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
if (entryExtension === '.toml') {
|
|
411
|
-
return '.toml';
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
return options.format === 'cjs' || options.format === 'esm' ? '.js' : '.js';
|
|
415
|
-
}
|
|
416
|
-
|
|
417
|
-
private resolveConcreteOutputPath(outputPath: string): string | undefined {
|
|
418
|
-
if (fs.existsSync(outputPath)) {
|
|
419
|
-
return outputPath;
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
if (!outputPath.includes('[hash]')) {
|
|
423
|
-
return outputPath;
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
const directory = path.dirname(outputPath);
|
|
427
|
-
if (!fs.existsSync(directory)) {
|
|
428
|
-
return undefined;
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
const basenamePattern = path.basename(outputPath);
|
|
432
|
-
const matcher = new RegExp(`^${this.escapeRegExp(basenamePattern).replace(/\\\[hash\\\]/g, '(.+)')}$`);
|
|
433
|
-
const matches = fs
|
|
434
|
-
.readdirSync(directory)
|
|
435
|
-
.filter((candidate) => matcher.test(candidate))
|
|
436
|
-
.sort();
|
|
437
|
-
|
|
438
|
-
if (matches.length === 0) {
|
|
439
|
-
return undefined;
|
|
440
|
-
}
|
|
441
|
-
|
|
442
|
-
return path.join(directory, matches[0]!);
|
|
443
|
-
}
|
|
444
|
-
|
|
445
|
-
private normalizePathForMatch(filePath: string): string {
|
|
446
|
-
return path.normalize(filePath).split(path.sep).join('/');
|
|
447
|
-
}
|
|
448
|
-
|
|
449
|
-
private normalizeOutputPathForMatch(outputPath: string, templatePath: string): string {
|
|
450
|
-
const normalizedOutputPath = path.normalize(outputPath);
|
|
451
|
-
const templateExtension = path.extname(templatePath);
|
|
452
|
-
|
|
453
|
-
if (!templateExtension) {
|
|
454
|
-
return normalizedOutputPath;
|
|
455
|
-
}
|
|
456
|
-
|
|
457
|
-
if (templateExtension === '.js') {
|
|
458
|
-
if (this.hasJavaScriptExtension(normalizedOutputPath)) {
|
|
459
|
-
return path.normalize(normalizedOutputPath.replace(/\.(?:[cm]?js)$/u, '.js'));
|
|
460
|
-
}
|
|
461
|
-
|
|
462
|
-
return path.normalize(`${normalizedOutputPath}.js`);
|
|
463
|
-
}
|
|
464
|
-
|
|
465
|
-
if (normalizedOutputPath.endsWith(templateExtension)) {
|
|
466
|
-
return normalizedOutputPath;
|
|
467
|
-
}
|
|
468
|
-
|
|
469
|
-
return path.normalize(`${normalizedOutputPath}${templateExtension}`);
|
|
470
|
-
}
|
|
471
|
-
|
|
472
|
-
private extractTemplateHashTokens(templatePath: string, candidatePath: string): string[] | undefined {
|
|
473
|
-
const normalizedTemplatePath = this.normalizePathForMatch(templatePath);
|
|
474
|
-
const normalizedCandidatePath = this.normalizePathForMatch(
|
|
475
|
-
this.normalizeOutputPathForMatch(candidatePath, templatePath),
|
|
476
|
-
);
|
|
477
|
-
const matcher = new RegExp(
|
|
478
|
-
`^${this.escapeRegExp(normalizedTemplatePath).replace(/\\\[hash\\\]/g, '([^/]+)')}$`,
|
|
479
|
-
);
|
|
480
|
-
const match = normalizedCandidatePath.match(matcher);
|
|
481
|
-
|
|
482
|
-
if (!match) {
|
|
483
|
-
return undefined;
|
|
484
|
-
}
|
|
485
|
-
|
|
486
|
-
return match.slice(1);
|
|
487
|
-
}
|
|
488
|
-
|
|
489
|
-
private applyTemplateHashTokens(templatePath: string, hashTokens: string[]): string | undefined {
|
|
490
|
-
const hashTokenCount = templatePath.match(/\[hash\]/g)?.length ?? 0;
|
|
491
|
-
|
|
492
|
-
if (hashTokenCount !== hashTokens.length) {
|
|
493
|
-
return undefined;
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
if (hashTokenCount === 0) {
|
|
497
|
-
return templatePath;
|
|
498
|
-
}
|
|
499
|
-
|
|
500
|
-
let hashTokenIndex = 0;
|
|
501
|
-
return templatePath.replace(/\[hash\]/g, () => hashTokens[hashTokenIndex++] ?? '');
|
|
502
|
-
}
|
|
503
|
-
|
|
504
|
-
private resolveTemplatedOutputPath(options: BuildOptions, entrypointPath: string): string | undefined {
|
|
505
|
-
if (!options.outdir) {
|
|
506
|
-
return undefined;
|
|
507
|
-
}
|
|
508
|
-
|
|
509
|
-
const template = typeof options.naming === 'string' ? options.naming : '[dir]/[name]';
|
|
510
|
-
const outdir = path.resolve(options.outdir);
|
|
511
|
-
const outputExtension = this.getOutputExtension(options, entrypointPath);
|
|
512
|
-
const relativeBase = path.resolve(options.outbase ?? options.root ?? process.cwd());
|
|
513
|
-
const relativeEntrypoint = path.relative(relativeBase, entrypointPath);
|
|
514
|
-
const relativeDir = path.dirname(relativeEntrypoint);
|
|
515
|
-
const dirToken = relativeDir === '.' ? '' : relativeDir.split(path.sep).join('/');
|
|
516
|
-
const nameToken = path.basename(relativeEntrypoint, path.extname(relativeEntrypoint));
|
|
517
|
-
const extToken = outputExtension.replace(/^\./, '');
|
|
518
|
-
|
|
519
|
-
let resolvedPath = template
|
|
520
|
-
.replaceAll('[dir]', dirToken)
|
|
521
|
-
.replaceAll('[name]', nameToken)
|
|
522
|
-
.replaceAll('[ext]', extToken);
|
|
523
|
-
|
|
524
|
-
if (outputExtension && !resolvedPath.endsWith(outputExtension)) {
|
|
525
|
-
resolvedPath += outputExtension;
|
|
526
|
-
}
|
|
527
|
-
|
|
528
|
-
resolvedPath = resolvedPath.replace(/^\.\//, '');
|
|
529
|
-
|
|
530
|
-
return path.join(outdir, resolvedPath);
|
|
531
|
-
}
|
|
532
|
-
|
|
533
|
-
private relocateOutputFile(currentPath: string, targetPath: string): string {
|
|
534
|
-
if (currentPath === targetPath || !fs.existsSync(currentPath)) {
|
|
535
|
-
return fs.existsSync(targetPath) ? targetPath : currentPath;
|
|
536
|
-
}
|
|
537
|
-
|
|
538
|
-
fs.mkdirSync(path.dirname(targetPath), { recursive: true });
|
|
539
|
-
fs.rmSync(targetPath, { force: true });
|
|
540
|
-
fs.renameSync(currentPath, targetPath);
|
|
541
|
-
return targetPath;
|
|
542
|
-
}
|
|
543
|
-
|
|
544
|
-
private hasJavaScriptExtension(outputPath: string): boolean {
|
|
545
|
-
return /\.(?:[cm]?js)$/u.test(outputPath);
|
|
546
|
-
}
|
|
547
|
-
|
|
548
|
-
private findOutputMatchForEntrypoint(
|
|
549
|
-
options: BuildOptions,
|
|
550
|
-
entrypointPath: string,
|
|
551
|
-
outputs: NormalizedBunOutput[],
|
|
552
|
-
usedOutputIndexes: Set<number>,
|
|
553
|
-
): { outputIndex: number; targetPath: string } | undefined {
|
|
554
|
-
const expectedOutputPath = this.resolveTemplatedOutputPath(options, entrypointPath);
|
|
555
|
-
|
|
556
|
-
if (!expectedOutputPath) {
|
|
557
|
-
return undefined;
|
|
558
|
-
}
|
|
559
|
-
|
|
560
|
-
const expectedMatchPaths = [expectedOutputPath];
|
|
561
|
-
|
|
562
|
-
if (options.outbase) {
|
|
563
|
-
const bunRootRelativeOutputPath = this.resolveTemplatedOutputPath(
|
|
564
|
-
{ ...options, outbase: undefined },
|
|
565
|
-
entrypointPath,
|
|
566
|
-
);
|
|
567
|
-
|
|
568
|
-
if (bunRootRelativeOutputPath && bunRootRelativeOutputPath !== expectedOutputPath) {
|
|
569
|
-
expectedMatchPaths.push(bunRootRelativeOutputPath);
|
|
570
|
-
}
|
|
571
|
-
}
|
|
572
|
-
|
|
573
|
-
for (const [outputIndex, output] of outputs.entries()) {
|
|
574
|
-
if (usedOutputIndexes.has(outputIndex)) {
|
|
575
|
-
continue;
|
|
576
|
-
}
|
|
577
|
-
|
|
578
|
-
for (const matchPath of expectedMatchPaths) {
|
|
579
|
-
const hashTokens = this.extractTemplateHashTokens(matchPath, output.concretePath);
|
|
580
|
-
if (!hashTokens) {
|
|
581
|
-
continue;
|
|
582
|
-
}
|
|
583
|
-
|
|
584
|
-
const targetPath = this.applyTemplateHashTokens(expectedOutputPath, hashTokens);
|
|
585
|
-
if (!targetPath) {
|
|
586
|
-
continue;
|
|
587
|
-
}
|
|
588
|
-
|
|
589
|
-
usedOutputIndexes.add(outputIndex);
|
|
590
|
-
return { outputIndex, targetPath };
|
|
591
|
-
}
|
|
592
|
-
}
|
|
593
|
-
|
|
594
|
-
return undefined;
|
|
595
|
-
}
|
|
596
|
-
|
|
597
|
-
private normalizeBunOutputs(result: BuildResult, options: BuildOptions): BuildResult {
|
|
598
|
-
if (!result.success || result.outputs.length === 0) {
|
|
599
|
-
return result;
|
|
600
|
-
}
|
|
601
|
-
|
|
602
|
-
const normalizedOutputs = result.outputs.map((output) => ({
|
|
603
|
-
concretePath: this.resolveConcreteOutputPath(output.path) ?? output.path,
|
|
604
|
-
}));
|
|
605
|
-
const matchedTargetsByIndex = new Map<number, string>();
|
|
606
|
-
const usedOutputIndexes = new Set<number>();
|
|
607
|
-
|
|
608
|
-
for (const entrypointPath of options.entrypoints) {
|
|
609
|
-
const matchedOutput = this.findOutputMatchForEntrypoint(
|
|
610
|
-
options,
|
|
611
|
-
entrypointPath,
|
|
612
|
-
normalizedOutputs,
|
|
613
|
-
usedOutputIndexes,
|
|
614
|
-
);
|
|
615
|
-
|
|
616
|
-
if (matchedOutput) {
|
|
617
|
-
matchedTargetsByIndex.set(matchedOutput.outputIndex, matchedOutput.targetPath);
|
|
618
|
-
}
|
|
619
|
-
}
|
|
620
|
-
|
|
621
|
-
return {
|
|
622
|
-
...result,
|
|
623
|
-
outputs: normalizedOutputs.map((output, index) => {
|
|
624
|
-
const expectedOutputPath = matchedTargetsByIndex.get(index);
|
|
625
|
-
const concreteOutputPath = output.concretePath;
|
|
626
|
-
|
|
627
|
-
if (expectedOutputPath) {
|
|
628
|
-
return {
|
|
629
|
-
path: this.relocateOutputFile(concreteOutputPath, expectedOutputPath),
|
|
630
|
-
};
|
|
631
|
-
}
|
|
632
|
-
|
|
633
|
-
if (this.hasJavaScriptExtension(concreteOutputPath)) {
|
|
634
|
-
return {
|
|
635
|
-
path: concreteOutputPath,
|
|
636
|
-
};
|
|
637
|
-
}
|
|
638
|
-
|
|
639
|
-
const normalizedPath = `${concreteOutputPath}.js`;
|
|
640
|
-
return {
|
|
641
|
-
path: this.relocateOutputFile(concreteOutputPath, normalizedPath),
|
|
642
|
-
};
|
|
643
|
-
}),
|
|
644
|
-
};
|
|
645
|
-
}
|
|
646
|
-
|
|
647
|
-
private rewriteAliasedRuntimeSpecifiers(result: BuildResult, plugins: EcoBuildPlugin[]): BuildResult {
|
|
648
|
-
if (!result.success || result.outputs.length === 0) {
|
|
649
|
-
return result;
|
|
650
|
-
}
|
|
651
|
-
|
|
652
|
-
const aliasMap = collectRuntimeSpecifierAliasMap(plugins);
|
|
653
|
-
if (aliasMap.size === 0) {
|
|
654
|
-
return result;
|
|
655
|
-
}
|
|
656
|
-
|
|
657
|
-
for (const output of result.outputs) {
|
|
658
|
-
if (!/\.(?:[cm]?js)$/u.test(output.path) || !fs.existsSync(output.path)) {
|
|
659
|
-
continue;
|
|
660
|
-
}
|
|
661
|
-
|
|
662
|
-
const code = fs.readFileSync(output.path, 'utf-8');
|
|
663
|
-
const rewritten = rewriteRuntimeSpecifierAliases(code, aliasMap);
|
|
664
|
-
|
|
665
|
-
if (rewritten !== code) {
|
|
666
|
-
fs.writeFileSync(output.path, rewritten);
|
|
667
|
-
}
|
|
668
|
-
}
|
|
669
|
-
|
|
670
|
-
return result;
|
|
671
|
-
}
|
|
672
|
-
|
|
673
|
-
async build(options: BuildOptions): Promise<BuildResult> {
|
|
674
|
-
const bun = getBunRuntime();
|
|
675
|
-
|
|
676
|
-
if (!bun) {
|
|
677
|
-
return this.fallbackAdapter.build(options);
|
|
678
|
-
}
|
|
679
|
-
|
|
680
|
-
try {
|
|
681
|
-
const contextRoot = options.root ? path.resolve(options.root) : process.cwd();
|
|
682
|
-
const outdir = path.resolve(options.outdir ?? 'dist/assets');
|
|
683
|
-
const plugins = this.getPluginsForBuild(options.plugins);
|
|
684
|
-
const result = await bun.build({
|
|
685
|
-
entrypoints: options.entrypoints,
|
|
686
|
-
outdir,
|
|
687
|
-
root: contextRoot,
|
|
688
|
-
naming: typeof options.naming === 'string' ? options.naming : undefined,
|
|
689
|
-
define: options.define,
|
|
690
|
-
external: options.external,
|
|
691
|
-
format: this.mapBunFormat(options.format),
|
|
692
|
-
target: this.mapBunTarget(options.target),
|
|
693
|
-
sourcemap: options.sourcemap as 'none' | 'external' | 'linked' | 'inline' | undefined,
|
|
694
|
-
splitting: !!options.splitting,
|
|
695
|
-
minify: !!options.minify,
|
|
696
|
-
packages: options.target !== 'browser' && options.externalPackages !== false ? 'external' : undefined,
|
|
697
|
-
plugins: plugins.length > 0 ? [this.createEcoPluginBridge(plugins, contextRoot)] : undefined,
|
|
698
|
-
});
|
|
699
|
-
|
|
700
|
-
return this.rewriteAliasedRuntimeSpecifiers(
|
|
701
|
-
this.normalizeBunOutputs(
|
|
702
|
-
{
|
|
703
|
-
success: result.success,
|
|
704
|
-
logs: result.logs.map((log) => ({ message: log.message })),
|
|
705
|
-
outputs: result.outputs.map((output) => ({ path: output.path })),
|
|
706
|
-
},
|
|
707
|
-
options,
|
|
708
|
-
),
|
|
709
|
-
plugins,
|
|
710
|
-
);
|
|
711
|
-
} catch (error) {
|
|
712
|
-
return {
|
|
713
|
-
success: false,
|
|
714
|
-
logs: this.toBuildLogs(error),
|
|
715
|
-
outputs: [],
|
|
716
|
-
};
|
|
717
|
-
}
|
|
718
|
-
}
|
|
719
|
-
|
|
720
|
-
resolve(importPath: string, rootDir: string): string {
|
|
721
|
-
const bun = getBunRuntime();
|
|
722
|
-
|
|
723
|
-
if (!bun) {
|
|
724
|
-
return this.fallbackAdapter.resolve(importPath, rootDir);
|
|
725
|
-
}
|
|
726
|
-
|
|
727
|
-
return bun.resolveSync(importPath, rootDir);
|
|
728
|
-
}
|
|
729
|
-
|
|
730
|
-
getTranspileOptions(profile: BuildTranspileProfile): BuildTranspileOptions {
|
|
731
|
-
return transpileProfileToOptions(profile);
|
|
732
|
-
}
|
|
733
|
-
}
|
|
734
|
-
|
|
735
|
-
function createHostOwnedBuildError(methodName: string): Error {
|
|
736
|
-
return new Error(
|
|
737
|
-
`Vite-hosted builds are owned by the host runtime. Core cannot ${methodName} through the host-owned compatibility adapter.`,
|
|
738
|
-
);
|
|
739
|
-
}
|
|
740
|
-
|
|
741
|
-
export class ViteHostBuildAdapter implements BuildAdapter {
|
|
742
|
-
readonly ownership = 'vite-host' as const;
|
|
743
|
-
|
|
744
|
-
async build(_options: BuildOptions): Promise<BuildResult> {
|
|
745
|
-
throw createHostOwnedBuildError('build');
|
|
746
|
-
}
|
|
747
|
-
|
|
748
|
-
resolve(_importPath: string, _rootDir: string): string {
|
|
749
|
-
throw createHostOwnedBuildError('resolve imports');
|
|
750
|
-
}
|
|
751
|
-
|
|
752
|
-
getTranspileOptions(_profile: BuildTranspileProfile): BuildTranspileOptions {
|
|
753
|
-
throw createHostOwnedBuildError('derive transpile options');
|
|
754
|
-
}
|
|
755
|
-
}
|
|
756
|
-
|
|
757
|
-
export function createBunBuildAdapter(): BuildAdapter {
|
|
758
|
-
return new BunBuildAdapter();
|
|
759
|
-
}
|
|
760
|
-
|
|
761
|
-
export function createViteHostBuildAdapter(): BuildAdapter {
|
|
762
|
-
return new ViteHostBuildAdapter();
|
|
763
|
-
}
|
|
764
|
-
|
|
765
|
-
export function createBuildAdapter(options?: { ownership?: BuildOwnership }): BuildAdapter {
|
|
766
|
-
switch (options?.ownership ?? 'bun-native') {
|
|
767
|
-
case 'vite-host':
|
|
768
|
-
return createViteHostBuildAdapter();
|
|
769
|
-
case 'bun-native':
|
|
770
|
-
default:
|
|
771
|
-
return createBunBuildAdapter();
|
|
772
|
-
}
|
|
773
|
-
}
|
|
774
|
-
|
|
775
|
-
export const defaultBunBuildAdapter: BuildAdapter = createBuildAdapter({ ownership: 'bun-native' });
|
|
776
|
-
export const defaultViteHostBuildAdapter: BuildAdapter = createBuildAdapter({ ownership: 'vite-host' });
|
|
777
|
-
/**
|
|
778
|
-
* Bun-native fallback export for callsites that still resolve build state
|
|
779
|
-
* globally.
|
|
780
|
-
*
|
|
781
|
-
* New app-aware code should prefer `getAppBuildAdapter()`.
|
|
782
|
-
*/
|
|
783
|
-
export const defaultBuildAdapter: BuildAdapter = defaultBunBuildAdapter;
|
|
784
|
-
|
|
785
|
-
export function getDefaultBuildAdapter(ownership: BuildOwnership = 'bun-native'): BuildAdapter {
|
|
786
|
-
return ownership === 'vite-host' ? defaultViteHostBuildAdapter : defaultBunBuildAdapter;
|
|
787
|
-
}
|
|
788
|
-
|
|
789
|
-
export function getBuildAdapterOwnership(buildAdapter: BuildAdapter | undefined): BuildOwnership {
|
|
790
|
-
return buildAdapter?.ownership ?? 'bun-native';
|
|
791
|
-
}
|
|
792
|
-
|
|
793
|
-
export function getAppBuildOwnership(appConfig: EcoPagesAppConfig): BuildOwnership {
|
|
794
|
-
return appConfig.runtime?.buildOwnership ?? getBuildAdapterOwnership(appConfig.runtime?.buildAdapter);
|
|
795
|
-
}
|
|
796
|
-
|
|
797
|
-
export function setAppBuildOwnership(appConfig: EcoPagesAppConfig, buildOwnership: BuildOwnership): void {
|
|
798
|
-
appConfig.runtime = {
|
|
799
|
-
...(appConfig.runtime ?? {}),
|
|
800
|
-
buildOwnership,
|
|
801
|
-
};
|
|
802
|
-
}
|
|
803
|
-
|
|
804
|
-
/**
|
|
805
|
-
* Returns the adapter owned by an app/runtime instance.
|
|
806
|
-
*
|
|
807
|
-
* @remarks
|
|
808
|
-
* The config builder installs an explicit adapter per app. The Bun-native
|
|
809
|
-
* fallback remains only as compatibility scaffolding for helpers that do not
|
|
810
|
-
* yet thread app runtime state explicitly.
|
|
811
|
-
*/
|
|
812
|
-
export function getAppBuildAdapter(appConfig: EcoPagesAppConfig): BuildAdapter {
|
|
813
|
-
return appConfig.runtime?.buildAdapter ?? getDefaultBuildAdapter(getAppBuildOwnership(appConfig));
|
|
814
|
-
}
|
|
815
|
-
|
|
816
|
-
/**
|
|
817
|
-
* Installs the adapter that should serve future builds for one app instance.
|
|
818
|
-
*/
|
|
819
|
-
export function setAppBuildAdapter(appConfig: EcoPagesAppConfig, buildAdapter: BuildAdapter): void {
|
|
820
|
-
appConfig.runtime = {
|
|
821
|
-
...(appConfig.runtime ?? {}),
|
|
822
|
-
buildOwnership: getBuildAdapterOwnership(buildAdapter),
|
|
823
|
-
buildAdapter,
|
|
824
|
-
};
|
|
825
|
-
}
|
|
826
|
-
|
|
827
|
-
/**
|
|
828
|
-
* Returns the build manifest owned by an app/runtime instance.
|
|
829
|
-
*/
|
|
830
|
-
export function getAppBuildManifest(appConfig: EcoPagesAppConfig): AppBuildManifest {
|
|
831
|
-
return (
|
|
832
|
-
appConfig.runtime?.buildManifest ??
|
|
833
|
-
createAppBuildManifest({
|
|
834
|
-
loaderPlugins: Array.from(appConfig.loaders.values()),
|
|
835
|
-
})
|
|
836
|
-
);
|
|
837
|
-
}
|
|
838
|
-
|
|
839
|
-
/**
|
|
840
|
-
* Installs the build manifest that should be visible to one app instance.
|
|
841
|
-
*/
|
|
842
|
-
export function setAppBuildManifest(appConfig: EcoPagesAppConfig, buildManifest: AppBuildManifest): void {
|
|
843
|
-
appConfig.runtime = {
|
|
844
|
-
...(appConfig.runtime ?? {}),
|
|
845
|
-
buildManifest,
|
|
846
|
-
};
|
|
847
|
-
}
|
|
848
|
-
|
|
849
|
-
/**
|
|
850
|
-
* Rebuilds an app-owned manifest from config-owned loaders plus explicit
|
|
851
|
-
* runtime/browser contribution input.
|
|
852
|
-
*
|
|
853
|
-
* @remarks
|
|
854
|
-
* This keeps loader ownership with config finalization while still letting a
|
|
855
|
-
* caller supply the non-loader plugin buckets that were discovered elsewhere.
|
|
856
|
-
*/
|
|
857
|
-
export function createConfiguredAppBuildManifest(
|
|
858
|
-
appConfig: EcoPagesAppConfig,
|
|
859
|
-
input?: Partial<AppBuildManifest>,
|
|
860
|
-
): AppBuildManifest {
|
|
861
|
-
return createAppBuildManifest({
|
|
862
|
-
loaderPlugins: input?.loaderPlugins ?? Array.from(appConfig.loaders.values()),
|
|
863
|
-
runtimePlugins: input?.runtimePlugins,
|
|
864
|
-
browserBundlePlugins: input?.browserBundlePlugins,
|
|
865
|
-
});
|
|
866
|
-
}
|
|
867
|
-
|
|
868
|
-
/**
|
|
869
|
-
* Replaces the app-owned manifest using config-owned loaders and explicit
|
|
870
|
-
* contribution input.
|
|
871
|
-
*/
|
|
872
|
-
export function updateAppBuildManifest(appConfig: EcoPagesAppConfig, input?: Partial<AppBuildManifest>): void {
|
|
873
|
-
setAppBuildManifest(appConfig, createConfiguredAppBuildManifest(appConfig, input));
|
|
874
|
-
}
|
|
875
|
-
|
|
876
|
-
/**
|
|
877
|
-
* Collects the build-facing processor and integration contributions that should
|
|
878
|
-
* be sealed into the app manifest during config finalization.
|
|
879
|
-
*
|
|
880
|
-
* @remarks
|
|
881
|
-
* This runs `prepareBuildContributions()` only. Runtime-only side effects such
|
|
882
|
-
* as HMR registration, cache prewarming, and runtime-origin wiring belong to
|
|
883
|
-
* the startup path and must not be triggered here.
|
|
884
|
-
*/
|
|
885
|
-
export async function collectConfiguredAppBuildManifestContributions(
|
|
886
|
-
appConfig: EcoPagesAppConfig,
|
|
887
|
-
): Promise<Pick<AppBuildManifest, 'runtimePlugins' | 'browserBundlePlugins'>> {
|
|
888
|
-
const runtimePlugins: EcoBuildPlugin[] = [];
|
|
889
|
-
const browserBundlePlugins: EcoBuildPlugin[] = [];
|
|
890
|
-
|
|
891
|
-
for (const processor of appConfig.processors.values()) {
|
|
892
|
-
await processor.prepareBuildContributions();
|
|
893
|
-
|
|
894
|
-
if (processor.plugins) {
|
|
895
|
-
runtimePlugins.push(...processor.plugins);
|
|
896
|
-
}
|
|
897
|
-
|
|
898
|
-
if (processor.buildPlugins) {
|
|
899
|
-
browserBundlePlugins.push(...processor.buildPlugins);
|
|
900
|
-
}
|
|
901
|
-
}
|
|
902
|
-
|
|
903
|
-
for (const integration of appConfig.integrations) {
|
|
904
|
-
integration.setConfig(appConfig);
|
|
905
|
-
await integration.prepareBuildContributions();
|
|
906
|
-
runtimePlugins.push(...(integration.plugins ?? []));
|
|
907
|
-
browserBundlePlugins.push(...(integration.browserBuildPlugins ?? []));
|
|
908
|
-
}
|
|
909
|
-
|
|
910
|
-
return {
|
|
911
|
-
runtimePlugins,
|
|
912
|
-
browserBundlePlugins,
|
|
913
|
-
};
|
|
914
|
-
}
|
|
915
|
-
|
|
916
|
-
/**
|
|
917
|
-
* Runs runtime-only processor and integration setup against an already sealed
|
|
918
|
-
* app manifest.
|
|
919
|
-
*
|
|
920
|
-
* @remarks
|
|
921
|
-
* Startup paths call this after config build has finalized manifest
|
|
922
|
-
* contributions. The manifest is reused as-is; this helper only performs the
|
|
923
|
-
* runtime side effects that still need live startup context.
|
|
924
|
-
*/
|
|
925
|
-
export async function setupAppRuntimePlugins(options: {
|
|
926
|
-
appConfig: EcoPagesAppConfig;
|
|
927
|
-
runtimeOrigin: string;
|
|
928
|
-
hmrManager?: IHmrManager;
|
|
929
|
-
onRuntimePlugin?: (plugin: EcoBuildPlugin) => void;
|
|
930
|
-
}): Promise<void> {
|
|
931
|
-
for (const processor of options.appConfig.processors.values()) {
|
|
932
|
-
await processor.setup();
|
|
933
|
-
|
|
934
|
-
if (processor.plugins) {
|
|
935
|
-
for (const plugin of processor.plugins) {
|
|
936
|
-
options.onRuntimePlugin?.(plugin);
|
|
937
|
-
}
|
|
938
|
-
}
|
|
939
|
-
}
|
|
940
|
-
|
|
941
|
-
for (const integration of options.appConfig.integrations) {
|
|
942
|
-
integration.setConfig(options.appConfig);
|
|
943
|
-
integration.setRuntimeOrigin(options.runtimeOrigin);
|
|
944
|
-
if (options.hmrManager) {
|
|
945
|
-
integration.setHmrManager(options.hmrManager);
|
|
946
|
-
}
|
|
947
|
-
|
|
948
|
-
await integration.setup();
|
|
949
|
-
|
|
950
|
-
for (const plugin of integration.plugins) {
|
|
951
|
-
options.onRuntimePlugin?.(plugin);
|
|
952
|
-
}
|
|
953
|
-
}
|
|
954
|
-
}
|
|
955
|
-
|
|
956
|
-
export function getAppServerBuildPlugins(appConfig: EcoPagesAppConfig): EcoBuildPlugin[] {
|
|
957
|
-
return getServerBuildPlugins(getAppBuildManifest(appConfig));
|
|
958
|
-
}
|
|
959
|
-
|
|
960
|
-
export function getAppBrowserBuildPlugins(appConfig: EcoPagesAppConfig): EcoBuildPlugin[] {
|
|
961
|
-
return getBrowserBuildPlugins(getAppBuildManifest(appConfig));
|
|
962
|
-
}
|
|
963
|
-
|
|
964
|
-
/**
|
|
965
|
-
* Returns the executor owned by an app/runtime instance.
|
|
966
|
-
*
|
|
967
|
-
* @remarks
|
|
968
|
-
* The config builder seeds this with the app-owned adapter. Runtime adapters
|
|
969
|
-
* may replace it with a compatibility coordinator while keeping ownership tied
|
|
970
|
-
* to the same Bun-native backend.
|
|
971
|
-
*/
|
|
972
|
-
export function getAppBuildExecutor(appConfig: EcoPagesAppConfig): BuildExecutor {
|
|
973
|
-
return appConfig.runtime?.buildExecutor ?? getAppBuildAdapter(appConfig);
|
|
974
|
-
}
|
|
975
|
-
|
|
976
|
-
/**
|
|
977
|
-
* Installs the executor that should serve future builds for one app instance.
|
|
978
|
-
*/
|
|
979
|
-
export function setAppBuildExecutor(appConfig: EcoPagesAppConfig, buildExecutor: BuildExecutor): void {
|
|
980
|
-
appConfig.runtime = {
|
|
981
|
-
...(appConfig.runtime ?? {}),
|
|
982
|
-
buildExecutor,
|
|
983
|
-
};
|
|
984
|
-
}
|
|
985
|
-
|
|
986
|
-
/**
|
|
987
|
-
* Runs a build through the active pipeline.
|
|
988
|
-
*
|
|
989
|
-
* @remarks
|
|
990
|
-
* Callers can pass an explicit executor when builds should be routed through an
|
|
991
|
-
* app-owned development coordinator. Without one, the Bun-native default
|
|
992
|
-
* adapter is used directly.
|
|
993
|
-
*/
|
|
994
|
-
export function build(options: BuildOptions, executor: BuildExecutor = defaultBunBuildAdapter): Promise<BuildResult> {
|
|
995
|
-
return executor.build(options);
|
|
996
|
-
}
|
|
997
|
-
|
|
998
|
-
/**
|
|
999
|
-
* Bun-native fallback helper for callsites without app runtime context.
|
|
1000
|
-
*
|
|
1001
|
-
* New app-aware code should prefer `getAppTranspileOptions()`.
|
|
1002
|
-
*/
|
|
1003
|
-
export function getTranspileOptions(profile: BuildTranspileProfile): BuildTranspileOptions {
|
|
1004
|
-
return defaultBunBuildAdapter.getTranspileOptions(profile);
|
|
1005
|
-
}
|
|
1006
|
-
|
|
1007
|
-
export function getAppTranspileOptions(
|
|
1008
|
-
appConfig: EcoPagesAppConfig,
|
|
1009
|
-
profile: BuildTranspileProfile,
|
|
1010
|
-
): BuildTranspileOptions {
|
|
1011
|
-
return getAppBuildAdapter(appConfig).getTranspileOptions(profile);
|
|
1012
|
-
}
|