@servicetitan/startup 36.4.0 → 37.0.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/bin/analyze.js +3 -0
- package/dist/cli/commands/build.d.ts.map +1 -1
- package/dist/cli/commands/build.js +4 -5
- package/dist/cli/commands/build.js.map +1 -1
- package/dist/cli/commands/bundle-vite.d.ts.map +1 -1
- package/dist/cli/commands/bundle-vite.js +18 -1
- package/dist/cli/commands/bundle-vite.js.map +1 -1
- package/dist/cli/commands/registry/build.d.ts +6 -0
- package/dist/cli/commands/registry/build.d.ts.map +1 -1
- package/dist/cli/commands/registry/build.js +10 -1
- package/dist/cli/commands/registry/build.js.map +1 -1
- package/dist/cli/commands/registry/command-registry.d.ts +12 -28
- package/dist/cli/commands/registry/command-registry.d.ts.map +1 -1
- package/dist/cli/commands/registry/command-registry.js +0 -3
- package/dist/cli/commands/registry/command-registry.js.map +1 -1
- package/dist/cli/commands/registry/start.d.ts +6 -0
- package/dist/cli/commands/registry/start.d.ts.map +1 -1
- package/dist/cli/commands/registry/start.js +10 -1
- package/dist/cli/commands/registry/start.js.map +1 -1
- package/dist/cli/commands/review/rules/index.d.ts.map +1 -1
- package/dist/cli/commands/review/rules/index.js +2 -0
- package/dist/cli/commands/review/rules/index.js.map +1 -1
- package/dist/cli/commands/review/rules/require-compatible-typescript.d.ts +13 -0
- package/dist/cli/commands/review/rules/require-compatible-typescript.d.ts.map +1 -0
- package/dist/cli/commands/review/rules/require-compatible-typescript.js +72 -0
- package/dist/cli/commands/review/rules/require-compatible-typescript.js.map +1 -0
- package/dist/cli/commands/start.d.ts.map +1 -1
- package/dist/cli/commands/start.js +3 -4
- package/dist/cli/commands/start.js.map +1 -1
- package/dist/cli/index.js +1 -1
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/utils/get-bundle-command.d.ts +3 -0
- package/dist/cli/utils/get-bundle-command.d.ts.map +1 -0
- package/dist/cli/utils/get-bundle-command.js +16 -0
- package/dist/cli/utils/get-bundle-command.js.map +1 -0
- package/dist/cli/utils/get-exit-code.d.ts +12 -0
- package/dist/cli/utils/get-exit-code.d.ts.map +1 -0
- package/dist/cli/utils/get-exit-code.js +26 -0
- package/dist/cli/utils/get-exit-code.js.map +1 -0
- package/dist/cli/utils/index.d.ts +3 -0
- package/dist/cli/utils/index.d.ts.map +1 -1
- package/dist/cli/utils/index.js +3 -0
- package/dist/cli/utils/index.js.map +1 -1
- package/dist/cli/utils/resolve-bundler.d.ts +8 -0
- package/dist/cli/utils/resolve-bundler.d.ts.map +1 -0
- package/dist/cli/utils/resolve-bundler.js +24 -0
- package/dist/cli/utils/resolve-bundler.js.map +1 -0
- package/dist/core/bundle-report.d.ts +4 -0
- package/dist/core/bundle-report.d.ts.map +1 -0
- package/dist/core/bundle-report.js +43 -0
- package/dist/core/bundle-report.js.map +1 -0
- package/dist/core/check-resource/check-resource.d.ts +2 -2
- package/dist/core/check-resource/check-resource.d.ts.map +1 -1
- package/dist/core/check-resource/check-resource.js +20 -13
- package/dist/core/check-resource/check-resource.js.map +1 -1
- package/dist/core/check-resource/get-peer-dependency-meta.d.ts +11 -1
- package/dist/core/check-resource/get-peer-dependency-meta.d.ts.map +1 -1
- package/dist/core/check-resource/get-peer-dependency-meta.js +58 -2
- package/dist/core/check-resource/get-peer-dependency-meta.js.map +1 -1
- package/dist/core/check-resource/index.d.ts +1 -1
- package/dist/core/check-resource/index.d.ts.map +1 -1
- package/dist/core/check-resource/index.js.map +1 -1
- package/dist/core/check-resource/is-resolvable.d.ts +7 -0
- package/dist/core/check-resource/is-resolvable.d.ts.map +1 -0
- package/dist/core/check-resource/is-resolvable.js +31 -0
- package/dist/core/check-resource/is-resolvable.js.map +1 -0
- package/dist/core/check-resource/types.d.ts +1 -0
- package/dist/core/check-resource/types.d.ts.map +1 -1
- package/dist/core/chunk-patterns.d.ts +7 -0
- package/dist/core/chunk-patterns.d.ts.map +1 -0
- package/dist/core/chunk-patterns.js +37 -0
- package/dist/core/chunk-patterns.js.map +1 -0
- package/dist/core/create-build-context.d.ts +0 -1
- package/dist/core/create-build-context.d.ts.map +1 -1
- package/dist/core/create-build-context.js +2 -2
- package/dist/core/create-build-context.js.map +1 -1
- package/dist/core/create-extension-regexp.d.ts +5 -0
- package/dist/core/create-extension-regexp.d.ts.map +1 -0
- package/dist/core/create-extension-regexp.js +45 -0
- package/dist/core/create-extension-regexp.js.map +1 -0
- package/dist/core/get-process-env.d.ts +3 -0
- package/dist/core/get-process-env.d.ts.map +1 -0
- package/dist/core/get-process-env.js +25 -0
- package/dist/core/get-process-env.js.map +1 -0
- package/dist/core/index.d.ts +8 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +8 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/moment-locales.d.ts +2 -0
- package/dist/core/moment-locales.d.ts.map +1 -0
- package/dist/core/moment-locales.js +21 -0
- package/dist/core/moment-locales.js.map +1 -0
- package/dist/core/resolve-output-path.d.ts +3 -0
- package/dist/core/resolve-output-path.d.ts.map +1 -0
- package/dist/core/resolve-output-path.js +25 -0
- package/dist/core/resolve-output-path.js.map +1 -0
- package/dist/core/resolve-output-root.d.ts +3 -0
- package/dist/core/resolve-output-root.d.ts.map +1 -0
- package/dist/core/resolve-output-root.js +23 -0
- package/dist/core/resolve-output-root.js.map +1 -0
- package/dist/core/sort-shared-css.d.ts +2 -0
- package/dist/core/sort-shared-css.d.ts.map +1 -0
- package/dist/core/sort-shared-css.js +20 -0
- package/dist/core/sort-shared-css.js.map +1 -0
- package/dist/core/types.d.ts +1 -1
- package/dist/core/types.d.ts.map +1 -1
- package/dist/cypress/config/index.d.ts +1 -0
- package/dist/cypress/config/index.d.ts.map +1 -1
- package/dist/cypress/config/index.js +1 -0
- package/dist/cypress/config/index.js.map +1 -1
- package/dist/cypress/config/vite-config.d.ts +3 -0
- package/dist/cypress/config/vite-config.d.ts.map +1 -0
- package/dist/cypress/config/vite-config.js +58 -0
- package/dist/cypress/config/vite-config.js.map +1 -0
- package/dist/storybook-config/index.d.ts +1 -0
- package/dist/storybook-config/index.d.ts.map +1 -1
- package/dist/storybook-config/index.js +1 -0
- package/dist/storybook-config/index.js.map +1 -1
- package/dist/storybook-config/vite-final.d.ts +7 -0
- package/dist/storybook-config/vite-final.d.ts.map +1 -0
- package/dist/storybook-config/vite-final.js +86 -0
- package/dist/storybook-config/vite-final.js.map +1 -0
- package/dist/utils/get-configuration.d.ts +15 -10
- package/dist/utils/get-configuration.d.ts.map +1 -1
- package/dist/utils/get-configuration.js +32 -2
- package/dist/utils/get-configuration.js.map +1 -1
- package/dist/utils/get-package-name.d.ts +2 -1
- package/dist/utils/get-package-name.d.ts.map +1 -1
- package/dist/utils/get-package-name.js +4 -2
- package/dist/utils/get-package-name.js.map +1 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/types.d.ts +2 -0
- package/dist/utils/types.d.ts.map +1 -0
- package/dist/utils/types.js +6 -0
- package/dist/utils/types.js.map +1 -0
- package/dist/utils/validate-shared-dependencies.d.ts.map +1 -1
- package/dist/utils/validate-shared-dependencies.js +4 -0
- package/dist/utils/validate-shared-dependencies.js.map +1 -1
- package/dist/vite/build-shared-dependencies.d.ts.map +1 -1
- package/dist/vite/build-shared-dependencies.js +1 -2
- package/dist/vite/build-shared-dependencies.js.map +1 -1
- package/dist/vite/config/asset-file-names.d.ts +4 -0
- package/dist/vite/config/asset-file-names.d.ts.map +1 -0
- package/dist/vite/config/asset-file-names.js +29 -0
- package/dist/vite/config/asset-file-names.js.map +1 -0
- package/dist/vite/config/base-config.d.ts.map +1 -1
- package/dist/vite/config/base-config.js +67 -40
- package/dist/vite/config/base-config.js.map +1 -1
- package/dist/vite/config/code-splitting.d.ts +4 -0
- package/dist/vite/config/code-splitting.d.ts.map +1 -0
- package/dist/vite/config/code-splitting.js +48 -0
- package/dist/vite/config/code-splitting.js.map +1 -0
- package/dist/vite/config/create-css-config.d.ts +3 -0
- package/dist/vite/config/create-css-config.d.ts.map +1 -0
- package/dist/vite/config/create-css-config.js +26 -0
- package/dist/vite/config/create-css-config.js.map +1 -0
- package/dist/vite/config/create-filtering-logger.d.ts +3 -0
- package/dist/vite/config/create-filtering-logger.d.ts.map +1 -0
- package/dist/vite/config/create-filtering-logger.js +37 -0
- package/dist/vite/config/create-filtering-logger.js.map +1 -0
- package/dist/vite/config/create-vite-build-context.d.ts +2 -1
- package/dist/vite/config/create-vite-build-context.d.ts.map +1 -1
- package/dist/vite/config/create-vite-build-context.js.map +1 -1
- package/dist/vite/config/create-vite-config.d.ts.map +1 -1
- package/dist/vite/config/create-vite-config.js +30 -13
- package/dist/vite/config/create-vite-config.js.map +1 -1
- package/dist/vite/config/get-warmup-client-files.d.ts +3 -0
- package/dist/vite/config/get-warmup-client-files.d.ts.map +1 -0
- package/dist/vite/config/get-warmup-client-files.js +26 -0
- package/dist/vite/config/get-warmup-client-files.js.map +1 -0
- package/dist/vite/index.html +1 -0
- package/dist/vite/plugins/bundle-stat-plugin.d.ts +4 -0
- package/dist/vite/plugins/bundle-stat-plugin.d.ts.map +1 -0
- package/dist/vite/plugins/bundle-stat-plugin.js +32 -0
- package/dist/vite/plugins/bundle-stat-plugin.js.map +1 -0
- package/dist/vite/plugins/chain-source-maps-plugin.d.ts +3 -0
- package/dist/vite/plugins/chain-source-maps-plugin.d.ts.map +1 -0
- package/dist/vite/plugins/chain-source-maps-plugin.js +37 -0
- package/dist/vite/plugins/chain-source-maps-plugin.js.map +1 -0
- package/dist/vite/plugins/clean-plugin.d.ts +4 -0
- package/dist/vite/plugins/clean-plugin.d.ts.map +1 -0
- package/dist/vite/plugins/clean-plugin.js +63 -0
- package/dist/vite/plugins/clean-plugin.js.map +1 -0
- package/dist/vite/plugins/design-system-guard-plugin.d.ts +4 -0
- package/dist/vite/plugins/design-system-guard-plugin.d.ts.map +1 -0
- package/dist/vite/plugins/design-system-guard-plugin.js +35 -0
- package/dist/vite/plugins/design-system-guard-plugin.js.map +1 -0
- package/dist/vite/plugins/ignore-modules-plugin.d.ts +17 -1
- package/dist/vite/plugins/ignore-modules-plugin.d.ts.map +1 -1
- package/dist/vite/plugins/ignore-modules-plugin.js +22 -8
- package/dist/vite/plugins/ignore-modules-plugin.js.map +1 -1
- package/dist/vite/plugins/index.d.ts +7 -0
- package/dist/vite/plugins/index.d.ts.map +1 -1
- package/dist/vite/plugins/index.js +7 -0
- package/dist/vite/plugins/index.js.map +1 -1
- package/dist/vite/plugins/istanbul-plugin.d.ts +4 -0
- package/dist/vite/plugins/istanbul-plugin.d.ts.map +1 -0
- package/dist/vite/plugins/istanbul-plugin.js +27 -0
- package/dist/vite/plugins/istanbul-plugin.js.map +1 -0
- package/dist/vite/plugins/magic-comments-plugin/index.d.ts +2 -0
- package/dist/vite/plugins/magic-comments-plugin/index.d.ts.map +1 -0
- package/dist/vite/plugins/magic-comments-plugin/index.js +20 -0
- package/dist/vite/plugins/magic-comments-plugin/index.js.map +1 -0
- package/dist/vite/plugins/magic-comments-plugin/magic-comments-plugin.d.ts +4 -0
- package/dist/vite/plugins/magic-comments-plugin/magic-comments-plugin.d.ts.map +1 -0
- package/dist/vite/plugins/magic-comments-plugin/magic-comments-plugin.js +63 -0
- package/dist/vite/plugins/magic-comments-plugin/magic-comments-plugin.js.map +1 -0
- package/dist/vite/plugins/magic-comments-plugin/parse-magic-comments.d.ts +6 -0
- package/dist/vite/plugins/magic-comments-plugin/parse-magic-comments.d.ts.map +1 -0
- package/dist/vite/plugins/magic-comments-plugin/parse-magic-comments.js +40 -0
- package/dist/vite/plugins/magic-comments-plugin/parse-magic-comments.js.map +1 -0
- package/dist/vite/plugins/metadata-plugin.js +2 -2
- package/dist/vite/plugins/metadata-plugin.js.map +1 -1
- package/dist/vite/plugins/moment-locales-plugin.d.ts +5 -0
- package/dist/vite/plugins/moment-locales-plugin.d.ts.map +1 -0
- package/dist/vite/plugins/moment-locales-plugin.js +50 -0
- package/dist/vite/plugins/moment-locales-plugin.js.map +1 -0
- package/dist/vite/plugins/shared-dependencies-plugin/assemble-iife.d.ts +14 -0
- package/dist/vite/plugins/shared-dependencies-plugin/assemble-iife.d.ts.map +1 -0
- package/dist/vite/plugins/shared-dependencies-plugin/assemble-iife.js +100 -0
- package/dist/vite/plugins/shared-dependencies-plugin/assemble-iife.js.map +1 -0
- package/dist/vite/plugins/shared-dependencies-plugin/assert-no-dynamic-css.d.ts +3 -0
- package/dist/vite/plugins/shared-dependencies-plugin/assert-no-dynamic-css.d.ts.map +1 -0
- package/dist/vite/plugins/shared-dependencies-plugin/assert-no-dynamic-css.js +56 -0
- package/dist/vite/plugins/shared-dependencies-plugin/assert-no-dynamic-css.js.map +1 -0
- package/dist/vite/plugins/shared-dependencies-plugin/flatten.d.ts +2 -0
- package/dist/vite/plugins/shared-dependencies-plugin/flatten.d.ts.map +1 -0
- package/dist/vite/plugins/shared-dependencies-plugin/flatten.js +19 -0
- package/dist/vite/plugins/shared-dependencies-plugin/flatten.js.map +1 -0
- package/dist/vite/plugins/shared-dependencies-plugin/index.d.ts +2 -0
- package/dist/vite/plugins/shared-dependencies-plugin/index.d.ts.map +1 -0
- package/dist/vite/plugins/shared-dependencies-plugin/index.js +20 -0
- package/dist/vite/plugins/shared-dependencies-plugin/index.js.map +1 -0
- package/dist/vite/plugins/shared-dependencies-plugin/shared-dependencies-plugin.d.ts.map +1 -0
- package/dist/vite/plugins/{shared-dependencies-plugin.js → shared-dependencies-plugin/shared-dependencies-plugin.js} +29 -107
- package/dist/vite/plugins/shared-dependencies-plugin/shared-dependencies-plugin.js.map +1 -0
- package/dist/vite/plugins/utils/import-esm.d.ts +2 -0
- package/dist/vite/plugins/utils/import-esm.d.ts.map +1 -0
- package/dist/vite/plugins/utils/import-esm.js +22 -0
- package/dist/vite/plugins/utils/import-esm.js.map +1 -0
- package/dist/vite/plugins/utils/index.d.ts +3 -0
- package/dist/vite/plugins/utils/index.d.ts.map +1 -0
- package/dist/vite/plugins/utils/index.js +21 -0
- package/dist/vite/plugins/utils/index.js.map +1 -0
- package/dist/webpack/configs/optimization-config.d.ts.map +1 -1
- package/dist/webpack/configs/optimization-config.js +53 -24
- package/dist/webpack/configs/optimization-config.js.map +1 -1
- package/dist/webpack/configs/output-config.d.ts.map +1 -1
- package/dist/webpack/configs/output-config.js +0 -1
- package/dist/webpack/configs/output-config.js.map +1 -1
- package/dist/webpack/configs/plugins/assets-manifest-plugin.d.ts.map +1 -1
- package/dist/webpack/configs/plugins/assets-manifest-plugin.js +11 -3
- package/dist/webpack/configs/plugins/assets-manifest-plugin.js.map +1 -1
- package/dist/webpack/configs/plugins/bundle-analyser-plugin.d.ts.map +1 -1
- package/dist/webpack/configs/plugins/bundle-analyser-plugin.js +2 -21
- package/dist/webpack/configs/plugins/bundle-analyser-plugin.js.map +1 -1
- package/dist/webpack/configs/plugins/define-process-env-plugin.d.ts +5 -0
- package/dist/webpack/configs/plugins/define-process-env-plugin.d.ts.map +1 -0
- package/dist/webpack/configs/plugins/define-process-env-plugin.js +20 -0
- package/dist/webpack/configs/plugins/define-process-env-plugin.js.map +1 -0
- package/dist/webpack/configs/plugins/ignore-plugin/empty-module.d.ts +2 -0
- package/dist/webpack/configs/plugins/ignore-plugin/empty-module.d.ts.map +1 -0
- package/dist/webpack/configs/plugins/ignore-plugin/empty-module.js +11 -0
- package/dist/webpack/configs/plugins/ignore-plugin/empty-module.js.map +1 -0
- package/dist/webpack/configs/plugins/ignore-plugin/ignore-plugin.d.ts +26 -3
- package/dist/webpack/configs/plugins/ignore-plugin/ignore-plugin.d.ts.map +1 -1
- package/dist/webpack/configs/plugins/ignore-plugin/ignore-plugin.js +41 -10
- package/dist/webpack/configs/plugins/ignore-plugin/ignore-plugin.js.map +1 -1
- package/dist/webpack/configs/plugins/index.d.ts +1 -0
- package/dist/webpack/configs/plugins/index.d.ts.map +1 -1
- package/dist/webpack/configs/plugins/index.js +1 -0
- package/dist/webpack/configs/plugins/index.js.map +1 -1
- package/dist/webpack/configs/plugins/moment-locales-plugin.d.ts.map +1 -1
- package/dist/webpack/configs/plugins/moment-locales-plugin.js +2 -5
- package/dist/webpack/configs/plugins/moment-locales-plugin.js.map +1 -1
- package/dist/webpack/configs/plugins-config.d.ts.map +1 -1
- package/dist/webpack/configs/plugins-config.js +1 -0
- package/dist/webpack/configs/plugins-config.js.map +1 -1
- package/dist/webpack/configs/rules/font-rules.d.ts.map +1 -1
- package/dist/webpack/configs/rules/font-rules.js +2 -1
- package/dist/webpack/configs/rules/font-rules.js.map +1 -1
- package/dist/webpack/configs/rules/image-rules.d.ts.map +1 -1
- package/dist/webpack/configs/rules/image-rules.js +2 -1
- package/dist/webpack/configs/rules/image-rules.js.map +1 -1
- package/dist/webpack/create-webpack-config.d.ts.map +1 -1
- package/dist/webpack/create-webpack-config.js +8 -3
- package/dist/webpack/create-webpack-config.js.map +1 -1
- package/dist/webpack/create-webpack-configs.d.ts.map +1 -1
- package/dist/webpack/create-webpack-configs.js +4 -12
- package/dist/webpack/create-webpack-configs.js.map +1 -1
- package/dist/webpack/types.d.ts +1 -1
- package/dist/webpack/types.d.ts.map +1 -1
- package/dist/webpack/utils/create-webpack-build-context.d.ts.map +1 -1
- package/dist/webpack/utils/create-webpack-build-context.js +1 -2
- package/dist/webpack/utils/create-webpack-build-context.js.map +1 -1
- package/package.json +22 -18
- package/src/cli/commands/__tests__/build.test.ts +33 -5
- package/src/cli/commands/__tests__/bundle-vite.test.ts +50 -1
- package/src/cli/commands/__tests__/start.test.ts +17 -4
- package/src/cli/commands/build.ts +5 -6
- package/src/cli/commands/bundle-vite.ts +13 -0
- package/src/cli/commands/registry/build.ts +6 -1
- package/src/cli/commands/registry/command-registry.ts +0 -1
- package/src/cli/commands/registry/start.ts +6 -1
- package/src/cli/commands/review/rules/__tests__/require-compatible-typescript.test.ts +127 -0
- package/src/cli/commands/review/rules/index.ts +2 -0
- package/src/cli/commands/review/rules/require-compatible-typescript.ts +64 -0
- package/src/cli/commands/start.ts +4 -4
- package/src/cli/index.ts +2 -2
- package/src/cli/utils/__tests__/get-bundle-command.test.ts +23 -0
- package/src/cli/utils/__tests__/get-exit-code.test.ts +41 -0
- package/src/cli/utils/__tests__/resolve-bundler.test.ts +64 -0
- package/src/cli/utils/get-bundle-command.ts +5 -0
- package/src/cli/utils/get-exit-code.ts +17 -0
- package/src/cli/utils/index.ts +3 -0
- package/src/cli/utils/resolve-bundler.ts +23 -0
- package/src/core/__tests__/bundle-report.test.ts +60 -0
- package/src/core/__tests__/create-extension-regexp.test.ts +32 -0
- package/src/core/__tests__/resolve-output-path.test.ts +45 -0
- package/src/core/__tests__/resolve-output-root.test.ts +37 -0
- package/src/core/__tests__/sort-shared-css.test.ts +39 -0
- package/src/core/bundle-report.ts +33 -0
- package/src/core/check-resource/__tests__/check-resource.test.ts +21 -7
- package/src/core/check-resource/__tests__/get-peer-dependency-meta.test.ts +70 -13
- package/src/core/check-resource/__tests__/is-resolvable.test.ts +20 -0
- package/src/core/check-resource/check-resource.ts +15 -14
- package/src/core/check-resource/get-peer-dependency-meta.ts +67 -4
- package/src/core/check-resource/index.ts +1 -1
- package/src/core/check-resource/is-resolvable.ts +19 -0
- package/src/core/check-resource/types.ts +2 -0
- package/src/core/chunk-patterns.ts +30 -0
- package/src/core/create-build-context.ts +2 -2
- package/src/core/create-extension-regexp.ts +7 -0
- package/src/core/get-process-env.ts +17 -0
- package/src/core/index.ts +8 -1
- package/src/core/moment-locales.ts +6 -0
- package/src/core/resolve-output-path.ts +10 -0
- package/src/core/resolve-output-root.ts +8 -0
- package/src/core/sort-shared-css.ts +7 -0
- package/src/core/types.ts +1 -1
- package/src/cypress/config/__tests__/vite-config.test.ts +72 -0
- package/src/cypress/config/index.ts +1 -0
- package/src/cypress/config/vite-config.ts +37 -0
- package/src/storybook-config/__tests__/vite-final.test.ts +122 -0
- package/src/storybook-config/index.ts +1 -0
- package/src/storybook-config/vite-final.ts +65 -0
- package/src/utils/__tests__/get-configuration.test.ts +82 -5
- package/src/utils/__tests__/get-package-name.test.ts +57 -0
- package/src/utils/__tests__/validate-shared-dependencies.test.ts +50 -35
- package/src/utils/get-configuration.ts +50 -15
- package/src/utils/get-package-name.ts +8 -2
- package/src/utils/index.ts +1 -0
- package/src/utils/types.ts +1 -0
- package/src/utils/validate-shared-dependencies.ts +15 -1
- package/src/vite/__tests__/build-shared-dependencies.test.ts +13 -26
- package/src/vite/__tests__/validate-shared-dependencies.test.ts +30 -19
- package/src/vite/build-shared-dependencies.ts +3 -7
- package/src/vite/config/__tests__/asset-file-names.test.ts +40 -0
- package/src/vite/config/__tests__/base-config.test.ts +99 -31
- package/src/vite/config/__tests__/code-splitting.test.ts +34 -0
- package/src/vite/config/__tests__/create-css-config.test.ts +58 -0
- package/src/vite/config/__tests__/create-filtering-logger.test.ts +51 -0
- package/src/vite/config/__tests__/create-vite-build-context.test.ts +5 -2
- package/src/vite/config/__tests__/create-vite-config.test.ts +91 -13
- package/src/vite/config/__tests__/get-warmup-client-files.test.ts +20 -0
- package/src/vite/config/asset-file-names.ts +20 -0
- package/src/vite/config/base-config.ts +45 -37
- package/src/vite/config/code-splitting.ts +23 -0
- package/src/vite/config/create-css-config.ts +16 -0
- package/src/vite/config/create-filtering-logger.ts +34 -0
- package/src/vite/config/create-vite-build-context.ts +3 -5
- package/src/vite/config/create-vite-config.ts +45 -12
- package/src/vite/config/get-warmup-client-files.ts +13 -0
- package/src/vite/index.html +1 -0
- package/src/vite/plugins/__tests__/bundle-stat-plugin.test.ts +70 -0
- package/src/vite/plugins/__tests__/chain-source-maps-plugin.test.ts +58 -0
- package/src/vite/plugins/__tests__/clean-plugin.test.ts +121 -0
- package/src/vite/plugins/__tests__/design-system-guard-plugin.test.ts +83 -0
- package/src/vite/plugins/__tests__/html-template.test.ts +6 -0
- package/src/vite/plugins/__tests__/ignore-modules-plugin.test.ts +29 -7
- package/src/vite/plugins/__tests__/istanbul-plugin.test.ts +62 -0
- package/src/vite/plugins/__tests__/moment-locales-plugin.test.ts +104 -0
- package/src/vite/plugins/bundle-stat-plugin.ts +24 -0
- package/src/vite/plugins/chain-source-maps-plugin.ts +26 -0
- package/src/vite/plugins/clean-plugin.ts +46 -0
- package/src/vite/plugins/design-system-guard-plugin.ts +34 -0
- package/src/vite/plugins/ignore-modules-plugin.ts +31 -5
- package/src/vite/plugins/index.ts +7 -0
- package/src/vite/plugins/istanbul-plugin.ts +19 -0
- package/src/vite/plugins/magic-comments-plugin/__tests__/magic-comments-plugin.test.ts +105 -0
- package/src/vite/plugins/magic-comments-plugin/__tests__/parse-magic-comments.test.ts +40 -0
- package/src/vite/plugins/magic-comments-plugin/index.ts +1 -0
- package/src/vite/plugins/magic-comments-plugin/magic-comments-plugin.ts +63 -0
- package/src/vite/plugins/magic-comments-plugin/parse-magic-comments.ts +39 -0
- package/src/vite/plugins/metadata-plugin.ts +1 -1
- package/src/vite/plugins/moment-locales-plugin.ts +41 -0
- package/src/vite/plugins/shared-dependencies-plugin/__tests__/assemble-iife.test.ts +29 -0
- package/src/vite/plugins/shared-dependencies-plugin/__tests__/assert-no-dynamic-css.test.ts +113 -0
- package/src/vite/plugins/shared-dependencies-plugin/__tests__/flatten.test.ts +23 -0
- package/src/vite/plugins/{__tests__ → shared-dependencies-plugin/__tests__}/shared-dependencies-plugin.test.ts +38 -4
- package/src/vite/plugins/shared-dependencies-plugin/assemble-iife.ts +114 -0
- package/src/vite/plugins/shared-dependencies-plugin/assert-no-dynamic-css.ts +58 -0
- package/src/vite/plugins/shared-dependencies-plugin/flatten.ts +8 -0
- package/src/vite/plugins/shared-dependencies-plugin/index.ts +1 -0
- package/src/vite/plugins/{shared-dependencies-plugin.ts → shared-dependencies-plugin/shared-dependencies-plugin.ts} +24 -115
- package/src/vite/plugins/utils/import-esm.ts +15 -0
- package/src/vite/plugins/utils/index.ts +2 -0
- package/src/vite/rolldown-oxc.d.ts +20 -0
- package/src/webpack/__tests__/bundle-webpack.test.ts +8 -8
- package/src/webpack/__tests__/create-webpack-config-shared-dependencies.test.ts +54 -5
- package/src/webpack/__tests__/create-webpack-config-web-component.test.ts +70 -12
- package/src/webpack/__tests__/create-webpack-config.test.ts +92 -9
- package/src/webpack/configs/optimization-config.ts +47 -25
- package/src/webpack/configs/output-config.ts +1 -2
- package/src/webpack/configs/plugins/assets-manifest-plugin.ts +16 -4
- package/src/webpack/configs/plugins/bundle-analyser-plugin.ts +3 -25
- package/src/webpack/configs/plugins/define-process-env-plugin.ts +10 -0
- package/src/webpack/configs/plugins/ignore-plugin/__tests__/ignore-plugin.test.ts +76 -24
- package/src/webpack/configs/plugins/ignore-plugin/empty-module.ts +7 -0
- package/src/webpack/configs/plugins/ignore-plugin/ignore-plugin.ts +59 -9
- package/src/webpack/configs/plugins/index.ts +1 -0
- package/src/webpack/configs/plugins/moment-locales-plugin.ts +2 -2
- package/src/webpack/configs/plugins-config.ts +2 -0
- package/src/webpack/configs/rules/font-rules.ts +2 -2
- package/src/webpack/configs/rules/image-rules.ts +2 -2
- package/src/webpack/create-webpack-config.ts +11 -4
- package/src/webpack/create-webpack-configs.ts +2 -8
- package/src/webpack/types.ts +1 -4
- package/src/webpack/utils/create-webpack-build-context.ts +1 -6
- package/tsconfig/base.json +1 -1
- package/tsconfig/types.d.ts +10 -0
- package/dist/core/get-output-path.d.ts +0 -3
- package/dist/core/get-output-path.d.ts.map +0 -1
- package/dist/core/get-output-path.js +0 -29
- package/dist/core/get-output-path.js.map +0 -1
- package/dist/vite/plugins/shared-dependencies-plugin.d.ts.map +0 -1
- package/dist/vite/plugins/shared-dependencies-plugin.js.map +0 -1
- package/src/core/__tests__/get-output-path.test.ts +0 -64
- package/src/core/get-output-path.ts +0 -15
- /package/dist/vite/plugins/{shared-dependencies-plugin.d.ts → shared-dependencies-plugin/shared-dependencies-plugin.d.ts} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"moment-locales-plugin.d.ts","sourceRoot":"","sources":["../../../src/vite/plugins/moment-locales-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AACnC,OAAO,EAAE,YAAY,EAAkB,MAAM,YAAY,CAAC;AAE1D,eAAO,MAAM,cAAc,qBAAqB,CAAC;AAYjD,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,YAAY,GAAG,MAAM,CAyBlE"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
get VIRTUAL_MOMENT () {
|
|
13
|
+
return VIRTUAL_MOMENT;
|
|
14
|
+
},
|
|
15
|
+
get momentLocalesPlugin () {
|
|
16
|
+
return momentLocalesPlugin;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
const _core = require("../../core");
|
|
20
|
+
const VIRTUAL_MOMENT = '\0VIRTUAL_MOMENT';
|
|
21
|
+
const UMD_LOCALE = /^moment\/locale\/(.+)$/;
|
|
22
|
+
function momentLocalesPlugin(_context) {
|
|
23
|
+
return {
|
|
24
|
+
name: 'moment-locales',
|
|
25
|
+
enforce: 'pre',
|
|
26
|
+
resolveId (source, importer, options) {
|
|
27
|
+
var _UMD_LOCALE_exec;
|
|
28
|
+
if (source === 'moment') {
|
|
29
|
+
return VIRTUAL_MOMENT;
|
|
30
|
+
}
|
|
31
|
+
// Redirect explicit UMD locale imports to the ESM build so they share that instance.
|
|
32
|
+
const locale = (_UMD_LOCALE_exec = UMD_LOCALE.exec(source)) === null || _UMD_LOCALE_exec === void 0 ? void 0 : _UMD_LOCALE_exec[1];
|
|
33
|
+
if (locale) {
|
|
34
|
+
return this.resolve(`moment/dist/locale/${locale}`, importer, options);
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
load (id) {
|
|
38
|
+
if (id === VIRTUAL_MOMENT) {
|
|
39
|
+
return [
|
|
40
|
+
..._core.MOMENT_LOCALES.map((locale)=>`import 'moment/dist/locale/${locale}';`),
|
|
41
|
+
`import moment from 'moment/dist/moment.js';`,
|
|
42
|
+
`export * from 'moment/dist/moment.js';`,
|
|
43
|
+
`export default moment;`
|
|
44
|
+
].join('\n');
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
//# sourceMappingURL=moment-locales-plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/vite/plugins/moment-locales-plugin.ts"],"sourcesContent":["import type { Plugin } from 'vite';\nimport { BuildContext, MOMENT_LOCALES } from '../../core';\n\nexport const VIRTUAL_MOMENT = '\\0VIRTUAL_MOMENT';\n\nconst UMD_LOCALE = /^moment\\/locale\\/(.+)$/;\n\n/*\n * Statically bundle the supported moment locales for parity with webpack's\n * MomentLocalesPlugin. We need this because moment loads locales via a dynamic\n * require that, with Rolldown, never loads.\n *\n * Resolve everything through moment/dist (the ESM build) else Rolldown creates\n * a separate UMD instance from what the app uses.\n */\nexport function momentLocalesPlugin(_context: BuildContext): Plugin {\n return {\n name: 'moment-locales',\n enforce: 'pre',\n resolveId(source, importer, options) {\n if (source === 'moment') {\n return VIRTUAL_MOMENT;\n }\n // Redirect explicit UMD locale imports to the ESM build so they share that instance.\n const locale = UMD_LOCALE.exec(source)?.[1];\n if (locale) {\n return this.resolve(`moment/dist/locale/${locale}`, importer, options);\n }\n },\n load(id) {\n if (id === VIRTUAL_MOMENT) {\n return [\n ...MOMENT_LOCALES.map(locale => `import 'moment/dist/locale/${locale}';`),\n `import moment from 'moment/dist/moment.js';`,\n `export * from 'moment/dist/moment.js';`,\n `export default moment;`,\n ].join('\\n');\n }\n },\n };\n}\n"],"names":["VIRTUAL_MOMENT","momentLocalesPlugin","UMD_LOCALE","_context","name","enforce","resolveId","source","importer","options","locale","exec","resolve","load","id","MOMENT_LOCALES","map","join"],"mappings":";;;;;;;;;;;QAGaA;eAAAA;;QAYGC;eAAAA;;;sBAd6B;AAEtC,MAAMD,iBAAiB;AAE9B,MAAME,aAAa;AAUZ,SAASD,oBAAoBE,QAAsB;IACtD,OAAO;QACHC,MAAM;QACNC,SAAS;QACTC,WAAUC,MAAM,EAAEC,QAAQ,EAAEC,OAAO;gBAKhBP;YAJf,IAAIK,WAAW,UAAU;gBACrB,OAAOP;YACX;YACA,qFAAqF;YACrF,MAAMU,UAASR,mBAAAA,WAAWS,IAAI,CAACJ,qBAAhBL,uCAAAA,gBAAyB,CAAC,EAAE;YAC3C,IAAIQ,QAAQ;gBACR,OAAO,IAAI,CAACE,OAAO,CAAC,CAAC,mBAAmB,EAAEF,QAAQ,EAAEF,UAAUC;YAClE;QACJ;QACAI,MAAKC,EAAE;YACH,IAAIA,OAAOd,gBAAgB;gBACvB,OAAO;uBACAe,oBAAc,CAACC,GAAG,CAACN,CAAAA,SAAU,CAAC,2BAA2B,EAAEA,OAAO,EAAE,CAAC;oBACxE,CAAC,2CAA2C,CAAC;oBAC7C,CAAC,sCAAsC,CAAC;oBACxC,CAAC,sBAAsB,CAAC;iBAC3B,CAACO,IAAI,CAAC;YACX;QACJ;IACJ;AACJ"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface ModuleFactory {
|
|
2
|
+
/** Module id used as the factory's key and require() argument (e.g. `react`, `./_chunk.js`). */
|
|
3
|
+
id: string;
|
|
4
|
+
/** The chunk's generated code, run inside `function(module, exports, require) { ... }`. */
|
|
5
|
+
code: string;
|
|
6
|
+
}
|
|
7
|
+
export interface Expose {
|
|
8
|
+
/** Global path the dependency is published under (e.g. `SharedDependencies.React`). */
|
|
9
|
+
variable: string;
|
|
10
|
+
/** Module id resolved through the scoped require when the global is accessed. */
|
|
11
|
+
dependency: string;
|
|
12
|
+
}
|
|
13
|
+
export declare function assembleIife(modules: ModuleFactory[], exposes: Expose[]): string;
|
|
14
|
+
//# sourceMappingURL=assemble-iife.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assemble-iife.d.ts","sourceRoot":"","sources":["../../../../src/vite/plugins/shared-dependencies-plugin/assemble-iife.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa;IAC1B,gGAAgG;IAChG,EAAE,EAAE,MAAM,CAAC;IACX,2FAA2F;IAC3F,IAAI,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,MAAM;IACnB,uFAAuF;IACvF,QAAQ,EAAE,MAAM,CAAC;IACjB,iFAAiF;IACjF,UAAU,EAAE,MAAM,CAAC;CACtB;AAWD,wBAAgB,YAAY,CAAC,OAAO,EAAE,aAAa,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,CA0FhF"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "assembleIife", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return assembleIife;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
function indent(spaces) {
|
|
12
|
+
return ' '.repeat(spaces);
|
|
13
|
+
}
|
|
14
|
+
function assembleIife(modules, exposes) {
|
|
15
|
+
const factories = modules.map(({ id, code })=>`'${id}': function(module, exports, require) {\n${indent(12)}${code}\n${indent(8)}}`);
|
|
16
|
+
const exposeCalls = exposes.map(({ variable, dependency })=>`expose('${variable}', '${dependency}');`);
|
|
17
|
+
return `\
|
|
18
|
+
(function () {
|
|
19
|
+
const STORAGE_KEY = Symbol.for('SERVICETITAN_EXPOSE_LOADER_STORAGE');
|
|
20
|
+
const g = globalThis;
|
|
21
|
+
|
|
22
|
+
if (g[STORAGE_KEY] === undefined) {
|
|
23
|
+
g[STORAGE_KEY] = Object.assign(Object.create(null), {
|
|
24
|
+
clear(scope) {
|
|
25
|
+
delete this[scope];
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
var storage = g[STORAGE_KEY];
|
|
31
|
+
|
|
32
|
+
var modules = {
|
|
33
|
+
${factories.join(`,\n${indent(8)}`)}
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
function createScopedRequire(scope) {
|
|
37
|
+
const cache = (storage[scope] = storage[scope] || Object.create(null));
|
|
38
|
+
|
|
39
|
+
function require(id) {
|
|
40
|
+
if (cache[id]) {
|
|
41
|
+
return cache[id].exports;
|
|
42
|
+
}
|
|
43
|
+
if (!modules[id]) {
|
|
44
|
+
throw new Error('Module not found: ' + id);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const module = (cache[id] = { id, loaded: false, exports: {} });
|
|
48
|
+
modules[id](module, module.exports, require);
|
|
49
|
+
module.loaded = true;
|
|
50
|
+
|
|
51
|
+
const keys = Object.keys(module.exports);
|
|
52
|
+
if (module.exports.__esModule && keys.length === 1 && keys[0] === 'default') {
|
|
53
|
+
module.exports = module.exports.default;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return module.exports;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
Object.setPrototypeOf(require, {
|
|
60
|
+
resolve(id) {
|
|
61
|
+
return id;
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
return require;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function expose(path, moduleId) {
|
|
68
|
+
const parts = path.split('.');
|
|
69
|
+
let obj = g;
|
|
70
|
+
|
|
71
|
+
for (let i = 0; i < parts.length - 1; i++) {
|
|
72
|
+
if (obj[parts[i]] === undefined) {
|
|
73
|
+
obj[parts[i]] = Object.create(null);
|
|
74
|
+
}
|
|
75
|
+
obj = obj[parts[i]];
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
obj[parts[parts.length - 1]] = new Proxy(
|
|
79
|
+
Object.assign(Object.create(null), {
|
|
80
|
+
getStorage() {
|
|
81
|
+
return storage;
|
|
82
|
+
},
|
|
83
|
+
}),
|
|
84
|
+
{
|
|
85
|
+
get(target, scope, receiver) {
|
|
86
|
+
if (scope === 'getStorage') {
|
|
87
|
+
return Reflect.get(target, scope, receiver);
|
|
88
|
+
}
|
|
89
|
+
return createScopedRequire(scope)(moduleId);
|
|
90
|
+
},
|
|
91
|
+
}
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
${exposeCalls.join(`\n${indent(4)}`)}
|
|
96
|
+
})();
|
|
97
|
+
`;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
//# sourceMappingURL=assemble-iife.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/vite/plugins/shared-dependencies-plugin/assemble-iife.ts"],"sourcesContent":["export interface ModuleFactory {\n /** Module id used as the factory's key and require() argument (e.g. `react`, `./_chunk.js`). */\n id: string;\n /** The chunk's generated code, run inside `function(module, exports, require) { ... }`. */\n code: string;\n}\n\nexport interface Expose {\n /** Global path the dependency is published under (e.g. `SharedDependencies.React`). */\n variable: string;\n /** Module id resolved through the scoped require when the global is accessed. */\n dependency: string;\n}\n\nfunction indent(spaces: number) {\n return ' '.repeat(spaces);\n}\n\n/*\n * Wraps the bundle's module factories and expose calls in the runtime IIFE.\n * The IIFE installs a per-scope require system on globalThis so each MFE gets\n * isolated module instances of the shared dependencies.\n */\nexport function assembleIife(modules: ModuleFactory[], exposes: Expose[]): string {\n const factories = modules.map(\n ({ id, code }) =>\n `'${id}': function(module, exports, require) {\\n${indent(12)}${code}\\n${indent(8)}}`\n );\n const exposeCalls = exposes.map(\n ({ variable, dependency }) => `expose('${variable}', '${dependency}');`\n );\n\n return `\\\n(function () {\n const STORAGE_KEY = Symbol.for('SERVICETITAN_EXPOSE_LOADER_STORAGE');\n const g = globalThis;\n\n if (g[STORAGE_KEY] === undefined) {\n g[STORAGE_KEY] = Object.assign(Object.create(null), {\n clear(scope) {\n delete this[scope];\n },\n });\n }\n\n var storage = g[STORAGE_KEY];\n\n var modules = {\n ${factories.join(`,\\n${indent(8)}`)}\n };\n\n function createScopedRequire(scope) {\n const cache = (storage[scope] = storage[scope] || Object.create(null));\n\n function require(id) {\n if (cache[id]) {\n return cache[id].exports;\n }\n if (!modules[id]) {\n throw new Error('Module not found: ' + id);\n }\n\n const module = (cache[id] = { id, loaded: false, exports: {} });\n modules[id](module, module.exports, require);\n module.loaded = true;\n\n const keys = Object.keys(module.exports);\n if (module.exports.__esModule && keys.length === 1 && keys[0] === 'default') {\n module.exports = module.exports.default;\n }\n\n return module.exports;\n }\n\n Object.setPrototypeOf(require, {\n resolve(id) {\n return id;\n },\n });\n return require;\n }\n\n function expose(path, moduleId) {\n const parts = path.split('.');\n let obj = g;\n\n for (let i = 0; i < parts.length - 1; i++) {\n if (obj[parts[i]] === undefined) {\n obj[parts[i]] = Object.create(null);\n }\n obj = obj[parts[i]];\n }\n\n obj[parts[parts.length - 1]] = new Proxy(\n Object.assign(Object.create(null), {\n getStorage() {\n return storage;\n },\n }),\n {\n get(target, scope, receiver) {\n if (scope === 'getStorage') {\n return Reflect.get(target, scope, receiver);\n }\n return createScopedRequire(scope)(moduleId);\n },\n }\n );\n }\n\n ${exposeCalls.join(`\\n${indent(4)}`)}\n})();\n`;\n}\n"],"names":["assembleIife","indent","spaces","repeat","modules","exposes","factories","map","id","code","exposeCalls","variable","dependency","join"],"mappings":";;;;+BAuBgBA;;;eAAAA;;;AAThB,SAASC,OAAOC,MAAc;IAC1B,OAAO,IAAIC,MAAM,CAACD;AACtB;AAOO,SAASF,aAAaI,OAAwB,EAAEC,OAAiB;IACpE,MAAMC,YAAYF,QAAQG,GAAG,CACzB,CAAC,EAAEC,EAAE,EAAEC,IAAI,EAAE,GACT,CAAC,CAAC,EAAED,GAAG,yCAAyC,EAAEP,OAAO,MAAMQ,KAAK,EAAE,EAAER,OAAO,GAAG,CAAC,CAAC;IAE5F,MAAMS,cAAcL,QAAQE,GAAG,CAC3B,CAAC,EAAEI,QAAQ,EAAEC,UAAU,EAAE,GAAK,CAAC,QAAQ,EAAED,SAAS,IAAI,EAAEC,WAAW,GAAG,CAAC;IAG3E,OAAO,CAAC;;;;;;;;;;;;;;;;QAgBJ,EAAEN,UAAUO,IAAI,CAAC,CAAC,GAAG,EAAEZ,OAAO,IAAI,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA8DxC,EAAES,YAAYG,IAAI,CAAC,CAAC,EAAE,EAAEZ,OAAO,IAAI,EAAE;;AAEzC,CAAC;AACD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assert-no-dynamic-css.d.ts","sourceRoot":"","sources":["../../../../src/vite/plugins/shared-dependencies-plugin/assert-no-dynamic-css.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAe,MAAM,UAAU,CAAC;AAQ1D,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI,CAiB7D"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "assertNoDynamicCss", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return assertNoDynamicCss;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
function assertNoDynamicCss(bundle) {
|
|
12
|
+
for (const entry of Object.values(bundle)){
|
|
13
|
+
if (!(entry.type === 'chunk' && entry.isEntry)) {
|
|
14
|
+
continue;
|
|
15
|
+
}
|
|
16
|
+
const includedCss = importedCss(entry);
|
|
17
|
+
const excludedCss = [
|
|
18
|
+
...allCss(entry, bundle)
|
|
19
|
+
].filter((css)=>!includedCss.has(css));
|
|
20
|
+
if (excludedCss.length > 0) {
|
|
21
|
+
throw new Error(`Shared dependency chunk "${entry.name}" pulls in CSS through a dynamic import ` + `(${excludedCss.join(', ')}). Shared dependencies only include statically imported ` + `CSS. Dynamically imported CSS will not load on the host.`);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
/*
|
|
26
|
+
* Return every CSS file imported by the entry and recursively by anything it imports.
|
|
27
|
+
*/ function allCss(entry, bundle) {
|
|
28
|
+
const result = new Set();
|
|
29
|
+
const visited = new Set();
|
|
30
|
+
const stack = [
|
|
31
|
+
entry
|
|
32
|
+
];
|
|
33
|
+
while(stack.length > 0){
|
|
34
|
+
const chunk = stack.pop();
|
|
35
|
+
importedCss(chunk).forEach((file)=>result.add(file));
|
|
36
|
+
for (const fileName of [
|
|
37
|
+
...chunk.imports,
|
|
38
|
+
...chunk.dynamicImports
|
|
39
|
+
]){
|
|
40
|
+
const imported = bundle[fileName];
|
|
41
|
+
if ((imported === null || imported === void 0 ? void 0 : imported.type) === 'chunk' && !visited.has(fileName)) {
|
|
42
|
+
visited.add(fileName);
|
|
43
|
+
stack.push(imported);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return result;
|
|
48
|
+
}
|
|
49
|
+
function importedCss(chunk) {
|
|
50
|
+
var _ref;
|
|
51
|
+
var _chunk_viteMetadata;
|
|
52
|
+
return (_ref = (_chunk_viteMetadata = // Vite adds `viteMetadata` to Rolldown chunks; cast because its type augmentation is not in scope here.
|
|
53
|
+
chunk.viteMetadata) === null || _chunk_viteMetadata === void 0 ? void 0 : _chunk_viteMetadata.importedCss) !== null && _ref !== void 0 ? _ref : new Set();
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
//# sourceMappingURL=assert-no-dynamic-css.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/vite/plugins/shared-dependencies-plugin/assert-no-dynamic-css.ts"],"sourcesContent":["import type { OutputBundle, OutputChunk } from 'rolldown';\n\n/*\n * Output bundles only include statically imported CSS. CSS pulled in by a dynamic\n * import() lands in a separate async chunk that is omitted from entrypoints.json\n * and silently fails to load. Fail the build when the bundle references CSS that\n * does not land in entrypoints.json.\n */\nexport function assertNoDynamicCss(bundle: OutputBundle): void {\n for (const entry of Object.values(bundle)) {\n if (!(entry.type === 'chunk' && entry.isEntry)) {\n continue;\n }\n\n const includedCss = importedCss(entry);\n const excludedCss = [...allCss(entry, bundle)].filter(css => !includedCss.has(css));\n\n if (excludedCss.length > 0) {\n throw new Error(\n `Shared dependency chunk \"${entry.name}\" pulls in CSS through a dynamic import ` +\n `(${excludedCss.join(', ')}). Shared dependencies only include statically imported ` +\n `CSS. Dynamically imported CSS will not load on the host.`\n );\n }\n }\n}\n\n/*\n * Return every CSS file imported by the entry and recursively by anything it imports.\n */\nfunction allCss(entry: OutputChunk, bundle: OutputBundle): Set<string> {\n const result = new Set<string>();\n const visited = new Set<string>();\n const stack = [entry];\n\n while (stack.length > 0) {\n const chunk = stack.pop()!;\n importedCss(chunk).forEach(file => result.add(file));\n\n for (const fileName of [...chunk.imports, ...chunk.dynamicImports]) {\n const imported = bundle[fileName];\n if (imported?.type === 'chunk' && !visited.has(fileName)) {\n visited.add(fileName);\n stack.push(imported);\n }\n }\n }\n\n return result;\n}\n\nfunction importedCss(chunk: OutputChunk): ReadonlySet<string> {\n return (\n // Vite adds `viteMetadata` to Rolldown chunks; cast because its type augmentation is not in scope here.\n (chunk as { viteMetadata?: { importedCss?: Set<string> } }).viteMetadata?.importedCss ??\n new Set<string>()\n );\n}\n"],"names":["assertNoDynamicCss","bundle","entry","Object","values","type","isEntry","includedCss","importedCss","excludedCss","allCss","filter","css","has","length","Error","name","join","result","Set","visited","stack","chunk","pop","forEach","file","add","fileName","imports","dynamicImports","imported","push","viteMetadata"],"mappings":";;;;+BAQgBA;;;eAAAA;;;AAAT,SAASA,mBAAmB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AAIW;AAEZ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flatten.d.ts","sourceRoot":"","sources":["../../../../src/vite/plugins/shared-dependencies-plugin/flatten.ts"],"names":[],"mappings":"AAKA,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE3C"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Replaces `/` with `-` so scoped packages stay flat in Rolldown output.
|
|
3
|
+
* Without this, `@scope/foo` emits into a subdirectory and its require()
|
|
4
|
+
* calls use `../` paths that don't match the IIFE's flat module keys.
|
|
5
|
+
*/ "use strict";
|
|
6
|
+
Object.defineProperty(exports, "__esModule", {
|
|
7
|
+
value: true
|
|
8
|
+
});
|
|
9
|
+
Object.defineProperty(exports, "flatten", {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function() {
|
|
12
|
+
return flatten;
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
function flatten(dep) {
|
|
16
|
+
return dep.replace(/\//g, '-');
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=flatten.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/vite/plugins/shared-dependencies-plugin/flatten.ts"],"sourcesContent":["/*\n * Replaces `/` with `-` so scoped packages stay flat in Rolldown output.\n * Without this, `@scope/foo` emits into a subdirectory and its require()\n * calls use `../` paths that don't match the IIFE's flat module keys.\n */\nexport function flatten(dep: string): string {\n return dep.replace(/\\//g, '-');\n}\n"],"names":["flatten","dep","replace"],"mappings":"AAAA;;;;CAIC;;;;+BACeA;;;eAAAA;;;AAAT,SAASA,QAAQC,GAAW;IAC/B,OAAOA,IAAIC,OAAO,CAAC,OAAO;AAC9B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/vite/plugins/shared-dependencies-plugin/index.ts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
_export_star(require("./shared-dependencies-plugin"), exports);
|
|
6
|
+
function _export_star(from, to) {
|
|
7
|
+
Object.keys(from).forEach(function(k) {
|
|
8
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
9
|
+
Object.defineProperty(to, k, {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function() {
|
|
12
|
+
return from[k];
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
return from;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/vite/plugins/shared-dependencies-plugin/index.ts"],"sourcesContent":["export * from './shared-dependencies-plugin';\n"],"names":[],"mappings":";;;;qBAAc"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared-dependencies-plugin.d.ts","sourceRoot":"","sources":["../../../../src/vite/plugins/shared-dependencies-plugin/shared-dependencies-plugin.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAM9B,MAAM,WAAW,+BAA+B;IAC5C,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACrC,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IAC/B,WAAW,CAAC,EAAE,MAAM,CAAC;CACxB;AAKD,wBAAgB,wBAAwB,CAAC,EACrC,YAAY,EACZ,GAAG,EACH,WAAW,GACd,EAAE,+BAA+B,GAAG,MAAM,CAgK1C"}
|
|
@@ -10,22 +10,17 @@ Object.defineProperty(exports, "sharedDependenciesPlugin", {
|
|
|
10
10
|
});
|
|
11
11
|
const _crypto = /*#__PURE__*/ _interop_require_default(require("crypto"));
|
|
12
12
|
const _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
13
|
-
const _core = require("
|
|
13
|
+
const _core = require("../../../core");
|
|
14
|
+
const _assembleiife = require("./assemble-iife");
|
|
15
|
+
const _assertnodynamiccss = require("./assert-no-dynamic-css");
|
|
16
|
+
const _flatten = require("./flatten");
|
|
14
17
|
function _interop_require_default(obj) {
|
|
15
18
|
return obj && obj.__esModule ? obj : {
|
|
16
19
|
default: obj
|
|
17
20
|
};
|
|
18
21
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
* Without this, `@scope/foo` emits into a subdirectory and its require()
|
|
22
|
-
* calls use `../` paths that don't match the IIFE's flat module keys.
|
|
23
|
-
*/ function flatName(dep) {
|
|
24
|
-
return dep.replace('/', '-');
|
|
25
|
-
}
|
|
26
|
-
function indent(spaces) {
|
|
27
|
-
return ' '.repeat(spaces);
|
|
28
|
-
}
|
|
22
|
+
// Suffix for the CJS entry files emitted by `entryFileNames` below.
|
|
23
|
+
const ENTRY_FILE_SUFFIX = '.cjs.js';
|
|
29
24
|
function sharedDependenciesPlugin({ dependencies, css, metadataDir }) {
|
|
30
25
|
const CSS_VIRTUAL_PREFIX = '\0SHARED_DEPENDENCY_CSS';
|
|
31
26
|
const dependencyNames = Object.keys(dependencies);
|
|
@@ -40,7 +35,7 @@ function sharedDependenciesPlugin({ dependencies, css, metadataDir }) {
|
|
|
40
35
|
isProduction = env.mode === _core.bundleConstants.mode.production;
|
|
41
36
|
const input = {};
|
|
42
37
|
for (const dependency of dependencyNames){
|
|
43
|
-
input[
|
|
38
|
+
input[(0, _flatten.flatten)(dependency)] = dependency;
|
|
44
39
|
}
|
|
45
40
|
for (const name of cssInputNames){
|
|
46
41
|
input[name] = CSS_VIRTUAL_PREFIX + name;
|
|
@@ -48,7 +43,7 @@ function sharedDependenciesPlugin({ dependencies, css, metadataDir }) {
|
|
|
48
43
|
return {
|
|
49
44
|
// Relative base so CSS font URLs resolve from the CSS file's directory, not site root
|
|
50
45
|
base: './',
|
|
51
|
-
// Must match host build mode
|
|
46
|
+
// Must match host build mode; mismatch causes react-dom/client usingClientEntryPoint errors
|
|
52
47
|
define: {
|
|
53
48
|
'process.env.NODE_ENV': JSON.stringify(env.mode)
|
|
54
49
|
},
|
|
@@ -63,14 +58,14 @@ function sharedDependenciesPlugin({ dependencies, css, metadataDir }) {
|
|
|
63
58
|
* code in function(module, exports, require) { ... }
|
|
64
59
|
*/ format: 'cjs',
|
|
65
60
|
exports: 'named',
|
|
66
|
-
entryFileNames:
|
|
61
|
+
entryFileNames: `[name]${ENTRY_FILE_SUFFIX}`,
|
|
67
62
|
chunkFileNames: '_[name]-[hash].js',
|
|
68
63
|
assetFileNames: (assetInfo)=>{
|
|
69
64
|
var _ref, _rawName_split_pop;
|
|
70
65
|
var _assetInfo_names;
|
|
71
66
|
const rawName = (_ref = (_assetInfo_names = assetInfo.names) === null || _assetInfo_names === void 0 ? void 0 : _assetInfo_names[0]) !== null && _ref !== void 0 ? _ref : '';
|
|
72
67
|
const ext = (_rawName_split_pop = rawName.split('.').pop()) !== null && _rawName_split_pop !== void 0 ? _rawName_split_pop : '';
|
|
73
|
-
// Strip scope prefix added by
|
|
68
|
+
// Strip scope prefix added by flatten (e.g. @servicetitan-anvil2 to anvil2)
|
|
74
69
|
const name = rawName.replace(/^@[^-]+-/, '').replace(/\.[^.]+$/, '');
|
|
75
70
|
if (ext === 'css') {
|
|
76
71
|
return isProduction ? `${name}.[hash].bundle[extname]` : `${name}.bundle[extname]`;
|
|
@@ -110,32 +105,42 @@ function sharedDependenciesPlugin({ dependencies, css, metadataDir }) {
|
|
|
110
105
|
return imports.map((p)=>`import '${p}';`).join('\n');
|
|
111
106
|
},
|
|
112
107
|
generateBundle (_options, bundle) {
|
|
113
|
-
|
|
108
|
+
(0, _assertnodynamiccss.assertNoDynamicCss)(bundle);
|
|
109
|
+
const modules = [];
|
|
114
110
|
const exposes = [];
|
|
115
111
|
for (const [fileName, chunk] of Object.entries(bundle)){
|
|
116
112
|
if (chunk.type !== 'chunk') {
|
|
117
113
|
continue;
|
|
118
114
|
}
|
|
119
115
|
if (!chunk.isEntry) {
|
|
120
|
-
|
|
116
|
+
modules.push({
|
|
117
|
+
id: `./${fileName}`,
|
|
118
|
+
code: chunk.code
|
|
119
|
+
});
|
|
121
120
|
delete bundle[fileName];
|
|
122
121
|
}
|
|
123
122
|
}
|
|
124
123
|
for (const [dependency, variable] of Object.entries(dependencies)){
|
|
125
|
-
const entryFileName = `${
|
|
124
|
+
const entryFileName = `${(0, _flatten.flatten)(dependency)}${ENTRY_FILE_SUFFIX}`;
|
|
126
125
|
const chunk = bundle[entryFileName];
|
|
127
126
|
if ((chunk === null || chunk === void 0 ? void 0 : chunk.type) !== 'chunk') {
|
|
128
127
|
var _ref;
|
|
129
128
|
throw new Error(`Expected entry chunk for ${dependency}, got type: ${(_ref = chunk === null || chunk === void 0 ? void 0 : chunk.type) !== null && _ref !== void 0 ? _ref : 'undefined'}`);
|
|
130
129
|
}
|
|
131
|
-
|
|
132
|
-
|
|
130
|
+
modules.push({
|
|
131
|
+
id: dependency,
|
|
132
|
+
code: chunk.code
|
|
133
|
+
});
|
|
134
|
+
exposes.push({
|
|
135
|
+
variable,
|
|
136
|
+
dependency
|
|
137
|
+
});
|
|
133
138
|
delete bundle[entryFileName];
|
|
134
139
|
}
|
|
135
140
|
for (const name of cssInputNames){
|
|
136
|
-
delete bundle[`${name}
|
|
141
|
+
delete bundle[`${name}${ENTRY_FILE_SUFFIX}`];
|
|
137
142
|
}
|
|
138
|
-
const code =
|
|
143
|
+
const code = (0, _assembleiife.assembleIife)(modules, exposes);
|
|
139
144
|
const hash = _crypto.default.createHash('md5').update(code).digest('hex').slice(0, 20);
|
|
140
145
|
const sharedFileName = isProduction ? `shared.${hash}.bundle.js` : 'shared.bundle.js';
|
|
141
146
|
this.emitFile({
|
|
@@ -143,7 +148,7 @@ function sharedDependenciesPlugin({ dependencies, css, metadataDir }) {
|
|
|
143
148
|
fileName: sharedFileName,
|
|
144
149
|
source: code
|
|
145
150
|
});
|
|
146
|
-
const cssFiles = Object.keys(bundle).filter((f)=>f.endsWith('.bundle.css'));
|
|
151
|
+
const cssFiles = (0, _core.sortSharedCss)(Object.keys(bundle).filter((f)=>f.endsWith('.bundle.css')));
|
|
147
152
|
const entrypoints = {
|
|
148
153
|
css: cssFiles,
|
|
149
154
|
js: [
|
|
@@ -160,93 +165,10 @@ function sharedDependenciesPlugin({ dependencies, css, metadataDir }) {
|
|
|
160
165
|
/*
|
|
161
166
|
* dir is always set when build.outDir is configured (our case).
|
|
162
167
|
* Rolldown types it as optional, but falling back to '' would
|
|
163
|
-
* silently resolve to cwd
|
|
168
|
+
* silently resolve to cwd; better to crash than write wrong metadata.
|
|
164
169
|
*/ (0, _core.generateExposedDependenciesMetadata)(metadataDir, ()=>_path.default.resolve(options.dir, 'entrypoints.json'));
|
|
165
170
|
} : undefined
|
|
166
171
|
};
|
|
167
172
|
}
|
|
168
|
-
function assembleIIFE(factories, exposes) {
|
|
169
|
-
return `\
|
|
170
|
-
(function () {
|
|
171
|
-
const STORAGE_KEY = Symbol.for('SERVICETITAN_EXPOSE_LOADER_STORAGE');
|
|
172
|
-
const g = globalThis;
|
|
173
|
-
|
|
174
|
-
if (g[STORAGE_KEY] === undefined) {
|
|
175
|
-
g[STORAGE_KEY] = Object.assign(Object.create(null), {
|
|
176
|
-
clear(scope) {
|
|
177
|
-
delete this[scope];
|
|
178
|
-
},
|
|
179
|
-
});
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
var storage = g[STORAGE_KEY];
|
|
183
|
-
|
|
184
|
-
var modules = {
|
|
185
|
-
${factories.join(`,\n${indent(8)}`)}
|
|
186
|
-
};
|
|
187
|
-
|
|
188
|
-
function createScopedRequire(scope) {
|
|
189
|
-
const cache = (storage[scope] = storage[scope] || Object.create(null));
|
|
190
|
-
|
|
191
|
-
function require(id) {
|
|
192
|
-
if (cache[id]) {
|
|
193
|
-
return cache[id].exports;
|
|
194
|
-
}
|
|
195
|
-
if (!modules[id]) {
|
|
196
|
-
throw new Error('Module not found: ' + id);
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
const module = (cache[id] = { id, loaded: false, exports: {} });
|
|
200
|
-
modules[id](module, module.exports, require);
|
|
201
|
-
module.loaded = true;
|
|
202
|
-
|
|
203
|
-
const keys = Object.keys(module.exports);
|
|
204
|
-
if (module.exports.__esModule && keys.length === 1 && keys[0] === 'default') {
|
|
205
|
-
module.exports = module.exports.default;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
return module.exports;
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
Object.setPrototypeOf(require, {
|
|
212
|
-
resolve(id) {
|
|
213
|
-
return id;
|
|
214
|
-
},
|
|
215
|
-
});
|
|
216
|
-
return require;
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
function expose(path, moduleId) {
|
|
220
|
-
const parts = path.split('.');
|
|
221
|
-
let obj = g;
|
|
222
|
-
|
|
223
|
-
for (let i = 0; i < parts.length - 1; i++) {
|
|
224
|
-
if (obj[parts[i]] === undefined) {
|
|
225
|
-
obj[parts[i]] = Object.create(null);
|
|
226
|
-
}
|
|
227
|
-
obj = obj[parts[i]];
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
obj[parts[parts.length - 1]] = new Proxy(
|
|
231
|
-
Object.assign(Object.create(null), {
|
|
232
|
-
getStorage() {
|
|
233
|
-
return storage;
|
|
234
|
-
},
|
|
235
|
-
}),
|
|
236
|
-
{
|
|
237
|
-
get(target, scope, receiver) {
|
|
238
|
-
if (scope === 'getStorage') {
|
|
239
|
-
return Reflect.get(target, scope, receiver);
|
|
240
|
-
}
|
|
241
|
-
return createScopedRequire(scope)(moduleId);
|
|
242
|
-
},
|
|
243
|
-
}
|
|
244
|
-
);
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
${exposes.join(`\n${indent(4)}`)}
|
|
248
|
-
})();
|
|
249
|
-
`;
|
|
250
|
-
}
|
|
251
173
|
|
|
252
174
|
//# sourceMappingURL=shared-dependencies-plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/vite/plugins/shared-dependencies-plugin/shared-dependencies-plugin.ts"],"sourcesContent":["import crypto from 'crypto';\nimport path from 'path';\nimport { Plugin } from 'vite';\nimport { bundleConstants, generateExposedDependenciesMetadata, sortSharedCss } from '../../../core';\nimport { assembleIife, Expose, ModuleFactory } from './assemble-iife';\nimport { assertNoDynamicCss } from './assert-no-dynamic-css';\nimport { flatten } from './flatten';\n\nexport interface SharedDependenciesPluginOptions {\n dependencies: Record<string, string>;\n css?: Record<string, string[]>;\n metadataDir?: string;\n}\n\n// Suffix for the CJS entry files emitted by `entryFileNames` below.\nconst ENTRY_FILE_SUFFIX = '.cjs.js';\n\nexport function sharedDependenciesPlugin({\n dependencies,\n css,\n metadataDir,\n}: SharedDependenciesPluginOptions): Plugin {\n const CSS_VIRTUAL_PREFIX = '\\0SHARED_DEPENDENCY_CSS';\n\n const dependencyNames = Object.keys(dependencies);\n const dependencySet = new Set(dependencyNames);\n const cssEntries = css ?? {};\n const cssInputNames = Object.keys(cssEntries);\n let isProduction = false;\n\n return {\n name: 'shared-dependencies',\n enforce: 'pre',\n\n config(_, env) {\n isProduction = env.mode === bundleConstants.mode.production;\n\n const input: Record<string, string> = {};\n for (const dependency of dependencyNames) {\n input[flatten(dependency)] = dependency;\n }\n for (const name of cssInputNames) {\n input[name] = CSS_VIRTUAL_PREFIX + name;\n }\n\n return {\n // Relative base so CSS font URLs resolve from the CSS file's directory, not site root\n base: './',\n // Must match host build mode; mismatch causes react-dom/client usingClientEntryPoint errors\n define: {\n 'process.env.NODE_ENV': JSON.stringify(env.mode),\n },\n build: {\n rolldownOptions: {\n // Vite defaults to false which strips all CJS exports from entry chunks\n preserveEntrySignatures: 'exports-only',\n input,\n output: {\n /*\n * CJS format + named exports: the factory system wraps each entry's\n * code in function(module, exports, require) { ... }\n */\n format: 'cjs',\n exports: 'named',\n entryFileNames: `[name]${ENTRY_FILE_SUFFIX}`,\n chunkFileNames: '_[name]-[hash].js',\n assetFileNames: assetInfo => {\n const rawName = assetInfo.names?.[0] ?? '';\n const ext = rawName.split('.').pop() ?? '';\n // Strip scope prefix added by flatten (e.g. @servicetitan-anvil2 to anvil2)\n const name = rawName\n .replace(/^@[^-]+-/, '')\n .replace(/\\.[^.]+$/, '');\n if (ext === 'css') {\n return isProduction\n ? `${name}.[hash].bundle[extname]`\n : `${name}.bundle[extname]`;\n }\n return isProduction\n ? `${name}.[hash][extname]`\n : `${name}[extname]`;\n },\n },\n // Disabled: we don't know which exports MFEs will use at runtime\n treeshake: false,\n },\n },\n };\n },\n\n resolveId(source: string, importer: string | undefined) {\n if (source.startsWith(CSS_VIRTUAL_PREFIX)) {\n return source;\n }\n if (!importer) {\n return;\n }\n if (dependencySet.has(source)) {\n return { id: source, external: true };\n }\n },\n\n load(id: string) {\n if (!id.startsWith(CSS_VIRTUAL_PREFIX)) {\n return;\n }\n const name = id.slice(CSS_VIRTUAL_PREFIX.length);\n const imports = cssEntries[name];\n if (!imports) {\n return;\n }\n return imports.map(p => `import '${p}';`).join('\\n');\n },\n\n generateBundle(_options, bundle) {\n assertNoDynamicCss(bundle);\n\n const modules: ModuleFactory[] = [];\n const exposes: Expose[] = [];\n\n for (const [fileName, chunk] of Object.entries(bundle)) {\n if (chunk.type !== 'chunk') {\n continue;\n }\n if (!chunk.isEntry) {\n modules.push({ id: `./${fileName}`, code: chunk.code });\n delete bundle[fileName];\n }\n }\n\n for (const [dependency, variable] of Object.entries(dependencies)) {\n const entryFileName = `${flatten(dependency)}${ENTRY_FILE_SUFFIX}`;\n const chunk = bundle[entryFileName];\n if (chunk?.type !== 'chunk') {\n throw new Error(\n `Expected entry chunk for ${dependency}, got type: ${chunk?.type ?? 'undefined'}`\n );\n }\n modules.push({ id: dependency, code: chunk.code });\n exposes.push({ variable, dependency });\n delete bundle[entryFileName];\n }\n\n for (const name of cssInputNames) {\n delete bundle[`${name}${ENTRY_FILE_SUFFIX}`];\n }\n\n const code = assembleIife(modules, exposes);\n const hash = crypto.createHash('md5').update(code).digest('hex').slice(0, 20);\n const sharedFileName = isProduction ? `shared.${hash}.bundle.js` : 'shared.bundle.js';\n\n this.emitFile({\n type: 'asset',\n fileName: sharedFileName,\n source: code,\n });\n\n const cssFiles = sortSharedCss(\n Object.keys(bundle).filter(f => f.endsWith('.bundle.css'))\n );\n const entrypoints = { css: cssFiles, js: [sharedFileName] };\n this.emitFile({\n type: 'asset',\n fileName: 'entrypoints.json',\n source: JSON.stringify(entrypoints, null, 2),\n });\n },\n\n writeBundle: metadataDir\n ? options => {\n /*\n * dir is always set when build.outDir is configured (our case).\n * Rolldown types it as optional, but falling back to '' would\n * silently resolve to cwd; better to crash than write wrong metadata.\n */\n generateExposedDependenciesMetadata(metadataDir, () =>\n path.resolve(options.dir!, 'entrypoints.json')\n );\n }\n : undefined,\n };\n}\n"],"names":["sharedDependenciesPlugin","ENTRY_FILE_SUFFIX","dependencies","css","metadataDir","CSS_VIRTUAL_PREFIX","dependencyNames","Object","keys","dependencySet","Set","cssEntries","cssInputNames","isProduction","name","enforce","config","_","env","mode","bundleConstants","production","input","dependency","flatten","base","define","JSON","stringify","build","rolldownOptions","preserveEntrySignatures","output","format","exports","entryFileNames","chunkFileNames","assetFileNames","assetInfo","rawName","names","ext","split","pop","replace","treeshake","resolveId","source","importer","startsWith","has","id","external","load","slice","length","imports","map","p","join","generateBundle","_options","bundle","assertNoDynamicCss","modules","exposes","fileName","chunk","entries","type","isEntry","push","code","variable","entryFileName","Error","assembleIife","hash","crypto","createHash","update","digest","sharedFileName","emitFile","cssFiles","sortSharedCss","filter","f","endsWith","entrypoints","js","writeBundle","options","generateExposedDependenciesMetadata","path","resolve","dir","undefined"],"mappings":";;;;+BAiBgBA;;;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,MAAMC,cAAc;gBAAEtF,KAAKiF;gBAAUM,IAAI;oBAACR;iBAAe;YAAC;YAC1D,IAAI,CAACC,QAAQ,CAAC;gBACVd,MAAM;gBACNH,UAAU;gBACVnB,QAAQpB,KAAKC,SAAS,CAAC6D,aAAa,MAAM;YAC9C;QACJ;QAEAE,aAAavF,cACPwF,CAAAA;YACI;;;;mBAIC,GACDC,IAAAA,yCAAmC,EAACzF,aAAa,IAC7C0F,aAAI,CAACC,OAAO,CAACH,QAAQI,GAAG,EAAG;QAEnC,IACAC;IACV;AACJ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"import-esm.d.ts","sourceRoot":"","sources":["../../../../src/vite/plugins/utils/import-esm.ts"],"names":[],"mappings":"AAYA,wBAAgB,SAAS,CAAC,CAAC,GAAG,OAAO,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,CAEpE"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "importEsm", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return importEsm;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
/*
|
|
12
|
+
* Load an ES module from CommonJS output. SWC rewrites a plain dynamic
|
|
13
|
+
* import() to require(), which throws on ESM-only packages (those whose
|
|
14
|
+
* package exports have no "require" entry, e.g. vite-plugin-istanbul). Hiding
|
|
15
|
+
* the import() inside a Function keeps it native so it isn't rewritten.
|
|
16
|
+
*/ // eslint-disable-next-line @typescript-eslint/no-implied-eval
|
|
17
|
+
const nativeImport = new Function('specifier', 'return import(specifier)');
|
|
18
|
+
function importEsm(specifier) {
|
|
19
|
+
return nativeImport(specifier);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
//# sourceMappingURL=import-esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/vite/plugins/utils/import-esm.ts"],"sourcesContent":["/*\n * Load an ES module from CommonJS output. SWC rewrites a plain dynamic\n * import() to require(), which throws on ESM-only packages (those whose\n * package exports have no \"require\" entry, e.g. vite-plugin-istanbul). Hiding\n * the import() inside a Function keeps it native so it isn't rewritten.\n */\n// eslint-disable-next-line @typescript-eslint/no-implied-eval\nconst nativeImport = new Function('specifier', 'return import(specifier)') as (\n specifier: string\n) => Promise<unknown>;\n\n/* istanbul ignore next -- native import can't run in jest; verified at runtime */\nexport function importEsm<T = unknown>(specifier: string): Promise<T> {\n return nativeImport(specifier) as Promise<T>;\n}\n"],"names":["importEsm","nativeImport","Function","specifier"],"mappings":";;;;+BAYgBA;;;eAAAA;;;AAZhB;;;;;CAKC,GACD,8DAA8D;AAC9D,MAAMC,eAAe,IAAIC,SAAS,aAAa;AAKxC,SAASF,UAAuBG,SAAiB;IACpD,OAAOF,aAAaE;AACxB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/vite/plugins/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,cAAc,CAAC"}
|