@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
|
@@ -2,9 +2,11 @@ import { BuildContext } from '../../types';
|
|
|
2
2
|
import { checkResource } from '../check-resource';
|
|
3
3
|
import { getPeerDependencyMeta } from '../get-peer-dependency-meta';
|
|
4
4
|
import { isManagedReactDomClientDependency } from '../is-managed-react-dom-client-dependency';
|
|
5
|
+
import { isResolvable } from '../is-resolvable';
|
|
5
6
|
|
|
6
7
|
jest.mock('../is-managed-react-dom-client-dependency');
|
|
7
8
|
jest.mock('../get-peer-dependency-meta');
|
|
9
|
+
jest.mock('../is-resolvable');
|
|
8
10
|
|
|
9
11
|
describe(`${checkResource.name}`, () => {
|
|
10
12
|
const importer = 'node_modules/web-components/dist';
|
|
@@ -22,7 +24,7 @@ describe(`${checkResource.name}`, () => {
|
|
|
22
24
|
|
|
23
25
|
const subject = () => checkResource(context)({ resource, importer });
|
|
24
26
|
|
|
25
|
-
function itReturns(value:
|
|
27
|
+
function itReturns(value: 'throw' | 'empty' | false) {
|
|
26
28
|
test(`returns ${JSON.stringify(value)}`, () => expect(subject()).toBe(value));
|
|
27
29
|
}
|
|
28
30
|
|
|
@@ -31,7 +33,19 @@ describe(`${checkResource.name}`, () => {
|
|
|
31
33
|
describe('when resource is optional peer dependency', () => {
|
|
32
34
|
beforeEach(() => (peerDependenciesMeta = { optional: true }));
|
|
33
35
|
|
|
34
|
-
itReturns(
|
|
36
|
+
itReturns('throw');
|
|
37
|
+
|
|
38
|
+
describe('when peer fallback is "empty"', () => {
|
|
39
|
+
beforeEach(() => (peerDependenciesMeta!.fallback = 'empty'));
|
|
40
|
+
|
|
41
|
+
itReturns('empty');
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
describe('when resource is resolvable', () => {
|
|
45
|
+
beforeEach(() => jest.mocked(isResolvable).mockReturnValue(true));
|
|
46
|
+
|
|
47
|
+
itReturns(false);
|
|
48
|
+
});
|
|
35
49
|
|
|
36
50
|
describe('when resource is package dependency', () => {
|
|
37
51
|
beforeEach(() => (context.package.dependencies[resource] = '*'));
|
|
@@ -43,16 +57,16 @@ describe(`${checkResource.name}`, () => {
|
|
|
43
57
|
describe('when resource is managed react-dom client dependency', () => {
|
|
44
58
|
beforeEach(() => jest.mocked(isManagedReactDomClientDependency).mockReturnValue(true));
|
|
45
59
|
|
|
46
|
-
describe('when resource is
|
|
47
|
-
beforeEach(() => (
|
|
60
|
+
describe('when resource is resolvable', () => {
|
|
61
|
+
beforeEach(() => jest.mocked(isResolvable).mockReturnValue(true));
|
|
48
62
|
|
|
49
63
|
itReturns(false);
|
|
50
64
|
});
|
|
51
65
|
|
|
52
|
-
describe('when resource is not
|
|
53
|
-
beforeEach(() => (
|
|
66
|
+
describe('when resource is not resolvable', () => {
|
|
67
|
+
beforeEach(() => jest.mocked(isResolvable).mockReturnValue(false));
|
|
54
68
|
|
|
55
|
-
itReturns(
|
|
69
|
+
itReturns('empty');
|
|
56
70
|
});
|
|
57
71
|
});
|
|
58
72
|
});
|
|
@@ -4,17 +4,16 @@ import { getPeerDependencyMeta } from '../get-peer-dependency-meta';
|
|
|
4
4
|
jest.mock('../get-package-json');
|
|
5
5
|
|
|
6
6
|
describe(`[startup] ${getPeerDependencyMeta.name}`, () => {
|
|
7
|
-
const meta = { optional: true };
|
|
8
7
|
let importer: string;
|
|
9
8
|
let resource: string;
|
|
9
|
+
let packageJson: ReturnType<typeof getPackageJson>;
|
|
10
10
|
|
|
11
11
|
beforeEach(() => {
|
|
12
12
|
jest.clearAllMocks();
|
|
13
13
|
importer = 'node_modules/pkg/dist';
|
|
14
14
|
resource = '@scope/a';
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}));
|
|
15
|
+
packageJson = undefined;
|
|
16
|
+
jest.mocked(getPackageJson).mockImplementation(() => packageJson);
|
|
18
17
|
});
|
|
19
18
|
|
|
20
19
|
const subject = () => getPeerDependencyMeta({ resource, importer });
|
|
@@ -25,9 +24,7 @@ describe(`[startup] ${getPeerDependencyMeta.name}`, () => {
|
|
|
25
24
|
});
|
|
26
25
|
}
|
|
27
26
|
|
|
28
|
-
|
|
29
|
-
expect(subject()).toEqual(meta);
|
|
30
|
-
});
|
|
27
|
+
itReturnsUndefined();
|
|
31
28
|
|
|
32
29
|
describe('when resource is not a package name', () => {
|
|
33
30
|
beforeEach(() => (resource = './local'));
|
|
@@ -35,17 +32,77 @@ describe(`[startup] ${getPeerDependencyMeta.name}`, () => {
|
|
|
35
32
|
itReturnsUndefined();
|
|
36
33
|
});
|
|
37
34
|
|
|
38
|
-
describe('when
|
|
35
|
+
describe('when package.json has no entry for resource', () => {
|
|
36
|
+
beforeEach(() => (packageJson = {}));
|
|
37
|
+
|
|
38
|
+
itReturnsUndefined();
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
describe('when peerDependenciesMeta includes resource', () => {
|
|
39
42
|
beforeEach(() => {
|
|
40
|
-
|
|
43
|
+
packageJson = { peerDependenciesMeta: { [resource]: { optional: true } } };
|
|
41
44
|
});
|
|
42
45
|
|
|
43
|
-
|
|
46
|
+
test('returns entry', () => {
|
|
47
|
+
expect(subject()).toEqual(packageJson!.peerDependenciesMeta[resource]);
|
|
48
|
+
});
|
|
44
49
|
});
|
|
45
50
|
|
|
46
|
-
describe('when
|
|
47
|
-
beforeEach(() =>
|
|
51
|
+
describe('when cli.peerDependenciesMeta includes resource', () => {
|
|
52
|
+
beforeEach(() => {
|
|
53
|
+
packageJson = {
|
|
54
|
+
peerDependenciesMeta: { [resource]: { optional: true } },
|
|
55
|
+
cli: { peerDependenciesMeta: { [resource]: { fallback: 'empty' } } },
|
|
56
|
+
};
|
|
57
|
+
});
|
|
48
58
|
|
|
49
|
-
|
|
59
|
+
function itThrowsError(matcher: RegExp) {
|
|
60
|
+
test('throws', () => {
|
|
61
|
+
expect(subject).toThrow(matcher);
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
test('returns merged entry', () => {
|
|
66
|
+
expect(subject()).toEqual({
|
|
67
|
+
...packageJson!.peerDependenciesMeta[resource],
|
|
68
|
+
...packageJson!.cli.peerDependenciesMeta[resource],
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
describe('when peerDependenciesMeta.optional is missing', () => {
|
|
73
|
+
beforeEach(() => delete packageJson!.peerDependenciesMeta);
|
|
74
|
+
|
|
75
|
+
itThrowsError(/requires peerDependenciesMeta.*optional/);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
describe('when entry is not an object', () => {
|
|
79
|
+
beforeEach(() => (packageJson!.cli.peerDependenciesMeta[resource] = ''));
|
|
80
|
+
|
|
81
|
+
itThrowsError(/must be an object/);
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
describe('when the malformed entry is for a different resource', () => {
|
|
85
|
+
beforeEach(() => {
|
|
86
|
+
packageJson!.cli.peerDependenciesMeta.foo = '';
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
itThrowsError(/must be an object/);
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
describe('when entry has an unexpected key', () => {
|
|
93
|
+
beforeEach(() => {
|
|
94
|
+
packageJson!.cli.peerDependenciesMeta[resource].optional = true;
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
itThrowsError(/unexpected key\(s\) \[optional\]/);
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
describe('when entry has invalid fallback', () => {
|
|
101
|
+
beforeEach(() => {
|
|
102
|
+
packageJson!.cli.peerDependenciesMeta[resource].fallback = 'foo';
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
itThrowsError(/must be one of \[throw, empty\]/);
|
|
106
|
+
});
|
|
50
107
|
});
|
|
51
108
|
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { isResolvable } from '../is-resolvable';
|
|
2
|
+
|
|
3
|
+
describe('isResolvable', () => {
|
|
4
|
+
const importer = __filename;
|
|
5
|
+
let resource: string;
|
|
6
|
+
|
|
7
|
+
const subject = () => isResolvable({ resource, importer });
|
|
8
|
+
|
|
9
|
+
describe('when the resource resolves', () => {
|
|
10
|
+
beforeEach(() => (resource = 'lodash.memoize'));
|
|
11
|
+
|
|
12
|
+
test('returns true', () => expect(subject()).toBe(true));
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
describe('when the resource does not resolve', () => {
|
|
16
|
+
beforeEach(() => (resource = '@servicetitan/does-not-exist'));
|
|
17
|
+
|
|
18
|
+
test('returns false', () => expect(subject()).toBe(false));
|
|
19
|
+
});
|
|
20
|
+
});
|
|
@@ -1,29 +1,30 @@
|
|
|
1
1
|
import { log } from '../../utils';
|
|
2
|
-
import {
|
|
2
|
+
import type { PackageContext } from '../types';
|
|
3
3
|
import { getPeerDependencyMeta } from './get-peer-dependency-meta';
|
|
4
4
|
import { isManagedReactDomClientDependency } from './is-managed-react-dom-client-dependency';
|
|
5
|
-
import
|
|
5
|
+
import { isResolvable } from './is-resolvable';
|
|
6
|
+
import type { CheckerArgs, IgnoreMode } from './types';
|
|
6
7
|
|
|
7
|
-
export function checkResource(context:
|
|
8
|
-
return function ({ resource, importer }: CheckerArgs):
|
|
9
|
-
if (
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
export function checkResource(context: { package: Pick<PackageContext, 'dependencies'> }) {
|
|
9
|
+
return function ({ resource, importer }: CheckerArgs): IgnoreMode | false {
|
|
10
|
+
if (!context.package.dependencies[resource]) {
|
|
11
|
+
const meta = getPeerDependencyMeta({ resource, importer });
|
|
12
|
+
if (meta?.optional && !isResolvable({ resource, importer })) {
|
|
13
|
+
const mode = meta.fallback ?? 'throw';
|
|
14
|
+
log.debug('check-resource', `${JSON.stringify({ resource, importer })} => ${mode}`);
|
|
15
|
+
return mode;
|
|
16
|
+
}
|
|
15
17
|
}
|
|
16
18
|
|
|
17
19
|
/**
|
|
18
20
|
* react-dom/client isn't an explicit dependency, so the peerDependenciesMeta
|
|
19
21
|
* path above can't catch it.
|
|
20
22
|
*/
|
|
21
|
-
if (
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
23
|
+
if (
|
|
24
|
+
isManagedReactDomClientDependency({ resource, importer }) &&
|
|
25
|
+
!isResolvable({ resource, importer })
|
|
26
|
+
) {
|
|
27
|
+
return 'empty';
|
|
27
28
|
}
|
|
28
29
|
return false;
|
|
29
30
|
};
|
|
@@ -1,15 +1,78 @@
|
|
|
1
|
+
import memoize from 'lodash.memoize';
|
|
1
2
|
import { getPackageJson } from './get-package-json';
|
|
2
|
-
import type { CheckerArgs } from './types';
|
|
3
|
+
import type { CheckerArgs, IgnoreMode } from './types';
|
|
3
4
|
|
|
4
5
|
interface PeerDependencyMeta {
|
|
5
6
|
optional?: boolean;
|
|
7
|
+
fallback?: IgnoreMode;
|
|
6
8
|
}
|
|
7
9
|
|
|
10
|
+
const ALLOWED_KEYS: readonly string[] = ['fallback'];
|
|
11
|
+
const ALLOWED_FALLBACKS: readonly IgnoreMode[] = ['throw', 'empty'];
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Merged view of npm's `peerDependenciesMeta[resource]` (which carries
|
|
15
|
+
* `optional`) and our extension `cli.peerDependenciesMeta[resource]`. Returns
|
|
16
|
+
* undefined when no entry is declared for the resource.
|
|
17
|
+
*
|
|
18
|
+
* Validates the `cli.peerDependenciesMeta` map so a malformed entry (for
|
|
19
|
+
* example, `optional: true` written there by mistake, thinking it's npm's
|
|
20
|
+
* field) fails loudly.
|
|
21
|
+
*/
|
|
8
22
|
export function getPeerDependencyMeta({
|
|
9
23
|
resource,
|
|
10
24
|
importer,
|
|
11
25
|
}: CheckerArgs): PeerDependencyMeta | undefined {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
26
|
+
if (!/^[@a-z]/.test(resource)) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const pkg = getPackageJson(importer);
|
|
31
|
+
if (!pkg) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const cliMap = pkg.cli?.peerDependenciesMeta;
|
|
36
|
+
if (cliMap && typeof cliMap === 'object') {
|
|
37
|
+
validate(cliMap);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const npmEntry = pkg.peerDependenciesMeta?.[resource];
|
|
41
|
+
const cliEntry = cliMap?.[resource];
|
|
42
|
+
if (!npmEntry && !cliEntry) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
if (cliEntry?.fallback && !npmEntry?.optional) {
|
|
46
|
+
throw new Error(
|
|
47
|
+
`cli.peerDependenciesMeta["${resource}"].fallback requires peerDependenciesMeta["${resource}"].optional = true`
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
return { ...npmEntry, ...cliEntry };
|
|
15
51
|
}
|
|
52
|
+
|
|
53
|
+
/*
|
|
54
|
+
* cli.peerDependenciesMeta mirrors npm's peerDependenciesMeta shape. If a
|
|
55
|
+
* developer mistakenly puts npm fields (for example, `optional: true`) there
|
|
56
|
+
* thinking it's npm's config, this check causes it to fail loudly.
|
|
57
|
+
*
|
|
58
|
+
* Memoized by reference so each importer's map is validated once per build.
|
|
59
|
+
*/
|
|
60
|
+
const validate = memoize(function validate(meta: Record<string, unknown>) {
|
|
61
|
+
for (const [resource, entry] of Object.entries(meta)) {
|
|
62
|
+
if (entry === null || typeof entry !== 'object') {
|
|
63
|
+
throw new Error(`cli.peerDependenciesMeta["${resource}"] must be an object`);
|
|
64
|
+
}
|
|
65
|
+
const unknown = Object.keys(entry).filter(k => !ALLOWED_KEYS.includes(k));
|
|
66
|
+
if (unknown.length) {
|
|
67
|
+
throw new Error(
|
|
68
|
+
`cli.peerDependenciesMeta["${resource}"] has unexpected key(s) [${unknown.join(', ')}]; allowed: [${ALLOWED_KEYS.join(', ')}]`
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
const { fallback } = entry as { fallback?: unknown };
|
|
72
|
+
if (fallback !== undefined && !ALLOWED_FALLBACKS.includes(fallback as IgnoreMode)) {
|
|
73
|
+
throw new Error(
|
|
74
|
+
`cli.peerDependenciesMeta["${resource}"].fallback must be one of [${ALLOWED_FALLBACKS.join(', ')}], got ${JSON.stringify(fallback)}`
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { checkResource } from './check-resource';
|
|
2
|
-
export type { CheckerArgs } from './types';
|
|
2
|
+
export type { CheckerArgs, IgnoreMode } from './types';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import memoize from 'lodash.memoize';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import type { CheckerArgs } from './types';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Whether a module resolves from the importer's location. Memoized so each unique
|
|
7
|
+
* (package, importer directory) pair is resolved once.
|
|
8
|
+
*/
|
|
9
|
+
export const isResolvable = memoize(
|
|
10
|
+
function isResolvable({ resource, importer }: CheckerArgs): boolean {
|
|
11
|
+
try {
|
|
12
|
+
require.resolve(resource, { paths: [path.dirname(importer)] });
|
|
13
|
+
return true;
|
|
14
|
+
} catch {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
({ resource, importer }) => `${resource}\0${path.dirname(importer)}`
|
|
19
|
+
);
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Canonical module-path patterns for each code-splitting chunk, shared by the Vite
|
|
3
|
+
* and webpack configs. Using [\\/]? at the start matches both Vite module IDs (which
|
|
4
|
+
* begin with "node_modules/...") and webpack module paths (which begin with an
|
|
5
|
+
* absolute path separator before "node_modules/...").
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const VENDOR_CORE_PACKAGES = [
|
|
9
|
+
'axios',
|
|
10
|
+
'classnames',
|
|
11
|
+
'formstate',
|
|
12
|
+
'inversify',
|
|
13
|
+
'mobx',
|
|
14
|
+
'mobx-react',
|
|
15
|
+
'mobx-utils',
|
|
16
|
+
'react',
|
|
17
|
+
'react-dom',
|
|
18
|
+
'react-router',
|
|
19
|
+
'react-router-dom',
|
|
20
|
+
'reflect-metadata',
|
|
21
|
+
];
|
|
22
|
+
|
|
23
|
+
export const CHUNK_PATTERNS = {
|
|
24
|
+
'servicetitan': /[\\/]?node_modules[\\/]@servicetitan[\\/]/,
|
|
25
|
+
'kendo': /[\\/]?node_modules[\\/](@progress|@telerik)[\\/]/,
|
|
26
|
+
'vendor-core': new RegExp(
|
|
27
|
+
`[\\\\/]?node_modules[\\\\/](${VENDOR_CORE_PACKAGES.join('|')})[\\\\/]`
|
|
28
|
+
),
|
|
29
|
+
'vendor': /[\\/]?node_modules[\\/]/,
|
|
30
|
+
};
|
|
@@ -2,6 +2,7 @@ import { getPackageManager } from '@servicetitan/install';
|
|
|
2
2
|
import yargs, { Arguments } from 'yargs';
|
|
3
3
|
import { hideBin } from 'yargs/helpers';
|
|
4
4
|
import {
|
|
5
|
+
getExposeProcessEnv,
|
|
5
6
|
getFolders,
|
|
6
7
|
getPackageData,
|
|
7
8
|
isExposeSharedDependencies,
|
|
@@ -18,7 +19,6 @@ export interface BuildContextOptions {
|
|
|
18
19
|
light?: boolean;
|
|
19
20
|
headless?: boolean;
|
|
20
21
|
emitExposedDependencies?: BuildIdentity['emitExposedDependencies'];
|
|
21
|
-
outputBasePath?: string;
|
|
22
22
|
codeCoverage?: boolean;
|
|
23
23
|
buildStat?: boolean;
|
|
24
24
|
}
|
|
@@ -43,6 +43,7 @@ export function createBuildContext(options: BuildContextOptions): BuildContext {
|
|
|
43
43
|
isWebComponent: isWebComponent(),
|
|
44
44
|
isLegacyRoot: isLegacyRoot(),
|
|
45
45
|
isExposeSharedDependencies: isExposeSharedDependencies(),
|
|
46
|
+
exposeProcessEnv: getExposeProcessEnv(),
|
|
46
47
|
packageManager: getPackageManager(),
|
|
47
48
|
},
|
|
48
49
|
build: {
|
|
@@ -51,7 +52,6 @@ export function createBuildContext(options: BuildContextOptions): BuildContext {
|
|
|
51
52
|
light: options.light,
|
|
52
53
|
headless: options.headless,
|
|
53
54
|
emitExposedDependencies: options.emitExposedDependencies,
|
|
54
|
-
outputBasePath: options.outputBasePath,
|
|
55
55
|
},
|
|
56
56
|
options: {
|
|
57
57
|
codeCoverage: options.codeCoverage ?? !!args['code-coverage'],
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export const FONT_EXTENSIONS = ['woff', 'woff2', 'eot', 'ttf', 'otf'];
|
|
2
|
+
export const IMAGE_EXTENSIONS = ['png', 'jpg', 'jpeg', 'gif'];
|
|
3
|
+
export const SVG_EXTENSIONS = ['svg'];
|
|
4
|
+
|
|
5
|
+
export function createExtensionRegExp(extensions: string[]): RegExp {
|
|
6
|
+
return new RegExp(`\\.(${extensions.join('|')})$`, 'i');
|
|
7
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { BuildContext } from './types';
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* Maps each configured variable name to a `process.env.NAME` key holding its JSON-encoded
|
|
5
|
+
* build-time value. An unset variable maps to `undefined`. Returns undefined when none are
|
|
6
|
+
* configured.
|
|
7
|
+
*/
|
|
8
|
+
export function getProcessEnv(context: BuildContext): Record<string, string> | undefined {
|
|
9
|
+
const names = context.package.exposeProcessEnv;
|
|
10
|
+
if (!names?.length) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return Object.fromEntries(
|
|
15
|
+
names.map(name => [`process.env.${name}`, JSON.stringify(process.env[name]) ?? 'undefined'])
|
|
16
|
+
);
|
|
17
|
+
}
|
package/src/core/index.ts
CHANGED
|
@@ -1,16 +1,23 @@
|
|
|
1
|
+
export * from './bundle-report';
|
|
1
2
|
export * from './check-resource';
|
|
3
|
+
export * from './chunk-patterns';
|
|
2
4
|
export * from './constants';
|
|
3
5
|
export * from './create-build-context';
|
|
6
|
+
export * from './create-extension-regexp';
|
|
4
7
|
export * from './defines';
|
|
5
8
|
export * from './externals';
|
|
6
9
|
export * from './get-build-name';
|
|
7
10
|
export * from './get-bundle-type';
|
|
8
11
|
export * from './get-cdn-path';
|
|
9
12
|
export * from './get-exposed-dependencies';
|
|
10
|
-
export * from './get-
|
|
13
|
+
export * from './get-process-env';
|
|
11
14
|
export * from './get-shared-entry-points';
|
|
12
15
|
export * from './get-version';
|
|
13
16
|
export * from './metadata';
|
|
17
|
+
export * from './moment-locales';
|
|
18
|
+
export * from './resolve-output-path';
|
|
19
|
+
export * from './resolve-output-root';
|
|
20
|
+
export * from './sort-shared-css';
|
|
14
21
|
export * from './stringify-config';
|
|
15
22
|
export type * from './types';
|
|
16
23
|
export * from './virtual-modules';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The moment locales the build supports. Under webpack, MomentLocalesPlugin narrows moment's
|
|
3
|
+
* built-in locales down to this set; under Vite, Rolldown bundles no locales, so the Vite plugin
|
|
4
|
+
* statically imports these to add them back. Shared so both bundlers agree on the set.
|
|
5
|
+
*/
|
|
6
|
+
export const MOMENT_LOCALES = ['en-au', 'en-ca', 'en-gb'];
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import { getBundleType } from './get-bundle-type';
|
|
3
|
+
import { resolveOutputRoot } from './resolve-output-root';
|
|
4
|
+
import { BuildContext } from './types';
|
|
5
|
+
|
|
6
|
+
export function resolveOutputPath(context: BuildContext, outputPath: string | undefined): string {
|
|
7
|
+
const root = resolveOutputRoot(context, outputPath);
|
|
8
|
+
const subdir = getBundleType(context);
|
|
9
|
+
return subdir ? path.join(root, subdir) : root;
|
|
10
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import { BuildContext } from './types';
|
|
3
|
+
|
|
4
|
+
export function resolveOutputRoot(context: BuildContext, outputPath: string | undefined): string {
|
|
5
|
+
const { destination, isWebComponent } = context.package;
|
|
6
|
+
const defaultOutputPath = path.join(process.cwd(), destination, 'bundle');
|
|
7
|
+
return isWebComponent ? defaultOutputPath : (outputPath ?? defaultOutputPath);
|
|
8
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export function sortSharedCss(cssFiles: string[]): string[] {
|
|
2
|
+
// Put design-system CSS first to give anvil2 CSS higher precedence
|
|
3
|
+
const offset = cssFiles.findIndex(name => name.startsWith('design-system'));
|
|
4
|
+
return offset > 0
|
|
5
|
+
? [cssFiles[offset], ...cssFiles.filter((_, index) => index !== offset)]
|
|
6
|
+
: cssFiles;
|
|
7
|
+
}
|
package/src/core/types.ts
CHANGED
|
@@ -16,6 +16,7 @@ export interface PackageContext {
|
|
|
16
16
|
isWebComponent: boolean;
|
|
17
17
|
isLegacyRoot: boolean;
|
|
18
18
|
isExposeSharedDependencies: boolean;
|
|
19
|
+
exposeProcessEnv?: string[];
|
|
19
20
|
packageManager: ReturnType<typeof getPackageManager>;
|
|
20
21
|
}
|
|
21
22
|
|
|
@@ -25,7 +26,6 @@ export interface BuildIdentity {
|
|
|
25
26
|
light?: boolean;
|
|
26
27
|
headless?: boolean;
|
|
27
28
|
emitExposedDependencies?: boolean;
|
|
28
|
-
outputBasePath?: string;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
export interface BuildOptions {
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import type { InlineConfig } from 'vite';
|
|
2
|
+
import { createCssConfig } from '../../../vite/config/create-css-config';
|
|
3
|
+
import { istanbulPlugin, svgrPlugin } from '../../../vite/plugins';
|
|
4
|
+
import { viteConfig } from '../vite-config';
|
|
5
|
+
|
|
6
|
+
jest.mock('vite', () => ({
|
|
7
|
+
mergeConfig: (base: object, overrides: object) => ({ ...base, ...overrides }),
|
|
8
|
+
}));
|
|
9
|
+
jest.mock('../../../vite/config/create-css-config');
|
|
10
|
+
jest.mock('../../../vite/plugins');
|
|
11
|
+
|
|
12
|
+
describe(`[startup/cypress-config] ${viteConfig.name}`, () => {
|
|
13
|
+
const cssConfig: any = { modules: { localsConvention: 'camelCaseOnly' } };
|
|
14
|
+
const svgr: any = { name: 'svgr' };
|
|
15
|
+
const istanbul: any = { name: 'istanbul' };
|
|
16
|
+
|
|
17
|
+
let overrides: InlineConfig | undefined;
|
|
18
|
+
|
|
19
|
+
const subject = () => viteConfig(overrides);
|
|
20
|
+
|
|
21
|
+
beforeEach(() => {
|
|
22
|
+
jest.clearAllMocks();
|
|
23
|
+
jest.mocked(createCssConfig).mockReturnValue(cssConfig);
|
|
24
|
+
jest.mocked(svgrPlugin).mockReturnValue(svgr);
|
|
25
|
+
jest.mocked(istanbulPlugin).mockReturnValue(istanbul);
|
|
26
|
+
overrides = undefined;
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
test('builds the CSS config for development', () => {
|
|
30
|
+
subject();
|
|
31
|
+
|
|
32
|
+
expect(createCssConfig).toHaveBeenCalledWith(false);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
test('wires the shared CSS config', () => {
|
|
36
|
+
expect(subject().css).toBe(cssConfig);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
test('includes the SVG plugin', () => {
|
|
40
|
+
expect(subject().plugins).toContain(svgr);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
test('enables code coverage', () => {
|
|
44
|
+
subject();
|
|
45
|
+
|
|
46
|
+
expect(istanbulPlugin).toHaveBeenCalledWith(
|
|
47
|
+
expect.objectContaining({ options: { codeCoverage: true } })
|
|
48
|
+
);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
test('includes the coverage plugin', () => {
|
|
52
|
+
expect(subject().plugins).toContain(istanbul);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
test('dedupes React', () => {
|
|
56
|
+
expect(subject().resolve?.dedupe).toEqual(['react', 'react-dom']);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
test('pre-bundles React', () => {
|
|
60
|
+
expect(subject().optimizeDeps?.include).toContain('react/jsx-runtime');
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
describe('with overrides', () => {
|
|
64
|
+
beforeEach(() => {
|
|
65
|
+
overrides = { clearScreen: false };
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
test('merges overrides into the config', () => {
|
|
69
|
+
expect(subject().clearScreen).toBe(false);
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
});
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { type InlineConfig, mergeConfig } from 'vite';
|
|
2
|
+
import { createCssConfig } from '../../vite/config/create-css-config';
|
|
3
|
+
import { istanbulPlugin, svgrPlugin } from '../../vite/plugins';
|
|
4
|
+
import type { ViteBuildContext } from '../../vite/types';
|
|
5
|
+
|
|
6
|
+
/*
|
|
7
|
+
* Dedupe and pre-bundle React so component tests load a single React instance.
|
|
8
|
+
* Mirrors how viteFinal handles Storybook, where automatic discovery can miss
|
|
9
|
+
* React in monorepos.
|
|
10
|
+
*/
|
|
11
|
+
const REACT_DEDUPE = ['react', 'react-dom'];
|
|
12
|
+
const REACT_OPTIMIZE = [...REACT_DEDUPE, 'react/jsx-runtime'];
|
|
13
|
+
|
|
14
|
+
export function viteConfig(overrides?: InlineConfig): InlineConfig {
|
|
15
|
+
const context = getContext();
|
|
16
|
+
|
|
17
|
+
const config: InlineConfig = {
|
|
18
|
+
css: createCssConfig(false),
|
|
19
|
+
resolve: { dedupe: REACT_DEDUPE },
|
|
20
|
+
optimizeDeps: { include: REACT_OPTIMIZE },
|
|
21
|
+
plugins: [svgrPlugin(context), istanbulPlugin(context)],
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
return mergeConfig(config, overrides ?? {});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function getContext(): ViteBuildContext {
|
|
28
|
+
/*
|
|
29
|
+
* svgrPlugin reads bundlerConfig.pluginOverrides and istanbulPlugin reads
|
|
30
|
+
* options.codeCoverage, so a minimal context reuses both. Component tests
|
|
31
|
+
* always instrument for coverage, matching the webpack Cypress config.
|
|
32
|
+
*/
|
|
33
|
+
return {
|
|
34
|
+
options: { codeCoverage: true },
|
|
35
|
+
bundlerConfig: { pluginOverrides: {} },
|
|
36
|
+
} as ViteBuildContext;
|
|
37
|
+
}
|