@ecopages/core 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -143
- package/package.json +16 -3
- package/src/adapters/node/dev-session.js +2 -1
- package/src/adapters/node/node-client-bridge.d.ts +5 -7
- package/src/adapters/node/node-client-bridge.js +4 -14
- package/src/adapters/node/server-adapter.d.ts +4 -2
- package/src/adapters/node/server-adapter.js +13 -12
- package/src/adapters/shared/hmr/client-bridge.d.ts +25 -0
- package/src/adapters/shared/hmr/client-bridge.js +35 -0
- package/src/adapters/shared/hmr/dev-transform-entrypoint-registry.js +1 -1
- package/src/adapters/shared/hmr/hmr-manager.d.ts +9 -2
- package/src/adapters/shared/hmr/hmr-manager.js +36 -6
- package/src/adapters/shared/http/dist-file-handler.js +3 -7
- package/src/adapters/shared/http/response-headers.d.ts +29 -0
- package/src/adapters/shared/http/response-headers.js +89 -0
- package/src/adapters/shared/runtime/copy-runtime-public-dir.js +1 -1
- package/src/adapters/shared/runtime/runtime-server-lifecycle.d.ts +3 -2
- package/src/adapters/shared/runtime/runtime-server-lifecycle.js +4 -3
- package/src/adapters/shared/runtime/server-request-pipeline.js +4 -4
- package/src/adapters/shared/runtime/server-static-builder.d.ts +19 -8
- package/src/adapters/shared/runtime/server-static-builder.js +23 -4
- package/src/adapters/shared/ws/node-http-websocket-upgrades.d.ts +1 -1
- package/src/adapters/shared/ws/node-http-websocket-upgrades.js +23 -16
- package/src/assets/app-browser-client-build.d.ts +5 -12
- package/src/assets/app-browser-client-build.js +121 -336
- package/src/assets/asset-processing-service/app-browser-client-bundle.d.ts +4 -0
- package/src/assets/asset-processing-service/app-browser-client-bundle.js +6 -0
- package/src/assets/asset-processing-service/asset-dependency-keys.d.ts +28 -8
- package/src/assets/asset-processing-service/asset-dependency-keys.js +104 -29
- package/src/assets/asset-processing-service/asset-processing.service.d.ts +60 -2
- package/src/assets/asset-processing-service/asset-processing.service.js +189 -58
- package/src/assets/asset-processing-service/bundleable-script.d.ts +3 -0
- package/src/assets/asset-processing-service/bundleable-script.js +4 -0
- package/src/assets/asset-processing-service/grouped-content-bundles.d.ts +2 -2
- package/src/assets/asset-processing-service/grouped-content-bundles.js +5 -10
- package/src/assets/asset-processing-service/index.d.ts +0 -3
- package/src/assets/asset-processing-service/index.js +0 -3
- package/src/assets/asset-processing-service/last-good-output.d.ts +21 -0
- package/src/assets/asset-processing-service/last-good-output.js +32 -0
- package/src/assets/asset-processing-service/page-package.js +1 -4
- package/src/assets/asset-processing-service/processed-asset-ledger.d.ts +63 -0
- package/src/assets/asset-processing-service/processed-asset-ledger.js +101 -0
- package/src/assets/asset-processing-service/processors/base/base-processor.js +1 -1
- package/src/assets/asset-processing-service/processors/base/base-script-processor.js +1 -1
- package/src/assets/asset-processing-service/processors/script/content-script.processor.d.ts +24 -0
- package/src/assets/asset-processing-service/processors/script/content-script.processor.js +59 -4
- package/src/assets/asset-processing-service/processors/script/file-script.processor.d.ts +8 -4
- package/src/assets/asset-processing-service/processors/script/file-script.processor.js +18 -6
- package/src/assets/asset-processing-service/processors/script/node-module-script.processor.js +2 -3
- package/src/assets/asset-processing-service/processors/stylesheet/app-stylesheet-imports.d.ts +34 -0
- package/src/assets/asset-processing-service/processors/stylesheet/app-stylesheet-imports.js +115 -0
- package/src/assets/asset-processing-service/processors/stylesheet/content-stylesheet.processor.js +2 -2
- package/src/assets/asset-processing-service/processors/stylesheet/css-module-types.d.ts +39 -0
- package/src/assets/asset-processing-service/processors/stylesheet/css-module-types.js +150 -0
- package/src/assets/asset-processing-service/processors/stylesheet/css-scanner.d.ts +84 -0
- package/src/assets/asset-processing-service/processors/stylesheet/css-scanner.js +379 -0
- package/src/assets/asset-processing-service/processors/stylesheet/file-stylesheet.processor.d.ts +16 -0
- package/src/assets/asset-processing-service/processors/stylesheet/file-stylesheet.processor.js +50 -24
- package/src/assets/asset-processing-service/processors/stylesheet/import-order.d.ts +33 -0
- package/src/assets/asset-processing-service/processors/stylesheet/import-order.js +67 -0
- package/src/assets/asset-processing-service/processors/stylesheet/package-stylesheet.d.ts +44 -0
- package/src/assets/asset-processing-service/processors/stylesheet/package-stylesheet.js +149 -0
- package/src/assets/asset-processing-service/processors/stylesheet/processed-stylesheet-cache.d.ts +31 -0
- package/src/assets/asset-processing-service/processors/stylesheet/processed-stylesheet-cache.js +59 -0
- package/src/assets/asset-processing-service/processors/stylesheet/source-relative-stylesheet.d.ts +20 -0
- package/src/assets/asset-processing-service/processors/stylesheet/source-relative-stylesheet.js +51 -0
- package/src/assets/asset-processing-service/processors/stylesheet/stylesheet-failure.d.ts +2 -0
- package/src/assets/asset-processing-service/processors/stylesheet/stylesheet-failure.js +5 -0
- package/src/assets/asset-processing-service/processors/stylesheet/stylesheet-module.d.ts +37 -0
- package/src/assets/asset-processing-service/processors/stylesheet/stylesheet-module.js +48 -0
- package/src/assets/asset-processing-service/processors/stylesheet/stylesheet-processor-pipeline.d.ts +25 -1
- package/src/assets/asset-processing-service/processors/stylesheet/stylesheet-processor-pipeline.js +56 -15
- package/src/assets/asset-processing-service/processors/stylesheet/stylesheet-warnings.d.ts +9 -0
- package/src/assets/asset-processing-service/processors/stylesheet/stylesheet-warnings.js +21 -0
- package/src/assets/browser-asset-output.js +1 -1
- package/src/assets/hashed-browser-asset.js +1 -1
- package/src/assets/{browser-runtime-asset-page-cache.d.ts → page-script-page-cache.d.ts} +3 -3
- package/src/assets/{browser-runtime-asset-page-cache.js → page-script-page-cache.js} +3 -3
- package/src/build/app-build-manifest-runtime.d.ts +23 -11
- package/src/build/app-build-manifest-runtime.js +52 -13
- package/src/build/browser/jsx-ownership-plugins.d.ts +4 -1
- package/src/build/browser/jsx-ownership-plugins.js +6 -0
- package/src/build/build-adapter.d.ts +1 -1
- package/src/build/build-adapter.js +1 -1
- package/src/build/build-graph.d.ts +4 -2
- package/src/build/build-graph.js +12 -46
- package/src/build/cache/build-input-dependency-index.d.ts +0 -19
- package/src/build/cache/build-input-dependency-index.js +1 -34
- package/src/build/cache/pages-unified-graph-build.js +7 -43
- package/src/build/cache/server-module-entries.d.ts +1 -1
- package/src/build/cache/server-module-entries.js +9 -9
- package/src/build/contracts/build-contracts.d.ts +59 -12
- package/src/build/contracts/build-manifest.d.ts +3 -6
- package/src/build/contracts/build-manifest.js +2 -12
- package/src/build/contracts/content-virtual-modules.js +1 -3
- package/src/build/copy-server-files.js +1 -1
- package/src/build/preserve-import-meta-transform.d.ts +3 -1
- package/src/build/preserve-import-meta-transform.js +7 -4
- package/src/build/production-asset-ledger.d.ts +36 -0
- package/src/build/production-asset-ledger.js +104 -0
- package/src/build/production-dist-complete.js +12 -13
- package/src/build/production-route-list.js +1 -1
- package/src/build/rolldown/app-package-declarations.js +1 -1
- package/src/build/rolldown/entry-module-closures.d.ts +5 -1
- package/src/build/rolldown/entry-module-closures.js +21 -8
- package/src/build/rolldown/rolldown-adapter-helpers.d.ts +19 -8
- package/src/build/rolldown/rolldown-adapter-helpers.js +82 -45
- package/src/build/rolldown/rolldown-build-adapter.js +10 -13
- package/src/build/rolldown/rolldown-module-id.d.ts +18 -0
- package/src/build/rolldown/rolldown-module-id.js +29 -0
- package/src/build/rolldown/rolldown-plugin-bridge.d.ts +24 -60
- package/src/build/rolldown/rolldown-plugin-bridge.js +201 -373
- package/src/build/rolldown/stylesheet-module-plugin.d.ts +34 -0
- package/src/build/rolldown/stylesheet-module-plugin.js +160 -0
- package/src/build/rolldown/worker-entries-plugin.d.ts +13 -0
- package/src/build/rolldown/worker-entries-plugin.js +57 -0
- package/src/build/runtime/build-environment-options.js +13 -3
- package/src/build/runtime/build-request-identity.js +1 -1
- package/src/build/runtime/build-request-policy.d.ts +7 -12
- package/src/build/runtime/build-request-policy.js +63 -17
- package/src/build/server/imported-view-plugin.d.ts +1 -0
- package/src/build/server/imported-view-plugin.js +6 -4
- package/src/build/server/page-module-import.service.d.ts +1 -2
- package/src/build/server/page-module-import.service.js +4 -6
- package/src/build/server/resolve-static-view.js +3 -2
- package/src/build/server/route-module-build-cache-registry.js +1 -1
- package/src/build/server/route-module-build-cache.store.js +1 -1
- package/src/build/server/route-module-build-manifest.js +1 -1
- package/src/build/server/route-module-dependency-hasher.d.ts +1 -1
- package/src/build/server/route-module-dependency-hasher.js +2 -2
- package/src/build/server/server-modules-manifest.d.ts +3 -5
- package/src/build/server/server-modules-manifest.js +6 -21
- package/src/build/server/view-module.d.ts +12 -0
- package/src/build/server/view-module.js +23 -0
- package/src/build/server/view-reference.d.ts +16 -5
- package/src/build/server/view-reference.js +25 -14
- package/src/build/server-bundle-deploy-manifest.d.ts +1 -1
- package/src/build/server-bundle-deploy-manifest.js +2 -2
- package/src/build/server-bundle-publication.d.ts +7 -1
- package/src/build/server-bundle-publication.js +11 -4
- package/src/build/server-module.js +1 -1
- package/src/build/worker-urls.d.ts +60 -0
- package/src/build/worker-urls.js +197 -0
- package/src/build.d.ts +7 -5
- package/src/build.js +7 -5
- package/src/cache/module-parse-cache.js +2 -2
- package/src/client/navigation-attributes.d.ts +8 -0
- package/src/client/navigation-attributes.js +8 -0
- package/src/client/navigation-scripts/global-scripts.d.ts +14 -0
- package/src/client/navigation-scripts/global-scripts.js +65 -0
- package/src/client/navigation-scripts/index.d.ts +1 -0
- package/src/client/navigation-scripts/index.js +1 -0
- package/src/client.d.ts +2 -2
- package/src/client.js +2 -2
- package/src/config/assembly/app-runtime.d.ts +45 -5
- package/src/config/assembly/app-runtime.js +11 -2
- package/src/config/assembly/finalize-config.js +13 -5
- package/src/config/config-module-files.js +10 -6
- package/src/config/index.d.ts +2 -1
- package/src/config/internal-types.d.ts +3 -0
- package/src/config/load-eco-config.js +8 -5
- package/src/config/resolve-eco-config-path.js +3 -3
- package/src/config/server-config-bundle.js +1 -1
- package/src/config/user-config-types.d.ts +54 -1
- package/src/config/write-types.js +4 -1
- package/src/css-imports.d.ts +12 -0
- package/src/declarations.d.ts +2 -0
- package/src/dev/development-restart-watch-paths.js +1 -1
- package/src/dev/development-restart.js +1 -1
- package/src/dev/invalidation/development-invalidation.service.d.ts +6 -1
- package/src/dev/invalidation/development-invalidation.service.js +18 -2
- package/src/dev/stylesheets/development-stylesheet.service.d.ts +149 -0
- package/src/dev/stylesheets/development-stylesheet.service.js +350 -0
- package/src/dev/transform-server/dev-transform-bundler.d.ts +12 -3
- package/src/dev/transform-server/dev-transform-bundler.js +32 -21
- package/src/dev/transform-server/dev-transform-externalize-plugin.d.ts +3 -5
- package/src/dev/transform-server/dev-transform-externalize-plugin.js +8 -9
- package/src/dev/transform-server/dev-transform-import-rewriter.d.ts +15 -2
- package/src/dev/transform-server/dev-transform-import-rewriter.js +204 -35
- package/src/dev/transform-server/dev-transform-install-stamp.d.ts +17 -0
- package/src/dev/transform-server/dev-transform-install-stamp.js +79 -0
- package/src/dev/transform-server/dev-transform-server.d.ts +38 -2
- package/src/dev/transform-server/dev-transform-server.js +96 -33
- package/src/dev/transform-server/dev-transform-url.d.ts +4 -2
- package/src/dev/transform-server/dev-transform-url.js +13 -12
- package/src/dev/transform-server/dev-transform-vendor-registry.d.ts +178 -21
- package/src/dev/transform-server/dev-transform-vendor-registry.js +675 -99
- package/src/dev/transform-server/index.d.ts +1 -1
- package/src/dev-toolbar/dev-toolbar-package.js +4 -4
- package/src/eco/component-render-output.d.ts +6 -1
- package/src/eco/component-render-output.js +32 -7
- package/src/eco/discovered-dependencies.d.ts +30 -11
- package/src/eco/discovered-dependencies.js +25 -13
- package/src/eco/discovered-dependency-paths.d.ts +36 -0
- package/src/eco/discovered-dependency-paths.js +58 -0
- package/src/eco/eco.browser.js +8 -12
- package/src/eco/eco.js +0 -30
- package/src/eco/mdx-page-metadata.d.ts +14 -0
- package/src/eco/mdx-page-metadata.js +15 -0
- package/src/eco/page-layout-normalization.d.ts +6 -2
- package/src/eco/page-layout-normalization.js +9 -6
- package/src/env.js +17 -0
- package/src/hmr/client/hmr-runtime.js +14 -13
- package/src/hmr/dev-client-runtime.d.ts +5 -2
- package/src/hmr/dev-client-runtime.js +14 -4
- package/src/hmr/hmr-entrypoint-output.js +1 -1
- package/src/hmr/hmr-strategy.d.ts +2 -2
- package/src/hmr/hmr-strategy.js +2 -2
- package/src/hmr/strategies/js-hmr-strategy.d.ts +4 -1
- package/src/hmr/strategies/js-hmr-strategy.js +7 -6
- package/src/hmr/strategies/template-source-hmr-strategy.d.ts +25 -0
- package/src/hmr/strategies/template-source-hmr-strategy.js +36 -0
- package/src/html-pages/html-page-module-scripts.d.ts +2 -1
- package/src/html-pages/html-page-module-scripts.js +37 -14
- package/src/html-pages/html-page-module.js +1 -1
- package/src/html-pages/html-page-renderer.js +7 -6
- package/src/html-pages/html-page-template.d.ts +0 -5
- package/src/html-pages/html-page-template.js +3 -15
- package/src/html-pages/html-pages.plugin.js +2 -2
- package/src/integration.d.ts +8 -6
- package/src/integration.js +5 -3
- package/src/page-cache/html-page-cache-dependency-index.js +1 -1
- package/src/page-cache/page-cache-service.js +1 -1
- package/src/plugins/alias-resolver-plugin.d.ts +7 -0
- package/src/plugins/alias-resolver-plugin.js +16 -6
- package/src/plugins/component-import-discovery.d.ts +178 -7
- package/src/plugins/component-import-discovery.js +696 -112
- package/src/plugins/eco-component-meta-plugin.d.ts +47 -6
- package/src/plugins/eco-component-meta-plugin.js +227 -59
- package/src/plugins/foreign-jsx-override-plugin.d.ts +14 -1
- package/src/plugins/foreign-jsx-override-plugin.js +18 -8
- package/src/plugins/integration-plugin.d.ts +47 -11
- package/src/plugins/integration-plugin.js +57 -8
- package/src/plugins/processor.d.ts +72 -7
- package/src/plugins/processor.js +44 -9
- package/src/plugins/stylesheet-kinds.d.ts +57 -0
- package/src/plugins/stylesheet-kinds.js +114 -0
- package/src/plugins/tsconfig-import-resolver.d.ts +49 -3
- package/src/plugins/tsconfig-import-resolver.js +120 -6
- package/src/processor-contract.d.ts +66 -0
- package/src/processor-contract.js +389 -0
- package/src/processor.d.ts +6 -1
- package/src/processor.js +6 -1
- package/src/route-renderer/error-pages/default-error-pages.d.ts +1 -0
- package/src/route-renderer/error-pages/default-error-pages.js +27 -7
- package/src/route-renderer/orchestration/custom-element-scripts/custom-element-script-preload-invalidation.d.ts +8 -0
- package/src/route-renderer/orchestration/custom-element-scripts/custom-element-script-preload-invalidation.js +12 -0
- package/src/route-renderer/orchestration/custom-element-scripts/custom-element-script-preloader.d.ts +77 -24
- package/src/route-renderer/orchestration/custom-element-scripts/custom-element-script-preloader.js +97 -32
- package/src/route-renderer/orchestration/custom-element-scripts/custom-element-server-module-importer.js +1 -1
- package/src/route-renderer/orchestration/document-shell/document-shell-render.service.d.ts +9 -0
- package/src/route-renderer/orchestration/document-shell/document-shell-render.service.js +16 -2
- package/src/route-renderer/orchestration/document-shell/layout-children-not-rendered-error.d.ts +35 -0
- package/src/route-renderer/orchestration/document-shell/layout-children-not-rendered-error.js +53 -0
- package/src/route-renderer/orchestration/foreign-child/render-session.d.ts +4 -8
- package/src/route-renderer/orchestration/foreign-child/render-session.js +2 -5
- package/src/route-renderer/orchestration/integration-renderer.d.ts +171 -64
- package/src/route-renderer/orchestration/integration-renderer.js +293 -332
- package/src/route-renderer/orchestration/ownership-graph/component-graph-collectors.d.ts +8 -5
- package/src/route-renderer/orchestration/ownership-graph/component-graph-collectors.js +27 -25
- package/src/route-renderer/orchestration/ownership-graph/component-graph.d.ts +0 -6
- package/src/route-renderer/orchestration/page-browser-graph/global-injector-assets.service.js +3 -3
- package/src/route-renderer/orchestration/page-browser-graph/grouped-graph-build-plan.d.ts +12 -25
- package/src/route-renderer/orchestration/page-browser-graph/grouped-graph-build-plan.js +1 -14
- package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph-session.d.ts +0 -16
- package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph-session.js +1 -87
- package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph.service.d.ts +8 -16
- package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph.service.js +25 -271
- package/src/route-renderer/orchestration/page-browser-graph/route-instance-key.d.ts +0 -24
- package/src/route-renderer/orchestration/page-browser-graph/route-instance-key.js +0 -67
- package/src/route-renderer/orchestration/route-pipeline/route-render-orchestrator.d.ts +28 -15
- package/src/route-renderer/orchestration/route-pipeline/route-render-orchestrator.js +63 -41
- package/src/route-renderer/page-loading/component-dependency-collection.d.ts +4 -1
- package/src/route-renderer/page-loading/component-dependency-collection.js +51 -15
- package/src/route-renderer/page-loading/dependency-resolver.d.ts +10 -0
- package/src/route-renderer/page-loading/dependency-resolver.js +27 -6
- package/src/route-renderer/page-loading/file-scoped-dependency-components.d.ts +4 -2
- package/src/route-renderer/page-loading/file-scoped-dependency-components.js +22 -17
- package/src/route-renderer/page-loading/lazy-entry-collection.d.ts +5 -0
- package/src/route-renderer/page-loading/lazy-entry-collection.js +6 -4
- package/src/route-renderer/page-loading/page-dependency-bundling.d.ts +5 -2
- package/src/route-renderer/page-loading/page-dependency-bundling.js +15 -31
- package/src/route-renderer/page-loading/page-module-loader.d.ts +13 -2
- package/src/route-renderer/page-loading/page-module-loader.js +23 -5
- package/src/route-renderer/route-renderer.d.ts +1 -1
- package/src/router/client/navigation-commit.d.ts +2 -0
- package/src/router/client/navigation-commit.js +20 -3
- package/src/router/client/navigation-coordinator.d.ts +18 -0
- package/src/router/client/navigation-coordinator.js +14 -0
- package/src/router/client/navigation-head-order.fixture.css +3 -0
- package/src/router/client/navigation-head.d.ts +2 -1
- package/src/router/client/navigation-head.fixture.css +3 -0
- package/src/router/client/navigation-head.js +222 -39
- package/src/router/client/navigation-lifecycle.d.ts +8 -1
- package/src/router/client/navigation-lifecycle.js +6 -3
- package/src/router/client/navigation-pipeline.d.ts +1 -0
- package/src/router/client/navigation-pipeline.js +1 -0
- package/src/router/server/route-registry.d.ts +3 -2
- package/src/router/server/route-registry.js +6 -5
- package/src/static-site-generator/production-page-browser-graph-prebuild.d.ts +30 -18
- package/src/static-site-generator/production-page-browser-graph-prebuild.js +82 -143
- package/src/static-site-generator/static-site-generator.d.ts +37 -4
- package/src/static-site-generator/static-site-generator.js +99 -51
- package/src/types/asset-types.d.ts +19 -1
- package/src/types/build-types.d.ts +53 -35
- package/src/types/component-identity.d.ts +8 -0
- package/src/types/contracts.d.ts +69 -21
- package/src/types/dev-transform-types.d.ts +33 -6
- package/src/types/eco-api-types.d.ts +13 -18
- package/src/types/integration-types.d.ts +1 -1
- package/src/types/public-types.d.ts +1 -1
- package/src/utils/additional-watch-paths.js +3 -5
- package/src/utils/entry-command-flags.d.ts +23 -0
- package/src/utils/entry-command-flags.js +24 -0
- package/src/utils/package-path.d.ts +42 -0
- package/src/utils/package-path.js +114 -0
- package/src/utils/parse-cli-args.d.ts +18 -1
- package/src/utils/parse-cli-args.js +54 -37
- package/src/utils/path-containment.js +3 -10
- package/src/utils/resolve-work-dir.js +2 -2
- package/src/utils/root-relative-path.js +2 -2
- package/src/utils/server-bundle-context.d.ts +5 -0
- package/src/utils/server-bundle-context.js +7 -1
- package/src/utils/server-utils.module.js +1 -1
- package/src/watchers/project-watcher-ignore.js +3 -3
- package/src/watchers/project-watcher.d.ts +14 -2
- package/src/watchers/project-watcher.js +37 -6
- package/src/watchers/workspace-package-watch-roots.js +2 -2
- package/src/assets/app-browser-client-manifest.d.ts +0 -66
- package/src/assets/app-browser-client-manifest.js +0 -260
- package/src/assets/asset-processing-service/asset-package-role.d.ts +0 -2
- package/src/assets/asset-processing-service/asset-package-role.js +0 -3
- package/src/assets/asset-processing-service/browser-runtime-asset.factory.d.ts +0 -58
- package/src/assets/asset-processing-service/browser-runtime-asset.factory.js +0 -61
- package/src/assets/asset-processing-service/browser-runtime-entry-resolution.d.ts +0 -79
- package/src/assets/asset-processing-service/browser-runtime-entry-resolution.js +0 -200
- package/src/assets/asset-processing-service/browser-runtime-entry.factory.d.ts +0 -24
- package/src/assets/asset-processing-service/browser-runtime-entry.factory.js +0 -67
- package/src/build/browser/browser-runtime-manifest.d.ts +0 -35
- package/src/build/browser/browser-runtime-manifest.js +0 -65
- package/src/build/browser/browser-runtime-plugin-helpers.d.ts +0 -14
- package/src/build/browser/browser-runtime-plugin-helpers.js +0 -21
- package/src/build/browser/browser-runtime-plugin.d.ts +0 -54
- package/src/build/browser/browser-runtime-plugin.js +0 -76
- package/src/build/rolldown/server-side-css-shim-plugin.d.ts +0 -28
- package/src/build/rolldown/server-side-css-shim-plugin.js +0 -59
- package/src/dev/transform-server/dev-transform-module-kind.d.ts +0 -13
- package/src/dev/transform-server/dev-transform-module-kind.js +0 -17
- package/src/dev/transform-server/dev-transform-runtime-specifiers.d.ts +0 -5
- package/src/dev/transform-server/dev-transform-runtime-specifiers.js +0 -16
- package/src/route-renderer/orchestration/custom-element-scripts/custom-element-ssr-preload-entrypoint.d.ts +0 -15
- package/src/route-renderer/orchestration/custom-element-scripts/custom-element-ssr-preload-entrypoint.js +0 -65
- package/src/route-renderer/orchestration/page-browser-graph/missing-production-browser-graph.d.ts +0 -21
- package/src/route-renderer/orchestration/page-browser-graph/missing-production-browser-graph.js +0 -31
|
@@ -2,72 +2,30 @@
|
|
|
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
|
-
import
|
|
44
|
-
import {
|
|
45
|
-
import {
|
|
19
|
+
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
20
|
+
import { path } from '@ecopages/file-system/path';
|
|
21
|
+
import { fromRolldownModuleId, toRolldownModuleId } from './rolldown-module-id.js';
|
|
22
|
+
import { exclude, id as idFilter, include } from 'rolldown/filter';
|
|
46
23
|
import { escapeRegExp } from '../../utils/regex-escaping.js';
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
* @remarks
|
|
53
|
-
* A Windows drive prefix such as `C:\` or `C:/` is part of the path, not a namespace.
|
|
54
|
-
*/
|
|
55
|
-
function splitNamespace(id) {
|
|
56
|
-
const separatorIndex = id.indexOf(NAMESPACE_SEPARATOR);
|
|
57
|
-
if (separatorIndex <= 0 || /^[A-Za-z]:[\\/]/.test(id)) {
|
|
58
|
-
return { namespace: undefined, path: id };
|
|
59
|
-
}
|
|
60
|
-
return {
|
|
61
|
-
namespace: id.slice(0, separatorIndex),
|
|
62
|
-
path: id.slice(separatorIndex + 1),
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
function stripQuery(id) {
|
|
66
|
-
return id.replace(/[?#].*$/, '');
|
|
67
|
-
}
|
|
68
|
-
function inferRolldownModuleTypeFromPath(filePath) {
|
|
69
|
-
const extension = path.extname(filePath).toLowerCase();
|
|
70
|
-
switch (extension) {
|
|
24
|
+
import { isUsableSourceMap } from '../source-maps.js';
|
|
25
|
+
const VIRTUAL_MODULE_ID = /^\0/;
|
|
26
|
+
const ROLLDOWN_MODULE_LOADERS = new Set(['js', 'jsx', 'ts', 'tsx']);
|
|
27
|
+
function inferModuleType(filePath) {
|
|
28
|
+
switch (path.extname(filePath).toLowerCase()) {
|
|
71
29
|
case '.ts':
|
|
72
30
|
return 'ts';
|
|
73
31
|
case '.tsx':
|
|
@@ -82,369 +40,239 @@ function inferRolldownModuleTypeFromPath(filePath) {
|
|
|
82
40
|
return 'js';
|
|
83
41
|
}
|
|
84
42
|
}
|
|
85
|
-
const ROLLDOWN_MODULE_LOADERS = new Set(['js', 'jsx', 'ts', 'tsx']);
|
|
86
|
-
function normalizeRolldownModuleType(loader) {
|
|
87
|
-
return typeof loader === 'string' && ROLLDOWN_MODULE_LOADERS.has(loader) ? loader : undefined;
|
|
88
|
-
}
|
|
89
|
-
function convertLoadResultToModuleSource(result) {
|
|
90
|
-
if (result.loader === 'object' && result.exports && typeof result.exports === 'object') {
|
|
91
|
-
return Object.entries(result.exports)
|
|
92
|
-
.map(([key, value]) => key === 'default'
|
|
93
|
-
? `export default ${JSON.stringify(value)};`
|
|
94
|
-
: `export const ${key} = ${JSON.stringify(value)};`)
|
|
95
|
-
.join('\n');
|
|
96
|
-
}
|
|
97
|
-
return undefined;
|
|
98
|
-
}
|
|
99
|
-
function buildIdMatcher(filter, namespace) {
|
|
100
|
-
if (!namespace) {
|
|
101
|
-
return (id) => filter.test(id);
|
|
102
|
-
}
|
|
103
|
-
const prefix = `${namespace}${NAMESPACE_SEPARATOR}`;
|
|
104
|
-
return (id) => id.startsWith(prefix) && filter.test(id.slice(prefix.length));
|
|
105
|
-
}
|
|
106
43
|
function resolvePluginPath(value, importer, contextRoot) {
|
|
107
|
-
if (path.isAbsolute(value)) {
|
|
44
|
+
if (path.isAbsolute(value) || !value.startsWith('.')) {
|
|
108
45
|
return value;
|
|
109
46
|
}
|
|
110
|
-
|
|
111
|
-
const baseDir = importer ? path.dirname(importer) : contextRoot;
|
|
112
|
-
return path.resolve(baseDir, value);
|
|
113
|
-
}
|
|
114
|
-
return value;
|
|
47
|
+
return path.resolve(importer ? path.dirname(importer) : contextRoot, value);
|
|
115
48
|
}
|
|
116
|
-
function
|
|
117
|
-
if (!result || typeof result !== '
|
|
118
|
-
return
|
|
49
|
+
function toResolveResult(result, source, importer, contextRoot) {
|
|
50
|
+
if (!result || (typeof result.path !== 'string' && typeof result.external !== 'boolean')) {
|
|
51
|
+
return null;
|
|
119
52
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
moduleType: 'js',
|
|
127
|
-
};
|
|
128
|
-
return description;
|
|
129
|
-
}
|
|
130
|
-
if (typeof candidate.contents === 'string' || candidate.contents instanceof Uint8Array) {
|
|
131
|
-
const code = typeof candidate.contents === 'string' ? candidate.contents : new TextDecoder().decode(candidate.contents);
|
|
132
|
-
const description = {
|
|
133
|
-
code,
|
|
134
|
-
moduleType: (normalizeRolldownModuleType(candidate.loader) ??
|
|
135
|
-
inferRolldownModuleTypeFromPath(sourcePath)),
|
|
136
|
-
...(candidate.map !== undefined ? { map: toRolldownSourceMapInput(candidate.map) } : {}),
|
|
137
|
-
};
|
|
138
|
-
return description;
|
|
139
|
-
}
|
|
140
|
-
return undefined;
|
|
141
|
-
}
|
|
142
|
-
function convertPluginOnResolveResult(result, importer, contextRoot) {
|
|
143
|
-
if (!result || typeof result !== 'object') {
|
|
144
|
-
return undefined;
|
|
145
|
-
}
|
|
146
|
-
const candidate = result;
|
|
147
|
-
if (typeof candidate.path !== 'string' && typeof candidate.namespace !== 'string') {
|
|
148
|
-
if (typeof candidate.external !== 'boolean') {
|
|
149
|
-
return undefined;
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
const partial = { id: '' };
|
|
153
|
-
if (typeof candidate.path === 'string') {
|
|
154
|
-
partial.id = joinNamespace(candidate.namespace, resolvePluginPath(candidate.path, importer, contextRoot));
|
|
155
|
-
}
|
|
156
|
-
else if (typeof candidate.namespace === 'string') {
|
|
157
|
-
partial.id = joinNamespace(candidate.namespace, '');
|
|
158
|
-
}
|
|
159
|
-
if (typeof candidate.external === 'boolean') {
|
|
160
|
-
partial.external = candidate.external;
|
|
161
|
-
}
|
|
162
|
-
return partial;
|
|
53
|
+
return {
|
|
54
|
+
id: typeof result.path === 'string'
|
|
55
|
+
? toRolldownModuleId(resolvePluginPath(result.path, importer, contextRoot))
|
|
56
|
+
: source,
|
|
57
|
+
...(typeof result.external === 'boolean' ? { external: result.external } : {}),
|
|
58
|
+
};
|
|
163
59
|
}
|
|
164
60
|
/**
|
|
165
|
-
* Narrows a bundler-agnostic
|
|
61
|
+
* Narrows a bundler-agnostic map to Rolldown's `SourceMapInput`.
|
|
166
62
|
*
|
|
167
63
|
* @remarks
|
|
168
|
-
* `
|
|
169
|
-
*
|
|
170
|
-
* forwarded; an empty or source-less map is dropped, so the caller treats the rewrite as unmapped. The
|
|
171
|
-
* assertion to `SourceMapInput` happens after that check, so the original map object is returned without a copy.
|
|
64
|
+
* `map` is `unknown` so plugin authors stay free of Rolldown types. Only usable maps (see
|
|
65
|
+
* {@link isUsableSourceMap}) and `null` (keep the incoming map) pass; anything else is `undefined`.
|
|
172
66
|
*/
|
|
173
|
-
function
|
|
174
|
-
if (value === null)
|
|
175
|
-
return
|
|
176
|
-
}
|
|
67
|
+
function toSourceMapInput(value) {
|
|
68
|
+
if (value === null)
|
|
69
|
+
return null;
|
|
177
70
|
return isUsableSourceMap(value) ? value : undefined;
|
|
178
71
|
}
|
|
179
|
-
function
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
state.preserveIncoming = false;
|
|
183
|
-
}
|
|
184
|
-
function keepTransformMap(state, map, pluginName, sourcePath) {
|
|
185
|
-
if (state.invalidated)
|
|
186
|
-
return;
|
|
187
|
-
if (state.preserveIncoming) {
|
|
188
|
-
state.map = map;
|
|
189
|
-
state.preserveIncoming = false;
|
|
190
|
-
return;
|
|
191
|
-
}
|
|
192
|
-
if (!state.map) {
|
|
193
|
-
state.map = map;
|
|
194
|
-
return;
|
|
195
|
-
}
|
|
196
|
-
try {
|
|
197
|
-
state.map = composeSourceMaps(map, state.map);
|
|
198
|
-
}
|
|
199
|
-
catch (error) {
|
|
200
|
-
throw new EcoBuildPluginError(error, pluginName, sourcePath);
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
function updateTransformMap(state, result, previousCode, currentCode, pluginName, sourcePath) {
|
|
204
|
-
if (result.map === null) {
|
|
205
|
-
if (!state.map && !state.invalidated) {
|
|
206
|
-
state.preserveIncoming = true;
|
|
207
|
-
}
|
|
208
|
-
return;
|
|
209
|
-
}
|
|
210
|
-
if (result.map === undefined) {
|
|
211
|
-
if (currentCode !== previousCode)
|
|
212
|
-
invalidateTransformMap(state);
|
|
213
|
-
return;
|
|
72
|
+
function toLoadResult(result, id) {
|
|
73
|
+
if (!result || (typeof result.contents !== 'string' && !(result.contents instanceof Uint8Array))) {
|
|
74
|
+
return null;
|
|
214
75
|
}
|
|
215
|
-
const map =
|
|
216
|
-
if (!map) {
|
|
217
|
-
invalidateTransformMap(state);
|
|
218
|
-
return;
|
|
219
|
-
}
|
|
220
|
-
keepTransformMap(state, map, pluginName, sourcePath);
|
|
221
|
-
}
|
|
222
|
-
function createRegistration(filter, namespace, callback, pluginName) {
|
|
76
|
+
const map = toSourceMapInput(result.map);
|
|
223
77
|
return {
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
78
|
+
code: typeof result.contents === 'string' ? result.contents : new TextDecoder().decode(result.contents),
|
|
79
|
+
moduleType: typeof result.loader === 'string' && ROLLDOWN_MODULE_LOADERS.has(result.loader)
|
|
80
|
+
? result.loader
|
|
81
|
+
: inferModuleType(id),
|
|
82
|
+
...(map !== undefined ? { map } : {}),
|
|
228
83
|
};
|
|
229
84
|
}
|
|
230
85
|
/**
|
|
231
|
-
*
|
|
86
|
+
* Converts a transform result to Rolldown's shape.
|
|
232
87
|
*
|
|
233
88
|
* @remarks
|
|
234
|
-
*
|
|
235
|
-
*
|
|
236
|
-
* {@link getEcoBuildPluginName}. A new error is thrown for every attribution so the thrown value, which a
|
|
237
|
-
* plugin may share across files or freeze, is never changed; it stays available as `cause`.
|
|
89
|
+
* A rewrite without a usable map gets empty `mappings`, so Rolldown does not emit SOURCEMAP_BROKEN
|
|
90
|
+
* and the chained map does not point at stale source positions. An unchanged result is `null`.
|
|
238
91
|
*/
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
92
|
+
function toTransformResult(result, code) {
|
|
93
|
+
if (result === undefined)
|
|
94
|
+
return null;
|
|
95
|
+
const transformed = typeof result === 'string' ? result : result.code;
|
|
96
|
+
const map = typeof result === 'string' ? undefined : toSourceMapInput(result.map);
|
|
97
|
+
if (map === undefined && transformed === code)
|
|
98
|
+
return null;
|
|
99
|
+
return { code: transformed, map: map === undefined ? { mappings: '' } : map };
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Copies an error an `EcoBuildPlugin` threw, adding the module id it failed on.
|
|
103
|
+
*
|
|
104
|
+
* @remarks
|
|
105
|
+
* Rolldown writes `code`, `plugin` and `hook` onto a thrown error and leaves `id` unset, so a plugin
|
|
106
|
+
* that throws one shared or frozen error for several modules would lose its attribution. The copy
|
|
107
|
+
* keeps the thrown value unchanged as `cause`. `plugin` is set only for a `setup` error, which is
|
|
108
|
+
* thrown before Rolldown runs.
|
|
109
|
+
*/
|
|
110
|
+
function toPluginError(thrown, id, plugin) {
|
|
111
|
+
const source = typeof thrown === 'object' && thrown !== null ? thrown : {};
|
|
112
|
+
const error = new Error(typeof source.message === 'string' ? source.message : String(thrown), { cause: thrown });
|
|
113
|
+
if (typeof source.stack === 'string')
|
|
114
|
+
error.stack = source.stack;
|
|
115
|
+
const errorId = typeof source.id === 'string' ? source.id : id;
|
|
116
|
+
if (errorId)
|
|
117
|
+
error.id = errorId;
|
|
118
|
+
if (source.loc)
|
|
119
|
+
error.loc = source.loc;
|
|
120
|
+
if (typeof source.frame === 'string')
|
|
121
|
+
error.frame = source.frame;
|
|
122
|
+
if (plugin)
|
|
123
|
+
error.plugin = plugin;
|
|
124
|
+
return error;
|
|
125
|
+
}
|
|
126
|
+
async function attribute(id, run) {
|
|
127
|
+
try {
|
|
128
|
+
return await run();
|
|
129
|
+
}
|
|
130
|
+
catch (thrown) {
|
|
131
|
+
throw toPluginError(thrown, id);
|
|
261
132
|
}
|
|
262
133
|
}
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
134
|
+
function toHookFilter(options, cleanUrl = false) {
|
|
135
|
+
return [
|
|
136
|
+
...(options.exclude ? [exclude(idFilter(options.exclude, { cleanUrl }))] : []),
|
|
137
|
+
include(idFilter(options.filter, { cleanUrl })),
|
|
138
|
+
];
|
|
139
|
+
}
|
|
140
|
+
function exactIdFilter(value) {
|
|
141
|
+
return [include(idFilter(new RegExp(`^${escapeRegExp(value)}$`)))];
|
|
266
142
|
}
|
|
267
143
|
/**
|
|
268
|
-
*
|
|
269
|
-
* `EcoBuildPlugin` instances.
|
|
270
|
-
*
|
|
271
|
-
* All eco plugins are merged into one Rolldown plugin. Its `resolveId`
|
|
272
|
-
* and `load` hooks check the registrations in `plugins` array order, so
|
|
273
|
-
* registrations from earlier eco plugins win over later ones. `transform`
|
|
274
|
-
* runs every matching registration in that same order.
|
|
144
|
+
* The `onLoad` or `transform` call a builder's `addWatchFile` and `resolve` belong to.
|
|
275
145
|
*
|
|
276
146
|
* @remarks
|
|
277
|
-
*
|
|
278
|
-
*
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
*
|
|
283
|
-
* Transform filters are tested with the query and hash stripped. Rolldown
|
|
284
|
-
* tests filters against ids with `/` separators, so a filter written for
|
|
285
|
-
* backslash separators does not match on Windows.
|
|
147
|
+
* Rolldown runs hooks for many modules at once, so the module a call is for travels with its async
|
|
148
|
+
* context instead of living on the builder.
|
|
149
|
+
*/
|
|
150
|
+
const hookScope = new AsyncLocalStorage();
|
|
151
|
+
/**
|
|
152
|
+
* Creates the Rolldown plugins that drive the supplied `EcoBuildPlugin` instances.
|
|
286
153
|
*
|
|
287
|
-
*
|
|
288
|
-
*
|
|
154
|
+
* @remarks
|
|
155
|
+
* Every `setup` runs here, in order, before any Rolldown plugin exists, because Rolldown reads hook
|
|
156
|
+
* filters when a plugin is registered; a handler registered later throws. Every builder shares one
|
|
157
|
+
* `entrypoints` object, so a plugin can key state on it for one build. Transform filters are tested
|
|
158
|
+
* with the query and hash stripped and never see a `\0` virtual id. Rolldown tests filters against
|
|
159
|
+
* ids with `/` separators, so a filter written for backslash separators does not match on Windows.
|
|
289
160
|
*
|
|
290
161
|
* @param plugins - `EcoBuildPlugin` instances registered for this build.
|
|
291
|
-
* @param contextRoot - Project root used to resolve relative
|
|
292
|
-
* @param
|
|
293
|
-
* and invalidation include them.
|
|
162
|
+
* @param contextRoot - Project root used to resolve a relative path an `onResolve` callback returns.
|
|
163
|
+
* @param options.watchFiles - Receives each file a callback declares with `addWatchFile`, under the module it ran for.
|
|
294
164
|
*/
|
|
295
|
-
export async function createRolldownPluginBridge(plugins, contextRoot,
|
|
296
|
-
|
|
297
|
-
return [];
|
|
298
|
-
}
|
|
299
|
-
let moduleCount = 0;
|
|
165
|
+
export async function createRolldownPluginBridge(plugins, contextRoot, options = {}) {
|
|
166
|
+
const rolldownPlugins = [];
|
|
300
167
|
let registrationClosed = false;
|
|
301
168
|
const assertOpen = (method) => {
|
|
302
169
|
if (registrationClosed) {
|
|
303
170
|
throw new Error(`[ecopages] build.${method}() was called after the plugin setup finished. Register build plugin handlers before setup returns or its promise resolves.`);
|
|
304
171
|
}
|
|
305
172
|
};
|
|
306
|
-
const
|
|
307
|
-
|
|
308
|
-
|
|
173
|
+
const inModule = (context, moduleId, run) => hookScope.run({
|
|
174
|
+
addWatchFile(filePath) {
|
|
175
|
+
const resolved = path.resolve(contextRoot, filePath);
|
|
176
|
+
context.addWatchFile(resolved);
|
|
177
|
+
if (!options.watchFiles)
|
|
178
|
+
return;
|
|
179
|
+
const files = options.watchFiles.get(moduleId) ?? new Set();
|
|
180
|
+
files.add(resolved);
|
|
181
|
+
options.watchFiles.set(moduleId, files);
|
|
182
|
+
},
|
|
183
|
+
async resolve(specifier, importer) {
|
|
184
|
+
const resolved = await context.resolve(specifier, importer, { skipSelf: true });
|
|
185
|
+
return resolved
|
|
186
|
+
? { id: fromRolldownModuleId(resolved.id), external: Boolean(resolved.external) }
|
|
187
|
+
: undefined;
|
|
188
|
+
},
|
|
189
|
+
}, run);
|
|
190
|
+
const currentScope = (method, name) => {
|
|
191
|
+
const scope = hookScope.getStore();
|
|
192
|
+
if (!scope) {
|
|
193
|
+
throw new Error(`[ecopages] build.${method}() was called outside an onLoad or transform callback of "${name}".`);
|
|
194
|
+
}
|
|
195
|
+
return scope;
|
|
196
|
+
};
|
|
309
197
|
for (const ecoPlugin of plugins) {
|
|
310
|
-
const
|
|
198
|
+
const name = ecoPlugin.name;
|
|
311
199
|
const builder = {
|
|
312
|
-
...(entrypoints ? { entrypoints } : {}),
|
|
313
|
-
onResolve
|
|
200
|
+
...(options.entrypoints ? { entrypoints: options.entrypoints } : {}),
|
|
201
|
+
onResolve(filter, callback) {
|
|
314
202
|
assertOpen('onResolve');
|
|
315
|
-
|
|
203
|
+
rolldownPlugins.push({
|
|
204
|
+
name,
|
|
205
|
+
resolveId: {
|
|
206
|
+
filter: toHookFilter(filter),
|
|
207
|
+
handler: async (source, rolldownImporter) => {
|
|
208
|
+
const importer = rolldownImporter === undefined ? undefined : fromRolldownModuleId(rolldownImporter);
|
|
209
|
+
return toResolveResult(await attribute(importer, () => callback({ path: source, importer })), source, importer, contextRoot);
|
|
210
|
+
},
|
|
211
|
+
},
|
|
212
|
+
});
|
|
316
213
|
},
|
|
317
|
-
onLoad
|
|
214
|
+
onLoad(filter, callback) {
|
|
318
215
|
assertOpen('onLoad');
|
|
319
|
-
|
|
216
|
+
rolldownPlugins.push({
|
|
217
|
+
name,
|
|
218
|
+
load: {
|
|
219
|
+
filter: toHookFilter(filter),
|
|
220
|
+
async handler(rolldownId) {
|
|
221
|
+
const id = fromRolldownModuleId(rolldownId);
|
|
222
|
+
return toLoadResult(await attribute(id, () => inModule(this, id, () => callback({ path: id }))), id);
|
|
223
|
+
},
|
|
224
|
+
},
|
|
225
|
+
});
|
|
320
226
|
},
|
|
321
|
-
module
|
|
227
|
+
module(specifier, callback) {
|
|
322
228
|
assertOpen('module');
|
|
323
|
-
const
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
229
|
+
const virtualId = `\0${specifier}`;
|
|
230
|
+
rolldownPlugins.push({
|
|
231
|
+
name,
|
|
232
|
+
resolveId: { filter: exactIdFilter(specifier), handler: () => virtualId },
|
|
233
|
+
load: {
|
|
234
|
+
filter: exactIdFilter(virtualId),
|
|
235
|
+
handler: async () => toLoadResult(await attribute(specifier, callback), specifier),
|
|
236
|
+
},
|
|
237
|
+
});
|
|
327
238
|
},
|
|
328
|
-
transform
|
|
239
|
+
transform(filter, callback) {
|
|
329
240
|
assertOpen('transform');
|
|
330
|
-
|
|
241
|
+
rolldownPlugins.push({
|
|
242
|
+
name,
|
|
243
|
+
transform: {
|
|
244
|
+
filter: [exclude(idFilter(VIRTUAL_MODULE_ID)), ...toHookFilter(filter, true)],
|
|
245
|
+
async handler(code, rolldownId) {
|
|
246
|
+
const id = fromRolldownModuleId(rolldownId);
|
|
247
|
+
return toTransformResult(await attribute(id, () => inModule(this, id, () => callback(code, id))), code);
|
|
248
|
+
},
|
|
249
|
+
},
|
|
250
|
+
});
|
|
251
|
+
},
|
|
252
|
+
onEnd(callback) {
|
|
253
|
+
assertOpen('onEnd');
|
|
254
|
+
rolldownPlugins.push({
|
|
255
|
+
name,
|
|
256
|
+
async buildEnd(error) {
|
|
257
|
+
if (!error)
|
|
258
|
+
await attribute(undefined, callback);
|
|
259
|
+
},
|
|
260
|
+
});
|
|
261
|
+
},
|
|
262
|
+
addWatchFile(filePath) {
|
|
263
|
+
currentScope('addWatchFile', name).addWatchFile(filePath);
|
|
264
|
+
},
|
|
265
|
+
resolve(specifier, importer) {
|
|
266
|
+
return currentScope('resolve', name).resolve(specifier, importer);
|
|
331
267
|
},
|
|
332
268
|
};
|
|
333
269
|
try {
|
|
334
270
|
await ecoPlugin.setup(builder);
|
|
335
271
|
}
|
|
336
|
-
catch (
|
|
337
|
-
throw
|
|
272
|
+
catch (thrown) {
|
|
273
|
+
throw toPluginError(thrown, undefined, name);
|
|
338
274
|
}
|
|
339
275
|
}
|
|
340
276
|
registrationClosed = true;
|
|
341
|
-
|
|
342
|
-
for (const { matches, callback, pluginName } of resolveRegistrations) {
|
|
343
|
-
if (!matches(source)) {
|
|
344
|
-
continue;
|
|
345
|
-
}
|
|
346
|
-
const { namespace, path: sourcePath } = splitNamespace(source);
|
|
347
|
-
let result;
|
|
348
|
-
try {
|
|
349
|
-
result = await callback({ path: sourcePath, importer, namespace, kind: extraOptions?.kind });
|
|
350
|
-
}
|
|
351
|
-
catch (error) {
|
|
352
|
-
throw new EcoBuildPluginError(error, pluginName, importer);
|
|
353
|
-
}
|
|
354
|
-
const converted = convertPluginOnResolveResult(result, importer, contextRoot);
|
|
355
|
-
if (converted !== undefined) {
|
|
356
|
-
return converted;
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
return undefined;
|
|
360
|
-
};
|
|
361
|
-
const loadHandler = async function (id) {
|
|
362
|
-
for (const { matches, callback, pluginName } of loadRegistrations) {
|
|
363
|
-
if (!matches(id)) {
|
|
364
|
-
continue;
|
|
365
|
-
}
|
|
366
|
-
const { namespace, path: sourcePath } = splitNamespace(id);
|
|
367
|
-
const addWatchFile = typeof this?.addWatchFile === 'function' ? this.addWatchFile.bind(this) : undefined;
|
|
368
|
-
const resolved = path.isAbsolute(sourcePath) ? sourcePath : path.resolve(contextRoot, sourcePath);
|
|
369
|
-
recordBuildInput?.(id, resolved);
|
|
370
|
-
addWatchFile?.(resolved);
|
|
371
|
-
let result;
|
|
372
|
-
try {
|
|
373
|
-
result = await callback({ path: sourcePath, namespace });
|
|
374
|
-
}
|
|
375
|
-
catch (error) {
|
|
376
|
-
throw new EcoBuildPluginError(error, pluginName, sourcePath);
|
|
377
|
-
}
|
|
378
|
-
const converted = convertPluginOnLoadResult({ id }, result);
|
|
379
|
-
if (converted !== undefined) {
|
|
380
|
-
return converted;
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
return undefined;
|
|
384
|
-
};
|
|
385
|
-
/**
|
|
386
|
-
* Runs every matching transform and composes maps between them. A rewrite
|
|
387
|
-
* without a map uses empty `mappings` so Rolldown does not emit
|
|
388
|
-
* SOURCEMAP_BROKEN or report stale source positions.
|
|
389
|
-
*/
|
|
390
|
-
const transformHandler = async (code, id) => {
|
|
391
|
-
const { namespace, path: sourcePath } = splitNamespace(id);
|
|
392
|
-
if (namespace !== undefined) {
|
|
393
|
-
return undefined;
|
|
394
|
-
}
|
|
395
|
-
let current = code;
|
|
396
|
-
const mapState = { map: undefined, invalidated: false, preserveIncoming: false };
|
|
397
|
-
for (const { matches, callback, pluginName } of transformRegistrations) {
|
|
398
|
-
if (!matches(sourcePath) && !matches(stripQuery(sourcePath))) {
|
|
399
|
-
continue;
|
|
400
|
-
}
|
|
401
|
-
let result;
|
|
402
|
-
try {
|
|
403
|
-
result = await callback(current, sourcePath);
|
|
404
|
-
}
|
|
405
|
-
catch (error) {
|
|
406
|
-
throw new EcoBuildPluginError(error, pluginName, sourcePath);
|
|
407
|
-
}
|
|
408
|
-
if (!result) {
|
|
409
|
-
continue;
|
|
410
|
-
}
|
|
411
|
-
const previous = current;
|
|
412
|
-
if (typeof result === 'string') {
|
|
413
|
-
current = result;
|
|
414
|
-
if (current !== previous)
|
|
415
|
-
invalidateTransformMap(mapState);
|
|
416
|
-
continue;
|
|
417
|
-
}
|
|
418
|
-
current = result.code;
|
|
419
|
-
updateTransformMap(mapState, result, previous, current, pluginName, sourcePath);
|
|
420
|
-
}
|
|
421
|
-
const sourceMap = toRolldownSourceMapInput(mapState.map);
|
|
422
|
-
if (current === code && sourceMap === undefined && !mapState.invalidated && !mapState.preserveIncoming) {
|
|
423
|
-
return undefined;
|
|
424
|
-
}
|
|
425
|
-
return {
|
|
426
|
-
code: current,
|
|
427
|
-
map: sourceMap ?? (mapState.preserveIncoming ? null : { mappings: '' }),
|
|
428
|
-
};
|
|
429
|
-
};
|
|
430
|
-
const plugin = { name: 'ecopages-plugin-bridge' };
|
|
431
|
-
if (resolveRegistrations.length > 0) {
|
|
432
|
-
plugin.resolveId = {
|
|
433
|
-
filter: resolveRegistrations.map(({ hookFilter }) => include(idFilter(hookFilter))),
|
|
434
|
-
handler: resolveIdHandler,
|
|
435
|
-
};
|
|
436
|
-
}
|
|
437
|
-
if (loadRegistrations.length > 0) {
|
|
438
|
-
plugin.load = {
|
|
439
|
-
filter: loadRegistrations.map(({ hookFilter }) => include(idFilter(hookFilter))),
|
|
440
|
-
handler: loadHandler,
|
|
441
|
-
};
|
|
442
|
-
}
|
|
443
|
-
if (transformRegistrations.length > 0) {
|
|
444
|
-
plugin.transform = {
|
|
445
|
-
filter: transformRegistrations.map(({ hookFilter }) => include(idFilter(hookFilter, { cleanUrl: true }))),
|
|
446
|
-
handler: transformHandler,
|
|
447
|
-
};
|
|
448
|
-
}
|
|
449
|
-
return [plugin];
|
|
277
|
+
return rolldownPlugins;
|
|
450
278
|
}
|