@ecopages/core 0.2.0-alpha.9 → 0.2.1
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 +18 -11
- package/README.md +23 -26
- package/package.json +76 -58
- 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 +4 -12
- package/src/adapters/bun/create-app.js +4 -5
- package/src/adapters/bun/hmr-manager.d.ts +4 -4
- package/src/adapters/bun/hmr-manager.js +8 -8
- package/src/adapters/bun/index.d.ts +1 -1
- package/src/adapters/bun/index.js +2 -2
- package/src/adapters/bun/server-adapter.d.ts +5 -5
- package/src/adapters/bun/server-adapter.js +6 -5
- package/src/adapters/bun/server-lifecycle.d.ts +4 -4
- package/src/adapters/bun/server-lifecycle.js +2 -2
- 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 +6 -9
- package/src/adapters/node/create-app.js +12 -6
- package/src/adapters/node/node-client-bridge.d.ts +1 -1
- package/src/adapters/node/node-hmr-manager.d.ts +2 -2
- package/src/adapters/node/node-hmr-manager.js +3 -3
- package/src/adapters/node/server-adapter.d.ts +4 -4
- package/src/adapters/node/server-adapter.js +13 -12
- package/src/adapters/node/static-content-server.d.ts +1 -1
- package/src/adapters/node/static-content-server.js +1 -1
- 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-route-matcher.d.ts +2 -2
- package/src/adapters/shared/file-route-middleware-pipeline.d.ts +1 -1
- package/src/adapters/shared/fs-server-response-factory.d.ts +2 -2
- package/src/adapters/shared/fs-server-response-factory.js +1 -1
- package/src/adapters/shared/fs-server-response-matcher.d.ts +1 -1
- 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/render-context.d.ts +2 -1
- package/src/adapters/shared/render-context.js +3 -1
- package/src/adapters/shared/runtime-bootstrap.d.ts +1 -1
- package/src/adapters/shared/runtime-bootstrap.js +1 -1
- package/src/adapters/shared/server-adapter.d.ts +1 -1
- package/src/adapters/shared/server-adapter.js +5 -1
- package/src/adapters/shared/server-route-handler.d.ts +4 -4
- package/src/adapters/shared/server-route-handler.js +3 -3
- package/src/adapters/shared/server-static-builder.d.ts +5 -5
- package/src/adapters/shared/server-static-builder.js +5 -4
- package/src/build/README.md +19 -13
- package/src/build/build-adapter.d.ts +67 -20
- package/src/build/build-adapter.js +420 -19
- package/src/build/dev-build-coordinator.d.ts +10 -12
- package/src/build/dev-build-coordinator.js +8 -15
- package/src/build/esbuild-build-adapter.d.ts +6 -0
- package/src/build/esbuild-build-adapter.js +94 -11
- package/src/build/runtime-build-executor.d.ts +5 -4
- package/src/build/runtime-build-executor.js +5 -3
- package/src/build/runtime-specifier-alias-plugin.js +19 -15
- package/src/build/runtime-specifier-aliases.d.ts +5 -0
- package/src/build/runtime-specifier-aliases.js +95 -0
- package/src/config/README.md +5 -2
- package/src/config/config-builder.d.ts +25 -2
- package/src/config/config-builder.js +44 -7
- package/src/declarations.d.ts +1 -1
- 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 +83 -0
- package/src/eco/eco.js +19 -48
- package/src/eco/eco.types.d.ts +1 -1
- 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 +1 -1
- package/src/eco/lazy-injector-map.d.ts +1 -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 +2 -2
- package/src/hmr/strategies/js-hmr-strategy.js +2 -2
- 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 +6 -1
- package/src/integrations/ghtml/ghtml-renderer.js +29 -28
- package/src/integrations/ghtml/ghtml.plugin.d.ts +2 -2
- package/src/integrations/ghtml/ghtml.plugin.js +2 -2
- package/src/plugins/README.md +1 -0
- package/src/plugins/eco-component-meta-plugin.d.ts +12 -1
- package/src/plugins/eco-component-meta-plugin.js +26 -20
- 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 +99 -33
- package/src/plugins/integration-plugin.js +68 -21
- package/src/plugins/processor.d.ts +2 -2
- package/src/plugins/processor.js +2 -2
- package/src/plugins/source-transform.d.ts +46 -0
- package/src/plugins/source-transform.js +71 -0
- package/src/route-renderer/GRAPH.md +54 -84
- package/src/route-renderer/README.md +14 -20
- package/src/route-renderer/orchestration/component-render-context.d.ts +83 -0
- package/src/route-renderer/orchestration/component-render-context.js +147 -0
- package/src/route-renderer/orchestration/integration-renderer.d.ts +233 -76
- package/src/route-renderer/orchestration/integration-renderer.js +500 -143
- package/src/route-renderer/orchestration/queued-boundary-runtime.service.d.ts +93 -0
- package/src/route-renderer/orchestration/queued-boundary-runtime.service.js +155 -0
- package/src/route-renderer/orchestration/render-execution.service.d.ts +11 -71
- package/src/route-renderer/orchestration/render-execution.service.js +65 -80
- package/src/{eco/eco.utils.ts → route-renderer/orchestration/render-output.utils.d.ts} +10 -53
- package/src/route-renderer/orchestration/render-output.utils.js +65 -0
- package/src/route-renderer/orchestration/render-preparation.service.d.ts +2 -8
- package/src/route-renderer/orchestration/render-preparation.service.js +10 -17
- 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/dependency-resolver.d.ts +2 -2
- package/src/route-renderer/page-loading/dependency-resolver.js +10 -8
- package/src/route-renderer/page-loading/page-module-loader.d.ts +6 -4
- package/src/route-renderer/page-loading/page-module-loader.js +7 -5
- package/src/route-renderer/route-renderer.d.ts +5 -3
- package/src/route-renderer/route-renderer.js +13 -3
- package/src/router/README.md +79 -8
- package/src/router/client/navigation-coordinator.js +2 -2
- package/src/router/server/fs-router-scanner.d.ts +1 -1
- package/src/router/server/fs-router-scanner.js +6 -1
- package/src/router/server/fs-router.d.ts +1 -1
- package/src/services/assets/asset-processing-service/asset-processing.service.d.ts +3 -3
- package/src/services/assets/asset-processing-service/asset-processing.service.js +6 -6
- 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/index.d.ts +5 -5
- package/src/services/assets/asset-processing-service/index.js +5 -5
- 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 +1 -1
- package/src/services/assets/asset-processing-service/processors/base/base-script-processor.d.ts +3 -3
- package/src/services/assets/asset-processing-service/processors/base/base-script-processor.js +2 -2
- 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 +2 -2
- package/src/services/assets/asset-processing-service/processors/script/content-script.processor.js +1 -1
- 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 +15 -3
- package/src/services/assets/asset-processing-service/processors/script/node-module-script.processor.d.ts +3 -3
- package/src/services/assets/asset-processing-service/processors/script/node-module-script.processor.js +1 -1
- package/src/services/assets/asset-processing-service/processors/stylesheet/content-stylesheet.processor.d.ts +2 -2
- package/src/services/assets/asset-processing-service/processors/stylesheet/content-stylesheet.processor.js +1 -1
- 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 +1 -1
- package/src/services/assets/browser-bundle.service.d.ts +1 -1
- package/src/services/assets/browser-bundle.service.js +2 -2
- package/src/services/html/html-rewriter-provider.service.js +4 -1
- package/src/services/html/html-transformer.service.d.ts +2 -2
- package/src/services/html/html-transformer.service.js +4 -10
- 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 +25 -0
- package/src/services/module-loading/app-module-loader.service.js +31 -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 +77 -2
- 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/{adapters/node/bootstrap-dependency-resolver.d.ts → services/module-loading/node-bootstrap-plugin.d.ts} +2 -24
- package/src/{adapters/node/bootstrap-dependency-resolver.js → services/module-loading/node-bootstrap-plugin.js} +42 -22
- package/src/services/module-loading/page-module-import.service.d.ts +4 -0
- package/src/services/module-loading/page-module-import.service.js +38 -9
- package/src/services/module-loading/server-module-transpiler.service.d.ts +3 -0
- package/src/services/module-loading/server-module-transpiler.service.js +4 -1
- 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/runtime-specifier-registry.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 +2 -2
- package/src/static-site-generator/static-site-generator.js +1 -1
- package/src/{internal-types.d.ts → types/internal-types.d.ts} +24 -14
- package/src/{public-types.d.ts → types/public-types.d.ts} +30 -14
- 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 +4 -10
- package/src/watchers/project-watcher.test-helpers.d.ts +2 -2
- 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.ts +0 -124
- package/src/adapters/index.ts +0 -6
- 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.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.ts +0 -221
- 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.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/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.ts +0 -230
- 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.ts +0 -219
- 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.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/{constants.d.ts → config/constants.d.ts} +0 -0
- /package/src/{constants.js → config/constants.js} +0 -0
- /package/src/{internal-types.js → services/module-loading/module-loading-types.js} +0 -0
- /package/src/{public-types.js → types/internal-types.js} +0 -0
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
import path from 'node:path';
|
|
2
|
-
import { fileSystem } from '@ecopages/file-system';
|
|
3
|
-
import { StaticContentServer } from '../../dev/sc-server';
|
|
4
|
-
import { appLogger } from '../../global/app-logger';
|
|
5
|
-
import type { EcoPagesAppConfig } from '../../internal-types';
|
|
6
|
-
import type { ApiHandler, StaticRoute } from '../../public-types';
|
|
7
|
-
import type { RouteRendererFactory } from '../../route-renderer/route-renderer';
|
|
8
|
-
import type { FSRouter } from '../../router/server/fs-router';
|
|
9
|
-
import type { StaticSiteGenerator } from '../../static-site-generator/static-site-generator';
|
|
10
|
-
|
|
11
|
-
export interface StaticBuildOptions {
|
|
12
|
-
preview?: boolean;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export interface ServeOptions {
|
|
16
|
-
hostname?: string;
|
|
17
|
-
port?: number | string;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export interface ServerStaticBuilderParams {
|
|
21
|
-
appConfig: EcoPagesAppConfig;
|
|
22
|
-
staticSiteGenerator: StaticSiteGenerator;
|
|
23
|
-
serveOptions: ServeOptions;
|
|
24
|
-
apiHandlers?: ApiHandler[];
|
|
25
|
-
logger?: ServerStaticBuilderLogger;
|
|
26
|
-
previewServerFactory?: ServerStaticPreviewServerFactory;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Minimal logger dependency used by the static builder.
|
|
31
|
-
*/
|
|
32
|
-
export interface ServerStaticBuilderLogger {
|
|
33
|
-
warn(message: string, detail?: string): unknown;
|
|
34
|
-
info(message: string): unknown;
|
|
35
|
-
error(message: string): unknown;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Preview server factory dependency used when static preview mode is enabled.
|
|
40
|
-
*/
|
|
41
|
-
export interface ServerStaticPreviewServerFactory {
|
|
42
|
-
createServer(args: { appConfig: EcoPagesAppConfig; options: { port: number } }): {
|
|
43
|
-
server?: {
|
|
44
|
-
port?: number;
|
|
45
|
-
} | null;
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Handles static site generation and previews.
|
|
51
|
-
*/
|
|
52
|
-
export class ServerStaticBuilder {
|
|
53
|
-
private readonly appConfig: EcoPagesAppConfig;
|
|
54
|
-
private readonly staticSiteGenerator: StaticSiteGenerator;
|
|
55
|
-
private readonly serveOptions: ServeOptions;
|
|
56
|
-
private readonly apiHandlers: ApiHandler[];
|
|
57
|
-
private readonly logger: ServerStaticBuilderLogger;
|
|
58
|
-
private readonly previewServerFactory: ServerStaticPreviewServerFactory;
|
|
59
|
-
|
|
60
|
-
constructor({
|
|
61
|
-
appConfig,
|
|
62
|
-
staticSiteGenerator,
|
|
63
|
-
serveOptions,
|
|
64
|
-
apiHandlers,
|
|
65
|
-
logger,
|
|
66
|
-
previewServerFactory,
|
|
67
|
-
}: ServerStaticBuilderParams) {
|
|
68
|
-
this.appConfig = appConfig;
|
|
69
|
-
this.staticSiteGenerator = staticSiteGenerator;
|
|
70
|
-
this.serveOptions = serveOptions;
|
|
71
|
-
this.apiHandlers = apiHandlers ?? [];
|
|
72
|
-
this.logger = logger ?? appLogger;
|
|
73
|
-
this.previewServerFactory = previewServerFactory ?? StaticContentServer;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
private warnApiHandlersUnavailableInStaticMode(): void {
|
|
77
|
-
if (this.apiHandlers.length === 0) {
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
const uniqueHandlers = Array.from(
|
|
82
|
-
new Set(this.apiHandlers.map((handler) => `${handler.method} ${handler.path}`)),
|
|
83
|
-
);
|
|
84
|
-
const visibleHandlers = uniqueHandlers.slice(0, 5).join(', ');
|
|
85
|
-
const remainingCount = uniqueHandlers.length - Math.min(uniqueHandlers.length, 5);
|
|
86
|
-
const summary = remainingCount > 0 ? `${visibleHandlers}, +${remainingCount} more` : visibleHandlers;
|
|
87
|
-
|
|
88
|
-
this.logger.warn(
|
|
89
|
-
'Registered API endpoints are not available in static build or preview modes because no server runtime is started. They are excluded from the generated output.\n',
|
|
90
|
-
`➤ ${summary}`,
|
|
91
|
-
);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
private prepareExportDirectory(): void {
|
|
95
|
-
const exportDir =
|
|
96
|
-
this.appConfig.absolutePaths?.distDir ?? path.join(this.appConfig.rootDir, this.appConfig.distDir);
|
|
97
|
-
fileSystem.ensureDir(exportDir, true);
|
|
98
|
-
|
|
99
|
-
const srcPublicDir = path.join(
|
|
100
|
-
this.appConfig.rootDir,
|
|
101
|
-
this.appConfig.srcDir ?? 'src',
|
|
102
|
-
this.appConfig.publicDir ?? 'public',
|
|
103
|
-
);
|
|
104
|
-
if (fileSystem.exists(srcPublicDir)) {
|
|
105
|
-
fileSystem.copyDir(srcPublicDir, exportDir);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
private async refreshRuntimeAssets(): Promise<void> {
|
|
110
|
-
for (const processor of this.appConfig.processors.values()) {
|
|
111
|
-
await processor.setup();
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
for (const integration of this.appConfig.integrations) {
|
|
115
|
-
await integration.setup();
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* Generates a static build of the site for deployment.
|
|
121
|
-
* @param options.preview - If true, starts a preview server after build
|
|
122
|
-
* @param dependencies.router - The initialized router
|
|
123
|
-
* @param dependencies.routeRendererFactory - The route renderer factory
|
|
124
|
-
* @param dependencies.staticRoutes - Explicit static routes registered via app.static()
|
|
125
|
-
*/
|
|
126
|
-
async build(
|
|
127
|
-
options: StaticBuildOptions | undefined,
|
|
128
|
-
dependencies: {
|
|
129
|
-
router: FSRouter;
|
|
130
|
-
routeRendererFactory: RouteRendererFactory;
|
|
131
|
-
staticRoutes?: StaticRoute[];
|
|
132
|
-
},
|
|
133
|
-
): Promise<void> {
|
|
134
|
-
const { preview = false } = options ?? {};
|
|
135
|
-
|
|
136
|
-
const baseUrl = `http://${this.serveOptions.hostname || 'localhost'}:${this.serveOptions.port || 3000}`;
|
|
137
|
-
this.warnApiHandlersUnavailableInStaticMode();
|
|
138
|
-
this.prepareExportDirectory();
|
|
139
|
-
await this.refreshRuntimeAssets();
|
|
140
|
-
|
|
141
|
-
await this.staticSiteGenerator.run({
|
|
142
|
-
router: dependencies.router,
|
|
143
|
-
baseUrl,
|
|
144
|
-
routeRendererFactory: dependencies.routeRendererFactory,
|
|
145
|
-
staticRoutes: dependencies.staticRoutes,
|
|
146
|
-
});
|
|
147
|
-
|
|
148
|
-
if (!preview) {
|
|
149
|
-
this.logger.info('Build completed');
|
|
150
|
-
return;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
const previewPort = this.serveOptions.port || 3000;
|
|
154
|
-
|
|
155
|
-
const { server } = this.previewServerFactory.createServer({
|
|
156
|
-
appConfig: this.appConfig,
|
|
157
|
-
options: { port: Number(previewPort) },
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
if (server?.port) {
|
|
161
|
-
this.logger.info(`Preview running at http://localhost:${server.port}`);
|
|
162
|
-
} else {
|
|
163
|
-
this.logger.error('Failed to start preview server');
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
}
|
|
@@ -1,361 +0,0 @@
|
|
|
1
|
-
import type { BunPlugin } from 'bun';
|
|
2
|
-
import type { EcoBuildPlugin } from './build-types.ts';
|
|
3
|
-
import {
|
|
4
|
-
createAppBuildManifest,
|
|
5
|
-
getBrowserBuildPlugins,
|
|
6
|
-
getServerBuildPlugins,
|
|
7
|
-
type AppBuildManifest,
|
|
8
|
-
} from './build-manifest.ts';
|
|
9
|
-
import { EsbuildBuildAdapter } from './esbuild-build-adapter.ts';
|
|
10
|
-
import { getRequiredBunRuntime } from '../utils/runtime.ts';
|
|
11
|
-
import type { EcoPagesAppConfig } from '../internal-types.ts';
|
|
12
|
-
import type { IHmrManager } from '../public-types.ts';
|
|
13
|
-
|
|
14
|
-
export { EsbuildBuildAdapter } from './esbuild-build-adapter.ts';
|
|
15
|
-
|
|
16
|
-
export interface BuildLog {
|
|
17
|
-
message: string;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export interface BuildOutput {
|
|
21
|
-
path: string;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Dependency graph metadata produced by a build backend.
|
|
26
|
-
*
|
|
27
|
-
* @remarks
|
|
28
|
-
* This structure is runtime-neutral at the type level, but current population
|
|
29
|
-
* is Node/esbuild-only. Bun-backed builds may omit this metadata.
|
|
30
|
-
*/
|
|
31
|
-
export interface BuildDependencyGraph {
|
|
32
|
-
/**
|
|
33
|
-
* Normalized absolute entrypoint path mapped to all normalized absolute
|
|
34
|
-
* source inputs that contributed to that entrypoint output.
|
|
35
|
-
*/
|
|
36
|
-
entrypoints: Record<string, string[]>;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export interface BuildResult {
|
|
40
|
-
success: boolean;
|
|
41
|
-
logs: BuildLog[];
|
|
42
|
-
outputs: BuildOutput[];
|
|
43
|
-
/**
|
|
44
|
-
* Optional build dependency metadata for selective invalidation.
|
|
45
|
-
*
|
|
46
|
-
* @remarks
|
|
47
|
-
* This is currently filled by the Node/esbuild adapter. Other runtimes should
|
|
48
|
-
* treat missing graph data as a valid state and fall back deterministically.
|
|
49
|
-
*/
|
|
50
|
-
dependencyGraph?: BuildDependencyGraph;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export interface BuildOptions {
|
|
54
|
-
entrypoints: string[];
|
|
55
|
-
outdir?: string;
|
|
56
|
-
outbase?: string;
|
|
57
|
-
naming?: string;
|
|
58
|
-
conditions?: string[];
|
|
59
|
-
define?: Record<string, string>;
|
|
60
|
-
minify?: boolean;
|
|
61
|
-
treeshaking?: boolean;
|
|
62
|
-
target?: string;
|
|
63
|
-
format?: string;
|
|
64
|
-
sourcemap?: string;
|
|
65
|
-
splitting?: boolean;
|
|
66
|
-
root?: string;
|
|
67
|
-
bundle?: boolean;
|
|
68
|
-
externalPackages?: boolean;
|
|
69
|
-
external?: string[];
|
|
70
|
-
plugins?: EcoBuildPlugin[];
|
|
71
|
-
[key: string]: unknown;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
export type BuildTranspileProfile = 'browser-script' | 'hmr-runtime' | 'hmr-entrypoint';
|
|
75
|
-
|
|
76
|
-
export interface BuildTranspileOptions {
|
|
77
|
-
target: string;
|
|
78
|
-
format: string;
|
|
79
|
-
sourcemap: string;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
export interface BuildAdapter {
|
|
83
|
-
/**
|
|
84
|
-
* Executes one concrete backend build.
|
|
85
|
-
*
|
|
86
|
-
* @remarks
|
|
87
|
-
* `BuildAdapter` is the low-level backend contract. The default adapter is
|
|
88
|
-
* `EsbuildBuildAdapter`, but alternate adapters may satisfy the same shape.
|
|
89
|
-
*/
|
|
90
|
-
build(options: BuildOptions): Promise<BuildResult>;
|
|
91
|
-
resolve(importPath: string, rootDir: string): string;
|
|
92
|
-
getTranspileOptions(profile: BuildTranspileProfile): BuildTranspileOptions;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* Runtime-owned facade for issuing builds.
|
|
97
|
-
*
|
|
98
|
-
* @remarks
|
|
99
|
-
* This is intentionally narrower than `BuildAdapter`. A build executor answers
|
|
100
|
-
* only the question "how should this app execute a build right now?".
|
|
101
|
-
*
|
|
102
|
-
* In production and non-watch flows the executor is usually the adapter itself,
|
|
103
|
-
* which today means `EsbuildBuildAdapter`. In development watch flows the
|
|
104
|
-
* executor is typically `DevBuildCoordinator`, which wraps the shared esbuild
|
|
105
|
-
* adapter to serialize callers and recover from known worker faults.
|
|
106
|
-
*/
|
|
107
|
-
export interface BuildExecutor {
|
|
108
|
-
build(options: BuildOptions): Promise<BuildResult>;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
export function createBuildAdapter(): BuildAdapter {
|
|
112
|
-
return new EsbuildBuildAdapter();
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
function transpileProfileToOptions(profile: BuildTranspileProfile): BuildTranspileOptions {
|
|
116
|
-
switch (profile) {
|
|
117
|
-
case 'browser-script':
|
|
118
|
-
return {
|
|
119
|
-
target: 'browser',
|
|
120
|
-
format: 'esm',
|
|
121
|
-
sourcemap: 'none',
|
|
122
|
-
};
|
|
123
|
-
case 'hmr-runtime':
|
|
124
|
-
return {
|
|
125
|
-
target: 'browser',
|
|
126
|
-
format: 'esm',
|
|
127
|
-
sourcemap: 'none',
|
|
128
|
-
};
|
|
129
|
-
case 'hmr-entrypoint':
|
|
130
|
-
return {
|
|
131
|
-
target: 'browser',
|
|
132
|
-
format: 'esm',
|
|
133
|
-
sourcemap: 'none',
|
|
134
|
-
};
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* @deprecated Use EsbuildBuildAdapter instead. Bun native build is missing some dependency graph features.
|
|
140
|
-
*/
|
|
141
|
-
export class BunBuildAdapter implements BuildAdapter {
|
|
142
|
-
async build(options: BuildOptions): Promise<BuildResult> {
|
|
143
|
-
const bun = getRequiredBunRuntime();
|
|
144
|
-
const result = await bun.build({
|
|
145
|
-
...options,
|
|
146
|
-
plugins: options.plugins as BunPlugin[] | undefined,
|
|
147
|
-
} as Bun.BuildConfig);
|
|
148
|
-
|
|
149
|
-
return {
|
|
150
|
-
success: result.success,
|
|
151
|
-
logs: result.logs.map((log) => ({ message: log.message })),
|
|
152
|
-
outputs: result.outputs.map((output) => ({ path: output.path })),
|
|
153
|
-
};
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
resolve(importPath: string, rootDir: string): string {
|
|
157
|
-
return getRequiredBunRuntime().resolveSync(importPath, rootDir);
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
getTranspileOptions(profile: BuildTranspileProfile): BuildTranspileOptions {
|
|
161
|
-
return transpileProfileToOptions(profile);
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
export const defaultBuildAdapter: BuildAdapter = createBuildAdapter();
|
|
166
|
-
|
|
167
|
-
/**
|
|
168
|
-
* Returns the adapter owned by an app/runtime instance.
|
|
169
|
-
*
|
|
170
|
-
* @remarks
|
|
171
|
-
* The config builder installs a dedicated adapter per app. The shared default
|
|
172
|
-
* adapter remains only as a compatibility fallback for older tests and helpers
|
|
173
|
-
* that do not yet thread app runtime state explicitly.
|
|
174
|
-
*/
|
|
175
|
-
export function getAppBuildAdapter(appConfig: EcoPagesAppConfig): BuildAdapter {
|
|
176
|
-
return appConfig.runtime?.buildAdapter ?? defaultBuildAdapter;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
/**
|
|
180
|
-
* Installs the adapter that should serve future builds for one app instance.
|
|
181
|
-
*/
|
|
182
|
-
export function setAppBuildAdapter(appConfig: EcoPagesAppConfig, buildAdapter: BuildAdapter): void {
|
|
183
|
-
appConfig.runtime = {
|
|
184
|
-
...(appConfig.runtime ?? {}),
|
|
185
|
-
buildAdapter,
|
|
186
|
-
};
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
/**
|
|
190
|
-
* Returns the build manifest owned by an app/runtime instance.
|
|
191
|
-
*/
|
|
192
|
-
export function getAppBuildManifest(appConfig: EcoPagesAppConfig): AppBuildManifest {
|
|
193
|
-
return (
|
|
194
|
-
appConfig.runtime?.buildManifest ??
|
|
195
|
-
createAppBuildManifest({
|
|
196
|
-
loaderPlugins: Array.from(appConfig.loaders.values()),
|
|
197
|
-
})
|
|
198
|
-
);
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
/**
|
|
202
|
-
* Installs the build manifest that should be visible to one app instance.
|
|
203
|
-
*/
|
|
204
|
-
export function setAppBuildManifest(appConfig: EcoPagesAppConfig, buildManifest: AppBuildManifest): void {
|
|
205
|
-
appConfig.runtime = {
|
|
206
|
-
...(appConfig.runtime ?? {}),
|
|
207
|
-
buildManifest,
|
|
208
|
-
};
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
/**
|
|
212
|
-
* Rebuilds an app-owned manifest from config-owned loaders plus explicit
|
|
213
|
-
* runtime/browser contribution input.
|
|
214
|
-
*
|
|
215
|
-
* @remarks
|
|
216
|
-
* This keeps loader ownership with config finalization while still letting a
|
|
217
|
-
* caller supply the non-loader plugin buckets that were discovered elsewhere.
|
|
218
|
-
*/
|
|
219
|
-
export function createConfiguredAppBuildManifest(
|
|
220
|
-
appConfig: EcoPagesAppConfig,
|
|
221
|
-
input?: Partial<AppBuildManifest>,
|
|
222
|
-
): AppBuildManifest {
|
|
223
|
-
return createAppBuildManifest({
|
|
224
|
-
loaderPlugins: input?.loaderPlugins ?? Array.from(appConfig.loaders.values()),
|
|
225
|
-
runtimePlugins: input?.runtimePlugins,
|
|
226
|
-
browserBundlePlugins: input?.browserBundlePlugins,
|
|
227
|
-
});
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
/**
|
|
231
|
-
* Replaces the app-owned manifest using config-owned loaders and explicit
|
|
232
|
-
* contribution input.
|
|
233
|
-
*/
|
|
234
|
-
export function updateAppBuildManifest(appConfig: EcoPagesAppConfig, input?: Partial<AppBuildManifest>): void {
|
|
235
|
-
setAppBuildManifest(appConfig, createConfiguredAppBuildManifest(appConfig, input));
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
/**
|
|
239
|
-
* Collects the build-facing processor and integration contributions that should
|
|
240
|
-
* be sealed into the app manifest during config finalization.
|
|
241
|
-
*
|
|
242
|
-
* @remarks
|
|
243
|
-
* This runs `prepareBuildContributions()` only. Runtime-only side effects such
|
|
244
|
-
* as HMR registration, cache prewarming, and runtime-origin wiring belong to
|
|
245
|
-
* the startup path and must not be triggered here.
|
|
246
|
-
*/
|
|
247
|
-
export async function collectConfiguredAppBuildManifestContributions(
|
|
248
|
-
appConfig: EcoPagesAppConfig,
|
|
249
|
-
): Promise<Pick<AppBuildManifest, 'runtimePlugins' | 'browserBundlePlugins'>> {
|
|
250
|
-
const runtimePlugins: EcoBuildPlugin[] = [];
|
|
251
|
-
const browserBundlePlugins: EcoBuildPlugin[] = [];
|
|
252
|
-
|
|
253
|
-
for (const processor of appConfig.processors.values()) {
|
|
254
|
-
await processor.prepareBuildContributions();
|
|
255
|
-
|
|
256
|
-
if (processor.plugins) {
|
|
257
|
-
runtimePlugins.push(...processor.plugins);
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
if (processor.buildPlugins) {
|
|
261
|
-
browserBundlePlugins.push(...processor.buildPlugins);
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
for (const integration of appConfig.integrations) {
|
|
266
|
-
integration.setConfig(appConfig);
|
|
267
|
-
await integration.prepareBuildContributions();
|
|
268
|
-
runtimePlugins.push(...integration.plugins);
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
return {
|
|
272
|
-
runtimePlugins,
|
|
273
|
-
browserBundlePlugins,
|
|
274
|
-
};
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
/**
|
|
278
|
-
* Runs runtime-only processor and integration setup against an already sealed
|
|
279
|
-
* app manifest.
|
|
280
|
-
*
|
|
281
|
-
* @remarks
|
|
282
|
-
* Startup paths call this after config build has finalized manifest
|
|
283
|
-
* contributions. The manifest is reused as-is; this helper only performs the
|
|
284
|
-
* runtime side effects that still need live startup context.
|
|
285
|
-
*/
|
|
286
|
-
export async function setupAppRuntimePlugins(options: {
|
|
287
|
-
appConfig: EcoPagesAppConfig;
|
|
288
|
-
runtimeOrigin: string;
|
|
289
|
-
hmrManager?: IHmrManager;
|
|
290
|
-
onRuntimePlugin?: (plugin: EcoBuildPlugin) => void;
|
|
291
|
-
}): Promise<void> {
|
|
292
|
-
for (const processor of options.appConfig.processors.values()) {
|
|
293
|
-
await processor.setup();
|
|
294
|
-
|
|
295
|
-
if (processor.plugins) {
|
|
296
|
-
for (const plugin of processor.plugins) {
|
|
297
|
-
options.onRuntimePlugin?.(plugin);
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
for (const integration of options.appConfig.integrations) {
|
|
303
|
-
integration.setConfig(options.appConfig);
|
|
304
|
-
integration.setRuntimeOrigin(options.runtimeOrigin);
|
|
305
|
-
if (options.hmrManager) {
|
|
306
|
-
integration.setHmrManager(options.hmrManager);
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
await integration.setup();
|
|
310
|
-
|
|
311
|
-
for (const plugin of integration.plugins) {
|
|
312
|
-
options.onRuntimePlugin?.(plugin);
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
export function getAppServerBuildPlugins(appConfig: EcoPagesAppConfig): EcoBuildPlugin[] {
|
|
318
|
-
return getServerBuildPlugins(getAppBuildManifest(appConfig));
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
export function getAppBrowserBuildPlugins(appConfig: EcoPagesAppConfig): EcoBuildPlugin[] {
|
|
322
|
-
return getBrowserBuildPlugins(getAppBuildManifest(appConfig));
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
/**
|
|
326
|
-
* Returns the executor owned by an app/runtime instance.
|
|
327
|
-
*
|
|
328
|
-
* @remarks
|
|
329
|
-
* The config builder seeds this with the shared default adapter. Runtime
|
|
330
|
-
* adapters may replace it with a coordinator that still delegates to the same
|
|
331
|
-
* backend while adding development policy.
|
|
332
|
-
*/
|
|
333
|
-
export function getAppBuildExecutor(appConfig: EcoPagesAppConfig): BuildExecutor {
|
|
334
|
-
return appConfig.runtime?.buildExecutor ?? getAppBuildAdapter(appConfig);
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
/**
|
|
338
|
-
* Installs the executor that should serve future builds for one app instance.
|
|
339
|
-
*/
|
|
340
|
-
export function setAppBuildExecutor(appConfig: EcoPagesAppConfig, buildExecutor: BuildExecutor): void {
|
|
341
|
-
appConfig.runtime = {
|
|
342
|
-
...(appConfig.runtime ?? {}),
|
|
343
|
-
buildExecutor,
|
|
344
|
-
};
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
/**
|
|
348
|
-
* Runs a build through the active pipeline.
|
|
349
|
-
*
|
|
350
|
-
* @remarks
|
|
351
|
-
* Callers can pass an explicit executor when builds should be routed through an
|
|
352
|
-
* app-owned development coordinator. Without one, the shared default adapter is
|
|
353
|
-
* used directly.
|
|
354
|
-
*/
|
|
355
|
-
export function build(options: BuildOptions, executor: BuildExecutor = defaultBuildAdapter): Promise<BuildResult> {
|
|
356
|
-
return executor.build(options);
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
export function getTranspileOptions(profile: BuildTranspileProfile): BuildTranspileOptions {
|
|
360
|
-
return defaultBuildAdapter.getTranspileOptions(profile);
|
|
361
|
-
}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import type { EcoBuildPlugin } from './build-types.ts';
|
|
2
|
-
|
|
3
|
-
export interface AppBuildManifest {
|
|
4
|
-
loaderPlugins: EcoBuildPlugin[];
|
|
5
|
-
runtimePlugins: EcoBuildPlugin[];
|
|
6
|
-
browserBundlePlugins: EcoBuildPlugin[];
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Merges plugin lists while preserving first-registration precedence by name.
|
|
11
|
-
*
|
|
12
|
-
* @remarks
|
|
13
|
-
* Build manifests treat plugin names as stable identities. The first plugin
|
|
14
|
-
* with a given name wins so config-time assembly stays deterministic across
|
|
15
|
-
* loader, runtime, and browser buckets.
|
|
16
|
-
*/
|
|
17
|
-
export function mergeEcoBuildPlugins(...pluginLists: Array<EcoBuildPlugin[] | undefined>): EcoBuildPlugin[] {
|
|
18
|
-
const byName = new Map<string, EcoBuildPlugin>();
|
|
19
|
-
|
|
20
|
-
for (const plugins of pluginLists) {
|
|
21
|
-
for (const plugin of plugins ?? []) {
|
|
22
|
-
if (!byName.has(plugin.name)) {
|
|
23
|
-
byName.set(plugin.name, plugin);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
return Array.from(byName.values());
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Creates one app-owned build manifest from the supplied plugin buckets.
|
|
33
|
-
*/
|
|
34
|
-
export function createAppBuildManifest(input?: Partial<AppBuildManifest>): AppBuildManifest {
|
|
35
|
-
return {
|
|
36
|
-
loaderPlugins: mergeEcoBuildPlugins(input?.loaderPlugins),
|
|
37
|
-
runtimePlugins: mergeEcoBuildPlugins(input?.runtimePlugins),
|
|
38
|
-
browserBundlePlugins: mergeEcoBuildPlugins(input?.browserBundlePlugins),
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Returns the plugin list used for server-oriented builds.
|
|
44
|
-
*/
|
|
45
|
-
export function getServerBuildPlugins(manifest: AppBuildManifest): EcoBuildPlugin[] {
|
|
46
|
-
return mergeEcoBuildPlugins(manifest.loaderPlugins, manifest.runtimePlugins);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Returns the plugin list used for browser-oriented builds.
|
|
51
|
-
*/
|
|
52
|
-
export function getBrowserBuildPlugins(manifest: AppBuildManifest): EcoBuildPlugin[] {
|
|
53
|
-
return mergeEcoBuildPlugins(manifest.loaderPlugins, manifest.runtimePlugins, manifest.browserBundlePlugins);
|
|
54
|
-
}
|
package/src/build/build-types.ts
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Arguments passed to a build plugin `onResolve` callback.
|
|
3
|
-
*/
|
|
4
|
-
export type EcoBuildOnResolveArgs = {
|
|
5
|
-
path: string;
|
|
6
|
-
importer?: string;
|
|
7
|
-
namespace?: string;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Result returned by a build plugin `onResolve` callback.
|
|
12
|
-
*/
|
|
13
|
-
export type EcoBuildOnResolveResult = {
|
|
14
|
-
path?: string;
|
|
15
|
-
namespace?: string;
|
|
16
|
-
external?: boolean;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Arguments passed to a build plugin `onLoad` callback.
|
|
21
|
-
*/
|
|
22
|
-
export type EcoBuildOnLoadArgs = {
|
|
23
|
-
path: string;
|
|
24
|
-
namespace?: string;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Loader kinds supported across Bun/esbuild bridge points.
|
|
29
|
-
*/
|
|
30
|
-
export type EcoBuildLoader =
|
|
31
|
-
| 'base64'
|
|
32
|
-
| 'binary'
|
|
33
|
-
| 'copy'
|
|
34
|
-
| 'css'
|
|
35
|
-
| 'dataurl'
|
|
36
|
-
| 'empty'
|
|
37
|
-
| 'file'
|
|
38
|
-
| 'global-css'
|
|
39
|
-
| 'js'
|
|
40
|
-
| 'json'
|
|
41
|
-
| 'jsx'
|
|
42
|
-
| 'local-css'
|
|
43
|
-
| 'object'
|
|
44
|
-
| 'text'
|
|
45
|
-
| 'ts'
|
|
46
|
-
| 'tsx';
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Result returned by a build plugin `onLoad` callback.
|
|
50
|
-
*/
|
|
51
|
-
export type EcoBuildOnLoadResult = {
|
|
52
|
-
contents?: string | Uint8Array;
|
|
53
|
-
loader?: EcoBuildLoader;
|
|
54
|
-
exports?: Record<string, unknown>;
|
|
55
|
-
resolveDir?: string;
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Shared plugin builder contract used by Ecopages across Bun and esbuild.
|
|
60
|
-
*/
|
|
61
|
-
export interface EcoBuildPluginBuilder {
|
|
62
|
-
onResolve(
|
|
63
|
-
options: { filter: RegExp; namespace?: string },
|
|
64
|
-
callback: (
|
|
65
|
-
args: EcoBuildOnResolveArgs,
|
|
66
|
-
) => EcoBuildOnResolveResult | undefined | Promise<EcoBuildOnResolveResult | undefined>,
|
|
67
|
-
): void;
|
|
68
|
-
onLoad(
|
|
69
|
-
options: { filter: RegExp; namespace?: string },
|
|
70
|
-
callback: (
|
|
71
|
-
args: EcoBuildOnLoadArgs,
|
|
72
|
-
) => EcoBuildOnLoadResult | undefined | Promise<EcoBuildOnLoadResult | undefined>,
|
|
73
|
-
): void;
|
|
74
|
-
module(specifier: string, callback: () => EcoBuildOnLoadResult | Promise<EcoBuildOnLoadResult>): void;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Runtime-agnostic build plugin contract consumed by Ecopages processors/loaders.
|
|
79
|
-
*/
|
|
80
|
-
export type EcoBuildPlugin = {
|
|
81
|
-
name: string;
|
|
82
|
-
setup: (build: EcoBuildPluginBuilder) => void | Promise<void>;
|
|
83
|
-
};
|