@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
|
@@ -6,6 +6,8 @@ export type DevTransformServerOptions = {
|
|
|
6
6
|
onModuleDependencies?: (modulePath: string, dependencies: string[]) => void;
|
|
7
7
|
/** Called with the error message when a module fails to transpile, before the 500 response is returned. */
|
|
8
8
|
onTransformError?: (message: string) => void;
|
|
9
|
+
/** Called when a vendor graph rebuild changes vendor files a browser already loaded, so connected pages can reload. */
|
|
10
|
+
onVendorGraphChange?: () => void;
|
|
9
11
|
};
|
|
10
12
|
/**
|
|
11
13
|
* Serves per-module browser ESM on demand during native CLI dev.
|
|
@@ -19,22 +21,41 @@ export declare class DevTransformServer {
|
|
|
19
21
|
private readonly bundler;
|
|
20
22
|
private readonly vendorRegistry;
|
|
21
23
|
private readonly contributors;
|
|
22
|
-
private readonly runtimeSpecifierMap;
|
|
23
24
|
private readonly onModuleDependencies?;
|
|
24
25
|
private readonly onTransformError?;
|
|
25
26
|
private readonly failedSources;
|
|
26
27
|
private readonly urlToSource;
|
|
27
28
|
private readonly sourceToUrl;
|
|
29
|
+
/** Compiled modules, keyed by source path, plus the variant of a module compiled in another form. */
|
|
28
30
|
private readonly cache;
|
|
31
|
+
/**
|
|
32
|
+
* The module each source last compiled to, by cache key.
|
|
33
|
+
*
|
|
34
|
+
* @remarks
|
|
35
|
+
* A module whose compile fails keeps answering with it, so the importer still loads while the error shows in the
|
|
36
|
+
* page, and the next save that compiles replaces it. A module that never compiled answers `500`. The server only
|
|
37
|
+
* exists in `ecopages dev`, so it applies the rule of `keepsLastGoodOutput` without asking it.
|
|
38
|
+
*/
|
|
39
|
+
private readonly lastCompiled;
|
|
29
40
|
private readonly inFlight;
|
|
30
41
|
private cacheGeneration;
|
|
31
42
|
private readonly sourceGenerations;
|
|
32
43
|
private readonly extraModuleRoots;
|
|
44
|
+
private readonly stylesheetKinds;
|
|
45
|
+
private readonly installStamp;
|
|
33
46
|
constructor(options: DevTransformServerOptions);
|
|
34
47
|
registerModule(sourcePath: string): string;
|
|
35
48
|
getRegisteredSourcePath(moduleUrl: string): string | undefined;
|
|
36
49
|
addContributor(contributor: DevTransformBundleContributor): void;
|
|
37
|
-
|
|
50
|
+
/**
|
|
51
|
+
* Rewrites the imports of a module the browser loads as written, such as an unbundled content script.
|
|
52
|
+
*
|
|
53
|
+
* @remarks
|
|
54
|
+
* The rules are those of a transpiled module: a bare import becomes its vendor URL, with named imports of a
|
|
55
|
+
* CommonJS vendor read from its default export, and a project import becomes its dev-transform URL.
|
|
56
|
+
* `importerPath` resolves relative imports.
|
|
57
|
+
*/
|
|
58
|
+
rewriteImports(code: string, importerPath: string): Promise<string>;
|
|
38
59
|
private resolveVendorBundlePlugins;
|
|
39
60
|
/** Error messages of modules whose last transpile failed, since the last {@link clearFailures}. */
|
|
40
61
|
getFailureMessages(): string[];
|
|
@@ -54,8 +75,23 @@ export declare class DevTransformServer {
|
|
|
54
75
|
invalidateSource(sourcePath: string): void;
|
|
55
76
|
invalidateAll(): void;
|
|
56
77
|
reset(): void;
|
|
78
|
+
/**
|
|
79
|
+
* @remarks
|
|
80
|
+
* An asset request first checks whether packages were installed since the last one, and if so invalidates
|
|
81
|
+
* every compiled module and vendor graph, so an install during the session takes effect without a restart.
|
|
82
|
+
*/
|
|
57
83
|
tryHandleRequest(request: Request): Promise<Response | null>;
|
|
58
84
|
private resolveSourcePathFromModuleUrl;
|
|
59
85
|
private createJavaScriptResponse;
|
|
86
|
+
/**
|
|
87
|
+
* Compiles a stylesheet import into the module of its processed CSS, as server builds and bundles do.
|
|
88
|
+
*
|
|
89
|
+
* @remarks
|
|
90
|
+
* The stylesheets its CSS inlined are not reported as module dependencies: an edit to one reaches this module
|
|
91
|
+
* through the development stylesheet service, which plans the importing stylesheet as changed when its output does.
|
|
92
|
+
* Reporting them would send the partial itself to HMR, which no served module imports.
|
|
93
|
+
*/
|
|
94
|
+
private compileStylesheet;
|
|
95
|
+
private cacheKey;
|
|
60
96
|
private materialize;
|
|
61
97
|
}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import path from '
|
|
1
|
+
import { path } from '@ecopages/file-system/path';
|
|
2
2
|
import { fileSystem } from '@ecopages/file-system';
|
|
3
3
|
import { isEcopagesEnvEnabled } from '../../env.js';
|
|
4
4
|
import { appLogger } from '../../global/app-logger.js';
|
|
5
5
|
import { startupTrace } from '../../diagnostics/startup-trace.js';
|
|
6
6
|
import { DevTransformBundler } from './dev-transform-bundler.js';
|
|
7
7
|
import { DevTransformVendorRegistry } from './dev-transform-vendor-registry.js';
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
8
|
+
import { DevTransformInstallStamp } from './dev-transform-install-stamp.js';
|
|
9
|
+
import { getStylesheetKinds } from '../../plugins/stylesheet-kinds.js';
|
|
10
|
+
import { RESOLVED_ASSETS_DIR } from '../../constants.js';
|
|
11
|
+
import { compileStylesheetModule } from '../../assets/asset-processing-service/processors/stylesheet/stylesheet-module.js';
|
|
10
12
|
import { resolveWorkspacePackageWatchRoots } from '../../watchers/workspace-package-watch-roots.js';
|
|
11
13
|
import { resolveDevTransformModuleSourcePath, resolveDevTransformModuleUrl } from './dev-transform-url.js';
|
|
12
14
|
/**
|
|
@@ -21,32 +23,49 @@ export class DevTransformServer {
|
|
|
21
23
|
bundler;
|
|
22
24
|
vendorRegistry;
|
|
23
25
|
contributors = [];
|
|
24
|
-
runtimeSpecifierMap = new Map();
|
|
25
26
|
onModuleDependencies;
|
|
26
27
|
onTransformError;
|
|
27
28
|
failedSources = new Map();
|
|
28
29
|
urlToSource = new Map();
|
|
29
30
|
sourceToUrl = new Map();
|
|
31
|
+
/** Compiled modules, keyed by source path, plus the variant of a module compiled in another form. */
|
|
30
32
|
cache = new Map();
|
|
33
|
+
/**
|
|
34
|
+
* The module each source last compiled to, by cache key.
|
|
35
|
+
*
|
|
36
|
+
* @remarks
|
|
37
|
+
* A module whose compile fails keeps answering with it, so the importer still loads while the error shows in the
|
|
38
|
+
* page, and the next save that compiles replaces it. A module that never compiled answers `500`. The server only
|
|
39
|
+
* exists in `ecopages dev`, so it applies the rule of `keepsLastGoodOutput` without asking it.
|
|
40
|
+
*/
|
|
41
|
+
lastCompiled = new Map();
|
|
31
42
|
inFlight = new Map();
|
|
32
43
|
cacheGeneration = 0;
|
|
33
44
|
sourceGenerations = new Map();
|
|
34
45
|
extraModuleRoots;
|
|
46
|
+
stylesheetKinds;
|
|
47
|
+
installStamp;
|
|
35
48
|
constructor(options) {
|
|
36
49
|
this.appConfig = options.appConfig;
|
|
50
|
+
this.stylesheetKinds = getStylesheetKinds(options.appConfig);
|
|
37
51
|
this.onModuleDependencies = options.onModuleDependencies;
|
|
38
52
|
this.onTransformError = options.onTransformError;
|
|
39
53
|
this.contributors.push(...(options.contributors ?? []));
|
|
40
54
|
this.extraModuleRoots = resolveWorkspacePackageWatchRoots(this.appConfig.rootDir);
|
|
41
|
-
this.
|
|
55
|
+
this.installStamp = new DevTransformInstallStamp(this.appConfig.rootDir);
|
|
42
56
|
this.vendorRegistry = new DevTransformVendorRegistry({
|
|
43
57
|
appConfig: options.appConfig,
|
|
44
58
|
resolveVendorBundlePlugins: () => this.resolveVendorBundlePlugins(),
|
|
59
|
+
onVendorGraphChange: options.onVendorGraphChange,
|
|
45
60
|
});
|
|
61
|
+
for (const contributor of this.contributors) {
|
|
62
|
+
const vendorEntries = contributor.getVendorEntries?.();
|
|
63
|
+
if (vendorEntries)
|
|
64
|
+
this.vendorRegistry.addKnownEntries(vendorEntries);
|
|
65
|
+
}
|
|
46
66
|
this.bundler = new DevTransformBundler({
|
|
47
67
|
appConfig: options.appConfig,
|
|
48
68
|
contributors: this.contributors,
|
|
49
|
-
getRuntimeSpecifierMap: () => this.runtimeSpecifierMap,
|
|
50
69
|
vendorRegistry: this.vendorRegistry,
|
|
51
70
|
extraModuleRoots: this.extraModuleRoots,
|
|
52
71
|
});
|
|
@@ -67,14 +86,22 @@ export class DevTransformServer {
|
|
|
67
86
|
}
|
|
68
87
|
addContributor(contributor) {
|
|
69
88
|
this.contributors.push(contributor);
|
|
70
|
-
this.rebuildRuntimeSpecifierMap();
|
|
71
89
|
this.bundler.addContributor(contributor);
|
|
90
|
+
const vendorEntries = contributor.getVendorEntries?.();
|
|
91
|
+
if (vendorEntries)
|
|
92
|
+
this.vendorRegistry.addKnownEntries(vendorEntries);
|
|
72
93
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
94
|
+
/**
|
|
95
|
+
* Rewrites the imports of a module the browser loads as written, such as an unbundled content script.
|
|
96
|
+
*
|
|
97
|
+
* @remarks
|
|
98
|
+
* The rules are those of a transpiled module: a bare import becomes its vendor URL, with named imports of a
|
|
99
|
+
* CommonJS vendor read from its default export, and a project import becomes its dev-transform URL.
|
|
100
|
+
* `importerPath` resolves relative imports.
|
|
101
|
+
*/
|
|
102
|
+
async rewriteImports(code, importerPath) {
|
|
103
|
+
const rewritten = await this.bundler.rewriteImports(code, importerPath);
|
|
104
|
+
return rewritten.code;
|
|
78
105
|
}
|
|
79
106
|
async resolveVendorBundlePlugins() {
|
|
80
107
|
const plugins = [];
|
|
@@ -109,7 +136,10 @@ export class DevTransformServer {
|
|
|
109
136
|
*/
|
|
110
137
|
invalidateSource(sourcePath) {
|
|
111
138
|
const normalized = path.resolve(sourcePath);
|
|
112
|
-
this.cache.
|
|
139
|
+
for (const key of this.cache.keys()) {
|
|
140
|
+
if (key === normalized || key.startsWith(`${normalized}?`))
|
|
141
|
+
this.cache.delete(key);
|
|
142
|
+
}
|
|
113
143
|
this.sourceGenerations.set(normalized, (this.sourceGenerations.get(normalized) ?? 0) + 1);
|
|
114
144
|
}
|
|
115
145
|
invalidateAll() {
|
|
@@ -122,10 +152,20 @@ export class DevTransformServer {
|
|
|
122
152
|
reset() {
|
|
123
153
|
this.urlToSource.clear();
|
|
124
154
|
this.sourceToUrl.clear();
|
|
155
|
+
this.lastCompiled.clear();
|
|
125
156
|
this.invalidateAll();
|
|
126
157
|
}
|
|
158
|
+
/**
|
|
159
|
+
* @remarks
|
|
160
|
+
* An asset request first checks whether packages were installed since the last one, and if so invalidates
|
|
161
|
+
* every compiled module and vendor graph, so an install during the session takes effect without a restart.
|
|
162
|
+
*/
|
|
127
163
|
async tryHandleRequest(request) {
|
|
128
164
|
const url = new URL(request.url);
|
|
165
|
+
if (url.pathname.startsWith(`/${RESOLVED_ASSETS_DIR}/`) && this.installStamp.changed()) {
|
|
166
|
+
appLogger.info('[dev-transform] Installed packages changed; rebuilding browser modules and vendors');
|
|
167
|
+
this.invalidateAll();
|
|
168
|
+
}
|
|
129
169
|
const vendorResponse = await this.vendorRegistry.tryHandleVendorRequest(url.pathname, request.headers.get('If-None-Match'));
|
|
130
170
|
if (vendorResponse) {
|
|
131
171
|
return vendorResponse;
|
|
@@ -134,10 +174,11 @@ export class DevTransformServer {
|
|
|
134
174
|
if (!sourcePath) {
|
|
135
175
|
return null;
|
|
136
176
|
}
|
|
177
|
+
const variant = url.searchParams.get('eco-variant') ?? undefined;
|
|
137
178
|
startupTrace.beginDevClientTransform();
|
|
138
179
|
const startedAt = performance.now();
|
|
139
180
|
try {
|
|
140
|
-
const entry = await this.materialize(sourcePath);
|
|
181
|
+
const entry = await this.materialize(sourcePath, variant);
|
|
141
182
|
this.failedSources.delete(path.resolve(sourcePath));
|
|
142
183
|
if (isEcopagesEnvEnabled('ECOPAGES_STARTUP_TRACE')) {
|
|
143
184
|
appLogger.debug(`[dev-transform] materialize path=${url.pathname} bytes=${entry.code.length} durationMs=${Math.round(performance.now() - startedAt)}`);
|
|
@@ -148,6 +189,12 @@ export class DevTransformServer {
|
|
|
148
189
|
const message = error instanceof Error ? error.message : String(error);
|
|
149
190
|
this.failedSources.set(path.resolve(sourcePath), message);
|
|
150
191
|
this.onTransformError?.(message);
|
|
192
|
+
const lastCompiled = fileSystem.exists(sourcePath)
|
|
193
|
+
? this.lastCompiled.get(this.cacheKey(path.resolve(sourcePath), variant))
|
|
194
|
+
: undefined;
|
|
195
|
+
if (lastCompiled !== undefined) {
|
|
196
|
+
return this.createJavaScriptResponse(lastCompiled);
|
|
197
|
+
}
|
|
151
198
|
return new Response(message, {
|
|
152
199
|
status: 500,
|
|
153
200
|
headers: {
|
|
@@ -161,7 +208,7 @@ export class DevTransformServer {
|
|
|
161
208
|
}
|
|
162
209
|
}
|
|
163
210
|
resolveSourcePathFromModuleUrl(moduleUrl) {
|
|
164
|
-
const discoveredSourcePath = resolveDevTransformModuleSourcePath(this.appConfig.absolutePaths.srcDir, moduleUrl, this.extraModuleRoots);
|
|
211
|
+
const discoveredSourcePath = resolveDevTransformModuleSourcePath(this.appConfig.absolutePaths.srcDir, moduleUrl, this.extraModuleRoots, this.stylesheetKinds);
|
|
165
212
|
if (!discoveredSourcePath) {
|
|
166
213
|
return undefined;
|
|
167
214
|
}
|
|
@@ -176,37 +223,52 @@ export class DevTransformServer {
|
|
|
176
223
|
},
|
|
177
224
|
});
|
|
178
225
|
}
|
|
179
|
-
|
|
226
|
+
/**
|
|
227
|
+
* Compiles a stylesheet import into the module of its processed CSS, as server builds and bundles do.
|
|
228
|
+
*
|
|
229
|
+
* @remarks
|
|
230
|
+
* The stylesheets its CSS inlined are not reported as module dependencies: an edit to one reaches this module
|
|
231
|
+
* through the development stylesheet service, which plans the importing stylesheet as changed when its output does.
|
|
232
|
+
* Reporting them would send the partial itself to HMR, which no served module imports.
|
|
233
|
+
*/
|
|
234
|
+
async compileStylesheet(sourcePath) {
|
|
235
|
+
try {
|
|
236
|
+
return { code: (await compileStylesheetModule(this.appConfig, sourcePath)).code };
|
|
237
|
+
}
|
|
238
|
+
catch (error) {
|
|
239
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
240
|
+
throw new Error(`[dev-transform] Failed to compile stylesheet ${sourcePath}: ${message}`, { cause: error });
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
cacheKey(normalizedSourcePath, variant) {
|
|
244
|
+
return variant ? `${normalizedSourcePath}?${variant}` : normalizedSourcePath;
|
|
245
|
+
}
|
|
246
|
+
async materialize(sourcePath, variant) {
|
|
180
247
|
const normalized = path.resolve(sourcePath);
|
|
248
|
+
const cacheKey = this.cacheKey(normalized, variant);
|
|
181
249
|
if (!fileSystem.exists(normalized)) {
|
|
182
250
|
throw new Error(`[dev-transform] Missing source module: ${normalized}`);
|
|
183
251
|
}
|
|
184
252
|
const sourceHash = fileSystem.hash(normalized);
|
|
185
|
-
const cached = this.cache.get(
|
|
253
|
+
const cached = this.cache.get(cacheKey);
|
|
186
254
|
if (cached && cached.sourceHash === sourceHash) {
|
|
187
255
|
return cached;
|
|
188
256
|
}
|
|
189
|
-
const pending = this.inFlight.get(
|
|
257
|
+
const pending = this.inFlight.get(cacheKey);
|
|
190
258
|
if (pending) {
|
|
191
259
|
return pending;
|
|
192
260
|
}
|
|
193
|
-
const
|
|
194
|
-
if (moduleKind === 'stylesheet') {
|
|
195
|
-
const entry = {
|
|
196
|
-
code: materializeDevTransformStylesheet(fileSystem.readFileSync(normalized)),
|
|
197
|
-
sourceHash,
|
|
198
|
-
};
|
|
199
|
-
this.cache.set(normalized, entry);
|
|
200
|
-
return entry;
|
|
201
|
-
}
|
|
261
|
+
const isStylesheet = this.stylesheetKinds.isStylesheet(normalized);
|
|
202
262
|
const generation = this.cacheGeneration;
|
|
203
263
|
const sourceGeneration = this.sourceGenerations.get(normalized) ?? 0;
|
|
204
264
|
const isStale = () => generation !== this.cacheGeneration ||
|
|
205
265
|
sourceGeneration !== (this.sourceGenerations.get(normalized) ?? 0) ||
|
|
206
266
|
!fileSystem.exists(normalized) ||
|
|
207
267
|
fileSystem.hash(normalized) !== sourceHash;
|
|
208
|
-
const
|
|
209
|
-
.
|
|
268
|
+
const compile = isStylesheet
|
|
269
|
+
? this.compileStylesheet(normalized)
|
|
270
|
+
: this.bundler.transpileModule(normalized, variant);
|
|
271
|
+
const promise = compile
|
|
210
272
|
.then((result) => {
|
|
211
273
|
if (isStale()) {
|
|
212
274
|
return undefined;
|
|
@@ -215,7 +277,8 @@ export class DevTransformServer {
|
|
|
215
277
|
this.onModuleDependencies?.(normalized, result.dependencies);
|
|
216
278
|
}
|
|
217
279
|
const entry = { code: result.code, sourceHash };
|
|
218
|
-
this.cache.set(
|
|
280
|
+
this.cache.set(cacheKey, entry);
|
|
281
|
+
this.lastCompiled.set(cacheKey, result.code);
|
|
219
282
|
return entry;
|
|
220
283
|
})
|
|
221
284
|
.catch((error) => {
|
|
@@ -225,10 +288,10 @@ export class DevTransformServer {
|
|
|
225
288
|
throw error;
|
|
226
289
|
})
|
|
227
290
|
.finally(() => {
|
|
228
|
-
this.inFlight.delete(
|
|
291
|
+
this.inFlight.delete(cacheKey);
|
|
229
292
|
})
|
|
230
|
-
.then((entry) => entry ?? this.materialize(normalized));
|
|
231
|
-
this.inFlight.set(
|
|
293
|
+
.then((entry) => entry ?? this.materialize(normalized, variant));
|
|
294
|
+
this.inFlight.set(cacheKey, promise);
|
|
232
295
|
return promise;
|
|
233
296
|
}
|
|
234
297
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type StylesheetKinds } from '../../plugins/stylesheet-kinds.js';
|
|
1
2
|
export { DEV_TRANSFORM_URL_PREFIX } from '../../hmr/hmr-asset-paths.js';
|
|
2
3
|
/**
|
|
3
4
|
* Maps a source entrypoint to the browser URL served by the dev transform server.
|
|
@@ -5,7 +6,8 @@ export { DEV_TRANSFORM_URL_PREFIX } from '../../hmr/hmr-asset-paths.js';
|
|
|
5
6
|
* @remarks
|
|
6
7
|
* Files under `srcDir` keep path-relative URLs. Files in `extraRoots` (workspace
|
|
7
8
|
* packages) use `/assets/__eco_dev__/@fs/...` so an island outside the app folder
|
|
8
|
-
* can still hydrate.
|
|
9
|
+
* can still hydrate. The absolute path follows `@fs/` without its leading `/`, so a Windows path keeps its drive
|
|
10
|
+
* letter as the first segment (`@fs/D%3A/repo/...`).
|
|
9
11
|
*/
|
|
10
12
|
export declare function resolveDevTransformModuleUrl(srcDir: string, entrypointPath: string, extraRoots?: readonly string[]): string;
|
|
11
13
|
/**
|
|
@@ -15,4 +17,4 @@ export declare function resolveDevTransformModuleUrl(srcDir: string, entrypointP
|
|
|
15
17
|
* Client-side navigation can request page modules that were not registered during
|
|
16
18
|
* the current SSR response. Lazy resolution keeps those URLs materializable on demand.
|
|
17
19
|
*/
|
|
18
|
-
export declare function resolveDevTransformModuleSourcePath(srcDir: string, moduleUrl: string, extraRoots?: readonly string[]): string | undefined;
|
|
20
|
+
export declare function resolveDevTransformModuleSourcePath(srcDir: string, moduleUrl: string, extraRoots?: readonly string[], kinds?: StylesheetKinds): string | undefined;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import path from '
|
|
1
|
+
import { path } from '@ecopages/file-system/path';
|
|
2
2
|
import { fileSystem } from '@ecopages/file-system';
|
|
3
3
|
import { DEV_TRANSFORM_URL_PREFIX, stripModuleUrlQuery } from '../../hmr/hmr-asset-paths.js';
|
|
4
4
|
import { decodeHmrDynamicSegments, encodeHmrDynamicSegments } from '../../hmr/hmr-entrypoint-output.js';
|
|
5
5
|
import { isPathInside } from '../../utils/path-containment.js';
|
|
6
|
-
import {
|
|
6
|
+
import { PLAIN_CSS_KINDS } from '../../plugins/stylesheet-kinds.js';
|
|
7
7
|
export { DEV_TRANSFORM_URL_PREFIX } from '../../hmr/hmr-asset-paths.js';
|
|
8
8
|
const PAGE_SOURCE_EXTENSIONS = ['.tsx', '.ts', '.jsx', '.js', '.mdx', '.md'];
|
|
9
9
|
const FS_URL_SEGMENT = '@fs';
|
|
10
10
|
function toDevTransformUrlPath(relativeOrAbsolutePath) {
|
|
11
11
|
const relativePathJs = relativeOrAbsolutePath.replace(/\.(tsx?|jsx?|mdx?)$/, '.js');
|
|
12
|
-
return encodeHmrDynamicSegments(relativePathJs).split(
|
|
12
|
+
return encodeHmrDynamicSegments(relativePathJs).split('/').map(encodeURIComponent).join('/');
|
|
13
13
|
}
|
|
14
14
|
function isInsideAllowedRoot(filePath, allowedRoots) {
|
|
15
15
|
return allowedRoots.some((root) => isPathInside(filePath, root));
|
|
@@ -20,7 +20,8 @@ function isInsideAllowedRoot(filePath, allowedRoots) {
|
|
|
20
20
|
* @remarks
|
|
21
21
|
* Files under `srcDir` keep path-relative URLs. Files in `extraRoots` (workspace
|
|
22
22
|
* packages) use `/assets/__eco_dev__/@fs/...` so an island outside the app folder
|
|
23
|
-
* can still hydrate.
|
|
23
|
+
* can still hydrate. The absolute path follows `@fs/` without its leading `/`, so a Windows path keeps its drive
|
|
24
|
+
* letter as the first segment (`@fs/D%3A/repo/...`).
|
|
24
25
|
*/
|
|
25
26
|
export function resolveDevTransformModuleUrl(srcDir, entrypointPath, extraRoots = []) {
|
|
26
27
|
const resolvedSrcDir = path.resolve(srcDir);
|
|
@@ -36,8 +37,8 @@ export function resolveDevTransformModuleUrl(srcDir, entrypointPath, extraRoots
|
|
|
36
37
|
const fsPath = toDevTransformUrlPath(normalizedEntrypoint).replace(/^\//, '');
|
|
37
38
|
return `${DEV_TRANSFORM_URL_PREFIX}/${FS_URL_SEGMENT}/${fsPath}`;
|
|
38
39
|
}
|
|
39
|
-
function resolveExistingModuleFile(jsPath, allowedRoots) {
|
|
40
|
-
if (
|
|
40
|
+
function resolveExistingModuleFile(jsPath, allowedRoots, kinds) {
|
|
41
|
+
if (kinds.isStylesheet(jsPath)) {
|
|
41
42
|
if (isInsideAllowedRoot(jsPath, allowedRoots) && fileSystem.exists(jsPath)) {
|
|
42
43
|
return jsPath;
|
|
43
44
|
}
|
|
@@ -62,7 +63,7 @@ function resolveExistingModuleFile(jsPath, allowedRoots) {
|
|
|
62
63
|
* Client-side navigation can request page modules that were not registered during
|
|
63
64
|
* the current SSR response. Lazy resolution keeps those URLs materializable on demand.
|
|
64
65
|
*/
|
|
65
|
-
export function resolveDevTransformModuleSourcePath(srcDir, moduleUrl, extraRoots = []) {
|
|
66
|
+
export function resolveDevTransformModuleSourcePath(srcDir, moduleUrl, extraRoots = [], kinds = PLAIN_CSS_KINDS) {
|
|
66
67
|
const pathname = stripModuleUrlQuery(moduleUrl);
|
|
67
68
|
const prefix = `${DEV_TRANSFORM_URL_PREFIX}/`;
|
|
68
69
|
if (!pathname.startsWith(prefix)) {
|
|
@@ -79,10 +80,10 @@ export function resolveDevTransformModuleSourcePath(srcDir, moduleUrl, extraRoot
|
|
|
79
80
|
}
|
|
80
81
|
const fsPrefix = `${FS_URL_SEGMENT}/`;
|
|
81
82
|
if (relativeUrlPath.startsWith(fsPrefix)) {
|
|
82
|
-
const
|
|
83
|
-
|
|
83
|
+
const fsPath = decodeHmrDynamicSegments(relativeUrlPath.slice(fsPrefix.length));
|
|
84
|
+
const absoluteJsPath = path.resolve(path.isAbsolute(fsPath) ? fsPath : `/${fsPath}`);
|
|
85
|
+
return resolveExistingModuleFile(absoluteJsPath, allowedRoots, kinds);
|
|
84
86
|
}
|
|
85
|
-
const
|
|
86
|
-
|
|
87
|
-
return resolveExistingModuleFile(path.resolve(resolvedSrcDir, decodedRelativePathJs), allowedRoots);
|
|
87
|
+
const decodedRelativePathJs = decodeHmrDynamicSegments(relativeUrlPath);
|
|
88
|
+
return resolveExistingModuleFile(path.resolve(resolvedSrcDir, decodedRelativePathJs), allowedRoots, kinds);
|
|
88
89
|
}
|
|
@@ -1,51 +1,208 @@
|
|
|
1
1
|
import type { EcoBuildPlugin } from '../../build/contracts/build-types.js';
|
|
2
2
|
import type { EcoPagesAppConfig } from '../../config/internal-types.js';
|
|
3
|
+
import type { VendorImport } from './dev-transform-import-rewriter.js';
|
|
4
|
+
import type { DevTransformVendorEntries } from '../../types/dev-transform-types.js';
|
|
3
5
|
export type DevTransformVendorRegistryOptions = {
|
|
4
6
|
appConfig: EcoPagesAppConfig;
|
|
5
7
|
resolveVendorBundlePlugins?: () => Promise<readonly EcoBuildPlugin[]>;
|
|
8
|
+
/**
|
|
9
|
+
* Called when a vendor graph was rebuilt after a browser received output of its previous build that the new
|
|
10
|
+
* build changes or drops.
|
|
11
|
+
*
|
|
12
|
+
* @remarks
|
|
13
|
+
* A page that keeps the old chunks and loads new ones could hold two copies of one module, so the caller
|
|
14
|
+
* reloads connected pages.
|
|
15
|
+
*/
|
|
16
|
+
onVendorGraphChange?: () => void;
|
|
6
17
|
};
|
|
7
18
|
/**
|
|
8
|
-
*
|
|
19
|
+
* Prebundles bare npm imports into process-local `/assets/vendors/*` files, one code-split Rolldown build per
|
|
20
|
+
* vendor graph.
|
|
9
21
|
*
|
|
10
22
|
* @remarks
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
23
|
+
* Every known dependency entry is an entry of one build, so a file shared by two entries of a package, a package
|
|
24
|
+
* shared by two packages, and a CommonJS module required by two packages each become one shared chunk with one
|
|
25
|
+
* URL. Entry URLs are `<label>.<hash of the entry path>.js` and stay the same across rebuilds, so app modules
|
|
26
|
+
* that embed them stay valid; chunks are content-hashed and imported relatively from the same directory.
|
|
27
|
+
*
|
|
28
|
+
* A new entry rebuilds its graph after a short quiet period, which collects the bare imports of one page load
|
|
29
|
+
* into one build. The known entries are written to the app's `workDir` after each build and seed the next dev
|
|
30
|
+
* process, which then builds the full graph on its first request. Bundle contents stay in memory.
|
|
31
|
+
*
|
|
32
|
+
* A build that fails as a whole, rather than for some of its entries, keeps the previous build's outputs, so a
|
|
33
|
+
* transient failure such as one during a package install leaves working vendors serving.
|
|
15
34
|
*/
|
|
16
35
|
export declare class DevTransformVendorRegistry {
|
|
17
36
|
private readonly appConfig;
|
|
18
37
|
private readonly browserBundleService;
|
|
19
38
|
private readonly resolveVendorBundlePlugins?;
|
|
20
|
-
private
|
|
21
|
-
private
|
|
39
|
+
private readonly onVendorGraphChange?;
|
|
40
|
+
private readonly graphs;
|
|
41
|
+
private readonly entriesByUrl;
|
|
42
|
+
private generation;
|
|
43
|
+
private readonly warnedPackageCopies;
|
|
44
|
+
private persistedContents?;
|
|
22
45
|
constructor(options: DevTransformVendorRegistryOptions);
|
|
23
|
-
|
|
46
|
+
/**
|
|
47
|
+
* Returns the stable vendor URL of a bare specifier once a build of its graph that contains it finished.
|
|
48
|
+
*
|
|
49
|
+
* @param importer - The importing module's path; defaults to a module at the app root.
|
|
50
|
+
*
|
|
51
|
+
* @remarks
|
|
52
|
+
* Rejects with the prebundle error when the entry failed to build.
|
|
53
|
+
*/
|
|
54
|
+
resolveVendorUrl(specifier: string, importer?: string): Promise<string>;
|
|
55
|
+
/**
|
|
56
|
+
* Returns the vendor URL of a bare specifier imported by `importer`, and whether that build found its module to
|
|
57
|
+
* be CommonJS.
|
|
58
|
+
*
|
|
59
|
+
* @remarks
|
|
60
|
+
* The specifier resolves from the importer's directory, as Node and the production bundle resolve it, so a
|
|
61
|
+
* dependency that only the importing package declares resolves under a strict install, and two importers that
|
|
62
|
+
* reach two installed versions of one package get two entries. Importers that resolve it to the same file share
|
|
63
|
+
* one entry and one URL.
|
|
64
|
+
*
|
|
65
|
+
* A CommonJS entry is served with `module.exports` as its default export and no named exports, so the import
|
|
66
|
+
* rewriter reads named imports of it from the default export.
|
|
67
|
+
*/
|
|
68
|
+
resolveVendorImport(specifier: string, importer: string): Promise<VendorImport>;
|
|
69
|
+
private resolveVendorEntry;
|
|
24
70
|
/**
|
|
25
71
|
* @remarks
|
|
26
|
-
* A
|
|
27
|
-
*
|
|
28
|
-
*
|
|
72
|
+
* A request for a known entry whose graph is still building, or was invalidated, waits for a build that
|
|
73
|
+
* contains it. A chunk is only requested by a file that a finished build served, and a rebuild that changes a
|
|
74
|
+
* served file reports a graph change, so a chunk request does not wait. Responses carry `no-cache` and a
|
|
75
|
+
* content `ETag`, so browsers revalidate each load and get `304` while `ifNoneMatch` still matches the
|
|
76
|
+
* in-memory output.
|
|
29
77
|
*/
|
|
30
78
|
tryHandleVendorRequest(pathname: string, ifNoneMatch?: string | null): Promise<Response | null>;
|
|
79
|
+
/**
|
|
80
|
+
* Adds the entries of bare specifiers that modules are known to import, without building.
|
|
81
|
+
*
|
|
82
|
+
* @param resolveFrom - A directory inside the package that declares them, which they resolve from.
|
|
83
|
+
*
|
|
84
|
+
* @remarks
|
|
85
|
+
* Generated modules such as hydration bootstraps import their packages one request after another. Knowing
|
|
86
|
+
* them up front puts them all in the first build of their graph, so a later build does not move a module a
|
|
87
|
+
* browser already loaded into a new shared chunk and reload the page. A specifier that does not resolve is
|
|
88
|
+
* skipped.
|
|
89
|
+
*/
|
|
90
|
+
addKnownEntries({ resolveFrom, specifiers }: DevTransformVendorEntries): void;
|
|
91
|
+
/**
|
|
92
|
+
* Rebuilds every graph on its next request and resolves each known specifier again, keeping the known
|
|
93
|
+
* entries.
|
|
94
|
+
*
|
|
95
|
+
* @remarks
|
|
96
|
+
* A build that started before this call still settles for its waiters but is not kept. The last build is kept
|
|
97
|
+
* only as the fallback of a rebuild that fails as a whole. Each specifier resolves again from every directory
|
|
98
|
+
* that reached its entry, so after a package upgrade each importer moves to the file it now reaches; an entry
|
|
99
|
+
* that no source resolves any more is kept as it was. A source whose directory no longer exists, such as a
|
|
100
|
+
* deleted workspace package, is dropped, and an entry left without sources goes with it.
|
|
101
|
+
*/
|
|
31
102
|
invalidateAll(): void;
|
|
32
103
|
/**
|
|
33
|
-
*
|
|
104
|
+
* @remarks
|
|
105
|
+
* Entries are keyed by the resolved file, so importers that reach one file share its entry and URL; the first
|
|
106
|
+
* specifier names the URL, and every specifier and directory pair is kept as a source of the entry.
|
|
107
|
+
*/
|
|
108
|
+
private addEntry;
|
|
109
|
+
/**
|
|
110
|
+
* Warns when the package of `specifier` is reached in more than one installed copy.
|
|
34
111
|
*
|
|
35
112
|
* @remarks
|
|
36
|
-
*
|
|
37
|
-
*
|
|
113
|
+
* Each copy is its own vendor entry and loads as its own module, as in the production build. That is right for
|
|
114
|
+
* two versions an app means to have, but an accidental second copy of a package such as React, from a pnpm peer
|
|
115
|
+
* variant or a workspace package with its own install, otherwise surfaces only as a confusing runtime error.
|
|
116
|
+
* The warning names each copy's directory and the directories of the modules that import it, once per set of
|
|
117
|
+
* copies.
|
|
38
118
|
*/
|
|
39
|
-
private
|
|
40
|
-
private
|
|
41
|
-
private
|
|
119
|
+
private warnOnDuplicatePackageCopies;
|
|
120
|
+
private requireGraph;
|
|
121
|
+
private waitForBuildContaining;
|
|
42
122
|
/**
|
|
43
|
-
*
|
|
123
|
+
* Schedules a build of every known entry of `graph` after a quiet period, restarting the period on each call.
|
|
44
124
|
*
|
|
45
125
|
* @remarks
|
|
46
|
-
*
|
|
47
|
-
*
|
|
126
|
+
* Builds of one graph run one at a time through its queue, and the entry list is read when a build starts, so
|
|
127
|
+
* an entry added while a build runs lands in the next one.
|
|
128
|
+
*/
|
|
129
|
+
private scheduleBuild;
|
|
130
|
+
private startBuild;
|
|
131
|
+
private runBuild;
|
|
132
|
+
/**
|
|
133
|
+
* @remarks
|
|
134
|
+
* A file the previous build served and this build left unchanged counts as served by this one too, so a later
|
|
135
|
+
* build that changes it still reports the change.
|
|
136
|
+
*/
|
|
137
|
+
private commitBuild;
|
|
138
|
+
/**
|
|
139
|
+
* Builds `entries` as one graph, isolating the entries that fail.
|
|
140
|
+
*
|
|
141
|
+
* @remarks
|
|
142
|
+
* When the graph fails, each entry builds alone to find the failing ones, and the graph builds again without
|
|
143
|
+
* them, so one broken package does not take every vendor down. Entries in `failed` are left out and keep
|
|
144
|
+
* their error. When no entry is isolated, because every entry builds alone or none does, or when anything
|
|
145
|
+
* throws, the graph failed as a whole: see {@link DevTransformVendorRegistry.keepLastGoodBuild}.
|
|
146
|
+
*/
|
|
147
|
+
private buildGraph;
|
|
148
|
+
/**
|
|
149
|
+
* The build of a graph that failed as a whole: the outputs of the last build, with an error for each entry
|
|
150
|
+
* that has none.
|
|
151
|
+
*
|
|
152
|
+
* @remarks
|
|
153
|
+
* A whole-graph failure can be transient, such as one during a package install, so no entry is marked
|
|
154
|
+
* failed and the next build tries every entry again. An entry without a previous output gets its own error
|
|
155
|
+
* when it failed alone, otherwise the graph error. A request for such an entry made after a backoff schedules
|
|
156
|
+
* that next build, so the error does not stick; the backoff keeps a lasting failure from rebuilding the graph,
|
|
157
|
+
* with its per-entry isolation builds, on every request.
|
|
158
|
+
*/
|
|
159
|
+
private keepLastGoodBuild;
|
|
160
|
+
/**
|
|
161
|
+
* Keeps the `@ecopages/core` imports of module-first packages out of their graph, pointing each at its
|
|
162
|
+
* browser-first entry URL.
|
|
163
|
+
*
|
|
164
|
+
* @remarks
|
|
165
|
+
* A package such as a router imports core's browser modules. Bundled into the module-first graph, they would
|
|
166
|
+
* be a second copy next to the browser-first one that Pages import, and would move between that graph's chunks
|
|
167
|
+
* as other packages that import them arrive. The import becomes the entry's stable URL instead, which a browser
|
|
168
|
+
* request then builds like any other entry.
|
|
169
|
+
*/
|
|
170
|
+
private createBrowserFirstImportsPlugin;
|
|
171
|
+
private bundleGraph;
|
|
172
|
+
/**
|
|
173
|
+
* @remarks
|
|
174
|
+
* Every output lands in one directory, so the relative imports between entries and chunks resolve under
|
|
175
|
+
* `/assets/vendors/` in the browser as they are.
|
|
176
|
+
*/
|
|
177
|
+
private collectOutputs;
|
|
178
|
+
private findOutput;
|
|
179
|
+
/**
|
|
180
|
+
* @remarks
|
|
181
|
+
* After {@link DevTransformVendorRegistry.invalidateAll} an entry URL waits for the rebuild, but a chunk or an
|
|
182
|
+
* entry URL that is no longer known is still served from the previous build until the rebuild commits, so an
|
|
183
|
+
* open page can load its lazy chunks; a rebuild that changes a served file then reloads the page.
|
|
184
|
+
*/
|
|
185
|
+
private findBuiltOutput;
|
|
186
|
+
/** The graph's last build when it belongs to the current generation. */
|
|
187
|
+
private currentBuild;
|
|
188
|
+
private resolveOutdir;
|
|
189
|
+
private resolveEntriesFile;
|
|
190
|
+
/**
|
|
191
|
+
* Seeds the known entries from the previous dev process.
|
|
192
|
+
*
|
|
193
|
+
* @remarks
|
|
194
|
+
* A specifier that no longer resolves from its directory, or now belongs to another graph, is skipped without
|
|
195
|
+
* an error.
|
|
196
|
+
*/
|
|
197
|
+
private seedPersistedEntries;
|
|
198
|
+
/**
|
|
199
|
+
* @remarks
|
|
200
|
+
* Every known entry is written, failing ones included, so a failure never costs the next process its seed.
|
|
201
|
+
* The write is synchronous so it finishes before the build's waiters resume; a failed write only costs the
|
|
202
|
+
* next process its seed, so it is logged at debug level.
|
|
48
203
|
*/
|
|
49
|
-
private
|
|
204
|
+
private persistEntries;
|
|
50
205
|
private resolvePackageEntry;
|
|
206
|
+
/** Where a bare import that no module imports resolves from. */
|
|
207
|
+
private get rootResolveDir();
|
|
51
208
|
}
|