@ecopages/core 0.2.0-alpha.7 → 0.2.0-alpha.9
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 +31 -0
- package/package.json +212 -92
- package/src/adapters/abstract/application-adapter.d.ts +168 -0
- package/src/adapters/abstract/application-adapter.js +109 -0
- package/src/adapters/abstract/router-adapter.d.ts +26 -0
- package/src/adapters/abstract/router-adapter.js +5 -0
- package/src/adapters/abstract/server-adapter.d.ts +69 -0
- package/src/adapters/abstract/server-adapter.js +15 -0
- package/src/adapters/bun/client-bridge.d.ts +34 -0
- package/src/adapters/bun/client-bridge.js +48 -0
- package/src/adapters/bun/create-app.d.ts +60 -0
- package/src/adapters/bun/create-app.js +117 -0
- package/src/adapters/bun/hmr-manager.d.ts +143 -0
- package/src/adapters/bun/hmr-manager.js +334 -0
- package/src/adapters/bun/index.d.ts +2 -0
- package/src/adapters/bun/index.js +8 -0
- package/src/adapters/bun/server-adapter.d.ts +155 -0
- package/src/adapters/bun/server-adapter.js +373 -0
- package/src/adapters/bun/server-lifecycle.d.ts +63 -0
- package/src/adapters/bun/server-lifecycle.js +92 -0
- package/src/adapters/index.d.ts +6 -0
- package/src/adapters/index.js +14 -0
- package/src/adapters/node/bootstrap-dependency-resolver.d.ts +44 -0
- package/src/adapters/node/bootstrap-dependency-resolver.js +172 -0
- package/src/adapters/node/create-app.d.ts +21 -0
- package/src/adapters/node/create-app.js +143 -0
- package/src/adapters/node/index.d.ts +6 -0
- package/src/adapters/node/index.js +11 -0
- package/src/adapters/node/node-client-bridge.d.ts +26 -0
- package/src/adapters/node/node-client-bridge.js +66 -0
- package/src/adapters/node/node-hmr-manager.d.ts +133 -0
- package/src/adapters/node/node-hmr-manager.js +312 -0
- package/src/adapters/node/runtime-adapter.d.ts +46 -0
- package/src/adapters/node/runtime-adapter.js +306 -0
- package/src/adapters/node/server-adapter.d.ts +161 -0
- package/src/adapters/node/server-adapter.js +358 -0
- package/src/adapters/node/static-content-server.d.ts +60 -0
- package/src/adapters/node/static-content-server.js +194 -0
- package/src/adapters/node/write-runtime-manifest.d.ts +26 -0
- package/src/adapters/node/write-runtime-manifest.js +12 -0
- package/src/adapters/shared/api-response.d.ts +52 -0
- package/src/adapters/shared/api-response.js +96 -0
- package/src/adapters/shared/application-adapter.d.ts +18 -0
- package/src/adapters/shared/application-adapter.js +90 -0
- package/src/adapters/shared/define-api-handler.d.ts +25 -0
- package/src/adapters/shared/define-api-handler.js +15 -0
- package/src/adapters/shared/explicit-static-route-matcher.d.ts +38 -0
- package/src/adapters/shared/explicit-static-route-matcher.js +103 -0
- package/src/adapters/shared/file-route-middleware-pipeline.d.ts +65 -0
- package/src/adapters/shared/file-route-middleware-pipeline.js +99 -0
- package/src/adapters/shared/fs-server-response-factory.d.ts +19 -0
- package/src/adapters/shared/fs-server-response-factory.js +97 -0
- package/src/adapters/shared/fs-server-response-matcher.d.ts +75 -0
- package/src/adapters/shared/fs-server-response-matcher.js +160 -0
- package/src/adapters/shared/hmr-entrypoint-registrar.d.ts +55 -0
- package/src/adapters/shared/hmr-entrypoint-registrar.js +87 -0
- package/src/adapters/shared/hmr-html-response.d.ts +22 -0
- package/src/adapters/shared/hmr-html-response.js +32 -0
- package/src/adapters/shared/render-context.d.ts +14 -0
- package/src/adapters/shared/render-context.js +70 -0
- package/src/adapters/shared/runtime-bootstrap.d.ts +38 -0
- package/src/adapters/shared/runtime-bootstrap.js +43 -0
- package/src/adapters/shared/server-adapter.d.ts +97 -0
- package/src/adapters/shared/server-adapter.js +386 -0
- package/src/adapters/shared/server-route-handler.d.ts +89 -0
- package/src/adapters/shared/server-route-handler.js +111 -0
- package/src/adapters/shared/server-static-builder.d.ts +70 -0
- package/src/adapters/shared/server-static-builder.js +99 -0
- package/src/build/build-adapter.d.ts +186 -0
- package/src/build/build-adapter.js +168 -0
- package/src/build/build-manifest.d.ts +27 -0
- package/src/build/build-manifest.js +30 -0
- package/src/build/build-types.d.ts +57 -0
- package/src/build/build-types.js +0 -0
- package/src/build/dev-build-coordinator.d.ts +74 -0
- package/src/build/dev-build-coordinator.js +161 -0
- package/src/build/esbuild-build-adapter.d.ts +72 -0
- package/src/build/esbuild-build-adapter.js +422 -0
- package/src/build/runtime-build-executor.d.ts +13 -0
- package/src/build/runtime-build-executor.js +20 -0
- package/src/build/runtime-specifier-alias-plugin.d.ts +15 -0
- package/src/build/runtime-specifier-alias-plugin.js +31 -0
- package/src/config/config-builder.d.ts +238 -0
- package/src/config/config-builder.js +565 -0
- package/src/constants.d.ts +45 -0
- package/src/constants.js +25 -0
- package/src/create-app.d.ts +17 -0
- package/src/create-app.js +66 -0
- package/src/dev/sc-server.d.ts +30 -0
- package/src/dev/sc-server.js +111 -0
- package/src/eco/component-render-context.d.ts +105 -0
- package/src/eco/component-render-context.js +87 -0
- package/src/eco/eco.d.ts +9 -0
- package/src/eco/eco.js +114 -0
- package/src/eco/eco.types.d.ts +178 -0
- package/src/eco/eco.types.js +0 -0
- package/src/eco/eco.utils.d.ts +40 -0
- package/src/eco/eco.utils.js +40 -0
- package/src/eco/global-injector-map.d.ts +16 -0
- package/src/eco/global-injector-map.js +80 -0
- package/src/eco/lazy-injector-map.d.ts +8 -0
- package/src/eco/lazy-injector-map.js +70 -0
- package/src/eco/module-dependencies.d.ts +18 -0
- package/src/eco/module-dependencies.js +49 -0
- package/src/errors/http-error.d.ts +31 -0
- package/src/errors/http-error.js +50 -0
- package/src/errors/index.d.ts +2 -0
- package/src/errors/index.js +4 -0
- package/src/errors/locals-access-error.d.ts +4 -0
- package/src/errors/locals-access-error.js +9 -0
- package/src/global/app-logger.d.ts +2 -0
- package/src/global/app-logger.js +6 -0
- package/src/hmr/client/hmr-runtime.d.ts +5 -0
- package/src/hmr/client/hmr-runtime.js +109 -0
- package/src/hmr/hmr-strategy.d.ts +159 -0
- package/src/hmr/hmr-strategy.js +29 -0
- package/src/hmr/hmr.postcss.test.e2e.d.ts +1 -0
- package/src/hmr/hmr.postcss.test.e2e.js +31 -0
- package/src/hmr/hmr.test.e2e.d.ts +1 -0
- package/src/hmr/hmr.test.e2e.js +43 -0
- package/src/hmr/strategies/default-hmr-strategy.d.ts +43 -0
- package/src/hmr/strategies/default-hmr-strategy.js +34 -0
- package/src/hmr/strategies/js-hmr-strategy.d.ts +139 -0
- package/src/hmr/strategies/js-hmr-strategy.js +178 -0
- package/src/index.browser.d.ts +3 -0
- package/src/index.browser.js +4 -0
- package/src/index.d.ts +5 -0
- package/src/index.js +10 -0
- package/src/integrations/ghtml/ghtml-renderer.d.ts +15 -0
- package/src/integrations/ghtml/ghtml-renderer.js +62 -0
- package/src/integrations/ghtml/ghtml.plugin.d.ts +20 -0
- package/src/integrations/ghtml/ghtml.plugin.js +21 -0
- package/src/internal-types.d.ts +221 -0
- package/src/internal-types.js +0 -0
- package/src/plugins/alias-resolver-plugin.d.ts +2 -0
- package/src/plugins/alias-resolver-plugin.js +53 -0
- package/src/plugins/eco-component-meta-plugin.d.ts +97 -0
- package/src/plugins/eco-component-meta-plugin.js +157 -0
- package/src/plugins/integration-plugin.d.ts +136 -0
- package/src/plugins/integration-plugin.js +133 -0
- package/src/plugins/processor.d.ts +95 -0
- package/src/plugins/processor.js +136 -0
- package/src/plugins/runtime-capability.d.ts +9 -0
- package/src/plugins/runtime-capability.js +0 -0
- package/src/public-types.d.ts +1149 -0
- package/src/public-types.js +0 -0
- package/src/route-renderer/component-graph/component-graph-executor.d.ts +32 -0
- package/src/route-renderer/component-graph/component-graph-executor.js +31 -0
- package/src/route-renderer/component-graph/component-graph.d.ts +42 -0
- package/src/route-renderer/component-graph/component-graph.js +72 -0
- package/src/route-renderer/component-graph/component-marker.d.ts +52 -0
- package/src/route-renderer/component-graph/component-marker.js +46 -0
- package/src/route-renderer/component-graph/component-reference.d.ts +10 -0
- package/src/route-renderer/component-graph/component-reference.js +19 -0
- package/src/route-renderer/component-graph/marker-graph-resolver.d.ts +77 -0
- package/src/route-renderer/component-graph/marker-graph-resolver.js +95 -0
- package/src/route-renderer/orchestration/integration-renderer.d.ts +372 -0
- package/src/route-renderer/orchestration/integration-renderer.js +589 -0
- package/src/route-renderer/orchestration/render-execution.service.d.ts +103 -0
- package/src/route-renderer/orchestration/render-execution.service.js +121 -0
- package/src/route-renderer/orchestration/render-preparation.service.d.ts +121 -0
- package/src/route-renderer/orchestration/render-preparation.service.js +332 -0
- package/src/route-renderer/page-loading/dependency-resolver.d.ts +35 -0
- package/src/route-renderer/page-loading/dependency-resolver.js +442 -0
- package/src/route-renderer/page-loading/page-module-loader.d.ts +87 -0
- package/src/route-renderer/page-loading/page-module-loader.js +124 -0
- package/src/route-renderer/route-renderer.d.ts +61 -0
- package/src/route-renderer/route-renderer.js +87 -0
- package/src/router/client/link-intent.js +34 -0
- package/src/router/client/link-intent.test.browser.d.ts +1 -0
- package/src/router/client/link-intent.test.browser.js +43 -0
- package/src/router/client/navigation-coordinator.d.ts +149 -0
- package/src/router/client/navigation-coordinator.js +215 -0
- package/src/router/server/fs-router-scanner.d.ts +41 -0
- package/src/router/server/fs-router-scanner.js +156 -0
- package/src/router/server/fs-router.d.ts +26 -0
- package/src/router/server/fs-router.js +100 -0
- package/src/services/assets/asset-processing-service/asset-processing.service.d.ts +120 -0
- package/src/services/assets/asset-processing-service/asset-processing.service.js +331 -0
- package/src/services/assets/asset-processing-service/asset.factory.d.ts +17 -0
- package/src/services/assets/asset-processing-service/asset.factory.js +82 -0
- package/src/services/assets/asset-processing-service/assets.types.d.ts +89 -0
- package/src/services/assets/asset-processing-service/assets.types.js +0 -0
- package/src/services/assets/asset-processing-service/browser-runtime-asset.factory.d.ts +55 -0
- package/src/services/assets/asset-processing-service/browser-runtime-asset.factory.js +48 -0
- package/src/services/assets/asset-processing-service/browser-runtime-entry.factory.d.ts +20 -0
- package/src/services/assets/asset-processing-service/browser-runtime-entry.factory.js +41 -0
- package/src/services/assets/asset-processing-service/index.d.ts +5 -0
- package/src/services/assets/asset-processing-service/index.js +5 -0
- package/src/services/assets/asset-processing-service/processor.interface.d.ts +22 -0
- package/src/services/assets/asset-processing-service/processor.interface.js +6 -0
- package/src/services/assets/asset-processing-service/processor.registry.d.ts +8 -0
- package/src/services/assets/asset-processing-service/processor.registry.js +15 -0
- package/src/services/assets/asset-processing-service/processors/base/base-processor.d.ts +24 -0
- package/src/services/assets/asset-processing-service/processors/base/base-processor.js +64 -0
- package/src/services/assets/asset-processing-service/processors/base/base-script-processor.d.ts +17 -0
- package/src/services/assets/asset-processing-service/processors/base/base-script-processor.js +72 -0
- package/src/services/assets/asset-processing-service/processors/index.d.ts +5 -0
- package/src/services/assets/asset-processing-service/processors/index.js +5 -0
- package/src/services/assets/asset-processing-service/processors/script/content-script.processor.d.ts +5 -0
- package/src/services/assets/asset-processing-service/processors/script/content-script.processor.js +57 -0
- package/src/services/assets/asset-processing-service/processors/script/file-script.processor.d.ts +8 -0
- package/src/services/assets/asset-processing-service/processors/script/file-script.processor.js +76 -0
- package/src/services/assets/asset-processing-service/processors/script/node-module-script.processor.d.ts +7 -0
- package/src/services/assets/asset-processing-service/processors/script/node-module-script.processor.js +75 -0
- package/src/services/assets/asset-processing-service/processors/stylesheet/content-stylesheet.processor.d.ts +5 -0
- package/src/services/assets/asset-processing-service/processors/stylesheet/content-stylesheet.processor.js +25 -0
- package/src/services/assets/asset-processing-service/processors/stylesheet/file-stylesheet.processor.d.ts +9 -0
- package/src/services/assets/asset-processing-service/processors/stylesheet/file-stylesheet.processor.js +66 -0
- package/src/services/assets/browser-bundle.service.d.ts +32 -0
- package/src/services/assets/browser-bundle.service.js +33 -0
- package/src/services/cache/cache.types.d.ts +107 -0
- package/src/services/cache/cache.types.js +0 -0
- package/src/services/cache/index.d.ts +7 -0
- package/src/services/cache/index.js +7 -0
- package/src/services/cache/memory-cache-store.d.ts +42 -0
- package/src/services/cache/memory-cache-store.js +98 -0
- package/src/services/cache/page-cache-service.d.ts +70 -0
- package/src/services/cache/page-cache-service.js +152 -0
- package/src/services/cache/page-request-cache-coordinator.service.d.ts +75 -0
- package/src/services/cache/page-request-cache-coordinator.service.js +109 -0
- package/src/services/html/html-rewriter-provider.service.d.ts +37 -0
- package/src/services/html/html-rewriter-provider.service.js +65 -0
- package/src/services/html/html-transformer.service.d.ts +77 -0
- package/src/services/html/html-transformer.service.js +221 -0
- package/src/services/invalidation/development-invalidation.service.d.ts +74 -0
- package/src/services/invalidation/development-invalidation.service.js +189 -0
- package/src/services/module-loading/app-server-module-transpiler.service.d.ts +16 -0
- package/src/services/module-loading/app-server-module-transpiler.service.js +34 -0
- package/src/services/module-loading/page-module-import.service.d.ts +71 -0
- package/src/services/module-loading/page-module-import.service.js +132 -0
- package/src/services/module-loading/server-loader.service.d.ts +96 -0
- package/src/services/module-loading/server-loader.service.js +32 -0
- package/src/services/module-loading/server-module-transpiler.service.d.ts +69 -0
- package/src/services/module-loading/server-module-transpiler.service.js +61 -0
- package/src/services/runtime-manifest/node-runtime-manifest.service.d.ts +35 -0
- package/src/services/runtime-manifest/node-runtime-manifest.service.js +60 -0
- package/src/services/runtime-state/dev-graph.service.d.ts +118 -0
- package/src/services/runtime-state/dev-graph.service.js +162 -0
- package/src/services/runtime-state/entrypoint-dependency-graph.service.d.ts +41 -0
- package/src/services/runtime-state/entrypoint-dependency-graph.service.js +85 -0
- package/src/services/runtime-state/runtime-specifier-registry.service.d.ts +69 -0
- package/src/services/runtime-state/runtime-specifier-registry.service.js +37 -0
- package/src/services/runtime-state/server-invalidation-state.service.d.ts +26 -0
- package/src/services/runtime-state/server-invalidation-state.service.js +35 -0
- package/src/services/validation/schema-validation-service.d.ts +122 -0
- package/src/services/validation/schema-validation-service.js +101 -0
- package/src/services/validation/standard-schema.types.d.ts +65 -0
- package/src/services/validation/standard-schema.types.js +0 -0
- package/src/static-site-generator/static-site-generator.d.ts +109 -0
- package/src/static-site-generator/static-site-generator.js +353 -0
- package/src/utils/css.d.ts +1 -0
- package/src/utils/css.js +7 -0
- package/src/utils/deep-merge.d.ts +14 -0
- package/src/utils/deep-merge.js +32 -0
- package/src/utils/hash.d.ts +1 -0
- package/src/utils/hash.js +7 -0
- package/src/utils/html.d.ts +1 -0
- package/src/utils/html.js +4 -0
- package/src/utils/invariant.d.ts +5 -0
- package/src/utils/invariant.js +11 -0
- package/src/utils/locals-utils.d.ts +15 -0
- package/src/utils/locals-utils.js +24 -0
- package/src/utils/parse-cli-args.d.ts +24 -0
- package/src/utils/parse-cli-args.js +47 -0
- package/src/utils/path-utils.module.d.ts +5 -0
- package/src/utils/path-utils.module.js +14 -0
- package/src/utils/resolve-work-dir.d.ts +11 -0
- package/src/utils/resolve-work-dir.js +31 -0
- package/src/utils/runtime.d.ts +11 -0
- package/src/utils/runtime.js +40 -0
- package/src/utils/server-utils.module.d.ts +19 -0
- package/src/utils/server-utils.module.js +56 -0
- package/src/watchers/project-watcher.d.ts +136 -0
- package/src/watchers/project-watcher.js +281 -0
- package/src/watchers/project-watcher.test-helpers.d.ts +4 -0
- package/src/watchers/project-watcher.test-helpers.js +52 -0
- package/src/adapters/bun/hmr-manager.test.ts +0 -267
- package/src/adapters/node/bootstrap-dependency-resolver.test.ts +0 -282
- package/src/adapters/node/node-client-bridge.test.ts +0 -198
- package/src/adapters/node/node-hmr-manager.test.ts +0 -322
- package/src/adapters/node/runtime-adapter.test.ts +0 -868
- package/src/adapters/node/static-content-server.test.ts +0 -60
- package/src/adapters/shared/api-response.test.ts +0 -97
- package/src/adapters/shared/explicit-static-route-matcher.test.ts +0 -381
- package/src/adapters/shared/file-route-middleware-pipeline.test.ts +0 -90
- package/src/adapters/shared/fs-server-response-factory.test.ts +0 -187
- package/src/adapters/shared/fs-server-response-matcher.test.ts +0 -286
- package/src/adapters/shared/hmr-manager.contract.test.ts +0 -196
- package/src/adapters/shared/hmr-manager.dispatch.test.ts +0 -220
- package/src/adapters/shared/render-context.test.ts +0 -146
- package/src/adapters/shared/server-adapter.test.ts +0 -77
- package/src/adapters/shared/server-route-handler.test.ts +0 -110
- package/src/adapters/shared/server-static-builder.test.ts +0 -316
- package/src/build/build-adapter-serialization.test.ts +0 -268
- package/src/build/build-adapter.test.ts +0 -815
- package/src/build/runtime-specifier-alias-plugin.test.ts +0 -43
- package/src/config/config-builder.test.ts +0 -410
- package/src/eco/eco.test.ts +0 -678
- package/src/eco/eco.utils.test.ts +0 -124
- package/src/eco/global-injector-map.test.ts +0 -42
- package/src/eco/lazy-injector-map.test.ts +0 -66
- package/src/eco/module-dependencies.test.ts +0 -30
- package/src/errors/http-error.test.ts +0 -134
- package/src/global/utils.test.ts +0 -12
- package/src/hmr/client/__screenshots__/hmr-runtime.test.browser.ts/HMR-Runtime-HMR-Server-Integration-should-have-HMR-script-injected-in-page-1.png +0 -0
- package/src/hmr/client/__screenshots__/hmr-runtime.test.browser.ts/HMR-Runtime-HMR-Server-Integration-should-load-fixture-app-page-1.png +0 -0
- package/src/hmr/client/__screenshots__/hmr-runtime.test.browser.ts/HMR-Runtime-WebSocket-Connection-should-connect-to-correct-HMR-endpoint-1.png +0 -0
- package/src/hmr/hmr-strategy.test.ts +0 -124
- package/src/hmr/strategies/js-hmr-strategy.test.ts +0 -335
- package/src/integrations/ghtml/ghtml-renderer.test.ts +0 -63
- package/src/plugins/alias-resolver-plugin.test.ts +0 -41
- package/src/plugins/eco-component-meta-plugin.test.ts +0 -380
- package/src/plugins/integration-plugin.test.ts +0 -111
- package/src/plugins/processor.test.ts +0 -148
- package/src/route-renderer/component-graph/component-graph-executor.test.ts +0 -41
- package/src/route-renderer/component-graph/component-graph.test.ts +0 -63
- package/src/route-renderer/component-graph/component-marker.test.ts +0 -73
- package/src/route-renderer/component-graph/marker-graph-resolver.test.ts +0 -135
- package/src/route-renderer/orchestration/integration-renderer.test.ts +0 -936
- package/src/route-renderer/orchestration/render-execution.service.test.ts +0 -97
- package/src/route-renderer/orchestration/render-preparation.service.test.ts +0 -235
- package/src/route-renderer/page-loading/dependency-resolver.test.ts +0 -345
- package/src/route-renderer/page-loading/page-module-loader.test.ts +0 -96
- package/src/router/client/navigation-coordinator.test.ts +0 -237
- package/src/router/server/fs-router-scanner.test.ts +0 -83
- package/src/router/server/fs-router.test.ts +0 -214
- package/src/services/assets/asset-processing-service/asset-processing.service.test.ts +0 -385
- package/src/services/assets/asset-processing-service/asset.factory.test.ts +0 -63
- package/src/services/assets/asset-processing-service/browser-runtime-asset.factory.test.ts +0 -72
- package/src/services/assets/asset-processing-service/browser-runtime-entry.factory.test.ts +0 -67
- package/src/services/assets/asset-processing-service/processors/base/base-processor.test.ts +0 -59
- package/src/services/assets/asset-processing-service/processors/script/file-script.processor.test.ts +0 -286
- package/src/services/assets/asset-processing-service/processors/script/node-module-script.processor.test.ts +0 -227
- package/src/services/assets/asset-processing-service/processors/stylesheet/content-stylesheet.processor.test.ts +0 -199
- package/src/services/assets/browser-bundle.service.test.ts +0 -36
- package/src/services/cache/memory-cache-store.test.ts +0 -225
- package/src/services/cache/page-cache-service.test.ts +0 -175
- package/src/services/cache/page-request-cache-coordinator.service.test.ts +0 -79
- package/src/services/html/html-rewriter-provider.service.test.ts +0 -183
- package/src/services/html/html-transformer.service.test.ts +0 -378
- package/src/services/invalidation/development-invalidation.service.test.ts +0 -77
- package/src/services/module-loading/page-module-import.service.test.ts +0 -253
- package/src/services/module-loading/server-loader.service.test.ts +0 -161
- package/src/services/module-loading/server-module-transpiler.service.test.ts +0 -115
- package/src/services/runtime-manifest/node-runtime-manifest.service.test.ts +0 -95
- package/src/services/validation/schema-validation-service.test.ts +0 -223
- package/src/static-site-generator/static-site-generator.test.ts +0 -307
- package/src/utils/deep-merge.test.ts +0 -114
- package/src/utils/invariant.test.ts +0 -22
- package/src/utils/path-utils.test.ts +0 -15
- package/src/utils/server-utils.test.ts +0 -38
- package/src/watchers/project-watcher.integration.test.ts +0 -337
- package/src/watchers/project-watcher.test.ts +0 -678
|
@@ -1,815 +0,0 @@
|
|
|
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
|
-
defaultBuildAdapter,
|
|
11
|
-
EsbuildBuildAdapter,
|
|
12
|
-
getAppBuildAdapter,
|
|
13
|
-
getAppBuildManifest,
|
|
14
|
-
getAppBrowserBuildPlugins,
|
|
15
|
-
getAppBuildExecutor,
|
|
16
|
-
getAppServerBuildPlugins,
|
|
17
|
-
setAppBuildAdapter,
|
|
18
|
-
setAppBuildManifest,
|
|
19
|
-
setupAppRuntimePlugins,
|
|
20
|
-
updateAppBuildManifest,
|
|
21
|
-
} from './build-adapter.ts';
|
|
22
|
-
import { createAppBuildManifest } from './build-manifest.ts';
|
|
23
|
-
import type { EcoBuildPluginBuilder } from './build-types.ts';
|
|
24
|
-
import { createAppBuildExecutor } from './dev-build-coordinator.ts';
|
|
25
|
-
|
|
26
|
-
const tempRoots: string[] = [];
|
|
27
|
-
|
|
28
|
-
function createTempRoot(prefix: string): string {
|
|
29
|
-
const root = fs.mkdtempSync(path.join(os.tmpdir(), `${prefix}-`));
|
|
30
|
-
tempRoots.push(root);
|
|
31
|
-
return root;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
function cleanupTempRoots(): void {
|
|
35
|
-
for (const root of tempRoots.splice(0)) {
|
|
36
|
-
fs.rmSync(root, { recursive: true, force: true });
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function clearNodeCssBridge(): void {
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
test('defaultBuildAdapter uses EsbuildBuildAdapter on Node runtime', () => {
|
|
45
|
-
assert.ok(defaultBuildAdapter instanceof EsbuildBuildAdapter);
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
test('build helper accepts an explicit executor across package and relative build-adapter imports', async () => {
|
|
49
|
-
const packageBuildAdapter = await import('@ecopages/core/build/build-adapter');
|
|
50
|
-
const executor = {
|
|
51
|
-
build: vi.fn(async () => ({
|
|
52
|
-
success: true,
|
|
53
|
-
logs: [],
|
|
54
|
-
outputs: [{ path: '/tmp/shared.js' }],
|
|
55
|
-
})),
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
const result = await packageBuildAdapter.build(
|
|
59
|
-
{
|
|
60
|
-
entrypoints: ['/tmp/shared.ts'],
|
|
61
|
-
root: '/tmp',
|
|
62
|
-
outdir: '/tmp/out',
|
|
63
|
-
target: 'node',
|
|
64
|
-
format: 'esm',
|
|
65
|
-
sourcemap: 'none',
|
|
66
|
-
splitting: false,
|
|
67
|
-
minify: false,
|
|
68
|
-
},
|
|
69
|
-
executor,
|
|
70
|
-
);
|
|
71
|
-
|
|
72
|
-
assert.equal(result.success, true);
|
|
73
|
-
assert.deepEqual(result.outputs, [{ path: '/tmp/shared.js' }]);
|
|
74
|
-
assert.equal(executor.build.mock.calls.length, 1);
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
test('build helper uses the shared adapter when no executor is provided', async () => {
|
|
78
|
-
const executor = {
|
|
79
|
-
build: vi.fn(async () => ({
|
|
80
|
-
success: true,
|
|
81
|
-
logs: [],
|
|
82
|
-
outputs: [{ path: '/tmp/direct.js' }],
|
|
83
|
-
})),
|
|
84
|
-
};
|
|
85
|
-
const adapterSpy = vi.spyOn(defaultBuildAdapter, 'build').mockImplementation(executor.build);
|
|
86
|
-
|
|
87
|
-
const result = await build({
|
|
88
|
-
entrypoints: ['/tmp/direct.ts'],
|
|
89
|
-
root: '/tmp',
|
|
90
|
-
outdir: '/tmp/out',
|
|
91
|
-
target: 'node',
|
|
92
|
-
format: 'esm',
|
|
93
|
-
sourcemap: 'none',
|
|
94
|
-
splitting: false,
|
|
95
|
-
minify: false,
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
assert.equal(result.success, true);
|
|
99
|
-
assert.deepEqual(result.outputs, [{ path: '/tmp/direct.js' }]);
|
|
100
|
-
assert.equal(adapterSpy.mock.calls.length, 1);
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
test('getAppBuildExecutor falls back to the app-owned adapter before the shared default adapter', async () => {
|
|
104
|
-
const appConfig = {
|
|
105
|
-
runtime: {},
|
|
106
|
-
loaders: new Map(),
|
|
107
|
-
} as any;
|
|
108
|
-
const appAdapter = new EsbuildBuildAdapter();
|
|
109
|
-
|
|
110
|
-
setAppBuildAdapter(appConfig, appAdapter);
|
|
111
|
-
|
|
112
|
-
assert.equal(getAppBuildAdapter(appConfig), appAdapter);
|
|
113
|
-
assert.equal(getAppBuildExecutor(appConfig), appAdapter);
|
|
114
|
-
assert.notEqual(getAppBuildAdapter(appConfig), defaultBuildAdapter);
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
test('createAppBuildExecutor injects app-owned plugins into builds', async () => {
|
|
118
|
-
const plugin = {
|
|
119
|
-
name: 'app-owned-plugin',
|
|
120
|
-
setup() {},
|
|
121
|
-
};
|
|
122
|
-
const adapter = {
|
|
123
|
-
build: vi.fn(async (options) => ({
|
|
124
|
-
success: true,
|
|
125
|
-
logs: [],
|
|
126
|
-
outputs: [{ path: options.outdir ? `${options.outdir}/entry.js` : '/tmp/entry.js' }],
|
|
127
|
-
})),
|
|
128
|
-
resolve: vi.fn(),
|
|
129
|
-
registerPlugin: vi.fn(),
|
|
130
|
-
getTranspileOptions: vi.fn(),
|
|
131
|
-
};
|
|
132
|
-
const appConfig = {
|
|
133
|
-
loaders: new Map(),
|
|
134
|
-
runtime: {},
|
|
135
|
-
} as any;
|
|
136
|
-
|
|
137
|
-
setAppBuildManifest(
|
|
138
|
-
appConfig,
|
|
139
|
-
createAppBuildManifest({
|
|
140
|
-
runtimePlugins: [plugin],
|
|
141
|
-
}),
|
|
142
|
-
);
|
|
143
|
-
const executor = createAppBuildExecutor({
|
|
144
|
-
development: false,
|
|
145
|
-
adapter,
|
|
146
|
-
getPlugins: () => getAppServerBuildPlugins(appConfig),
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
await executor.build({
|
|
150
|
-
entrypoints: ['/tmp/entry.ts'],
|
|
151
|
-
root: '/tmp',
|
|
152
|
-
outdir: '/tmp/out',
|
|
153
|
-
target: 'node',
|
|
154
|
-
format: 'esm',
|
|
155
|
-
sourcemap: 'none',
|
|
156
|
-
splitting: false,
|
|
157
|
-
minify: false,
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
assert.equal(adapter.build.mock.calls.length, 1);
|
|
161
|
-
assert.deepEqual(adapter.build.mock.calls[0][0].plugins, [plugin]);
|
|
162
|
-
assert.equal(adapter.registerPlugin.mock.calls.length, 0);
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
test('build manifest separates server and browser plugin sets', () => {
|
|
166
|
-
const loaderPlugin = { name: 'loader-plugin', setup() {} };
|
|
167
|
-
const runtimePlugin = { name: 'runtime-plugin', setup() {} };
|
|
168
|
-
const browserPlugin = { name: 'browser-plugin', setup() {} };
|
|
169
|
-
const appConfig = {
|
|
170
|
-
loaders: new Map(),
|
|
171
|
-
runtime: {},
|
|
172
|
-
} as any;
|
|
173
|
-
|
|
174
|
-
setAppBuildManifest(
|
|
175
|
-
appConfig,
|
|
176
|
-
createAppBuildManifest({
|
|
177
|
-
loaderPlugins: [loaderPlugin],
|
|
178
|
-
runtimePlugins: [runtimePlugin],
|
|
179
|
-
browserBundlePlugins: [browserPlugin],
|
|
180
|
-
}),
|
|
181
|
-
);
|
|
182
|
-
|
|
183
|
-
assert.deepEqual(getAppBuildManifest(appConfig).loaderPlugins, [loaderPlugin]);
|
|
184
|
-
assert.deepEqual(getAppServerBuildPlugins(appConfig), [loaderPlugin, runtimePlugin]);
|
|
185
|
-
assert.deepEqual(getAppBrowserBuildPlugins(appConfig), [loaderPlugin, runtimePlugin, browserPlugin]);
|
|
186
|
-
});
|
|
187
|
-
|
|
188
|
-
test('createConfiguredAppBuildManifest defaults loader plugins from app config', () => {
|
|
189
|
-
const loaderPlugin = { name: 'loader-plugin', setup() {} };
|
|
190
|
-
const runtimePlugin = { name: 'runtime-plugin', setup() {} };
|
|
191
|
-
const appConfig = {
|
|
192
|
-
loaders: new Map([[loaderPlugin.name, loaderPlugin]]),
|
|
193
|
-
runtime: {},
|
|
194
|
-
} as any;
|
|
195
|
-
|
|
196
|
-
const manifest = createConfiguredAppBuildManifest(appConfig, {
|
|
197
|
-
runtimePlugins: [runtimePlugin],
|
|
198
|
-
});
|
|
199
|
-
|
|
200
|
-
assert.deepEqual(manifest.loaderPlugins, [loaderPlugin]);
|
|
201
|
-
assert.deepEqual(manifest.runtimePlugins, [runtimePlugin]);
|
|
202
|
-
assert.deepEqual(manifest.browserBundlePlugins, []);
|
|
203
|
-
});
|
|
204
|
-
|
|
205
|
-
test('updateAppBuildManifest rebuilds the app manifest from config-owned loaders and explicit runtime plugins', () => {
|
|
206
|
-
const loaderPlugin = { name: 'loader-plugin', setup() {} };
|
|
207
|
-
const runtimePlugin = { name: 'runtime-plugin', setup() {} };
|
|
208
|
-
const browserPlugin = { name: 'browser-plugin', setup() {} };
|
|
209
|
-
const appConfig = {
|
|
210
|
-
loaders: new Map([[loaderPlugin.name, loaderPlugin]]),
|
|
211
|
-
runtime: {},
|
|
212
|
-
} as any;
|
|
213
|
-
|
|
214
|
-
updateAppBuildManifest(appConfig, {
|
|
215
|
-
runtimePlugins: [runtimePlugin],
|
|
216
|
-
browserBundlePlugins: [browserPlugin],
|
|
217
|
-
});
|
|
218
|
-
|
|
219
|
-
assert.deepEqual(getAppBuildManifest(appConfig).loaderPlugins, [loaderPlugin]);
|
|
220
|
-
assert.deepEqual(getAppServerBuildPlugins(appConfig), [loaderPlugin, runtimePlugin]);
|
|
221
|
-
assert.deepEqual(getAppBrowserBuildPlugins(appConfig), [loaderPlugin, runtimePlugin, browserPlugin]);
|
|
222
|
-
});
|
|
223
|
-
|
|
224
|
-
test('collectConfiguredAppBuildManifestContributions gathers processor and integration contributions during config build', async () => {
|
|
225
|
-
const contributionOrder: string[] = [];
|
|
226
|
-
const processorRuntimePlugin = { name: 'processor-runtime-plugin', setup() {} };
|
|
227
|
-
const processorBrowserPlugin = { name: 'processor-browser-plugin', setup() {} };
|
|
228
|
-
const integrationRuntimePlugin = { name: 'integration-runtime-plugin', setup() {} };
|
|
229
|
-
const processor = {
|
|
230
|
-
plugins: [processorRuntimePlugin],
|
|
231
|
-
buildPlugins: [processorBrowserPlugin],
|
|
232
|
-
prepareBuildContributions: vi.fn(async () => {
|
|
233
|
-
contributionOrder.push('processor-prepare');
|
|
234
|
-
}),
|
|
235
|
-
};
|
|
236
|
-
const integration = {
|
|
237
|
-
plugins: [integrationRuntimePlugin],
|
|
238
|
-
setConfig: vi.fn(() => contributionOrder.push('integration-config')),
|
|
239
|
-
prepareBuildContributions: vi.fn(async () => {
|
|
240
|
-
contributionOrder.push('integration-prepare');
|
|
241
|
-
}),
|
|
242
|
-
};
|
|
243
|
-
|
|
244
|
-
const contributions = await collectConfiguredAppBuildManifestContributions({
|
|
245
|
-
processors: new Map([['processor', processor]]),
|
|
246
|
-
integrations: [integration],
|
|
247
|
-
} as any);
|
|
248
|
-
|
|
249
|
-
assert.deepEqual(contributionOrder, ['processor-prepare', 'integration-config', 'integration-prepare']);
|
|
250
|
-
assert.deepEqual(contributions.runtimePlugins, [processorRuntimePlugin, integrationRuntimePlugin]);
|
|
251
|
-
assert.deepEqual(contributions.browserBundlePlugins, [processorBrowserPlugin]);
|
|
252
|
-
});
|
|
253
|
-
|
|
254
|
-
test('setupAppRuntimePlugins runs runtime setup without recomposing manifest contributions', async () => {
|
|
255
|
-
const contributionOrder: string[] = [];
|
|
256
|
-
const processorRuntimePlugin = { name: 'processor-runtime-plugin', setup() {} };
|
|
257
|
-
const integrationRuntimePlugin = { name: 'integration-runtime-plugin', setup() {} };
|
|
258
|
-
const processor = {
|
|
259
|
-
plugins: [processorRuntimePlugin],
|
|
260
|
-
setup: vi.fn(async () => {
|
|
261
|
-
contributionOrder.push('processor-setup');
|
|
262
|
-
}),
|
|
263
|
-
};
|
|
264
|
-
const integration = {
|
|
265
|
-
plugins: [integrationRuntimePlugin],
|
|
266
|
-
setConfig: vi.fn(() => contributionOrder.push('integration-config')),
|
|
267
|
-
setRuntimeOrigin: vi.fn(() => contributionOrder.push('integration-origin')),
|
|
268
|
-
setHmrManager: vi.fn(() => contributionOrder.push('integration-hmr')),
|
|
269
|
-
setup: vi.fn(async () => {
|
|
270
|
-
contributionOrder.push('integration-setup');
|
|
271
|
-
}),
|
|
272
|
-
};
|
|
273
|
-
const observedRuntimePlugins: string[] = [];
|
|
274
|
-
|
|
275
|
-
await setupAppRuntimePlugins({
|
|
276
|
-
appConfig: {
|
|
277
|
-
processors: new Map([['processor', processor]]),
|
|
278
|
-
integrations: [integration],
|
|
279
|
-
} as any,
|
|
280
|
-
runtimeOrigin: 'http://localhost:3000',
|
|
281
|
-
hmrManager: {} as any,
|
|
282
|
-
onRuntimePlugin: (plugin) => observedRuntimePlugins.push(plugin.name),
|
|
283
|
-
});
|
|
284
|
-
|
|
285
|
-
assert.deepEqual(contributionOrder, [
|
|
286
|
-
'processor-setup',
|
|
287
|
-
'integration-config',
|
|
288
|
-
'integration-origin',
|
|
289
|
-
'integration-hmr',
|
|
290
|
-
'integration-setup',
|
|
291
|
-
]);
|
|
292
|
-
assert.deepEqual(observedRuntimePlugins, ['processor-runtime-plugin', 'integration-runtime-plugin']);
|
|
293
|
-
});
|
|
294
|
-
|
|
295
|
-
test('EsbuildBuildAdapter supports module virtual modules', async () => {
|
|
296
|
-
try {
|
|
297
|
-
const root = createTempRoot('ecopages-esbuild-virtual-module');
|
|
298
|
-
const srcDir = path.join(root, 'src');
|
|
299
|
-
const outDir = path.join(root, 'dist');
|
|
300
|
-
fs.mkdirSync(srcDir, { recursive: true });
|
|
301
|
-
|
|
302
|
-
const entryPath = path.join(srcDir, 'entry.ts');
|
|
303
|
-
fs.writeFileSync(entryPath, "import answer from 'virtual:answer';\nexport const value = answer;");
|
|
304
|
-
|
|
305
|
-
const adapter = new EsbuildBuildAdapter();
|
|
306
|
-
|
|
307
|
-
const result = await adapter.build({
|
|
308
|
-
entrypoints: [entryPath],
|
|
309
|
-
root,
|
|
310
|
-
outdir: outDir,
|
|
311
|
-
target: 'node',
|
|
312
|
-
format: 'esm',
|
|
313
|
-
sourcemap: 'none',
|
|
314
|
-
splitting: false,
|
|
315
|
-
minify: false,
|
|
316
|
-
plugins: [
|
|
317
|
-
{
|
|
318
|
-
name: 'virtual-module-test',
|
|
319
|
-
setup(build: EcoBuildPluginBuilder) {
|
|
320
|
-
build.module('virtual:answer', () => ({
|
|
321
|
-
loader: 'object',
|
|
322
|
-
exports: {
|
|
323
|
-
default: 42,
|
|
324
|
-
},
|
|
325
|
-
}));
|
|
326
|
-
},
|
|
327
|
-
},
|
|
328
|
-
],
|
|
329
|
-
});
|
|
330
|
-
|
|
331
|
-
assert.equal(result.success, true);
|
|
332
|
-
|
|
333
|
-
const outputPath = result.outputs.find((output) => output.path.endsWith('entry.js'))?.path;
|
|
334
|
-
assert.ok(outputPath);
|
|
335
|
-
|
|
336
|
-
const outputSource = fs.readFileSync(outputPath, 'utf-8');
|
|
337
|
-
assert.match(outputSource, /42/);
|
|
338
|
-
} finally {
|
|
339
|
-
cleanupTempRoots();
|
|
340
|
-
}
|
|
341
|
-
});
|
|
342
|
-
|
|
343
|
-
test('EsbuildBuildAdapter applies build plugin CSS transforms to imported CSS strings', async () => {
|
|
344
|
-
try {
|
|
345
|
-
const root = createTempRoot('ecopages-esbuild-css');
|
|
346
|
-
const srcDir = path.join(root, 'src');
|
|
347
|
-
const outDir = path.join(root, 'dist');
|
|
348
|
-
fs.mkdirSync(srcDir, { recursive: true });
|
|
349
|
-
|
|
350
|
-
const cssPath = path.join(srcDir, 'styles.css');
|
|
351
|
-
const entryPath = path.join(srcDir, 'entry.ts');
|
|
352
|
-
|
|
353
|
-
fs.writeFileSync(cssPath, '.counter { color: red; }');
|
|
354
|
-
fs.writeFileSync(entryPath, "import styles from './styles.css';\nexport const cssText = styles;");
|
|
355
|
-
|
|
356
|
-
const adapter = new EsbuildBuildAdapter();
|
|
357
|
-
|
|
358
|
-
const result = await adapter.build({
|
|
359
|
-
entrypoints: [entryPath],
|
|
360
|
-
root,
|
|
361
|
-
outdir: outDir,
|
|
362
|
-
target: 'node',
|
|
363
|
-
format: 'esm',
|
|
364
|
-
sourcemap: 'none',
|
|
365
|
-
splitting: false,
|
|
366
|
-
minify: false,
|
|
367
|
-
plugins: [
|
|
368
|
-
{
|
|
369
|
-
name: 'css-bridge-replacement-test',
|
|
370
|
-
setup(build) {
|
|
371
|
-
build.onLoad({ filter: /\.css$/ }, async (args) => {
|
|
372
|
-
const contents = fs.readFileSync(args.path, 'utf-8');
|
|
373
|
-
return {
|
|
374
|
-
loader: 'object',
|
|
375
|
-
exports: {
|
|
376
|
-
default: `/* transformed */\n${contents}`,
|
|
377
|
-
},
|
|
378
|
-
};
|
|
379
|
-
});
|
|
380
|
-
},
|
|
381
|
-
},
|
|
382
|
-
],
|
|
383
|
-
});
|
|
384
|
-
|
|
385
|
-
assert.equal(result.success, true);
|
|
386
|
-
|
|
387
|
-
const outputPath = result.outputs.find((output) => output.path.endsWith('entry.js'))?.path;
|
|
388
|
-
assert.ok(outputPath);
|
|
389
|
-
|
|
390
|
-
const outputSource = fs.readFileSync(outputPath, 'utf-8');
|
|
391
|
-
assert.match(outputSource, /\/\* transformed \*\//);
|
|
392
|
-
assert.match(outputSource, /\.counter \{ color: red; \}/);
|
|
393
|
-
} finally {
|
|
394
|
-
cleanupTempRoots();
|
|
395
|
-
clearNodeCssBridge();
|
|
396
|
-
}
|
|
397
|
-
});
|
|
398
|
-
|
|
399
|
-
test('EsbuildBuildAdapter resolves tsconfig path aliases', async () => {
|
|
400
|
-
try {
|
|
401
|
-
const root = createTempRoot('ecopages-esbuild-tsconfig-paths');
|
|
402
|
-
const srcDir = path.join(root, 'src');
|
|
403
|
-
const outDir = path.join(root, 'dist');
|
|
404
|
-
const libDir = path.join(srcDir, 'lib');
|
|
405
|
-
fs.mkdirSync(libDir, { recursive: true });
|
|
406
|
-
|
|
407
|
-
const tsconfigPath = path.join(root, 'tsconfig.json');
|
|
408
|
-
fs.writeFileSync(
|
|
409
|
-
tsconfigPath,
|
|
410
|
-
JSON.stringify({
|
|
411
|
-
compilerOptions: {
|
|
412
|
-
baseUrl: '.',
|
|
413
|
-
paths: {
|
|
414
|
-
'@/*': ['src/*'],
|
|
415
|
-
},
|
|
416
|
-
},
|
|
417
|
-
}),
|
|
418
|
-
);
|
|
419
|
-
|
|
420
|
-
const utilPath = path.join(libDir, 'count.ts');
|
|
421
|
-
fs.writeFileSync(utilPath, 'export const count = 7;');
|
|
422
|
-
|
|
423
|
-
const entryPath = path.join(srcDir, 'entry.ts');
|
|
424
|
-
fs.writeFileSync(entryPath, "import { count } from '@/lib/count';\nexport const value = count;");
|
|
425
|
-
|
|
426
|
-
const adapter = new EsbuildBuildAdapter();
|
|
427
|
-
const result = await adapter.build({
|
|
428
|
-
entrypoints: [entryPath],
|
|
429
|
-
root,
|
|
430
|
-
outdir: outDir,
|
|
431
|
-
target: 'node',
|
|
432
|
-
format: 'esm',
|
|
433
|
-
sourcemap: 'none',
|
|
434
|
-
splitting: false,
|
|
435
|
-
minify: false,
|
|
436
|
-
});
|
|
437
|
-
|
|
438
|
-
assert.equal(result.success, true);
|
|
439
|
-
|
|
440
|
-
const outputPath = result.outputs.find((output) => output.path.endsWith('entry.js'))?.path;
|
|
441
|
-
assert.ok(outputPath);
|
|
442
|
-
|
|
443
|
-
const outputSource = fs.readFileSync(outputPath, 'utf-8');
|
|
444
|
-
assert.match(outputSource, /7/);
|
|
445
|
-
} finally {
|
|
446
|
-
cleanupTempRoots();
|
|
447
|
-
clearNodeCssBridge();
|
|
448
|
-
}
|
|
449
|
-
});
|
|
450
|
-
|
|
451
|
-
test('EsbuildBuildAdapter compiles decorated classes without legacy mode', async () => {
|
|
452
|
-
try {
|
|
453
|
-
const root = createTempRoot('ecopages-esbuild-decorated-declare');
|
|
454
|
-
const srcDir = path.join(root, 'src');
|
|
455
|
-
const outDir = path.join(root, 'dist');
|
|
456
|
-
fs.mkdirSync(srcDir, { recursive: true });
|
|
457
|
-
|
|
458
|
-
const entryPath = path.join(srcDir, 'entry.ts');
|
|
459
|
-
fs.writeFileSync(
|
|
460
|
-
entryPath,
|
|
461
|
-
[
|
|
462
|
-
'function sealed<T extends new (...args: never[]) => object>(value: T) {',
|
|
463
|
-
'\treturn value;',
|
|
464
|
-
'}',
|
|
465
|
-
'@sealed',
|
|
466
|
-
'class Counter {}',
|
|
467
|
-
'export const ready = typeof Counter === "function";',
|
|
468
|
-
].join('\n'),
|
|
469
|
-
);
|
|
470
|
-
|
|
471
|
-
const adapter = new EsbuildBuildAdapter();
|
|
472
|
-
const result = await adapter.build({
|
|
473
|
-
entrypoints: [entryPath],
|
|
474
|
-
root,
|
|
475
|
-
outdir: outDir,
|
|
476
|
-
target: 'node',
|
|
477
|
-
format: 'esm',
|
|
478
|
-
sourcemap: 'none',
|
|
479
|
-
splitting: false,
|
|
480
|
-
minify: false,
|
|
481
|
-
});
|
|
482
|
-
|
|
483
|
-
assert.equal(result.success, true);
|
|
484
|
-
|
|
485
|
-
const outputPath = result.outputs.find((output) => output.path.endsWith('entry.js'))?.path;
|
|
486
|
-
assert.ok(outputPath);
|
|
487
|
-
} finally {
|
|
488
|
-
cleanupTempRoots();
|
|
489
|
-
clearNodeCssBridge();
|
|
490
|
-
}
|
|
491
|
-
});
|
|
492
|
-
|
|
493
|
-
test('EsbuildBuildAdapter compiles decorated accessor fields', async () => {
|
|
494
|
-
try {
|
|
495
|
-
const root = createTempRoot('ecopages-esbuild-decorated-accessor');
|
|
496
|
-
const srcDir = path.join(root, 'src');
|
|
497
|
-
const outDir = path.join(root, 'dist');
|
|
498
|
-
fs.mkdirSync(srcDir, { recursive: true });
|
|
499
|
-
|
|
500
|
-
const entryPath = path.join(srcDir, 'entry.ts');
|
|
501
|
-
fs.writeFileSync(
|
|
502
|
-
entryPath,
|
|
503
|
-
[
|
|
504
|
-
'function property(_options: unknown) {',
|
|
505
|
-
'\treturn function (_target: unknown, _context: unknown) {};',
|
|
506
|
-
'}',
|
|
507
|
-
'class Counter {',
|
|
508
|
-
'\t@property({ type: Number }) accessor count = 0;',
|
|
509
|
-
'}',
|
|
510
|
-
'export const ready = typeof Counter === "function";',
|
|
511
|
-
].join('\n'),
|
|
512
|
-
);
|
|
513
|
-
|
|
514
|
-
const adapter = new EsbuildBuildAdapter();
|
|
515
|
-
const result = await adapter.build({
|
|
516
|
-
entrypoints: [entryPath],
|
|
517
|
-
root,
|
|
518
|
-
outdir: outDir,
|
|
519
|
-
target: 'node',
|
|
520
|
-
format: 'esm',
|
|
521
|
-
sourcemap: 'none',
|
|
522
|
-
splitting: false,
|
|
523
|
-
minify: false,
|
|
524
|
-
});
|
|
525
|
-
|
|
526
|
-
assert.equal(result.success, true);
|
|
527
|
-
|
|
528
|
-
const outputPath = result.outputs.find((output) => output.path.endsWith('entry.js'))?.path;
|
|
529
|
-
assert.ok(outputPath);
|
|
530
|
-
} finally {
|
|
531
|
-
cleanupTempRoots();
|
|
532
|
-
clearNodeCssBridge();
|
|
533
|
-
}
|
|
534
|
-
});
|
|
535
|
-
|
|
536
|
-
test('EsbuildBuildAdapter downlevels accessor fields for browser target bundles', async () => {
|
|
537
|
-
try {
|
|
538
|
-
const root = createTempRoot('ecopages-esbuild-browser-accessor');
|
|
539
|
-
const srcDir = path.join(root, 'src');
|
|
540
|
-
const outDir = path.join(root, 'dist');
|
|
541
|
-
fs.mkdirSync(srcDir, { recursive: true });
|
|
542
|
-
|
|
543
|
-
const entryPath = path.join(srcDir, 'entry.ts');
|
|
544
|
-
fs.writeFileSync(
|
|
545
|
-
entryPath,
|
|
546
|
-
[
|
|
547
|
-
'class Counter {',
|
|
548
|
-
'\taccessor count = 0;',
|
|
549
|
-
'}',
|
|
550
|
-
'export const ready = typeof Counter === "function";',
|
|
551
|
-
].join('\n'),
|
|
552
|
-
);
|
|
553
|
-
|
|
554
|
-
const adapter = new EsbuildBuildAdapter();
|
|
555
|
-
const result = await adapter.build({
|
|
556
|
-
entrypoints: [entryPath],
|
|
557
|
-
root,
|
|
558
|
-
outdir: outDir,
|
|
559
|
-
target: 'browser',
|
|
560
|
-
format: 'esm',
|
|
561
|
-
sourcemap: 'none',
|
|
562
|
-
splitting: false,
|
|
563
|
-
minify: false,
|
|
564
|
-
});
|
|
565
|
-
|
|
566
|
-
assert.equal(result.success, true);
|
|
567
|
-
|
|
568
|
-
const outputPath = result.outputs.find((output) => output.path.endsWith('entry.js'))?.path;
|
|
569
|
-
assert.ok(outputPath);
|
|
570
|
-
|
|
571
|
-
const outputSource = fs.readFileSync(outputPath, 'utf-8');
|
|
572
|
-
assert.doesNotMatch(outputSource, /accessor\s+count/);
|
|
573
|
-
} finally {
|
|
574
|
-
cleanupTempRoots();
|
|
575
|
-
clearNodeCssBridge();
|
|
576
|
-
}
|
|
577
|
-
});
|
|
578
|
-
|
|
579
|
-
test('EsbuildBuildAdapter applies plugin CSS transforms for CSS imported in TS modules', async () => {
|
|
580
|
-
try {
|
|
581
|
-
const root = createTempRoot('ecopages-esbuild-plugin-css-transform');
|
|
582
|
-
const srcDir = path.join(root, 'src');
|
|
583
|
-
const outDir = path.join(root, 'dist');
|
|
584
|
-
fs.mkdirSync(srcDir, { recursive: true });
|
|
585
|
-
|
|
586
|
-
const cssPath = path.join(srcDir, 'styles.css');
|
|
587
|
-
const entryPath = path.join(srcDir, 'entry.ts');
|
|
588
|
-
|
|
589
|
-
fs.writeFileSync(cssPath, '.counter { color: red; }');
|
|
590
|
-
fs.writeFileSync(entryPath, "import styles from './styles.css';\nexport const cssText = styles;");
|
|
591
|
-
|
|
592
|
-
const adapter = new EsbuildBuildAdapter();
|
|
593
|
-
|
|
594
|
-
const result = await adapter.build({
|
|
595
|
-
entrypoints: [entryPath],
|
|
596
|
-
root,
|
|
597
|
-
outdir: outDir,
|
|
598
|
-
target: 'node',
|
|
599
|
-
format: 'esm',
|
|
600
|
-
sourcemap: 'none',
|
|
601
|
-
splitting: false,
|
|
602
|
-
minify: false,
|
|
603
|
-
plugins: [
|
|
604
|
-
{
|
|
605
|
-
name: 'css-transform-test-plugin',
|
|
606
|
-
setup(build) {
|
|
607
|
-
build.onLoad({ filter: /\.css$/ }, async (args) => {
|
|
608
|
-
const contents = fs.readFileSync(args.path, 'utf-8');
|
|
609
|
-
return {
|
|
610
|
-
loader: 'object',
|
|
611
|
-
exports: {
|
|
612
|
-
default: `/* postprocessed */\n${contents}`,
|
|
613
|
-
},
|
|
614
|
-
};
|
|
615
|
-
});
|
|
616
|
-
},
|
|
617
|
-
},
|
|
618
|
-
],
|
|
619
|
-
});
|
|
620
|
-
|
|
621
|
-
assert.equal(result.success, true);
|
|
622
|
-
|
|
623
|
-
const outputPath = result.outputs.find((output) => output.path.endsWith('entry.js'))?.path;
|
|
624
|
-
assert.ok(outputPath);
|
|
625
|
-
|
|
626
|
-
const outputSource = fs.readFileSync(outputPath, 'utf-8');
|
|
627
|
-
assert.match(outputSource, /\/\* postprocessed \*\//);
|
|
628
|
-
assert.match(outputSource, /\.counter \{ color: red; \}/);
|
|
629
|
-
} finally {
|
|
630
|
-
cleanupTempRoots();
|
|
631
|
-
clearNodeCssBridge();
|
|
632
|
-
}
|
|
633
|
-
});
|
|
634
|
-
|
|
635
|
-
test('EsbuildBuildAdapter returns dependency graph entrypoint mapping', async () => {
|
|
636
|
-
try {
|
|
637
|
-
const root = createTempRoot('ecopages-esbuild-dependency-graph');
|
|
638
|
-
const srcDir = path.join(root, 'src');
|
|
639
|
-
const outDir = path.join(root, 'dist');
|
|
640
|
-
fs.mkdirSync(srcDir, { recursive: true });
|
|
641
|
-
|
|
642
|
-
const sharedPath = path.join(srcDir, 'shared.ts');
|
|
643
|
-
const leafPath = path.join(srcDir, 'leaf.ts');
|
|
644
|
-
const entryPath = path.join(srcDir, 'entry.ts');
|
|
645
|
-
|
|
646
|
-
fs.writeFileSync(sharedPath, "import { leaf } from './leaf';\nexport const shared = leaf + 1;");
|
|
647
|
-
fs.writeFileSync(leafPath, 'export const leaf = 2;');
|
|
648
|
-
fs.writeFileSync(entryPath, "import { shared } from './shared';\nexport const value = shared;");
|
|
649
|
-
|
|
650
|
-
const adapter = new EsbuildBuildAdapter();
|
|
651
|
-
const result = await adapter.build({
|
|
652
|
-
entrypoints: [entryPath],
|
|
653
|
-
root,
|
|
654
|
-
outdir: outDir,
|
|
655
|
-
target: 'node',
|
|
656
|
-
format: 'esm',
|
|
657
|
-
sourcemap: 'none',
|
|
658
|
-
splitting: false,
|
|
659
|
-
minify: false,
|
|
660
|
-
});
|
|
661
|
-
|
|
662
|
-
assert.equal(result.success, true);
|
|
663
|
-
assert.ok(result.dependencyGraph);
|
|
664
|
-
|
|
665
|
-
const dependencies = result.dependencyGraph?.entrypoints[path.resolve(entryPath)] ?? [];
|
|
666
|
-
|
|
667
|
-
assert.ok(dependencies.includes(path.resolve(entryPath)));
|
|
668
|
-
assert.ok(dependencies.includes(path.resolve(sharedPath)));
|
|
669
|
-
assert.ok(dependencies.includes(path.resolve(leafPath)));
|
|
670
|
-
} finally {
|
|
671
|
-
cleanupTempRoots();
|
|
672
|
-
clearNodeCssBridge();
|
|
673
|
-
}
|
|
674
|
-
});
|
|
675
|
-
|
|
676
|
-
test('EsbuildBuildAdapter honors first-match plugin precedence within one build', async () => {
|
|
677
|
-
try {
|
|
678
|
-
const root = createTempRoot('ecopages-esbuild-plugin-precedence');
|
|
679
|
-
const srcDir = path.join(root, 'src');
|
|
680
|
-
const outDir = path.join(root, 'dist');
|
|
681
|
-
fs.mkdirSync(srcDir, { recursive: true });
|
|
682
|
-
|
|
683
|
-
const cssPath = path.join(srcDir, 'styles.css');
|
|
684
|
-
const entryPath = path.join(srcDir, 'entry.ts');
|
|
685
|
-
|
|
686
|
-
fs.writeFileSync(cssPath, '.counter { color: red; }');
|
|
687
|
-
fs.writeFileSync(entryPath, "import styles from './styles.css';\nexport const cssText = styles;");
|
|
688
|
-
|
|
689
|
-
const adapter = new EsbuildBuildAdapter();
|
|
690
|
-
|
|
691
|
-
const result = await adapter.build({
|
|
692
|
-
entrypoints: [entryPath],
|
|
693
|
-
root,
|
|
694
|
-
outdir: outDir,
|
|
695
|
-
target: 'node',
|
|
696
|
-
format: 'esm',
|
|
697
|
-
sourcemap: 'none',
|
|
698
|
-
splitting: false,
|
|
699
|
-
minify: false,
|
|
700
|
-
plugins: [
|
|
701
|
-
{
|
|
702
|
-
name: 'first-css-plugin',
|
|
703
|
-
setup(build) {
|
|
704
|
-
build.onLoad({ filter: /\.css$/ }, async () => {
|
|
705
|
-
return {
|
|
706
|
-
loader: 'object',
|
|
707
|
-
exports: {
|
|
708
|
-
default: 'first-css',
|
|
709
|
-
},
|
|
710
|
-
};
|
|
711
|
-
});
|
|
712
|
-
},
|
|
713
|
-
},
|
|
714
|
-
{
|
|
715
|
-
name: 'second-css-plugin',
|
|
716
|
-
setup(build) {
|
|
717
|
-
build.onLoad({ filter: /\.css$/ }, async () => {
|
|
718
|
-
return {
|
|
719
|
-
loader: 'object',
|
|
720
|
-
exports: {
|
|
721
|
-
default: 'second-css',
|
|
722
|
-
},
|
|
723
|
-
};
|
|
724
|
-
});
|
|
725
|
-
},
|
|
726
|
-
},
|
|
727
|
-
],
|
|
728
|
-
});
|
|
729
|
-
|
|
730
|
-
assert.equal(result.success, true);
|
|
731
|
-
|
|
732
|
-
const outputPath = result.outputs.find((output) => output.path.endsWith('entry.js'))?.path;
|
|
733
|
-
assert.ok(outputPath);
|
|
734
|
-
|
|
735
|
-
const outputSource = fs.readFileSync(outputPath, 'utf-8');
|
|
736
|
-
assert.match(outputSource, /first-css/);
|
|
737
|
-
assert.doesNotMatch(outputSource, /second-css/);
|
|
738
|
-
} finally {
|
|
739
|
-
cleanupTempRoots();
|
|
740
|
-
clearNodeCssBridge();
|
|
741
|
-
}
|
|
742
|
-
});
|
|
743
|
-
|
|
744
|
-
test('EsbuildBuildAdapter resolves templated naming patterns to concrete output files', async () => {
|
|
745
|
-
try {
|
|
746
|
-
const root = createTempRoot('ecopages-esbuild-naming-template');
|
|
747
|
-
const srcDir = path.join(root, 'src');
|
|
748
|
-
const outDir = path.join(root, 'dist');
|
|
749
|
-
fs.mkdirSync(srcDir, { recursive: true });
|
|
750
|
-
|
|
751
|
-
const entryPath = path.join(srcDir, 'entry.ts');
|
|
752
|
-
fs.writeFileSync(entryPath, 'export const value = 1;');
|
|
753
|
-
|
|
754
|
-
const adapter = new EsbuildBuildAdapter();
|
|
755
|
-
const result = await adapter.build({
|
|
756
|
-
entrypoints: [entryPath],
|
|
757
|
-
root,
|
|
758
|
-
outdir: outDir,
|
|
759
|
-
target: 'node',
|
|
760
|
-
format: 'esm',
|
|
761
|
-
sourcemap: 'none',
|
|
762
|
-
splitting: true,
|
|
763
|
-
minify: false,
|
|
764
|
-
naming: '[name].[ext]',
|
|
765
|
-
});
|
|
766
|
-
|
|
767
|
-
assert.equal(result.success, true);
|
|
768
|
-
|
|
769
|
-
const outputPath = result.outputs.find((output) => output.path.endsWith('entry.js'))?.path;
|
|
770
|
-
assert.ok(outputPath);
|
|
771
|
-
assert.equal(fs.existsSync(path.join(outDir, '[name].[ext]')), false);
|
|
772
|
-
} finally {
|
|
773
|
-
cleanupTempRoots();
|
|
774
|
-
clearNodeCssBridge();
|
|
775
|
-
}
|
|
776
|
-
});
|
|
777
|
-
|
|
778
|
-
test('EsbuildBuildAdapter forwards define replacements into bundled runtime modules', async () => {
|
|
779
|
-
try {
|
|
780
|
-
const root = createTempRoot('ecopages-esbuild-define-runtime');
|
|
781
|
-
const srcDir = path.join(root, 'src');
|
|
782
|
-
const outDir = path.join(root, 'dist');
|
|
783
|
-
fs.mkdirSync(srcDir, { recursive: true });
|
|
784
|
-
|
|
785
|
-
const entryPath = path.join(srcDir, 'entry.js');
|
|
786
|
-
fs.writeFileSync(entryPath, 'export const mode = process.env.NODE_ENV;\n');
|
|
787
|
-
|
|
788
|
-
const adapter = new EsbuildBuildAdapter();
|
|
789
|
-
const result = await adapter.build({
|
|
790
|
-
entrypoints: [entryPath],
|
|
791
|
-
root,
|
|
792
|
-
outdir: outDir,
|
|
793
|
-
target: 'browser',
|
|
794
|
-
format: 'esm',
|
|
795
|
-
sourcemap: 'none',
|
|
796
|
-
splitting: false,
|
|
797
|
-
minify: false,
|
|
798
|
-
define: {
|
|
799
|
-
'process.env.NODE_ENV': '"development"',
|
|
800
|
-
},
|
|
801
|
-
});
|
|
802
|
-
|
|
803
|
-
assert.equal(result.success, true);
|
|
804
|
-
|
|
805
|
-
const outputPath = result.outputs.find((output) => output.path.endsWith('entry.js'))?.path;
|
|
806
|
-
assert.ok(outputPath);
|
|
807
|
-
|
|
808
|
-
const outputSource = fs.readFileSync(outputPath, 'utf-8');
|
|
809
|
-
assert.match(outputSource, /development/);
|
|
810
|
-
assert.doesNotMatch(outputSource, /production/);
|
|
811
|
-
} finally {
|
|
812
|
-
cleanupTempRoots();
|
|
813
|
-
clearNodeCssBridge();
|
|
814
|
-
}
|
|
815
|
-
});
|