@ecopages/core 0.2.0-alpha.22 → 0.2.0-alpha.24
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/package.json +93 -226
- package/src/adapters/abstract/application-adapter.test.ts +172 -0
- package/src/adapters/abstract/application-adapter.ts +379 -0
- package/src/adapters/abstract/router-adapter.ts +30 -0
- package/src/adapters/abstract/server-adapter.ts +79 -0
- package/src/adapters/bun/client-bridge.ts +62 -0
- package/src/adapters/bun/create-app.ts +180 -0
- package/src/adapters/bun/hmr-manager.test.ts +267 -0
- package/src/adapters/bun/hmr-manager.ts +406 -0
- package/src/adapters/bun/index.ts +2 -0
- package/src/adapters/bun/server-adapter.ts +500 -0
- package/src/adapters/bun/server-lifecycle.ts +124 -0
- package/src/adapters/create-app.test.ts +10 -0
- package/src/adapters/create-app.ts +91 -0
- package/src/adapters/index.ts +2 -0
- package/src/adapters/node/create-app.test.ts +53 -0
- package/src/adapters/node/create-app.ts +183 -0
- package/src/adapters/node/node-client-bridge.test.ts +198 -0
- package/src/adapters/node/node-client-bridge.ts +79 -0
- package/src/adapters/node/node-hmr-manager.test.ts +322 -0
- package/src/adapters/node/node-hmr-manager.ts +378 -0
- package/src/adapters/node/server-adapter.ts +502 -0
- package/src/adapters/node/static-content-server.test.ts +60 -0
- package/src/adapters/node/static-content-server.ts +239 -0
- package/src/adapters/shared/api-response.test.ts +97 -0
- package/src/adapters/shared/api-response.ts +104 -0
- package/src/adapters/shared/application-adapter.ts +199 -0
- package/src/adapters/shared/define-api-handler.ts +66 -0
- package/src/adapters/shared/explicit-static-route-matcher.test.ts +381 -0
- package/src/adapters/shared/explicit-static-route-matcher.ts +140 -0
- package/src/adapters/shared/file-route-middleware-pipeline.test.ts +90 -0
- package/src/adapters/shared/file-route-middleware-pipeline.ts +127 -0
- package/src/adapters/shared/fs-server-response-factory.test.ts +187 -0
- package/src/adapters/shared/fs-server-response-factory.ts +118 -0
- package/src/adapters/shared/fs-server-response-matcher.test.ts +285 -0
- package/src/adapters/shared/fs-server-response-matcher.ts +189 -0
- package/src/adapters/shared/hmr-entrypoint-registrar.ts +149 -0
- package/src/adapters/shared/hmr-html-response.ts +52 -0
- package/src/adapters/shared/hmr-manager.contract.test.ts +232 -0
- package/src/adapters/shared/hmr-manager.dispatch.test.ts +220 -0
- package/src/adapters/shared/render-context.test.ts +150 -0
- package/src/adapters/shared/render-context.ts +123 -0
- package/src/adapters/shared/runtime-bootstrap.ts +79 -0
- package/src/adapters/shared/server-adapter.test.ts +77 -0
- package/src/adapters/shared/server-adapter.ts +493 -0
- package/src/adapters/shared/server-route-handler.test.ts +110 -0
- package/src/adapters/shared/server-route-handler.ts +153 -0
- package/src/adapters/shared/server-static-builder.test.ts +338 -0
- package/src/adapters/shared/server-static-builder.ts +170 -0
- package/src/build/build-adapter-serialization.test.ts +281 -0
- package/src/build/build-adapter.test.ts +1240 -0
- package/src/build/build-adapter.ts +1012 -0
- package/src/build/build-manifest.ts +54 -0
- package/src/build/build-types.ts +83 -0
- package/src/build/dev-build-coordinator.ts +220 -0
- package/src/build/esbuild-build-adapter.ts +660 -0
- package/src/build/runtime-build-executor.test.ts +81 -0
- package/src/build/runtime-build-executor.ts +40 -0
- package/src/build/runtime-specifier-alias-plugin.test.ts +67 -0
- package/src/build/runtime-specifier-alias-plugin.ts +62 -0
- package/src/build/runtime-specifier-aliases.ts +135 -0
- package/src/config/config-builder.test.ts +443 -0
- package/src/config/config-builder.ts +742 -0
- package/src/config/config-builder.typecheck.test.ts +96 -0
- package/src/config/{constants.d.ts → constants.ts} +22 -13
- package/src/dev/sc-server.ts +143 -0
- package/src/eco/eco.browser.test.ts +43 -0
- package/src/eco/eco.browser.ts +118 -0
- package/src/eco/eco.test.ts +654 -0
- package/src/eco/eco.ts +205 -0
- package/src/eco/eco.types.ts +221 -0
- package/src/eco/eco.utils.test.ts +219 -0
- package/src/eco/eco.utils.ts +5 -0
- package/src/eco/global-injector-map.test.ts +42 -0
- package/src/eco/global-injector-map.ts +112 -0
- package/src/eco/lazy-injector-map.test.ts +66 -0
- package/src/eco/lazy-injector-map.ts +120 -0
- package/src/eco/module-dependencies.test.ts +30 -0
- package/src/eco/module-dependencies.ts +75 -0
- package/src/errors/http-error.test.ts +134 -0
- package/src/errors/http-error.ts +72 -0
- package/src/errors/{index.d.ts → index.ts} +2 -2
- package/src/errors/locals-access-error.ts +7 -0
- package/src/global/app-logger.ts +4 -0
- package/src/global/utils.test.ts +12 -0
- package/src/hmr/client/__screenshots__/hmr-runtime.test.browser.ts/HMR-Runtime-HMR-Server-Integration-should-have-HMR-script-injected-in-page-1.png +0 -0
- package/src/hmr/client/__screenshots__/hmr-runtime.test.browser.ts/HMR-Runtime-HMR-Server-Integration-should-load-fixture-app-page-1.png +0 -0
- package/src/hmr/client/__screenshots__/hmr-runtime.test.browser.ts/HMR-Runtime-WebSocket-Connection-should-connect-to-correct-HMR-endpoint-1.png +0 -0
- package/src/hmr/client/hmr-runtime.ts +160 -0
- package/src/hmr/hmr-strategy.test.ts +124 -0
- package/src/hmr/hmr-strategy.ts +177 -0
- package/src/hmr/hmr.postcss.test.e2e.ts +41 -0
- package/src/hmr/hmr.test.e2e.ts +66 -0
- package/src/hmr/strategies/default-hmr-strategy.ts +60 -0
- package/src/hmr/strategies/js-hmr-strategy.test.ts +335 -0
- package/src/hmr/strategies/js-hmr-strategy.ts +320 -0
- package/src/index.browser.ts +3 -0
- package/src/index.ts +15 -0
- package/src/integrations/ghtml/ghtml-renderer.test.ts +253 -0
- package/src/integrations/ghtml/ghtml-renderer.ts +97 -0
- package/src/integrations/ghtml/ghtml.constants.ts +1 -0
- package/src/integrations/ghtml/ghtml.plugin.ts +28 -0
- package/src/plugins/alias-resolver-plugin.test.ts +41 -0
- package/src/plugins/alias-resolver-plugin.ts +63 -0
- package/src/plugins/eco-component-meta-plugin.test.ts +406 -0
- package/src/plugins/eco-component-meta-plugin.ts +495 -0
- package/src/plugins/foreign-jsx-override-plugin.test.ts +65 -0
- package/src/plugins/foreign-jsx-override-plugin.ts +67 -0
- package/src/plugins/integration-plugin.test.ts +156 -0
- package/src/plugins/integration-plugin.ts +311 -0
- package/src/plugins/processor.test.ts +148 -0
- package/src/plugins/processor.ts +240 -0
- package/src/plugins/{runtime-capability.d.ts → runtime-capability.ts} +8 -3
- package/src/plugins/source-transform.test.ts +82 -0
- package/src/plugins/source-transform.ts +123 -0
- package/src/route-renderer/orchestration/boundary-planning.service.ts +146 -0
- package/src/route-renderer/orchestration/component-render-context.ts +318 -0
- package/src/route-renderer/orchestration/integration-renderer.test.ts +2088 -0
- package/src/route-renderer/orchestration/integration-renderer.ts +1285 -0
- package/src/route-renderer/orchestration/page-packaging.service.test.ts +76 -0
- package/src/route-renderer/orchestration/page-packaging.service.ts +85 -0
- package/src/route-renderer/orchestration/processed-asset-dedupe.ts +25 -0
- package/src/route-renderer/orchestration/queued-boundary-runtime.service.test.ts +319 -0
- package/src/route-renderer/orchestration/queued-boundary-runtime.service.ts +289 -0
- package/src/route-renderer/orchestration/render-execution.service.test.ts +196 -0
- package/src/route-renderer/orchestration/render-execution.service.ts +182 -0
- package/src/route-renderer/orchestration/render-output.utils.ts +302 -0
- package/src/route-renderer/orchestration/render-preparation.service.test.ts +569 -0
- package/src/route-renderer/orchestration/render-preparation.service.ts +508 -0
- package/src/route-renderer/orchestration/route-shell-composer.service.ts +162 -0
- package/src/route-renderer/orchestration/template-serialization.test.ts +110 -0
- package/src/route-renderer/orchestration/template-serialization.ts +117 -0
- package/src/route-renderer/page-loading/component-dependency-collection.ts +196 -0
- package/src/route-renderer/page-loading/declared-asset-collection.ts +156 -0
- package/src/route-renderer/page-loading/dependency-resolver.test.ts +665 -0
- package/src/route-renderer/page-loading/dependency-resolver.ts +150 -0
- package/src/route-renderer/page-loading/ecopages-virtual-imports.ts +75 -0
- package/src/route-renderer/page-loading/lazy-entry-collection.ts +167 -0
- package/src/route-renderer/page-loading/lazy-trigger-planning.ts +74 -0
- package/src/route-renderer/page-loading/module-declaration-aggregation.ts +60 -0
- package/src/route-renderer/page-loading/module-declaration-scripts.ts +16 -0
- package/src/route-renderer/page-loading/page-dependency-bundling.ts +205 -0
- package/src/route-renderer/page-loading/page-module-loader.test.ts +183 -0
- package/src/route-renderer/page-loading/page-module-loader.ts +184 -0
- package/src/route-renderer/route-renderer.ts +136 -0
- package/src/router/client/link-intent.test.browser.ts +51 -0
- package/src/router/client/link-intent.ts +92 -0
- package/src/router/client/navigation-coordinator.test.ts +237 -0
- package/src/router/client/navigation-coordinator.ts +453 -0
- package/src/router/server/fs-router-scanner.test.ts +83 -0
- package/src/router/server/fs-router-scanner.ts +224 -0
- package/src/router/server/fs-router.test.ts +214 -0
- package/src/router/server/fs-router.ts +122 -0
- package/src/services/assets/asset-processing-service/asset-dependency-keys.ts +66 -0
- package/src/services/assets/asset-processing-service/asset-processing.service.test.ts +476 -0
- package/src/services/assets/asset-processing-service/asset-processing.service.ts +345 -0
- package/src/services/assets/asset-processing-service/asset.factory.test.ts +63 -0
- package/src/services/assets/asset-processing-service/asset.factory.ts +105 -0
- package/src/services/assets/asset-processing-service/assets.types.ts +125 -0
- package/src/services/assets/asset-processing-service/browser-runtime-asset.factory.test.ts +74 -0
- package/src/services/assets/asset-processing-service/browser-runtime-asset.factory.ts +96 -0
- package/src/services/assets/asset-processing-service/browser-runtime-entry.factory.test.ts +67 -0
- package/src/services/assets/asset-processing-service/browser-runtime-entry.factory.ts +78 -0
- package/src/services/assets/asset-processing-service/grouped-content-bundles.ts +104 -0
- package/src/services/assets/asset-processing-service/index.ts +5 -0
- package/src/services/assets/asset-processing-service/{processor.interface.d.ts → processor.interface.ts} +10 -5
- package/src/services/assets/asset-processing-service/processor.registry.ts +18 -0
- package/src/services/assets/asset-processing-service/processors/base/base-processor.test.ts +59 -0
- package/src/services/assets/asset-processing-service/processors/base/base-processor.ts +83 -0
- package/src/services/assets/asset-processing-service/processors/base/base-script-processor.ts +174 -0
- package/src/services/assets/asset-processing-service/processors/index.ts +5 -0
- package/src/services/assets/asset-processing-service/processors/script/content-script.processor.test.ts +192 -0
- package/src/services/assets/asset-processing-service/processors/script/content-script.processor.ts +134 -0
- package/src/services/assets/asset-processing-service/processors/script/file-script.processor.test.ts +326 -0
- package/src/services/assets/asset-processing-service/processors/script/file-script.processor.ts +110 -0
- package/src/services/assets/asset-processing-service/processors/script/node-module-script.processor.test.ts +227 -0
- package/src/services/assets/asset-processing-service/processors/script/node-module-script.processor.ts +87 -0
- package/src/services/assets/asset-processing-service/processors/stylesheet/content-stylesheet.processor.test.ts +261 -0
- package/src/services/assets/asset-processing-service/processors/stylesheet/content-stylesheet.processor.ts +71 -0
- package/src/services/assets/asset-processing-service/processors/stylesheet/file-stylesheet.processor.ts +81 -0
- package/src/services/assets/asset-processing-service/ungrouped-dependency-processing.ts +65 -0
- package/src/services/assets/browser-bundle.service.test.ts +66 -0
- package/src/services/assets/browser-bundle.service.ts +109 -0
- package/src/services/cache/cache.types.ts +126 -0
- package/src/services/cache/index.ts +18 -0
- package/src/services/cache/memory-cache-store.test.ts +225 -0
- package/src/services/cache/memory-cache-store.ts +130 -0
- package/src/services/cache/page-cache-service.test.ts +175 -0
- package/src/services/cache/page-cache-service.ts +202 -0
- package/src/services/cache/page-request-cache-coordinator.service.test.ts +79 -0
- package/src/services/cache/page-request-cache-coordinator.service.ts +131 -0
- package/src/services/html/html-rewriter-provider.service.test.ts +183 -0
- package/src/services/html/html-rewriter-provider.service.ts +104 -0
- package/src/services/html/html-transformer.service.test.ts +479 -0
- package/src/services/html/html-transformer.service.ts +275 -0
- package/src/services/invalidation/development-invalidation.service.test.ts +87 -0
- package/src/services/invalidation/development-invalidation.service.ts +262 -0
- package/src/services/module-loading/app-module-loader.service.ts +9 -0
- package/src/services/module-loading/app-server-module-transpiler.service.test.ts +130 -0
- package/src/services/module-loading/app-server-module-transpiler.service.ts +143 -0
- package/src/services/module-loading/host-module-loader-registry.ts +15 -0
- package/src/services/module-loading/{module-loading-types.d.ts → module-loading-types.ts} +1 -0
- package/src/services/module-loading/node-bootstrap-plugin.test.ts +335 -0
- package/src/services/module-loading/node-bootstrap-plugin.ts +297 -0
- package/src/services/module-loading/page-module-import.service.test.ts +504 -0
- package/src/services/module-loading/page-module-import.service.ts +252 -0
- package/src/services/module-loading/server-module-transpiler.service.test.ts +243 -0
- package/src/services/module-loading/server-module-transpiler.service.ts +104 -0
- package/src/services/module-loading/source-module-support.ts +19 -0
- package/src/services/runtime-state/dev-graph.service.ts +217 -0
- package/src/services/runtime-state/entrypoint-dependency-graph.service.ts +136 -0
- package/src/services/runtime-state/runtime-specifier-registry.service.ts +96 -0
- package/src/services/runtime-state/server-invalidation-state.service.ts +68 -0
- package/src/services/validation/schema-validation-service.test.ts +223 -0
- package/src/services/validation/schema-validation-service.ts +204 -0
- package/src/services/validation/{standard-schema.types.d.ts → standard-schema.types.ts} +20 -17
- package/src/static-site-generator/static-site-generator.test.ts +316 -0
- package/src/static-site-generator/static-site-generator.ts +462 -0
- package/src/types/internal-types.ts +242 -0
- package/src/types/public-types.ts +1443 -0
- package/src/utils/deep-merge.test.ts +114 -0
- package/src/utils/deep-merge.ts +47 -0
- package/src/utils/hash.ts +5 -0
- package/src/utils/html-escaping.ts +9 -0
- package/src/utils/invariant.test.ts +22 -0
- package/src/utils/invariant.ts +15 -0
- package/src/utils/locals-utils.ts +37 -0
- package/src/utils/parse-cli-args.test.ts +69 -0
- package/src/utils/parse-cli-args.ts +105 -0
- package/src/utils/path-utils.module.ts +14 -0
- package/src/utils/path-utils.test.ts +15 -0
- package/src/utils/resolve-work-dir.ts +45 -0
- package/src/utils/runtime.ts +44 -0
- package/src/utils/server-utils.module.ts +67 -0
- package/src/utils/server-utils.test.ts +38 -0
- package/src/watchers/project-watcher.integration.test.ts +337 -0
- package/src/watchers/project-watcher.test-helpers.ts +41 -0
- package/src/watchers/project-watcher.test.ts +768 -0
- package/src/watchers/project-watcher.ts +357 -0
- package/CHANGELOG.md +0 -51
- package/src/adapters/abstract/application-adapter.d.ts +0 -194
- package/src/adapters/abstract/application-adapter.js +0 -121
- package/src/adapters/abstract/router-adapter.d.ts +0 -26
- package/src/adapters/abstract/router-adapter.js +0 -5
- package/src/adapters/abstract/server-adapter.d.ts +0 -69
- package/src/adapters/abstract/server-adapter.js +0 -15
- package/src/adapters/bun/client-bridge.d.ts +0 -34
- package/src/adapters/bun/client-bridge.js +0 -48
- package/src/adapters/bun/create-app.d.ts +0 -52
- package/src/adapters/bun/create-app.js +0 -116
- package/src/adapters/bun/hmr-manager.d.ts +0 -143
- package/src/adapters/bun/hmr-manager.js +0 -333
- package/src/adapters/bun/index.d.ts +0 -2
- package/src/adapters/bun/index.js +0 -8
- package/src/adapters/bun/server-adapter.d.ts +0 -155
- package/src/adapters/bun/server-adapter.js +0 -374
- package/src/adapters/bun/server-lifecycle.d.ts +0 -63
- package/src/adapters/bun/server-lifecycle.js +0 -92
- package/src/adapters/create-app.d.ts +0 -20
- package/src/adapters/create-app.js +0 -66
- package/src/adapters/index.d.ts +0 -2
- package/src/adapters/index.js +0 -8
- package/src/adapters/node/create-app.d.ts +0 -18
- package/src/adapters/node/create-app.js +0 -149
- package/src/adapters/node/node-client-bridge.d.ts +0 -26
- package/src/adapters/node/node-client-bridge.js +0 -66
- package/src/adapters/node/node-hmr-manager.d.ts +0 -133
- package/src/adapters/node/node-hmr-manager.js +0 -311
- package/src/adapters/node/server-adapter.d.ts +0 -161
- package/src/adapters/node/server-adapter.js +0 -359
- package/src/adapters/node/static-content-server.d.ts +0 -60
- package/src/adapters/node/static-content-server.js +0 -194
- package/src/adapters/shared/api-response.d.ts +0 -52
- package/src/adapters/shared/api-response.js +0 -96
- package/src/adapters/shared/application-adapter.d.ts +0 -18
- package/src/adapters/shared/application-adapter.js +0 -90
- package/src/adapters/shared/define-api-handler.d.ts +0 -25
- package/src/adapters/shared/define-api-handler.js +0 -15
- package/src/adapters/shared/explicit-static-route-matcher.d.ts +0 -38
- package/src/adapters/shared/explicit-static-route-matcher.js +0 -103
- package/src/adapters/shared/file-route-middleware-pipeline.d.ts +0 -65
- package/src/adapters/shared/file-route-middleware-pipeline.js +0 -99
- package/src/adapters/shared/fs-server-response-factory.d.ts +0 -19
- package/src/adapters/shared/fs-server-response-factory.js +0 -97
- package/src/adapters/shared/fs-server-response-matcher.d.ts +0 -67
- package/src/adapters/shared/fs-server-response-matcher.js +0 -147
- package/src/adapters/shared/hmr-entrypoint-registrar.d.ts +0 -55
- package/src/adapters/shared/hmr-entrypoint-registrar.js +0 -87
- package/src/adapters/shared/hmr-html-response.d.ts +0 -22
- package/src/adapters/shared/hmr-html-response.js +0 -32
- package/src/adapters/shared/render-context.d.ts +0 -15
- package/src/adapters/shared/render-context.js +0 -72
- package/src/adapters/shared/runtime-bootstrap.d.ts +0 -38
- package/src/adapters/shared/runtime-bootstrap.js +0 -43
- package/src/adapters/shared/server-adapter.d.ts +0 -97
- package/src/adapters/shared/server-adapter.js +0 -390
- package/src/adapters/shared/server-route-handler.d.ts +0 -89
- package/src/adapters/shared/server-route-handler.js +0 -111
- package/src/adapters/shared/server-static-builder.d.ts +0 -70
- package/src/adapters/shared/server-static-builder.js +0 -100
- package/src/build/build-adapter.d.ts +0 -239
- package/src/build/build-adapter.js +0 -642
- package/src/build/build-manifest.d.ts +0 -27
- package/src/build/build-manifest.js +0 -30
- package/src/build/build-types.d.ts +0 -57
- package/src/build/build-types.js +0 -0
- package/src/build/dev-build-coordinator.d.ts +0 -72
- package/src/build/dev-build-coordinator.js +0 -154
- package/src/build/esbuild-build-adapter.d.ts +0 -78
- package/src/build/esbuild-build-adapter.js +0 -505
- package/src/build/runtime-build-executor.d.ts +0 -14
- package/src/build/runtime-build-executor.js +0 -22
- package/src/build/runtime-specifier-alias-plugin.d.ts +0 -15
- package/src/build/runtime-specifier-alias-plugin.js +0 -35
- package/src/build/runtime-specifier-aliases.d.ts +0 -5
- package/src/build/runtime-specifier-aliases.js +0 -95
- package/src/config/config-builder.d.ts +0 -252
- package/src/config/config-builder.js +0 -603
- package/src/config/constants.js +0 -25
- package/src/dev/sc-server.d.ts +0 -30
- package/src/dev/sc-server.js +0 -111
- package/src/eco/eco.browser.d.ts +0 -2
- package/src/eco/eco.browser.js +0 -83
- package/src/eco/eco.d.ts +0 -9
- package/src/eco/eco.js +0 -85
- package/src/eco/eco.types.d.ts +0 -178
- package/src/eco/eco.types.js +0 -0
- package/src/eco/eco.utils.d.ts +0 -1
- package/src/eco/eco.utils.js +0 -10
- package/src/eco/global-injector-map.d.ts +0 -16
- package/src/eco/global-injector-map.js +0 -80
- package/src/eco/lazy-injector-map.d.ts +0 -8
- package/src/eco/lazy-injector-map.js +0 -70
- package/src/eco/module-dependencies.d.ts +0 -18
- package/src/eco/module-dependencies.js +0 -49
- package/src/errors/http-error.d.ts +0 -31
- package/src/errors/http-error.js +0 -50
- package/src/errors/index.js +0 -4
- package/src/errors/locals-access-error.d.ts +0 -4
- package/src/errors/locals-access-error.js +0 -9
- package/src/global/app-logger.d.ts +0 -2
- package/src/global/app-logger.js +0 -6
- package/src/hmr/client/hmr-runtime.d.ts +0 -5
- package/src/hmr/client/hmr-runtime.js +0 -109
- package/src/hmr/hmr-strategy.d.ts +0 -162
- package/src/hmr/hmr-strategy.js +0 -44
- package/src/hmr/hmr.postcss.test.e2e.d.ts +0 -1
- package/src/hmr/hmr.postcss.test.e2e.js +0 -31
- package/src/hmr/hmr.test.e2e.d.ts +0 -1
- package/src/hmr/hmr.test.e2e.js +0 -43
- package/src/hmr/strategies/default-hmr-strategy.d.ts +0 -43
- package/src/hmr/strategies/default-hmr-strategy.js +0 -34
- package/src/hmr/strategies/js-hmr-strategy.d.ts +0 -139
- package/src/hmr/strategies/js-hmr-strategy.js +0 -178
- package/src/index.browser.d.ts +0 -3
- package/src/index.browser.js +0 -4
- package/src/index.d.ts +0 -6
- package/src/index.js +0 -21
- package/src/integrations/ghtml/ghtml-renderer.d.ts +0 -20
- package/src/integrations/ghtml/ghtml-renderer.js +0 -63
- package/src/integrations/ghtml/ghtml.constants.d.ts +0 -1
- package/src/integrations/ghtml/ghtml.constants.js +0 -4
- package/src/integrations/ghtml/ghtml.plugin.d.ts +0 -16
- package/src/integrations/ghtml/ghtml.plugin.js +0 -20
- package/src/plugins/alias-resolver-plugin.d.ts +0 -2
- package/src/plugins/alias-resolver-plugin.js +0 -53
- package/src/plugins/eco-component-meta-plugin.d.ts +0 -108
- package/src/plugins/eco-component-meta-plugin.js +0 -163
- package/src/plugins/foreign-jsx-override-plugin.d.ts +0 -31
- package/src/plugins/foreign-jsx-override-plugin.js +0 -35
- package/src/plugins/integration-plugin.d.ts +0 -219
- package/src/plugins/integration-plugin.js +0 -196
- package/src/plugins/processor.d.ts +0 -95
- package/src/plugins/processor.js +0 -136
- package/src/plugins/runtime-capability.js +0 -0
- package/src/plugins/source-transform.d.ts +0 -46
- package/src/plugins/source-transform.js +0 -71
- package/src/route-renderer/orchestration/boundary-planning.service.d.ts +0 -25
- package/src/route-renderer/orchestration/boundary-planning.service.js +0 -97
- package/src/route-renderer/orchestration/component-render-context.d.ts +0 -83
- package/src/route-renderer/orchestration/component-render-context.js +0 -147
- package/src/route-renderer/orchestration/integration-renderer.d.ts +0 -554
- package/src/route-renderer/orchestration/integration-renderer.js +0 -957
- package/src/route-renderer/orchestration/queued-boundary-runtime.service.d.ts +0 -89
- package/src/route-renderer/orchestration/queued-boundary-runtime.service.js +0 -155
- package/src/route-renderer/orchestration/render-execution.service.d.ts +0 -43
- package/src/route-renderer/orchestration/render-execution.service.js +0 -106
- package/src/route-renderer/orchestration/render-output.utils.d.ts +0 -46
- package/src/route-renderer/orchestration/render-output.utils.js +0 -65
- package/src/route-renderer/orchestration/render-preparation.service.d.ts +0 -120
- package/src/route-renderer/orchestration/render-preparation.service.js +0 -341
- package/src/route-renderer/orchestration/route-shell-composer.service.d.ts +0 -50
- package/src/route-renderer/orchestration/route-shell-composer.service.js +0 -81
- package/src/route-renderer/orchestration/template-serialization.d.ts +0 -38
- package/src/route-renderer/orchestration/template-serialization.js +0 -45
- package/src/route-renderer/page-loading/dependency-resolver.d.ts +0 -35
- package/src/route-renderer/page-loading/dependency-resolver.js +0 -444
- package/src/route-renderer/page-loading/page-module-loader.d.ts +0 -90
- package/src/route-renderer/page-loading/page-module-loader.js +0 -127
- package/src/route-renderer/route-renderer.d.ts +0 -67
- package/src/route-renderer/route-renderer.js +0 -103
- package/src/router/client/link-intent.js +0 -34
- package/src/router/client/link-intent.test.browser.d.ts +0 -1
- package/src/router/client/link-intent.test.browser.js +0 -43
- package/src/router/client/navigation-coordinator.d.ts +0 -149
- package/src/router/client/navigation-coordinator.js +0 -215
- package/src/router/server/fs-router-scanner.d.ts +0 -41
- package/src/router/server/fs-router-scanner.js +0 -161
- package/src/router/server/fs-router.d.ts +0 -26
- package/src/router/server/fs-router.js +0 -100
- package/src/services/assets/asset-processing-service/asset-processing.service.d.ts +0 -120
- package/src/services/assets/asset-processing-service/asset-processing.service.js +0 -331
- package/src/services/assets/asset-processing-service/asset.factory.d.ts +0 -17
- package/src/services/assets/asset-processing-service/asset.factory.js +0 -82
- package/src/services/assets/asset-processing-service/assets.types.d.ts +0 -89
- package/src/services/assets/asset-processing-service/assets.types.js +0 -0
- package/src/services/assets/asset-processing-service/browser-runtime-asset.factory.d.ts +0 -55
- package/src/services/assets/asset-processing-service/browser-runtime-asset.factory.js +0 -48
- package/src/services/assets/asset-processing-service/browser-runtime-entry.factory.d.ts +0 -20
- package/src/services/assets/asset-processing-service/browser-runtime-entry.factory.js +0 -41
- package/src/services/assets/asset-processing-service/index.d.ts +0 -5
- package/src/services/assets/asset-processing-service/index.js +0 -5
- package/src/services/assets/asset-processing-service/processor.interface.js +0 -6
- package/src/services/assets/asset-processing-service/processor.registry.d.ts +0 -8
- package/src/services/assets/asset-processing-service/processor.registry.js +0 -15
- package/src/services/assets/asset-processing-service/processors/base/base-processor.d.ts +0 -24
- package/src/services/assets/asset-processing-service/processors/base/base-processor.js +0 -64
- package/src/services/assets/asset-processing-service/processors/base/base-script-processor.d.ts +0 -17
- package/src/services/assets/asset-processing-service/processors/base/base-script-processor.js +0 -72
- package/src/services/assets/asset-processing-service/processors/index.d.ts +0 -5
- package/src/services/assets/asset-processing-service/processors/index.js +0 -5
- package/src/services/assets/asset-processing-service/processors/script/content-script.processor.d.ts +0 -5
- package/src/services/assets/asset-processing-service/processors/script/content-script.processor.js +0 -57
- package/src/services/assets/asset-processing-service/processors/script/file-script.processor.d.ts +0 -9
- package/src/services/assets/asset-processing-service/processors/script/file-script.processor.js +0 -88
- package/src/services/assets/asset-processing-service/processors/script/node-module-script.processor.d.ts +0 -7
- package/src/services/assets/asset-processing-service/processors/script/node-module-script.processor.js +0 -75
- package/src/services/assets/asset-processing-service/processors/stylesheet/content-stylesheet.processor.d.ts +0 -5
- package/src/services/assets/asset-processing-service/processors/stylesheet/content-stylesheet.processor.js +0 -25
- package/src/services/assets/asset-processing-service/processors/stylesheet/file-stylesheet.processor.d.ts +0 -9
- package/src/services/assets/asset-processing-service/processors/stylesheet/file-stylesheet.processor.js +0 -66
- package/src/services/assets/browser-bundle.service.d.ts +0 -32
- package/src/services/assets/browser-bundle.service.js +0 -33
- package/src/services/cache/cache.types.d.ts +0 -107
- package/src/services/cache/cache.types.js +0 -0
- package/src/services/cache/index.d.ts +0 -7
- package/src/services/cache/index.js +0 -7
- package/src/services/cache/memory-cache-store.d.ts +0 -42
- package/src/services/cache/memory-cache-store.js +0 -98
- package/src/services/cache/page-cache-service.d.ts +0 -70
- package/src/services/cache/page-cache-service.js +0 -152
- package/src/services/cache/page-request-cache-coordinator.service.d.ts +0 -75
- package/src/services/cache/page-request-cache-coordinator.service.js +0 -109
- package/src/services/html/html-rewriter-provider.service.d.ts +0 -37
- package/src/services/html/html-rewriter-provider.service.js +0 -68
- package/src/services/html/html-transformer.service.d.ts +0 -77
- package/src/services/html/html-transformer.service.js +0 -215
- package/src/services/invalidation/development-invalidation.service.d.ts +0 -74
- package/src/services/invalidation/development-invalidation.service.js +0 -190
- package/src/services/module-loading/app-module-loader.service.d.ts +0 -28
- package/src/services/module-loading/app-module-loader.service.js +0 -35
- package/src/services/module-loading/app-server-module-transpiler.service.d.ts +0 -24
- package/src/services/module-loading/app-server-module-transpiler.service.js +0 -109
- package/src/services/module-loading/host-module-loader-registry.d.ts +0 -4
- package/src/services/module-loading/host-module-loader-registry.js +0 -15
- package/src/services/module-loading/module-loading-types.js +0 -0
- package/src/services/module-loading/node-bootstrap-plugin.d.ts +0 -42
- package/src/services/module-loading/node-bootstrap-plugin.js +0 -204
- package/src/services/module-loading/page-module-import.service.d.ts +0 -76
- package/src/services/module-loading/page-module-import.service.js +0 -173
- package/src/services/module-loading/server-module-transpiler.service.d.ts +0 -72
- package/src/services/module-loading/server-module-transpiler.service.js +0 -64
- package/src/services/runtime-state/dev-graph.service.d.ts +0 -118
- package/src/services/runtime-state/dev-graph.service.js +0 -162
- package/src/services/runtime-state/entrypoint-dependency-graph.service.d.ts +0 -41
- package/src/services/runtime-state/entrypoint-dependency-graph.service.js +0 -85
- package/src/services/runtime-state/runtime-specifier-registry.service.d.ts +0 -69
- package/src/services/runtime-state/runtime-specifier-registry.service.js +0 -37
- package/src/services/runtime-state/server-invalidation-state.service.d.ts +0 -26
- package/src/services/runtime-state/server-invalidation-state.service.js +0 -35
- package/src/services/validation/schema-validation-service.d.ts +0 -122
- package/src/services/validation/schema-validation-service.js +0 -101
- package/src/services/validation/standard-schema.types.js +0 -0
- package/src/static-site-generator/static-site-generator.d.ts +0 -104
- package/src/static-site-generator/static-site-generator.js +0 -338
- package/src/types/internal-types.d.ts +0 -231
- package/src/types/internal-types.js +0 -0
- package/src/types/public-types.d.ts +0 -1219
- package/src/types/public-types.js +0 -0
- package/src/utils/deep-merge.d.ts +0 -14
- package/src/utils/deep-merge.js +0 -32
- package/src/utils/hash.d.ts +0 -1
- package/src/utils/hash.js +0 -7
- package/src/utils/html-escaping.d.ts +0 -7
- package/src/utils/html-escaping.js +0 -6
- package/src/utils/html.js +0 -4
- package/src/utils/invariant.d.ts +0 -5
- package/src/utils/invariant.js +0 -11
- package/src/utils/locals-utils.d.ts +0 -15
- package/src/utils/locals-utils.js +0 -24
- package/src/utils/parse-cli-args.d.ts +0 -27
- package/src/utils/parse-cli-args.js +0 -62
- package/src/utils/path-utils.module.d.ts +0 -5
- package/src/utils/path-utils.module.js +0 -14
- package/src/utils/resolve-work-dir.d.ts +0 -11
- package/src/utils/resolve-work-dir.js +0 -31
- package/src/utils/runtime.d.ts +0 -11
- package/src/utils/runtime.js +0 -40
- package/src/utils/server-utils.module.d.ts +0 -19
- package/src/utils/server-utils.module.js +0 -56
- package/src/watchers/project-watcher.d.ts +0 -136
- package/src/watchers/project-watcher.js +0 -275
- package/src/watchers/project-watcher.test-helpers.d.ts +0 -4
- package/src/watchers/project-watcher.test-helpers.js +0 -52
- /package/src/utils/{html.d.ts → html.ts} +0 -0
|
@@ -0,0 +1,1240 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import os from 'node:os';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import { test, vi } from 'vitest';
|
|
6
|
+
import {
|
|
7
|
+
build,
|
|
8
|
+
collectConfiguredAppBuildManifestContributions,
|
|
9
|
+
createConfiguredAppBuildManifest,
|
|
10
|
+
createBuildAdapter,
|
|
11
|
+
createBunBuildAdapter,
|
|
12
|
+
defaultBunBuildAdapter,
|
|
13
|
+
defaultBuildAdapter,
|
|
14
|
+
EsbuildBuildAdapter,
|
|
15
|
+
getAppBuildOwnership,
|
|
16
|
+
getAppBuildAdapter,
|
|
17
|
+
getAppBuildManifest,
|
|
18
|
+
getAppBrowserBuildPlugins,
|
|
19
|
+
getAppBuildExecutor,
|
|
20
|
+
getDefaultBuildAdapter,
|
|
21
|
+
getAppServerBuildPlugins,
|
|
22
|
+
setAppBuildAdapter,
|
|
23
|
+
setAppBuildOwnership,
|
|
24
|
+
setAppBuildManifest,
|
|
25
|
+
setupAppRuntimePlugins,
|
|
26
|
+
updateAppBuildManifest,
|
|
27
|
+
ViteHostBuildAdapter,
|
|
28
|
+
} from './build-adapter.ts';
|
|
29
|
+
import { createAppBuildManifest } from './build-manifest.ts';
|
|
30
|
+
import type { EcoBuildPluginBuilder } from './build-types.ts';
|
|
31
|
+
import { createAppBuildExecutor } from './dev-build-coordinator.ts';
|
|
32
|
+
|
|
33
|
+
const tempRoots: string[] = [];
|
|
34
|
+
|
|
35
|
+
function createTempRoot(prefix: string): string {
|
|
36
|
+
const root = fs.mkdtempSync(path.join(os.tmpdir(), `${prefix}-`));
|
|
37
|
+
tempRoots.push(root);
|
|
38
|
+
return root;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function cleanupTempRoots(): void {
|
|
42
|
+
for (const root of tempRoots.splice(0)) {
|
|
43
|
+
fs.rmSync(root, { recursive: true, force: true });
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function clearNodeCssBridge(): void {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
test('defaultBuildAdapter remains the Bun-native fallback backed by the Bun adapter', () => {
|
|
52
|
+
assert.equal(defaultBuildAdapter, defaultBunBuildAdapter);
|
|
53
|
+
assert.ok(!(defaultBuildAdapter instanceof EsbuildBuildAdapter));
|
|
54
|
+
assert.equal(defaultBuildAdapter.ownership, 'bun-native');
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
test('createBuildAdapter makes Bun-native and Vite-host ownership explicit', () => {
|
|
58
|
+
const bunAdapter = createBuildAdapter({ ownership: 'bun-native' });
|
|
59
|
+
const viteAdapter = createBuildAdapter({ ownership: 'vite-host' });
|
|
60
|
+
const defaultViteAdapter = getDefaultBuildAdapter('vite-host');
|
|
61
|
+
|
|
62
|
+
assert.ok(!(bunAdapter instanceof EsbuildBuildAdapter));
|
|
63
|
+
assert.equal(bunAdapter.ownership, 'bun-native');
|
|
64
|
+
assert.ok(viteAdapter instanceof ViteHostBuildAdapter);
|
|
65
|
+
assert.equal(viteAdapter.ownership, 'vite-host');
|
|
66
|
+
assert.ok(defaultViteAdapter instanceof ViteHostBuildAdapter);
|
|
67
|
+
assert.equal(defaultViteAdapter.ownership, 'vite-host');
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
test('ViteHostBuildAdapter rejects core-owned execution attempts', async () => {
|
|
71
|
+
const adapter = new ViteHostBuildAdapter();
|
|
72
|
+
|
|
73
|
+
await assert.rejects(
|
|
74
|
+
adapter.build({
|
|
75
|
+
entrypoints: ['/tmp/entry.ts'],
|
|
76
|
+
root: '/tmp',
|
|
77
|
+
outdir: '/tmp/out',
|
|
78
|
+
target: 'browser',
|
|
79
|
+
format: 'esm',
|
|
80
|
+
sourcemap: 'none',
|
|
81
|
+
splitting: false,
|
|
82
|
+
minify: false,
|
|
83
|
+
}),
|
|
84
|
+
/Vite-hosted builds are owned by the host runtime/,
|
|
85
|
+
);
|
|
86
|
+
assert.throws(() => adapter.resolve('react', '/tmp'), /Vite-hosted builds are owned by the host runtime/);
|
|
87
|
+
assert.throws(
|
|
88
|
+
() => adapter.getTranspileOptions('browser-script'),
|
|
89
|
+
/Vite-hosted builds are owned by the host runtime/,
|
|
90
|
+
);
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
test('build helper accepts an explicit executor across package and relative build-adapter imports', async () => {
|
|
94
|
+
const packageBuildAdapter = await import('@ecopages/core/build/build-adapter');
|
|
95
|
+
const executor = {
|
|
96
|
+
build: vi.fn(async () => ({
|
|
97
|
+
success: true,
|
|
98
|
+
logs: [],
|
|
99
|
+
outputs: [{ path: '/tmp/shared.js' }],
|
|
100
|
+
})),
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
const result = await packageBuildAdapter.build(
|
|
104
|
+
{
|
|
105
|
+
entrypoints: ['/tmp/shared.ts'],
|
|
106
|
+
root: '/tmp',
|
|
107
|
+
outdir: '/tmp/out',
|
|
108
|
+
target: 'node',
|
|
109
|
+
format: 'esm',
|
|
110
|
+
sourcemap: 'none',
|
|
111
|
+
splitting: false,
|
|
112
|
+
minify: false,
|
|
113
|
+
},
|
|
114
|
+
executor,
|
|
115
|
+
);
|
|
116
|
+
|
|
117
|
+
assert.equal(result.success, true);
|
|
118
|
+
assert.deepEqual(result.outputs, [{ path: '/tmp/shared.js' }]);
|
|
119
|
+
assert.equal(executor.build.mock.calls.length, 1);
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
test('build helper uses the shared adapter when no executor is provided', async () => {
|
|
123
|
+
const executor = {
|
|
124
|
+
build: vi.fn(async () => ({
|
|
125
|
+
success: true,
|
|
126
|
+
logs: [],
|
|
127
|
+
outputs: [{ path: '/tmp/direct.js' }],
|
|
128
|
+
})),
|
|
129
|
+
};
|
|
130
|
+
const adapterSpy = vi.spyOn(defaultBuildAdapter, 'build').mockImplementation(executor.build);
|
|
131
|
+
|
|
132
|
+
const result = await build({
|
|
133
|
+
entrypoints: ['/tmp/direct.ts'],
|
|
134
|
+
root: '/tmp',
|
|
135
|
+
outdir: '/tmp/out',
|
|
136
|
+
target: 'node',
|
|
137
|
+
format: 'esm',
|
|
138
|
+
sourcemap: 'none',
|
|
139
|
+
splitting: false,
|
|
140
|
+
minify: false,
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
assert.equal(result.success, true);
|
|
144
|
+
assert.deepEqual(result.outputs, [{ path: '/tmp/direct.js' }]);
|
|
145
|
+
assert.equal(adapterSpy.mock.calls.length, 1);
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
test('BunBuildAdapter bundles entrypoints by default to keep transitive app imports in the emitted server module', async () => {
|
|
149
|
+
const originalBun = (globalThis as typeof globalThis & { Bun?: unknown }).Bun;
|
|
150
|
+
const buildCalls: Array<Record<string, unknown>> = [];
|
|
151
|
+
|
|
152
|
+
(globalThis as typeof globalThis & { Bun?: unknown }).Bun = {
|
|
153
|
+
build: vi.fn(async (options: Record<string, unknown>) => {
|
|
154
|
+
buildCalls.push(options);
|
|
155
|
+
return {
|
|
156
|
+
success: true,
|
|
157
|
+
logs: [],
|
|
158
|
+
outputs: [{ path: '/tmp/out/entry.js' }],
|
|
159
|
+
};
|
|
160
|
+
}),
|
|
161
|
+
hash: vi.fn(() => 1),
|
|
162
|
+
resolveSync: vi.fn((importPath: string) => importPath),
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
try {
|
|
166
|
+
const freshAdapter = createBunBuildAdapter();
|
|
167
|
+
const result = await freshAdapter.build({
|
|
168
|
+
entrypoints: ['/tmp/entry.ts'],
|
|
169
|
+
root: '/tmp',
|
|
170
|
+
outdir: '/tmp/out',
|
|
171
|
+
target: 'node',
|
|
172
|
+
format: 'esm',
|
|
173
|
+
sourcemap: 'none',
|
|
174
|
+
splitting: true,
|
|
175
|
+
minify: false,
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
assert.equal(result.success, true);
|
|
179
|
+
assert.equal(buildCalls.length, 1);
|
|
180
|
+
assert.equal(buildCalls[0]?.bundle, undefined);
|
|
181
|
+
} finally {
|
|
182
|
+
if (originalBun === undefined) {
|
|
183
|
+
delete (globalThis as typeof globalThis & { Bun?: unknown }).Bun;
|
|
184
|
+
} else {
|
|
185
|
+
(globalThis as typeof globalThis & { Bun?: unknown }).Bun = originalBun;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
test('BunBuildAdapter normalizes hashed naming patterns to concrete emitted output files', async () => {
|
|
191
|
+
const originalBun = (globalThis as typeof globalThis & { Bun?: unknown }).Bun;
|
|
192
|
+
|
|
193
|
+
try {
|
|
194
|
+
const root = createTempRoot('ecopages-bun-naming-template');
|
|
195
|
+
const srcDir = path.join(root, 'src', 'components');
|
|
196
|
+
const outDir = path.join(root, 'dist', 'assets', 'components');
|
|
197
|
+
fs.mkdirSync(srcDir, { recursive: true });
|
|
198
|
+
fs.mkdirSync(outDir, { recursive: true });
|
|
199
|
+
|
|
200
|
+
const entryPath = path.join(srcDir, 'kita-counter.script.ts');
|
|
201
|
+
fs.writeFileSync(entryPath, 'export const value = 1;');
|
|
202
|
+
|
|
203
|
+
const concreteOutputPath = path.join(outDir, 'kita-counter.script-abc123.js');
|
|
204
|
+
const placeholderOutputPath = path.join(outDir, 'kita-counter.script-[hash].js');
|
|
205
|
+
|
|
206
|
+
(globalThis as typeof globalThis & { Bun?: unknown }).Bun = {
|
|
207
|
+
build: vi.fn(async () => {
|
|
208
|
+
fs.writeFileSync(concreteOutputPath, 'export const value = 1;', 'utf8');
|
|
209
|
+
return {
|
|
210
|
+
success: true,
|
|
211
|
+
logs: [],
|
|
212
|
+
outputs: [{ path: placeholderOutputPath }],
|
|
213
|
+
};
|
|
214
|
+
}),
|
|
215
|
+
hash: vi.fn(() => 1),
|
|
216
|
+
resolveSync: vi.fn((importPath: string) => importPath),
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
const freshAdapter = createBunBuildAdapter();
|
|
220
|
+
const result = await freshAdapter.build({
|
|
221
|
+
entrypoints: [entryPath],
|
|
222
|
+
root,
|
|
223
|
+
outdir: outDir,
|
|
224
|
+
target: 'browser',
|
|
225
|
+
format: 'esm',
|
|
226
|
+
sourcemap: 'none',
|
|
227
|
+
splitting: true,
|
|
228
|
+
minify: false,
|
|
229
|
+
naming: '[name]-[hash].[ext]',
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
assert.equal(result.success, true);
|
|
233
|
+
assert.deepEqual(result.outputs, [{ path: concreteOutputPath }]);
|
|
234
|
+
assert.equal(fs.existsSync(concreteOutputPath), true);
|
|
235
|
+
assert.equal(fs.existsSync(placeholderOutputPath), false);
|
|
236
|
+
} finally {
|
|
237
|
+
if (originalBun === undefined) {
|
|
238
|
+
delete (globalThis as typeof globalThis & { Bun?: unknown }).Bun;
|
|
239
|
+
} else {
|
|
240
|
+
(globalThis as typeof globalThis & { Bun?: unknown }).Bun = originalBun;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
test('BunBuildAdapter normalizes unordered multi-entrypoint outputs by path instead of output index', async () => {
|
|
246
|
+
const originalBun = (globalThis as typeof globalThis & { Bun?: unknown }).Bun;
|
|
247
|
+
|
|
248
|
+
try {
|
|
249
|
+
const root = createTempRoot('ecopages-bun-unordered-entrypoints');
|
|
250
|
+
const srcDir = path.join(root, 'src', 'components');
|
|
251
|
+
const outDir = path.join(root, 'dist', 'assets');
|
|
252
|
+
fs.mkdirSync(path.join(srcDir, 'theme-toggle'), { recursive: true });
|
|
253
|
+
fs.mkdirSync(path.join(srcDir, 'weather-app'), { recursive: true });
|
|
254
|
+
fs.mkdirSync(path.join(srcDir, 'code-tabs'), { recursive: true });
|
|
255
|
+
fs.mkdirSync(outDir, { recursive: true });
|
|
256
|
+
|
|
257
|
+
const themeToggleEntrypoint = path.join(srcDir, 'theme-toggle', 'theme-toggle.script.ts');
|
|
258
|
+
const weatherAppEntrypoint = path.join(srcDir, 'weather-app', 'weather-app.script.tsx');
|
|
259
|
+
const codeTabsEntrypoint = path.join(srcDir, 'code-tabs', 'code-tabs.script.tsx');
|
|
260
|
+
fs.writeFileSync(themeToggleEntrypoint, 'export const themeToggle = 1;');
|
|
261
|
+
fs.writeFileSync(weatherAppEntrypoint, 'export const weatherApp = 2;');
|
|
262
|
+
fs.writeFileSync(codeTabsEntrypoint, 'export const codeTabs = 3;');
|
|
263
|
+
|
|
264
|
+
const themeToggleOutput = path.join(outDir, 'components', 'theme-toggle', 'theme-toggle.script');
|
|
265
|
+
const weatherAppOutput = path.join(outDir, 'components', 'weather-app', 'weather-app.script');
|
|
266
|
+
const codeTabsOutput = path.join(outDir, 'components', 'code-tabs', 'code-tabs.script');
|
|
267
|
+
|
|
268
|
+
(globalThis as typeof globalThis & { Bun?: unknown }).Bun = {
|
|
269
|
+
build: vi.fn(async () => {
|
|
270
|
+
fs.mkdirSync(path.dirname(themeToggleOutput), { recursive: true });
|
|
271
|
+
fs.mkdirSync(path.dirname(weatherAppOutput), { recursive: true });
|
|
272
|
+
fs.mkdirSync(path.dirname(codeTabsOutput), { recursive: true });
|
|
273
|
+
fs.writeFileSync(themeToggleOutput, 'export const themeToggle = 1;', 'utf8');
|
|
274
|
+
fs.writeFileSync(weatherAppOutput, 'export const weatherApp = 2;', 'utf8');
|
|
275
|
+
fs.writeFileSync(codeTabsOutput, 'export const codeTabs = 3;', 'utf8');
|
|
276
|
+
return {
|
|
277
|
+
success: true,
|
|
278
|
+
logs: [],
|
|
279
|
+
outputs: [{ path: weatherAppOutput }, { path: codeTabsOutput }, { path: themeToggleOutput }],
|
|
280
|
+
};
|
|
281
|
+
}),
|
|
282
|
+
hash: vi.fn(() => 1),
|
|
283
|
+
resolveSync: vi.fn((importPath: string) => importPath),
|
|
284
|
+
};
|
|
285
|
+
|
|
286
|
+
const freshAdapter = createBunBuildAdapter();
|
|
287
|
+
const result = await freshAdapter.build({
|
|
288
|
+
entrypoints: [themeToggleEntrypoint, weatherAppEntrypoint, codeTabsEntrypoint],
|
|
289
|
+
root,
|
|
290
|
+
outdir: outDir,
|
|
291
|
+
outbase: path.join(root, 'src'),
|
|
292
|
+
target: 'browser',
|
|
293
|
+
format: 'esm',
|
|
294
|
+
sourcemap: 'none',
|
|
295
|
+
splitting: true,
|
|
296
|
+
minify: false,
|
|
297
|
+
naming: '[dir]/[name]',
|
|
298
|
+
});
|
|
299
|
+
|
|
300
|
+
assert.equal(result.success, true);
|
|
301
|
+
assert.deepEqual(result.outputs, [
|
|
302
|
+
{ path: `${weatherAppOutput}.js` },
|
|
303
|
+
{ path: `${codeTabsOutput}.js` },
|
|
304
|
+
{ path: `${themeToggleOutput}.js` },
|
|
305
|
+
]);
|
|
306
|
+
assert.equal(fs.readFileSync(`${themeToggleOutput}.js`, 'utf8'), 'export const themeToggle = 1;');
|
|
307
|
+
assert.equal(fs.readFileSync(`${weatherAppOutput}.js`, 'utf8'), 'export const weatherApp = 2;');
|
|
308
|
+
assert.equal(fs.readFileSync(`${codeTabsOutput}.js`, 'utf8'), 'export const codeTabs = 3;');
|
|
309
|
+
} finally {
|
|
310
|
+
if (originalBun === undefined) {
|
|
311
|
+
delete (globalThis as typeof globalThis & { Bun?: unknown }).Bun;
|
|
312
|
+
} else {
|
|
313
|
+
(globalThis as typeof globalThis & { Bun?: unknown }).Bun = originalBun;
|
|
314
|
+
}
|
|
315
|
+
cleanupTempRoots();
|
|
316
|
+
}
|
|
317
|
+
});
|
|
318
|
+
|
|
319
|
+
test('BunBuildAdapter matches reordered hashed multi-entrypoint outputs back to outbase-relative targets', async () => {
|
|
320
|
+
const originalBun = (globalThis as typeof globalThis & { Bun?: unknown }).Bun;
|
|
321
|
+
|
|
322
|
+
try {
|
|
323
|
+
const root = createTempRoot('ecopages-bun-unordered-hashed-entrypoints');
|
|
324
|
+
const srcDir = path.join(root, 'src', 'components');
|
|
325
|
+
const outDir = path.join(root, 'dist', 'assets');
|
|
326
|
+
fs.mkdirSync(path.join(srcDir, 'theme-toggle'), { recursive: true });
|
|
327
|
+
fs.mkdirSync(path.join(srcDir, 'weather-app'), { recursive: true });
|
|
328
|
+
fs.mkdirSync(outDir, { recursive: true });
|
|
329
|
+
|
|
330
|
+
const themeToggleEntrypoint = path.join(srcDir, 'theme-toggle', 'theme-toggle.script.ts');
|
|
331
|
+
const weatherAppEntrypoint = path.join(srcDir, 'weather-app', 'weather-app.script.tsx');
|
|
332
|
+
fs.writeFileSync(themeToggleEntrypoint, 'export const themeToggle = 1;');
|
|
333
|
+
fs.writeFileSync(weatherAppEntrypoint, 'export const weatherApp = 2;');
|
|
334
|
+
|
|
335
|
+
const themeToggleBunOutput = path.join(
|
|
336
|
+
outDir,
|
|
337
|
+
'src',
|
|
338
|
+
'components',
|
|
339
|
+
'theme-toggle',
|
|
340
|
+
'theme-toggle.script-abc123.js',
|
|
341
|
+
);
|
|
342
|
+
const weatherAppBunOutput = path.join(
|
|
343
|
+
outDir,
|
|
344
|
+
'src',
|
|
345
|
+
'components',
|
|
346
|
+
'weather-app',
|
|
347
|
+
'weather-app.script-def456.js',
|
|
348
|
+
);
|
|
349
|
+
const themeToggleExpectedOutput = path.join(
|
|
350
|
+
outDir,
|
|
351
|
+
'components',
|
|
352
|
+
'theme-toggle',
|
|
353
|
+
'theme-toggle.script-abc123.js',
|
|
354
|
+
);
|
|
355
|
+
const weatherAppExpectedOutput = path.join(outDir, 'components', 'weather-app', 'weather-app.script-def456.js');
|
|
356
|
+
|
|
357
|
+
(globalThis as typeof globalThis & { Bun?: unknown }).Bun = {
|
|
358
|
+
build: vi.fn(async () => {
|
|
359
|
+
fs.mkdirSync(path.dirname(themeToggleBunOutput), { recursive: true });
|
|
360
|
+
fs.mkdirSync(path.dirname(weatherAppBunOutput), { recursive: true });
|
|
361
|
+
fs.writeFileSync(themeToggleBunOutput, 'export const themeToggle = 1;', 'utf8');
|
|
362
|
+
fs.writeFileSync(weatherAppBunOutput, 'export const weatherApp = 2;', 'utf8');
|
|
363
|
+
return {
|
|
364
|
+
success: true,
|
|
365
|
+
logs: [],
|
|
366
|
+
outputs: [{ path: weatherAppBunOutput }, { path: themeToggleBunOutput }],
|
|
367
|
+
};
|
|
368
|
+
}),
|
|
369
|
+
hash: vi.fn(() => 1),
|
|
370
|
+
resolveSync: vi.fn((importPath: string) => importPath),
|
|
371
|
+
};
|
|
372
|
+
|
|
373
|
+
const freshAdapter = createBunBuildAdapter();
|
|
374
|
+
const result = await freshAdapter.build({
|
|
375
|
+
entrypoints: [themeToggleEntrypoint, weatherAppEntrypoint],
|
|
376
|
+
root,
|
|
377
|
+
outdir: outDir,
|
|
378
|
+
outbase: path.join(root, 'src'),
|
|
379
|
+
target: 'browser',
|
|
380
|
+
format: 'esm',
|
|
381
|
+
sourcemap: 'none',
|
|
382
|
+
splitting: true,
|
|
383
|
+
minify: false,
|
|
384
|
+
naming: '[dir]/[name]-[hash].[ext]',
|
|
385
|
+
});
|
|
386
|
+
|
|
387
|
+
assert.equal(result.success, true);
|
|
388
|
+
assert.deepEqual(result.outputs, [{ path: weatherAppExpectedOutput }, { path: themeToggleExpectedOutput }]);
|
|
389
|
+
assert.equal(fs.readFileSync(themeToggleExpectedOutput, 'utf8'), 'export const themeToggle = 1;');
|
|
390
|
+
assert.equal(fs.readFileSync(weatherAppExpectedOutput, 'utf8'), 'export const weatherApp = 2;');
|
|
391
|
+
assert.equal(fs.existsSync(themeToggleBunOutput), false);
|
|
392
|
+
assert.equal(fs.existsSync(weatherAppBunOutput), false);
|
|
393
|
+
} finally {
|
|
394
|
+
if (originalBun === undefined) {
|
|
395
|
+
delete (globalThis as typeof globalThis & { Bun?: unknown }).Bun;
|
|
396
|
+
} else {
|
|
397
|
+
(globalThis as typeof globalThis & { Bun?: unknown }).Bun = originalBun;
|
|
398
|
+
}
|
|
399
|
+
cleanupTempRoots();
|
|
400
|
+
}
|
|
401
|
+
});
|
|
402
|
+
|
|
403
|
+
test('BunBuildAdapter remaps Bun root-relative outputs back to outbase-relative paths', async () => {
|
|
404
|
+
const originalBun = (globalThis as typeof globalThis & { Bun?: unknown }).Bun;
|
|
405
|
+
|
|
406
|
+
try {
|
|
407
|
+
const root = createTempRoot('ecopages-bun-outbase-root-relative');
|
|
408
|
+
const srcDir = path.join(root, 'src', 'components', 'theme-toggle');
|
|
409
|
+
const outDir = path.join(root, 'dist', 'assets');
|
|
410
|
+
fs.mkdirSync(srcDir, { recursive: true });
|
|
411
|
+
fs.mkdirSync(outDir, { recursive: true });
|
|
412
|
+
|
|
413
|
+
const entryPath = path.join(srcDir, 'theme-toggle.script.ts');
|
|
414
|
+
fs.writeFileSync(entryPath, 'export const themeToggle = 1;');
|
|
415
|
+
|
|
416
|
+
const bunRootRelativeOutputPath = path.join(outDir, 'src', 'components', 'theme-toggle', 'theme-toggle.script');
|
|
417
|
+
const expectedOutputPath = path.join(outDir, 'components', 'theme-toggle', 'theme-toggle.script');
|
|
418
|
+
|
|
419
|
+
(globalThis as typeof globalThis & { Bun?: unknown }).Bun = {
|
|
420
|
+
build: vi.fn(async () => {
|
|
421
|
+
fs.mkdirSync(path.dirname(bunRootRelativeOutputPath), { recursive: true });
|
|
422
|
+
fs.writeFileSync(bunRootRelativeOutputPath, 'export const themeToggle = 1;', 'utf8');
|
|
423
|
+
return {
|
|
424
|
+
success: true,
|
|
425
|
+
logs: [],
|
|
426
|
+
outputs: [{ path: bunRootRelativeOutputPath }],
|
|
427
|
+
};
|
|
428
|
+
}),
|
|
429
|
+
hash: vi.fn(() => 1),
|
|
430
|
+
resolveSync: vi.fn((importPath: string) => importPath),
|
|
431
|
+
};
|
|
432
|
+
|
|
433
|
+
const freshAdapter = createBunBuildAdapter();
|
|
434
|
+
const result = await freshAdapter.build({
|
|
435
|
+
entrypoints: [entryPath],
|
|
436
|
+
root,
|
|
437
|
+
outdir: outDir,
|
|
438
|
+
outbase: path.join(root, 'src'),
|
|
439
|
+
target: 'browser',
|
|
440
|
+
format: 'esm',
|
|
441
|
+
sourcemap: 'none',
|
|
442
|
+
splitting: true,
|
|
443
|
+
minify: false,
|
|
444
|
+
naming: '[dir]/[name]',
|
|
445
|
+
});
|
|
446
|
+
|
|
447
|
+
assert.equal(result.success, true);
|
|
448
|
+
assert.deepEqual(result.outputs, [{ path: `${expectedOutputPath}.js` }]);
|
|
449
|
+
assert.equal(fs.existsSync(`${expectedOutputPath}.js`), true);
|
|
450
|
+
assert.equal(fs.existsSync(bunRootRelativeOutputPath), false);
|
|
451
|
+
assert.equal(fs.readFileSync(`${expectedOutputPath}.js`, 'utf8'), 'export const themeToggle = 1;');
|
|
452
|
+
} finally {
|
|
453
|
+
if (originalBun === undefined) {
|
|
454
|
+
delete (globalThis as typeof globalThis & { Bun?: unknown }).Bun;
|
|
455
|
+
} else {
|
|
456
|
+
(globalThis as typeof globalThis & { Bun?: unknown }).Bun = originalBun;
|
|
457
|
+
}
|
|
458
|
+
cleanupTempRoots();
|
|
459
|
+
}
|
|
460
|
+
});
|
|
461
|
+
|
|
462
|
+
test('getAppBuildExecutor falls back to the app-owned adapter before the shared default adapter', async () => {
|
|
463
|
+
const appConfig = {
|
|
464
|
+
runtime: {},
|
|
465
|
+
loaders: new Map(),
|
|
466
|
+
} as any;
|
|
467
|
+
const appAdapter = new EsbuildBuildAdapter();
|
|
468
|
+
|
|
469
|
+
setAppBuildAdapter(appConfig, appAdapter);
|
|
470
|
+
|
|
471
|
+
assert.equal(getAppBuildAdapter(appConfig), appAdapter);
|
|
472
|
+
assert.equal(getAppBuildExecutor(appConfig), appAdapter);
|
|
473
|
+
assert.equal(getAppBuildOwnership(appConfig), 'bun-native');
|
|
474
|
+
assert.notEqual(getAppBuildAdapter(appConfig), defaultBuildAdapter);
|
|
475
|
+
});
|
|
476
|
+
|
|
477
|
+
test('getAppBuildAdapter falls back to the explicit Vite-host adapter when ownership is host-owned', () => {
|
|
478
|
+
const appConfig = {
|
|
479
|
+
runtime: {},
|
|
480
|
+
loaders: new Map(),
|
|
481
|
+
} as any;
|
|
482
|
+
|
|
483
|
+
setAppBuildOwnership(appConfig, 'vite-host');
|
|
484
|
+
|
|
485
|
+
assert.equal(getAppBuildOwnership(appConfig), 'vite-host');
|
|
486
|
+
assert.ok(getAppBuildAdapter(appConfig) instanceof ViteHostBuildAdapter);
|
|
487
|
+
});
|
|
488
|
+
|
|
489
|
+
test('createAppBuildExecutor injects app-owned plugins into builds', async () => {
|
|
490
|
+
const plugin = {
|
|
491
|
+
name: 'app-owned-plugin',
|
|
492
|
+
setup() {},
|
|
493
|
+
};
|
|
494
|
+
const adapter = {
|
|
495
|
+
build: vi.fn(async (options) => ({
|
|
496
|
+
success: true,
|
|
497
|
+
logs: [],
|
|
498
|
+
outputs: [{ path: options.outdir ? `${options.outdir}/entry.js` : '/tmp/entry.js' }],
|
|
499
|
+
})),
|
|
500
|
+
resolve: vi.fn(),
|
|
501
|
+
registerPlugin: vi.fn(),
|
|
502
|
+
getTranspileOptions: vi.fn(),
|
|
503
|
+
};
|
|
504
|
+
const appConfig = {
|
|
505
|
+
loaders: new Map(),
|
|
506
|
+
runtime: {},
|
|
507
|
+
} as any;
|
|
508
|
+
|
|
509
|
+
setAppBuildManifest(
|
|
510
|
+
appConfig,
|
|
511
|
+
createAppBuildManifest({
|
|
512
|
+
runtimePlugins: [plugin],
|
|
513
|
+
}),
|
|
514
|
+
);
|
|
515
|
+
const executor = createAppBuildExecutor({
|
|
516
|
+
development: false,
|
|
517
|
+
adapter,
|
|
518
|
+
getPlugins: () => getAppServerBuildPlugins(appConfig),
|
|
519
|
+
});
|
|
520
|
+
|
|
521
|
+
await executor.build({
|
|
522
|
+
entrypoints: ['/tmp/entry.ts'],
|
|
523
|
+
root: '/tmp',
|
|
524
|
+
outdir: '/tmp/out',
|
|
525
|
+
target: 'node',
|
|
526
|
+
format: 'esm',
|
|
527
|
+
sourcemap: 'none',
|
|
528
|
+
splitting: false,
|
|
529
|
+
minify: false,
|
|
530
|
+
});
|
|
531
|
+
|
|
532
|
+
assert.equal(adapter.build.mock.calls.length, 1);
|
|
533
|
+
assert.deepEqual(adapter.build.mock.calls[0][0].plugins, [plugin]);
|
|
534
|
+
assert.equal(adapter.registerPlugin.mock.calls.length, 0);
|
|
535
|
+
});
|
|
536
|
+
|
|
537
|
+
test('build manifest separates server and browser plugin sets', () => {
|
|
538
|
+
const loaderPlugin = { name: 'loader-plugin', setup() {} };
|
|
539
|
+
const runtimePlugin = { name: 'runtime-plugin', setup() {} };
|
|
540
|
+
const browserPlugin = { name: 'browser-plugin', setup() {} };
|
|
541
|
+
const appConfig = {
|
|
542
|
+
loaders: new Map(),
|
|
543
|
+
runtime: {},
|
|
544
|
+
} as any;
|
|
545
|
+
|
|
546
|
+
setAppBuildManifest(
|
|
547
|
+
appConfig,
|
|
548
|
+
createAppBuildManifest({
|
|
549
|
+
loaderPlugins: [loaderPlugin],
|
|
550
|
+
runtimePlugins: [runtimePlugin],
|
|
551
|
+
browserBundlePlugins: [browserPlugin],
|
|
552
|
+
}),
|
|
553
|
+
);
|
|
554
|
+
|
|
555
|
+
assert.deepEqual(getAppBuildManifest(appConfig).loaderPlugins, [loaderPlugin]);
|
|
556
|
+
assert.deepEqual(getAppServerBuildPlugins(appConfig), [loaderPlugin, runtimePlugin]);
|
|
557
|
+
assert.deepEqual(getAppBrowserBuildPlugins(appConfig), [loaderPlugin, runtimePlugin, browserPlugin]);
|
|
558
|
+
});
|
|
559
|
+
|
|
560
|
+
test('createConfiguredAppBuildManifest defaults loader plugins from app config', () => {
|
|
561
|
+
const loaderPlugin = { name: 'loader-plugin', setup() {} };
|
|
562
|
+
const runtimePlugin = { name: 'runtime-plugin', setup() {} };
|
|
563
|
+
const appConfig = {
|
|
564
|
+
loaders: new Map([[loaderPlugin.name, loaderPlugin]]),
|
|
565
|
+
runtime: {},
|
|
566
|
+
} as any;
|
|
567
|
+
|
|
568
|
+
const manifest = createConfiguredAppBuildManifest(appConfig, {
|
|
569
|
+
runtimePlugins: [runtimePlugin],
|
|
570
|
+
});
|
|
571
|
+
|
|
572
|
+
assert.deepEqual(manifest.loaderPlugins, [loaderPlugin]);
|
|
573
|
+
assert.deepEqual(manifest.runtimePlugins, [runtimePlugin]);
|
|
574
|
+
assert.deepEqual(manifest.browserBundlePlugins, []);
|
|
575
|
+
});
|
|
576
|
+
|
|
577
|
+
test('updateAppBuildManifest rebuilds the app manifest from config-owned loaders and explicit runtime plugins', () => {
|
|
578
|
+
const loaderPlugin = { name: 'loader-plugin', setup() {} };
|
|
579
|
+
const runtimePlugin = { name: 'runtime-plugin', setup() {} };
|
|
580
|
+
const browserPlugin = { name: 'browser-plugin', setup() {} };
|
|
581
|
+
const appConfig = {
|
|
582
|
+
loaders: new Map([[loaderPlugin.name, loaderPlugin]]),
|
|
583
|
+
runtime: {},
|
|
584
|
+
} as any;
|
|
585
|
+
|
|
586
|
+
updateAppBuildManifest(appConfig, {
|
|
587
|
+
runtimePlugins: [runtimePlugin],
|
|
588
|
+
browserBundlePlugins: [browserPlugin],
|
|
589
|
+
});
|
|
590
|
+
|
|
591
|
+
assert.deepEqual(getAppBuildManifest(appConfig).loaderPlugins, [loaderPlugin]);
|
|
592
|
+
assert.deepEqual(getAppServerBuildPlugins(appConfig), [loaderPlugin, runtimePlugin]);
|
|
593
|
+
assert.deepEqual(getAppBrowserBuildPlugins(appConfig), [loaderPlugin, runtimePlugin, browserPlugin]);
|
|
594
|
+
});
|
|
595
|
+
|
|
596
|
+
test('collectConfiguredAppBuildManifestContributions gathers processor and integration contributions during config build', async () => {
|
|
597
|
+
const contributionOrder: string[] = [];
|
|
598
|
+
const processorRuntimePlugin = { name: 'processor-runtime-plugin', setup() {} };
|
|
599
|
+
const processorBrowserPlugin = { name: 'processor-browser-plugin', setup() {} };
|
|
600
|
+
const integrationRuntimePlugin = { name: 'integration-runtime-plugin', setup() {} };
|
|
601
|
+
const processor = {
|
|
602
|
+
plugins: [processorRuntimePlugin],
|
|
603
|
+
buildPlugins: [processorBrowserPlugin],
|
|
604
|
+
prepareBuildContributions: vi.fn(async () => {
|
|
605
|
+
contributionOrder.push('processor-prepare');
|
|
606
|
+
}),
|
|
607
|
+
};
|
|
608
|
+
const integration = {
|
|
609
|
+
plugins: [integrationRuntimePlugin],
|
|
610
|
+
setConfig: vi.fn(() => contributionOrder.push('integration-config')),
|
|
611
|
+
prepareBuildContributions: vi.fn(async () => {
|
|
612
|
+
contributionOrder.push('integration-prepare');
|
|
613
|
+
}),
|
|
614
|
+
};
|
|
615
|
+
|
|
616
|
+
const contributions = await collectConfiguredAppBuildManifestContributions({
|
|
617
|
+
processors: new Map([['processor', processor]]),
|
|
618
|
+
integrations: [integration],
|
|
619
|
+
} as any);
|
|
620
|
+
|
|
621
|
+
assert.deepEqual(contributionOrder, ['processor-prepare', 'integration-config', 'integration-prepare']);
|
|
622
|
+
assert.deepEqual(contributions.runtimePlugins, [processorRuntimePlugin, integrationRuntimePlugin]);
|
|
623
|
+
assert.deepEqual(contributions.browserBundlePlugins, [processorBrowserPlugin]);
|
|
624
|
+
});
|
|
625
|
+
|
|
626
|
+
test('setupAppRuntimePlugins runs runtime setup without recomposing manifest contributions', async () => {
|
|
627
|
+
const contributionOrder: string[] = [];
|
|
628
|
+
const processorRuntimePlugin = { name: 'processor-runtime-plugin', setup() {} };
|
|
629
|
+
const integrationRuntimePlugin = { name: 'integration-runtime-plugin', setup() {} };
|
|
630
|
+
const processor = {
|
|
631
|
+
plugins: [processorRuntimePlugin],
|
|
632
|
+
setup: vi.fn(async () => {
|
|
633
|
+
contributionOrder.push('processor-setup');
|
|
634
|
+
}),
|
|
635
|
+
};
|
|
636
|
+
const integration = {
|
|
637
|
+
plugins: [integrationRuntimePlugin],
|
|
638
|
+
setConfig: vi.fn(() => contributionOrder.push('integration-config')),
|
|
639
|
+
setRuntimeOrigin: vi.fn(() => contributionOrder.push('integration-origin')),
|
|
640
|
+
setHmrManager: vi.fn(() => contributionOrder.push('integration-hmr')),
|
|
641
|
+
setup: vi.fn(async () => {
|
|
642
|
+
contributionOrder.push('integration-setup');
|
|
643
|
+
}),
|
|
644
|
+
};
|
|
645
|
+
const observedRuntimePlugins: string[] = [];
|
|
646
|
+
|
|
647
|
+
await setupAppRuntimePlugins({
|
|
648
|
+
appConfig: {
|
|
649
|
+
processors: new Map([['processor', processor]]),
|
|
650
|
+
integrations: [integration],
|
|
651
|
+
} as any,
|
|
652
|
+
runtimeOrigin: 'http://localhost:3000',
|
|
653
|
+
hmrManager: {} as any,
|
|
654
|
+
onRuntimePlugin: (plugin) => observedRuntimePlugins.push(plugin.name),
|
|
655
|
+
});
|
|
656
|
+
|
|
657
|
+
assert.deepEqual(contributionOrder, [
|
|
658
|
+
'processor-setup',
|
|
659
|
+
'integration-config',
|
|
660
|
+
'integration-origin',
|
|
661
|
+
'integration-hmr',
|
|
662
|
+
'integration-setup',
|
|
663
|
+
]);
|
|
664
|
+
assert.deepEqual(observedRuntimePlugins, ['processor-runtime-plugin', 'integration-runtime-plugin']);
|
|
665
|
+
});
|
|
666
|
+
|
|
667
|
+
test('EsbuildBuildAdapter supports module virtual modules', async () => {
|
|
668
|
+
try {
|
|
669
|
+
const root = createTempRoot('ecopages-esbuild-virtual-module');
|
|
670
|
+
const srcDir = path.join(root, 'src');
|
|
671
|
+
const outDir = path.join(root, 'dist');
|
|
672
|
+
fs.mkdirSync(srcDir, { recursive: true });
|
|
673
|
+
|
|
674
|
+
const entryPath = path.join(srcDir, 'entry.ts');
|
|
675
|
+
fs.writeFileSync(entryPath, "import answer from 'virtual:answer';\nexport const value = answer;");
|
|
676
|
+
|
|
677
|
+
const adapter = new EsbuildBuildAdapter();
|
|
678
|
+
|
|
679
|
+
const result = await adapter.build({
|
|
680
|
+
entrypoints: [entryPath],
|
|
681
|
+
root,
|
|
682
|
+
outdir: outDir,
|
|
683
|
+
target: 'node',
|
|
684
|
+
format: 'esm',
|
|
685
|
+
sourcemap: 'none',
|
|
686
|
+
splitting: false,
|
|
687
|
+
minify: false,
|
|
688
|
+
plugins: [
|
|
689
|
+
{
|
|
690
|
+
name: 'virtual-module-test',
|
|
691
|
+
setup(build: EcoBuildPluginBuilder) {
|
|
692
|
+
build.module('virtual:answer', () => ({
|
|
693
|
+
loader: 'object',
|
|
694
|
+
exports: {
|
|
695
|
+
default: 42,
|
|
696
|
+
},
|
|
697
|
+
}));
|
|
698
|
+
},
|
|
699
|
+
},
|
|
700
|
+
],
|
|
701
|
+
});
|
|
702
|
+
|
|
703
|
+
assert.equal(result.success, true);
|
|
704
|
+
|
|
705
|
+
const outputPath = result.outputs.find((output) => output.path.endsWith('entry.js'))?.path;
|
|
706
|
+
assert.ok(outputPath);
|
|
707
|
+
|
|
708
|
+
const outputSource = fs.readFileSync(outputPath, 'utf-8');
|
|
709
|
+
assert.match(outputSource, /42/);
|
|
710
|
+
} finally {
|
|
711
|
+
cleanupTempRoots();
|
|
712
|
+
}
|
|
713
|
+
});
|
|
714
|
+
|
|
715
|
+
test('EsbuildBuildAdapter applies build plugin CSS transforms to imported CSS strings', async () => {
|
|
716
|
+
try {
|
|
717
|
+
const root = createTempRoot('ecopages-esbuild-css');
|
|
718
|
+
const srcDir = path.join(root, 'src');
|
|
719
|
+
const outDir = path.join(root, 'dist');
|
|
720
|
+
fs.mkdirSync(srcDir, { recursive: true });
|
|
721
|
+
|
|
722
|
+
const cssPath = path.join(srcDir, 'styles.css');
|
|
723
|
+
const entryPath = path.join(srcDir, 'entry.ts');
|
|
724
|
+
|
|
725
|
+
fs.writeFileSync(cssPath, '.counter { color: red; }');
|
|
726
|
+
fs.writeFileSync(entryPath, "import styles from './styles.css';\nexport const cssText = styles;");
|
|
727
|
+
|
|
728
|
+
const adapter = new EsbuildBuildAdapter();
|
|
729
|
+
|
|
730
|
+
const result = await adapter.build({
|
|
731
|
+
entrypoints: [entryPath],
|
|
732
|
+
root,
|
|
733
|
+
outdir: outDir,
|
|
734
|
+
target: 'node',
|
|
735
|
+
format: 'esm',
|
|
736
|
+
sourcemap: 'none',
|
|
737
|
+
splitting: false,
|
|
738
|
+
minify: false,
|
|
739
|
+
plugins: [
|
|
740
|
+
{
|
|
741
|
+
name: 'css-bridge-replacement-test',
|
|
742
|
+
setup(build) {
|
|
743
|
+
build.onLoad({ filter: /\.css$/ }, async (args) => {
|
|
744
|
+
const contents = fs.readFileSync(args.path, 'utf-8');
|
|
745
|
+
return {
|
|
746
|
+
loader: 'object',
|
|
747
|
+
exports: {
|
|
748
|
+
default: `/* transformed */\n${contents}`,
|
|
749
|
+
},
|
|
750
|
+
};
|
|
751
|
+
});
|
|
752
|
+
},
|
|
753
|
+
},
|
|
754
|
+
],
|
|
755
|
+
});
|
|
756
|
+
|
|
757
|
+
assert.equal(result.success, true);
|
|
758
|
+
|
|
759
|
+
const outputPath = result.outputs.find((output) => output.path.endsWith('entry.js'))?.path;
|
|
760
|
+
assert.ok(outputPath);
|
|
761
|
+
|
|
762
|
+
const outputSource = fs.readFileSync(outputPath, 'utf-8');
|
|
763
|
+
assert.match(outputSource, /\/\* transformed \*\//);
|
|
764
|
+
assert.match(outputSource, /\.counter \{ color: red; \}/);
|
|
765
|
+
} finally {
|
|
766
|
+
cleanupTempRoots();
|
|
767
|
+
clearNodeCssBridge();
|
|
768
|
+
}
|
|
769
|
+
});
|
|
770
|
+
|
|
771
|
+
test('EsbuildBuildAdapter resolves tsconfig path aliases', async () => {
|
|
772
|
+
try {
|
|
773
|
+
const root = createTempRoot('ecopages-esbuild-tsconfig-paths');
|
|
774
|
+
const srcDir = path.join(root, 'src');
|
|
775
|
+
const outDir = path.join(root, 'dist');
|
|
776
|
+
const libDir = path.join(srcDir, 'lib');
|
|
777
|
+
fs.mkdirSync(libDir, { recursive: true });
|
|
778
|
+
|
|
779
|
+
const tsconfigPath = path.join(root, 'tsconfig.json');
|
|
780
|
+
fs.writeFileSync(
|
|
781
|
+
tsconfigPath,
|
|
782
|
+
JSON.stringify({
|
|
783
|
+
compilerOptions: {
|
|
784
|
+
baseUrl: '.',
|
|
785
|
+
paths: {
|
|
786
|
+
'@/*': ['src/*'],
|
|
787
|
+
},
|
|
788
|
+
},
|
|
789
|
+
}),
|
|
790
|
+
);
|
|
791
|
+
|
|
792
|
+
const utilPath = path.join(libDir, 'count.ts');
|
|
793
|
+
fs.writeFileSync(utilPath, 'export const count = 7;');
|
|
794
|
+
|
|
795
|
+
const entryPath = path.join(srcDir, 'entry.ts');
|
|
796
|
+
fs.writeFileSync(entryPath, "import { count } from '@/lib/count';\nexport const value = count;");
|
|
797
|
+
|
|
798
|
+
const adapter = new EsbuildBuildAdapter();
|
|
799
|
+
const result = await adapter.build({
|
|
800
|
+
entrypoints: [entryPath],
|
|
801
|
+
root,
|
|
802
|
+
outdir: outDir,
|
|
803
|
+
target: 'node',
|
|
804
|
+
format: 'esm',
|
|
805
|
+
sourcemap: 'none',
|
|
806
|
+
splitting: false,
|
|
807
|
+
minify: false,
|
|
808
|
+
});
|
|
809
|
+
|
|
810
|
+
assert.equal(result.success, true);
|
|
811
|
+
|
|
812
|
+
const outputPath = result.outputs.find((output) => output.path.endsWith('entry.js'))?.path;
|
|
813
|
+
assert.ok(outputPath);
|
|
814
|
+
|
|
815
|
+
const outputSource = fs.readFileSync(outputPath, 'utf-8');
|
|
816
|
+
assert.match(outputSource, /7/);
|
|
817
|
+
} finally {
|
|
818
|
+
cleanupTempRoots();
|
|
819
|
+
clearNodeCssBridge();
|
|
820
|
+
}
|
|
821
|
+
});
|
|
822
|
+
|
|
823
|
+
test('EsbuildBuildAdapter compiles decorated classes without legacy mode', async () => {
|
|
824
|
+
try {
|
|
825
|
+
const root = createTempRoot('ecopages-esbuild-decorated-declare');
|
|
826
|
+
const srcDir = path.join(root, 'src');
|
|
827
|
+
const outDir = path.join(root, 'dist');
|
|
828
|
+
fs.mkdirSync(srcDir, { recursive: true });
|
|
829
|
+
|
|
830
|
+
const entryPath = path.join(srcDir, 'entry.ts');
|
|
831
|
+
fs.writeFileSync(
|
|
832
|
+
entryPath,
|
|
833
|
+
[
|
|
834
|
+
'function sealed<T extends new (...args: never[]) => object>(value: T) {',
|
|
835
|
+
'\treturn value;',
|
|
836
|
+
'}',
|
|
837
|
+
'@sealed',
|
|
838
|
+
'class Counter {}',
|
|
839
|
+
'export const ready = typeof Counter === "function";',
|
|
840
|
+
].join('\n'),
|
|
841
|
+
);
|
|
842
|
+
|
|
843
|
+
const adapter = new EsbuildBuildAdapter();
|
|
844
|
+
const result = await adapter.build({
|
|
845
|
+
entrypoints: [entryPath],
|
|
846
|
+
root,
|
|
847
|
+
outdir: outDir,
|
|
848
|
+
target: 'node',
|
|
849
|
+
format: 'esm',
|
|
850
|
+
sourcemap: 'none',
|
|
851
|
+
splitting: false,
|
|
852
|
+
minify: false,
|
|
853
|
+
});
|
|
854
|
+
|
|
855
|
+
assert.equal(result.success, true);
|
|
856
|
+
|
|
857
|
+
const outputPath = result.outputs.find((output) => output.path.endsWith('entry.js'))?.path;
|
|
858
|
+
assert.ok(outputPath);
|
|
859
|
+
} finally {
|
|
860
|
+
cleanupTempRoots();
|
|
861
|
+
clearNodeCssBridge();
|
|
862
|
+
}
|
|
863
|
+
});
|
|
864
|
+
|
|
865
|
+
test('EsbuildBuildAdapter compiles decorated accessor fields', async () => {
|
|
866
|
+
try {
|
|
867
|
+
const root = createTempRoot('ecopages-esbuild-decorated-accessor');
|
|
868
|
+
const srcDir = path.join(root, 'src');
|
|
869
|
+
const outDir = path.join(root, 'dist');
|
|
870
|
+
fs.mkdirSync(srcDir, { recursive: true });
|
|
871
|
+
|
|
872
|
+
const entryPath = path.join(srcDir, 'entry.ts');
|
|
873
|
+
fs.writeFileSync(
|
|
874
|
+
entryPath,
|
|
875
|
+
[
|
|
876
|
+
'function property(_options: unknown) {',
|
|
877
|
+
'\treturn function (_target: unknown, _context: unknown) {};',
|
|
878
|
+
'}',
|
|
879
|
+
'class Counter {',
|
|
880
|
+
'\t@property({ type: Number }) accessor count = 0;',
|
|
881
|
+
'}',
|
|
882
|
+
'export const ready = typeof Counter === "function";',
|
|
883
|
+
].join('\n'),
|
|
884
|
+
);
|
|
885
|
+
|
|
886
|
+
const adapter = new EsbuildBuildAdapter();
|
|
887
|
+
const result = await adapter.build({
|
|
888
|
+
entrypoints: [entryPath],
|
|
889
|
+
root,
|
|
890
|
+
outdir: outDir,
|
|
891
|
+
target: 'node',
|
|
892
|
+
format: 'esm',
|
|
893
|
+
sourcemap: 'none',
|
|
894
|
+
splitting: false,
|
|
895
|
+
minify: false,
|
|
896
|
+
});
|
|
897
|
+
|
|
898
|
+
assert.equal(result.success, true);
|
|
899
|
+
|
|
900
|
+
const outputPath = result.outputs.find((output) => output.path.endsWith('entry.js'))?.path;
|
|
901
|
+
assert.ok(outputPath);
|
|
902
|
+
} finally {
|
|
903
|
+
cleanupTempRoots();
|
|
904
|
+
clearNodeCssBridge();
|
|
905
|
+
}
|
|
906
|
+
});
|
|
907
|
+
|
|
908
|
+
test('EsbuildBuildAdapter downlevels accessor fields for browser target bundles', async () => {
|
|
909
|
+
try {
|
|
910
|
+
const root = createTempRoot('ecopages-esbuild-browser-accessor');
|
|
911
|
+
const srcDir = path.join(root, 'src');
|
|
912
|
+
const outDir = path.join(root, 'dist');
|
|
913
|
+
fs.mkdirSync(srcDir, { recursive: true });
|
|
914
|
+
|
|
915
|
+
const entryPath = path.join(srcDir, 'entry.ts');
|
|
916
|
+
fs.writeFileSync(
|
|
917
|
+
entryPath,
|
|
918
|
+
[
|
|
919
|
+
'class Counter {',
|
|
920
|
+
'\taccessor count = 0;',
|
|
921
|
+
'}',
|
|
922
|
+
'export const ready = typeof Counter === "function";',
|
|
923
|
+
].join('\n'),
|
|
924
|
+
);
|
|
925
|
+
|
|
926
|
+
const adapter = new EsbuildBuildAdapter();
|
|
927
|
+
const result = await adapter.build({
|
|
928
|
+
entrypoints: [entryPath],
|
|
929
|
+
root,
|
|
930
|
+
outdir: outDir,
|
|
931
|
+
target: 'browser',
|
|
932
|
+
format: 'esm',
|
|
933
|
+
sourcemap: 'none',
|
|
934
|
+
splitting: false,
|
|
935
|
+
minify: false,
|
|
936
|
+
});
|
|
937
|
+
|
|
938
|
+
assert.equal(result.success, true);
|
|
939
|
+
|
|
940
|
+
const outputPath = result.outputs.find((output) => output.path.endsWith('entry.js'))?.path;
|
|
941
|
+
assert.ok(outputPath);
|
|
942
|
+
|
|
943
|
+
const outputSource = fs.readFileSync(outputPath, 'utf-8');
|
|
944
|
+
assert.doesNotMatch(outputSource, /accessor\s+count/);
|
|
945
|
+
} finally {
|
|
946
|
+
cleanupTempRoots();
|
|
947
|
+
clearNodeCssBridge();
|
|
948
|
+
}
|
|
949
|
+
});
|
|
950
|
+
|
|
951
|
+
test('EsbuildBuildAdapter applies plugin CSS transforms for CSS imported in TS modules', async () => {
|
|
952
|
+
try {
|
|
953
|
+
const root = createTempRoot('ecopages-esbuild-plugin-css-transform');
|
|
954
|
+
const srcDir = path.join(root, 'src');
|
|
955
|
+
const outDir = path.join(root, 'dist');
|
|
956
|
+
fs.mkdirSync(srcDir, { recursive: true });
|
|
957
|
+
|
|
958
|
+
const cssPath = path.join(srcDir, 'styles.css');
|
|
959
|
+
const entryPath = path.join(srcDir, 'entry.ts');
|
|
960
|
+
|
|
961
|
+
fs.writeFileSync(cssPath, '.counter { color: red; }');
|
|
962
|
+
fs.writeFileSync(entryPath, "import styles from './styles.css';\nexport const cssText = styles;");
|
|
963
|
+
|
|
964
|
+
const adapter = new EsbuildBuildAdapter();
|
|
965
|
+
|
|
966
|
+
const result = await adapter.build({
|
|
967
|
+
entrypoints: [entryPath],
|
|
968
|
+
root,
|
|
969
|
+
outdir: outDir,
|
|
970
|
+
target: 'node',
|
|
971
|
+
format: 'esm',
|
|
972
|
+
sourcemap: 'none',
|
|
973
|
+
splitting: false,
|
|
974
|
+
minify: false,
|
|
975
|
+
plugins: [
|
|
976
|
+
{
|
|
977
|
+
name: 'css-transform-test-plugin',
|
|
978
|
+
setup(build) {
|
|
979
|
+
build.onLoad({ filter: /\.css$/ }, async (args) => {
|
|
980
|
+
const contents = fs.readFileSync(args.path, 'utf-8');
|
|
981
|
+
return {
|
|
982
|
+
loader: 'object',
|
|
983
|
+
exports: {
|
|
984
|
+
default: `/* postprocessed */\n${contents}`,
|
|
985
|
+
},
|
|
986
|
+
};
|
|
987
|
+
});
|
|
988
|
+
},
|
|
989
|
+
},
|
|
990
|
+
],
|
|
991
|
+
});
|
|
992
|
+
|
|
993
|
+
assert.equal(result.success, true);
|
|
994
|
+
|
|
995
|
+
const outputPath = result.outputs.find((output) => output.path.endsWith('entry.js'))?.path;
|
|
996
|
+
assert.ok(outputPath);
|
|
997
|
+
|
|
998
|
+
const outputSource = fs.readFileSync(outputPath, 'utf-8');
|
|
999
|
+
assert.match(outputSource, /\/\* postprocessed \*\//);
|
|
1000
|
+
assert.match(outputSource, /\.counter \{ color: red; \}/);
|
|
1001
|
+
} finally {
|
|
1002
|
+
cleanupTempRoots();
|
|
1003
|
+
clearNodeCssBridge();
|
|
1004
|
+
}
|
|
1005
|
+
});
|
|
1006
|
+
|
|
1007
|
+
test('EsbuildBuildAdapter supports synchronous onLoad transforms for entrypoints', async () => {
|
|
1008
|
+
try {
|
|
1009
|
+
const root = createTempRoot('ecopages-esbuild-entrypoint-onload');
|
|
1010
|
+
const srcDir = path.join(root, 'src');
|
|
1011
|
+
const outDir = path.join(root, 'dist');
|
|
1012
|
+
fs.mkdirSync(srcDir, { recursive: true });
|
|
1013
|
+
|
|
1014
|
+
const entryPath = path.join(srcDir, 'entry.tsx');
|
|
1015
|
+
fs.writeFileSync(
|
|
1016
|
+
entryPath,
|
|
1017
|
+
[
|
|
1018
|
+
"import { jsx as _jsx } from 'react/jsx-runtime';",
|
|
1019
|
+
"export const view = () => _jsx('button', { children: 'ok' });",
|
|
1020
|
+
].join('\n'),
|
|
1021
|
+
);
|
|
1022
|
+
|
|
1023
|
+
const adapter = new EsbuildBuildAdapter();
|
|
1024
|
+
const result = await adapter.build({
|
|
1025
|
+
entrypoints: [entryPath],
|
|
1026
|
+
root,
|
|
1027
|
+
outdir: outDir,
|
|
1028
|
+
target: 'browser',
|
|
1029
|
+
format: 'esm',
|
|
1030
|
+
sourcemap: 'none',
|
|
1031
|
+
splitting: false,
|
|
1032
|
+
minify: false,
|
|
1033
|
+
plugins: [
|
|
1034
|
+
{
|
|
1035
|
+
name: 'entrypoint-onload-test-plugin',
|
|
1036
|
+
setup(build) {
|
|
1037
|
+
build.onLoad({ filter: /entry\.tsx$/ }, (args) => ({
|
|
1038
|
+
contents: fs.readFileSync(args.path, 'utf-8'),
|
|
1039
|
+
loader: 'tsx',
|
|
1040
|
+
resolveDir: path.dirname(args.path),
|
|
1041
|
+
}));
|
|
1042
|
+
},
|
|
1043
|
+
},
|
|
1044
|
+
],
|
|
1045
|
+
});
|
|
1046
|
+
|
|
1047
|
+
assert.equal(result.success, true);
|
|
1048
|
+
|
|
1049
|
+
const outputPath = result.outputs.find((output) => output.path.endsWith('entry.js'))?.path;
|
|
1050
|
+
assert.ok(outputPath);
|
|
1051
|
+
|
|
1052
|
+
const outputSource = fs.readFileSync(outputPath, 'utf-8');
|
|
1053
|
+
assert.match(outputSource, /button/);
|
|
1054
|
+
} finally {
|
|
1055
|
+
cleanupTempRoots();
|
|
1056
|
+
clearNodeCssBridge();
|
|
1057
|
+
}
|
|
1058
|
+
});
|
|
1059
|
+
|
|
1060
|
+
test('EsbuildBuildAdapter returns dependency graph entrypoint mapping', async () => {
|
|
1061
|
+
try {
|
|
1062
|
+
const root = createTempRoot('ecopages-esbuild-dependency-graph');
|
|
1063
|
+
const srcDir = path.join(root, 'src');
|
|
1064
|
+
const outDir = path.join(root, 'dist');
|
|
1065
|
+
fs.mkdirSync(srcDir, { recursive: true });
|
|
1066
|
+
|
|
1067
|
+
const sharedPath = path.join(srcDir, 'shared.ts');
|
|
1068
|
+
const leafPath = path.join(srcDir, 'leaf.ts');
|
|
1069
|
+
const entryPath = path.join(srcDir, 'entry.ts');
|
|
1070
|
+
|
|
1071
|
+
fs.writeFileSync(sharedPath, "import { leaf } from './leaf';\nexport const shared = leaf + 1;");
|
|
1072
|
+
fs.writeFileSync(leafPath, 'export const leaf = 2;');
|
|
1073
|
+
fs.writeFileSync(entryPath, "import { shared } from './shared';\nexport const value = shared;");
|
|
1074
|
+
|
|
1075
|
+
const adapter = new EsbuildBuildAdapter();
|
|
1076
|
+
const result = await adapter.build({
|
|
1077
|
+
entrypoints: [entryPath],
|
|
1078
|
+
root,
|
|
1079
|
+
outdir: outDir,
|
|
1080
|
+
target: 'node',
|
|
1081
|
+
format: 'esm',
|
|
1082
|
+
sourcemap: 'none',
|
|
1083
|
+
splitting: false,
|
|
1084
|
+
minify: false,
|
|
1085
|
+
});
|
|
1086
|
+
|
|
1087
|
+
assert.equal(result.success, true);
|
|
1088
|
+
assert.ok(result.dependencyGraph);
|
|
1089
|
+
|
|
1090
|
+
const dependencies = result.dependencyGraph?.entrypoints[path.resolve(entryPath)] ?? [];
|
|
1091
|
+
|
|
1092
|
+
assert.ok(dependencies.includes(path.resolve(entryPath)));
|
|
1093
|
+
assert.ok(dependencies.includes(path.resolve(sharedPath)));
|
|
1094
|
+
assert.ok(dependencies.includes(path.resolve(leafPath)));
|
|
1095
|
+
} finally {
|
|
1096
|
+
cleanupTempRoots();
|
|
1097
|
+
clearNodeCssBridge();
|
|
1098
|
+
}
|
|
1099
|
+
});
|
|
1100
|
+
|
|
1101
|
+
test('EsbuildBuildAdapter honors first-match plugin precedence within one build', async () => {
|
|
1102
|
+
try {
|
|
1103
|
+
const root = createTempRoot('ecopages-esbuild-plugin-precedence');
|
|
1104
|
+
const srcDir = path.join(root, 'src');
|
|
1105
|
+
const outDir = path.join(root, 'dist');
|
|
1106
|
+
fs.mkdirSync(srcDir, { recursive: true });
|
|
1107
|
+
|
|
1108
|
+
const cssPath = path.join(srcDir, 'styles.css');
|
|
1109
|
+
const entryPath = path.join(srcDir, 'entry.ts');
|
|
1110
|
+
|
|
1111
|
+
fs.writeFileSync(cssPath, '.counter { color: red; }');
|
|
1112
|
+
fs.writeFileSync(entryPath, "import styles from './styles.css';\nexport const cssText = styles;");
|
|
1113
|
+
|
|
1114
|
+
const adapter = new EsbuildBuildAdapter();
|
|
1115
|
+
|
|
1116
|
+
const result = await adapter.build({
|
|
1117
|
+
entrypoints: [entryPath],
|
|
1118
|
+
root,
|
|
1119
|
+
outdir: outDir,
|
|
1120
|
+
target: 'node',
|
|
1121
|
+
format: 'esm',
|
|
1122
|
+
sourcemap: 'none',
|
|
1123
|
+
splitting: false,
|
|
1124
|
+
minify: false,
|
|
1125
|
+
plugins: [
|
|
1126
|
+
{
|
|
1127
|
+
name: 'first-css-plugin',
|
|
1128
|
+
setup(build) {
|
|
1129
|
+
build.onLoad({ filter: /\.css$/ }, async () => {
|
|
1130
|
+
return {
|
|
1131
|
+
loader: 'object',
|
|
1132
|
+
exports: {
|
|
1133
|
+
default: 'first-css',
|
|
1134
|
+
},
|
|
1135
|
+
};
|
|
1136
|
+
});
|
|
1137
|
+
},
|
|
1138
|
+
},
|
|
1139
|
+
{
|
|
1140
|
+
name: 'second-css-plugin',
|
|
1141
|
+
setup(build) {
|
|
1142
|
+
build.onLoad({ filter: /\.css$/ }, async () => {
|
|
1143
|
+
return {
|
|
1144
|
+
loader: 'object',
|
|
1145
|
+
exports: {
|
|
1146
|
+
default: 'second-css',
|
|
1147
|
+
},
|
|
1148
|
+
};
|
|
1149
|
+
});
|
|
1150
|
+
},
|
|
1151
|
+
},
|
|
1152
|
+
],
|
|
1153
|
+
});
|
|
1154
|
+
|
|
1155
|
+
assert.equal(result.success, true);
|
|
1156
|
+
|
|
1157
|
+
const outputPath = result.outputs.find((output) => output.path.endsWith('entry.js'))?.path;
|
|
1158
|
+
assert.ok(outputPath);
|
|
1159
|
+
|
|
1160
|
+
const outputSource = fs.readFileSync(outputPath, 'utf-8');
|
|
1161
|
+
assert.match(outputSource, /first-css/);
|
|
1162
|
+
assert.doesNotMatch(outputSource, /second-css/);
|
|
1163
|
+
} finally {
|
|
1164
|
+
cleanupTempRoots();
|
|
1165
|
+
clearNodeCssBridge();
|
|
1166
|
+
}
|
|
1167
|
+
});
|
|
1168
|
+
|
|
1169
|
+
test('EsbuildBuildAdapter resolves templated naming patterns to concrete output files', async () => {
|
|
1170
|
+
try {
|
|
1171
|
+
const root = createTempRoot('ecopages-esbuild-naming-template');
|
|
1172
|
+
const srcDir = path.join(root, 'src');
|
|
1173
|
+
const outDir = path.join(root, 'dist');
|
|
1174
|
+
fs.mkdirSync(srcDir, { recursive: true });
|
|
1175
|
+
|
|
1176
|
+
const entryPath = path.join(srcDir, 'entry.ts');
|
|
1177
|
+
fs.writeFileSync(entryPath, 'export const value = 1;');
|
|
1178
|
+
|
|
1179
|
+
const adapter = new EsbuildBuildAdapter();
|
|
1180
|
+
const result = await adapter.build({
|
|
1181
|
+
entrypoints: [entryPath],
|
|
1182
|
+
root,
|
|
1183
|
+
outdir: outDir,
|
|
1184
|
+
target: 'node',
|
|
1185
|
+
format: 'esm',
|
|
1186
|
+
sourcemap: 'none',
|
|
1187
|
+
splitting: true,
|
|
1188
|
+
minify: false,
|
|
1189
|
+
naming: '[name].[ext]',
|
|
1190
|
+
});
|
|
1191
|
+
|
|
1192
|
+
assert.equal(result.success, true);
|
|
1193
|
+
|
|
1194
|
+
const outputPath = result.outputs.find((output) => output.path.endsWith('entry.js'))?.path;
|
|
1195
|
+
assert.ok(outputPath);
|
|
1196
|
+
assert.equal(fs.existsSync(path.join(outDir, '[name].[ext]')), false);
|
|
1197
|
+
} finally {
|
|
1198
|
+
cleanupTempRoots();
|
|
1199
|
+
clearNodeCssBridge();
|
|
1200
|
+
}
|
|
1201
|
+
});
|
|
1202
|
+
|
|
1203
|
+
test('EsbuildBuildAdapter forwards define replacements into bundled runtime modules', async () => {
|
|
1204
|
+
try {
|
|
1205
|
+
const root = createTempRoot('ecopages-esbuild-define-runtime');
|
|
1206
|
+
const srcDir = path.join(root, 'src');
|
|
1207
|
+
const outDir = path.join(root, 'dist');
|
|
1208
|
+
fs.mkdirSync(srcDir, { recursive: true });
|
|
1209
|
+
|
|
1210
|
+
const entryPath = path.join(srcDir, 'entry.js');
|
|
1211
|
+
fs.writeFileSync(entryPath, 'export const mode = process.env.NODE_ENV;\n');
|
|
1212
|
+
|
|
1213
|
+
const adapter = new EsbuildBuildAdapter();
|
|
1214
|
+
const result = await adapter.build({
|
|
1215
|
+
entrypoints: [entryPath],
|
|
1216
|
+
root,
|
|
1217
|
+
outdir: outDir,
|
|
1218
|
+
target: 'browser',
|
|
1219
|
+
format: 'esm',
|
|
1220
|
+
sourcemap: 'none',
|
|
1221
|
+
splitting: false,
|
|
1222
|
+
minify: false,
|
|
1223
|
+
define: {
|
|
1224
|
+
'process.env.NODE_ENV': '"development"',
|
|
1225
|
+
},
|
|
1226
|
+
});
|
|
1227
|
+
|
|
1228
|
+
assert.equal(result.success, true);
|
|
1229
|
+
|
|
1230
|
+
const outputPath = result.outputs.find((output) => output.path.endsWith('entry.js'))?.path;
|
|
1231
|
+
assert.ok(outputPath);
|
|
1232
|
+
|
|
1233
|
+
const outputSource = fs.readFileSync(outputPath, 'utf-8');
|
|
1234
|
+
assert.match(outputSource, /development/);
|
|
1235
|
+
assert.doesNotMatch(outputSource, /production/);
|
|
1236
|
+
} finally {
|
|
1237
|
+
cleanupTempRoots();
|
|
1238
|
+
clearNodeCssBridge();
|
|
1239
|
+
}
|
|
1240
|
+
});
|