@ecopages/core 0.6.0 → 0.7.0
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 +20 -3
- package/src/router/client/navigation-coordinator.d.ts +18 -0
- package/src/router/client/navigation-coordinator.js +14 -0
- package/src/router/client/navigation-head-order.fixture.css +3 -0
- package/src/router/client/navigation-head.d.ts +2 -1
- package/src/router/client/navigation-head.fixture.css +3 -0
- package/src/router/client/navigation-head.js +222 -39
- package/src/router/client/navigation-lifecycle.d.ts +8 -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
|
@@ -4,13 +4,12 @@
|
|
|
4
4
|
* `ecopages build` emits every server entry into `dist/server/` and writes
|
|
5
5
|
* `server-modules.json`. `ecopages start` imports those modules and never compiles.
|
|
6
6
|
*/
|
|
7
|
-
import path from '
|
|
8
|
-
import { pathToFileURL } from 'node:url';
|
|
7
|
+
import { path } from '@ecopages/file-system/path';
|
|
9
8
|
import { fileSystem } from '@ecopages/file-system';
|
|
10
9
|
import { isEcopagesEnvDisabled } from '../../env.js';
|
|
11
10
|
import { isProductionRuntime } from '../../utils/runtime.js';
|
|
12
11
|
import { requireAppRuntime } from '../../utils/app-runtime.js';
|
|
13
|
-
import { setupAppRuntimeIntegrations } from '../app-build-manifest-runtime.js';
|
|
12
|
+
import { requireBrowserBuildGlobalScriptResolution, setupAppRuntimeIntegrations, } from '../app-build-manifest-runtime.js';
|
|
14
13
|
import { appLogger } from '../../global/app-logger.js';
|
|
15
14
|
import { findIntegrationForFile } from '../../plugins/find-integration-for-file.js';
|
|
16
15
|
import { buildOrThrow } from '../runtime/build-queue.js';
|
|
@@ -18,7 +17,7 @@ import { createServerBuildRequest } from '../runtime/build-request-policy.js';
|
|
|
18
17
|
import { getBuildEntryOutput } from '../build-graph.js';
|
|
19
18
|
import { contentHash } from '../../utils/content-hash.js';
|
|
20
19
|
import { toRootRelativePath } from '../../utils/root-relative-path.js';
|
|
21
|
-
import { loadProductionServerModules,
|
|
20
|
+
import { loadProductionServerModules, writeProductionServerModulesManifest, } from '../server/server-modules-manifest.js';
|
|
22
21
|
import { getServerBundleOutputPaths } from '../server-bundle-deploy-manifest.js';
|
|
23
22
|
import { ensureProductionBuildId } from '../production-build-id.js';
|
|
24
23
|
import { collectServerModuleEntries, collectSsrScriptPaths, isRolldownServerModuleEntry, } from './server-module-entries.js';
|
|
@@ -85,47 +84,12 @@ function reviveCompiledPageModuleFromDisk(appConfig, filePath, outputPath) {
|
|
|
85
84
|
filePath,
|
|
86
85
|
});
|
|
87
86
|
}
|
|
88
|
-
/**
|
|
89
|
-
* Points `identity.file` at the current app root when the emitted module still
|
|
90
|
-
* names the build machine, so a copied `dist/` does not read that path.
|
|
91
|
-
*
|
|
92
|
-
* @remarks
|
|
93
|
-
* Relative `dependencies.scripts` resolve from this directory, so the remap
|
|
94
|
-
* keeps the source key. Emitting the module path here breaks the asset
|
|
95
|
-
* pipeline (`./hello.script.ts` would resolve under `dist/server/`).
|
|
96
|
-
*/
|
|
97
|
-
function remapProductionIdentityFile(identity, appConfig) {
|
|
98
|
-
if (!identity?.file) {
|
|
99
|
-
return;
|
|
100
|
-
}
|
|
101
|
-
const manifest = loadProductionServerModules(appConfig);
|
|
102
|
-
if (!manifest) {
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
105
|
-
const key = matchProductionModuleKey(appConfig.rootDir, identity.file, manifest.modules);
|
|
106
|
-
if (key) {
|
|
107
|
-
identity.file = path.resolve(appConfig.rootDir, key);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
function remapLoadedModuleIdentities(loaded, appConfig) {
|
|
111
|
-
for (const value of Object.values(loaded)) {
|
|
112
|
-
if ((typeof value !== 'object' && typeof value !== 'function') || value === null) {
|
|
113
|
-
continue;
|
|
114
|
-
}
|
|
115
|
-
const record = value;
|
|
116
|
-
remapProductionIdentityFile(record.config?.identity ?? record.identity, appConfig);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
87
|
export async function importEmittedServerModule(appConfig, filePath, outputPath) {
|
|
120
88
|
const owner = findIntegrationForFile(appConfig.integrations, path.normalize(filePath));
|
|
121
89
|
if (owner?.reviveCompiledPageModule) {
|
|
122
90
|
return reviveCompiledPageModuleFromDisk(appConfig, filePath, outputPath);
|
|
123
91
|
}
|
|
124
|
-
|
|
125
|
-
if (loaded && typeof loaded === 'object') {
|
|
126
|
-
remapLoadedModuleIdentities(loaded, appConfig);
|
|
127
|
-
}
|
|
128
|
-
return loaded;
|
|
92
|
+
return (await import(/* @vite-ignore */ path.toFileUrl(outputPath).href));
|
|
129
93
|
}
|
|
130
94
|
async function emitRolldownServerModules(appConfig, entryPaths, outdir) {
|
|
131
95
|
if (entryPaths.length === 0) {
|
|
@@ -171,7 +135,7 @@ async function importEmittedModules(manifest, sourceKeys) {
|
|
|
171
135
|
if (!relativePath) {
|
|
172
136
|
continue;
|
|
173
137
|
}
|
|
174
|
-
modules.push(await import(/* @vite-ignore */
|
|
138
|
+
modules.push(await import(/* @vite-ignore */ path.toFileUrl(path.join(manifest.outdir, relativePath)).href));
|
|
175
139
|
}
|
|
176
140
|
return modules;
|
|
177
141
|
}
|
|
@@ -192,7 +156,7 @@ function assignProductionServerModules(appConfig, manifest) {
|
|
|
192
156
|
*/
|
|
193
157
|
export async function emitProductionServerModules(options) {
|
|
194
158
|
const appConfig = options.appConfig;
|
|
195
|
-
|
|
159
|
+
requireBrowserBuildGlobalScriptResolution(appConfig);
|
|
196
160
|
await setupAppRuntimeIntegrations({ appConfig });
|
|
197
161
|
const outdir = path.resolve(options.outdir ?? getServerBundleOutputPaths(appConfig).serverOutdir);
|
|
198
162
|
fileSystem.ensureDir(outdir);
|
|
@@ -217,7 +181,7 @@ export async function emitProductionServerModules(options) {
|
|
|
217
181
|
modules,
|
|
218
182
|
};
|
|
219
183
|
assignProductionServerModules(appConfig, manifest);
|
|
220
|
-
const discoveredScripts = collectSsrScriptPaths(await importEmittedModules(manifest, rolldownEntries.map((entryPath) => toRootRelativePath(appConfig.rootDir, entryPath)))).filter((scriptPath) => fileSystem.exists(scriptPath) && !(toRootRelativePath(appConfig.rootDir, scriptPath) in modules));
|
|
184
|
+
const discoveredScripts = collectSsrScriptPaths(await importEmittedModules(manifest, rolldownEntries.map((entryPath) => toRootRelativePath(appConfig.rootDir, entryPath))), appConfig.rootDir).filter((scriptPath) => fileSystem.exists(scriptPath) && !(toRootRelativePath(appConfig.rootDir, scriptPath) in modules));
|
|
221
185
|
if (discoveredScripts.length > 0) {
|
|
222
186
|
const scriptsToEmit = [];
|
|
223
187
|
for (const scriptPath of discoveredScripts) {
|
|
@@ -32,4 +32,4 @@ export declare function collectServerModuleEntries(options: {
|
|
|
32
32
|
/**
|
|
33
33
|
* Walks compiled Page, Layout, and view modules for `ssr: true` script paths.
|
|
34
34
|
*/
|
|
35
|
-
export declare function collectSsrScriptPaths(modules: readonly unknown[]): string[];
|
|
35
|
+
export declare function collectSsrScriptPaths(modules: readonly unknown[], rootDir: string): string[];
|
|
@@ -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 { getComponentIdentity } from '../../eco/component-identity.js';
|
|
4
4
|
import { isEcoDeclaredComponent } from '../../eco/eco-declared-component.js';
|
|
@@ -67,9 +67,9 @@ export async function collectServerModuleEntries(options) {
|
|
|
67
67
|
}
|
|
68
68
|
return [...entries];
|
|
69
69
|
}
|
|
70
|
-
function addSsrScripts(component, scripts) {
|
|
70
|
+
function addSsrScripts(component, rootDir, scripts) {
|
|
71
71
|
const identity = getComponentIdentity(component);
|
|
72
|
-
const ownerDir = identity?.file ? path.dirname(identity.file) : undefined;
|
|
72
|
+
const ownerDir = identity?.file ? path.dirname(path.resolve(rootDir, identity.file)) : undefined;
|
|
73
73
|
if (!ownerDir) {
|
|
74
74
|
return;
|
|
75
75
|
}
|
|
@@ -79,31 +79,31 @@ function addSsrScripts(component, scripts) {
|
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
|
-
function collectSsrScriptsFromComponent(component, seen, scripts) {
|
|
82
|
+
function collectSsrScriptsFromComponent(component, rootDir, seen, scripts) {
|
|
83
83
|
if (!component || seen.has(component) || !isEcoDeclaredComponent(component)) {
|
|
84
84
|
return;
|
|
85
85
|
}
|
|
86
86
|
seen.add(component);
|
|
87
87
|
const ecoComponent = component;
|
|
88
|
-
addSsrScripts(ecoComponent, scripts);
|
|
88
|
+
addSsrScripts(ecoComponent, rootDir, scripts);
|
|
89
89
|
for (const related of ecoComponent.config?.layouts ?? []) {
|
|
90
|
-
collectSsrScriptsFromComponent(related, seen, scripts);
|
|
90
|
+
collectSsrScriptsFromComponent(related, rootDir, seen, scripts);
|
|
91
91
|
}
|
|
92
92
|
for (const related of ecoComponent.config?.dependencies?.components ?? []) {
|
|
93
|
-
collectSsrScriptsFromComponent(related, seen, scripts);
|
|
93
|
+
collectSsrScriptsFromComponent(related, rootDir, seen, scripts);
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
96
|
/**
|
|
97
97
|
* Walks compiled Page, Layout, and view modules for `ssr: true` script paths.
|
|
98
98
|
*/
|
|
99
|
-
export function collectSsrScriptPaths(modules) {
|
|
99
|
+
export function collectSsrScriptPaths(modules, rootDir) {
|
|
100
100
|
const scripts = new Set();
|
|
101
101
|
const seen = new Set();
|
|
102
102
|
for (const module of modules) {
|
|
103
103
|
if (!module || typeof module !== 'object') {
|
|
104
104
|
continue;
|
|
105
105
|
}
|
|
106
|
-
collectSsrScriptsFromComponent(module.default, seen, scripts);
|
|
106
|
+
collectSsrScriptsFromComponent(module.default, rootDir, seen, scripts);
|
|
107
107
|
}
|
|
108
108
|
return [...scripts];
|
|
109
109
|
}
|
|
@@ -11,13 +11,22 @@ export interface BuildOutput {
|
|
|
11
11
|
export interface BuildDependencyGraph {
|
|
12
12
|
/**
|
|
13
13
|
* Each entry's resolved absolute path, mapped to its static and dynamic source
|
|
14
|
-
* module closure, including inlined and tree-shaken imports and the entry itself
|
|
14
|
+
* module closure, including inlined and tree-shaken imports and the entry itself,
|
|
15
|
+
* plus the files a plugin declared with `addWatchFile` for a module in it.
|
|
15
16
|
*
|
|
16
17
|
* @remarks
|
|
17
18
|
* Production caches hash these files to decide reuse, so an omitted module leaves stale output after it
|
|
18
19
|
* changes.
|
|
19
20
|
*/
|
|
20
21
|
entrypoints: Record<string, string[]>;
|
|
22
|
+
/**
|
|
23
|
+
* Resolved paths of the entries whose own module the bundler detected as CommonJS.
|
|
24
|
+
*
|
|
25
|
+
* @remarks
|
|
26
|
+
* Such an entry's output has a default export, `module.exports`, and no named exports. The development vendor
|
|
27
|
+
* graph reads it so importers can take named bindings from the default export.
|
|
28
|
+
*/
|
|
29
|
+
commonJsEntrypoints?: string[];
|
|
21
30
|
}
|
|
22
31
|
/**
|
|
23
32
|
* One error or warning of a build.
|
|
@@ -46,17 +55,6 @@ export interface BuildSuccess {
|
|
|
46
55
|
outputs: BuildOutput[];
|
|
47
56
|
/** Warnings reported by the bundler. */
|
|
48
57
|
warnings: BuildLog[];
|
|
49
|
-
/** Absolute filesystem paths recorded by plugin load hooks during this build. */
|
|
50
|
-
loadedInputs: string[];
|
|
51
|
-
/**
|
|
52
|
-
* Filesystem inputs recorded by each plugin-loaded module in this build.
|
|
53
|
-
*
|
|
54
|
-
* @remarks
|
|
55
|
-
* Cache owners use module ownership to keep plugin inputs scoped to their
|
|
56
|
-
* own entry closure, including when one entry's plugin explicitly reads a
|
|
57
|
-
* file that another entry loads as a source module.
|
|
58
|
-
*/
|
|
59
|
-
loadedInputsByModule: Record<string, string[]>;
|
|
60
58
|
dependencyGraph: BuildDependencyGraph;
|
|
61
59
|
/**
|
|
62
60
|
* Emitted absolute output paths keyed by the entry path or name the caller
|
|
@@ -139,6 +137,55 @@ export interface BuildOptions {
|
|
|
139
137
|
sideEffects?: boolean;
|
|
140
138
|
};
|
|
141
139
|
plugins?: EcoBuildPlugin[];
|
|
140
|
+
/**
|
|
141
|
+
* How the build compiles the stylesheets its modules import; defaults to `.css` files exported as written.
|
|
142
|
+
*
|
|
143
|
+
* @remarks
|
|
144
|
+
* Server and browser requests set it from the app: the extensions of the registered stylesheet Processor (see
|
|
145
|
+
* `StylesheetKinds`) and core's `compileStylesheetModule`, so both environments give an import the same CSS.
|
|
146
|
+
*/
|
|
147
|
+
stylesheets?: BuildStylesheets;
|
|
148
|
+
/**
|
|
149
|
+
* Builds each `new Worker(new URL('./x.js', import.meta.url), { type: 'module' })`, and the same with
|
|
150
|
+
* `SharedWorker`, as its own entry and points the URL at the emitted file. Browser builds only; defaults to `true`.
|
|
151
|
+
*
|
|
152
|
+
* @remarks
|
|
153
|
+
* The dev transform server sets `false`: it compiles one module at a time and points the URL at its own module URL.
|
|
154
|
+
*/
|
|
155
|
+
workerEntries?: boolean;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* The stylesheets of one build request and the compiler of the module a binding import of one receives.
|
|
159
|
+
*
|
|
160
|
+
* @remarks
|
|
161
|
+
* Only `extensions` is part of the request identity: `compileModule` is the app's one stylesheet compiler, the same
|
|
162
|
+
* for every request of the app.
|
|
163
|
+
*/
|
|
164
|
+
export interface BuildStylesheets {
|
|
165
|
+
/** The lowercase, dotted stylesheet extensions. */
|
|
166
|
+
readonly extensions: readonly string[];
|
|
167
|
+
/** Whether `file` names a CSS Module, by the same rule as `StylesheetKinds.isCssModule`; defaults to `.module.css`. */
|
|
168
|
+
isCssModule?(file: string): boolean;
|
|
169
|
+
/**
|
|
170
|
+
* Compiles the stylesheet at `file` into ES module code whose default export is its processed CSS, with the other
|
|
171
|
+
* files that CSS inlined.
|
|
172
|
+
*
|
|
173
|
+
* @remarks
|
|
174
|
+
* The build joins `dependencies` to the module closure of each entry that imports the stylesheet, so a change to an
|
|
175
|
+
* `@import` partial rebuilds the server module that embeds it.
|
|
176
|
+
*/
|
|
177
|
+
compileModule(file: string): Promise<{
|
|
178
|
+
code: string;
|
|
179
|
+
dependencies?: readonly string[];
|
|
180
|
+
}>;
|
|
181
|
+
/**
|
|
182
|
+
* Receives the error for a package module's own side-effect stylesheet import in a browser build, which then loads
|
|
183
|
+
* an empty module. Without it, that error fails the build.
|
|
184
|
+
*
|
|
185
|
+
* @remarks
|
|
186
|
+
* Development requests set it, so `ecopages dev` warns about such a package instead of stopping.
|
|
187
|
+
*/
|
|
188
|
+
reportUndeliverable?(error: Error): void;
|
|
142
189
|
}
|
|
143
190
|
/** Compilation environment, independent of the build queue's scheduling lane. */
|
|
144
191
|
export type BuildEnvironment = 'server' | 'browser';
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import type { EcoBuildPlugin } from './build-types.js';
|
|
2
2
|
import type { BuildEnvironment } from './build-contracts.js';
|
|
3
|
-
import { type BrowserRuntimeManifest } from '../browser/browser-runtime-manifest.js';
|
|
4
3
|
/**
|
|
5
|
-
* App-owned build plugins, already selected per environment
|
|
4
|
+
* App-owned build plugins, already selected per environment.
|
|
6
5
|
*
|
|
7
6
|
* @remarks
|
|
8
7
|
* Sealed once by {@link createAppBuildManifest}. Readers take `server` or `browser` as it is and do not filter.
|
|
@@ -10,7 +9,6 @@ import { type BrowserRuntimeManifest } from '../browser/browser-runtime-manifest
|
|
|
10
9
|
export interface AppBuildManifest {
|
|
11
10
|
server: EcoBuildPlugin[];
|
|
12
11
|
browser: EcoBuildPlugin[];
|
|
13
|
-
browserRuntimeManifest: BrowserRuntimeManifest;
|
|
14
12
|
}
|
|
15
13
|
/** One plugin an app contributes to its build manifest, and who contributed it. */
|
|
16
14
|
export interface BuildPluginRegistration {
|
|
@@ -23,7 +21,6 @@ export declare function appliesToBuildEnvironment(plugin: EcoBuildPlugin, enviro
|
|
|
23
21
|
*
|
|
24
22
|
* @remarks
|
|
25
23
|
* Registration order is kept. The browser list puts the plugins that also apply to the server first, then the
|
|
26
|
-
* browser
|
|
27
|
-
* the first plugin to return a result for a resolve or load wins.
|
|
24
|
+
* browser-only plugins, because the first plugin to return a result for a resolve or load wins.
|
|
28
25
|
*/
|
|
29
|
-
export declare function createAppBuildManifest(registrations: readonly BuildPluginRegistration[]
|
|
26
|
+
export declare function createAppBuildManifest(registrations: readonly BuildPluginRegistration[]): AppBuildManifest;
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { createBrowserRuntimePlugin, DEFAULT_BROWSER_RUNTIME_PLUGIN_NAME } from '../browser/browser-runtime-plugin.js';
|
|
2
|
-
import { mergeBrowserRuntimeManifests } from '../browser/browser-runtime-manifest.js';
|
|
3
1
|
export function appliesToBuildEnvironment(plugin, environment) {
|
|
4
2
|
return plugin.environments?.includes(environment) ?? true;
|
|
5
3
|
}
|
|
@@ -28,25 +26,17 @@ function validateBuildPluginRegistrations(registrations) {
|
|
|
28
26
|
*
|
|
29
27
|
* @remarks
|
|
30
28
|
* Registration order is kept. The browser list puts the plugins that also apply to the server first, then the
|
|
31
|
-
* browser
|
|
32
|
-
* the first plugin to return a result for a resolve or load wins.
|
|
29
|
+
* browser-only plugins, because the first plugin to return a result for a resolve or load wins.
|
|
33
30
|
*/
|
|
34
|
-
export function createAppBuildManifest(registrations
|
|
31
|
+
export function createAppBuildManifest(registrations) {
|
|
35
32
|
validateBuildPluginRegistrations(registrations);
|
|
36
33
|
const plugins = registrations.map(({ plugin }) => plugin);
|
|
37
|
-
const runtimeManifest = mergeBrowserRuntimeManifests(browserRuntimeManifest);
|
|
38
|
-
const runtimePlugin = createBrowserRuntimePlugin({
|
|
39
|
-
name: DEFAULT_BROWSER_RUNTIME_PLUGIN_NAME,
|
|
40
|
-
manifest: runtimeManifest,
|
|
41
|
-
});
|
|
42
34
|
const browserPlugins = plugins.filter((plugin) => appliesToBuildEnvironment(plugin, 'browser'));
|
|
43
35
|
return {
|
|
44
36
|
server: plugins.filter((plugin) => appliesToBuildEnvironment(plugin, 'server')),
|
|
45
37
|
browser: [
|
|
46
38
|
...browserPlugins.filter((plugin) => appliesToBuildEnvironment(plugin, 'server')),
|
|
47
|
-
...(runtimePlugin ? [runtimePlugin] : []),
|
|
48
39
|
...browserPlugins.filter((plugin) => !appliesToBuildEnvironment(plugin, 'server')),
|
|
49
40
|
],
|
|
50
|
-
browserRuntimeManifest: runtimeManifest,
|
|
51
41
|
};
|
|
52
42
|
}
|
|
@@ -15,9 +15,7 @@ export const CONTENT_COMPONENT_VIRTUAL_MODULE_PATTERN = /^ecopages:content\/[a-z
|
|
|
15
15
|
export function parseCollectionSpecifier(specifier) {
|
|
16
16
|
const normalized = specifier.startsWith(`${CONTENT_VIRTUAL_MODULE_PREFIX}/`)
|
|
17
17
|
? specifier.slice(`${CONTENT_VIRTUAL_MODULE_PREFIX}/`.length)
|
|
18
|
-
:
|
|
19
|
-
? specifier.slice('content/'.length)
|
|
20
|
-
: null;
|
|
18
|
+
: null;
|
|
21
19
|
if (!normalized) {
|
|
22
20
|
return null;
|
|
23
21
|
}
|
|
@@ -28,5 +28,7 @@ export declare function realpathOfDirectory(dir: string): string;
|
|
|
28
28
|
* The filter matches the extensions this transform accepts
|
|
29
29
|
* (`.ts`, `.tsx`, `.js`, `.jsx`), so bundled `.mjs`, `.cjs`, `.mts` and
|
|
30
30
|
* `.cts` modules keep the `import.meta` of their output chunk.
|
|
31
|
+
*
|
|
32
|
+
* The `cacheKey` names `runtimeDir` relative to `rootDir`, as no plugin key may hold an absolute path.
|
|
31
33
|
*/
|
|
32
|
-
export declare function createPreserveImportMetaPlugin(runtimeDir: string): EcoBuildPlugin;
|
|
34
|
+
export declare function createPreserveImportMetaPlugin(runtimeDir: string, rootDir: string): EcoBuildPlugin;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import path from '
|
|
1
|
+
import { path } from '@ecopages/file-system/path';
|
|
2
2
|
import { fileSystem } from '@ecopages/file-system';
|
|
3
|
+
import { toRootRelativePath } from '../utils/root-relative-path.js';
|
|
3
4
|
import { parseModuleSource } from '../cache/module-parse-cache.js';
|
|
4
5
|
import { createCoreTransformPlugin, createMappedSourceTransformResult } from './mapped-source-transform.js';
|
|
5
6
|
/**
|
|
@@ -49,7 +50,7 @@ const DIRECTORY_PROPERTIES = new Set(['dirname', 'dir']);
|
|
|
49
50
|
const FILE_PROPERTIES = new Set(['filename', 'path']);
|
|
50
51
|
function collectImportMetaEdits(code, id, runtimeDir) {
|
|
51
52
|
const program = parseModuleSource(id, code, { sourceType: 'module' }).program;
|
|
52
|
-
const relativeDir = path.relative(runtimeDir, path.dirname(id))
|
|
53
|
+
const relativeDir = path.relative(runtimeDir, path.dirname(id));
|
|
53
54
|
const relativeFile = relativeDir ? `${relativeDir}/${path.basename(id)}` : `./${path.basename(id)}`;
|
|
54
55
|
const edits = [];
|
|
55
56
|
let needsNodePath = false;
|
|
@@ -112,12 +113,14 @@ function collectImportMetaEdits(code, id, runtimeDir) {
|
|
|
112
113
|
* The filter matches the extensions this transform accepts
|
|
113
114
|
* (`.ts`, `.tsx`, `.js`, `.jsx`), so bundled `.mjs`, `.cjs`, `.mts` and
|
|
114
115
|
* `.cts` modules keep the `import.meta` of their output chunk.
|
|
116
|
+
*
|
|
117
|
+
* The `cacheKey` names `runtimeDir` relative to `rootDir`, as no plugin key may hold an absolute path.
|
|
115
118
|
*/
|
|
116
|
-
export function createPreserveImportMetaPlugin(runtimeDir) {
|
|
119
|
+
export function createPreserveImportMetaPlugin(runtimeDir, rootDir) {
|
|
117
120
|
let realRuntimeDir;
|
|
118
121
|
return createCoreTransformPlugin({
|
|
119
122
|
name: 'preserve-import-meta-for-server-output',
|
|
120
|
-
cacheKey: runtimeDir,
|
|
123
|
+
cacheKey: toRootRelativePath(rootDir, runtimeDir),
|
|
121
124
|
filter: /\.[jt]sx?$/,
|
|
122
125
|
transform(code, id) {
|
|
123
126
|
if (!code.includes('import.meta')) {
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { SerializedProcessedAssetLedger } from '../assets/asset-processing-service/processed-asset-ledger.js';
|
|
2
|
+
import type { EcoPagesAppConfig } from '../config/internal-types.js';
|
|
3
|
+
export declare const PRODUCTION_ASSET_LEDGER_FILENAME = "processed-assets.json";
|
|
4
|
+
/**
|
|
5
|
+
* Everything a production build emitted for the browser, as `ecopages start` restores it.
|
|
6
|
+
*
|
|
7
|
+
* @remarks
|
|
8
|
+
* Paths are relative to the app root with POSIX separators, and HTML module-script URLs are keyed by their
|
|
9
|
+
* root-relative source, so the file serves a build moved to another folder or platform.
|
|
10
|
+
*/
|
|
11
|
+
export type ProductionAssetLedgerFile = SerializedProcessedAssetLedger & {
|
|
12
|
+
version: 4;
|
|
13
|
+
buildId: string;
|
|
14
|
+
htmlPageModuleScriptUrls: Record<string, string>;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Writes the app runtime's asset ledger, with the HTML module-script URLs of the same build, to
|
|
18
|
+
* `<distDir>/server/processed-assets.json`.
|
|
19
|
+
*
|
|
20
|
+
* @remarks
|
|
21
|
+
* The production prebuild writes it right after the app-wide browser build, so the Lit static-render worker can
|
|
22
|
+
* restore it during the export, and the build writes it again once rendering has processed every file dependency.
|
|
23
|
+
*/
|
|
24
|
+
export declare function writeProductionAssetLedger(appConfig: EcoPagesAppConfig, htmlPageModuleScriptUrls: ReadonlyMap<string, string>): void;
|
|
25
|
+
/** Removes the file a previous build wrote, so a failed build cannot leave it for `ecopages start`. */
|
|
26
|
+
export declare function clearProductionAssetLedger(appConfig: EcoPagesAppConfig): void;
|
|
27
|
+
/**
|
|
28
|
+
* Loads the record written by `ecopages build` into the app runtime's ledger, if the build wrote one.
|
|
29
|
+
*
|
|
30
|
+
* @remarks
|
|
31
|
+
* Once restored, asset processing serves every script the app-wide browser build bundled from its emitted
|
|
32
|
+
* output. Returns the HTML module-script URLs, by absolute source path.
|
|
33
|
+
*/
|
|
34
|
+
export declare function restoreProductionAssetLedger(appConfig: EcoPagesAppConfig): {
|
|
35
|
+
htmlPageModuleScriptUrls: Map<string, string>;
|
|
36
|
+
} | undefined;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { path } from '@ecopages/file-system/path';
|
|
2
|
+
import { fileSystem } from '@ecopages/file-system';
|
|
3
|
+
import { requireAppRuntime } from '../utils/app-runtime.js';
|
|
4
|
+
import { isPathStrictlyInside } from '../utils/path-containment.js';
|
|
5
|
+
import { toRootRelativePath } from '../utils/root-relative-path.js';
|
|
6
|
+
import { getServerBundleOutputPaths } from './server-bundle-deploy-manifest.js';
|
|
7
|
+
import { ensureProductionBuildId } from './production-build-id.js';
|
|
8
|
+
export const PRODUCTION_ASSET_LEDGER_FILENAME = 'processed-assets.json';
|
|
9
|
+
/** The route-shaped browser manifest earlier versions wrote instead of the asset ledger. */
|
|
10
|
+
const LEGACY_BROWSER_CLIENT_MANIFEST_FILENAME = 'browser-client-manifest.json';
|
|
11
|
+
function getLedgerPath(appConfig) {
|
|
12
|
+
return path.join(getServerBundleOutputPaths(appConfig).serverOutdir, PRODUCTION_ASSET_LEDGER_FILENAME);
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Writes the app runtime's asset ledger, with the HTML module-script URLs of the same build, to
|
|
16
|
+
* `<distDir>/server/processed-assets.json`.
|
|
17
|
+
*
|
|
18
|
+
* @remarks
|
|
19
|
+
* The production prebuild writes it right after the app-wide browser build, so the Lit static-render worker can
|
|
20
|
+
* restore it during the export, and the build writes it again once rendering has processed every file dependency.
|
|
21
|
+
*/
|
|
22
|
+
export function writeProductionAssetLedger(appConfig, htmlPageModuleScriptUrls) {
|
|
23
|
+
const runtime = requireAppRuntime(appConfig);
|
|
24
|
+
const payload = {
|
|
25
|
+
version: 4,
|
|
26
|
+
buildId: ensureProductionBuildId(appConfig),
|
|
27
|
+
...runtime.processedAssets.serialize(),
|
|
28
|
+
htmlPageModuleScriptUrls: Object.fromEntries([...htmlPageModuleScriptUrls]
|
|
29
|
+
.map(([filePath, url]) => [toRootRelativePath(appConfig.rootDir, filePath), url])
|
|
30
|
+
.sort(([left], [right]) => left.localeCompare(right))),
|
|
31
|
+
};
|
|
32
|
+
const ledgerPath = getLedgerPath(appConfig);
|
|
33
|
+
fileSystem.ensureDir(path.dirname(ledgerPath));
|
|
34
|
+
fileSystem.write(ledgerPath, `${JSON.stringify(payload, null, '\t')}\n`);
|
|
35
|
+
}
|
|
36
|
+
/** Removes the file a previous build wrote, so a failed build cannot leave it for `ecopages start`. */
|
|
37
|
+
export function clearProductionAssetLedger(appConfig) {
|
|
38
|
+
fileSystem.remove(getLedgerPath(appConfig));
|
|
39
|
+
}
|
|
40
|
+
function isRecord(value) {
|
|
41
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
42
|
+
}
|
|
43
|
+
function isStringArray(value) {
|
|
44
|
+
return Array.isArray(value) && value.every((item) => typeof item === 'string');
|
|
45
|
+
}
|
|
46
|
+
function isLedgerFile(value) {
|
|
47
|
+
return (isRecord(value) &&
|
|
48
|
+
value.version === 4 &&
|
|
49
|
+
typeof value.buildId === 'string' &&
|
|
50
|
+
Array.isArray(value.entries) &&
|
|
51
|
+
value.entries.every((entry) => isRecord(entry) && typeof entry.key === 'string' && isRecord(entry.asset)) &&
|
|
52
|
+
(value.browserOutputs === undefined || isStringArray(value.browserOutputs)) &&
|
|
53
|
+
isRecord(value.htmlPageModuleScriptUrls) &&
|
|
54
|
+
Object.values(value.htmlPageModuleScriptUrls).every((url) => typeof url === 'string'));
|
|
55
|
+
}
|
|
56
|
+
function readProductionAssetLedger(appConfig) {
|
|
57
|
+
const ledgerPath = getLedgerPath(appConfig);
|
|
58
|
+
if (!fileSystem.exists(ledgerPath)) {
|
|
59
|
+
const legacyManifestPath = path.join(path.dirname(ledgerPath), LEGACY_BROWSER_CLIENT_MANIFEST_FILENAME);
|
|
60
|
+
if (fileSystem.exists(legacyManifestPath)) {
|
|
61
|
+
throw new Error(`${path.relative(appConfig.rootDir, legacyManifestPath)} was written by an earlier version of Ecopages. Run \`ecopages build\` again.`);
|
|
62
|
+
}
|
|
63
|
+
return undefined;
|
|
64
|
+
}
|
|
65
|
+
try {
|
|
66
|
+
const parsed = JSON.parse(fileSystem.readFileSync(ledgerPath).toString());
|
|
67
|
+
if (!isLedgerFile(parsed))
|
|
68
|
+
throw new Error('unsupported ledger shape');
|
|
69
|
+
return parsed;
|
|
70
|
+
}
|
|
71
|
+
catch (error) {
|
|
72
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
73
|
+
throw new Error(`Could not read ${path.relative(appConfig.rootDir, ledgerPath)} (${detail}). Run \`ecopages build\` again.`, { cause: error });
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
function assertOutputsExist(appConfig, ledger) {
|
|
77
|
+
const htmlOutputs = Object.values(ledger.htmlPageModuleScriptUrls).map((url) => path.resolve(appConfig.absolutePaths.distDir, url.replace(/^\/+/, '').split(/[?#]/, 1)[0] ?? ''));
|
|
78
|
+
const outputs = (ledger.browserOutputs ?? []).map((output) => path.resolve(appConfig.rootDir, output));
|
|
79
|
+
for (const outputPath of [...outputs, ...htmlOutputs]) {
|
|
80
|
+
if (!isPathStrictlyInside(outputPath, appConfig.absolutePaths.distDir) || !fileSystem.exists(outputPath)) {
|
|
81
|
+
throw new Error(`The production asset ledger references missing output ${toRootRelativePath(appConfig.rootDir, outputPath)}. Run \`ecopages build\` again.`);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Loads the record written by `ecopages build` into the app runtime's ledger, if the build wrote one.
|
|
87
|
+
*
|
|
88
|
+
* @remarks
|
|
89
|
+
* Once restored, asset processing serves every script the app-wide browser build bundled from its emitted
|
|
90
|
+
* output. Returns the HTML module-script URLs, by absolute source path.
|
|
91
|
+
*/
|
|
92
|
+
export function restoreProductionAssetLedger(appConfig) {
|
|
93
|
+
const ledger = readProductionAssetLedger(appConfig);
|
|
94
|
+
if (!ledger)
|
|
95
|
+
return undefined;
|
|
96
|
+
assertOutputsExist(appConfig, ledger);
|
|
97
|
+
requireAppRuntime(appConfig).processedAssets.restore(ledger);
|
|
98
|
+
return {
|
|
99
|
+
htmlPageModuleScriptUrls: new Map(Object.entries(ledger.htmlPageModuleScriptUrls).map(([filePath, url]) => [
|
|
100
|
+
path.resolve(appConfig.rootDir, filePath),
|
|
101
|
+
url,
|
|
102
|
+
])),
|
|
103
|
+
};
|
|
104
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import path from '
|
|
1
|
+
import { path } from '@ecopages/file-system/path';
|
|
2
2
|
import { fileSystem } from '@ecopages/file-system';
|
|
3
3
|
import { SERVER_BUNDLE_DIR } from '../utils/resolve-entry-file.js';
|
|
4
4
|
import { PRODUCTION_ROUTES_FILENAME } from './production-route-list.js';
|
|
5
5
|
import { SERVER_MODULES_MANIFEST_FILENAME } from './server/server-modules-manifest.js';
|
|
6
|
-
|
|
6
|
+
import { PRODUCTION_ASSET_LEDGER_FILENAME } from './production-asset-ledger.js';
|
|
7
7
|
function describe(rootDir, filePath) {
|
|
8
8
|
return path.relative(rootDir, filePath) || '.';
|
|
9
9
|
}
|
|
@@ -64,16 +64,15 @@ function requireServerModules(rootDir, serverDir, buildId, deployManifestPath) {
|
|
|
64
64
|
}
|
|
65
65
|
requireListedFiles(rootDir, Object.values(modules), (relativePath) => path.join(serverDir, relativePath), 'server module');
|
|
66
66
|
}
|
|
67
|
-
function
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
}
|
|
67
|
+
function requireAssetLedger(rootDir, serverDir, buildId, deployManifestPath) {
|
|
68
|
+
const ledgerPath = path.join(serverDir, PRODUCTION_ASSET_LEDGER_FILENAME);
|
|
69
|
+
const ledger = requireJsonObject(rootDir, ledgerPath, 'asset ledger');
|
|
70
|
+
requireMatchingBuildId(rootDir, buildId, deployManifestPath, ledgerPath, ledger);
|
|
71
|
+
const entryOutputs = Array.isArray(ledger.entries)
|
|
72
|
+
? ledger.entries.flatMap((entry) => entry.asset?.filepath ?? [])
|
|
73
|
+
: [];
|
|
74
|
+
const browserOutputs = Array.isArray(ledger.browserOutputs) ? ledger.browserOutputs : [];
|
|
75
|
+
requireListedFiles(rootDir, [...entryOutputs, ...browserOutputs], (relativePath) => path.resolve(rootDir, relativePath), 'asset output');
|
|
77
76
|
}
|
|
78
77
|
/**
|
|
79
78
|
* Checks that `dist/` is a complete production export: one build id across its
|
|
@@ -97,5 +96,5 @@ export function assertProductionDistComplete(rootDir, distDir) {
|
|
|
97
96
|
const routeList = requireJsonObject(resolvedRoot, routeListPath, 'route list');
|
|
98
97
|
requireMatchingBuildId(resolvedRoot, buildId, deployManifestPath, routeListPath, routeList);
|
|
99
98
|
requireServerModules(resolvedRoot, serverDir, buildId, deployManifestPath);
|
|
100
|
-
|
|
99
|
+
requireAssetLedger(resolvedRoot, serverDir, buildId, deployManifestPath);
|
|
101
100
|
}
|
|
@@ -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 { toRootRelativePath } from '../utils/root-relative-path.js';
|
|
4
4
|
import { ensureProductionBuildId } from './production-build-id.js';
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import type { RolldownPlugin } from 'rolldown';
|
|
2
2
|
import type { BuildDependencyGraph } from '../build-adapter.js';
|
|
3
|
+
import type { WatchFilesByModule } from './rolldown-plugin-bridge.js';
|
|
3
4
|
/**
|
|
4
5
|
* @remarks
|
|
5
6
|
* Source dependencies come from the module graph before emission can inline or
|
|
6
7
|
* remove modules. External ids are retained as leaves for local file hashing.
|
|
8
|
+
* The files a plugin declared with `addWatchFile` for a module join the closure
|
|
9
|
+
* of every entry that holds that module. An entry whose module Rolldown detected
|
|
10
|
+
* as CommonJS is also listed in `commonJsEntrypoints`.
|
|
7
11
|
*/
|
|
8
|
-
export declare function createEntryModuleClosuresPlugin(graph: BuildDependencyGraph, root: string): RolldownPlugin;
|
|
12
|
+
export declare function createEntryModuleClosuresPlugin(graph: BuildDependencyGraph, root: string, watchFiles: WatchFilesByModule): RolldownPlugin;
|