@servicetitan/startup 36.4.0 → 37.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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/commands/test/runners/vitest.d.ts.map +1 -1
- package/dist/cli/commands/test/runners/vitest.js +7 -1
- package/dist/cli/commands/test/runners/vitest.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 +5 -3
- 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/jest/resolver.d.ts.map +1 -1
- package/dist/jest/resolver.js +20 -1
- package/dist/jest/resolver.js.map +1 -1
- 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 +21 -3
- 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/filter-warnings-plugin.d.ts +1 -1
- package/dist/webpack/configs/plugins/filter-warnings-plugin.d.ts.map +1 -1
- package/dist/webpack/configs/plugins/filter-warnings-plugin.js +1 -4
- package/dist/webpack/configs/plugins/filter-warnings-plugin.js.map +1 -1
- 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/commands/test/runners/__tests__/vitest.test.ts +8 -1
- package/src/cli/commands/test/runners/vitest.ts +5 -3
- 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 +17 -16
- 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/jest/__tests__/resolver.test.ts +42 -1
- package/src/jest/resolver.ts +17 -1
- 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 +36 -7
- 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 +81 -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/filter-warnings-plugin.ts +1 -5
- 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
|
@@ -1,21 +1,25 @@
|
|
|
1
|
-
import { Config } from '@jest/types';
|
|
2
|
-
import { swcDir } from '@swc/cli';
|
|
3
|
-
import { ESLint } from 'eslint';
|
|
1
|
+
import type { Config } from '@jest/types';
|
|
2
|
+
import type { swcDir } from '@swc/cli';
|
|
3
|
+
import type { ESLint } from 'eslint';
|
|
4
4
|
import fs from 'fs';
|
|
5
5
|
import path from 'path';
|
|
6
|
-
import { LinterOptions } from 'stylelint';
|
|
7
|
-
import svgr from 'vite-plugin-svgr';
|
|
8
|
-
import { ViteUserConfig } from 'vitest/config';
|
|
9
|
-
import { Configuration as WebpackDevServerConfiguration } from 'webpack-dev-server';
|
|
10
|
-
import { ReviewConfiguration } from '../cli/commands/review';
|
|
6
|
+
import type { LinterOptions } from 'stylelint';
|
|
7
|
+
import type svgr from 'vite-plugin-svgr';
|
|
8
|
+
import type { ViteUserConfig } from 'vitest/config';
|
|
9
|
+
import type { Configuration as WebpackDevServerConfiguration } from 'webpack-dev-server';
|
|
10
|
+
import type { ReviewConfiguration } from '../cli/commands/review';
|
|
11
11
|
import { getFolders } from './get-folders';
|
|
12
|
+
import { getPackageName } from './get-package-name';
|
|
12
13
|
import { log } from './log';
|
|
13
14
|
import { readJson, readJsonSafe } from './read-json';
|
|
15
|
+
import { LocationOrJson } from './types';
|
|
14
16
|
|
|
15
17
|
type VitePluginSvgrOptions = NonNullable<Parameters<typeof svgr>[0]>;
|
|
16
18
|
|
|
17
19
|
type ElementType<T> = T extends readonly (infer ElementType)[] ? ElementType : never;
|
|
18
20
|
|
|
21
|
+
export type Bundler = 'vite' | 'webpack';
|
|
22
|
+
|
|
19
23
|
export const allowedWebpackDevServerOptions = ['headers', 'port', 'proxy', 'static'] as const;
|
|
20
24
|
|
|
21
25
|
export interface MinifyJSOptions {
|
|
@@ -65,7 +69,6 @@ export interface NodeConfiguration {
|
|
|
65
69
|
/* eslint-disable @typescript-eslint/naming-convention */
|
|
66
70
|
export enum CommandName {
|
|
67
71
|
'build' = 'build',
|
|
68
|
-
'bundle-package' = 'bundle-package',
|
|
69
72
|
'bundle-vite' = 'bundle-vite',
|
|
70
73
|
'bundle-webpack' = 'bundle-webpack',
|
|
71
74
|
'clean' = 'clean',
|
|
@@ -124,6 +127,7 @@ export interface ViteBundlerConfig {
|
|
|
124
127
|
|
|
125
128
|
export interface VitePackageJsonOverride extends ViteBundlerConfig {
|
|
126
129
|
config?: Omit<import('vite').UserConfig, 'plugins'>;
|
|
130
|
+
devServer?: false;
|
|
127
131
|
}
|
|
128
132
|
|
|
129
133
|
export interface WebComponentBranchConfigs {
|
|
@@ -141,6 +145,7 @@ interface WebComponentOptions {
|
|
|
141
145
|
}
|
|
142
146
|
|
|
143
147
|
type Configuration = {
|
|
148
|
+
'bundler'?: Bundler;
|
|
144
149
|
'jest'?: JestConfiguration;
|
|
145
150
|
'legacy'?: boolean;
|
|
146
151
|
'lint'?: { eslint: ESLintConfiguration; stylelint: StylelintConfiguration };
|
|
@@ -148,6 +153,7 @@ type Configuration = {
|
|
|
148
153
|
'swc-compile-package'?: Parameters<typeof swcDir>[0];
|
|
149
154
|
'test'?: JestConfiguration; // for backward-compatibility
|
|
150
155
|
'testRunner'?: string;
|
|
156
|
+
'expose-process-env'?: string[];
|
|
151
157
|
'expose-shared-dependencies'?: boolean;
|
|
152
158
|
'shared-dependencies'?: Record<string, string>;
|
|
153
159
|
'vite'?: false | VitePackageJsonOverride;
|
|
@@ -158,8 +164,6 @@ type Configuration = {
|
|
|
158
164
|
[key in CommandName]?: NodeConfiguration;
|
|
159
165
|
} & NodeConfiguration;
|
|
160
166
|
|
|
161
|
-
type LocationOrJson = string | Record<string, any>;
|
|
162
|
-
|
|
163
167
|
export function getConfiguration(locationOrJson: LocationOrJson = './'): Configuration {
|
|
164
168
|
const json =
|
|
165
169
|
typeof locationOrJson === 'string'
|
|
@@ -193,6 +197,10 @@ export function getStylelintConfiguration() {
|
|
|
193
197
|
return getConfiguration().lint?.stylelint ?? {};
|
|
194
198
|
}
|
|
195
199
|
|
|
200
|
+
export function getExposeProcessEnv(): string[] {
|
|
201
|
+
return getConfiguration()['expose-process-env'] ?? [];
|
|
202
|
+
}
|
|
203
|
+
|
|
196
204
|
export function getViteConfiguration(): VitePackageJsonOverride {
|
|
197
205
|
const { vite } = getConfiguration();
|
|
198
206
|
return typeof vite === 'object' ? vite : {};
|
|
@@ -255,10 +263,9 @@ export function getSwcCompilePackageConfiguration() {
|
|
|
255
263
|
}
|
|
256
264
|
|
|
257
265
|
export function isBundle(locationOrJson?: LocationOrJson) {
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
);
|
|
266
|
+
const { webpack, vite } = getConfiguration(locationOrJson);
|
|
267
|
+
assertBundlersAgree(webpack, vite, locationOrJson);
|
|
268
|
+
return webpack !== false && vite !== false;
|
|
262
269
|
}
|
|
263
270
|
|
|
264
271
|
export function isDevServerDisabled() {
|
|
@@ -266,6 +273,10 @@ export function isDevServerDisabled() {
|
|
|
266
273
|
return webpackConfiguration.devServer === false;
|
|
267
274
|
}
|
|
268
275
|
|
|
276
|
+
export function isViteDevServerDisabled() {
|
|
277
|
+
return getViteConfiguration().devServer === false;
|
|
278
|
+
}
|
|
279
|
+
|
|
269
280
|
export function isExposeSharedDependencies() {
|
|
270
281
|
return (
|
|
271
282
|
(getConfiguration()['expose-shared-dependencies'] ??
|
|
@@ -288,3 +299,27 @@ export function isStyleCheckDisabled() {
|
|
|
288
299
|
export function isWebComponent(locationOrJson: LocationOrJson = './') {
|
|
289
300
|
return !!getWebComponentConfiguration(locationOrJson);
|
|
290
301
|
}
|
|
302
|
+
|
|
303
|
+
/*
|
|
304
|
+
* Require that Vite and Webpack configurations agree whether package is a bundle.
|
|
305
|
+
*/
|
|
306
|
+
function assertBundlersAgree(
|
|
307
|
+
webpack: Configuration['webpack'],
|
|
308
|
+
vite: Configuration['vite'],
|
|
309
|
+
locationOrJson?: LocationOrJson
|
|
310
|
+
) {
|
|
311
|
+
if (webpack === undefined || vite === undefined || !!webpack === !!vite) {
|
|
312
|
+
return;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
const mismatch =
|
|
316
|
+
webpack === false
|
|
317
|
+
? { falsy: 'cli.webpack', truthy: 'cli.vite' }
|
|
318
|
+
: { falsy: 'cli.vite', truthy: 'cli.webpack' };
|
|
319
|
+
|
|
320
|
+
throw new Error(
|
|
321
|
+
`package ${getPackageName(locationOrJson)} has conflicting webpack ` +
|
|
322
|
+
`and vite configurations: ${mismatch.falsy} is false but ` +
|
|
323
|
+
`${mismatch.truthy} is not`
|
|
324
|
+
);
|
|
325
|
+
}
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import path from 'path';
|
|
2
2
|
import { readJson } from './read-json';
|
|
3
|
+
import { LocationOrJson } from './types';
|
|
3
4
|
|
|
4
|
-
export function getPackageName(
|
|
5
|
-
|
|
5
|
+
export function getPackageName(locationOrJson: LocationOrJson = './'): string {
|
|
6
|
+
const json =
|
|
7
|
+
typeof locationOrJson === 'string'
|
|
8
|
+
? readJson(path.join(locationOrJson, 'package.json'))
|
|
9
|
+
: locationOrJson;
|
|
10
|
+
|
|
11
|
+
return json?.name ?? '';
|
|
6
12
|
}
|
package/src/utils/index.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type LocationOrJson = string | Record<string, any>;
|
|
@@ -1,7 +1,21 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
getConfiguration,
|
|
3
|
+
getWebpackConfiguration,
|
|
4
|
+
isExposeSharedDependencies,
|
|
5
|
+
isWebComponent,
|
|
6
|
+
} from './get-configuration';
|
|
7
|
+
import { getPackageName } from './get-package-name';
|
|
2
8
|
|
|
3
9
|
export function validateSharedDependencies() {
|
|
4
10
|
const config = getConfiguration();
|
|
11
|
+
|
|
12
|
+
if (isWebComponent() && isExposeSharedDependencies()) {
|
|
13
|
+
throw new Error(
|
|
14
|
+
'cli.expose-shared-dependencies only applies to host applications.' +
|
|
15
|
+
`Remove it from ${getPackageName()}.`
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
|
|
5
19
|
const webpackSharedDependencies = getWebpackConfiguration()['shared-dependencies'];
|
|
6
20
|
const topLevelSharedDependencies = config['shared-dependencies'];
|
|
7
21
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { build } from 'vite';
|
|
1
|
+
import { build, type InlineConfig } from 'vite';
|
|
2
2
|
import type { BuildContext } from '../../core';
|
|
3
|
-
import { bundleConstants, createBuildContext,
|
|
3
|
+
import { bundleConstants, createBuildContext, resolveOutputPath } from '../../core';
|
|
4
4
|
import { buildSharedDependencies } from '../build-shared-dependencies';
|
|
5
5
|
import { createViteConfig } from '../config';
|
|
6
6
|
import { sharedDependenciesPlugin } from '../plugins/shared-dependencies-plugin';
|
|
@@ -9,11 +9,11 @@ jest.mock('vite', () => ({
|
|
|
9
9
|
build: jest.fn(),
|
|
10
10
|
}));
|
|
11
11
|
jest.mock('../../core', () => ({
|
|
12
|
+
...jest.requireActual('../../core'),
|
|
12
13
|
bundleConstants: {
|
|
13
14
|
mode: { production: 'production', development: 'development' },
|
|
14
15
|
},
|
|
15
16
|
createBuildContext: jest.fn(),
|
|
16
|
-
getOutputPath: jest.fn(),
|
|
17
17
|
}));
|
|
18
18
|
jest.mock('../config', () => ({
|
|
19
19
|
createViteConfig: jest.fn(),
|
|
@@ -23,6 +23,7 @@ jest.mock('../plugins/shared-dependencies-plugin', () => ({
|
|
|
23
23
|
}));
|
|
24
24
|
|
|
25
25
|
describe(buildSharedDependencies.name, () => {
|
|
26
|
+
const viteConfig: any = {};
|
|
26
27
|
let options: any;
|
|
27
28
|
let context: BuildContext;
|
|
28
29
|
|
|
@@ -33,12 +34,11 @@ describe(buildSharedDependencies.name, () => {
|
|
|
33
34
|
build: { isProduction: false },
|
|
34
35
|
package: {
|
|
35
36
|
sharedDependencies: { react: 'globalReact' },
|
|
36
|
-
destination: '
|
|
37
|
+
destination: 'dist',
|
|
37
38
|
},
|
|
38
39
|
} as any;
|
|
39
|
-
jest.mocked(createViteConfig).mockResolvedValue(
|
|
40
|
+
jest.mocked(createViteConfig).mockResolvedValue(viteConfig);
|
|
40
41
|
jest.mocked(createBuildContext).mockReturnValue(context);
|
|
41
|
-
jest.mocked(getOutputPath).mockReturnValue('/output/pkg/bundle');
|
|
42
42
|
});
|
|
43
43
|
|
|
44
44
|
const subject = () => buildSharedDependencies(options);
|
|
@@ -48,7 +48,6 @@ describe(buildSharedDependencies.name, () => {
|
|
|
48
48
|
|
|
49
49
|
expect(createBuildContext).toHaveBeenCalledWith({
|
|
50
50
|
...options,
|
|
51
|
-
outputBasePath: undefined,
|
|
52
51
|
emitExposedDependencies: true,
|
|
53
52
|
});
|
|
54
53
|
});
|
|
@@ -77,7 +76,9 @@ describe(buildSharedDependencies.name, () => {
|
|
|
77
76
|
|
|
78
77
|
expect(build).toHaveBeenCalledWith(
|
|
79
78
|
expect.objectContaining({
|
|
80
|
-
build: expect.objectContaining({
|
|
79
|
+
build: expect.objectContaining({
|
|
80
|
+
outDir: resolveOutputPath(context, viteConfig.build?.outDir),
|
|
81
|
+
}),
|
|
81
82
|
})
|
|
82
83
|
);
|
|
83
84
|
});
|
|
@@ -97,7 +98,7 @@ describe(buildSharedDependencies.name, () => {
|
|
|
97
98
|
});
|
|
98
99
|
|
|
99
100
|
describe('when user config sets oxc options', () => {
|
|
100
|
-
const oxc = {
|
|
101
|
+
const oxc: InlineConfig['oxc'] = {
|
|
101
102
|
minify: { compress: true },
|
|
102
103
|
target: 'es2020',
|
|
103
104
|
legalComments: 'inline',
|
|
@@ -137,24 +138,10 @@ describe(buildSharedDependencies.name, () => {
|
|
|
137
138
|
});
|
|
138
139
|
|
|
139
140
|
describe('when user config has custom outDir', () => {
|
|
140
|
-
const
|
|
141
|
-
const customOutputPath = '/custom/out/bundle';
|
|
141
|
+
const outDir = '/foo';
|
|
142
142
|
|
|
143
143
|
beforeEach(() => {
|
|
144
|
-
jest.mocked(createViteConfig).mockResolvedValue({
|
|
145
|
-
build: { outDir: customOutDir },
|
|
146
|
-
});
|
|
147
|
-
jest.mocked(getOutputPath).mockReturnValue(customOutputPath);
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
test('passes custom output path to build context', async () => {
|
|
151
|
-
await subject();
|
|
152
|
-
|
|
153
|
-
expect(createBuildContext).toHaveBeenCalledWith({
|
|
154
|
-
...options,
|
|
155
|
-
outputBasePath: customOutDir,
|
|
156
|
-
emitExposedDependencies: true,
|
|
157
|
-
});
|
|
144
|
+
jest.mocked(createViteConfig).mockResolvedValue({ build: { outDir } });
|
|
158
145
|
});
|
|
159
146
|
|
|
160
147
|
test('builds with custom output directory', async () => {
|
|
@@ -162,7 +149,7 @@ describe(buildSharedDependencies.name, () => {
|
|
|
162
149
|
|
|
163
150
|
expect(build).toHaveBeenCalledWith(
|
|
164
151
|
expect.objectContaining({
|
|
165
|
-
build: expect.objectContaining({ outDir
|
|
152
|
+
build: expect.objectContaining({ outDir }),
|
|
166
153
|
})
|
|
167
154
|
);
|
|
168
155
|
});
|
|
@@ -1,34 +1,45 @@
|
|
|
1
1
|
import { fs, vol } from 'memfs';
|
|
2
|
+
import { validateSharedDependencies } from '../../utils/validate-shared-dependencies';
|
|
2
3
|
import { validateViteSharedDependencies } from '../validate-shared-dependencies';
|
|
3
4
|
|
|
4
5
|
jest.mock('fs', () => fs);
|
|
6
|
+
jest.mock('../../utils/validate-shared-dependencies');
|
|
5
7
|
|
|
6
|
-
describe(
|
|
7
|
-
|
|
8
|
-
vol.fromJSON({ 'package.json': JSON.stringify(content) });
|
|
9
|
-
}
|
|
8
|
+
describe(`[startup] ${validateViteSharedDependencies.name}`, () => {
|
|
9
|
+
let cli: Record<string, any>;
|
|
10
10
|
|
|
11
|
+
beforeEach(() => {
|
|
12
|
+
jest.clearAllMocks();
|
|
13
|
+
cli = {};
|
|
14
|
+
});
|
|
11
15
|
afterEach(() => vol.reset());
|
|
12
16
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
+
const subject = () => {
|
|
18
|
+
vol.fromJSON({ 'package.json': JSON.stringify({ cli }) });
|
|
19
|
+
return validateViteSharedDependencies();
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
function itThrows(message: RegExp) {
|
|
23
|
+
test('throws', () => {
|
|
24
|
+
expect(subject).toThrow(message);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
test('delegates to validateSharedDependencies', () => {
|
|
29
|
+
subject();
|
|
17
30
|
|
|
18
|
-
|
|
19
|
-
mockPackageJson({ cli: { 'expose-shared-dependencies': true } });
|
|
20
|
-
expect(() => validateViteSharedDependencies()).not.toThrow();
|
|
31
|
+
expect(validateSharedDependencies).toHaveBeenCalled();
|
|
21
32
|
});
|
|
22
33
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
34
|
+
describe('with cli.webpack.shared-dependencies', () => {
|
|
35
|
+
beforeEach(() => (cli.webpack = { 'shared-dependencies': { defaults: '' } }));
|
|
36
|
+
|
|
37
|
+
itThrows(/Move your shared-dependencies/);
|
|
26
38
|
});
|
|
27
39
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
);
|
|
40
|
+
describe('with cli.webpack.expose-shared-dependencies', () => {
|
|
41
|
+
beforeEach(() => (cli.webpack = { 'expose-shared-dependencies': true }));
|
|
42
|
+
|
|
43
|
+
itThrows(/Move your expose-shared-dependencies/);
|
|
33
44
|
});
|
|
34
45
|
});
|
|
@@ -4,18 +4,14 @@ import {
|
|
|
4
4
|
BuildContextOptions,
|
|
5
5
|
bundleConstants,
|
|
6
6
|
createBuildContext,
|
|
7
|
-
|
|
7
|
+
resolveOutputPath,
|
|
8
8
|
} from '../core';
|
|
9
9
|
import { createViteConfig } from './config';
|
|
10
10
|
import { sharedDependenciesPlugin } from './plugins/shared-dependencies-plugin';
|
|
11
11
|
|
|
12
12
|
export async function buildSharedDependencies(options: BuildContextOptions) {
|
|
13
13
|
const config = await createViteConfig(options);
|
|
14
|
-
const context = createBuildContext({
|
|
15
|
-
...options,
|
|
16
|
-
outputBasePath: config.build?.outDir,
|
|
17
|
-
emitExposedDependencies: true,
|
|
18
|
-
});
|
|
14
|
+
const context = createBuildContext({ ...options, emitExposedDependencies: true });
|
|
19
15
|
|
|
20
16
|
await build({
|
|
21
17
|
configFile: false,
|
|
@@ -26,7 +22,7 @@ export async function buildSharedDependencies(options: BuildContextOptions) {
|
|
|
26
22
|
mode: getMode(context),
|
|
27
23
|
plugins: [getSharedDependenciesPlugin(context)],
|
|
28
24
|
build: {
|
|
29
|
-
outDir:
|
|
25
|
+
outDir: resolveOutputPath(context, config.build?.outDir),
|
|
30
26
|
minify: config.build?.minify,
|
|
31
27
|
cssMinify: config.build?.cssMinify,
|
|
32
28
|
terserOptions: config.build?.terserOptions,
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { assetFileNames } from '../asset-file-names';
|
|
2
|
+
|
|
3
|
+
describe(assetFileNames.name, () => {
|
|
4
|
+
let asset: Parameters<typeof assetFileNames>[0];
|
|
5
|
+
|
|
6
|
+
beforeEach(() => (asset = { names: [] }));
|
|
7
|
+
|
|
8
|
+
const subject = () => assetFileNames(asset);
|
|
9
|
+
|
|
10
|
+
test('returns assets/[name]-[hash][extname]', () => {
|
|
11
|
+
expect(subject()).toBe('assets/[name]-[hash][extname]');
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
[
|
|
15
|
+
{
|
|
16
|
+
name: 'fonts/[name]-[hash][extname]',
|
|
17
|
+
extensions: ['woff', 'woff2', 'eot', 'ttf', 'otf'],
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
name: 'images/[name]-[hash][extname]',
|
|
21
|
+
extensions: ['png', 'jpg', 'jpeg', 'gif', 'svg'],
|
|
22
|
+
},
|
|
23
|
+
].forEach(({ extensions, name }) => {
|
|
24
|
+
describe.each(extensions)('with .%s', extension => {
|
|
25
|
+
beforeEach(() => (asset = { names: [`foo.${extension}`] }));
|
|
26
|
+
|
|
27
|
+
test(`returns ${name}`, () => {
|
|
28
|
+
expect(subject()).toBe(name);
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
describe('when asset has multiple names', () => {
|
|
34
|
+
beforeEach(() => (asset = { names: [`foo.png`, 'bar.ttf'] }));
|
|
35
|
+
|
|
36
|
+
test('uses first name', () => {
|
|
37
|
+
expect(subject()).toEqual('images/[name]-[hash][extname]');
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
});
|
|
@@ -4,22 +4,31 @@ import {
|
|
|
4
4
|
defineExposedInstanceDependencies,
|
|
5
5
|
defineWebComponentName,
|
|
6
6
|
getBundleType,
|
|
7
|
-
getOutputPath,
|
|
8
7
|
} from '../../../core';
|
|
9
8
|
import { omit } from '../../../utils';
|
|
10
9
|
import {
|
|
10
|
+
bundleStatPlugin,
|
|
11
|
+
chainSourceMapsPlugin,
|
|
12
|
+
cleanPlugin,
|
|
11
13
|
cssInjectorPlugin,
|
|
14
|
+
designSystemGuardPlugin,
|
|
12
15
|
devServerRoutingPlugin,
|
|
13
16
|
externalsPlugin,
|
|
14
17
|
htmlPlugin,
|
|
15
18
|
ignoreModulesPlugin,
|
|
19
|
+
istanbulPlugin,
|
|
20
|
+
magicCommentsPlugin,
|
|
16
21
|
metadataPlugin,
|
|
22
|
+
momentLocalesPlugin,
|
|
17
23
|
styleUrlsPlugin,
|
|
18
24
|
svgrPlugin,
|
|
19
25
|
virtualModulesPlugin,
|
|
20
26
|
} from '../../plugins';
|
|
21
27
|
import type { ViteBuildContext } from '../../types';
|
|
28
|
+
import { assetFileNames } from '../asset-file-names';
|
|
22
29
|
import { createBaseConfig } from '../base-config';
|
|
30
|
+
import { getCodeSplitting } from '../code-splitting';
|
|
31
|
+
import { createFilteringLogger } from '../create-filtering-logger';
|
|
23
32
|
|
|
24
33
|
jest.mock('../../../core', () => ({
|
|
25
34
|
...jest.requireActual('../../../core'),
|
|
@@ -35,7 +44,6 @@ jest.mock('../../../core', () => ({
|
|
|
35
44
|
mode: { production: 'production', development: 'development' },
|
|
36
45
|
},
|
|
37
46
|
getBundleType: jest.fn(),
|
|
38
|
-
getOutputPath: jest.fn(),
|
|
39
47
|
defineExposedDependencies: jest.fn(),
|
|
40
48
|
defineExposedInstanceDependencies: jest.fn(),
|
|
41
49
|
defineWebComponentName: jest.fn(),
|
|
@@ -45,25 +53,41 @@ jest.mock('../../../utils', () => ({
|
|
|
45
53
|
omit: jest.fn((obj: any) => obj),
|
|
46
54
|
}));
|
|
47
55
|
|
|
56
|
+
jest.mock('../create-filtering-logger', () => ({
|
|
57
|
+
createFilteringLogger: jest.fn(() => ({ name: 'filteringLogger' })),
|
|
58
|
+
}));
|
|
59
|
+
|
|
60
|
+
jest.mock('../code-splitting', () => ({
|
|
61
|
+
getCodeSplitting: jest.fn(),
|
|
62
|
+
}));
|
|
63
|
+
|
|
48
64
|
jest.mock('../../plugins', () => ({
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
virtualModulesPlugin: jest.fn(() => ({ name: 'virtualModules' })),
|
|
65
|
+
bundleStatPlugin: jest.fn(() => ({ name: 'bundleStat' })),
|
|
66
|
+
chainSourceMapsPlugin: jest.fn(() => ({ name: 'chainSourceMaps' })),
|
|
67
|
+
cleanPlugin: jest.fn(() => ({ name: 'clean' })),
|
|
53
68
|
cssInjectorPlugin: jest.fn(() => [{ name: 'cssInjector' }]),
|
|
54
|
-
|
|
55
|
-
metadataPlugin: jest.fn(() => ({ name: 'metadata' })),
|
|
69
|
+
designSystemGuardPlugin: jest.fn(() => ({ name: 'designSystemGuard' })),
|
|
56
70
|
devServerRoutingPlugin: jest.fn(() => ({ name: 'devServerRouting' })),
|
|
71
|
+
externalsPlugin: jest.fn(() => ({ name: 'externals' })),
|
|
72
|
+
htmlPlugin: jest.fn(() => ({ name: 'html' })),
|
|
57
73
|
ignoreModulesPlugin: jest.fn((context: any) => ({ name: 'ignoreModules', context })),
|
|
74
|
+
istanbulPlugin: jest.fn(() => ({ name: 'istanbul' })),
|
|
75
|
+
magicCommentsPlugin: jest.fn(() => ({ name: 'magicComments' })),
|
|
76
|
+
metadataPlugin: jest.fn(() => ({ name: 'metadata' })),
|
|
77
|
+
momentLocalesPlugin: jest.fn(() => ({ name: 'momentLocales' })),
|
|
78
|
+
styleUrlsPlugin: jest.fn(() => ({ name: 'styleUrls' })),
|
|
79
|
+
svgrPlugin: jest.fn(() => ({ name: 'svgr' })),
|
|
80
|
+
virtualModulesPlugin: jest.fn(() => ({ name: 'virtualModules' })),
|
|
58
81
|
}));
|
|
59
82
|
|
|
60
83
|
describe(createBaseConfig.name, () => {
|
|
84
|
+
const codeSplitting = { groups: [{ name: 'vendor', test: /node_modules/ }] };
|
|
61
85
|
let context: ViteBuildContext;
|
|
62
86
|
|
|
63
87
|
beforeEach(() => {
|
|
64
88
|
jest.clearAllMocks();
|
|
89
|
+
jest.mocked(getCodeSplitting).mockReturnValue(codeSplitting);
|
|
65
90
|
jest.mocked(getBundleType).mockReturnValue('full');
|
|
66
|
-
jest.mocked(getOutputPath).mockReturnValue('/output/dist');
|
|
67
91
|
jest.mocked(defineExposedDependencies).mockReturnValue({
|
|
68
92
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
69
93
|
EXPOSED_DEPENDENCIES: '"deps"',
|
|
@@ -95,12 +119,6 @@ describe(createBaseConfig.name, () => {
|
|
|
95
119
|
expect(subject().server!.port).toBe(8080);
|
|
96
120
|
});
|
|
97
121
|
|
|
98
|
-
test('pre-warms client files from destination', () => {
|
|
99
|
-
expect(subject().server!.warmup!.clientFiles).toEqual([
|
|
100
|
-
`${context.package.destination}/**/*.js`,
|
|
101
|
-
]);
|
|
102
|
-
});
|
|
103
|
-
|
|
104
122
|
test('sets development mode', () => {
|
|
105
123
|
expect(subject().mode).toBe(bundleConstants.mode.development);
|
|
106
124
|
});
|
|
@@ -109,6 +127,12 @@ describe(createBaseConfig.name, () => {
|
|
|
109
127
|
expect(subject().configFile).toBe(false);
|
|
110
128
|
});
|
|
111
129
|
|
|
130
|
+
test('filters noisy warnings through a custom logger', () => {
|
|
131
|
+
expect(subject().customLogger).toBe(
|
|
132
|
+
jest.mocked(createFilteringLogger).mock.results[0].value
|
|
133
|
+
);
|
|
134
|
+
});
|
|
135
|
+
|
|
112
136
|
test('strips legal comments', () => {
|
|
113
137
|
expect(subject().oxc).toEqual({ legalComments: 'none' });
|
|
114
138
|
});
|
|
@@ -139,16 +163,26 @@ describe(createBaseConfig.name, () => {
|
|
|
139
163
|
expect(subject().build!.cssCodeSplit).toBe(true);
|
|
140
164
|
});
|
|
141
165
|
|
|
142
|
-
test('
|
|
143
|
-
expect(subject().build!.
|
|
166
|
+
test('enables source maps', () => {
|
|
167
|
+
expect(subject().build!.sourcemap).toBe(true);
|
|
144
168
|
});
|
|
145
169
|
|
|
146
|
-
test('
|
|
147
|
-
expect(subject().build!.
|
|
170
|
+
test('routes assets through assetFileNames', () => {
|
|
171
|
+
expect(subject().build!.rolldownOptions!.output).toEqual(
|
|
172
|
+
expect.objectContaining({ assetFileNames })
|
|
173
|
+
);
|
|
148
174
|
});
|
|
149
175
|
|
|
150
|
-
test('
|
|
151
|
-
expect(subject().build!.
|
|
176
|
+
test('registers chainSourceMaps plugin', () => {
|
|
177
|
+
expect(subject().build!.rolldownOptions!.plugins).toEqual([chainSourceMapsPlugin()]);
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
test('configures code splitting from getCodeSplitting', () => {
|
|
181
|
+
expect(subject().build!.rolldownOptions!.output).toEqual(
|
|
182
|
+
expect.objectContaining({
|
|
183
|
+
codeSplitting: getCodeSplitting(context),
|
|
184
|
+
})
|
|
185
|
+
);
|
|
152
186
|
});
|
|
153
187
|
|
|
154
188
|
test('maps define values to import.meta.env prefix', () => {
|
|
@@ -161,6 +195,30 @@ describe(createBaseConfig.name, () => {
|
|
|
161
195
|
}
|
|
162
196
|
});
|
|
163
197
|
|
|
198
|
+
describe('when exposeProcessEnv lists a variable', () => {
|
|
199
|
+
const variable = 'API_URL';
|
|
200
|
+
const value = 'https://api.example.com';
|
|
201
|
+
|
|
202
|
+
beforeEach(() => {
|
|
203
|
+
context.package.exposeProcessEnv = [variable];
|
|
204
|
+
process.env[variable] = value;
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
afterEach(() => delete process.env[variable]);
|
|
208
|
+
|
|
209
|
+
test('defines process.env.NAME with the value', () => {
|
|
210
|
+
expect(subject().define![`process.env.${variable}`]).toBe(JSON.stringify(value));
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
describe('when variable is not set', () => {
|
|
214
|
+
beforeEach(() => delete process.env[variable]);
|
|
215
|
+
|
|
216
|
+
test('defines process.env.NAME as undefined', () => {
|
|
217
|
+
expect(subject().define![`process.env.${variable}`]).toBe('undefined');
|
|
218
|
+
});
|
|
219
|
+
});
|
|
220
|
+
});
|
|
221
|
+
|
|
164
222
|
test('includes startup-utils in optimized dependencies', () => {
|
|
165
223
|
expect(subject().optimizeDeps!.include).toEqual(['@servicetitan/startup-utils']);
|
|
166
224
|
});
|
|
@@ -173,15 +231,21 @@ describe(createBaseConfig.name, () => {
|
|
|
173
231
|
|
|
174
232
|
test('creates plugins from factories, passing context', () => {
|
|
175
233
|
const factories = [
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
externalsPlugin,
|
|
179
|
-
virtualModulesPlugin,
|
|
234
|
+
bundleStatPlugin,
|
|
235
|
+
cleanPlugin,
|
|
180
236
|
cssInjectorPlugin,
|
|
181
|
-
|
|
182
|
-
metadataPlugin,
|
|
237
|
+
designSystemGuardPlugin,
|
|
183
238
|
devServerRoutingPlugin,
|
|
239
|
+
externalsPlugin,
|
|
240
|
+
htmlPlugin,
|
|
184
241
|
ignoreModulesPlugin,
|
|
242
|
+
istanbulPlugin,
|
|
243
|
+
magicCommentsPlugin,
|
|
244
|
+
metadataPlugin,
|
|
245
|
+
momentLocalesPlugin,
|
|
246
|
+
styleUrlsPlugin,
|
|
247
|
+
svgrPlugin,
|
|
248
|
+
virtualModulesPlugin,
|
|
185
249
|
];
|
|
186
250
|
|
|
187
251
|
const pluginNames = (subject().plugins as any[]).map((p: any) => p.name);
|
|
@@ -218,10 +282,6 @@ describe(createBaseConfig.name, () => {
|
|
|
218
282
|
test('disables CSS code splitting', () => {
|
|
219
283
|
expect(subject().build!.cssCodeSplit).toBe(false);
|
|
220
284
|
});
|
|
221
|
-
|
|
222
|
-
test('empties output directory', () => {
|
|
223
|
-
expect(subject().build!.emptyOutDir).toBe(true);
|
|
224
|
-
});
|
|
225
285
|
});
|
|
226
286
|
|
|
227
287
|
describe('when production', () => {
|
|
@@ -306,4 +366,12 @@ describe(createBaseConfig.name, () => {
|
|
|
306
366
|
expect(subject().build!.cssMinify).toBe(!!context.bundlerConfig.minify.css);
|
|
307
367
|
});
|
|
308
368
|
});
|
|
369
|
+
|
|
370
|
+
describe('when code coverage is enabled', () => {
|
|
371
|
+
beforeEach(() => (context.options.codeCoverage = true));
|
|
372
|
+
|
|
373
|
+
test('disables minify', () => {
|
|
374
|
+
expect(subject().build!.minify).toBe(false);
|
|
375
|
+
});
|
|
376
|
+
});
|
|
309
377
|
});
|