@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,46 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import type { Plugin } from 'vite';
|
|
4
|
+
import { BuildContext, getBundleType } from '../../core';
|
|
5
|
+
|
|
6
|
+
/*
|
|
7
|
+
* Removes stale artifacts from the output directory. MFE builds use Vite's `emptyOutDir`.
|
|
8
|
+
* Host builds can't, since their outDir holds the shared dependencies subdir, so
|
|
9
|
+
* `buildStart` empties it while keeping shared dependencies.
|
|
10
|
+
*/
|
|
11
|
+
export function cleanPlugin(context: BuildContext): Plugin {
|
|
12
|
+
const { isWebComponent } = context.package;
|
|
13
|
+
let outDir = '';
|
|
14
|
+
|
|
15
|
+
return {
|
|
16
|
+
name: 'clean',
|
|
17
|
+
apply: 'build',
|
|
18
|
+
config: () => ({ build: { emptyOutDir: isWebComponent } }),
|
|
19
|
+
configResolved(config) {
|
|
20
|
+
outDir = config.build.outDir;
|
|
21
|
+
},
|
|
22
|
+
buildStart() {
|
|
23
|
+
if (isWebComponent || !fs.existsSync(outDir)) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const keep = getKeepDir(context);
|
|
27
|
+
for (const entry of fs.readdirSync(outDir)) {
|
|
28
|
+
if (entry === keep) {
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
fs.rmSync(path.join(outDir, entry), { recursive: true, force: true });
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/* The shared deps subdirectory to preserve, or undefined to clean everything. */
|
|
38
|
+
function getKeepDir(context: BuildContext): string | undefined {
|
|
39
|
+
if (context.build.emitExposedDependencies) {
|
|
40
|
+
return undefined;
|
|
41
|
+
}
|
|
42
|
+
return getBundleType({
|
|
43
|
+
...context,
|
|
44
|
+
build: { ...context.build, emitExposedDependencies: true },
|
|
45
|
+
});
|
|
46
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import type { Plugin } from 'vite';
|
|
3
|
+
import { BuildContext } from '../../core';
|
|
4
|
+
|
|
5
|
+
const DESIGN_SYSTEM = '@servicetitan/design-system';
|
|
6
|
+
const DESIGN_SYSTEM_CSS = /[\\/]design-system\.css$/;
|
|
7
|
+
|
|
8
|
+
/*
|
|
9
|
+
* Errors when a host's own code imports design-system.css while it exposes the design
|
|
10
|
+
* system as a shared dependency. The CSS already ships in the shared bundle, so a direct
|
|
11
|
+
* import would load the design system twice. Mirrors the webpack guard in css-rules.ts.
|
|
12
|
+
*/
|
|
13
|
+
export function designSystemGuardPlugin(context: BuildContext): Plugin {
|
|
14
|
+
const { isExposeSharedDependencies, sharedDependencies } = context.package;
|
|
15
|
+
const { emitExposedDependencies } = context.build;
|
|
16
|
+
|
|
17
|
+
const designSystemInSharedBundle =
|
|
18
|
+
isExposeSharedDependencies &&
|
|
19
|
+
!!sharedDependencies[DESIGN_SYSTEM] &&
|
|
20
|
+
!emitExposedDependencies;
|
|
21
|
+
|
|
22
|
+
return {
|
|
23
|
+
name: 'design-system-guard',
|
|
24
|
+
enforce: 'pre',
|
|
25
|
+
resolveId(source, importer) {
|
|
26
|
+
if (designSystemInSharedBundle && importer && DESIGN_SYSTEM_CSS.test(source)) {
|
|
27
|
+
const filename = path.parse(importer).name;
|
|
28
|
+
this.error(
|
|
29
|
+
`do not import design-system.css in "${filename}"; it is automatically included as a shared dependency`
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
}
|
|
@@ -1,8 +1,24 @@
|
|
|
1
1
|
import type { Plugin } from 'vite';
|
|
2
2
|
import { BuildContext, checkResource } from '../../core';
|
|
3
3
|
|
|
4
|
-
export const
|
|
4
|
+
export const THROW_PREFIX = '\0IGNORE_THROW:';
|
|
5
|
+
export const EMPTY_PREFIX = '\0IGNORE_EMPTY:';
|
|
5
6
|
|
|
7
|
+
/**
|
|
8
|
+
* Handles optional peer dependencies that are not installed.
|
|
9
|
+
*
|
|
10
|
+
* @see {@link file://./../../webpack/configs/plugins/ignore-plugin/ignore-plugin.ts} for the webpack counterpart.
|
|
11
|
+
*
|
|
12
|
+
* 'throw' mode: substitutes a virtual module whose body throws "Cannot find module" on
|
|
13
|
+
* evaluation. Mirrors webpack's `webpackMissingModule()` semantics. Top-level static
|
|
14
|
+
* imports of the resource crash module evaluation, and `try { await import(...) } catch {}`
|
|
15
|
+
* (or `try { require(...) } catch {}` in CJS code Rolldown bundles) work as expected.
|
|
16
|
+
* This is the default for matched optional peers.
|
|
17
|
+
*
|
|
18
|
+
* 'empty' mode: substitutes a virtual module with no exports. Required for top-level
|
|
19
|
+
* `import * as X from 'optional'` followed by `X.foo === undefined` detection. Opt in via
|
|
20
|
+
* `cli.peerDependenciesMeta["pkg"].fallback = "empty"` in the importer's package.json.
|
|
21
|
+
*/
|
|
6
22
|
export function ignoreModulesPlugin(context: BuildContext): Plugin {
|
|
7
23
|
const checker = checkResource(context);
|
|
8
24
|
|
|
@@ -10,16 +26,26 @@ export function ignoreModulesPlugin(context: BuildContext): Plugin {
|
|
|
10
26
|
name: 'ignore-modules',
|
|
11
27
|
enforce: 'pre',
|
|
12
28
|
resolveId(source, importer) {
|
|
13
|
-
if (importer
|
|
14
|
-
return
|
|
29
|
+
if (!importer) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
const mode = checker({ resource: source, importer });
|
|
33
|
+
if (mode === 'throw') {
|
|
34
|
+
return `${THROW_PREFIX}${source}`;
|
|
35
|
+
}
|
|
36
|
+
if (mode === 'empty') {
|
|
37
|
+
return `${EMPTY_PREFIX}${source}`;
|
|
15
38
|
}
|
|
16
39
|
},
|
|
17
40
|
load(id) {
|
|
18
|
-
if (id.startsWith(
|
|
19
|
-
const source = id.slice(
|
|
41
|
+
if (id.startsWith(THROW_PREFIX)) {
|
|
42
|
+
const source = id.slice(THROW_PREFIX.length);
|
|
20
43
|
const message = JSON.stringify(`Cannot find module '${source}'`);
|
|
21
44
|
return `throw Object.assign(new Error(${message}), { code: 'MODULE_NOT_FOUND' });`;
|
|
22
45
|
}
|
|
46
|
+
if (id.startsWith(EMPTY_PREFIX)) {
|
|
47
|
+
return 'export {};';
|
|
48
|
+
}
|
|
23
49
|
},
|
|
24
50
|
};
|
|
25
51
|
}
|
|
@@ -1,9 +1,16 @@
|
|
|
1
|
+
export * from './bundle-stat-plugin';
|
|
2
|
+
export * from './chain-source-maps-plugin';
|
|
3
|
+
export * from './clean-plugin';
|
|
1
4
|
export * from './css-injector-plugin';
|
|
5
|
+
export * from './design-system-guard-plugin';
|
|
2
6
|
export * from './dev-server-routing-plugin';
|
|
3
7
|
export * from './externals-plugin';
|
|
4
8
|
export * from './html-plugin';
|
|
5
9
|
export * from './ignore-modules-plugin';
|
|
10
|
+
export * from './istanbul-plugin';
|
|
11
|
+
export * from './magic-comments-plugin';
|
|
6
12
|
export * from './metadata-plugin';
|
|
13
|
+
export * from './moment-locales-plugin';
|
|
7
14
|
export * from './style-urls-plugin';
|
|
8
15
|
export * from './svgr-plugin';
|
|
9
16
|
export * from './virtual-modules-plugin';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Plugin } from 'vite';
|
|
2
|
+
import { ViteBuildContext } from '../types';
|
|
3
|
+
import { importEsm } from './utils';
|
|
4
|
+
|
|
5
|
+
export function istanbulPlugin(context: ViteBuildContext): Promise<Plugin> | undefined {
|
|
6
|
+
if (!context.options.codeCoverage) {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
// vite-plugin-istanbul is ESM-only; load it natively so SWC doesn't rewrite to require.
|
|
11
|
+
return importEsm<typeof import('vite-plugin-istanbul')>('vite-plugin-istanbul').then(
|
|
12
|
+
({ default: istanbul }) =>
|
|
13
|
+
istanbul({
|
|
14
|
+
exclude: ['**/node_modules/**', '**/.yalc/**'],
|
|
15
|
+
requireEnv: false,
|
|
16
|
+
forceBuildInstrument: true,
|
|
17
|
+
})
|
|
18
|
+
);
|
|
19
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import type { ViteBuildContext } from '../../../types';
|
|
2
|
+
import { magicCommentsPlugin } from '../magic-comments-plugin';
|
|
3
|
+
|
|
4
|
+
describe(`[startup] ${magicCommentsPlugin.name}`, () => {
|
|
5
|
+
const importPath = './feature';
|
|
6
|
+
const resolve = jest.fn();
|
|
7
|
+
const warn = jest.fn();
|
|
8
|
+
let context: ViteBuildContext;
|
|
9
|
+
let code: string;
|
|
10
|
+
|
|
11
|
+
beforeEach(() => {
|
|
12
|
+
jest.clearAllMocks();
|
|
13
|
+
resolve.mockImplementation(path => ({ id: path }));
|
|
14
|
+
context = { build: { isProduction: true } } as ViteBuildContext;
|
|
15
|
+
code = `import('${importPath}');`;
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
const subject = async () => {
|
|
19
|
+
const plugin = magicCommentsPlugin(context)!;
|
|
20
|
+
const { chunkFileNames } = (plugin.config as Function)().build.rolldownOptions.output;
|
|
21
|
+
// Returns chunk name the plugin produces for module imported by `code`
|
|
22
|
+
await (plugin.transform as { handler: Function }).handler.call({ resolve, warn }, code, '');
|
|
23
|
+
return chunkFileNames({ facadeModuleId: importPath });
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
function itReturnsDefaultChunkName() {
|
|
27
|
+
test('returns the default chunk name', async () => {
|
|
28
|
+
expect(await subject()).toBe('assets/[name]-[hash].js');
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
itReturnsDefaultChunkName();
|
|
33
|
+
|
|
34
|
+
describe('when code contains webpackChunkName comment', () => {
|
|
35
|
+
const webpackChunkName = 'dashboard';
|
|
36
|
+
|
|
37
|
+
beforeEach(
|
|
38
|
+
() =>
|
|
39
|
+
(code = code.replace(
|
|
40
|
+
'import(',
|
|
41
|
+
`import(/* webpackChunkName: '${webpackChunkName}' */`
|
|
42
|
+
))
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
test('renames the chunk', async () => {
|
|
46
|
+
expect(await subject()).toBe(`assets/${webpackChunkName}-[hash].js`);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
describe('when the import cannot be resolved', () => {
|
|
50
|
+
beforeEach(() => resolve.mockReturnValue(null));
|
|
51
|
+
|
|
52
|
+
itReturnsDefaultChunkName();
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
describe('when a chunk name is reused for different modules', () => {
|
|
57
|
+
beforeEach(() => {
|
|
58
|
+
code = [
|
|
59
|
+
"import(/* webpackChunkName: 'shared' */ './a')",
|
|
60
|
+
"import(/* webpackChunkName: 'shared' */ './b')",
|
|
61
|
+
].join(';');
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
test('warns that the modules will not be merged', async () => {
|
|
65
|
+
await subject();
|
|
66
|
+
|
|
67
|
+
expect(warn).toHaveBeenCalledWith(expect.stringMatching(/used by multiple modules/));
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
describe('when the same module is imported twice with one name', () => {
|
|
72
|
+
beforeEach(() => {
|
|
73
|
+
code = [
|
|
74
|
+
`import(/* webpackChunkName: 'dashboard' */ './a')`,
|
|
75
|
+
`import(/* webpackChunkName: 'dashboard' */ './a')`,
|
|
76
|
+
].join(';');
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
test('does not warn', async () => {
|
|
80
|
+
await subject();
|
|
81
|
+
|
|
82
|
+
expect(warn).not.toHaveBeenCalled();
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
describe('transform filter', () => {
|
|
87
|
+
const subject = () =>
|
|
88
|
+
(magicCommentsPlugin(context) as { transform: { filter: unknown } }).transform.filter;
|
|
89
|
+
|
|
90
|
+
test('excludes node_modules and requires the magic comment', () => {
|
|
91
|
+
expect(subject()).toEqual({
|
|
92
|
+
id: { exclude: /node_modules/ },
|
|
93
|
+
code: 'webpackChunkName',
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
describe('when not a production build', () => {
|
|
99
|
+
beforeEach(() => (context.build.isProduction = false));
|
|
100
|
+
|
|
101
|
+
test('is undefined', () => {
|
|
102
|
+
expect(magicCommentsPlugin(context)).toBeUndefined();
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
});
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { parseMagicComments } from '../parse-magic-comments';
|
|
2
|
+
|
|
3
|
+
describe(`[startup] ${parseMagicComments.name}`, () => {
|
|
4
|
+
const cases = [
|
|
5
|
+
// single-quoted comment and import path
|
|
6
|
+
{
|
|
7
|
+
code: "import(/* webpackChunkName: 'feature' */ './module');",
|
|
8
|
+
result: [{ chunkName: 'feature', importPath: './module' }],
|
|
9
|
+
},
|
|
10
|
+
// double-quoted comment and import path
|
|
11
|
+
{
|
|
12
|
+
code: 'import(/* webpackChunkName: "feature" */ "./module");',
|
|
13
|
+
result: [{ chunkName: 'feature', importPath: './module' }],
|
|
14
|
+
},
|
|
15
|
+
// multiple dynamic imports; the unannotated one is dropped
|
|
16
|
+
{
|
|
17
|
+
code: [
|
|
18
|
+
"import(/* webpackChunkName: 'featureA' */ './moduleA')",
|
|
19
|
+
"import(/* webpackChunkName: 'featureB' */ './moduleB')",
|
|
20
|
+
"import('./moduleC')",
|
|
21
|
+
].join(';'),
|
|
22
|
+
result: [
|
|
23
|
+
{ chunkName: 'featureA', importPath: './moduleA' },
|
|
24
|
+
{ chunkName: 'featureB', importPath: './moduleB' },
|
|
25
|
+
],
|
|
26
|
+
},
|
|
27
|
+
// dynamic import without a magic comment
|
|
28
|
+
{ code: "import('./module');", result: [] },
|
|
29
|
+
// non-string (computed) import path
|
|
30
|
+
{ code: "import(/* webpackChunkName: 'feature' */ modulePath);", result: [] },
|
|
31
|
+
// static import
|
|
32
|
+
{ code: "import /* webpackChunkName: 'feature' */ './module';", result: [] },
|
|
33
|
+
];
|
|
34
|
+
|
|
35
|
+
cases.forEach(({ code, result }) => {
|
|
36
|
+
test(`with ${code} returns ${JSON.stringify(result)}`, async () => {
|
|
37
|
+
await expect(parseMagicComments(code)).resolves.toEqual(result);
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './magic-comments-plugin';
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { Plugin } from 'vite';
|
|
2
|
+
import { ViteBuildContext } from '../../types';
|
|
3
|
+
import { parseMagicComments } from './parse-magic-comments';
|
|
4
|
+
|
|
5
|
+
/* Mirrors Vite's default chunk file naming. A magic comment only substitutes the [name] token. */
|
|
6
|
+
const CHUNK_FILE_NAME = 'assets/[name]-[hash].js';
|
|
7
|
+
|
|
8
|
+
/*
|
|
9
|
+
* Honors `webpackChunkName` magic comments on dynamic imports. Vite splits dynamic
|
|
10
|
+
* imports into separate chunks, named after the source file; this renames the chunk
|
|
11
|
+
* to specified `webpackChunkName`. Warns when a name is reused by different modules.
|
|
12
|
+
*/
|
|
13
|
+
export function magicCommentsPlugin(context: ViteBuildContext): Plugin | undefined {
|
|
14
|
+
if (!context.build.isProduction) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const chunkNames = new Map<string, string>();
|
|
19
|
+
const moduleByName = new Map<string, string>();
|
|
20
|
+
|
|
21
|
+
return {
|
|
22
|
+
name: 'magic-comments',
|
|
23
|
+
apply: 'build',
|
|
24
|
+
enforce: 'pre',
|
|
25
|
+
config: () => ({
|
|
26
|
+
build: {
|
|
27
|
+
rolldownOptions: {
|
|
28
|
+
output: {
|
|
29
|
+
chunkFileNames: (chunk: { facadeModuleId?: string | null }) => {
|
|
30
|
+
const name =
|
|
31
|
+
chunk.facadeModuleId && chunkNames.get(chunk.facadeModuleId);
|
|
32
|
+
return name ? CHUNK_FILE_NAME.replace('[name]', name) : CHUNK_FILE_NAME;
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
}),
|
|
38
|
+
transform: {
|
|
39
|
+
filter: { id: { exclude: /node_modules/ }, code: 'webpackChunkName' },
|
|
40
|
+
async handler(code, id) {
|
|
41
|
+
const comments = await parseMagicComments(code);
|
|
42
|
+
const resolved = await Promise.all(
|
|
43
|
+
comments.map(({ importPath }) => this.resolve(importPath, id))
|
|
44
|
+
);
|
|
45
|
+
comments.forEach(({ chunkName }, index) => {
|
|
46
|
+
const module = resolved[index];
|
|
47
|
+
if (!module) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
const claimedBy = moduleByName.get(chunkName);
|
|
51
|
+
if (claimedBy && claimedBy !== module.id) {
|
|
52
|
+
this.warn(
|
|
53
|
+
`webpackChunkName "${chunkName}" is used by multiple modules; Vite emits a separate chunk for each rather than merging them.`
|
|
54
|
+
);
|
|
55
|
+
} else {
|
|
56
|
+
moduleByName.set(chunkName, module.id);
|
|
57
|
+
}
|
|
58
|
+
chunkNames.set(module.id, chunkName);
|
|
59
|
+
});
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { init, parse } from 'es-module-lexer';
|
|
2
|
+
|
|
3
|
+
export interface MagicComment {
|
|
4
|
+
chunkName: string;
|
|
5
|
+
importPath: string;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
const CHUNK_NAME_REGEXP = /webpackChunkName:\s*["']([^"']+)["']/;
|
|
9
|
+
|
|
10
|
+
/*
|
|
11
|
+
* Extracts the chunk name from `webpackChunkName` magic comments on dynamic imports,
|
|
12
|
+
* such as `import( <comment> './foo')` with a `webpackChunkName: "x"` comment. Only
|
|
13
|
+
* target imports with a static string path.
|
|
14
|
+
*/
|
|
15
|
+
export async function parseMagicComments(code: string): Promise<MagicComment[]> {
|
|
16
|
+
await init;
|
|
17
|
+
const [imports] = parse(code);
|
|
18
|
+
|
|
19
|
+
const result: MagicComment[] = [];
|
|
20
|
+
for (const imp of imports) {
|
|
21
|
+
/*
|
|
22
|
+
* es-module-lexer positions on `import( <comment> './foo')`:
|
|
23
|
+
* (d: openParenIndex): the `(`, or -1 when the import is static
|
|
24
|
+
* (s: importPathStart): the opening quote of './foo'
|
|
25
|
+
* (n: importPath): ./foo, or undefined when not a string literal
|
|
26
|
+
*/
|
|
27
|
+
const { d: openParenIndex, n: importPath, s: importPathStart } = imp;
|
|
28
|
+
if (openParenIndex < 0 || importPath === undefined) {
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
// commentRegion (between the `(` and the path) holds the magic comment
|
|
32
|
+
const commentRegion = code.slice(openParenIndex + 1, importPathStart);
|
|
33
|
+
const match = CHUNK_NAME_REGEXP.exec(commentRegion);
|
|
34
|
+
if (match) {
|
|
35
|
+
result.push({ chunkName: match[1], importPath });
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return result;
|
|
39
|
+
}
|
|
@@ -2,7 +2,7 @@ import fs from 'fs';
|
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import type { Plugin } from 'vite';
|
|
4
4
|
import { BuildContext, generateMetadata } from '../../core';
|
|
5
|
-
import { getCssFileNames } from './utils
|
|
5
|
+
import { getCssFileNames } from './utils';
|
|
6
6
|
|
|
7
7
|
export function metadataPlugin(context: BuildContext): Plugin | undefined {
|
|
8
8
|
if (!context.package.isWebComponent) {
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { Plugin } from 'vite';
|
|
2
|
+
import { BuildContext, MOMENT_LOCALES } from '../../core';
|
|
3
|
+
|
|
4
|
+
export const VIRTUAL_MOMENT = '\0VIRTUAL_MOMENT';
|
|
5
|
+
|
|
6
|
+
const UMD_LOCALE = /^moment\/locale\/(.+)$/;
|
|
7
|
+
|
|
8
|
+
/*
|
|
9
|
+
* Statically bundle the supported moment locales for parity with webpack's
|
|
10
|
+
* MomentLocalesPlugin. We need this because moment loads locales via a dynamic
|
|
11
|
+
* require that, with Rolldown, never loads.
|
|
12
|
+
*
|
|
13
|
+
* Resolve everything through moment/dist (the ESM build) else Rolldown creates
|
|
14
|
+
* a separate UMD instance from what the app uses.
|
|
15
|
+
*/
|
|
16
|
+
export function momentLocalesPlugin(_context: BuildContext): Plugin {
|
|
17
|
+
return {
|
|
18
|
+
name: 'moment-locales',
|
|
19
|
+
enforce: 'pre',
|
|
20
|
+
resolveId(source, importer, options) {
|
|
21
|
+
if (source === 'moment') {
|
|
22
|
+
return VIRTUAL_MOMENT;
|
|
23
|
+
}
|
|
24
|
+
// Redirect explicit UMD locale imports to the ESM build so they share that instance.
|
|
25
|
+
const locale = UMD_LOCALE.exec(source)?.[1];
|
|
26
|
+
if (locale) {
|
|
27
|
+
return this.resolve(`moment/dist/locale/${locale}`, importer, options);
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
load(id) {
|
|
31
|
+
if (id === VIRTUAL_MOMENT) {
|
|
32
|
+
return [
|
|
33
|
+
...MOMENT_LOCALES.map(locale => `import 'moment/dist/locale/${locale}';`),
|
|
34
|
+
`import moment from 'moment/dist/moment.js';`,
|
|
35
|
+
`export * from 'moment/dist/moment.js';`,
|
|
36
|
+
`export default moment;`,
|
|
37
|
+
].join('\n');
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { assembleIife, Expose, ModuleFactory } from '../assemble-iife';
|
|
2
|
+
|
|
3
|
+
describe(assembleIife.name, () => {
|
|
4
|
+
let modules: ModuleFactory[];
|
|
5
|
+
let exposes: Expose[];
|
|
6
|
+
|
|
7
|
+
beforeEach(() => {
|
|
8
|
+
modules = [{ id: 'react', code: 'react code' }];
|
|
9
|
+
exposes = [{ variable: 'globalReact', dependency: 'react' }];
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
const subject = () => assembleIife(modules, exposes);
|
|
13
|
+
|
|
14
|
+
test('keys each module factory by id', () => {
|
|
15
|
+
expect(subject()).toContain(`'react': function(module, exports, require) {`);
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
test('includes the module code', () => {
|
|
19
|
+
expect(subject()).toContain('react code');
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
test('emits an expose call for each dependency', () => {
|
|
23
|
+
expect(subject()).toContain(`expose('globalReact', 'react');`);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
test('wraps output in the shared storage IIFE', () => {
|
|
27
|
+
expect(subject()).toContain(`Symbol.for('SERVICETITAN_EXPOSE_LOADER_STORAGE')`);
|
|
28
|
+
});
|
|
29
|
+
});
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { assertNoDynamicCss } from '../assert-no-dynamic-css';
|
|
2
|
+
|
|
3
|
+
describe(assertNoDynamicCss.name, () => {
|
|
4
|
+
const withCss = (...css: string[]) => ({ viteMetadata: { importedCss: new Set(css) } });
|
|
5
|
+
|
|
6
|
+
let bundle: Record<string, any>;
|
|
7
|
+
|
|
8
|
+
beforeEach(() => {
|
|
9
|
+
bundle = {
|
|
10
|
+
'react.cjs.js': {
|
|
11
|
+
type: 'chunk',
|
|
12
|
+
isEntry: true,
|
|
13
|
+
name: 'react',
|
|
14
|
+
imports: [],
|
|
15
|
+
dynamicImports: [],
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
const subject = () => assertNoDynamicCss(bundle);
|
|
21
|
+
|
|
22
|
+
function itDoesNotThrow() {
|
|
23
|
+
test('does not throw', () => {
|
|
24
|
+
expect(() => subject()).not.toThrow();
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
itDoesNotThrow();
|
|
29
|
+
|
|
30
|
+
describe('when all entry chunks include the CSS they reach', () => {
|
|
31
|
+
beforeEach(() => {
|
|
32
|
+
bundle = {
|
|
33
|
+
'react.cjs.js': {
|
|
34
|
+
type: 'chunk',
|
|
35
|
+
isEntry: true,
|
|
36
|
+
name: 'react',
|
|
37
|
+
imports: [],
|
|
38
|
+
dynamicImports: [],
|
|
39
|
+
...withCss('react.bundle.css'),
|
|
40
|
+
},
|
|
41
|
+
'react.bundle.css': { type: 'asset' },
|
|
42
|
+
};
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
itDoesNotThrow();
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
describe('when an entry chunk reaches excluded CSS', () => {
|
|
49
|
+
beforeEach(() => {
|
|
50
|
+
bundle = {
|
|
51
|
+
'react.cjs.js': {
|
|
52
|
+
type: 'chunk',
|
|
53
|
+
isEntry: true,
|
|
54
|
+
name: 'react',
|
|
55
|
+
imports: [],
|
|
56
|
+
dynamicImports: ['_lazy.js'],
|
|
57
|
+
...withCss('react.bundle.css'),
|
|
58
|
+
},
|
|
59
|
+
'react.bundle.css': { type: 'asset' },
|
|
60
|
+
'_lazy.js': {
|
|
61
|
+
type: 'chunk',
|
|
62
|
+
isEntry: false,
|
|
63
|
+
imports: [],
|
|
64
|
+
dynamicImports: [],
|
|
65
|
+
...withCss('lazy.bundle.css'),
|
|
66
|
+
},
|
|
67
|
+
'lazy.bundle.css': { type: 'asset' },
|
|
68
|
+
};
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
test('throws naming the offending chunk and its excluded CSS', () => {
|
|
72
|
+
expect(() => subject()).toThrow(
|
|
73
|
+
'Shared dependency chunk "react" pulls in CSS through a dynamic import ' +
|
|
74
|
+
'(lazy.bundle.css). Shared dependencies only include statically imported ' +
|
|
75
|
+
'CSS. Dynamically imported CSS will not load on the host.'
|
|
76
|
+
);
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
describe('when an entry chunk reaches excluded CSS through nested imports', () => {
|
|
81
|
+
beforeEach(() => {
|
|
82
|
+
bundle = {
|
|
83
|
+
'react.cjs.js': {
|
|
84
|
+
type: 'chunk',
|
|
85
|
+
isEntry: true,
|
|
86
|
+
name: 'react',
|
|
87
|
+
imports: ['_inner.js'],
|
|
88
|
+
dynamicImports: [],
|
|
89
|
+
...withCss(),
|
|
90
|
+
},
|
|
91
|
+
'_inner.js': {
|
|
92
|
+
type: 'chunk',
|
|
93
|
+
isEntry: false,
|
|
94
|
+
imports: [],
|
|
95
|
+
dynamicImports: ['_lazy.js'],
|
|
96
|
+
...withCss(),
|
|
97
|
+
},
|
|
98
|
+
'_lazy.js': {
|
|
99
|
+
type: 'chunk',
|
|
100
|
+
isEntry: false,
|
|
101
|
+
imports: [],
|
|
102
|
+
dynamicImports: [],
|
|
103
|
+
...withCss('lazy.bundle.css'),
|
|
104
|
+
},
|
|
105
|
+
'lazy.bundle.css': { type: 'asset' },
|
|
106
|
+
};
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
test('traces the offending chunk through the import graph', () => {
|
|
110
|
+
expect(() => subject()).toThrow(/react/);
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { flatten } from '../flatten';
|
|
2
|
+
|
|
3
|
+
describe(flatten.name, () => {
|
|
4
|
+
let name: string;
|
|
5
|
+
|
|
6
|
+
beforeEach(() => {
|
|
7
|
+
name = '@scope/lib/foo';
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
const subject = () => flatten(name);
|
|
11
|
+
|
|
12
|
+
test('replaces the slash with a dash', () => {
|
|
13
|
+
expect(subject()).toBe(name.replace(/\//g, '-'));
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
describe('when the name has no slash', () => {
|
|
17
|
+
beforeEach(() => (name = 'react'));
|
|
18
|
+
|
|
19
|
+
test('returns the name unchanged', () => {
|
|
20
|
+
expect(subject()).toBe(name);
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
});
|