@ecopages/core 0.6.1 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -143
- package/package.json +16 -3
- package/src/adapters/node/dev-session.js +2 -1
- package/src/adapters/node/node-client-bridge.d.ts +5 -7
- package/src/adapters/node/node-client-bridge.js +4 -14
- package/src/adapters/node/server-adapter.d.ts +4 -2
- package/src/adapters/node/server-adapter.js +13 -12
- package/src/adapters/shared/hmr/client-bridge.d.ts +25 -0
- package/src/adapters/shared/hmr/client-bridge.js +35 -0
- package/src/adapters/shared/hmr/dev-transform-entrypoint-registry.js +1 -1
- package/src/adapters/shared/hmr/hmr-manager.d.ts +9 -2
- package/src/adapters/shared/hmr/hmr-manager.js +36 -6
- package/src/adapters/shared/http/dist-file-handler.js +3 -7
- package/src/adapters/shared/http/response-headers.d.ts +29 -0
- package/src/adapters/shared/http/response-headers.js +89 -0
- package/src/adapters/shared/runtime/copy-runtime-public-dir.js +1 -1
- package/src/adapters/shared/runtime/runtime-server-lifecycle.d.ts +3 -2
- package/src/adapters/shared/runtime/runtime-server-lifecycle.js +4 -3
- package/src/adapters/shared/runtime/server-request-pipeline.js +4 -4
- package/src/adapters/shared/runtime/server-static-builder.d.ts +19 -8
- package/src/adapters/shared/runtime/server-static-builder.js +23 -4
- package/src/adapters/shared/ws/node-http-websocket-upgrades.d.ts +1 -1
- package/src/adapters/shared/ws/node-http-websocket-upgrades.js +23 -16
- package/src/assets/app-browser-client-build.d.ts +5 -12
- package/src/assets/app-browser-client-build.js +121 -336
- package/src/assets/asset-processing-service/app-browser-client-bundle.d.ts +4 -0
- package/src/assets/asset-processing-service/app-browser-client-bundle.js +6 -0
- package/src/assets/asset-processing-service/asset-dependency-keys.d.ts +28 -8
- package/src/assets/asset-processing-service/asset-dependency-keys.js +104 -29
- package/src/assets/asset-processing-service/asset-processing.service.d.ts +60 -2
- package/src/assets/asset-processing-service/asset-processing.service.js +189 -58
- package/src/assets/asset-processing-service/bundleable-script.d.ts +3 -0
- package/src/assets/asset-processing-service/bundleable-script.js +4 -0
- package/src/assets/asset-processing-service/grouped-content-bundles.d.ts +2 -2
- package/src/assets/asset-processing-service/grouped-content-bundles.js +5 -10
- package/src/assets/asset-processing-service/index.d.ts +0 -3
- package/src/assets/asset-processing-service/index.js +0 -3
- package/src/assets/asset-processing-service/last-good-output.d.ts +21 -0
- package/src/assets/asset-processing-service/last-good-output.js +32 -0
- package/src/assets/asset-processing-service/page-package.js +1 -4
- package/src/assets/asset-processing-service/processed-asset-ledger.d.ts +63 -0
- package/src/assets/asset-processing-service/processed-asset-ledger.js +101 -0
- package/src/assets/asset-processing-service/processors/base/base-processor.js +1 -1
- package/src/assets/asset-processing-service/processors/base/base-script-processor.js +1 -1
- package/src/assets/asset-processing-service/processors/script/content-script.processor.d.ts +24 -0
- package/src/assets/asset-processing-service/processors/script/content-script.processor.js +59 -4
- package/src/assets/asset-processing-service/processors/script/file-script.processor.d.ts +8 -4
- package/src/assets/asset-processing-service/processors/script/file-script.processor.js +18 -6
- package/src/assets/asset-processing-service/processors/script/node-module-script.processor.js +2 -3
- package/src/assets/asset-processing-service/processors/stylesheet/app-stylesheet-imports.d.ts +34 -0
- package/src/assets/asset-processing-service/processors/stylesheet/app-stylesheet-imports.js +115 -0
- package/src/assets/asset-processing-service/processors/stylesheet/content-stylesheet.processor.js +2 -2
- package/src/assets/asset-processing-service/processors/stylesheet/css-module-types.d.ts +39 -0
- package/src/assets/asset-processing-service/processors/stylesheet/css-module-types.js +150 -0
- package/src/assets/asset-processing-service/processors/stylesheet/css-scanner.d.ts +84 -0
- package/src/assets/asset-processing-service/processors/stylesheet/css-scanner.js +379 -0
- package/src/assets/asset-processing-service/processors/stylesheet/file-stylesheet.processor.d.ts +16 -0
- package/src/assets/asset-processing-service/processors/stylesheet/file-stylesheet.processor.js +50 -24
- package/src/assets/asset-processing-service/processors/stylesheet/import-order.d.ts +33 -0
- package/src/assets/asset-processing-service/processors/stylesheet/import-order.js +67 -0
- package/src/assets/asset-processing-service/processors/stylesheet/package-stylesheet.d.ts +44 -0
- package/src/assets/asset-processing-service/processors/stylesheet/package-stylesheet.js +149 -0
- package/src/assets/asset-processing-service/processors/stylesheet/processed-stylesheet-cache.d.ts +31 -0
- package/src/assets/asset-processing-service/processors/stylesheet/processed-stylesheet-cache.js +59 -0
- package/src/assets/asset-processing-service/processors/stylesheet/source-relative-stylesheet.d.ts +20 -0
- package/src/assets/asset-processing-service/processors/stylesheet/source-relative-stylesheet.js +51 -0
- package/src/assets/asset-processing-service/processors/stylesheet/stylesheet-failure.d.ts +2 -0
- package/src/assets/asset-processing-service/processors/stylesheet/stylesheet-failure.js +5 -0
- package/src/assets/asset-processing-service/processors/stylesheet/stylesheet-module.d.ts +37 -0
- package/src/assets/asset-processing-service/processors/stylesheet/stylesheet-module.js +48 -0
- package/src/assets/asset-processing-service/processors/stylesheet/stylesheet-processor-pipeline.d.ts +25 -1
- package/src/assets/asset-processing-service/processors/stylesheet/stylesheet-processor-pipeline.js +56 -15
- package/src/assets/asset-processing-service/processors/stylesheet/stylesheet-warnings.d.ts +9 -0
- package/src/assets/asset-processing-service/processors/stylesheet/stylesheet-warnings.js +21 -0
- package/src/assets/browser-asset-output.js +1 -1
- package/src/assets/hashed-browser-asset.js +1 -1
- package/src/assets/{browser-runtime-asset-page-cache.d.ts → page-script-page-cache.d.ts} +3 -3
- package/src/assets/{browser-runtime-asset-page-cache.js → page-script-page-cache.js} +3 -3
- package/src/build/app-build-manifest-runtime.d.ts +23 -11
- package/src/build/app-build-manifest-runtime.js +52 -13
- package/src/build/browser/jsx-ownership-plugins.d.ts +4 -1
- package/src/build/browser/jsx-ownership-plugins.js +6 -0
- package/src/build/build-adapter.d.ts +1 -1
- package/src/build/build-adapter.js +1 -1
- package/src/build/build-graph.d.ts +4 -2
- package/src/build/build-graph.js +12 -46
- package/src/build/cache/build-input-dependency-index.d.ts +0 -19
- package/src/build/cache/build-input-dependency-index.js +1 -34
- package/src/build/cache/pages-unified-graph-build.js +7 -43
- package/src/build/cache/server-module-entries.d.ts +1 -1
- package/src/build/cache/server-module-entries.js +9 -9
- package/src/build/contracts/build-contracts.d.ts +59 -12
- package/src/build/contracts/build-manifest.d.ts +3 -6
- package/src/build/contracts/build-manifest.js +2 -12
- package/src/build/contracts/content-virtual-modules.js +1 -3
- package/src/build/copy-server-files.js +1 -1
- package/src/build/preserve-import-meta-transform.d.ts +3 -1
- package/src/build/preserve-import-meta-transform.js +7 -4
- package/src/build/production-asset-ledger.d.ts +36 -0
- package/src/build/production-asset-ledger.js +104 -0
- package/src/build/production-dist-complete.js +12 -13
- package/src/build/production-route-list.js +1 -1
- package/src/build/rolldown/app-package-declarations.js +1 -1
- package/src/build/rolldown/entry-module-closures.d.ts +5 -1
- package/src/build/rolldown/entry-module-closures.js +21 -8
- package/src/build/rolldown/rolldown-adapter-helpers.d.ts +19 -8
- package/src/build/rolldown/rolldown-adapter-helpers.js +82 -45
- package/src/build/rolldown/rolldown-build-adapter.js +10 -13
- package/src/build/rolldown/rolldown-module-id.d.ts +18 -0
- package/src/build/rolldown/rolldown-module-id.js +29 -0
- package/src/build/rolldown/rolldown-plugin-bridge.d.ts +24 -60
- package/src/build/rolldown/rolldown-plugin-bridge.js +201 -373
- package/src/build/rolldown/stylesheet-module-plugin.d.ts +34 -0
- package/src/build/rolldown/stylesheet-module-plugin.js +160 -0
- package/src/build/rolldown/worker-entries-plugin.d.ts +13 -0
- package/src/build/rolldown/worker-entries-plugin.js +57 -0
- package/src/build/runtime/build-environment-options.js +13 -3
- package/src/build/runtime/build-request-identity.js +1 -1
- package/src/build/runtime/build-request-policy.d.ts +7 -12
- package/src/build/runtime/build-request-policy.js +63 -17
- package/src/build/server/imported-view-plugin.d.ts +1 -0
- package/src/build/server/imported-view-plugin.js +6 -4
- package/src/build/server/page-module-import.service.d.ts +1 -2
- package/src/build/server/page-module-import.service.js +4 -6
- package/src/build/server/resolve-static-view.js +3 -2
- package/src/build/server/route-module-build-cache-registry.js +1 -1
- package/src/build/server/route-module-build-cache.store.js +1 -1
- package/src/build/server/route-module-build-manifest.js +1 -1
- package/src/build/server/route-module-dependency-hasher.d.ts +1 -1
- package/src/build/server/route-module-dependency-hasher.js +2 -2
- package/src/build/server/server-modules-manifest.d.ts +3 -5
- package/src/build/server/server-modules-manifest.js +6 -21
- package/src/build/server/view-module.d.ts +12 -0
- package/src/build/server/view-module.js +23 -0
- package/src/build/server/view-reference.d.ts +16 -5
- package/src/build/server/view-reference.js +25 -14
- package/src/build/server-bundle-deploy-manifest.d.ts +1 -1
- package/src/build/server-bundle-deploy-manifest.js +2 -2
- package/src/build/server-bundle-publication.d.ts +7 -1
- package/src/build/server-bundle-publication.js +11 -4
- package/src/build/server-module.js +1 -1
- package/src/build/worker-urls.d.ts +60 -0
- package/src/build/worker-urls.js +197 -0
- package/src/build.d.ts +7 -5
- package/src/build.js +7 -5
- package/src/cache/module-parse-cache.js +2 -2
- package/src/client/navigation-attributes.d.ts +8 -0
- package/src/client/navigation-attributes.js +8 -0
- package/src/client/navigation-scripts/global-scripts.d.ts +14 -0
- package/src/client/navigation-scripts/global-scripts.js +65 -0
- package/src/client/navigation-scripts/index.d.ts +1 -0
- package/src/client/navigation-scripts/index.js +1 -0
- package/src/client.d.ts +2 -2
- package/src/client.js +2 -2
- package/src/config/assembly/app-runtime.d.ts +45 -5
- package/src/config/assembly/app-runtime.js +11 -2
- package/src/config/assembly/finalize-config.js +13 -5
- package/src/config/config-module-files.js +10 -6
- package/src/config/index.d.ts +2 -1
- package/src/config/internal-types.d.ts +3 -0
- package/src/config/load-eco-config.js +8 -5
- package/src/config/resolve-eco-config-path.js +3 -3
- package/src/config/server-config-bundle.js +1 -1
- package/src/config/user-config-types.d.ts +54 -1
- package/src/config/write-types.js +4 -1
- package/src/css-imports.d.ts +12 -0
- package/src/declarations.d.ts +2 -0
- package/src/dev/development-restart-watch-paths.js +1 -1
- package/src/dev/development-restart.js +1 -1
- package/src/dev/invalidation/development-invalidation.service.d.ts +6 -1
- package/src/dev/invalidation/development-invalidation.service.js +18 -2
- package/src/dev/stylesheets/development-stylesheet.service.d.ts +149 -0
- package/src/dev/stylesheets/development-stylesheet.service.js +350 -0
- package/src/dev/transform-server/dev-transform-bundler.d.ts +12 -3
- package/src/dev/transform-server/dev-transform-bundler.js +32 -21
- package/src/dev/transform-server/dev-transform-externalize-plugin.d.ts +3 -5
- package/src/dev/transform-server/dev-transform-externalize-plugin.js +8 -9
- package/src/dev/transform-server/dev-transform-import-rewriter.d.ts +15 -2
- package/src/dev/transform-server/dev-transform-import-rewriter.js +204 -35
- package/src/dev/transform-server/dev-transform-install-stamp.d.ts +17 -0
- package/src/dev/transform-server/dev-transform-install-stamp.js +79 -0
- package/src/dev/transform-server/dev-transform-server.d.ts +38 -2
- package/src/dev/transform-server/dev-transform-server.js +96 -33
- package/src/dev/transform-server/dev-transform-url.d.ts +4 -2
- package/src/dev/transform-server/dev-transform-url.js +13 -12
- package/src/dev/transform-server/dev-transform-vendor-registry.d.ts +178 -21
- package/src/dev/transform-server/dev-transform-vendor-registry.js +675 -99
- package/src/dev/transform-server/index.d.ts +1 -1
- package/src/dev-toolbar/dev-toolbar-package.js +4 -4
- package/src/eco/component-render-output.d.ts +6 -1
- package/src/eco/component-render-output.js +32 -7
- package/src/eco/discovered-dependencies.d.ts +30 -11
- package/src/eco/discovered-dependencies.js +25 -13
- package/src/eco/discovered-dependency-paths.d.ts +36 -0
- package/src/eco/discovered-dependency-paths.js +58 -0
- package/src/eco/eco.browser.js +8 -12
- package/src/eco/eco.js +0 -30
- package/src/eco/mdx-page-metadata.d.ts +14 -0
- package/src/eco/mdx-page-metadata.js +15 -0
- package/src/eco/page-layout-normalization.d.ts +6 -2
- package/src/eco/page-layout-normalization.js +9 -6
- package/src/env.js +17 -0
- package/src/hmr/client/hmr-runtime.js +14 -13
- package/src/hmr/dev-client-runtime.d.ts +5 -2
- package/src/hmr/dev-client-runtime.js +14 -4
- package/src/hmr/hmr-entrypoint-output.js +1 -1
- package/src/hmr/hmr-strategy.d.ts +2 -2
- package/src/hmr/hmr-strategy.js +2 -2
- package/src/hmr/strategies/js-hmr-strategy.d.ts +4 -1
- package/src/hmr/strategies/js-hmr-strategy.js +7 -6
- package/src/hmr/strategies/template-source-hmr-strategy.d.ts +25 -0
- package/src/hmr/strategies/template-source-hmr-strategy.js +36 -0
- package/src/html-pages/html-page-module-scripts.d.ts +2 -1
- package/src/html-pages/html-page-module-scripts.js +37 -14
- package/src/html-pages/html-page-module.js +1 -1
- package/src/html-pages/html-page-renderer.js +7 -6
- package/src/html-pages/html-page-template.d.ts +0 -5
- package/src/html-pages/html-page-template.js +3 -15
- package/src/html-pages/html-pages.plugin.js +2 -2
- package/src/integration.d.ts +8 -6
- package/src/integration.js +5 -3
- package/src/page-cache/html-page-cache-dependency-index.js +1 -1
- package/src/page-cache/page-cache-service.js +1 -1
- package/src/plugins/alias-resolver-plugin.d.ts +7 -0
- package/src/plugins/alias-resolver-plugin.js +16 -6
- package/src/plugins/component-import-discovery.d.ts +178 -7
- package/src/plugins/component-import-discovery.js +696 -112
- package/src/plugins/eco-component-meta-plugin.d.ts +47 -6
- package/src/plugins/eco-component-meta-plugin.js +227 -59
- package/src/plugins/foreign-jsx-override-plugin.d.ts +14 -1
- package/src/plugins/foreign-jsx-override-plugin.js +18 -8
- package/src/plugins/integration-plugin.d.ts +47 -11
- package/src/plugins/integration-plugin.js +57 -8
- package/src/plugins/processor.d.ts +72 -7
- package/src/plugins/processor.js +44 -9
- package/src/plugins/stylesheet-kinds.d.ts +57 -0
- package/src/plugins/stylesheet-kinds.js +114 -0
- package/src/plugins/tsconfig-import-resolver.d.ts +49 -3
- package/src/plugins/tsconfig-import-resolver.js +120 -6
- package/src/processor-contract.d.ts +66 -0
- package/src/processor-contract.js +389 -0
- package/src/processor.d.ts +6 -1
- package/src/processor.js +6 -1
- package/src/route-renderer/error-pages/default-error-pages.d.ts +1 -0
- package/src/route-renderer/error-pages/default-error-pages.js +27 -7
- package/src/route-renderer/orchestration/custom-element-scripts/custom-element-script-preload-invalidation.d.ts +8 -0
- package/src/route-renderer/orchestration/custom-element-scripts/custom-element-script-preload-invalidation.js +12 -0
- package/src/route-renderer/orchestration/custom-element-scripts/custom-element-script-preloader.d.ts +77 -24
- package/src/route-renderer/orchestration/custom-element-scripts/custom-element-script-preloader.js +97 -32
- package/src/route-renderer/orchestration/custom-element-scripts/custom-element-server-module-importer.js +1 -1
- package/src/route-renderer/orchestration/document-shell/document-shell-render.service.d.ts +9 -0
- package/src/route-renderer/orchestration/document-shell/document-shell-render.service.js +16 -2
- package/src/route-renderer/orchestration/document-shell/layout-children-not-rendered-error.d.ts +35 -0
- package/src/route-renderer/orchestration/document-shell/layout-children-not-rendered-error.js +53 -0
- package/src/route-renderer/orchestration/foreign-child/render-session.d.ts +4 -8
- package/src/route-renderer/orchestration/foreign-child/render-session.js +2 -5
- package/src/route-renderer/orchestration/integration-renderer.d.ts +171 -64
- package/src/route-renderer/orchestration/integration-renderer.js +293 -332
- package/src/route-renderer/orchestration/ownership-graph/component-graph-collectors.d.ts +8 -5
- package/src/route-renderer/orchestration/ownership-graph/component-graph-collectors.js +27 -25
- package/src/route-renderer/orchestration/ownership-graph/component-graph.d.ts +0 -6
- package/src/route-renderer/orchestration/page-browser-graph/global-injector-assets.service.js +3 -3
- package/src/route-renderer/orchestration/page-browser-graph/grouped-graph-build-plan.d.ts +12 -25
- package/src/route-renderer/orchestration/page-browser-graph/grouped-graph-build-plan.js +1 -14
- package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph-session.d.ts +0 -16
- package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph-session.js +1 -87
- package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph.service.d.ts +8 -16
- package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph.service.js +25 -271
- package/src/route-renderer/orchestration/page-browser-graph/route-instance-key.d.ts +0 -24
- package/src/route-renderer/orchestration/page-browser-graph/route-instance-key.js +0 -67
- package/src/route-renderer/orchestration/route-pipeline/route-render-orchestrator.d.ts +28 -15
- package/src/route-renderer/orchestration/route-pipeline/route-render-orchestrator.js +63 -41
- package/src/route-renderer/page-loading/component-dependency-collection.d.ts +4 -1
- package/src/route-renderer/page-loading/component-dependency-collection.js +51 -15
- package/src/route-renderer/page-loading/dependency-resolver.d.ts +10 -0
- package/src/route-renderer/page-loading/dependency-resolver.js +27 -6
- package/src/route-renderer/page-loading/file-scoped-dependency-components.d.ts +4 -2
- package/src/route-renderer/page-loading/file-scoped-dependency-components.js +22 -17
- package/src/route-renderer/page-loading/lazy-entry-collection.d.ts +5 -0
- package/src/route-renderer/page-loading/lazy-entry-collection.js +6 -4
- package/src/route-renderer/page-loading/page-dependency-bundling.d.ts +5 -2
- package/src/route-renderer/page-loading/page-dependency-bundling.js +15 -31
- package/src/route-renderer/page-loading/page-module-loader.d.ts +13 -2
- package/src/route-renderer/page-loading/page-module-loader.js +23 -5
- package/src/route-renderer/route-renderer.d.ts +1 -1
- package/src/router/client/navigation-commit.d.ts +2 -0
- package/src/router/client/navigation-commit.js +4 -1
- package/src/router/client/navigation-coordinator.d.ts +18 -0
- package/src/router/client/navigation-coordinator.js +14 -0
- package/src/router/client/navigation-lifecycle.d.ts +18 -1
- package/src/router/client/navigation-lifecycle.js +6 -3
- package/src/router/client/navigation-pipeline.d.ts +1 -0
- package/src/router/client/navigation-pipeline.js +1 -0
- package/src/router/server/route-registry.d.ts +3 -2
- package/src/router/server/route-registry.js +6 -5
- package/src/static-site-generator/production-page-browser-graph-prebuild.d.ts +30 -18
- package/src/static-site-generator/production-page-browser-graph-prebuild.js +82 -143
- package/src/static-site-generator/static-site-generator.d.ts +37 -4
- package/src/static-site-generator/static-site-generator.js +99 -51
- package/src/types/asset-types.d.ts +19 -1
- package/src/types/build-types.d.ts +53 -35
- package/src/types/component-identity.d.ts +8 -0
- package/src/types/contracts.d.ts +69 -21
- package/src/types/dev-transform-types.d.ts +33 -6
- package/src/types/eco-api-types.d.ts +13 -18
- package/src/types/integration-types.d.ts +1 -1
- package/src/types/public-types.d.ts +1 -1
- package/src/utils/additional-watch-paths.js +3 -5
- package/src/utils/entry-command-flags.d.ts +23 -0
- package/src/utils/entry-command-flags.js +24 -0
- package/src/utils/package-path.d.ts +42 -0
- package/src/utils/package-path.js +114 -0
- package/src/utils/parse-cli-args.d.ts +18 -1
- package/src/utils/parse-cli-args.js +54 -37
- package/src/utils/path-containment.js +3 -10
- package/src/utils/resolve-work-dir.js +2 -2
- package/src/utils/root-relative-path.js +2 -2
- package/src/utils/server-bundle-context.d.ts +5 -0
- package/src/utils/server-bundle-context.js +7 -1
- package/src/utils/server-utils.module.js +1 -1
- package/src/watchers/project-watcher-ignore.js +3 -3
- package/src/watchers/project-watcher.d.ts +14 -2
- package/src/watchers/project-watcher.js +37 -6
- package/src/watchers/workspace-package-watch-roots.js +2 -2
- package/src/assets/app-browser-client-manifest.d.ts +0 -66
- package/src/assets/app-browser-client-manifest.js +0 -260
- package/src/assets/asset-processing-service/asset-package-role.d.ts +0 -2
- package/src/assets/asset-processing-service/asset-package-role.js +0 -3
- package/src/assets/asset-processing-service/browser-runtime-asset.factory.d.ts +0 -58
- package/src/assets/asset-processing-service/browser-runtime-asset.factory.js +0 -61
- package/src/assets/asset-processing-service/browser-runtime-entry-resolution.d.ts +0 -79
- package/src/assets/asset-processing-service/browser-runtime-entry-resolution.js +0 -200
- package/src/assets/asset-processing-service/browser-runtime-entry.factory.d.ts +0 -24
- package/src/assets/asset-processing-service/browser-runtime-entry.factory.js +0 -67
- package/src/build/browser/browser-runtime-manifest.d.ts +0 -35
- package/src/build/browser/browser-runtime-manifest.js +0 -65
- package/src/build/browser/browser-runtime-plugin-helpers.d.ts +0 -14
- package/src/build/browser/browser-runtime-plugin-helpers.js +0 -21
- package/src/build/browser/browser-runtime-plugin.d.ts +0 -54
- package/src/build/browser/browser-runtime-plugin.js +0 -76
- package/src/build/rolldown/server-side-css-shim-plugin.d.ts +0 -28
- package/src/build/rolldown/server-side-css-shim-plugin.js +0 -59
- package/src/dev/transform-server/dev-transform-module-kind.d.ts +0 -13
- package/src/dev/transform-server/dev-transform-module-kind.js +0 -17
- package/src/dev/transform-server/dev-transform-runtime-specifiers.d.ts +0 -5
- package/src/dev/transform-server/dev-transform-runtime-specifiers.js +0 -16
- package/src/route-renderer/orchestration/custom-element-scripts/custom-element-ssr-preload-entrypoint.d.ts +0 -15
- package/src/route-renderer/orchestration/custom-element-scripts/custom-element-ssr-preload-entrypoint.js +0 -65
- package/src/route-renderer/orchestration/page-browser-graph/missing-production-browser-graph.d.ts +0 -21
- package/src/route-renderer/orchestration/page-browser-graph/missing-production-browser-graph.js +0 -31
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { EcoPagesAppConfig } from '../config/internal-types.js';
|
|
2
2
|
import type { EcoBuildOnTransformResult, EcoBuildPlugin } from '../build/contracts/build-types.js';
|
|
3
|
+
import { type StylesheetKinds } from './stylesheet-kinds.js';
|
|
4
|
+
import { type DiscoveryCache, type DiscoveryOptions } from './component-import-discovery.js';
|
|
3
5
|
/**
|
|
4
6
|
* Options for the plugin that attributes Eco Component identities.
|
|
5
7
|
*
|
|
@@ -12,9 +14,38 @@ export interface EcoComponentDirPluginOptions {
|
|
|
12
14
|
}
|
|
13
15
|
/**
|
|
14
16
|
* Whether the component meta transform moves the side-effect stylesheet imports of `filePath`
|
|
15
|
-
* into its Component Dependencies, removing them from the module.
|
|
17
|
+
* into its own Component Dependencies, removing them from the module.
|
|
18
|
+
*
|
|
19
|
+
* @remarks
|
|
20
|
+
* Only a module with an `eco.*()` call delivers its own imports. A plain module loses them too, but only a
|
|
21
|
+
* declaration that imports it delivers them, which an HTML Page module script is not, so the HTML Page scan
|
|
22
|
+
* still reports them.
|
|
16
23
|
*/
|
|
17
24
|
export declare function stripsSideEffectStylesheetImports(config: EcoPagesAppConfig, filePath: string, contents: string): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Options for {@link attributeComponentIdentity}.
|
|
27
|
+
*/
|
|
28
|
+
export type ComponentIdentityAttributionOptions = {
|
|
29
|
+
/** The Integration that owns the module, or `undefined` for a module no Integration owns. */
|
|
30
|
+
integration: string | undefined;
|
|
31
|
+
projectRoot: string;
|
|
32
|
+
jsxImportSource?: string;
|
|
33
|
+
/** Resolves the Integration that owns any file, for the cross-Integration check of discovery. */
|
|
34
|
+
integrationOf?: DiscoveryOptions['integrationOf'];
|
|
35
|
+
/** Receives each side-effect stylesheet import removed from a module without `eco.*()` calls. */
|
|
36
|
+
onStrippedStylesheet?: (source: string) => void;
|
|
37
|
+
/**
|
|
38
|
+
* Whether a module without `eco.*()` calls loses its delivered stylesheet imports; defaults to `true`.
|
|
39
|
+
*
|
|
40
|
+
* @remarks
|
|
41
|
+
* The build plugin turns it off for a package module outside the app root that discovery has not reached.
|
|
42
|
+
*/
|
|
43
|
+
stripPlainModuleStylesheets?: boolean;
|
|
44
|
+
/** Discovery results shared by the transforms of one build. */
|
|
45
|
+
discoveryCache?: DiscoveryCache;
|
|
46
|
+
/** The stylesheets the build delivers; defaults to plain `.css`. */
|
|
47
|
+
stylesheets?: StylesheetKinds;
|
|
48
|
+
};
|
|
18
49
|
/**
|
|
19
50
|
* Attributes real `eco.*()` factory calls with canonical component identity.
|
|
20
51
|
*
|
|
@@ -23,23 +54,33 @@ export declare function stripsSideEffectStylesheetImports(config: EcoPagesAppCon
|
|
|
23
54
|
* file share that name. Server and browser builds of one source derive the same id, and a named declaration
|
|
24
55
|
* keeps it while other code in the file changes. Calls bound to no name (an inline argument, a call inside an
|
|
25
56
|
* anonymous function) are numbered in source order, so adding or removing another unnamed call before them
|
|
26
|
-
* changes their id. `file` stays the module
|
|
57
|
+
* changes their id. `file` stays the module's root-relative source key for every call in the file. A module without calls only
|
|
58
|
+
* loses its side-effect stylesheet imports (see {@link stripPlainModuleStylesheetImports}).
|
|
27
59
|
*/
|
|
28
|
-
export declare function attributeComponentIdentity(contents: string, filePath: string,
|
|
60
|
+
export declare function attributeComponentIdentity(contents: string, filePath: string, options: ComponentIdentityAttributionOptions): EcoBuildOnTransformResult;
|
|
29
61
|
/**
|
|
30
62
|
* Attributes a compiled MDX module with canonical component identity and discovered dependencies.
|
|
31
63
|
*
|
|
32
64
|
* @remarks
|
|
33
65
|
* Pass the MDX compiler's map as `previousMap` so the returned map traces back to the `.mdx` file; without
|
|
34
66
|
* it the map is relative to the compiled module.
|
|
67
|
+
*
|
|
68
|
+
* `stylesheets` are the kinds of the app's stylesheet Processor, passed by the Integration that creates the MDX
|
|
69
|
+
* loader; without them only `.css` imports are discovered.
|
|
35
70
|
*/
|
|
36
|
-
export declare function attributeMdxComponentIdentity(contents: string, filePath: string, integration: string, projectRoot: string, previousMap?: unknown): EcoBuildOnTransformResult;
|
|
71
|
+
export declare function attributeMdxComponentIdentity(contents: string, filePath: string, integration: string, projectRoot: string, previousMap?: unknown, stylesheets?: StylesheetKinds): EcoBuildOnTransformResult;
|
|
37
72
|
/**
|
|
38
|
-
* Creates the build plugin that attributes component identity in every Integration's script files
|
|
73
|
+
* Creates the build plugin that attributes component identity in every Integration's script files and
|
|
74
|
+
* removes the stylesheet imports discovery delivers from every local script module.
|
|
39
75
|
*
|
|
40
76
|
* @remarks
|
|
41
77
|
* Core adds it to every build request after the app's plugins and before its `import.meta` transform, so no
|
|
42
|
-
* contributed plugin sees the attribution of another.
|
|
78
|
+
* contributed plugin sees the attribution of another. A module no Integration owns can still be a plain
|
|
79
|
+
* module discovery walks, so the filter takes every script outside `node_modules`. A module outside the app
|
|
80
|
+
* root, such as a linked workspace package, is a package: its stylesheet imports are only removed once
|
|
81
|
+
* discovery has reached it, and it never fails the reach check. A build can transform a
|
|
82
|
+
* plain module before the declaration that imports it, so the check that a declaration reached each
|
|
83
|
+
* module that lost a stylesheet import runs once the whole build is transformed.
|
|
43
84
|
*/
|
|
44
85
|
export declare function createEcoComponentMetaPlugin(options: EcoComponentDirPluginOptions): EcoBuildPlugin;
|
|
45
86
|
export default createEcoComponentMetaPlugin;
|
|
@@ -1,11 +1,18 @@
|
|
|
1
|
+
import { path } from '@ecopages/file-system/path';
|
|
2
|
+
import { fileSystem } from '@ecopages/file-system';
|
|
1
3
|
import MagicString from 'magic-string';
|
|
2
4
|
import { createJsxImportSourcePragma } from './jsx-import-source.utils.js';
|
|
3
5
|
import { composeSourceMaps, isUsableSourceMap } from '../build/source-maps.js';
|
|
4
|
-
import {
|
|
6
|
+
import { createMappedSourceTransformResult } from '../build/mapped-source-transform.js';
|
|
5
7
|
import { parseModuleSource } from '../cache/module-parse-cache.js';
|
|
8
|
+
import { getStylesheetKinds, PLAIN_CSS_KINDS } from './stylesheet-kinds.js';
|
|
6
9
|
import { contentHash } from '../utils/content-hash.js';
|
|
7
10
|
import { escapeRegExp } from '../utils/regex-escaping.js';
|
|
8
|
-
import {
|
|
11
|
+
import { toPackagePath } from '../utils/package-path.js';
|
|
12
|
+
import { formatPackageStylesheetEntry } from '../eco/discovered-dependency-paths.js';
|
|
13
|
+
import { toRootRelativePath } from '../utils/root-relative-path.js';
|
|
14
|
+
import { collectStaticImports, createDiscoveryCache, createUndeliverableStylesheetError, declaresEcoFactory, forgetDiscoveryOwner, discoverComponentImports, isDeliveredStylesheetImport, isReachedByDiscovery, } from './component-import-discovery.js';
|
|
15
|
+
import { loadTsconfigPathPrefixes } from './tsconfig-import-resolver.js';
|
|
9
16
|
import { findIntegrationForFile } from './find-integration-for-file.js';
|
|
10
17
|
function applySourceEdits(contents, edits, filePath, options = {}) {
|
|
11
18
|
if (edits.length === 0 && !options.prepend && !options.append) {
|
|
@@ -35,6 +42,11 @@ function applySourceEdits(contents, edits, filePath, options = {}) {
|
|
|
35
42
|
};
|
|
36
43
|
return createMappedSourceTransformResult(contents, filePath, editSource);
|
|
37
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* Matches the text of a side-effect import such as `import 'swiper/css'`, which can name a package stylesheet
|
|
47
|
+
* without a `.css` suffix.
|
|
48
|
+
*/
|
|
49
|
+
const SIDE_EFFECT_IMPORT = /(?:^|[;}\s])import\s*['"]/m;
|
|
38
50
|
function isAstNode(value) {
|
|
39
51
|
return typeof value === 'object' && value !== null;
|
|
40
52
|
}
|
|
@@ -61,18 +73,6 @@ function isIdentityBinding(node) {
|
|
|
61
73
|
return false;
|
|
62
74
|
return node.callee.type === 'Identifier' && node.callee.name === 'bindComponentIdentity';
|
|
63
75
|
}
|
|
64
|
-
function walkAst(node, visit) {
|
|
65
|
-
if (Array.isArray(node)) {
|
|
66
|
-
for (const child of node)
|
|
67
|
-
walkAst(child, visit);
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
if (!isAstNode(node))
|
|
71
|
-
return;
|
|
72
|
-
visit(node);
|
|
73
|
-
for (const value of Object.values(node))
|
|
74
|
-
walkAst(value, visit);
|
|
75
|
-
}
|
|
76
76
|
/**
|
|
77
77
|
* Visits each `eco.*()` call with the name of the declaration it belongs to.
|
|
78
78
|
*
|
|
@@ -100,9 +100,33 @@ function walkEcoFactoryCalls(node, binding, visit) {
|
|
|
100
100
|
for (const value of Object.values(node))
|
|
101
101
|
walkEcoFactoryCalls(value, scope, visit);
|
|
102
102
|
}
|
|
103
|
-
|
|
103
|
+
/**
|
|
104
|
+
* Returns the function that names a file the way server modules and the ledger store it: relative to the app
|
|
105
|
+
* root, with forward slashes.
|
|
106
|
+
*
|
|
107
|
+
* @remarks
|
|
108
|
+
* Both sides are real paths, so a root reached through a symlink, such as macOS `/tmp`, relativizes the
|
|
109
|
+
* real module ids the bundler reports. A file not on disk, such as a virtual module, takes the real path of its
|
|
110
|
+
* folder.
|
|
111
|
+
*/
|
|
112
|
+
function createSourceKeyResolver(projectRoot) {
|
|
113
|
+
const toRealPath = (file) => {
|
|
114
|
+
if (fileSystem.exists(file))
|
|
115
|
+
return fileSystem.realpath(file);
|
|
116
|
+
const dir = path.dirname(file);
|
|
117
|
+
return fileSystem.exists(dir) ? path.join(fileSystem.realpath(dir), path.basename(file)) : path.resolve(file);
|
|
118
|
+
};
|
|
119
|
+
const realRoot = toRealPath(projectRoot);
|
|
120
|
+
return (file) => toRootRelativePath(realRoot, toRealPath(file));
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* @remarks
|
|
124
|
+
* `file` is the root-relative source key and `id` hashes it, so an emitted module names its source the same
|
|
125
|
+
* wherever the app was built and keeps working after the app folder moves.
|
|
126
|
+
*/
|
|
127
|
+
function createIdentityLiteral(identitySource, sourceKey, integration) {
|
|
104
128
|
const id = BigInt(`0x${contentHash(identitySource, 16)}`).toString(36);
|
|
105
|
-
return `{ id: ${JSON.stringify(id)}, file: ${JSON.stringify(
|
|
129
|
+
return `{ id: ${JSON.stringify(id)}, file: ${JSON.stringify(sourceKey)}, integration: ${JSON.stringify(integration)} }`;
|
|
106
130
|
}
|
|
107
131
|
function createNamedImportEdit(program, sourceModule, importedName) {
|
|
108
132
|
const importedNames = typeof importedName === 'string' ? [importedName] : [...importedName];
|
|
@@ -148,24 +172,77 @@ function createNamedImportEdit(program, sourceModule, importedName) {
|
|
|
148
172
|
}
|
|
149
173
|
return { start: 0, end: 0, replacement: `import { ${missing.join(', ')} } from '${sourceModule}';\n` };
|
|
150
174
|
}
|
|
151
|
-
|
|
152
|
-
|
|
175
|
+
/**
|
|
176
|
+
* Imports the Eco Components plain modules import, so the declaration's component getter can name them.
|
|
177
|
+
*
|
|
178
|
+
* @remarks
|
|
179
|
+
* The imports go at the end of the module: the plain module that imports each Component already evaluates
|
|
180
|
+
* it, so the extra import does not change evaluation order. Specifiers are resolved absolute paths, so they
|
|
181
|
+
* do not depend on how the bundler names the importer.
|
|
182
|
+
*/
|
|
183
|
+
function createPlainModuleComponentImports(discovered) {
|
|
184
|
+
const locals = [];
|
|
185
|
+
let code = '';
|
|
186
|
+
if (discovered.plainModuleComponents.length === 0)
|
|
187
|
+
return { locals, code };
|
|
188
|
+
discovered.plainModuleComponents.forEach(({ file, imported }, index) => {
|
|
189
|
+
const local = `__ecoPlainModuleComponent${index}`;
|
|
190
|
+
const specifier = JSON.stringify(file);
|
|
191
|
+
const name = /^[A-Za-z_$][\w$]*$/.test(imported) ? imported : JSON.stringify(imported);
|
|
192
|
+
code +=
|
|
193
|
+
imported === 'default'
|
|
194
|
+
? `\nimport ${local} from ${specifier};`
|
|
195
|
+
: `\nimport { ${name} as ${local} } from ${specifier};`;
|
|
196
|
+
locals.push(local);
|
|
197
|
+
});
|
|
198
|
+
return { locals, code: code ? `${code}\n` : '' };
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Serializes discovery as the third argument of `bindComponentIdentity`.
|
|
202
|
+
*
|
|
203
|
+
* @remarks
|
|
204
|
+
* Local stylesheets and watch files are written relative to the app root, and a package stylesheet as the folder of
|
|
205
|
+
* the module that imported it and its package path (`src/components|some-lib@1.2.0/css/style.css`, see
|
|
206
|
+
* {@link formatPackageStylesheetEntry}), which `packageStylesheets` lists. Core
|
|
207
|
+
* resolves both at load, so no emitted module holds a path of the machine that built it. A package stylesheet
|
|
208
|
+
* outside any named package is written as a local one.
|
|
209
|
+
*/
|
|
210
|
+
function serializeDiscoveryArgument(discovered, toSourceKey, plainModuleComponents = []) {
|
|
211
|
+
if (!discovered ||
|
|
212
|
+
(discovered.components.length === 0 &&
|
|
213
|
+
discovered.stylesheets.length === 0 &&
|
|
214
|
+
discovered.plainModuleStylesheets.length === 0 &&
|
|
215
|
+
discovered.plainModuleComponents.length === 0 &&
|
|
216
|
+
discovered.watchFiles.length === 0)) {
|
|
153
217
|
return '';
|
|
154
218
|
}
|
|
155
|
-
const
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
219
|
+
const packagePaths = new Map();
|
|
220
|
+
for (const { file, importer } of discovered.packageStylesheets) {
|
|
221
|
+
const packagePath = toPackagePath(file);
|
|
222
|
+
if (packagePath) {
|
|
223
|
+
packagePaths.set(file, formatPackageStylesheetEntry(toSourceKey(path.dirname(importer)), packagePath));
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
const toStylesheetKey = (file) => packagePaths.get(file) ?? toSourceKey(file);
|
|
227
|
+
const components = [...discovered.components, ...plainModuleComponents].join(', ');
|
|
228
|
+
const stylesheets = discovered.stylesheets.map(toStylesheetKey);
|
|
229
|
+
const plain = discovered.plainModuleStylesheets.length > 0
|
|
230
|
+
? `, plainModuleStylesheets: ${JSON.stringify(discovered.plainModuleStylesheets.map(toStylesheetKey))}`
|
|
231
|
+
: '';
|
|
232
|
+
const packages = packagePaths.size > 0 ? `, packageStylesheets: ${JSON.stringify([...packagePaths.values()])}` : '';
|
|
233
|
+
const watchFiles = discovered.watchFiles.length > 0
|
|
234
|
+
? `, watchFiles: ${JSON.stringify(discovered.watchFiles.map(toSourceKey))}`
|
|
235
|
+
: '';
|
|
236
|
+
return `, { components: () => [${components}], stylesheets: ${JSON.stringify(stylesheets)}${plain}${packages}${watchFiles} }`;
|
|
165
237
|
}
|
|
166
238
|
/**
|
|
167
239
|
* Whether the component meta transform moves the side-effect stylesheet imports of `filePath`
|
|
168
|
-
* into its Component Dependencies, removing them from the module.
|
|
240
|
+
* into its own Component Dependencies, removing them from the module.
|
|
241
|
+
*
|
|
242
|
+
* @remarks
|
|
243
|
+
* Only a module with an `eco.*()` call delivers its own imports. A plain module loses them too, but only a
|
|
244
|
+
* declaration that imports it delivers them, which an HTML Page module script is not, so the HTML Page scan
|
|
245
|
+
* still reports them.
|
|
169
246
|
*/
|
|
170
247
|
export function stripsSideEffectStylesheetImports(config, filePath, contents) {
|
|
171
248
|
if (!contents.includes('eco.') || !createComponentMetaFilter(config).test(filePath))
|
|
@@ -173,12 +250,41 @@ export function stripsSideEffectStylesheetImports(config, filePath, contents) {
|
|
|
173
250
|
if (!findIntegrationForFile(config.integrations, filePath))
|
|
174
251
|
return false;
|
|
175
252
|
try {
|
|
176
|
-
return
|
|
253
|
+
return declaresEcoFactory(parseModuleSource(filePath, contents, { sourceType: 'module' }).program);
|
|
177
254
|
}
|
|
178
255
|
catch {
|
|
179
256
|
return false;
|
|
180
257
|
}
|
|
181
258
|
}
|
|
259
|
+
/**
|
|
260
|
+
* Removes the side-effect stylesheet imports, local or from a package, of a module without `eco.*()` calls.
|
|
261
|
+
*
|
|
262
|
+
* @remarks
|
|
263
|
+
* Discovery hands those stylesheets to the nearest Eco declaration that imports the module, so no server or
|
|
264
|
+
* browser build sees the import; the build plugin fails at the end of a build for a module no declaration
|
|
265
|
+
* reached. A CSS Module import stays, since the module uses its class map. Its scoped CSS reaches the Page as a
|
|
266
|
+
* Dependency of the declaration that imports the module, or that lists the stylesheet itself, so a CSS Module that
|
|
267
|
+
* no declaration reaches is not an error: a browser script may import the class map of a stylesheet its component
|
|
268
|
+
* lists. It throws for a CSS Module no Processor scopes.
|
|
269
|
+
*/
|
|
270
|
+
function stripPlainModuleStylesheetImports(program, filePath, options) {
|
|
271
|
+
const edits = [];
|
|
272
|
+
const pathPrefixes = loadTsconfigPathPrefixes(options.projectRoot);
|
|
273
|
+
const kinds = options.stylesheets ?? PLAIN_CSS_KINDS;
|
|
274
|
+
for (const entry of collectStaticImports(program)) {
|
|
275
|
+
if (!isDeliveredStylesheetImport(entry, filePath, options.projectRoot, pathPrefixes, kinds))
|
|
276
|
+
continue;
|
|
277
|
+
if (!entry.sideEffectOnly)
|
|
278
|
+
continue;
|
|
279
|
+
edits.push({ start: entry.start, end: entry.end, replacement: '' });
|
|
280
|
+
options.onStrippedStylesheet?.(entry.source);
|
|
281
|
+
}
|
|
282
|
+
return edits;
|
|
283
|
+
}
|
|
284
|
+
/** A cheap pre-parse check: whether `contents` names a stylesheet extension or has a side-effect import. */
|
|
285
|
+
function mayImportStylesheet(contents, stylesheets) {
|
|
286
|
+
return (stylesheets.extensions.some((extension) => contents.includes(extension)) || SIDE_EFFECT_IMPORT.test(contents));
|
|
287
|
+
}
|
|
182
288
|
/**
|
|
183
289
|
* Attributes real `eco.*()` factory calls with canonical component identity.
|
|
184
290
|
*
|
|
@@ -187,13 +293,16 @@ export function stripsSideEffectStylesheetImports(config, filePath, contents) {
|
|
|
187
293
|
* file share that name. Server and browser builds of one source derive the same id, and a named declaration
|
|
188
294
|
* keeps it while other code in the file changes. Calls bound to no name (an inline argument, a call inside an
|
|
189
295
|
* anonymous function) are numbered in source order, so adding or removing another unnamed call before them
|
|
190
|
-
* changes their id. `file` stays the module
|
|
296
|
+
* changes their id. `file` stays the module's root-relative source key for every call in the file. A module without calls only
|
|
297
|
+
* loses its side-effect stylesheet imports (see {@link stripPlainModuleStylesheetImports}).
|
|
191
298
|
*/
|
|
192
|
-
export function attributeComponentIdentity(contents, filePath,
|
|
193
|
-
const
|
|
299
|
+
export function attributeComponentIdentity(contents, filePath, options) {
|
|
300
|
+
const { integration, projectRoot, jsxImportSource } = options;
|
|
301
|
+
const pragma = integration && jsxImportSource && !contents.includes('@jsxImportSource')
|
|
194
302
|
? createJsxImportSourcePragma(jsxImportSource)
|
|
195
303
|
: undefined;
|
|
196
|
-
|
|
304
|
+
const mayDeclare = integration !== undefined && contents.includes('eco.');
|
|
305
|
+
if (!mayDeclare && !mayImportStylesheet(contents, options.stylesheets ?? PLAIN_CSS_KINDS)) {
|
|
197
306
|
return applySourceEdits(contents, [], filePath, { prepend: pragma });
|
|
198
307
|
}
|
|
199
308
|
let program;
|
|
@@ -203,9 +312,17 @@ export function attributeComponentIdentity(contents, filePath, integration, proj
|
|
|
203
312
|
catch {
|
|
204
313
|
return applySourceEdits(contents, [], filePath, { prepend: pragma });
|
|
205
314
|
}
|
|
206
|
-
if (!
|
|
207
|
-
|
|
315
|
+
if (!mayDeclare || !declaresEcoFactory(program)) {
|
|
316
|
+
forgetDiscoveryOwner(projectRoot, filePath);
|
|
317
|
+
const edits = options.stripPlainModuleStylesheets === false
|
|
318
|
+
? []
|
|
319
|
+
: stripPlainModuleStylesheetImports(program, filePath, options);
|
|
320
|
+
return applySourceEdits(contents, edits, filePath, {
|
|
321
|
+
prepend: pragma,
|
|
322
|
+
});
|
|
208
323
|
}
|
|
324
|
+
const toSourceKey = createSourceKeyResolver(projectRoot);
|
|
325
|
+
const sourceKey = toSourceKey(filePath);
|
|
209
326
|
const factoryArguments = [];
|
|
210
327
|
const bindingOccurrences = new Map();
|
|
211
328
|
walkEcoFactoryCalls(program, '', (node, binding) => {
|
|
@@ -221,25 +338,34 @@ export function attributeComponentIdentity(contents, filePath, integration, proj
|
|
|
221
338
|
factoryArguments.push({
|
|
222
339
|
start: firstArgument.start,
|
|
223
340
|
end: firstArgument.end,
|
|
224
|
-
identityLiteral: createIdentityLiteral(`${
|
|
341
|
+
identityLiteral: createIdentityLiteral(`${sourceKey}:${binding}:${occurrence}`, sourceKey, integration),
|
|
225
342
|
});
|
|
226
343
|
});
|
|
227
344
|
if (factoryArguments.length === 0) {
|
|
228
345
|
return applySourceEdits(contents, [], filePath, { prepend: pragma });
|
|
229
346
|
}
|
|
230
|
-
const discovered =
|
|
231
|
-
|
|
347
|
+
const discovered = discoverComponentImports(program, filePath, projectRoot, {
|
|
348
|
+
integrationOf: options.integrationOf,
|
|
349
|
+
ownerSource: contents,
|
|
350
|
+
cache: options.discoveryCache,
|
|
351
|
+
stylesheets: options.stylesheets,
|
|
352
|
+
});
|
|
353
|
+
const plainModuleImports = createPlainModuleComponentImports(discovered);
|
|
354
|
+
const discoveryArgument = serializeDiscoveryArgument(discovered, toSourceKey, plainModuleImports.locals);
|
|
232
355
|
const edits = factoryArguments.map((firstArgument) => ({
|
|
233
356
|
start: firstArgument.start,
|
|
234
357
|
end: firstArgument.end,
|
|
235
358
|
prefix: `bindComponentIdentity(${firstArgument.identityLiteral}, `,
|
|
236
359
|
suffix: `${discoveryArgument})`,
|
|
237
360
|
}));
|
|
238
|
-
edits.push(...
|
|
361
|
+
edits.push(...discovered.removals);
|
|
239
362
|
const importEdit = createNamedImportEdit(program, '@ecopages/core', 'bindComponentIdentity');
|
|
240
363
|
if (importEdit)
|
|
241
364
|
edits.push(importEdit);
|
|
242
|
-
return applySourceEdits(contents, edits, filePath, {
|
|
365
|
+
return applySourceEdits(contents, edits, filePath, {
|
|
366
|
+
prepend: pragma,
|
|
367
|
+
append: plainModuleImports.code || undefined,
|
|
368
|
+
});
|
|
243
369
|
}
|
|
244
370
|
function findMdxConfigDeclarator(program) {
|
|
245
371
|
for (const statement of nodes(program?.body)) {
|
|
@@ -286,8 +412,11 @@ function buildMdxIdentityAppend(options) {
|
|
|
286
412
|
* @remarks
|
|
287
413
|
* Pass the MDX compiler's map as `previousMap` so the returned map traces back to the `.mdx` file; without
|
|
288
414
|
* it the map is relative to the compiled module.
|
|
415
|
+
*
|
|
416
|
+
* `stylesheets` are the kinds of the app's stylesheet Processor, passed by the Integration that creates the MDX
|
|
417
|
+
* loader; without them only `.css` imports are discovered.
|
|
289
418
|
*/
|
|
290
|
-
export function attributeMdxComponentIdentity(contents, filePath, integration, projectRoot, previousMap) {
|
|
419
|
+
export function attributeMdxComponentIdentity(contents, filePath, integration, projectRoot, previousMap, stylesheets) {
|
|
291
420
|
if (!projectRoot) {
|
|
292
421
|
throw new Error(`[ecopages] Cannot process MDX dependencies for "${filePath}": projectRoot is required.`);
|
|
293
422
|
}
|
|
@@ -303,9 +432,12 @@ export function attributeMdxComponentIdentity(contents, filePath, integration, p
|
|
|
303
432
|
if (configDeclarator && isIdentityBinding(configDeclarator.init)) {
|
|
304
433
|
return { code: contents, map: previousMap };
|
|
305
434
|
}
|
|
306
|
-
const discovered = discoverComponentImports(program, filePath, projectRoot);
|
|
307
|
-
const
|
|
308
|
-
const
|
|
435
|
+
const discovered = discoverComponentImports(program, filePath, projectRoot, { stylesheets });
|
|
436
|
+
const toSourceKey = createSourceKeyResolver(projectRoot);
|
|
437
|
+
const sourceKey = toSourceKey(filePath);
|
|
438
|
+
const identityLiteral = createIdentityLiteral(sourceKey, sourceKey, integration);
|
|
439
|
+
const plainModuleImports = createPlainModuleComponentImports(discovered);
|
|
440
|
+
const discoveryArgument = serializeDiscoveryArgument(discovered, toSourceKey, plainModuleImports.locals);
|
|
309
441
|
const edits = buildMdxConfigIdentityEdits({
|
|
310
442
|
contents,
|
|
311
443
|
configDeclarator,
|
|
@@ -321,7 +453,7 @@ export function attributeMdxComponentIdentity(contents, filePath, integration, p
|
|
|
321
453
|
if (importEdit)
|
|
322
454
|
edits.push(importEdit);
|
|
323
455
|
const transformed = applySourceEdits(contents, edits, filePath, {
|
|
324
|
-
append: `\n${appended}`,
|
|
456
|
+
append: `\n${appended}${plainModuleImports.code}`,
|
|
325
457
|
});
|
|
326
458
|
return {
|
|
327
459
|
...transformed,
|
|
@@ -334,8 +466,7 @@ export function attributeMdxComponentIdentity(contents, filePath, integration, p
|
|
|
334
466
|
* Matches the ids of modules with a script extension that an Integration owns, before an optional query.
|
|
335
467
|
*
|
|
336
468
|
* @remarks
|
|
337
|
-
* With no such extension it matches no id,
|
|
338
|
-
* alternation matching all of them, `node_modules` included.
|
|
469
|
+
* With no such extension it matches no id, rather than an empty alternation matching all of them.
|
|
339
470
|
*/
|
|
340
471
|
function createComponentMetaFilter(config) {
|
|
341
472
|
const extensions = config.integrations
|
|
@@ -347,23 +478,60 @@ function createComponentMetaFilter(config) {
|
|
|
347
478
|
return new RegExp(`(${extensions.map(escapeRegExp).join('|')})(\\?.*)?$`);
|
|
348
479
|
}
|
|
349
480
|
/**
|
|
350
|
-
* Creates the build plugin that attributes component identity in every Integration's script files
|
|
481
|
+
* Creates the build plugin that attributes component identity in every Integration's script files and
|
|
482
|
+
* removes the stylesheet imports discovery delivers from every local script module.
|
|
351
483
|
*
|
|
352
484
|
* @remarks
|
|
353
485
|
* Core adds it to every build request after the app's plugins and before its `import.meta` transform, so no
|
|
354
|
-
* contributed plugin sees the attribution of another.
|
|
486
|
+
* contributed plugin sees the attribution of another. A module no Integration owns can still be a plain
|
|
487
|
+
* module discovery walks, so the filter takes every script outside `node_modules`. A module outside the app
|
|
488
|
+
* root, such as a linked workspace package, is a package: its stylesheet imports are only removed once
|
|
489
|
+
* discovery has reached it, and it never fails the reach check. A build can transform a
|
|
490
|
+
* plain module before the declaration that imports it, so the check that a declaration reached each
|
|
491
|
+
* module that lost a stylesheet import runs once the whole build is transformed.
|
|
355
492
|
*/
|
|
356
493
|
export function createEcoComponentMetaPlugin(options) {
|
|
357
|
-
|
|
494
|
+
const { integrations, rootDir } = options.config;
|
|
495
|
+
const integrationOf = (file) => findIntegrationForFile(integrations, file);
|
|
496
|
+
const stylesheets = getStylesheetKinds(options.config);
|
|
497
|
+
return {
|
|
358
498
|
name: 'eco-component-identity-attribution',
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
const
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
499
|
+
setup(build) {
|
|
500
|
+
const strippedStylesheets = new Map();
|
|
501
|
+
const discoveryCache = createDiscoveryCache();
|
|
502
|
+
const appRoot = `${fileSystem.exists(rootDir) ? fileSystem.realpath(rootDir) : path.resolve(rootDir)}/`;
|
|
503
|
+
build.transform({ filter: /\.[cm]?[jt]sx?(\?.*)?$/ }, (code, rawId) => {
|
|
504
|
+
const id = rawId.replace(/[?#].*$/, '');
|
|
505
|
+
if (id.includes('/node_modules/')) {
|
|
506
|
+
return { code };
|
|
507
|
+
}
|
|
508
|
+
const integration = findIntegrationForFile(integrations, id);
|
|
509
|
+
const insideApp = (fileSystem.exists(id) ? fileSystem.realpath(id) : id).startsWith(appRoot);
|
|
510
|
+
const stripPlainModuleStylesheets = insideApp || isReachedByDiscovery(rootDir, id);
|
|
511
|
+
if (!integration && !stripPlainModuleStylesheets) {
|
|
512
|
+
return { code };
|
|
513
|
+
}
|
|
514
|
+
return attributeComponentIdentity(code, id, {
|
|
515
|
+
integration: integration?.name,
|
|
516
|
+
projectRoot: rootDir,
|
|
517
|
+
jsxImportSource: integration?.jsxImportSource,
|
|
518
|
+
integrationOf,
|
|
519
|
+
stripPlainModuleStylesheets,
|
|
520
|
+
discoveryCache,
|
|
521
|
+
stylesheets,
|
|
522
|
+
onStrippedStylesheet: (source) => {
|
|
523
|
+
if (insideApp && !strippedStylesheets.has(id))
|
|
524
|
+
strippedStylesheets.set(id, source);
|
|
525
|
+
},
|
|
526
|
+
});
|
|
527
|
+
});
|
|
528
|
+
build.onEnd(() => {
|
|
529
|
+
for (const [file, source] of strippedStylesheets) {
|
|
530
|
+
if (!isReachedByDiscovery(rootDir, file))
|
|
531
|
+
throw createUndeliverableStylesheetError(rootDir, file, source);
|
|
532
|
+
}
|
|
533
|
+
});
|
|
366
534
|
},
|
|
367
|
-
}
|
|
535
|
+
};
|
|
368
536
|
}
|
|
369
537
|
export default createEcoComponentMetaPlugin;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { EcoBuildPlugin } from '../build/contracts/build-types.js';
|
|
1
|
+
import type { EcoBuildPlugin, EcoBuildPluginBuilder } from '../build/contracts/build-types.js';
|
|
2
2
|
/**
|
|
3
3
|
* Options for the shared foreign-JSX override build plugin.
|
|
4
4
|
*/
|
|
@@ -11,6 +11,14 @@ export interface ForeignJsxOverrideOptions {
|
|
|
11
11
|
excludeExtensions?: string[];
|
|
12
12
|
/** Optional plugin name override for debug output. */
|
|
13
13
|
name?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Returns, for one build, whether the override claims a foreign file; omitted, it claims every one.
|
|
16
|
+
*
|
|
17
|
+
* @remarks
|
|
18
|
+
* It runs in `setup`, and the check it returns runs for each matching file before any rewrite. A file the
|
|
19
|
+
* check rejects keeps its owner's JSX runtime; a check that throws fails the build.
|
|
20
|
+
*/
|
|
21
|
+
scope?: (build: EcoBuildPluginBuilder) => (sourcePath: string) => boolean;
|
|
14
22
|
}
|
|
15
23
|
/**
|
|
16
24
|
* Build plugin that prepends a `@jsxImportSource` pragma to foreign integration
|
|
@@ -27,6 +35,11 @@ export interface ForeignJsxOverrideOptions {
|
|
|
27
35
|
* client-side bundling can use it by passing its own `jsxImportSource` and the
|
|
28
36
|
* set of foreign extensions collected from the app config.
|
|
29
37
|
*
|
|
38
|
+
* @remarks
|
|
39
|
+
* The override is a `transform`, so it runs on whatever an earlier `onLoad`
|
|
40
|
+
* produced and composes with loaders such as the React client-graph boundary
|
|
41
|
+
* instead of replacing their output.
|
|
42
|
+
*
|
|
30
43
|
* When no JSX-bearing foreign extensions are present, the returned plugin is a
|
|
31
44
|
* no-op so integrations can register it unconditionally.
|
|
32
45
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import MagicString from 'magic-string';
|
|
2
2
|
import { escapeRegExp } from '../utils/regex-escaping.js';
|
|
3
3
|
import { createJsxImportSourcePragma, filterJsxSourceExtensions } from './jsx-import-source.utils.js';
|
|
4
4
|
/**
|
|
@@ -16,6 +16,11 @@ import { createJsxImportSourcePragma, filterJsxSourceExtensions } from './jsx-im
|
|
|
16
16
|
* client-side bundling can use it by passing its own `jsxImportSource` and the
|
|
17
17
|
* set of foreign extensions collected from the app config.
|
|
18
18
|
*
|
|
19
|
+
* @remarks
|
|
20
|
+
* The override is a `transform`, so it runs on whatever an earlier `onLoad`
|
|
21
|
+
* produced and composes with loaders such as the React client-graph boundary
|
|
22
|
+
* instead of replacing their output.
|
|
23
|
+
*
|
|
19
24
|
* When no JSX-bearing foreign extensions are present, the returned plugin is a
|
|
20
25
|
* no-op so integrations can register it unconditionally.
|
|
21
26
|
*/
|
|
@@ -34,18 +39,23 @@ export function createForeignJsxOverridePlugin(options) {
|
|
|
34
39
|
name: options.name ?? 'foreign-jsx-override',
|
|
35
40
|
cacheKey: JSON.stringify([options.hostJsxImportSource, extensions, excludedExtensions]),
|
|
36
41
|
setup(build) {
|
|
37
|
-
|
|
38
|
-
|
|
42
|
+
const claims = options.scope?.(build);
|
|
43
|
+
build.transform({ filter }, (code, id) => {
|
|
44
|
+
const sourcePath = id.replace(/[?#].*$/, '');
|
|
45
|
+
if (excludedExtensions.some((extension) => sourcePath.endsWith(extension))) {
|
|
46
|
+
return undefined;
|
|
47
|
+
}
|
|
48
|
+
if (claims && !claims(sourcePath)) {
|
|
39
49
|
return undefined;
|
|
40
50
|
}
|
|
41
|
-
|
|
42
|
-
const loader = args.path.endsWith('.jsx') ? 'jsx' : 'tsx';
|
|
43
|
-
if (source.includes('@jsxImportSource')) {
|
|
51
|
+
if (code.includes('@jsxImportSource')) {
|
|
44
52
|
return undefined;
|
|
45
53
|
}
|
|
54
|
+
const source = new MagicString(code, { filename: sourcePath });
|
|
55
|
+
source.prepend(pragma);
|
|
46
56
|
return {
|
|
47
|
-
|
|
48
|
-
|
|
57
|
+
code: source.toString(),
|
|
58
|
+
map: source.generateMap({ source: sourcePath, includeContent: true, hires: 'boundary' }),
|
|
49
59
|
};
|
|
50
60
|
});
|
|
51
61
|
},
|