@ecopages/core 0.6.1 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -143
- package/package.json +16 -3
- package/src/adapters/node/dev-session.js +2 -1
- package/src/adapters/node/node-client-bridge.d.ts +5 -7
- package/src/adapters/node/node-client-bridge.js +4 -14
- package/src/adapters/node/server-adapter.d.ts +4 -2
- package/src/adapters/node/server-adapter.js +13 -12
- package/src/adapters/shared/hmr/client-bridge.d.ts +25 -0
- package/src/adapters/shared/hmr/client-bridge.js +35 -0
- package/src/adapters/shared/hmr/dev-transform-entrypoint-registry.js +1 -1
- package/src/adapters/shared/hmr/hmr-manager.d.ts +9 -2
- package/src/adapters/shared/hmr/hmr-manager.js +36 -6
- package/src/adapters/shared/http/dist-file-handler.js +3 -7
- package/src/adapters/shared/http/response-headers.d.ts +29 -0
- package/src/adapters/shared/http/response-headers.js +89 -0
- package/src/adapters/shared/runtime/copy-runtime-public-dir.js +1 -1
- package/src/adapters/shared/runtime/runtime-server-lifecycle.d.ts +3 -2
- package/src/adapters/shared/runtime/runtime-server-lifecycle.js +4 -3
- package/src/adapters/shared/runtime/server-request-pipeline.js +4 -4
- package/src/adapters/shared/runtime/server-static-builder.d.ts +19 -8
- package/src/adapters/shared/runtime/server-static-builder.js +23 -4
- package/src/adapters/shared/ws/node-http-websocket-upgrades.d.ts +1 -1
- package/src/adapters/shared/ws/node-http-websocket-upgrades.js +23 -16
- package/src/assets/app-browser-client-build.d.ts +5 -12
- package/src/assets/app-browser-client-build.js +121 -336
- package/src/assets/asset-processing-service/app-browser-client-bundle.d.ts +4 -0
- package/src/assets/asset-processing-service/app-browser-client-bundle.js +6 -0
- package/src/assets/asset-processing-service/asset-dependency-keys.d.ts +28 -8
- package/src/assets/asset-processing-service/asset-dependency-keys.js +104 -29
- package/src/assets/asset-processing-service/asset-processing.service.d.ts +60 -2
- package/src/assets/asset-processing-service/asset-processing.service.js +189 -58
- package/src/assets/asset-processing-service/bundleable-script.d.ts +3 -0
- package/src/assets/asset-processing-service/bundleable-script.js +4 -0
- package/src/assets/asset-processing-service/grouped-content-bundles.d.ts +2 -2
- package/src/assets/asset-processing-service/grouped-content-bundles.js +5 -10
- package/src/assets/asset-processing-service/index.d.ts +0 -3
- package/src/assets/asset-processing-service/index.js +0 -3
- package/src/assets/asset-processing-service/last-good-output.d.ts +21 -0
- package/src/assets/asset-processing-service/last-good-output.js +32 -0
- package/src/assets/asset-processing-service/page-package.js +1 -4
- package/src/assets/asset-processing-service/processed-asset-ledger.d.ts +63 -0
- package/src/assets/asset-processing-service/processed-asset-ledger.js +101 -0
- package/src/assets/asset-processing-service/processors/base/base-processor.js +1 -1
- package/src/assets/asset-processing-service/processors/base/base-script-processor.js +1 -1
- package/src/assets/asset-processing-service/processors/script/content-script.processor.d.ts +24 -0
- package/src/assets/asset-processing-service/processors/script/content-script.processor.js +59 -4
- package/src/assets/asset-processing-service/processors/script/file-script.processor.d.ts +8 -4
- package/src/assets/asset-processing-service/processors/script/file-script.processor.js +18 -6
- package/src/assets/asset-processing-service/processors/script/node-module-script.processor.js +2 -3
- package/src/assets/asset-processing-service/processors/stylesheet/app-stylesheet-imports.d.ts +34 -0
- package/src/assets/asset-processing-service/processors/stylesheet/app-stylesheet-imports.js +115 -0
- package/src/assets/asset-processing-service/processors/stylesheet/content-stylesheet.processor.js +2 -2
- package/src/assets/asset-processing-service/processors/stylesheet/css-module-types.d.ts +39 -0
- package/src/assets/asset-processing-service/processors/stylesheet/css-module-types.js +150 -0
- package/src/assets/asset-processing-service/processors/stylesheet/css-scanner.d.ts +84 -0
- package/src/assets/asset-processing-service/processors/stylesheet/css-scanner.js +379 -0
- package/src/assets/asset-processing-service/processors/stylesheet/file-stylesheet.processor.d.ts +16 -0
- package/src/assets/asset-processing-service/processors/stylesheet/file-stylesheet.processor.js +50 -24
- package/src/assets/asset-processing-service/processors/stylesheet/import-order.d.ts +33 -0
- package/src/assets/asset-processing-service/processors/stylesheet/import-order.js +67 -0
- package/src/assets/asset-processing-service/processors/stylesheet/package-stylesheet.d.ts +44 -0
- package/src/assets/asset-processing-service/processors/stylesheet/package-stylesheet.js +149 -0
- package/src/assets/asset-processing-service/processors/stylesheet/processed-stylesheet-cache.d.ts +31 -0
- package/src/assets/asset-processing-service/processors/stylesheet/processed-stylesheet-cache.js +59 -0
- package/src/assets/asset-processing-service/processors/stylesheet/source-relative-stylesheet.d.ts +20 -0
- package/src/assets/asset-processing-service/processors/stylesheet/source-relative-stylesheet.js +51 -0
- package/src/assets/asset-processing-service/processors/stylesheet/stylesheet-failure.d.ts +2 -0
- package/src/assets/asset-processing-service/processors/stylesheet/stylesheet-failure.js +5 -0
- package/src/assets/asset-processing-service/processors/stylesheet/stylesheet-module.d.ts +37 -0
- package/src/assets/asset-processing-service/processors/stylesheet/stylesheet-module.js +48 -0
- package/src/assets/asset-processing-service/processors/stylesheet/stylesheet-processor-pipeline.d.ts +25 -1
- package/src/assets/asset-processing-service/processors/stylesheet/stylesheet-processor-pipeline.js +56 -15
- package/src/assets/asset-processing-service/processors/stylesheet/stylesheet-warnings.d.ts +9 -0
- package/src/assets/asset-processing-service/processors/stylesheet/stylesheet-warnings.js +21 -0
- package/src/assets/browser-asset-output.js +1 -1
- package/src/assets/hashed-browser-asset.js +1 -1
- package/src/assets/{browser-runtime-asset-page-cache.d.ts → page-script-page-cache.d.ts} +3 -3
- package/src/assets/{browser-runtime-asset-page-cache.js → page-script-page-cache.js} +3 -3
- package/src/build/app-build-manifest-runtime.d.ts +23 -11
- package/src/build/app-build-manifest-runtime.js +52 -13
- package/src/build/browser/jsx-ownership-plugins.d.ts +4 -1
- package/src/build/browser/jsx-ownership-plugins.js +6 -0
- package/src/build/build-adapter.d.ts +1 -1
- package/src/build/build-adapter.js +1 -1
- package/src/build/build-graph.d.ts +4 -2
- package/src/build/build-graph.js +12 -46
- package/src/build/cache/build-input-dependency-index.d.ts +0 -19
- package/src/build/cache/build-input-dependency-index.js +1 -34
- package/src/build/cache/pages-unified-graph-build.js +7 -43
- package/src/build/cache/server-module-entries.d.ts +1 -1
- package/src/build/cache/server-module-entries.js +9 -9
- package/src/build/contracts/build-contracts.d.ts +59 -12
- package/src/build/contracts/build-manifest.d.ts +3 -6
- package/src/build/contracts/build-manifest.js +2 -12
- package/src/build/contracts/content-virtual-modules.js +1 -3
- package/src/build/copy-server-files.js +1 -1
- package/src/build/preserve-import-meta-transform.d.ts +3 -1
- package/src/build/preserve-import-meta-transform.js +7 -4
- package/src/build/production-asset-ledger.d.ts +36 -0
- package/src/build/production-asset-ledger.js +104 -0
- package/src/build/production-dist-complete.js +12 -13
- package/src/build/production-route-list.js +1 -1
- package/src/build/rolldown/app-package-declarations.js +1 -1
- package/src/build/rolldown/entry-module-closures.d.ts +5 -1
- package/src/build/rolldown/entry-module-closures.js +21 -8
- package/src/build/rolldown/rolldown-adapter-helpers.d.ts +19 -8
- package/src/build/rolldown/rolldown-adapter-helpers.js +82 -45
- package/src/build/rolldown/rolldown-build-adapter.js +10 -13
- package/src/build/rolldown/rolldown-module-id.d.ts +18 -0
- package/src/build/rolldown/rolldown-module-id.js +29 -0
- package/src/build/rolldown/rolldown-plugin-bridge.d.ts +24 -60
- package/src/build/rolldown/rolldown-plugin-bridge.js +201 -373
- package/src/build/rolldown/stylesheet-module-plugin.d.ts +34 -0
- package/src/build/rolldown/stylesheet-module-plugin.js +160 -0
- package/src/build/rolldown/worker-entries-plugin.d.ts +13 -0
- package/src/build/rolldown/worker-entries-plugin.js +57 -0
- package/src/build/runtime/build-environment-options.js +13 -3
- package/src/build/runtime/build-request-identity.js +1 -1
- package/src/build/runtime/build-request-policy.d.ts +7 -12
- package/src/build/runtime/build-request-policy.js +63 -17
- package/src/build/server/imported-view-plugin.d.ts +1 -0
- package/src/build/server/imported-view-plugin.js +6 -4
- package/src/build/server/page-module-import.service.d.ts +1 -2
- package/src/build/server/page-module-import.service.js +4 -6
- package/src/build/server/resolve-static-view.js +3 -2
- package/src/build/server/route-module-build-cache-registry.js +1 -1
- package/src/build/server/route-module-build-cache.store.js +1 -1
- package/src/build/server/route-module-build-manifest.js +1 -1
- package/src/build/server/route-module-dependency-hasher.d.ts +1 -1
- package/src/build/server/route-module-dependency-hasher.js +2 -2
- package/src/build/server/server-modules-manifest.d.ts +3 -5
- package/src/build/server/server-modules-manifest.js +6 -21
- package/src/build/server/view-module.d.ts +12 -0
- package/src/build/server/view-module.js +23 -0
- package/src/build/server/view-reference.d.ts +16 -5
- package/src/build/server/view-reference.js +25 -14
- package/src/build/server-bundle-deploy-manifest.d.ts +1 -1
- package/src/build/server-bundle-deploy-manifest.js +2 -2
- package/src/build/server-bundle-publication.d.ts +7 -1
- package/src/build/server-bundle-publication.js +11 -4
- package/src/build/server-module.js +1 -1
- package/src/build/worker-urls.d.ts +60 -0
- package/src/build/worker-urls.js +197 -0
- package/src/build.d.ts +7 -5
- package/src/build.js +7 -5
- package/src/cache/module-parse-cache.js +2 -2
- package/src/client/navigation-attributes.d.ts +8 -0
- package/src/client/navigation-attributes.js +8 -0
- package/src/client/navigation-scripts/global-scripts.d.ts +14 -0
- package/src/client/navigation-scripts/global-scripts.js +65 -0
- package/src/client/navigation-scripts/index.d.ts +1 -0
- package/src/client/navigation-scripts/index.js +1 -0
- package/src/client.d.ts +2 -2
- package/src/client.js +2 -2
- package/src/config/assembly/app-runtime.d.ts +45 -5
- package/src/config/assembly/app-runtime.js +11 -2
- package/src/config/assembly/finalize-config.js +13 -5
- package/src/config/config-module-files.js +10 -6
- package/src/config/index.d.ts +2 -1
- package/src/config/internal-types.d.ts +3 -0
- package/src/config/load-eco-config.js +8 -5
- package/src/config/resolve-eco-config-path.js +3 -3
- package/src/config/server-config-bundle.js +1 -1
- package/src/config/user-config-types.d.ts +54 -1
- package/src/config/write-types.js +4 -1
- package/src/css-imports.d.ts +12 -0
- package/src/declarations.d.ts +2 -0
- package/src/dev/development-restart-watch-paths.js +1 -1
- package/src/dev/development-restart.js +1 -1
- package/src/dev/invalidation/development-invalidation.service.d.ts +6 -1
- package/src/dev/invalidation/development-invalidation.service.js +18 -2
- package/src/dev/stylesheets/development-stylesheet.service.d.ts +149 -0
- package/src/dev/stylesheets/development-stylesheet.service.js +350 -0
- package/src/dev/transform-server/dev-transform-bundler.d.ts +12 -3
- package/src/dev/transform-server/dev-transform-bundler.js +32 -21
- package/src/dev/transform-server/dev-transform-externalize-plugin.d.ts +3 -5
- package/src/dev/transform-server/dev-transform-externalize-plugin.js +8 -9
- package/src/dev/transform-server/dev-transform-import-rewriter.d.ts +15 -2
- package/src/dev/transform-server/dev-transform-import-rewriter.js +204 -35
- package/src/dev/transform-server/dev-transform-install-stamp.d.ts +17 -0
- package/src/dev/transform-server/dev-transform-install-stamp.js +79 -0
- package/src/dev/transform-server/dev-transform-server.d.ts +38 -2
- package/src/dev/transform-server/dev-transform-server.js +96 -33
- package/src/dev/transform-server/dev-transform-url.d.ts +4 -2
- package/src/dev/transform-server/dev-transform-url.js +13 -12
- package/src/dev/transform-server/dev-transform-vendor-registry.d.ts +178 -21
- package/src/dev/transform-server/dev-transform-vendor-registry.js +675 -99
- package/src/dev/transform-server/index.d.ts +1 -1
- package/src/dev-toolbar/dev-toolbar-package.js +4 -4
- package/src/eco/component-render-output.d.ts +6 -1
- package/src/eco/component-render-output.js +32 -7
- package/src/eco/discovered-dependencies.d.ts +30 -11
- package/src/eco/discovered-dependencies.js +25 -13
- package/src/eco/discovered-dependency-paths.d.ts +36 -0
- package/src/eco/discovered-dependency-paths.js +58 -0
- package/src/eco/eco.browser.js +8 -12
- package/src/eco/eco.js +0 -30
- package/src/eco/mdx-page-metadata.d.ts +14 -0
- package/src/eco/mdx-page-metadata.js +15 -0
- package/src/eco/page-layout-normalization.d.ts +6 -2
- package/src/eco/page-layout-normalization.js +9 -6
- package/src/env.js +17 -0
- package/src/hmr/client/hmr-runtime.js +14 -13
- package/src/hmr/dev-client-runtime.d.ts +5 -2
- package/src/hmr/dev-client-runtime.js +14 -4
- package/src/hmr/hmr-entrypoint-output.js +1 -1
- package/src/hmr/hmr-strategy.d.ts +2 -2
- package/src/hmr/hmr-strategy.js +2 -2
- package/src/hmr/strategies/js-hmr-strategy.d.ts +4 -1
- package/src/hmr/strategies/js-hmr-strategy.js +7 -6
- package/src/hmr/strategies/template-source-hmr-strategy.d.ts +25 -0
- package/src/hmr/strategies/template-source-hmr-strategy.js +36 -0
- package/src/html-pages/html-page-module-scripts.d.ts +2 -1
- package/src/html-pages/html-page-module-scripts.js +37 -14
- package/src/html-pages/html-page-module.js +1 -1
- package/src/html-pages/html-page-renderer.js +7 -6
- package/src/html-pages/html-page-template.d.ts +0 -5
- package/src/html-pages/html-page-template.js +3 -15
- package/src/html-pages/html-pages.plugin.js +2 -2
- package/src/integration.d.ts +8 -6
- package/src/integration.js +5 -3
- package/src/page-cache/html-page-cache-dependency-index.js +1 -1
- package/src/page-cache/page-cache-service.js +1 -1
- package/src/plugins/alias-resolver-plugin.d.ts +7 -0
- package/src/plugins/alias-resolver-plugin.js +16 -6
- package/src/plugins/component-import-discovery.d.ts +178 -7
- package/src/plugins/component-import-discovery.js +696 -112
- package/src/plugins/eco-component-meta-plugin.d.ts +47 -6
- package/src/plugins/eco-component-meta-plugin.js +227 -59
- package/src/plugins/foreign-jsx-override-plugin.d.ts +14 -1
- package/src/plugins/foreign-jsx-override-plugin.js +18 -8
- package/src/plugins/integration-plugin.d.ts +47 -11
- package/src/plugins/integration-plugin.js +57 -8
- package/src/plugins/processor.d.ts +72 -7
- package/src/plugins/processor.js +44 -9
- package/src/plugins/stylesheet-kinds.d.ts +57 -0
- package/src/plugins/stylesheet-kinds.js +114 -0
- package/src/plugins/tsconfig-import-resolver.d.ts +49 -3
- package/src/plugins/tsconfig-import-resolver.js +120 -6
- package/src/processor-contract.d.ts +66 -0
- package/src/processor-contract.js +389 -0
- package/src/processor.d.ts +6 -1
- package/src/processor.js +6 -1
- package/src/route-renderer/error-pages/default-error-pages.d.ts +1 -0
- package/src/route-renderer/error-pages/default-error-pages.js +27 -7
- package/src/route-renderer/orchestration/custom-element-scripts/custom-element-script-preload-invalidation.d.ts +8 -0
- package/src/route-renderer/orchestration/custom-element-scripts/custom-element-script-preload-invalidation.js +12 -0
- package/src/route-renderer/orchestration/custom-element-scripts/custom-element-script-preloader.d.ts +77 -24
- package/src/route-renderer/orchestration/custom-element-scripts/custom-element-script-preloader.js +97 -32
- package/src/route-renderer/orchestration/custom-element-scripts/custom-element-server-module-importer.js +1 -1
- package/src/route-renderer/orchestration/document-shell/document-shell-render.service.d.ts +9 -0
- package/src/route-renderer/orchestration/document-shell/document-shell-render.service.js +16 -2
- package/src/route-renderer/orchestration/document-shell/layout-children-not-rendered-error.d.ts +35 -0
- package/src/route-renderer/orchestration/document-shell/layout-children-not-rendered-error.js +53 -0
- package/src/route-renderer/orchestration/foreign-child/render-session.d.ts +4 -8
- package/src/route-renderer/orchestration/foreign-child/render-session.js +2 -5
- package/src/route-renderer/orchestration/integration-renderer.d.ts +171 -64
- package/src/route-renderer/orchestration/integration-renderer.js +293 -332
- package/src/route-renderer/orchestration/ownership-graph/component-graph-collectors.d.ts +8 -5
- package/src/route-renderer/orchestration/ownership-graph/component-graph-collectors.js +27 -25
- package/src/route-renderer/orchestration/ownership-graph/component-graph.d.ts +0 -6
- package/src/route-renderer/orchestration/page-browser-graph/global-injector-assets.service.js +3 -3
- package/src/route-renderer/orchestration/page-browser-graph/grouped-graph-build-plan.d.ts +12 -25
- package/src/route-renderer/orchestration/page-browser-graph/grouped-graph-build-plan.js +1 -14
- package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph-session.d.ts +0 -16
- package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph-session.js +1 -87
- package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph.service.d.ts +8 -16
- package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph.service.js +25 -271
- package/src/route-renderer/orchestration/page-browser-graph/route-instance-key.d.ts +0 -24
- package/src/route-renderer/orchestration/page-browser-graph/route-instance-key.js +0 -67
- package/src/route-renderer/orchestration/route-pipeline/route-render-orchestrator.d.ts +28 -15
- package/src/route-renderer/orchestration/route-pipeline/route-render-orchestrator.js +63 -41
- package/src/route-renderer/page-loading/component-dependency-collection.d.ts +4 -1
- package/src/route-renderer/page-loading/component-dependency-collection.js +51 -15
- package/src/route-renderer/page-loading/dependency-resolver.d.ts +10 -0
- package/src/route-renderer/page-loading/dependency-resolver.js +27 -6
- package/src/route-renderer/page-loading/file-scoped-dependency-components.d.ts +4 -2
- package/src/route-renderer/page-loading/file-scoped-dependency-components.js +22 -17
- package/src/route-renderer/page-loading/lazy-entry-collection.d.ts +5 -0
- package/src/route-renderer/page-loading/lazy-entry-collection.js +6 -4
- package/src/route-renderer/page-loading/page-dependency-bundling.d.ts +5 -2
- package/src/route-renderer/page-loading/page-dependency-bundling.js +15 -31
- package/src/route-renderer/page-loading/page-module-loader.d.ts +13 -2
- package/src/route-renderer/page-loading/page-module-loader.js +23 -5
- package/src/route-renderer/route-renderer.d.ts +1 -1
- package/src/router/client/navigation-commit.d.ts +2 -0
- package/src/router/client/navigation-commit.js +4 -1
- package/src/router/client/navigation-coordinator.d.ts +18 -0
- package/src/router/client/navigation-coordinator.js +14 -0
- package/src/router/client/navigation-lifecycle.d.ts +18 -1
- package/src/router/client/navigation-lifecycle.js +6 -3
- package/src/router/client/navigation-pipeline.d.ts +1 -0
- package/src/router/client/navigation-pipeline.js +1 -0
- package/src/router/server/route-registry.d.ts +3 -2
- package/src/router/server/route-registry.js +6 -5
- package/src/static-site-generator/production-page-browser-graph-prebuild.d.ts +30 -18
- package/src/static-site-generator/production-page-browser-graph-prebuild.js +82 -143
- package/src/static-site-generator/static-site-generator.d.ts +37 -4
- package/src/static-site-generator/static-site-generator.js +99 -51
- package/src/types/asset-types.d.ts +19 -1
- package/src/types/build-types.d.ts +53 -35
- package/src/types/component-identity.d.ts +8 -0
- package/src/types/contracts.d.ts +69 -21
- package/src/types/dev-transform-types.d.ts +33 -6
- package/src/types/eco-api-types.d.ts +13 -18
- package/src/types/integration-types.d.ts +1 -1
- package/src/types/public-types.d.ts +1 -1
- package/src/utils/additional-watch-paths.js +3 -5
- package/src/utils/entry-command-flags.d.ts +23 -0
- package/src/utils/entry-command-flags.js +24 -0
- package/src/utils/package-path.d.ts +42 -0
- package/src/utils/package-path.js +114 -0
- package/src/utils/parse-cli-args.d.ts +18 -1
- package/src/utils/parse-cli-args.js +54 -37
- package/src/utils/path-containment.js +3 -10
- package/src/utils/resolve-work-dir.js +2 -2
- package/src/utils/root-relative-path.js +2 -2
- package/src/utils/server-bundle-context.d.ts +5 -0
- package/src/utils/server-bundle-context.js +7 -1
- package/src/utils/server-utils.module.js +1 -1
- package/src/watchers/project-watcher-ignore.js +3 -3
- package/src/watchers/project-watcher.d.ts +14 -2
- package/src/watchers/project-watcher.js +37 -6
- package/src/watchers/workspace-package-watch-roots.js +2 -2
- package/src/assets/app-browser-client-manifest.d.ts +0 -66
- package/src/assets/app-browser-client-manifest.js +0 -260
- package/src/assets/asset-processing-service/asset-package-role.d.ts +0 -2
- package/src/assets/asset-processing-service/asset-package-role.js +0 -3
- package/src/assets/asset-processing-service/browser-runtime-asset.factory.d.ts +0 -58
- package/src/assets/asset-processing-service/browser-runtime-asset.factory.js +0 -61
- package/src/assets/asset-processing-service/browser-runtime-entry-resolution.d.ts +0 -79
- package/src/assets/asset-processing-service/browser-runtime-entry-resolution.js +0 -200
- package/src/assets/asset-processing-service/browser-runtime-entry.factory.d.ts +0 -24
- package/src/assets/asset-processing-service/browser-runtime-entry.factory.js +0 -67
- package/src/build/browser/browser-runtime-manifest.d.ts +0 -35
- package/src/build/browser/browser-runtime-manifest.js +0 -65
- package/src/build/browser/browser-runtime-plugin-helpers.d.ts +0 -14
- package/src/build/browser/browser-runtime-plugin-helpers.js +0 -21
- package/src/build/browser/browser-runtime-plugin.d.ts +0 -54
- package/src/build/browser/browser-runtime-plugin.js +0 -76
- package/src/build/rolldown/server-side-css-shim-plugin.d.ts +0 -28
- package/src/build/rolldown/server-side-css-shim-plugin.js +0 -59
- package/src/dev/transform-server/dev-transform-module-kind.d.ts +0 -13
- package/src/dev/transform-server/dev-transform-module-kind.js +0 -17
- package/src/dev/transform-server/dev-transform-runtime-specifiers.d.ts +0 -5
- package/src/dev/transform-server/dev-transform-runtime-specifiers.js +0 -16
- package/src/route-renderer/orchestration/custom-element-scripts/custom-element-ssr-preload-entrypoint.d.ts +0 -15
- package/src/route-renderer/orchestration/custom-element-scripts/custom-element-ssr-preload-entrypoint.js +0 -65
- package/src/route-renderer/orchestration/page-browser-graph/missing-production-browser-graph.d.ts +0 -21
- package/src/route-renderer/orchestration/page-browser-graph/missing-production-browser-graph.js +0 -31
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import path from '
|
|
1
|
+
import { path } from '@ecopages/file-system/path';
|
|
2
2
|
import { fileSystem } from '@ecopages/file-system';
|
|
3
3
|
import { collectBuildEntryInputPaths } from '../../build/build-graph.js';
|
|
4
4
|
/**
|
|
@@ -100,7 +100,7 @@ function isTrackableRouteModuleDependency(modulePath) {
|
|
|
100
100
|
if (!path.isAbsolute(normalizedPath)) {
|
|
101
101
|
return false;
|
|
102
102
|
}
|
|
103
|
-
if (normalizedPath.includes(
|
|
103
|
+
if (normalizedPath.includes(`/node_modules/`)) {
|
|
104
104
|
return false;
|
|
105
105
|
}
|
|
106
106
|
return !normalizedPath.includes('\0');
|
|
@@ -36,13 +36,11 @@ export declare function requireProductionServerModules(appConfig: EcoPagesAppCon
|
|
|
36
36
|
*/
|
|
37
37
|
export declare function missingProductionServerModuleError(sourceKey: string): Error;
|
|
38
38
|
/**
|
|
39
|
-
* Finds the production map key for `filePath
|
|
39
|
+
* Finds the production map key for `filePath`: its path relative to `rootDir`, when the map records it.
|
|
40
40
|
*
|
|
41
41
|
* @remarks
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
* that is a suffix of that path wins, so a copied `dist/` can load scripts
|
|
45
|
-
* resolved from that identity.
|
|
42
|
+
* Emitted modules name their sources relative to the app root, so a moved or copied deploy resolves every
|
|
43
|
+
* key against its own root.
|
|
46
44
|
*/
|
|
47
45
|
export declare function matchProductionModuleKey(rootDir: string, filePath: string, modules: Record<string, string>): string | undefined;
|
|
48
46
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import path from '
|
|
1
|
+
import { path } from '@ecopages/file-system/path';
|
|
2
2
|
import { fileSystem } from '@ecopages/file-system';
|
|
3
3
|
import { requireAppRuntime } from '../../utils/app-runtime.js';
|
|
4
4
|
import { toRootRelativePath } from '../../utils/root-relative-path.js';
|
|
@@ -89,30 +89,15 @@ function modulePathWithoutQuery(filePath) {
|
|
|
89
89
|
return query === -1 ? filePath : filePath.slice(0, query);
|
|
90
90
|
}
|
|
91
91
|
/**
|
|
92
|
-
* Finds the production map key for `filePath
|
|
92
|
+
* Finds the production map key for `filePath`: its path relative to `rootDir`, when the map records it.
|
|
93
93
|
*
|
|
94
94
|
* @remarks
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
* that is a suffix of that path wins, so a copied `dist/` can load scripts
|
|
98
|
-
* resolved from that identity.
|
|
95
|
+
* Emitted modules name their sources relative to the app root, so a moved or copied deploy resolves every
|
|
96
|
+
* key against its own root.
|
|
99
97
|
*/
|
|
100
98
|
export function matchProductionModuleKey(rootDir, filePath, modules) {
|
|
101
|
-
const
|
|
102
|
-
|
|
103
|
-
if (sourceKey in modules) {
|
|
104
|
-
return sourceKey;
|
|
105
|
-
}
|
|
106
|
-
const posix = file.split(path.sep).join('/');
|
|
107
|
-
let match;
|
|
108
|
-
for (const key of Object.keys(modules)) {
|
|
109
|
-
if (posix === key || posix.endsWith(`/${key}`)) {
|
|
110
|
-
if (!match || key.length > match.length) {
|
|
111
|
-
match = key;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
return match;
|
|
99
|
+
const sourceKey = toRootRelativePath(rootDir, modulePathWithoutQuery(filePath));
|
|
100
|
+
return sourceKey in modules ? sourceKey : undefined;
|
|
116
101
|
}
|
|
117
102
|
/**
|
|
118
103
|
* True when `ecopages build` recorded a compiled module for `filePath`.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* True when an Integration-owned file imported from the server entry is a view,
|
|
3
|
+
* so its import becomes a view reference.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* A view is the default export, so a script module without one, such as a file of
|
|
7
|
+
* plain components or a barrel, is not a view and loads as itself. Type-only
|
|
8
|
+
* exports do not count. Files that are not script modules (`.html`, `.mdx`) are
|
|
9
|
+
* views. A script module that does not parse is not, so the runtime or bundler
|
|
10
|
+
* loading it reports the syntax error.
|
|
11
|
+
*/
|
|
12
|
+
export declare function isViewModule(filePath: string, source: string): boolean;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { parseModuleSource } from '../../cache/module-parse-cache.js';
|
|
2
|
+
const SCRIPT_MODULE_EXTENSION = /\.[cm]?[jt]sx?$/;
|
|
3
|
+
/**
|
|
4
|
+
* True when an Integration-owned file imported from the server entry is a view,
|
|
5
|
+
* so its import becomes a view reference.
|
|
6
|
+
*
|
|
7
|
+
* @remarks
|
|
8
|
+
* A view is the default export, so a script module without one, such as a file of
|
|
9
|
+
* plain components or a barrel, is not a view and loads as itself. Type-only
|
|
10
|
+
* exports do not count. Files that are not script modules (`.html`, `.mdx`) are
|
|
11
|
+
* views. A script module that does not parse is not, so the runtime or bundler
|
|
12
|
+
* loading it reports the syntax error.
|
|
13
|
+
*/
|
|
14
|
+
export function isViewModule(filePath, source) {
|
|
15
|
+
if (!SCRIPT_MODULE_EXTENSION.test(filePath)) {
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
18
|
+
const result = parseModuleSource(filePath, source);
|
|
19
|
+
if (result.errors.length > 0) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
return result.module.staticExports.some((staticExport) => staticExport.entries.some((entry) => !entry.isType && (entry.exportName.kind === 'Default' || entry.exportName.name === 'default')));
|
|
23
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type ViewReference } from '../../types/view-reference.js';
|
|
2
2
|
export { isViewReference, VIEW_REFERENCE, type ViewReference } from '../../types/view-reference.js';
|
|
3
|
+
export { isViewModule } from './view-module.js';
|
|
3
4
|
export type ViewIntegrationMatch = {
|
|
4
5
|
name: string;
|
|
5
6
|
extensions: readonly string[];
|
|
@@ -26,13 +27,23 @@ export declare function isExemptFromViewReference(filePath: string, options?: {
|
|
|
26
27
|
export declare function findViewOwner(integrations: readonly ViewIntegrationMatch[], filePath: string): ViewIntegrationMatch | undefined;
|
|
27
28
|
export declare function viewExtensionFilter(extensions: readonly string[]): RegExp;
|
|
28
29
|
/**
|
|
29
|
-
* Returns the one view reference for `filePath
|
|
30
|
+
* Returns the one view reference for `filePath`, the view's source path relative to the app root.
|
|
30
31
|
*
|
|
31
32
|
* @remarks
|
|
32
|
-
* Two imports
|
|
33
|
-
*
|
|
33
|
+
* Two imports that name the file with the same string share this object. The
|
|
34
|
+
* server-entry bundle names it relative to the app root, so the bundle holds no path
|
|
35
|
+
* of the machine that built it; the development preload names it by absolute path.
|
|
36
|
+
* One process loads only one of them. Core resolves `filePath` against the app root
|
|
37
|
+
* when it renders the view.
|
|
34
38
|
*/
|
|
35
39
|
export declare function createViewReference<P = Record<string, unknown>>(filePath: string, integration?: string | null): ViewReference<P>;
|
|
36
|
-
/**
|
|
37
|
-
|
|
40
|
+
/**
|
|
41
|
+
* Synthetic ESM source the CLI hook and server-entry plugin evaluate instead of the view.
|
|
42
|
+
*
|
|
43
|
+
* @remarks
|
|
44
|
+
* The server-entry plugin passes `appRoot`, so the bundle names the view relative to it with forward slashes
|
|
45
|
+
* (see {@link createViewReference}). The development preload passes none and keeps the absolute path, which
|
|
46
|
+
* only lives in that process.
|
|
47
|
+
*/
|
|
48
|
+
export declare function viewReferenceModuleSource(filePath: string, integrationName?: string, appRoot?: string): string;
|
|
38
49
|
export declare function assertIsViewReference(value: unknown): asserts value is ViewReference;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import path from '
|
|
1
|
+
import { path } from '@ecopages/file-system/path';
|
|
2
2
|
import { findIntegrationForFile } from '../../plugins/find-integration-for-file.js';
|
|
3
3
|
import { escapeRegExp } from '../../utils/regex-escaping.js';
|
|
4
|
+
import { toRootRelativePath } from '../../utils/root-relative-path.js';
|
|
4
5
|
import { isViewReference, VIEW_REFERENCE } from '../../types/view-reference.js';
|
|
5
6
|
export { isViewReference, VIEW_REFERENCE } from '../../types/view-reference.js';
|
|
7
|
+
export { isViewModule } from './view-module.js';
|
|
6
8
|
const HTML_VIEW_EXTENSION = '.html';
|
|
7
9
|
/** Same name as `HTML_PAGES_INTEGRATION_NAME`; this file cannot import the Rendering layer. */
|
|
8
10
|
const HTML_VIEW_INTEGRATION = 'html-pages';
|
|
@@ -23,7 +25,7 @@ export function collectViewIntegrations(integrations) {
|
|
|
23
25
|
const ECO_CONFIG_BASENAME = /^eco\.config(?:\.[cm]?[jt]sx?)?$/;
|
|
24
26
|
/** True when a native import of this path must stay a real module. */
|
|
25
27
|
export function isIgnoredViewPath(filePath) {
|
|
26
|
-
return filePath.split(
|
|
28
|
+
return filePath.split('/').includes('node_modules');
|
|
27
29
|
}
|
|
28
30
|
function isInsideDir(filePath, dir) {
|
|
29
31
|
const relative = path.relative(path.resolve(dir), path.resolve(filePath));
|
|
@@ -70,36 +72,45 @@ export function viewExtensionFilter(extensions) {
|
|
|
70
72
|
return new RegExp(`(${extensions.map(escapeRegExp).join('|')})$`);
|
|
71
73
|
}
|
|
72
74
|
/**
|
|
73
|
-
* Returns the one view reference for `filePath
|
|
75
|
+
* Returns the one view reference for `filePath`, the view's source path relative to the app root.
|
|
74
76
|
*
|
|
75
77
|
* @remarks
|
|
76
|
-
* Two imports
|
|
77
|
-
*
|
|
78
|
+
* Two imports that name the file with the same string share this object. The
|
|
79
|
+
* server-entry bundle names it relative to the app root, so the bundle holds no path
|
|
80
|
+
* of the machine that built it; the development preload names it by absolute path.
|
|
81
|
+
* One process loads only one of them. Core resolves `filePath` against the app root
|
|
82
|
+
* when it renders the view.
|
|
78
83
|
*/
|
|
79
84
|
export function createViewReference(filePath, integration) {
|
|
80
|
-
const
|
|
81
|
-
const existing = viewReferences.get(resolvedPath);
|
|
85
|
+
const existing = viewReferences.get(filePath);
|
|
82
86
|
if (existing) {
|
|
83
87
|
return existing;
|
|
84
88
|
}
|
|
85
89
|
const integrationName = integration ?? undefined;
|
|
86
90
|
const reference = {
|
|
87
91
|
[VIEW_REFERENCE]: true,
|
|
88
|
-
filePath
|
|
92
|
+
filePath,
|
|
89
93
|
config: {
|
|
90
94
|
identity: {
|
|
91
|
-
id:
|
|
92
|
-
file:
|
|
95
|
+
id: filePath,
|
|
96
|
+
file: filePath,
|
|
93
97
|
integration: integrationName,
|
|
94
98
|
},
|
|
95
99
|
},
|
|
96
100
|
};
|
|
97
|
-
viewReferences.set(
|
|
101
|
+
viewReferences.set(filePath, reference);
|
|
98
102
|
return reference;
|
|
99
103
|
}
|
|
100
|
-
/**
|
|
101
|
-
|
|
102
|
-
|
|
104
|
+
/**
|
|
105
|
+
* Synthetic ESM source the CLI hook and server-entry plugin evaluate instead of the view.
|
|
106
|
+
*
|
|
107
|
+
* @remarks
|
|
108
|
+
* The server-entry plugin passes `appRoot`, so the bundle names the view relative to it with forward slashes
|
|
109
|
+
* (see {@link createViewReference}). The development preload passes none and keeps the absolute path, which
|
|
110
|
+
* only lives in that process.
|
|
111
|
+
*/
|
|
112
|
+
export function viewReferenceModuleSource(filePath, integrationName, appRoot) {
|
|
113
|
+
const pathLiteral = JSON.stringify(appRoot ? toRootRelativePath(appRoot, filePath) : path.resolve(filePath));
|
|
103
114
|
const integrationLiteral = JSON.stringify(integrationName);
|
|
104
115
|
return `import { createViewReference } from '@ecopages/core/view-reference';
|
|
105
116
|
export default createViewReference(${pathLiteral}, ${integrationLiteral});
|
|
@@ -13,7 +13,7 @@ export interface ServerBundleDeployManifest {
|
|
|
13
13
|
emittedConfigModule?: string;
|
|
14
14
|
/** Content hash of the emitted production config artifact. */
|
|
15
15
|
emittedConfigHash?: string;
|
|
16
|
-
/** Id shared with `routes.json`, `server-modules.json`, and
|
|
16
|
+
/** Id shared with `routes.json`, `server-modules.json`, and `processed-assets.json`. */
|
|
17
17
|
buildId?: string;
|
|
18
18
|
}
|
|
19
19
|
export declare function getServerBundleOutputPaths(appConfig: EcoPagesAppConfig): {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { contentHash } from '../utils/content-hash.js';
|
|
2
|
-
import path from '
|
|
2
|
+
import { path } from '@ecopages/file-system/path';
|
|
3
3
|
import { fileSystem } from '@ecopages/file-system';
|
|
4
4
|
import { CLIENT_OUTPUT_DIR, SERVER_BUNDLE_DIR, SERVER_BUNDLE_FILENAME } from '../utils/resolve-entry-file.js';
|
|
5
5
|
import { ensureProductionBuildId } from './production-build-id.js';
|
|
@@ -88,7 +88,7 @@ function isServerBundleDeployManifest(value) {
|
|
|
88
88
|
* @returns The absolute path of the build output directory.
|
|
89
89
|
*/
|
|
90
90
|
export async function resolveProductionDistDir(options = {}) {
|
|
91
|
-
const cwd = path.resolve(options.cwd ??
|
|
91
|
+
const cwd = path.resolve(options.cwd ?? path.cwd());
|
|
92
92
|
const describe = (distDir) => path.relative(cwd, distDir) || '.';
|
|
93
93
|
const staticOnlyError = (distDir) => new Error(`${describe(distDir)}/ holds a static-only build: it has no server bundle, so \`ecopages start\` cannot run it. Serve it with \`ecopages preview\` or deploy ${describe(distDir)}/${CLIENT_OUTPUT_DIR}/ to a static host.`);
|
|
94
94
|
const holdsBuiltHtml = (distDir) => fileSystem.exists(path.join(distDir, CLIENT_OUTPUT_DIR, 'index.html'));
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
|
+
* Creates a sibling staging directory so publication stays on one filesystem.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* The directory is made with a plain `mkdir` under a unique name, not `mkdtemp`, whose 0700 mode
|
|
6
|
+
* would survive the rename and leave `dist/server` unreadable to a non-root user in a deployed image.
|
|
7
|
+
*/
|
|
2
8
|
export declare function createServerBundleStagingDirectory(serverOutdir: string): string;
|
|
3
9
|
/**
|
|
4
10
|
* Publishes a complete server bundle generation without exposing mixed artifacts.
|
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
import { randomUUID } from 'node:crypto';
|
|
2
|
-
import path from '
|
|
2
|
+
import { path } from '@ecopages/file-system/path';
|
|
3
3
|
import { fileSystem } from '@ecopages/file-system';
|
|
4
|
-
/**
|
|
4
|
+
/**
|
|
5
|
+
* Creates a sibling staging directory so publication stays on one filesystem.
|
|
6
|
+
*
|
|
7
|
+
* @remarks
|
|
8
|
+
* The directory is made with a plain `mkdir` under a unique name, not `mkdtemp`, whose 0700 mode
|
|
9
|
+
* would survive the rename and leave `dist/server` unreadable to a non-root user in a deployed image.
|
|
10
|
+
*/
|
|
5
11
|
export function createServerBundleStagingDirectory(serverOutdir) {
|
|
6
12
|
const parentDir = path.dirname(serverOutdir);
|
|
7
|
-
|
|
8
|
-
|
|
13
|
+
const stagingDir = path.join(parentDir, `.${path.basename(serverOutdir)}.staging-${randomUUID()}`);
|
|
14
|
+
fileSystem.ensureDir(stagingDir);
|
|
15
|
+
return stagingDir;
|
|
9
16
|
}
|
|
10
17
|
/**
|
|
11
18
|
* Publishes a complete server bundle generation without exposing mixed artifacts.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import path from '
|
|
1
|
+
import { path } from '@ecopages/file-system/path';
|
|
2
2
|
import { resolveInternalExecutionDir } from '../utils/resolve-work-dir.js';
|
|
3
3
|
import { getBuildEntryOutput } from './build-graph.js';
|
|
4
4
|
import { buildOrThrow } from './runtime/build-queue.js';
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
export type WorkerUrlKind =
|
|
2
|
+
/** A relative literal URL of a module worker, or of a worker whose options cannot be read statically. */
|
|
3
|
+
'entry'
|
|
4
|
+
/** A relative literal URL of a classic worker: no options, or options whose `type` is not `'module'`. */
|
|
5
|
+
| 'classic'
|
|
6
|
+
/** A URL that is not a string literal. */
|
|
7
|
+
| 'dynamic'
|
|
8
|
+
/** A literal URL that does not start with `./` or `../`. */
|
|
9
|
+
| 'non-relative'
|
|
10
|
+
/** A relative literal URL with a query or a hash, which the build cannot name a file for. */
|
|
11
|
+
| 'query'
|
|
12
|
+
/** A Worker whose first argument is neither a string literal nor `new URL(..., import.meta.url)`, such as a variable. */
|
|
13
|
+
| 'indirect';
|
|
14
|
+
export type WorkerUrl = {
|
|
15
|
+
kind: WorkerUrlKind;
|
|
16
|
+
constructorName: 'Worker' | 'SharedWorker';
|
|
17
|
+
/** The literal URL, or the source text of a `dynamic` or `indirect` one. */
|
|
18
|
+
specifier: string;
|
|
19
|
+
/** Start offset of the URL argument of `new URL(...)`, quotes included. */
|
|
20
|
+
start: number;
|
|
21
|
+
/** End offset of the URL argument of `new URL(...)`, quotes included. */
|
|
22
|
+
end: number;
|
|
23
|
+
/** Start and end offsets of the whole `new URL(...)` expression, or of the first argument of an `indirect` one. */
|
|
24
|
+
expression: {
|
|
25
|
+
start: number;
|
|
26
|
+
end: number;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
/** Tells whether source text can hold a Worker URL, before it is parsed. */
|
|
30
|
+
export declare const WORKER_CONSTRUCTOR_PATTERN: RegExp;
|
|
31
|
+
/**
|
|
32
|
+
* Lists every `new (Shared)Worker(new URL(..., import.meta.url))` of a parsed module, in source order.
|
|
33
|
+
*
|
|
34
|
+
* @remarks
|
|
35
|
+
* Only this static bundler pattern is built; type assertions and parentheses around its parts are ignored. A Worker
|
|
36
|
+
* started from any other expression than a string literal is reported as `indirect`, so the caller can warn.
|
|
37
|
+
* `window.Worker`, `self.Worker` and `globalThis.Worker` are not read.
|
|
38
|
+
* Production builds each relative module Worker URL as its own entry and the dev transform server points it at
|
|
39
|
+
* its own module URL, so a source path never reaches the browser.
|
|
40
|
+
*/
|
|
41
|
+
export declare function findWorkerUrls(program: unknown, code: string): WorkerUrl[];
|
|
42
|
+
/** The error for a classic worker, which the build cannot serve as an ES module. */
|
|
43
|
+
export declare function formatClassicWorkerError(url: WorkerUrl, importer: string): string;
|
|
44
|
+
/** The error for a relative Worker URL with a query or a hash. */
|
|
45
|
+
export declare function formatWorkerUrlQueryError(url: WorkerUrl, importer: string): string;
|
|
46
|
+
/** Whether a Worker URL is left as written, and gets {@link formatUnbundledWorkerWarning}. */
|
|
47
|
+
export declare function isUnbundledWorkerUrl(url: WorkerUrl): boolean;
|
|
48
|
+
/** The warning for a Worker URL that is left as written. */
|
|
49
|
+
export declare function formatUnbundledWorkerWarning(url: WorkerUrl, importer: string): string;
|
|
50
|
+
/**
|
|
51
|
+
* Finds the first source file that starts a worker the build would emit, among `sourcePaths`.
|
|
52
|
+
*
|
|
53
|
+
* @remarks
|
|
54
|
+
* An inline script runs with the page's URL as `import.meta.url`, so an emitted worker's URL, which is relative to
|
|
55
|
+
* the script's own file, would resolve against the page; its owner fails instead of shipping that URL.
|
|
56
|
+
*/
|
|
57
|
+
export declare function findWorkerEntrySource(sourcePaths: readonly string[]): {
|
|
58
|
+
sourcePath: string;
|
|
59
|
+
url: WorkerUrl;
|
|
60
|
+
} | undefined;
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import { fileSystem } from '@ecopages/file-system';
|
|
2
|
+
import { parseModuleSource } from '../cache/module-parse-cache.js';
|
|
3
|
+
/** Tells whether source text can hold a Worker URL, before it is parsed. */
|
|
4
|
+
export const WORKER_CONSTRUCTOR_PATTERN = /\bnew\s+(?:Shared)?Worker\s*\(/;
|
|
5
|
+
function isNode(value) {
|
|
6
|
+
return Boolean(value) && typeof value === 'object' && typeof value.type === 'string';
|
|
7
|
+
}
|
|
8
|
+
function isIdentifier(node, name) {
|
|
9
|
+
return isNode(node) && node.type === 'Identifier' && node.name === name;
|
|
10
|
+
}
|
|
11
|
+
const TYPE_WRAPPERS = new Set([
|
|
12
|
+
'TSAsExpression',
|
|
13
|
+
'TSSatisfiesExpression',
|
|
14
|
+
'TSNonNullExpression',
|
|
15
|
+
'TSTypeAssertion',
|
|
16
|
+
'ParenthesizedExpression',
|
|
17
|
+
]);
|
|
18
|
+
/** Drops type assertions and parentheses, which do not change the value of the expression they wrap. */
|
|
19
|
+
function unwrap(value) {
|
|
20
|
+
let node = value;
|
|
21
|
+
while (isNode(node) && TYPE_WRAPPERS.has(node.type))
|
|
22
|
+
node = node.expression;
|
|
23
|
+
return node;
|
|
24
|
+
}
|
|
25
|
+
function isImportMetaUrl(value) {
|
|
26
|
+
const node = unwrap(value);
|
|
27
|
+
if (!isNode(node) || node.type !== 'MemberExpression' || node.computed)
|
|
28
|
+
return false;
|
|
29
|
+
const object = node.object;
|
|
30
|
+
return (isNode(object) &&
|
|
31
|
+
object.type === 'MetaProperty' &&
|
|
32
|
+
isIdentifier(object.meta, 'import') &&
|
|
33
|
+
isIdentifier(object.property, 'meta') &&
|
|
34
|
+
isIdentifier(node.property, 'url'));
|
|
35
|
+
}
|
|
36
|
+
function readLiteralString(node) {
|
|
37
|
+
if (node.type === 'Literal' && typeof node.value === 'string')
|
|
38
|
+
return node.value;
|
|
39
|
+
if (node.type === 'TemplateLiteral' && Array.isArray(node.expressions) && node.expressions.length === 0) {
|
|
40
|
+
const [quasi] = node.quasis;
|
|
41
|
+
return quasi?.value.cooked ?? undefined;
|
|
42
|
+
}
|
|
43
|
+
return undefined;
|
|
44
|
+
}
|
|
45
|
+
function readPropertyName(property) {
|
|
46
|
+
if (property.computed)
|
|
47
|
+
return undefined;
|
|
48
|
+
const key = property.key;
|
|
49
|
+
if (!isNode(key))
|
|
50
|
+
return undefined;
|
|
51
|
+
if (key.type === 'Identifier')
|
|
52
|
+
return key.name;
|
|
53
|
+
return readLiteralString(key);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Whether the worker options make it a classic worker.
|
|
57
|
+
*
|
|
58
|
+
* @remarks
|
|
59
|
+
* Options that are not an object literal, a `type` that is not a literal, and a spread whose `type` is unknown
|
|
60
|
+
* all count as a module worker: the build cannot tell, and an author who wrote them chose the options at run time.
|
|
61
|
+
*/
|
|
62
|
+
function isClassicWorker(options) {
|
|
63
|
+
if (options === undefined)
|
|
64
|
+
return true;
|
|
65
|
+
if (!isNode(options) || options.type !== 'ObjectExpression')
|
|
66
|
+
return false;
|
|
67
|
+
const properties = options.properties;
|
|
68
|
+
const typeProperty = properties.find((property) => property.type === 'Property' && readPropertyName(property) === 'type');
|
|
69
|
+
if (!typeProperty)
|
|
70
|
+
return !properties.some((property) => property.type === 'SpreadElement');
|
|
71
|
+
const value = typeProperty.value;
|
|
72
|
+
if (!isNode(value))
|
|
73
|
+
return false;
|
|
74
|
+
const literal = readLiteralString(value);
|
|
75
|
+
return literal !== undefined && literal !== 'module';
|
|
76
|
+
}
|
|
77
|
+
function isRelativeSpecifier(specifier) {
|
|
78
|
+
return specifier.startsWith('./') || specifier.startsWith('../');
|
|
79
|
+
}
|
|
80
|
+
function readWorkerUrl(node, code) {
|
|
81
|
+
const callee = node.callee;
|
|
82
|
+
const constructorName = isIdentifier(callee, 'Worker')
|
|
83
|
+
? 'Worker'
|
|
84
|
+
: isIdentifier(callee, 'SharedWorker')
|
|
85
|
+
? 'SharedWorker'
|
|
86
|
+
: undefined;
|
|
87
|
+
if (!constructorName)
|
|
88
|
+
return undefined;
|
|
89
|
+
const [firstArgument, options] = node.arguments;
|
|
90
|
+
const urlExpression = unwrap(firstArgument);
|
|
91
|
+
if (!isNode(firstArgument) || !isNode(urlExpression))
|
|
92
|
+
return undefined;
|
|
93
|
+
const [url, base] = urlExpression.type === 'NewExpression' && isIdentifier(urlExpression.callee, 'URL')
|
|
94
|
+
? urlExpression.arguments.map(unwrap)
|
|
95
|
+
: [];
|
|
96
|
+
if (!isNode(url) || !isImportMetaUrl(base)) {
|
|
97
|
+
if (readLiteralString(urlExpression) !== undefined)
|
|
98
|
+
return undefined;
|
|
99
|
+
const span = { start: firstArgument.start, end: firstArgument.end };
|
|
100
|
+
return {
|
|
101
|
+
kind: 'indirect',
|
|
102
|
+
constructorName,
|
|
103
|
+
specifier: code.slice(span.start, span.end),
|
|
104
|
+
...span,
|
|
105
|
+
expression: span,
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
const location = {
|
|
109
|
+
constructorName,
|
|
110
|
+
start: url.start,
|
|
111
|
+
end: url.end,
|
|
112
|
+
expression: { start: urlExpression.start, end: urlExpression.end },
|
|
113
|
+
};
|
|
114
|
+
const specifier = readLiteralString(url);
|
|
115
|
+
if (specifier === undefined)
|
|
116
|
+
return { ...location, kind: 'dynamic', specifier: code.slice(url.start, url.end) };
|
|
117
|
+
if (!isRelativeSpecifier(specifier))
|
|
118
|
+
return { ...location, kind: 'non-relative', specifier };
|
|
119
|
+
if (/[?#]/.test(specifier))
|
|
120
|
+
return { ...location, kind: 'query', specifier };
|
|
121
|
+
return { ...location, kind: isClassicWorker(options) ? 'classic' : 'entry', specifier };
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Lists every `new (Shared)Worker(new URL(..., import.meta.url))` of a parsed module, in source order.
|
|
125
|
+
*
|
|
126
|
+
* @remarks
|
|
127
|
+
* Only this static bundler pattern is built; type assertions and parentheses around its parts are ignored. A Worker
|
|
128
|
+
* started from any other expression than a string literal is reported as `indirect`, so the caller can warn.
|
|
129
|
+
* `window.Worker`, `self.Worker` and `globalThis.Worker` are not read.
|
|
130
|
+
* Production builds each relative module Worker URL as its own entry and the dev transform server points it at
|
|
131
|
+
* its own module URL, so a source path never reaches the browser.
|
|
132
|
+
*/
|
|
133
|
+
export function findWorkerUrls(program, code) {
|
|
134
|
+
const urls = [];
|
|
135
|
+
const visit = (value) => {
|
|
136
|
+
if (Array.isArray(value)) {
|
|
137
|
+
for (const child of value)
|
|
138
|
+
visit(child);
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
if (!isNode(value))
|
|
142
|
+
return;
|
|
143
|
+
if (value.type === 'NewExpression') {
|
|
144
|
+
const url = readWorkerUrl(value, code);
|
|
145
|
+
if (url)
|
|
146
|
+
urls.push(url);
|
|
147
|
+
}
|
|
148
|
+
for (const [key, child] of Object.entries(value)) {
|
|
149
|
+
if (key !== 'type' && typeof child === 'object')
|
|
150
|
+
visit(child);
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
visit(program);
|
|
154
|
+
return urls.sort((left, right) => left.start - right.start);
|
|
155
|
+
}
|
|
156
|
+
/** The error for a classic worker, which the build cannot serve as an ES module. */
|
|
157
|
+
export function formatClassicWorkerError(url, importer) {
|
|
158
|
+
return `new ${url.constructorName}(new URL(${JSON.stringify(url.specifier)}, import.meta.url)) in ${importer} needs { type: 'module' }: Ecopages builds workers as ES modules.`;
|
|
159
|
+
}
|
|
160
|
+
/** The error for a relative Worker URL with a query or a hash. */
|
|
161
|
+
export function formatWorkerUrlQueryError(url, importer) {
|
|
162
|
+
return `The ${url.constructorName} URL ${JSON.stringify(url.specifier)} in ${importer} has a query or a hash: Ecopages builds the worker as its own file, so remove them.`;
|
|
163
|
+
}
|
|
164
|
+
const UNBUNDLED_REASONS = {
|
|
165
|
+
dynamic: 'is not a string literal',
|
|
166
|
+
'non-relative': 'is not relative',
|
|
167
|
+
indirect: 'is not new URL(<relative string>, import.meta.url)',
|
|
168
|
+
};
|
|
169
|
+
/** Whether a Worker URL is left as written, and gets {@link formatUnbundledWorkerWarning}. */
|
|
170
|
+
export function isUnbundledWorkerUrl(url) {
|
|
171
|
+
return url.kind in UNBUNDLED_REASONS;
|
|
172
|
+
}
|
|
173
|
+
/** The warning for a Worker URL that is left as written. */
|
|
174
|
+
export function formatUnbundledWorkerWarning(url, importer) {
|
|
175
|
+
const reason = UNBUNDLED_REASONS[url.kind];
|
|
176
|
+
return `The ${url.constructorName} URL ${url.specifier} in ${importer} ${reason}, so it is left as written and not built; it must point at a file the server serves, such as one under public/.`;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Finds the first source file that starts a worker the build would emit, among `sourcePaths`.
|
|
180
|
+
*
|
|
181
|
+
* @remarks
|
|
182
|
+
* An inline script runs with the page's URL as `import.meta.url`, so an emitted worker's URL, which is relative to
|
|
183
|
+
* the script's own file, would resolve against the page; its owner fails instead of shipping that URL.
|
|
184
|
+
*/
|
|
185
|
+
export function findWorkerEntrySource(sourcePaths) {
|
|
186
|
+
for (const sourcePath of sourcePaths) {
|
|
187
|
+
if (sourcePath.includes('/node_modules/') || !fileSystem.exists(sourcePath))
|
|
188
|
+
continue;
|
|
189
|
+
const code = fileSystem.readFileSync(sourcePath).toString();
|
|
190
|
+
if (!WORKER_CONSTRUCTOR_PATTERN.test(code))
|
|
191
|
+
continue;
|
|
192
|
+
const url = findWorkerUrls(parseModuleSource(sourcePath, code, { sourceType: 'module' }).program, code).find((candidate) => candidate.kind === 'entry');
|
|
193
|
+
if (url)
|
|
194
|
+
return { sourcePath, url };
|
|
195
|
+
}
|
|
196
|
+
return undefined;
|
|
197
|
+
}
|
package/src/build.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export { createBrowserRuntimePlugin, DEFAULT_BROWSER_RUNTIME_PLUGIN_NAME, getBrowserRuntimeManifestFromPlugin, } from './build/browser/browser-runtime-plugin.js';
|
|
3
|
-
export { getHostScopedJsxOwnershipPlugins } from './build/browser/jsx-ownership-plugins.js';
|
|
1
|
+
export { findJsxExtensionOwner, getHostScopedJsxOwnershipPlugins } from './build/browser/jsx-ownership-plugins.js';
|
|
4
2
|
export { isLitStaticRenderWorkerThread } from './build/browser/lit-static-render-worker-context.js';
|
|
5
|
-
export {
|
|
3
|
+
export { restoreProductionBrowserBuild } from './static-site-generator/production-page-browser-graph-prebuild.js';
|
|
4
|
+
export { type BuildAdapter, type BuildExecutor, type BuildOptions, type BuildResult, resolveIntegrationDependencies, setupAppRuntimeIntegrations, setupAppRuntimePlugins, teardownAppRuntimeIntegrations, } from './build/build-adapter.js';
|
|
6
5
|
export { CONTENT_COMPONENT_VIRTUAL_MODULE_PATTERN, CONTENT_SERVER_VIRTUAL_MODULE_PATTERN, CONTENT_VIRTUAL_MODULE_PATTERN, CONTENT_VIRTUAL_MODULE_PREFIX, isContentServerVirtualModule, parseCollectionSpecifier, type ParsedCollectionSpecifier, } from './build/contracts/content-virtual-modules.js';
|
|
7
6
|
export { isServerOnlyModuleSpecifier } from './build/contracts/server-only-specifier.js';
|
|
8
7
|
export { shouldBuildPagesUnifiedGraph } from './build/cache/pages-unified-graph-build.js';
|
|
@@ -13,9 +12,12 @@ export { parseModuleSource, recordModuleTransformProfile } from './cache/index.j
|
|
|
13
12
|
export { GENERATED_BASE_PATHS, RESOLVED_ASSETS_DIR } from './constants.js';
|
|
14
13
|
export { ECOPAGES_DEV_RESTART_EXIT_CODE, ECOPAGES_DEV_RESTART_REASON_ENV, ECOPAGES_ENTRY_WATCH_ENV, getDevEnvFileNames, resolveDevelopmentRecoveryWatch, } from './dev/development-restart.js';
|
|
15
14
|
export { createRequestPipelineMetricsState, recordCollectionBuild, recordMdxTransform, type RequestPipelineMetricsState, } from './diagnostics/request-pipeline-metrics.js';
|
|
15
|
+
export { findIntegrationForFile } from './plugins/find-integration-for-file.js';
|
|
16
16
|
export { toPackageRootSpecifier } from './plugins/package-specifier.js';
|
|
17
|
-
export { loadTsconfigPathPrefixes, matchesTsconfigPathPrefix } from './plugins/tsconfig-import-resolver.js';
|
|
17
|
+
export { loadTsconfigPathPrefixes, matchesTsconfigPathPrefix, resolveProjectModulePath, } from './plugins/tsconfig-import-resolver.js';
|
|
18
|
+
export { ENTRY_COMMAND_FLAGS, getEntryCommandFlagNames, type EntryCommandFlagName, } from './utils/entry-command-flags.js';
|
|
18
19
|
export { contentHash } from './utils/content-hash.js';
|
|
20
|
+
export { toRootRelativePath } from './utils/root-relative-path.js';
|
|
19
21
|
export { isPathInside } from './utils/path-containment.js';
|
|
20
22
|
export { CLIENT_OUTPUT_DIR, SERVER_BUNDLE_DIR, SERVER_BUNDLE_FILENAME } from './utils/resolve-entry-file.js';
|
|
21
23
|
export { getEcopagesEnv, isDevelopmentRuntime, isEcopagesEnvDisabled, isEcopagesEnvEnabled, isProductionRuntime, type EcopagesBooleanEnvironmentVariable, type EcopagesEnvironmentVariable, } from './env.js';
|
package/src/build.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export { createBrowserRuntimePlugin, DEFAULT_BROWSER_RUNTIME_PLUGIN_NAME, getBrowserRuntimeManifestFromPlugin, } from './build/browser/browser-runtime-plugin.js';
|
|
3
|
-
export { getHostScopedJsxOwnershipPlugins } from './build/browser/jsx-ownership-plugins.js';
|
|
1
|
+
export { findJsxExtensionOwner, getHostScopedJsxOwnershipPlugins } from './build/browser/jsx-ownership-plugins.js';
|
|
4
2
|
export { isLitStaticRenderWorkerThread } from './build/browser/lit-static-render-worker-context.js';
|
|
5
|
-
export {
|
|
3
|
+
export { restoreProductionBrowserBuild } from './static-site-generator/production-page-browser-graph-prebuild.js';
|
|
4
|
+
export { resolveIntegrationDependencies, setupAppRuntimeIntegrations, setupAppRuntimePlugins, teardownAppRuntimeIntegrations, } from './build/build-adapter.js';
|
|
6
5
|
export { CONTENT_COMPONENT_VIRTUAL_MODULE_PATTERN, CONTENT_SERVER_VIRTUAL_MODULE_PATTERN, CONTENT_VIRTUAL_MODULE_PATTERN, CONTENT_VIRTUAL_MODULE_PREFIX, isContentServerVirtualModule, parseCollectionSpecifier, } from './build/contracts/content-virtual-modules.js';
|
|
7
6
|
export { isServerOnlyModuleSpecifier } from './build/contracts/server-only-specifier.js';
|
|
8
7
|
export { shouldBuildPagesUnifiedGraph } from './build/cache/pages-unified-graph-build.js';
|
|
@@ -13,9 +12,12 @@ export { parseModuleSource, recordModuleTransformProfile } from './cache/index.j
|
|
|
13
12
|
export { GENERATED_BASE_PATHS, RESOLVED_ASSETS_DIR } from './constants.js';
|
|
14
13
|
export { ECOPAGES_DEV_RESTART_EXIT_CODE, ECOPAGES_DEV_RESTART_REASON_ENV, ECOPAGES_ENTRY_WATCH_ENV, getDevEnvFileNames, resolveDevelopmentRecoveryWatch, } from './dev/development-restart.js';
|
|
15
14
|
export { createRequestPipelineMetricsState, recordCollectionBuild, recordMdxTransform, } from './diagnostics/request-pipeline-metrics.js';
|
|
15
|
+
export { findIntegrationForFile } from './plugins/find-integration-for-file.js';
|
|
16
16
|
export { toPackageRootSpecifier } from './plugins/package-specifier.js';
|
|
17
|
-
export { loadTsconfigPathPrefixes, matchesTsconfigPathPrefix } from './plugins/tsconfig-import-resolver.js';
|
|
17
|
+
export { loadTsconfigPathPrefixes, matchesTsconfigPathPrefix, resolveProjectModulePath, } from './plugins/tsconfig-import-resolver.js';
|
|
18
|
+
export { ENTRY_COMMAND_FLAGS, getEntryCommandFlagNames, } from './utils/entry-command-flags.js';
|
|
18
19
|
export { contentHash } from './utils/content-hash.js';
|
|
20
|
+
export { toRootRelativePath } from './utils/root-relative-path.js';
|
|
19
21
|
export { isPathInside } from './utils/path-containment.js';
|
|
20
22
|
export { CLIENT_OUTPUT_DIR, SERVER_BUNDLE_DIR, SERVER_BUNDLE_FILENAME } from './utils/resolve-entry-file.js';
|
|
21
23
|
export { getEcopagesEnv, isDevelopmentRuntime, isEcopagesEnvDisabled, isEcopagesEnvEnabled, isProductionRuntime, } from './env.js';
|
|
@@ -13,13 +13,13 @@
|
|
|
13
13
|
* mtime-hashed so that `touch`/`utimes` does not invalidate a
|
|
14
14
|
* still-valid parse.
|
|
15
15
|
*/
|
|
16
|
-
import {
|
|
16
|
+
import { path } from '@ecopages/file-system/path';
|
|
17
17
|
import { parseSync } from 'oxc-parser';
|
|
18
18
|
import { contentHash } from '../utils/content-hash.js';
|
|
19
19
|
const DEFAULT_MAX_ENTRIES = 10_000;
|
|
20
20
|
/** Resolves the Oxc dialect for a source module from its file extension. */
|
|
21
21
|
function parserLanguageForFile(filePath) {
|
|
22
|
-
const extension = extname(filePath).toLowerCase();
|
|
22
|
+
const extension = path.extname(filePath).toLowerCase();
|
|
23
23
|
if (extension === '.tsx')
|
|
24
24
|
return 'tsx';
|
|
25
25
|
if (extension === '.ts' || extension === '.mts' || extension === '.cts')
|
|
@@ -1,2 +1,10 @@
|
|
|
1
1
|
/** Shared attribute used to keep DOM elements across page navigations. */
|
|
2
2
|
export declare const ECO_PERSIST_ATTRIBUTE = "data-eco-persist";
|
|
3
|
+
/**
|
|
4
|
+
* Marks a head script as an Integration's global script, such as Lit's hydration support.
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* A client navigation loads the marked scripts of the next document before it imports that Page's modules or swaps
|
|
8
|
+
* its markup, so a Component the Page imports finds the global hook it relies on already in place.
|
|
9
|
+
*/
|
|
10
|
+
export declare const ECO_GLOBAL_SCRIPT_ATTRIBUTE = "data-eco-global-script";
|