@ecopages/core 0.6.1 → 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 +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 +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
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
import path from '
|
|
2
|
-
import { fileURLToPath } from 'node:url';
|
|
1
|
+
import { path } from '@ecopages/file-system/path';
|
|
3
2
|
import { resolveBuildEntryPath } from '../build-graph.js';
|
|
3
|
+
import { fromRolldownModuleId } from './rolldown-module-id.js';
|
|
4
4
|
/**
|
|
5
5
|
* @remarks
|
|
6
6
|
* Source dependencies come from the module graph before emission can inline or
|
|
7
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`.
|
|
8
11
|
*/
|
|
9
|
-
export function createEntryModuleClosuresPlugin(graph, root) {
|
|
12
|
+
export function createEntryModuleClosuresPlugin(graph, root, watchFiles) {
|
|
10
13
|
return {
|
|
11
14
|
name: 'ecopages-entry-module-closures',
|
|
12
15
|
generateBundle() {
|
|
@@ -15,14 +18,20 @@ export function createEntryModuleClosuresPlugin(graph, root) {
|
|
|
15
18
|
const normalizedIds = new Map([...ids].map((id) => [
|
|
16
19
|
id,
|
|
17
20
|
id.startsWith('file:')
|
|
18
|
-
?
|
|
21
|
+
? path.fromFileUrl(id)
|
|
19
22
|
: id.startsWith('\0') || !infoById.get(id) || !path.isAbsolute(id)
|
|
20
|
-
? id
|
|
23
|
+
? fromRolldownModuleId(id)
|
|
21
24
|
: resolveBuildEntryPath(id, root),
|
|
22
25
|
]));
|
|
23
26
|
for (const id of ids) {
|
|
24
|
-
|
|
27
|
+
const entryInfo = infoById.get(id);
|
|
28
|
+
if (!entryInfo?.isEntry)
|
|
25
29
|
continue;
|
|
30
|
+
const entryPath = resolveBuildEntryPath(id, root);
|
|
31
|
+
const commonJsEntrypoints = (graph.commonJsEntrypoints ??= []);
|
|
32
|
+
if (entryInfo.inputFormat === 'cjs' && !commonJsEntrypoints.includes(entryPath)) {
|
|
33
|
+
commonJsEntrypoints.push(entryPath);
|
|
34
|
+
}
|
|
26
35
|
const closure = new Set([id]);
|
|
27
36
|
for (const moduleId of closure) {
|
|
28
37
|
const info = infoById.get(moduleId);
|
|
@@ -31,8 +40,12 @@ export function createEntryModuleClosuresPlugin(graph, root) {
|
|
|
31
40
|
for (const imported of [...info.importedIds, ...info.dynamicallyImportedIds])
|
|
32
41
|
closure.add(imported);
|
|
33
42
|
}
|
|
34
|
-
|
|
35
|
-
(moduleId.startsWith('file:') ?
|
|
43
|
+
const modules = [...closure].map((moduleId) => normalizedIds.get(moduleId) ??
|
|
44
|
+
(moduleId.startsWith('file:') ? path.fromFileUrl(moduleId) : fromRolldownModuleId(moduleId)));
|
|
45
|
+
const declared = [...closure].flatMap((moduleId) => [
|
|
46
|
+
...(watchFiles.get(fromRolldownModuleId(moduleId)) ?? []),
|
|
47
|
+
]);
|
|
48
|
+
graph.entrypoints[entryPath] = [...new Set([...modules, ...declared])];
|
|
36
49
|
}
|
|
37
50
|
},
|
|
38
51
|
};
|
|
@@ -9,9 +9,20 @@
|
|
|
9
9
|
*
|
|
10
10
|
* @module
|
|
11
11
|
*/
|
|
12
|
+
import { type PathApi } from '@ecopages/file-system/path';
|
|
12
13
|
import type { InputOptions, OutputOptions, RolldownOutput, RolldownPlugin } from 'rolldown';
|
|
13
|
-
import type
|
|
14
|
+
import { type WatchFilesByModule } from './rolldown-plugin-bridge.js';
|
|
14
15
|
import type { BuildDependencyGraph, BuildOptions, BuildLog, BuildSuccess } from '../build-adapter.js';
|
|
16
|
+
/**
|
|
17
|
+
* Returns the import specifier that a server output file in `outdir` uses to load an installed package file.
|
|
18
|
+
*
|
|
19
|
+
* @remarks
|
|
20
|
+
* The specifier is a `./` or `../` path relative to `outdir`. On Windows a package installed on another drive
|
|
21
|
+
* than `outdir` (a temp folder on `C:` and a checkout on `D:`) has no relative path, so it is a `file:` URL,
|
|
22
|
+
* which Node's ESM loader accepts where a bare `D:/` path is rejected. `pathApi` exists so tests can run the
|
|
23
|
+
* Windows rules on any platform.
|
|
24
|
+
*/
|
|
25
|
+
export declare function toInstalledPackageExternalId(resolvedPath: string, outdir: string, pathApi?: PathApi): string;
|
|
15
26
|
/**
|
|
16
27
|
* Keeps installed compiled packages external as paths relative to the output
|
|
17
28
|
* directory.
|
|
@@ -46,8 +57,8 @@ import type { BuildDependencyGraph, BuildOptions, BuildLog, BuildSuccess } from
|
|
|
46
57
|
* Packages the app declares stay bare specifiers through the `external`
|
|
47
58
|
* option, which Rolldown checks before this hook. Packages in
|
|
48
59
|
* `CORE_RUNTIME_BUNDLED_PACKAGES`, workspace and source packages, anything
|
|
49
|
-
* that does not resolve
|
|
50
|
-
*
|
|
60
|
+
* that does not resolve are bundled. On Windows a package on another drive than
|
|
61
|
+
* `outdir` stays external as a `file:` URL.
|
|
51
62
|
*/
|
|
52
63
|
export declare function createInstalledPackageExternalPlugin(contextRoot: string, outdir: string, reportDir?: string): RolldownPlugin;
|
|
53
64
|
/**
|
|
@@ -77,8 +88,8 @@ export declare function toBuildLog(entry: unknown): BuildLog;
|
|
|
77
88
|
* Converts a build failure into logs, one per underlying error of a Rolldown `BundleError`.
|
|
78
89
|
*
|
|
79
90
|
* @remarks
|
|
80
|
-
* Only
|
|
81
|
-
*
|
|
91
|
+
* Only a `BundleError` is expanded. An `AggregateError` an `EcoBuildPlugin` setup threw is one failure
|
|
92
|
+
* and becomes one log.
|
|
82
93
|
*/
|
|
83
94
|
export declare function toBuildLogs(error: unknown): BuildLog[];
|
|
84
95
|
/** Translated Rolldown options for one {@link BuildOptions} request. */
|
|
@@ -89,9 +100,9 @@ export interface ResolvedRolldownOptions {
|
|
|
89
100
|
/**
|
|
90
101
|
* Translates a {@link BuildOptions} into Rolldown's `InputOptions` and
|
|
91
102
|
* `OutputOptions`. Always sets `experimental.nativeMagicString: true`
|
|
92
|
-
* and always
|
|
93
|
-
*
|
|
103
|
+
* and always maps eco plugins via the bridge, which runs every plugin
|
|
104
|
+
* `setup`. `watchFiles` receives the files those plugins declare.
|
|
94
105
|
*/
|
|
95
|
-
export declare function resolveRolldownOptions(options: BuildOptions, contextRoot: string, outdir: string, appRootRequireCache: Map<string, NodeJS.Require>,
|
|
106
|
+
export declare function resolveRolldownOptions(options: BuildOptions, contextRoot: string, outdir: string, appRootRequireCache: Map<string, NodeJS.Require>, watchFiles: WatchFilesByModule): Promise<ResolvedRolldownOptions>;
|
|
96
107
|
/** Maps a Rolldown `output` to the output fields of a {@link BuildSuccess}. */
|
|
97
108
|
export declare function buildResultFromRolldownOutput(output: RolldownOutput, outdir: string, contextRoot: string, dependencyGraph: BuildDependencyGraph, entrypoints: BuildOptions['entrypoints'], naming?: BuildOptions['naming'], includeContent?: boolean): Pick<BuildSuccess, 'success' | 'outputs' | 'dependencyGraph' | 'outputGraph' | 'entryOutputs'>;
|
|
@@ -11,9 +11,8 @@
|
|
|
11
11
|
*/
|
|
12
12
|
import { createHash } from 'node:crypto';
|
|
13
13
|
import { builtinModules, createRequire } from 'node:module';
|
|
14
|
-
import path from '
|
|
14
|
+
import { path } from '@ecopages/file-system/path';
|
|
15
15
|
import { fileSystem } from '@ecopages/file-system';
|
|
16
|
-
import { fileURLToPath } from 'node:url';
|
|
17
16
|
import { stripVTControlCharacters } from 'node:util';
|
|
18
17
|
import { recordBuildEntryOutput, resolveBuildEntryPath } from '../build-graph.js';
|
|
19
18
|
import { id as idFilter, include } from 'rolldown/filter';
|
|
@@ -23,12 +22,14 @@ import { isEcopagesEnvEnabled } from '../../env.js';
|
|
|
23
22
|
import { isBarePackageImportSpecifier } from '../../plugins/tsconfig-import-resolver.js';
|
|
24
23
|
import { toPackageRootSpecifier } from '../../plugins/package-specifier.js';
|
|
25
24
|
import { isServerOnlyModuleSpecifier } from '../contracts/server-only-specifier.js';
|
|
26
|
-
import {
|
|
25
|
+
import { createWorkerEntriesPlugin } from './worker-entries-plugin.js';
|
|
26
|
+
import { createStylesheetModulePlugin } from './stylesheet-module-plugin.js';
|
|
27
27
|
import { appLogger } from '../../global/app-logger.js';
|
|
28
28
|
import { realpathOfDirectory } from '../preserve-import-meta-transform.js';
|
|
29
|
-
import {
|
|
29
|
+
import { fromRolldownModuleId } from './rolldown-module-id.js';
|
|
30
|
+
import { createRolldownPluginBridge } from './rolldown-plugin-bridge.js';
|
|
30
31
|
import { isDeclaredAppPackageImport, isWorkspacePackageImport } from './app-package-declarations.js';
|
|
31
|
-
const coreSourceFile =
|
|
32
|
+
const coreSourceFile = path.fromFileUrl(import.meta.url);
|
|
32
33
|
const nodeBuiltinSpecifiers = new Set(builtinModules);
|
|
33
34
|
const MAX_FLATTENED_PRESERVED_MODULE_NAME_BYTES = 120;
|
|
34
35
|
const PRESERVED_MODULE_NAME_HASH_LENGTH = 16;
|
|
@@ -46,7 +47,7 @@ function getCorePackageNames() {
|
|
|
46
47
|
if (corePackageNames) {
|
|
47
48
|
return corePackageNames;
|
|
48
49
|
}
|
|
49
|
-
const packageJsonPath =
|
|
50
|
+
const packageJsonPath = path.fromFileUrl(new URL('../../../package.json', import.meta.url));
|
|
50
51
|
corePackageNames = new Set();
|
|
51
52
|
try {
|
|
52
53
|
const packageJson = JSON.parse(fileSystem.readFileSync(packageJsonPath));
|
|
@@ -107,7 +108,7 @@ function isAppPackageExternal(id, contextRoot, appRootRequireCache) {
|
|
|
107
108
|
function createExternalMatcher(options, appRootRequireCache) {
|
|
108
109
|
const explicitExternals = new Set(options.external ?? []);
|
|
109
110
|
const externalPackages = options.externalPackages === true;
|
|
110
|
-
const contextRoot = options.root ? path.resolve(options.root) :
|
|
111
|
+
const contextRoot = options.root ? path.resolve(options.root) : path.cwd();
|
|
111
112
|
return (id) => {
|
|
112
113
|
if (explicitExternals.has(id)) {
|
|
113
114
|
return true;
|
|
@@ -157,7 +158,23 @@ function isUndeclaredPackageImport(id, contextRoot) {
|
|
|
157
158
|
* loader, so PnP installs are not supported for relocated server output.
|
|
158
159
|
*/
|
|
159
160
|
function isInstalledCompiledModule(filePath) {
|
|
160
|
-
return /\.[cm]?js$/u.test(filePath) && /
|
|
161
|
+
return /\.[cm]?js$/u.test(filePath) && filePath.includes('/node_modules/') && !filePath.includes('.zip/');
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Returns the import specifier that a server output file in `outdir` uses to load an installed package file.
|
|
165
|
+
*
|
|
166
|
+
* @remarks
|
|
167
|
+
* The specifier is a `./` or `../` path relative to `outdir`. On Windows a package installed on another drive
|
|
168
|
+
* than `outdir` (a temp folder on `C:` and a checkout on `D:`) has no relative path, so it is a `file:` URL,
|
|
169
|
+
* which Node's ESM loader accepts where a bare `D:/` path is rejected. `pathApi` exists so tests can run the
|
|
170
|
+
* Windows rules on any platform.
|
|
171
|
+
*/
|
|
172
|
+
export function toInstalledPackageExternalId(resolvedPath, outdir, pathApi = path) {
|
|
173
|
+
const relativePath = pathApi.relative(outdir, resolvedPath);
|
|
174
|
+
if (pathApi.isAbsolute(relativePath)) {
|
|
175
|
+
return pathApi.toFileUrl(resolvedPath).href;
|
|
176
|
+
}
|
|
177
|
+
return relativePath.startsWith('../') ? relativePath : `./${relativePath}`;
|
|
161
178
|
}
|
|
162
179
|
/**
|
|
163
180
|
* Keeps installed compiled packages external as paths relative to the output
|
|
@@ -193,8 +210,8 @@ function isInstalledCompiledModule(filePath) {
|
|
|
193
210
|
* Packages the app declares stay bare specifiers through the `external`
|
|
194
211
|
* option, which Rolldown checks before this hook. Packages in
|
|
195
212
|
* `CORE_RUNTIME_BUNDLED_PACKAGES`, workspace and source packages, anything
|
|
196
|
-
* that does not resolve
|
|
197
|
-
*
|
|
213
|
+
* that does not resolve are bundled. On Windows a package on another drive than
|
|
214
|
+
* `outdir` stays external as a `file:` URL.
|
|
198
215
|
*/
|
|
199
216
|
export function createInstalledPackageExternalPlugin(contextRoot, outdir, reportDir) {
|
|
200
217
|
const coreNames = getCorePackageNames();
|
|
@@ -214,19 +231,19 @@ export function createInstalledPackageExternalPlugin(contextRoot, outdir, report
|
|
|
214
231
|
const resolveOptions = { kind: extraOptions.kind, skipSelf: true };
|
|
215
232
|
const resolved = (importer ? await this.resolve(id, importer, resolveOptions) : null) ??
|
|
216
233
|
(coreNames.has(packageName) ? await this.resolve(id, coreSourceFile, resolveOptions) : null);
|
|
217
|
-
|
|
234
|
+
const resolvedPath = resolved && !resolved.external ? fromRolldownModuleId(resolved.id) : undefined;
|
|
235
|
+
if (!resolvedPath || !isInstalledCompiledModule(resolvedPath)) {
|
|
218
236
|
return null;
|
|
219
237
|
}
|
|
220
238
|
realOutdir ??= realpathOfDirectory(outdir);
|
|
221
|
-
const relativePath = path.relative(realOutdir, resolved.id).split(path.sep).join('/');
|
|
222
|
-
if (path.isAbsolute(relativePath)) {
|
|
223
|
-
return null;
|
|
224
|
-
}
|
|
225
239
|
realContextRoot ??= realpathOfDirectory(contextRoot);
|
|
226
|
-
if (reportDir && !isPathInside(
|
|
240
|
+
if (reportDir && !isPathInside(resolvedPath, realContextRoot)) {
|
|
227
241
|
outsideRootPackages.add(packageName);
|
|
228
242
|
}
|
|
229
|
-
const externalId =
|
|
243
|
+
const externalId = toInstalledPackageExternalId(resolvedPath, realOutdir);
|
|
244
|
+
if (externalId.startsWith('file:')) {
|
|
245
|
+
return { id: externalId, external: true };
|
|
246
|
+
}
|
|
230
247
|
externalIds.add(externalId);
|
|
231
248
|
return { id: externalId, external: true };
|
|
232
249
|
},
|
|
@@ -245,7 +262,7 @@ export function createInstalledPackageExternalPlugin(contextRoot, outdir, report
|
|
|
245
262
|
}
|
|
246
263
|
if (reportDir) {
|
|
247
264
|
const outputLabel = entryFileNames
|
|
248
|
-
.map((fileName) => path.relative(contextRoot, path.join(reportDir, fileName))
|
|
265
|
+
.map((fileName) => path.relative(contextRoot, path.join(reportDir, fileName)))
|
|
249
266
|
.join(', ');
|
|
250
267
|
warnPackagesOutsideAppRoot(outputLabel, outsideRootPackages);
|
|
251
268
|
}
|
|
@@ -271,8 +288,8 @@ const nodeBuiltinFilter = new RegExp(`^(?:node:.*|${[...nodeBuiltinSpecifiers].m
|
|
|
271
288
|
*/
|
|
272
289
|
export function createBrowserServerOnlyGuardPlugin() {
|
|
273
290
|
const rejectServerOnly = (id, importer) => {
|
|
274
|
-
const from = importer ? ` (imported from ${importer})` : '';
|
|
275
|
-
throw new Error(`[browser-build] server-only module "${id}" cannot be bundled for the browser${from}. Check the browser graph boundary for the importer.`);
|
|
291
|
+
const from = importer ? ` (imported from ${fromRolldownModuleId(importer)})` : '';
|
|
292
|
+
throw new Error(`[browser-build] server-only module "${fromRolldownModuleId(id)}" cannot be bundled for the browser${from}. Check the browser graph boundary for the importer.`);
|
|
276
293
|
};
|
|
277
294
|
return {
|
|
278
295
|
name: 'ecopages-browser-server-only-guard',
|
|
@@ -282,7 +299,7 @@ export function createBrowserServerOnlyGuardPlugin() {
|
|
|
282
299
|
if (!isNodeBuiltinSpecifier(id)) {
|
|
283
300
|
return null;
|
|
284
301
|
}
|
|
285
|
-
const from = importer ? ` (imported from ${importer})` : '';
|
|
302
|
+
const from = importer ? ` (imported from ${fromRolldownModuleId(importer)})` : '';
|
|
286
303
|
throw new Error(`[browser-build] Node builtin "${id}" cannot be bundled for the browser${from}. Check package "browser" exports and the client-graph boundary for the importer.`);
|
|
287
304
|
},
|
|
288
305
|
},
|
|
@@ -380,29 +397,29 @@ export function toBuildLog(entry) {
|
|
|
380
397
|
Object.assign(log, { [key]: source[key] });
|
|
381
398
|
}
|
|
382
399
|
}
|
|
400
|
+
if (typeof log.id === 'string') {
|
|
401
|
+
log.id = fromRolldownModuleId(log.id);
|
|
402
|
+
}
|
|
403
|
+
if (typeof log.loc?.file === 'string') {
|
|
404
|
+
log.loc = { ...log.loc, file: fromRolldownModuleId(log.loc.file) };
|
|
405
|
+
}
|
|
383
406
|
if (typeof source.frame === 'string') {
|
|
384
407
|
log.frame = stripVTControlCharacters(source.frame);
|
|
385
408
|
}
|
|
386
409
|
if (typeof source.stack === 'string') {
|
|
387
410
|
log.stack = source.stack;
|
|
388
411
|
}
|
|
389
|
-
const ecoBuildPluginName = getEcoBuildPluginName(entry);
|
|
390
|
-
if (ecoBuildPluginName) {
|
|
391
|
-
log.plugin = ecoBuildPluginName;
|
|
392
|
-
}
|
|
393
412
|
return log;
|
|
394
413
|
}
|
|
395
414
|
/**
|
|
396
415
|
* Converts a build failure into logs, one per underlying error of a Rolldown `BundleError`.
|
|
397
416
|
*
|
|
398
417
|
* @remarks
|
|
399
|
-
* Only
|
|
400
|
-
*
|
|
418
|
+
* Only a `BundleError` is expanded. An `AggregateError` an `EcoBuildPlugin` setup threw is one failure
|
|
419
|
+
* and becomes one log.
|
|
401
420
|
*/
|
|
402
421
|
export function toBuildLogs(error) {
|
|
403
|
-
const errors = error instanceof Error && !(error instanceof AggregateError)
|
|
404
|
-
? error.errors
|
|
405
|
-
: undefined;
|
|
422
|
+
const errors = error instanceof Error && !(error instanceof AggregateError) ? error.errors : undefined;
|
|
406
423
|
return (Array.isArray(errors) && errors.length > 0 ? errors : [error]).map(toBuildLog);
|
|
407
424
|
}
|
|
408
425
|
function buildRolldownTransformOptions(options) {
|
|
@@ -418,11 +435,11 @@ function buildRolldownTransformOptions(options) {
|
|
|
418
435
|
}
|
|
419
436
|
return Object.keys(transformOptions).length > 0 ? transformOptions : undefined;
|
|
420
437
|
}
|
|
421
|
-
async function buildRolldownInputPlugins(options, contextRoot, outdir, rolldownPlatform,
|
|
438
|
+
async function buildRolldownInputPlugins(options, contextRoot, outdir, rolldownPlatform, watchFiles) {
|
|
422
439
|
const entrypoints = Array.isArray(options.entrypoints)
|
|
423
440
|
? Object.fromEntries(options.entrypoints.map((entry, index) => [String(index), entry]))
|
|
424
441
|
: options.entrypoints;
|
|
425
|
-
const appPlugins = await createRolldownPluginBridge((options.plugins ?? []).filter((plugin) => plugin.environments?.includes(options.environment) ?? true), contextRoot,
|
|
442
|
+
const appPlugins = await createRolldownPluginBridge((options.plugins ?? []).filter((plugin) => plugin.environments?.includes(options.environment) ?? true), contextRoot, { entrypoints, watchFiles });
|
|
426
443
|
return [
|
|
427
444
|
...(options.externalPackages === true
|
|
428
445
|
? [
|
|
@@ -430,11 +447,12 @@ async function buildRolldownInputPlugins(options, contextRoot, outdir, rolldownP
|
|
|
430
447
|
]
|
|
431
448
|
: []),
|
|
432
449
|
...(rolldownPlatform === 'browser' ? [createBrowserServerOnlyGuardPlugin()] : []),
|
|
433
|
-
|
|
450
|
+
createStylesheetModulePlugin({ environment: options.environment, root: contextRoot }, options.stylesheets, watchFiles),
|
|
434
451
|
...appPlugins,
|
|
452
|
+
...(options.environment === 'browser' && options.workerEntries !== false ? [createWorkerEntriesPlugin()] : []),
|
|
435
453
|
];
|
|
436
454
|
}
|
|
437
|
-
async function buildRolldownInputOptions(options, contextRoot, outdir, external, rolldownPlatform,
|
|
455
|
+
async function buildRolldownInputOptions(options, contextRoot, outdir, external, rolldownPlatform, watchFiles) {
|
|
438
456
|
return {
|
|
439
457
|
input: options.entrypoints,
|
|
440
458
|
cwd: contextRoot,
|
|
@@ -453,7 +471,7 @@ async function buildRolldownInputOptions(options, contextRoot, outdir, external,
|
|
|
453
471
|
experimental: {
|
|
454
472
|
nativeMagicString: true,
|
|
455
473
|
},
|
|
456
|
-
plugins: await buildRolldownInputPlugins(options, contextRoot, outdir, rolldownPlatform,
|
|
474
|
+
plugins: await buildRolldownInputPlugins(options, contextRoot, outdir, rolldownPlatform, watchFiles),
|
|
457
475
|
};
|
|
458
476
|
}
|
|
459
477
|
function resolveRolldownEntryFileNames(options) {
|
|
@@ -486,7 +504,12 @@ function truncateUtf8(value, maximumBytes) {
|
|
|
486
504
|
return prefix;
|
|
487
505
|
}
|
|
488
506
|
function flattenPreservedModuleName(sourceName) {
|
|
489
|
-
const flattened =
|
|
507
|
+
const flattened = path
|
|
508
|
+
.fromNative(sourceName)
|
|
509
|
+
.split('/')
|
|
510
|
+
.filter((segment) => segment !== '' && segment !== '.' && segment !== '..')
|
|
511
|
+
.join('-')
|
|
512
|
+
.replaceAll(':', '');
|
|
490
513
|
if (Buffer.byteLength(flattened) <= MAX_FLATTENED_PRESERVED_MODULE_NAME_BYTES)
|
|
491
514
|
return flattened;
|
|
492
515
|
const digest = createHash('sha256').update(sourceName).digest('hex').slice(0, PRESERVED_MODULE_NAME_HASH_LENGTH);
|
|
@@ -505,6 +528,17 @@ function flattenPreservedModuleName(sourceName) {
|
|
|
505
528
|
function flattenPreservedModuleFileNames(pattern) {
|
|
506
529
|
return (chunk) => pattern.replaceAll('[name]', () => flattenPreservedModuleName(chunk.name));
|
|
507
530
|
}
|
|
531
|
+
/**
|
|
532
|
+
* Sanitizes the name Rolldown gives a preserved module before it fills `[name]`.
|
|
533
|
+
*
|
|
534
|
+
* @remarks
|
|
535
|
+
* A module on another drive than `preserveModulesRoot` has no path relative to it, and Rolldown names it with a
|
|
536
|
+
* `../` prefix that it rejects as a `[name]` substitution before `entryFileNames` can rewrite it. The prefix is
|
|
537
|
+
* dropped here, along with the characters Rolldown's default sanitizer removes.
|
|
538
|
+
*/
|
|
539
|
+
function sanitizePreservedModuleName(name) {
|
|
540
|
+
return name.replace(/^(?:\.\.?\/)+/u, '').replaceAll(/[\0?*:]/gu, '_');
|
|
541
|
+
}
|
|
508
542
|
function buildRolldownOutputOptions(options, outdir) {
|
|
509
543
|
const entryFileNames = resolveRolldownEntryFileNames(options);
|
|
510
544
|
return {
|
|
@@ -517,7 +551,10 @@ function buildRolldownOutputOptions(options, outdir) {
|
|
|
517
551
|
...(options.preserveModules
|
|
518
552
|
? {
|
|
519
553
|
preserveModules: true,
|
|
520
|
-
|
|
554
|
+
sanitizeFileName: sanitizePreservedModuleName,
|
|
555
|
+
...(options.preserveModulesRoot
|
|
556
|
+
? { preserveModulesRoot: path.toNative(options.preserveModulesRoot) }
|
|
557
|
+
: {}),
|
|
521
558
|
}
|
|
522
559
|
: {}),
|
|
523
560
|
sourcemap: mapRolldownSourcemap(options.sourcemap),
|
|
@@ -527,14 +564,14 @@ function buildRolldownOutputOptions(options, outdir) {
|
|
|
527
564
|
/**
|
|
528
565
|
* Translates a {@link BuildOptions} into Rolldown's `InputOptions` and
|
|
529
566
|
* `OutputOptions`. Always sets `experimental.nativeMagicString: true`
|
|
530
|
-
* and always
|
|
531
|
-
*
|
|
567
|
+
* and always maps eco plugins via the bridge, which runs every plugin
|
|
568
|
+
* `setup`. `watchFiles` receives the files those plugins declare.
|
|
532
569
|
*/
|
|
533
|
-
export async function resolveRolldownOptions(options, contextRoot, outdir, appRootRequireCache,
|
|
570
|
+
export async function resolveRolldownOptions(options, contextRoot, outdir, appRootRequireCache, watchFiles) {
|
|
534
571
|
const rolldownPlatform = options.environment === 'browser' ? 'browser' : 'node';
|
|
535
572
|
const external = createExternalMatcher(options, appRootRequireCache);
|
|
536
573
|
return {
|
|
537
|
-
inputOptions: await buildRolldownInputOptions(options, contextRoot, outdir, external, rolldownPlatform,
|
|
574
|
+
inputOptions: await buildRolldownInputOptions(options, contextRoot, outdir, external, rolldownPlatform, watchFiles),
|
|
538
575
|
outputOptions: buildRolldownOutputOptions(options, outdir),
|
|
539
576
|
};
|
|
540
577
|
}
|
|
@@ -550,10 +587,10 @@ export async function resolveRolldownOptions(options, contextRoot, outdir, appRo
|
|
|
550
587
|
function isContentHashedOutput(entry, entryNamingHashed) {
|
|
551
588
|
if (entry.type === 'chunk')
|
|
552
589
|
return entry.isEntry ? entryNamingHashed : true;
|
|
553
|
-
const fileName = path.
|
|
590
|
+
const fileName = path.basename(entry.fileName);
|
|
554
591
|
return entry.names.some((name) => {
|
|
555
|
-
const extension = path.
|
|
556
|
-
const stem = path.
|
|
592
|
+
const extension = path.extname(name);
|
|
593
|
+
const stem = path.basename(name, extension);
|
|
557
594
|
return (fileName.startsWith(`${stem}-`) &&
|
|
558
595
|
fileName.endsWith(extension) &&
|
|
559
596
|
/^[A-Za-z0-9_-]+$/u.test(fileName.slice(stem.length + 1, fileName.length - extension.length)));
|
|
@@ -569,7 +606,7 @@ function isHashedSourceMap(fileName, hashedFileNames) {
|
|
|
569
606
|
function sourceModulePath(moduleId, root) {
|
|
570
607
|
if (moduleId.startsWith('\0'))
|
|
571
608
|
return [];
|
|
572
|
-
const filePath = moduleId.startsWith('file:') ?
|
|
609
|
+
const filePath = moduleId.startsWith('file:') ? path.fromFileUrl(moduleId) : moduleId;
|
|
573
610
|
return path.isAbsolute(filePath) ? [resolveBuildEntryPath(filePath, root)] : [];
|
|
574
611
|
}
|
|
575
612
|
/** Maps a Rolldown `output` to the output fields of a {@link BuildSuccess}. */
|
|
@@ -9,12 +9,11 @@
|
|
|
9
9
|
* Each `build()` creates a fresh `rolldown()` bundler.
|
|
10
10
|
*/
|
|
11
11
|
import { createRequire } from 'node:module';
|
|
12
|
-
import path from '
|
|
12
|
+
import { path } from '@ecopages/file-system/path';
|
|
13
13
|
import { rolldown } from 'rolldown';
|
|
14
14
|
import { buildResultFromRolldownOutput, resolveRolldownOptions, toBuildLog, toBuildLogs, } from './rolldown-adapter-helpers.js';
|
|
15
15
|
import { recordRolldownBuildInvocation } from './rolldown-build-invocation-metrics.js';
|
|
16
16
|
import { createEntryModuleClosuresPlugin } from './entry-module-closures.js';
|
|
17
|
-
import { createBuildInputRecorder, getBuildInputRecordingContext } from '../cache/build-input-dependency-index.js';
|
|
18
17
|
const moduleRequire = createRequire(import.meta.url);
|
|
19
18
|
export class RolldownBuildAdapter {
|
|
20
19
|
/** Per-adapter require cache, keyed on resolved context root. */
|
|
@@ -31,15 +30,15 @@ export class RolldownBuildAdapter {
|
|
|
31
30
|
throw new Error('Build requests require environment: "server" or "browser".');
|
|
32
31
|
}
|
|
33
32
|
recordRolldownBuildInvocation();
|
|
34
|
-
const contextRoot = options.root ? path.resolve(options.root) :
|
|
33
|
+
const contextRoot = options.root ? path.resolve(options.root) : path.cwd();
|
|
35
34
|
const outdir = path.resolve(options.outdir ?? 'dist/client/assets');
|
|
36
|
-
const
|
|
37
|
-
const
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
35
|
+
const watchFiles = new Map();
|
|
36
|
+
const { inputOptions, outputOptions } = await resolveRolldownOptions(options, contextRoot, outdir, this.appRootRequireCache, watchFiles);
|
|
37
|
+
const dependencyGraph = { entrypoints: {}, commonJsEntrypoints: [] };
|
|
38
|
+
inputOptions.plugins = [
|
|
39
|
+
inputOptions.plugins,
|
|
40
|
+
createEntryModuleClosuresPlugin(dependencyGraph, contextRoot, watchFiles),
|
|
41
|
+
];
|
|
43
42
|
const warnings = [];
|
|
44
43
|
const bundle = await rolldown({
|
|
45
44
|
...inputOptions,
|
|
@@ -56,8 +55,6 @@ export class RolldownBuildAdapter {
|
|
|
56
55
|
: await bundle.write(outputOptions);
|
|
57
56
|
return {
|
|
58
57
|
...buildResultFromRolldownOutput(output, outdir, contextRoot, dependencyGraph, options.entrypoints, options.naming, options.writeToDisk === false),
|
|
59
|
-
loadedInputs: [...loadedInputs],
|
|
60
|
-
loadedInputsByModule: Object.fromEntries([...loadedInputsByModule].map(([moduleId, paths]) => [moduleId, [...paths]])),
|
|
61
58
|
warnings,
|
|
62
59
|
};
|
|
63
60
|
}
|
|
@@ -77,7 +74,7 @@ export class RolldownBuildAdapter {
|
|
|
77
74
|
}
|
|
78
75
|
}
|
|
79
76
|
resolve(importPath, rootDir) {
|
|
80
|
-
return moduleRequire.resolve(importPath, { paths: [rootDir] });
|
|
77
|
+
return path.fromNative(moduleRequire.resolve(importPath, { paths: [rootDir] }));
|
|
81
78
|
}
|
|
82
79
|
}
|
|
83
80
|
export function createRolldownBuildAdapter() {
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts a module id Rolldown hands to a hook into an Ecopages path.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* Rolldown's resolver returns native paths, so on Windows a module id arrives with backslashes. Virtual ids
|
|
6
|
+
* (`\0...`) and bare specifiers pass through unchanged.
|
|
7
|
+
*/
|
|
8
|
+
export declare function fromRolldownModuleId(id: string): string;
|
|
9
|
+
/**
|
|
10
|
+
* Converts a path a hook resolves into the module id form Rolldown's own resolver produces.
|
|
11
|
+
*
|
|
12
|
+
* @remarks
|
|
13
|
+
* Rolldown keys modules by id string. On Windows its resolver returns backslash paths, so a plugin that resolved
|
|
14
|
+
* the same file to a forward-slash id would make it a second module. A query or hash after the path is kept as
|
|
15
|
+
* written. Only a drive-letter path is converted: a root-relative id such as `/assets/vendors/react.js` is a URL
|
|
16
|
+
* an external import keeps, not a file.
|
|
17
|
+
*/
|
|
18
|
+
export declare function toRolldownModuleId(id: string): string;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { path } from '@ecopages/file-system/path';
|
|
2
|
+
const WINDOWS_DRIVE_PATH = /^[A-Za-z]:\//u;
|
|
3
|
+
/**
|
|
4
|
+
* Converts a module id Rolldown hands to a hook into an Ecopages path.
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* Rolldown's resolver returns native paths, so on Windows a module id arrives with backslashes. Virtual ids
|
|
8
|
+
* (`\0...`) and bare specifiers pass through unchanged.
|
|
9
|
+
*/
|
|
10
|
+
export function fromRolldownModuleId(id) {
|
|
11
|
+
return path.fromNative(id);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Converts a path a hook resolves into the module id form Rolldown's own resolver produces.
|
|
15
|
+
*
|
|
16
|
+
* @remarks
|
|
17
|
+
* Rolldown keys modules by id string. On Windows its resolver returns backslash paths, so a plugin that resolved
|
|
18
|
+
* the same file to a forward-slash id would make it a second module. A query or hash after the path is kept as
|
|
19
|
+
* written. Only a drive-letter path is converted: a root-relative id such as `/assets/vendors/react.js` is a URL
|
|
20
|
+
* an external import keeps, not a file.
|
|
21
|
+
*/
|
|
22
|
+
export function toRolldownModuleId(id) {
|
|
23
|
+
if (!WINDOWS_DRIVE_PATH.test(id))
|
|
24
|
+
return id;
|
|
25
|
+
const suffixIndex = id.search(/[?#]/u);
|
|
26
|
+
return suffixIndex === -1
|
|
27
|
+
? path.toNative(id)
|
|
28
|
+
: `${path.toNative(id.slice(0, suffixIndex))}${id.slice(suffixIndex)}`;
|
|
29
|
+
}
|
|
@@ -2,75 +2,39 @@
|
|
|
2
2
|
* Bundler plugin bridge.
|
|
3
3
|
*
|
|
4
4
|
* @remarks
|
|
5
|
-
* Translates
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* `
|
|
10
|
-
* `resolveId`/`load`/`transform` hooks.
|
|
11
|
-
*
|
|
12
|
-
* The shared `EcoBuildPlugin` contract stays the boundary between
|
|
13
|
-
* integrations and bundler backends.
|
|
14
|
-
*
|
|
15
|
-
* **Namespace handling.**
|
|
16
|
-
*
|
|
17
|
-
* The shared `EcoBuildPlugin` contract scopes `onResolve`/`onLoad`
|
|
18
|
-
* handlers with a `namespace` string. The bundler encodes namespaces
|
|
19
|
-
* into the module id (no separate field). The bridge prepends
|
|
20
|
-
* `<namespace>:` to the resolved id when the result includes a
|
|
21
|
-
* namespace. A namespaced `onLoad`/`onResolve` filter matches only ids
|
|
22
|
-
* with that prefix, and is tested against the path after it. The bridge
|
|
23
|
-
* strips the prefix before forwarding the id back
|
|
24
|
-
* to the callback so plugin code keeps seeing the same `path` shape
|
|
25
|
-
* it did on the historical contract.
|
|
5
|
+
* Translates `EcoBuildPlugin` instances (the runtime-agnostic plugin contract used by Ecopages
|
|
6
|
+
* processors and integrations) into Rolldown plugins. Every handler a plugin registers becomes its
|
|
7
|
+
* own Rolldown plugin, named after the `EcoBuildPlugin` and carrying the handler's filter as a native
|
|
8
|
+
* hook filter: `onResolve` maps to `resolveId`, `onLoad` to `load`, `transform` to `transform`,
|
|
9
|
+
* `onEnd` to `buildEnd`, and `module` to a `resolveId` and `load` pair for a `\0` virtual id.
|
|
26
10
|
*
|
|
27
11
|
* **Plugin ordering is semantically significant.**
|
|
28
12
|
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
* order,
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
* - **Index 0** has the highest priority.
|
|
36
|
-
* - **Last index** has the lowest priority.
|
|
37
|
-
*
|
|
38
|
-
* When adding new integrations or processors, ensure security-critical
|
|
39
|
-
* plugins (e.g. `ecopages-client-graph-boundary`) are placed **before**
|
|
40
|
-
* general-purpose loaders in the array so they always get first refusal
|
|
41
|
-
* on every source file.
|
|
13
|
+
* The Rolldown plugins keep the order of the `plugins` array, and of the handlers inside each
|
|
14
|
+
* plugin. Rolldown gives the first non-null `resolveId` and `load` result precedence, and runs every
|
|
15
|
+
* matching `transform` in order, chaining their source maps. Index 0 has the highest priority, so
|
|
16
|
+
* security-critical plugins (e.g. `ecopages-client-graph-boundary`) go **before** general-purpose
|
|
17
|
+
* loaders, to get first refusal on every source file.
|
|
42
18
|
*/
|
|
43
19
|
import type { Plugin } from 'rolldown';
|
|
44
20
|
import type { EcoBuildPlugin } from '../contracts/build-types.js';
|
|
45
|
-
/**
|
|
46
|
-
export
|
|
47
|
-
export type BuildInputRecorder = (moduleId: string, filePath: string) => void;
|
|
21
|
+
/** Files each module's plugins declared with `addWatchFile`, keyed by Rolldown module id. */
|
|
22
|
+
export type WatchFilesByModule = Map<string, Set<string>>;
|
|
48
23
|
/**
|
|
49
|
-
* Creates the
|
|
50
|
-
* `EcoBuildPlugin` instances.
|
|
51
|
-
*
|
|
52
|
-
* All eco plugins are merged into one Rolldown plugin. Its `resolveId`
|
|
53
|
-
* and `load` hooks check the registrations in `plugins` array order, so
|
|
54
|
-
* registrations from earlier eco plugins win over later ones. `transform`
|
|
55
|
-
* runs every matching registration in that same order.
|
|
24
|
+
* Creates the Rolldown plugins that drive the supplied `EcoBuildPlugin` instances.
|
|
56
25
|
*
|
|
57
26
|
* @remarks
|
|
58
|
-
* Every `setup` runs here, before
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
* exact filter is tested in JavaScript against the path after the prefix.
|
|
64
|
-
* Transform filters are tested with the query and hash stripped. Rolldown
|
|
65
|
-
* tests filters against ids with `/` separators, so a filter written for
|
|
66
|
-
* backslash separators does not match on Windows.
|
|
67
|
-
*
|
|
68
|
-
* Every build creates a new bridge, so registrations and the
|
|
69
|
-
* virtual-module counter never carry over between builds.
|
|
27
|
+
* Every `setup` runs here, in order, before any Rolldown plugin exists, because Rolldown reads hook
|
|
28
|
+
* filters when a plugin is registered; a handler registered later throws. Every builder shares one
|
|
29
|
+
* `entrypoints` object, so a plugin can key state on it for one build. Transform filters are tested
|
|
30
|
+
* with the query and hash stripped and never see a `\0` virtual id. Rolldown tests filters against
|
|
31
|
+
* ids with `/` separators, so a filter written for backslash separators does not match on Windows.
|
|
70
32
|
*
|
|
71
33
|
* @param plugins - `EcoBuildPlugin` instances registered for this build.
|
|
72
|
-
* @param contextRoot - Project root used to resolve relative
|
|
73
|
-
* @param
|
|
74
|
-
* and invalidation include them.
|
|
34
|
+
* @param contextRoot - Project root used to resolve a relative path an `onResolve` callback returns.
|
|
35
|
+
* @param options.watchFiles - Receives each file a callback declares with `addWatchFile`, under the module it ran for.
|
|
75
36
|
*/
|
|
76
|
-
export declare function createRolldownPluginBridge(plugins: EcoBuildPlugin[], contextRoot: string,
|
|
37
|
+
export declare function createRolldownPluginBridge(plugins: EcoBuildPlugin[], contextRoot: string, options?: {
|
|
38
|
+
entrypoints?: Readonly<Record<string, string>>;
|
|
39
|
+
watchFiles?: WatchFilesByModule;
|
|
40
|
+
}): Promise<Plugin[]>;
|