@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,8 +1,12 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { readFileSync, readdirSync, writeFileSync } from "node:fs";
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
|
+
import path from "node:path";
|
|
3
4
|
import { pathToFileURL } from "node:url";
|
|
4
5
|
import { fileSystem } from "@ecopages/file-system";
|
|
5
|
-
|
|
6
|
+
import { collectRuntimeSpecifierAliasMap, rewriteRuntimeSpecifierAliases } from "./runtime-specifier-aliases.js";
|
|
7
|
+
const moduleRequire = createRequire(import.meta.url);
|
|
8
|
+
const esbuildPath = moduleRequire.resolve("esbuild");
|
|
9
|
+
const workspaceNodePathsCache = /* @__PURE__ */ new Map();
|
|
6
10
|
function transpileProfileToOptions(profile) {
|
|
7
11
|
switch (profile) {
|
|
8
12
|
case "browser-script":
|
|
@@ -25,7 +29,78 @@ function transpileProfileToOptions(profile) {
|
|
|
25
29
|
};
|
|
26
30
|
}
|
|
27
31
|
}
|
|
32
|
+
const ESBUILD_ADAPTER_BRAND = /* @__PURE__ */ Symbol.for("EsbuildBuildAdapter");
|
|
28
33
|
class EsbuildBuildAdapter {
|
|
34
|
+
ownership = "bun-native";
|
|
35
|
+
[ESBUILD_ADAPTER_BRAND] = true;
|
|
36
|
+
collectWorkspaceNodePaths(scanRoot, maxDepth = 3) {
|
|
37
|
+
const normalizedRoot = path.resolve(scanRoot);
|
|
38
|
+
const cached = workspaceNodePathsCache.get(normalizedRoot);
|
|
39
|
+
if (cached) {
|
|
40
|
+
return cached;
|
|
41
|
+
}
|
|
42
|
+
const nodePaths = /* @__PURE__ */ new Set();
|
|
43
|
+
const skippedDirectoryNames = /* @__PURE__ */ new Set([".git", ".turbo", "dist", "node_modules", "test-results"]);
|
|
44
|
+
const visit = (dirPath, depth) => {
|
|
45
|
+
if (depth > maxDepth) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
const packageJsonPath = path.join(dirPath, "package.json");
|
|
49
|
+
const nodeModulesPath = path.join(dirPath, "node_modules");
|
|
50
|
+
if (fileSystem.exists(packageJsonPath) && fileSystem.exists(nodeModulesPath)) {
|
|
51
|
+
nodePaths.add(nodeModulesPath);
|
|
52
|
+
}
|
|
53
|
+
if (depth === maxDepth) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
for (const entry of readdirSync(dirPath, { withFileTypes: true })) {
|
|
57
|
+
if (!entry.isDirectory()) {
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
if (skippedDirectoryNames.has(entry.name) || entry.name.startsWith(".")) {
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
visit(path.join(dirPath, entry.name), depth + 1);
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
if (fileSystem.exists(normalizedRoot) && fileSystem.isDirectory(normalizedRoot)) {
|
|
67
|
+
visit(normalizedRoot, 0);
|
|
68
|
+
}
|
|
69
|
+
const resolvedNodePaths = Array.from(nodePaths);
|
|
70
|
+
workspaceNodePathsCache.set(normalizedRoot, resolvedNodePaths);
|
|
71
|
+
return resolvedNodePaths;
|
|
72
|
+
}
|
|
73
|
+
getFallbackNodePaths(contextRoot) {
|
|
74
|
+
const nodePaths = /* @__PURE__ */ new Set();
|
|
75
|
+
const contextNodeModulesPath = path.join(contextRoot, "node_modules");
|
|
76
|
+
if (fileSystem.exists(contextNodeModulesPath)) {
|
|
77
|
+
nodePaths.add(contextNodeModulesPath);
|
|
78
|
+
}
|
|
79
|
+
for (const workspaceNodePath of this.collectWorkspaceNodePaths(process.cwd())) {
|
|
80
|
+
nodePaths.add(workspaceNodePath);
|
|
81
|
+
}
|
|
82
|
+
return Array.from(nodePaths);
|
|
83
|
+
}
|
|
84
|
+
rewriteAliasedRuntimeSpecifiers(result, plugins) {
|
|
85
|
+
if (!result.success || result.outputs.length === 0) {
|
|
86
|
+
return result;
|
|
87
|
+
}
|
|
88
|
+
const aliasMap = collectRuntimeSpecifierAliasMap(plugins);
|
|
89
|
+
if (aliasMap.size === 0) {
|
|
90
|
+
return result;
|
|
91
|
+
}
|
|
92
|
+
for (const output of result.outputs) {
|
|
93
|
+
if (!/\.(?:[cm]?js)$/u.test(output.path)) {
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
const code = readFileSync(output.path, "utf-8");
|
|
97
|
+
const rewritten = rewriteRuntimeSpecifierAliases(code, aliasMap);
|
|
98
|
+
if (rewritten !== code) {
|
|
99
|
+
writeFileSync(output.path, rewritten);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return result;
|
|
103
|
+
}
|
|
29
104
|
escapeRegExp(value) {
|
|
30
105
|
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
31
106
|
}
|
|
@@ -211,7 +286,10 @@ class EsbuildBuildAdapter {
|
|
|
211
286
|
const importedModule = await import("esbuild");
|
|
212
287
|
const esbuildModule = typeof importedModule.build === "function" ? importedModule : importedModule.default ?? importedModule;
|
|
213
288
|
if (moduleGeneration > 0 && !this.isMockedEsbuildModule(esbuildModule)) {
|
|
214
|
-
const freshModule = await import(
|
|
289
|
+
const freshModule = await import(
|
|
290
|
+
/* @vite-ignore */
|
|
291
|
+
`${pathToFileURL(esbuildPath).href}?ecopages_esbuild=${moduleGeneration}`
|
|
292
|
+
);
|
|
215
293
|
const normalizedFreshModule = typeof freshModule.build === "function" ? freshModule : freshModule.default ?? freshModule;
|
|
216
294
|
if (typeof normalizedFreshModule.build === "function") {
|
|
217
295
|
return normalizedFreshModule;
|
|
@@ -251,6 +329,7 @@ class EsbuildBuildAdapter {
|
|
|
251
329
|
const outdir = path.resolve(options.outdir ?? "dist/assets");
|
|
252
330
|
const tsconfigPath = path.join(contextRoot, "tsconfig.json");
|
|
253
331
|
const tsconfigExists = fileSystem.exists(tsconfigPath);
|
|
332
|
+
const nodePaths = this.getFallbackNodePaths(contextRoot);
|
|
254
333
|
const plugins = this.getPluginsForBuild(options.plugins);
|
|
255
334
|
const esbuildPlugins = [
|
|
256
335
|
...plugins.length > 0 ? [this.createEcoPluginBridge(plugins, contextRoot)] : []
|
|
@@ -270,6 +349,7 @@ class EsbuildBuildAdapter {
|
|
|
270
349
|
};
|
|
271
350
|
const result = await esbuild.build({
|
|
272
351
|
absWorkingDir: contextRoot,
|
|
352
|
+
...nodePaths.length > 0 ? { nodePaths } : {},
|
|
273
353
|
entryPoints: options.entrypoints,
|
|
274
354
|
bundle: options.bundle ?? true,
|
|
275
355
|
...outputOptions,
|
|
@@ -296,12 +376,15 @@ class EsbuildBuildAdapter {
|
|
|
296
376
|
}));
|
|
297
377
|
const logs = result.warnings.map((warning) => ({ message: warning.text }));
|
|
298
378
|
const dependencyGraph = this.extractDependencyGraph(result.metafile, contextRoot);
|
|
299
|
-
return
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
379
|
+
return this.rewriteAliasedRuntimeSpecifiers(
|
|
380
|
+
{
|
|
381
|
+
success: true,
|
|
382
|
+
logs,
|
|
383
|
+
outputs,
|
|
384
|
+
dependencyGraph
|
|
385
|
+
},
|
|
386
|
+
plugins
|
|
387
|
+
);
|
|
305
388
|
}
|
|
306
389
|
mapEsbuildSourcemap(value) {
|
|
307
390
|
switch (value) {
|
|
@@ -407,8 +490,7 @@ class EsbuildBuildAdapter {
|
|
|
407
490
|
* Resolves module specifiers from a project root.
|
|
408
491
|
*/
|
|
409
492
|
resolve(importPath, rootDir) {
|
|
410
|
-
|
|
411
|
-
return localRequire.resolve(importPath);
|
|
493
|
+
return moduleRequire.resolve(importPath, { paths: [rootDir] });
|
|
412
494
|
}
|
|
413
495
|
/**
|
|
414
496
|
* Returns transpile defaults for a known transpile profile.
|
|
@@ -418,5 +500,6 @@ class EsbuildBuildAdapter {
|
|
|
418
500
|
}
|
|
419
501
|
}
|
|
420
502
|
export {
|
|
503
|
+
ESBUILD_ADAPTER_BRAND,
|
|
421
504
|
EsbuildBuildAdapter
|
|
422
505
|
};
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import type { EcoPagesAppConfig } from '../internal-types.js';
|
|
1
|
+
import type { EcoPagesAppConfig } from '../types/internal-types.js';
|
|
2
2
|
import { type BuildExecutor } from './build-adapter.js';
|
|
3
3
|
/**
|
|
4
4
|
* Installs the app-owned runtime build executor for one app instance.
|
|
5
5
|
*
|
|
6
6
|
* @remarks
|
|
7
|
-
* This is the single
|
|
8
|
-
*
|
|
9
|
-
*
|
|
7
|
+
* This is the single runtime executor boundary for adapter-owned startup.
|
|
8
|
+
* Bun-native ownership may reuse `DevBuildCoordinator` in development, while
|
|
9
|
+
* Vite-host ownership stays on a plain host-owned executor boundary with no
|
|
10
|
+
* Bun-specific coordination policy.
|
|
10
11
|
*/
|
|
11
12
|
export declare function installAppRuntimeBuildExecutor(appConfig: EcoPagesAppConfig, options: {
|
|
12
13
|
development: boolean;
|
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getAppBuildAdapter,
|
|
3
3
|
getAppBuildExecutor,
|
|
4
|
+
getAppBuildOwnership,
|
|
4
5
|
getAppServerBuildPlugins,
|
|
5
6
|
setAppBuildExecutor
|
|
6
7
|
} from "./build-adapter.js";
|
|
7
|
-
import { createOrReuseAppBuildExecutor } from "./dev-build-coordinator.js";
|
|
8
|
+
import { createOrReuseAppBuildExecutor, withBuildExecutorPlugins } from "./dev-build-coordinator.js";
|
|
8
9
|
function installAppRuntimeBuildExecutor(appConfig, options) {
|
|
9
|
-
const
|
|
10
|
+
const buildOwnership = getAppBuildOwnership(appConfig);
|
|
11
|
+
const buildExecutor = buildOwnership === "bun-native" ? createOrReuseAppBuildExecutor({
|
|
10
12
|
development: options.development,
|
|
11
13
|
adapter: getAppBuildAdapter(appConfig),
|
|
12
14
|
currentExecutor: getAppBuildExecutor(appConfig),
|
|
13
15
|
getPlugins: () => getAppServerBuildPlugins(appConfig)
|
|
14
|
-
});
|
|
16
|
+
}) : withBuildExecutorPlugins(getAppBuildAdapter(appConfig), () => getAppServerBuildPlugins(appConfig));
|
|
15
17
|
setAppBuildExecutor(appConfig, buildExecutor);
|
|
16
18
|
return buildExecutor;
|
|
17
19
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { attachRuntimeSpecifierAliasMap } from "./runtime-specifier-aliases.js";
|
|
1
2
|
function toRuntimeSpecifierMap(specifierMap) {
|
|
2
3
|
return specifierMap instanceof Map ? specifierMap : new Map(Object.entries(specifierMap));
|
|
3
4
|
}
|
|
@@ -10,21 +11,24 @@ function createRuntimeSpecifierAliasPlugin(specifierMapInput, options) {
|
|
|
10
11
|
return null;
|
|
11
12
|
}
|
|
12
13
|
const filter = new RegExp(`^(${Array.from(specifierMap.keys()).map(escapeRegExp).join("|")})$`);
|
|
13
|
-
return
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
build
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
14
|
+
return attachRuntimeSpecifierAliasMap(
|
|
15
|
+
{
|
|
16
|
+
name: options?.name ?? "runtime-specifier-alias",
|
|
17
|
+
setup(build) {
|
|
18
|
+
build.onResolve({ filter }, (args) => {
|
|
19
|
+
const mappedPath = specifierMap.get(args.path);
|
|
20
|
+
if (!mappedPath) {
|
|
21
|
+
return void 0;
|
|
22
|
+
}
|
|
23
|
+
return {
|
|
24
|
+
path: mappedPath,
|
|
25
|
+
external: options?.external ?? true
|
|
26
|
+
};
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
specifierMap
|
|
31
|
+
);
|
|
28
32
|
}
|
|
29
33
|
export {
|
|
30
34
|
createRuntimeSpecifierAliasPlugin
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { EcoBuildPlugin } from './build-types.js';
|
|
2
|
+
export declare function attachRuntimeSpecifierAliasMap(plugin: EcoBuildPlugin, specifierMap: ReadonlyMap<string, string>): EcoBuildPlugin;
|
|
3
|
+
export declare function getRuntimeSpecifierAliasMap(plugin: EcoBuildPlugin): ReadonlyMap<string, string> | undefined;
|
|
4
|
+
export declare function collectRuntimeSpecifierAliasMap(plugins: EcoBuildPlugin[] | undefined): ReadonlyMap<string, string>;
|
|
5
|
+
export declare function rewriteRuntimeSpecifierAliases(code: string, specifierMap: ReadonlyMap<string, string>): string;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { parseSync } from "oxc-parser";
|
|
2
|
+
const RUNTIME_SPECIFIER_ALIAS_MAP = /* @__PURE__ */ Symbol("ecopages.runtimeSpecifierAliasMap");
|
|
3
|
+
function attachRuntimeSpecifierAliasMap(plugin, specifierMap) {
|
|
4
|
+
plugin[RUNTIME_SPECIFIER_ALIAS_MAP] = specifierMap;
|
|
5
|
+
return plugin;
|
|
6
|
+
}
|
|
7
|
+
function getRuntimeSpecifierAliasMap(plugin) {
|
|
8
|
+
return plugin[RUNTIME_SPECIFIER_ALIAS_MAP];
|
|
9
|
+
}
|
|
10
|
+
function collectRuntimeSpecifierAliasMap(plugins) {
|
|
11
|
+
const merged = /* @__PURE__ */ new Map();
|
|
12
|
+
for (const plugin of plugins ?? []) {
|
|
13
|
+
const specifierMap = getRuntimeSpecifierAliasMap(plugin);
|
|
14
|
+
if (!specifierMap) {
|
|
15
|
+
continue;
|
|
16
|
+
}
|
|
17
|
+
for (const [specifier, mappedPath] of specifierMap.entries()) {
|
|
18
|
+
if (!merged.has(specifier)) {
|
|
19
|
+
merged.set(specifier, mappedPath);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return merged;
|
|
24
|
+
}
|
|
25
|
+
function rewriteRuntimeSpecifierAliases(code, specifierMap) {
|
|
26
|
+
if (specifierMap.size === 0) {
|
|
27
|
+
return code;
|
|
28
|
+
}
|
|
29
|
+
const edits = [];
|
|
30
|
+
try {
|
|
31
|
+
const result = parseSync("runtime-alias-output.js", code, {
|
|
32
|
+
sourceType: "module",
|
|
33
|
+
lang: "js"
|
|
34
|
+
});
|
|
35
|
+
const queueReplacement = (source) => {
|
|
36
|
+
if (typeof source.value !== "string") {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
const mappedPath = specifierMap.get(source.value);
|
|
40
|
+
if (!mappedPath) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
const quote = code[source.start] === "'" ? "'" : '"';
|
|
44
|
+
edits.push({
|
|
45
|
+
start: source.start,
|
|
46
|
+
end: source.end,
|
|
47
|
+
replacement: `${quote}${mappedPath}${quote}`
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
const walk = (node) => {
|
|
51
|
+
if (!node || typeof node !== "object") {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
if (Array.isArray(node)) {
|
|
55
|
+
for (const child of node) {
|
|
56
|
+
walk(child);
|
|
57
|
+
}
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
const candidate = node;
|
|
61
|
+
if (candidate.type === "ImportDeclaration" || candidate.type === "ExportNamedDeclaration" || candidate.type === "ExportAllDeclaration") {
|
|
62
|
+
if (candidate.source) {
|
|
63
|
+
queueReplacement(candidate.source);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
if (candidate.type === "ImportExpression") {
|
|
67
|
+
const importNode = candidate;
|
|
68
|
+
if (importNode.source?.type === "StringLiteral" || importNode.source?.type === "Literal") {
|
|
69
|
+
queueReplacement(importNode.source);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
for (const value of Object.values(candidate)) {
|
|
73
|
+
walk(value);
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
walk(result.program);
|
|
77
|
+
} catch {
|
|
78
|
+
return code;
|
|
79
|
+
}
|
|
80
|
+
if (edits.length === 0) {
|
|
81
|
+
return code;
|
|
82
|
+
}
|
|
83
|
+
edits.sort((left, right) => right.start - left.start);
|
|
84
|
+
let rewritten = code;
|
|
85
|
+
for (const edit of edits) {
|
|
86
|
+
rewritten = rewritten.slice(0, edit.start) + edit.replacement + rewritten.slice(edit.end);
|
|
87
|
+
}
|
|
88
|
+
return rewritten;
|
|
89
|
+
}
|
|
90
|
+
export {
|
|
91
|
+
attachRuntimeSpecifierAliasMap,
|
|
92
|
+
collectRuntimeSpecifierAliasMap,
|
|
93
|
+
getRuntimeSpecifierAliasMap,
|
|
94
|
+
rewriteRuntimeSpecifierAliases
|
|
95
|
+
};
|
package/src/config/README.md
CHANGED
|
@@ -12,8 +12,9 @@ It is responsible for:
|
|
|
12
12
|
|
|
13
13
|
- validating integration, processor, and loader registration
|
|
14
14
|
- resolving semantic paths such as `html` and `404` templates
|
|
15
|
-
- creating app-owned runtime state such as the build adapter, build executor, build manifest, dev graph service, runtime specifier registry, and
|
|
15
|
+
- selecting explicit build ownership and creating app-owned runtime state such as the build adapter, build executor, build manifest, dev graph service, runtime specifier registry, and remaining compatibility-only runtime state
|
|
16
16
|
- enforcing runtime capability requirements before startup
|
|
17
|
+
- carrying host-injected runtime dependencies only through abstract slots such as host module loaders, never through bundler-specific core defaults
|
|
17
18
|
|
|
18
19
|
## Main Files
|
|
19
20
|
|
|
@@ -23,9 +24,11 @@ It is responsible for:
|
|
|
23
24
|
## Ownership Rules
|
|
24
25
|
|
|
25
26
|
- Integrations and processors declare contributions.
|
|
26
|
-
- `ConfigBuilder.build()` decides ordering and
|
|
27
|
+
- `ConfigBuilder.build()` decides ordering, validates compatibility, and seals build ownership for the finalized app config.
|
|
27
28
|
- Runtime startup reuses finalized config/build state; it should not recompute manifest ownership.
|
|
28
29
|
|
|
30
|
+
Bun-native is the default ownership path. Vite-host ownership is explicit and should be selected during config construction when a host-driven compatibility flow must avoid silently falling back to Bun build execution.
|
|
31
|
+
|
|
29
32
|
## Output
|
|
30
33
|
|
|
31
34
|
The result of this layer is a built `EcoPagesAppConfig` with resolved absolute paths and app-owned runtime services attached under `appConfig.runtime`.
|
|
@@ -2,11 +2,13 @@
|
|
|
2
2
|
* This module contains the ConfigBuilder class, which is used to build the EcoPagesAppConfig object.
|
|
3
3
|
* @module
|
|
4
4
|
*/
|
|
5
|
+
import { type BuildOwnership } from '../build/build-adapter.js';
|
|
5
6
|
import type { EcoBuildPlugin } from '../build/build-types.js';
|
|
6
|
-
import type { EcoPagesAppConfig, RobotsPreference } from '../internal-types.js';
|
|
7
|
+
import type { EcoPagesAppConfig, RobotsPreference } from '../types/internal-types.js';
|
|
7
8
|
import type { IntegrationPlugin } from '../plugins/integration-plugin.js';
|
|
8
9
|
import type { Processor } from '../plugins/processor.js';
|
|
9
|
-
import type {
|
|
10
|
+
import type { EcoSourceTransform } from '../plugins/source-transform.js';
|
|
11
|
+
import type { PageMetadataProps } from '../types/public-types.js';
|
|
10
12
|
import type { CacheConfig } from '../services/cache/cache.types.js';
|
|
11
13
|
export declare const CONFIG_BUILDER_ERRORS: {
|
|
12
14
|
readonly DUPLICATE_INTEGRATION_NAMES: "Integrations names must be unique";
|
|
@@ -51,6 +53,7 @@ type RuntimeKind = 'node' | 'bun';
|
|
|
51
53
|
* @throws {Error} When adding duplicate processors or loaders
|
|
52
54
|
*/
|
|
53
55
|
export declare class ConfigBuilder {
|
|
56
|
+
private buildOwnership;
|
|
54
57
|
config: EcoPagesAppConfig;
|
|
55
58
|
/**
|
|
56
59
|
* Sets the base URL for the application.
|
|
@@ -68,6 +71,15 @@ export declare class ConfigBuilder {
|
|
|
68
71
|
* @returns The ConfigBuilder instance for method chaining
|
|
69
72
|
*/
|
|
70
73
|
setRootDir(rootDir: string): this;
|
|
74
|
+
/**
|
|
75
|
+
* Sets which runtime path owns build execution for the finalized app config.
|
|
76
|
+
*
|
|
77
|
+
* @remarks
|
|
78
|
+
* Bun-native remains the default. Vite-host ownership should be selected only
|
|
79
|
+
* for host-driven compatibility flows where core must not silently fall back to
|
|
80
|
+
* Bun build execution.
|
|
81
|
+
*/
|
|
82
|
+
setBuildOwnership(buildOwnership: BuildOwnership): this;
|
|
71
83
|
/**
|
|
72
84
|
* Sets the source directory relative to the root directory.
|
|
73
85
|
* This directory contains all the source files for the application.
|
|
@@ -192,6 +204,11 @@ export declare class ConfigBuilder {
|
|
|
192
204
|
* @returns The ConfigBuilder instance for method chaining
|
|
193
205
|
*/
|
|
194
206
|
setLoaders(loaders: EcoBuildPlugin[]): this;
|
|
207
|
+
/**
|
|
208
|
+
* Sets the source transforms to use for transform-first bundlers such as Vite.
|
|
209
|
+
* This replaces any existing source transforms.
|
|
210
|
+
*/
|
|
211
|
+
setSourceTransforms(sourceTransforms: EcoSourceTransform[]): this;
|
|
195
212
|
/**
|
|
196
213
|
* Adds a loader to the application.
|
|
197
214
|
*
|
|
@@ -201,6 +218,12 @@ export declare class ConfigBuilder {
|
|
|
201
218
|
* @throws Error if a loader with the same name already exists
|
|
202
219
|
*/
|
|
203
220
|
addLoader(name: string, loader: EcoBuildPlugin): this;
|
|
221
|
+
/**
|
|
222
|
+
* Adds a source transform to the application.
|
|
223
|
+
*
|
|
224
|
+
* @throws Error if a source transform with the same name already exists.
|
|
225
|
+
*/
|
|
226
|
+
addSourceTransform(name: string, sourceTransform: EcoSourceTransform): this;
|
|
204
227
|
/**
|
|
205
228
|
* Sets the cache configuration for ISR and page caching.
|
|
206
229
|
*
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
DEFAULT_ECOPAGES_HOSTNAME,
|
|
5
5
|
DEFAULT_ECOPAGES_PORT,
|
|
6
6
|
DEFAULT_ECOPAGES_WORK_DIR
|
|
7
|
-
} from "../constants.js";
|
|
7
|
+
} from "../config/constants.js";
|
|
8
8
|
import {
|
|
9
9
|
collectConfiguredAppBuildManifestContributions,
|
|
10
10
|
createBuildAdapter,
|
|
@@ -16,14 +16,11 @@ import {
|
|
|
16
16
|
import { createAppBuildExecutor } from "../build/dev-build-coordinator.js";
|
|
17
17
|
import { GHTML_PLUGIN_NAME, ghtmlPlugin } from "../integrations/ghtml/ghtml.plugin.js";
|
|
18
18
|
import { createEcoComponentMetaPlugin } from "../plugins/eco-component-meta-plugin.js";
|
|
19
|
+
import { createEcoComponentMetaTransform } from "../plugins/eco-component-meta-plugin.js";
|
|
19
20
|
import {
|
|
20
21
|
NoopEntrypointDependencyGraph,
|
|
21
22
|
setAppEntrypointDependencyGraph
|
|
22
23
|
} from "../services/runtime-state/entrypoint-dependency-graph.service.js";
|
|
23
|
-
import {
|
|
24
|
-
createNodeRuntimeManifest,
|
|
25
|
-
setAppNodeRuntimeManifest
|
|
26
|
-
} from "../services/runtime-manifest/node-runtime-manifest.service.js";
|
|
27
24
|
import {
|
|
28
25
|
InMemoryRuntimeSpecifierRegistry,
|
|
29
26
|
setAppRuntimeSpecifierRegistry
|
|
@@ -47,6 +44,7 @@ const CONFIG_BUILDER_ERRORS = {
|
|
|
47
44
|
invalidRuntimeVersion: (kind, name, version) => `Cannot validate ${kind} "${name}" runtimeCapability.minRuntimeVersion "${version}" because it is not a dot-separated numeric version`
|
|
48
45
|
};
|
|
49
46
|
class ConfigBuilder {
|
|
47
|
+
buildOwnership = "bun-native";
|
|
50
48
|
config = {
|
|
51
49
|
baseUrl: "",
|
|
52
50
|
rootDir: ".",
|
|
@@ -86,6 +84,7 @@ class ConfigBuilder {
|
|
|
86
84
|
},
|
|
87
85
|
processors: /* @__PURE__ */ new Map(),
|
|
88
86
|
loaders: /* @__PURE__ */ new Map(),
|
|
87
|
+
sourceTransforms: /* @__PURE__ */ new Map(),
|
|
89
88
|
workDir: DEFAULT_ECOPAGES_WORK_DIR
|
|
90
89
|
};
|
|
91
90
|
/**
|
|
@@ -110,6 +109,18 @@ class ConfigBuilder {
|
|
|
110
109
|
this.config.rootDir = rootDir;
|
|
111
110
|
return this;
|
|
112
111
|
}
|
|
112
|
+
/**
|
|
113
|
+
* Sets which runtime path owns build execution for the finalized app config.
|
|
114
|
+
*
|
|
115
|
+
* @remarks
|
|
116
|
+
* Bun-native remains the default. Vite-host ownership should be selected only
|
|
117
|
+
* for host-driven compatibility flows where core must not silently fall back to
|
|
118
|
+
* Bun build execution.
|
|
119
|
+
*/
|
|
120
|
+
setBuildOwnership(buildOwnership) {
|
|
121
|
+
this.buildOwnership = buildOwnership;
|
|
122
|
+
return this;
|
|
123
|
+
}
|
|
113
124
|
/**
|
|
114
125
|
* Sets the source directory relative to the root directory.
|
|
115
126
|
* This directory contains all the source files for the application.
|
|
@@ -289,6 +300,17 @@ class ConfigBuilder {
|
|
|
289
300
|
}
|
|
290
301
|
return this;
|
|
291
302
|
}
|
|
303
|
+
/**
|
|
304
|
+
* Sets the source transforms to use for transform-first bundlers such as Vite.
|
|
305
|
+
* This replaces any existing source transforms.
|
|
306
|
+
*/
|
|
307
|
+
setSourceTransforms(sourceTransforms) {
|
|
308
|
+
this.config.sourceTransforms.clear();
|
|
309
|
+
for (const sourceTransform of sourceTransforms) {
|
|
310
|
+
this.addSourceTransform(sourceTransform.name, sourceTransform);
|
|
311
|
+
}
|
|
312
|
+
return this;
|
|
313
|
+
}
|
|
292
314
|
/**
|
|
293
315
|
* Adds a loader to the application.
|
|
294
316
|
*
|
|
@@ -304,6 +326,18 @@ class ConfigBuilder {
|
|
|
304
326
|
this.config.loaders.set(name, loader);
|
|
305
327
|
return this;
|
|
306
328
|
}
|
|
329
|
+
/**
|
|
330
|
+
* Adds a source transform to the application.
|
|
331
|
+
*
|
|
332
|
+
* @throws Error if a source transform with the same name already exists.
|
|
333
|
+
*/
|
|
334
|
+
addSourceTransform(name, sourceTransform) {
|
|
335
|
+
if (this.config.sourceTransforms.has(name)) {
|
|
336
|
+
throw new Error(CONFIG_BUILDER_ERRORS.duplicateLoaderName(name));
|
|
337
|
+
}
|
|
338
|
+
this.config.sourceTransforms.set(name, sourceTransform);
|
|
339
|
+
return this;
|
|
340
|
+
}
|
|
307
341
|
/**
|
|
308
342
|
* Sets the cache configuration for ISR and page caching.
|
|
309
343
|
*
|
|
@@ -507,6 +541,10 @@ class ConfigBuilder {
|
|
|
507
541
|
* This includes the eco-component-meta-plugin which auto-injects __eco metadata into component configs.
|
|
508
542
|
*/
|
|
509
543
|
async initializeDefaultLoaders() {
|
|
544
|
+
const componentMetaTransform = createEcoComponentMetaTransform({ config: this.config });
|
|
545
|
+
if (!this.config.sourceTransforms.has(componentMetaTransform.name)) {
|
|
546
|
+
this.config.sourceTransforms.set(componentMetaTransform.name, componentMetaTransform);
|
|
547
|
+
}
|
|
510
548
|
const componentMetaPlugin = createEcoComponentMetaPlugin({ config: this.config });
|
|
511
549
|
if (!this.config.loaders.has(componentMetaPlugin.name)) {
|
|
512
550
|
this.config.loaders.set(componentMetaPlugin.name, componentMetaPlugin);
|
|
@@ -541,7 +579,7 @@ class ConfigBuilder {
|
|
|
541
579
|
await this.initializeDefaultLoaders();
|
|
542
580
|
this.initializeProcessors();
|
|
543
581
|
this.validateRuntimeCapabilities();
|
|
544
|
-
const buildAdapter = createBuildAdapter();
|
|
582
|
+
const buildAdapter = createBuildAdapter({ ownership: this.buildOwnership });
|
|
545
583
|
setAppBuildAdapter(this.config, buildAdapter);
|
|
546
584
|
updateAppBuildManifest(this.config, await collectConfiguredAppBuildManifestContributions(this.config));
|
|
547
585
|
setAppServerInvalidationState(this.config, new CounterServerInvalidationState());
|
|
@@ -555,7 +593,6 @@ class ConfigBuilder {
|
|
|
555
593
|
getPlugins: () => getAppServerBuildPlugins(this.config)
|
|
556
594
|
})
|
|
557
595
|
);
|
|
558
|
-
setAppNodeRuntimeManifest(this.config, createNodeRuntimeManifest(this.config));
|
|
559
596
|
return this.config;
|
|
560
597
|
}
|
|
561
598
|
}
|
package/src/declarations.d.ts
CHANGED
package/src/dev/sc-server.d.ts
CHANGED
package/src/dev/sc-server.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { extname, join } from "node:path";
|
|
2
|
-
import { STATUS_MESSAGE } from "../constants.js";
|
|
2
|
+
import { STATUS_MESSAGE } from "../config/constants.js";
|
|
3
3
|
import { fileSystem } from "@ecopages/file-system";
|
|
4
4
|
import { ServerUtils } from "../utils/server-utils.module.js";
|
|
5
5
|
import { getRequiredBunRuntime } from "../utils/runtime.js";
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
function createComponentFactory(options) {
|
|
2
|
+
const component2 = ((props) => options.render(props));
|
|
3
|
+
component2.config = {
|
|
4
|
+
__eco: options.__eco,
|
|
5
|
+
integration: options.integration,
|
|
6
|
+
dependencies: options.dependencies
|
|
7
|
+
};
|
|
8
|
+
return component2;
|
|
9
|
+
}
|
|
10
|
+
function component(options) {
|
|
11
|
+
return createComponentFactory(options);
|
|
12
|
+
}
|
|
13
|
+
function html(options) {
|
|
14
|
+
return createComponentFactory(options);
|
|
15
|
+
}
|
|
16
|
+
function layout(options) {
|
|
17
|
+
return createComponentFactory(options);
|
|
18
|
+
}
|
|
19
|
+
function page(options) {
|
|
20
|
+
const {
|
|
21
|
+
layout: pageLayout,
|
|
22
|
+
dependencies,
|
|
23
|
+
render,
|
|
24
|
+
staticPaths: staticPaths2,
|
|
25
|
+
staticProps: staticProps2,
|
|
26
|
+
metadata: metadata2,
|
|
27
|
+
cache,
|
|
28
|
+
requires,
|
|
29
|
+
middleware
|
|
30
|
+
} = options;
|
|
31
|
+
const pageComponent = createComponentFactory({
|
|
32
|
+
__eco: options.__eco,
|
|
33
|
+
integration: options.integration,
|
|
34
|
+
dependencies: pageLayout ? {
|
|
35
|
+
...dependencies,
|
|
36
|
+
components: [...dependencies?.components ?? [], pageLayout]
|
|
37
|
+
} : dependencies,
|
|
38
|
+
render
|
|
39
|
+
});
|
|
40
|
+
if (pageLayout && pageComponent.config) {
|
|
41
|
+
pageComponent.config.layout = pageLayout;
|
|
42
|
+
}
|
|
43
|
+
if (staticPaths2) {
|
|
44
|
+
pageComponent.staticPaths = staticPaths2;
|
|
45
|
+
}
|
|
46
|
+
if (staticProps2) {
|
|
47
|
+
pageComponent.staticProps = staticProps2;
|
|
48
|
+
}
|
|
49
|
+
if (metadata2) {
|
|
50
|
+
pageComponent.metadata = metadata2;
|
|
51
|
+
}
|
|
52
|
+
if (cache) {
|
|
53
|
+
pageComponent.cache = cache;
|
|
54
|
+
}
|
|
55
|
+
if (requires) {
|
|
56
|
+
pageComponent.requires = requires;
|
|
57
|
+
}
|
|
58
|
+
if (middleware) {
|
|
59
|
+
pageComponent.middleware = middleware;
|
|
60
|
+
}
|
|
61
|
+
return pageComponent;
|
|
62
|
+
}
|
|
63
|
+
function metadata(fn) {
|
|
64
|
+
return fn;
|
|
65
|
+
}
|
|
66
|
+
function staticPaths(fn) {
|
|
67
|
+
return fn;
|
|
68
|
+
}
|
|
69
|
+
function staticProps(fn) {
|
|
70
|
+
return fn;
|
|
71
|
+
}
|
|
72
|
+
const eco = {
|
|
73
|
+
component,
|
|
74
|
+
html,
|
|
75
|
+
layout,
|
|
76
|
+
page,
|
|
77
|
+
metadata,
|
|
78
|
+
staticPaths,
|
|
79
|
+
staticProps
|
|
80
|
+
};
|
|
81
|
+
export {
|
|
82
|
+
eco
|
|
83
|
+
};
|