@servicetitan/startup 36.4.0 → 37.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/analyze.js +3 -0
- package/dist/cli/commands/build.d.ts.map +1 -1
- package/dist/cli/commands/build.js +4 -5
- package/dist/cli/commands/build.js.map +1 -1
- package/dist/cli/commands/bundle-vite.d.ts.map +1 -1
- package/dist/cli/commands/bundle-vite.js +18 -1
- package/dist/cli/commands/bundle-vite.js.map +1 -1
- package/dist/cli/commands/registry/build.d.ts +6 -0
- package/dist/cli/commands/registry/build.d.ts.map +1 -1
- package/dist/cli/commands/registry/build.js +10 -1
- package/dist/cli/commands/registry/build.js.map +1 -1
- package/dist/cli/commands/registry/command-registry.d.ts +12 -28
- package/dist/cli/commands/registry/command-registry.d.ts.map +1 -1
- package/dist/cli/commands/registry/command-registry.js +0 -3
- package/dist/cli/commands/registry/command-registry.js.map +1 -1
- package/dist/cli/commands/registry/start.d.ts +6 -0
- package/dist/cli/commands/registry/start.d.ts.map +1 -1
- package/dist/cli/commands/registry/start.js +10 -1
- package/dist/cli/commands/registry/start.js.map +1 -1
- package/dist/cli/commands/review/rules/index.d.ts.map +1 -1
- package/dist/cli/commands/review/rules/index.js +2 -0
- package/dist/cli/commands/review/rules/index.js.map +1 -1
- package/dist/cli/commands/review/rules/require-compatible-typescript.d.ts +13 -0
- package/dist/cli/commands/review/rules/require-compatible-typescript.d.ts.map +1 -0
- package/dist/cli/commands/review/rules/require-compatible-typescript.js +72 -0
- package/dist/cli/commands/review/rules/require-compatible-typescript.js.map +1 -0
- package/dist/cli/commands/start.d.ts.map +1 -1
- package/dist/cli/commands/start.js +3 -4
- package/dist/cli/commands/start.js.map +1 -1
- package/dist/cli/index.js +1 -1
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/utils/get-bundle-command.d.ts +3 -0
- package/dist/cli/utils/get-bundle-command.d.ts.map +1 -0
- package/dist/cli/utils/get-bundle-command.js +16 -0
- package/dist/cli/utils/get-bundle-command.js.map +1 -0
- package/dist/cli/utils/get-exit-code.d.ts +12 -0
- package/dist/cli/utils/get-exit-code.d.ts.map +1 -0
- package/dist/cli/utils/get-exit-code.js +26 -0
- package/dist/cli/utils/get-exit-code.js.map +1 -0
- package/dist/cli/utils/index.d.ts +3 -0
- package/dist/cli/utils/index.d.ts.map +1 -1
- package/dist/cli/utils/index.js +3 -0
- package/dist/cli/utils/index.js.map +1 -1
- package/dist/cli/utils/resolve-bundler.d.ts +8 -0
- package/dist/cli/utils/resolve-bundler.d.ts.map +1 -0
- package/dist/cli/utils/resolve-bundler.js +24 -0
- package/dist/cli/utils/resolve-bundler.js.map +1 -0
- package/dist/core/bundle-report.d.ts +4 -0
- package/dist/core/bundle-report.d.ts.map +1 -0
- package/dist/core/bundle-report.js +43 -0
- package/dist/core/bundle-report.js.map +1 -0
- package/dist/core/check-resource/check-resource.d.ts +2 -2
- package/dist/core/check-resource/check-resource.d.ts.map +1 -1
- package/dist/core/check-resource/check-resource.js +20 -13
- package/dist/core/check-resource/check-resource.js.map +1 -1
- package/dist/core/check-resource/get-peer-dependency-meta.d.ts +11 -1
- package/dist/core/check-resource/get-peer-dependency-meta.d.ts.map +1 -1
- package/dist/core/check-resource/get-peer-dependency-meta.js +58 -2
- package/dist/core/check-resource/get-peer-dependency-meta.js.map +1 -1
- package/dist/core/check-resource/index.d.ts +1 -1
- package/dist/core/check-resource/index.d.ts.map +1 -1
- package/dist/core/check-resource/index.js.map +1 -1
- package/dist/core/check-resource/is-resolvable.d.ts +7 -0
- package/dist/core/check-resource/is-resolvable.d.ts.map +1 -0
- package/dist/core/check-resource/is-resolvable.js +31 -0
- package/dist/core/check-resource/is-resolvable.js.map +1 -0
- package/dist/core/check-resource/types.d.ts +1 -0
- package/dist/core/check-resource/types.d.ts.map +1 -1
- package/dist/core/chunk-patterns.d.ts +7 -0
- package/dist/core/chunk-patterns.d.ts.map +1 -0
- package/dist/core/chunk-patterns.js +37 -0
- package/dist/core/chunk-patterns.js.map +1 -0
- package/dist/core/create-build-context.d.ts +0 -1
- package/dist/core/create-build-context.d.ts.map +1 -1
- package/dist/core/create-build-context.js +2 -2
- package/dist/core/create-build-context.js.map +1 -1
- package/dist/core/create-extension-regexp.d.ts +5 -0
- package/dist/core/create-extension-regexp.d.ts.map +1 -0
- package/dist/core/create-extension-regexp.js +45 -0
- package/dist/core/create-extension-regexp.js.map +1 -0
- package/dist/core/get-process-env.d.ts +3 -0
- package/dist/core/get-process-env.d.ts.map +1 -0
- package/dist/core/get-process-env.js +25 -0
- package/dist/core/get-process-env.js.map +1 -0
- package/dist/core/index.d.ts +8 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +8 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/moment-locales.d.ts +2 -0
- package/dist/core/moment-locales.d.ts.map +1 -0
- package/dist/core/moment-locales.js +21 -0
- package/dist/core/moment-locales.js.map +1 -0
- package/dist/core/resolve-output-path.d.ts +3 -0
- package/dist/core/resolve-output-path.d.ts.map +1 -0
- package/dist/core/resolve-output-path.js +25 -0
- package/dist/core/resolve-output-path.js.map +1 -0
- package/dist/core/resolve-output-root.d.ts +3 -0
- package/dist/core/resolve-output-root.d.ts.map +1 -0
- package/dist/core/resolve-output-root.js +23 -0
- package/dist/core/resolve-output-root.js.map +1 -0
- package/dist/core/sort-shared-css.d.ts +2 -0
- package/dist/core/sort-shared-css.d.ts.map +1 -0
- package/dist/core/sort-shared-css.js +20 -0
- package/dist/core/sort-shared-css.js.map +1 -0
- package/dist/core/types.d.ts +1 -1
- package/dist/core/types.d.ts.map +1 -1
- package/dist/cypress/config/index.d.ts +1 -0
- package/dist/cypress/config/index.d.ts.map +1 -1
- package/dist/cypress/config/index.js +1 -0
- package/dist/cypress/config/index.js.map +1 -1
- package/dist/cypress/config/vite-config.d.ts +3 -0
- package/dist/cypress/config/vite-config.d.ts.map +1 -0
- package/dist/cypress/config/vite-config.js +58 -0
- package/dist/cypress/config/vite-config.js.map +1 -0
- package/dist/storybook-config/index.d.ts +1 -0
- package/dist/storybook-config/index.d.ts.map +1 -1
- package/dist/storybook-config/index.js +1 -0
- package/dist/storybook-config/index.js.map +1 -1
- package/dist/storybook-config/vite-final.d.ts +7 -0
- package/dist/storybook-config/vite-final.d.ts.map +1 -0
- package/dist/storybook-config/vite-final.js +86 -0
- package/dist/storybook-config/vite-final.js.map +1 -0
- package/dist/utils/get-configuration.d.ts +15 -10
- package/dist/utils/get-configuration.d.ts.map +1 -1
- package/dist/utils/get-configuration.js +32 -2
- package/dist/utils/get-configuration.js.map +1 -1
- package/dist/utils/get-package-name.d.ts +2 -1
- package/dist/utils/get-package-name.d.ts.map +1 -1
- package/dist/utils/get-package-name.js +4 -2
- package/dist/utils/get-package-name.js.map +1 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/types.d.ts +2 -0
- package/dist/utils/types.d.ts.map +1 -0
- package/dist/utils/types.js +6 -0
- package/dist/utils/types.js.map +1 -0
- package/dist/utils/validate-shared-dependencies.d.ts.map +1 -1
- package/dist/utils/validate-shared-dependencies.js +4 -0
- package/dist/utils/validate-shared-dependencies.js.map +1 -1
- package/dist/vite/build-shared-dependencies.d.ts.map +1 -1
- package/dist/vite/build-shared-dependencies.js +1 -2
- package/dist/vite/build-shared-dependencies.js.map +1 -1
- package/dist/vite/config/asset-file-names.d.ts +4 -0
- package/dist/vite/config/asset-file-names.d.ts.map +1 -0
- package/dist/vite/config/asset-file-names.js +29 -0
- package/dist/vite/config/asset-file-names.js.map +1 -0
- package/dist/vite/config/base-config.d.ts.map +1 -1
- package/dist/vite/config/base-config.js +67 -40
- package/dist/vite/config/base-config.js.map +1 -1
- package/dist/vite/config/code-splitting.d.ts +4 -0
- package/dist/vite/config/code-splitting.d.ts.map +1 -0
- package/dist/vite/config/code-splitting.js +48 -0
- package/dist/vite/config/code-splitting.js.map +1 -0
- package/dist/vite/config/create-css-config.d.ts +3 -0
- package/dist/vite/config/create-css-config.d.ts.map +1 -0
- package/dist/vite/config/create-css-config.js +26 -0
- package/dist/vite/config/create-css-config.js.map +1 -0
- package/dist/vite/config/create-filtering-logger.d.ts +3 -0
- package/dist/vite/config/create-filtering-logger.d.ts.map +1 -0
- package/dist/vite/config/create-filtering-logger.js +37 -0
- package/dist/vite/config/create-filtering-logger.js.map +1 -0
- package/dist/vite/config/create-vite-build-context.d.ts +2 -1
- package/dist/vite/config/create-vite-build-context.d.ts.map +1 -1
- package/dist/vite/config/create-vite-build-context.js.map +1 -1
- package/dist/vite/config/create-vite-config.d.ts.map +1 -1
- package/dist/vite/config/create-vite-config.js +30 -13
- package/dist/vite/config/create-vite-config.js.map +1 -1
- package/dist/vite/config/get-warmup-client-files.d.ts +3 -0
- package/dist/vite/config/get-warmup-client-files.d.ts.map +1 -0
- package/dist/vite/config/get-warmup-client-files.js +26 -0
- package/dist/vite/config/get-warmup-client-files.js.map +1 -0
- package/dist/vite/index.html +1 -0
- package/dist/vite/plugins/bundle-stat-plugin.d.ts +4 -0
- package/dist/vite/plugins/bundle-stat-plugin.d.ts.map +1 -0
- package/dist/vite/plugins/bundle-stat-plugin.js +32 -0
- package/dist/vite/plugins/bundle-stat-plugin.js.map +1 -0
- package/dist/vite/plugins/chain-source-maps-plugin.d.ts +3 -0
- package/dist/vite/plugins/chain-source-maps-plugin.d.ts.map +1 -0
- package/dist/vite/plugins/chain-source-maps-plugin.js +37 -0
- package/dist/vite/plugins/chain-source-maps-plugin.js.map +1 -0
- package/dist/vite/plugins/clean-plugin.d.ts +4 -0
- package/dist/vite/plugins/clean-plugin.d.ts.map +1 -0
- package/dist/vite/plugins/clean-plugin.js +63 -0
- package/dist/vite/plugins/clean-plugin.js.map +1 -0
- package/dist/vite/plugins/design-system-guard-plugin.d.ts +4 -0
- package/dist/vite/plugins/design-system-guard-plugin.d.ts.map +1 -0
- package/dist/vite/plugins/design-system-guard-plugin.js +35 -0
- package/dist/vite/plugins/design-system-guard-plugin.js.map +1 -0
- package/dist/vite/plugins/ignore-modules-plugin.d.ts +17 -1
- package/dist/vite/plugins/ignore-modules-plugin.d.ts.map +1 -1
- package/dist/vite/plugins/ignore-modules-plugin.js +22 -8
- package/dist/vite/plugins/ignore-modules-plugin.js.map +1 -1
- package/dist/vite/plugins/index.d.ts +7 -0
- package/dist/vite/plugins/index.d.ts.map +1 -1
- package/dist/vite/plugins/index.js +7 -0
- package/dist/vite/plugins/index.js.map +1 -1
- package/dist/vite/plugins/istanbul-plugin.d.ts +4 -0
- package/dist/vite/plugins/istanbul-plugin.d.ts.map +1 -0
- package/dist/vite/plugins/istanbul-plugin.js +27 -0
- package/dist/vite/plugins/istanbul-plugin.js.map +1 -0
- package/dist/vite/plugins/magic-comments-plugin/index.d.ts +2 -0
- package/dist/vite/plugins/magic-comments-plugin/index.d.ts.map +1 -0
- package/dist/vite/plugins/magic-comments-plugin/index.js +20 -0
- package/dist/vite/plugins/magic-comments-plugin/index.js.map +1 -0
- package/dist/vite/plugins/magic-comments-plugin/magic-comments-plugin.d.ts +4 -0
- package/dist/vite/plugins/magic-comments-plugin/magic-comments-plugin.d.ts.map +1 -0
- package/dist/vite/plugins/magic-comments-plugin/magic-comments-plugin.js +63 -0
- package/dist/vite/plugins/magic-comments-plugin/magic-comments-plugin.js.map +1 -0
- package/dist/vite/plugins/magic-comments-plugin/parse-magic-comments.d.ts +6 -0
- package/dist/vite/plugins/magic-comments-plugin/parse-magic-comments.d.ts.map +1 -0
- package/dist/vite/plugins/magic-comments-plugin/parse-magic-comments.js +40 -0
- package/dist/vite/plugins/magic-comments-plugin/parse-magic-comments.js.map +1 -0
- package/dist/vite/plugins/metadata-plugin.js +2 -2
- package/dist/vite/plugins/metadata-plugin.js.map +1 -1
- package/dist/vite/plugins/moment-locales-plugin.d.ts +5 -0
- package/dist/vite/plugins/moment-locales-plugin.d.ts.map +1 -0
- package/dist/vite/plugins/moment-locales-plugin.js +50 -0
- package/dist/vite/plugins/moment-locales-plugin.js.map +1 -0
- package/dist/vite/plugins/shared-dependencies-plugin/assemble-iife.d.ts +14 -0
- package/dist/vite/plugins/shared-dependencies-plugin/assemble-iife.d.ts.map +1 -0
- package/dist/vite/plugins/shared-dependencies-plugin/assemble-iife.js +100 -0
- package/dist/vite/plugins/shared-dependencies-plugin/assemble-iife.js.map +1 -0
- package/dist/vite/plugins/shared-dependencies-plugin/assert-no-dynamic-css.d.ts +3 -0
- package/dist/vite/plugins/shared-dependencies-plugin/assert-no-dynamic-css.d.ts.map +1 -0
- package/dist/vite/plugins/shared-dependencies-plugin/assert-no-dynamic-css.js +56 -0
- package/dist/vite/plugins/shared-dependencies-plugin/assert-no-dynamic-css.js.map +1 -0
- package/dist/vite/plugins/shared-dependencies-plugin/flatten.d.ts +2 -0
- package/dist/vite/plugins/shared-dependencies-plugin/flatten.d.ts.map +1 -0
- package/dist/vite/plugins/shared-dependencies-plugin/flatten.js +19 -0
- package/dist/vite/plugins/shared-dependencies-plugin/flatten.js.map +1 -0
- package/dist/vite/plugins/shared-dependencies-plugin/index.d.ts +2 -0
- package/dist/vite/plugins/shared-dependencies-plugin/index.d.ts.map +1 -0
- package/dist/vite/plugins/shared-dependencies-plugin/index.js +20 -0
- package/dist/vite/plugins/shared-dependencies-plugin/index.js.map +1 -0
- package/dist/vite/plugins/shared-dependencies-plugin/shared-dependencies-plugin.d.ts.map +1 -0
- package/dist/vite/plugins/{shared-dependencies-plugin.js → shared-dependencies-plugin/shared-dependencies-plugin.js} +29 -107
- package/dist/vite/plugins/shared-dependencies-plugin/shared-dependencies-plugin.js.map +1 -0
- package/dist/vite/plugins/utils/import-esm.d.ts +2 -0
- package/dist/vite/plugins/utils/import-esm.d.ts.map +1 -0
- package/dist/vite/plugins/utils/import-esm.js +22 -0
- package/dist/vite/plugins/utils/import-esm.js.map +1 -0
- package/dist/vite/plugins/utils/index.d.ts +3 -0
- package/dist/vite/plugins/utils/index.d.ts.map +1 -0
- package/dist/vite/plugins/utils/index.js +21 -0
- package/dist/vite/plugins/utils/index.js.map +1 -0
- package/dist/webpack/configs/optimization-config.d.ts.map +1 -1
- package/dist/webpack/configs/optimization-config.js +53 -24
- package/dist/webpack/configs/optimization-config.js.map +1 -1
- package/dist/webpack/configs/output-config.d.ts.map +1 -1
- package/dist/webpack/configs/output-config.js +0 -1
- package/dist/webpack/configs/output-config.js.map +1 -1
- package/dist/webpack/configs/plugins/assets-manifest-plugin.d.ts.map +1 -1
- package/dist/webpack/configs/plugins/assets-manifest-plugin.js +11 -3
- package/dist/webpack/configs/plugins/assets-manifest-plugin.js.map +1 -1
- package/dist/webpack/configs/plugins/bundle-analyser-plugin.d.ts.map +1 -1
- package/dist/webpack/configs/plugins/bundle-analyser-plugin.js +2 -21
- package/dist/webpack/configs/plugins/bundle-analyser-plugin.js.map +1 -1
- package/dist/webpack/configs/plugins/define-process-env-plugin.d.ts +5 -0
- package/dist/webpack/configs/plugins/define-process-env-plugin.d.ts.map +1 -0
- package/dist/webpack/configs/plugins/define-process-env-plugin.js +20 -0
- package/dist/webpack/configs/plugins/define-process-env-plugin.js.map +1 -0
- package/dist/webpack/configs/plugins/ignore-plugin/empty-module.d.ts +2 -0
- package/dist/webpack/configs/plugins/ignore-plugin/empty-module.d.ts.map +1 -0
- package/dist/webpack/configs/plugins/ignore-plugin/empty-module.js +11 -0
- package/dist/webpack/configs/plugins/ignore-plugin/empty-module.js.map +1 -0
- package/dist/webpack/configs/plugins/ignore-plugin/ignore-plugin.d.ts +26 -3
- package/dist/webpack/configs/plugins/ignore-plugin/ignore-plugin.d.ts.map +1 -1
- package/dist/webpack/configs/plugins/ignore-plugin/ignore-plugin.js +41 -10
- package/dist/webpack/configs/plugins/ignore-plugin/ignore-plugin.js.map +1 -1
- package/dist/webpack/configs/plugins/index.d.ts +1 -0
- package/dist/webpack/configs/plugins/index.d.ts.map +1 -1
- package/dist/webpack/configs/plugins/index.js +1 -0
- package/dist/webpack/configs/plugins/index.js.map +1 -1
- package/dist/webpack/configs/plugins/moment-locales-plugin.d.ts.map +1 -1
- package/dist/webpack/configs/plugins/moment-locales-plugin.js +2 -5
- package/dist/webpack/configs/plugins/moment-locales-plugin.js.map +1 -1
- package/dist/webpack/configs/plugins-config.d.ts.map +1 -1
- package/dist/webpack/configs/plugins-config.js +1 -0
- package/dist/webpack/configs/plugins-config.js.map +1 -1
- package/dist/webpack/configs/rules/font-rules.d.ts.map +1 -1
- package/dist/webpack/configs/rules/font-rules.js +2 -1
- package/dist/webpack/configs/rules/font-rules.js.map +1 -1
- package/dist/webpack/configs/rules/image-rules.d.ts.map +1 -1
- package/dist/webpack/configs/rules/image-rules.js +2 -1
- package/dist/webpack/configs/rules/image-rules.js.map +1 -1
- package/dist/webpack/create-webpack-config.d.ts.map +1 -1
- package/dist/webpack/create-webpack-config.js +8 -3
- package/dist/webpack/create-webpack-config.js.map +1 -1
- package/dist/webpack/create-webpack-configs.d.ts.map +1 -1
- package/dist/webpack/create-webpack-configs.js +4 -12
- package/dist/webpack/create-webpack-configs.js.map +1 -1
- package/dist/webpack/types.d.ts +1 -1
- package/dist/webpack/types.d.ts.map +1 -1
- package/dist/webpack/utils/create-webpack-build-context.d.ts.map +1 -1
- package/dist/webpack/utils/create-webpack-build-context.js +1 -2
- package/dist/webpack/utils/create-webpack-build-context.js.map +1 -1
- package/package.json +22 -18
- package/src/cli/commands/__tests__/build.test.ts +33 -5
- package/src/cli/commands/__tests__/bundle-vite.test.ts +50 -1
- package/src/cli/commands/__tests__/start.test.ts +17 -4
- package/src/cli/commands/build.ts +5 -6
- package/src/cli/commands/bundle-vite.ts +13 -0
- package/src/cli/commands/registry/build.ts +6 -1
- package/src/cli/commands/registry/command-registry.ts +0 -1
- package/src/cli/commands/registry/start.ts +6 -1
- package/src/cli/commands/review/rules/__tests__/require-compatible-typescript.test.ts +127 -0
- package/src/cli/commands/review/rules/index.ts +2 -0
- package/src/cli/commands/review/rules/require-compatible-typescript.ts +64 -0
- package/src/cli/commands/start.ts +4 -4
- package/src/cli/index.ts +2 -2
- package/src/cli/utils/__tests__/get-bundle-command.test.ts +23 -0
- package/src/cli/utils/__tests__/get-exit-code.test.ts +41 -0
- package/src/cli/utils/__tests__/resolve-bundler.test.ts +64 -0
- package/src/cli/utils/get-bundle-command.ts +5 -0
- package/src/cli/utils/get-exit-code.ts +17 -0
- package/src/cli/utils/index.ts +3 -0
- package/src/cli/utils/resolve-bundler.ts +23 -0
- package/src/core/__tests__/bundle-report.test.ts +60 -0
- package/src/core/__tests__/create-extension-regexp.test.ts +32 -0
- package/src/core/__tests__/resolve-output-path.test.ts +45 -0
- package/src/core/__tests__/resolve-output-root.test.ts +37 -0
- package/src/core/__tests__/sort-shared-css.test.ts +39 -0
- package/src/core/bundle-report.ts +33 -0
- package/src/core/check-resource/__tests__/check-resource.test.ts +21 -7
- package/src/core/check-resource/__tests__/get-peer-dependency-meta.test.ts +70 -13
- package/src/core/check-resource/__tests__/is-resolvable.test.ts +20 -0
- package/src/core/check-resource/check-resource.ts +15 -14
- package/src/core/check-resource/get-peer-dependency-meta.ts +67 -4
- package/src/core/check-resource/index.ts +1 -1
- package/src/core/check-resource/is-resolvable.ts +19 -0
- package/src/core/check-resource/types.ts +2 -0
- package/src/core/chunk-patterns.ts +30 -0
- package/src/core/create-build-context.ts +2 -2
- package/src/core/create-extension-regexp.ts +7 -0
- package/src/core/get-process-env.ts +17 -0
- package/src/core/index.ts +8 -1
- package/src/core/moment-locales.ts +6 -0
- package/src/core/resolve-output-path.ts +10 -0
- package/src/core/resolve-output-root.ts +8 -0
- package/src/core/sort-shared-css.ts +7 -0
- package/src/core/types.ts +1 -1
- package/src/cypress/config/__tests__/vite-config.test.ts +72 -0
- package/src/cypress/config/index.ts +1 -0
- package/src/cypress/config/vite-config.ts +37 -0
- package/src/storybook-config/__tests__/vite-final.test.ts +122 -0
- package/src/storybook-config/index.ts +1 -0
- package/src/storybook-config/vite-final.ts +65 -0
- package/src/utils/__tests__/get-configuration.test.ts +82 -5
- package/src/utils/__tests__/get-package-name.test.ts +57 -0
- package/src/utils/__tests__/validate-shared-dependencies.test.ts +50 -35
- package/src/utils/get-configuration.ts +50 -15
- package/src/utils/get-package-name.ts +8 -2
- package/src/utils/index.ts +1 -0
- package/src/utils/types.ts +1 -0
- package/src/utils/validate-shared-dependencies.ts +15 -1
- package/src/vite/__tests__/build-shared-dependencies.test.ts +13 -26
- package/src/vite/__tests__/validate-shared-dependencies.test.ts +30 -19
- package/src/vite/build-shared-dependencies.ts +3 -7
- package/src/vite/config/__tests__/asset-file-names.test.ts +40 -0
- package/src/vite/config/__tests__/base-config.test.ts +99 -31
- package/src/vite/config/__tests__/code-splitting.test.ts +34 -0
- package/src/vite/config/__tests__/create-css-config.test.ts +58 -0
- package/src/vite/config/__tests__/create-filtering-logger.test.ts +51 -0
- package/src/vite/config/__tests__/create-vite-build-context.test.ts +5 -2
- package/src/vite/config/__tests__/create-vite-config.test.ts +91 -13
- package/src/vite/config/__tests__/get-warmup-client-files.test.ts +20 -0
- package/src/vite/config/asset-file-names.ts +20 -0
- package/src/vite/config/base-config.ts +45 -37
- package/src/vite/config/code-splitting.ts +23 -0
- package/src/vite/config/create-css-config.ts +16 -0
- package/src/vite/config/create-filtering-logger.ts +34 -0
- package/src/vite/config/create-vite-build-context.ts +3 -5
- package/src/vite/config/create-vite-config.ts +45 -12
- package/src/vite/config/get-warmup-client-files.ts +13 -0
- package/src/vite/index.html +1 -0
- package/src/vite/plugins/__tests__/bundle-stat-plugin.test.ts +70 -0
- package/src/vite/plugins/__tests__/chain-source-maps-plugin.test.ts +58 -0
- package/src/vite/plugins/__tests__/clean-plugin.test.ts +121 -0
- package/src/vite/plugins/__tests__/design-system-guard-plugin.test.ts +83 -0
- package/src/vite/plugins/__tests__/html-template.test.ts +6 -0
- package/src/vite/plugins/__tests__/ignore-modules-plugin.test.ts +29 -7
- package/src/vite/plugins/__tests__/istanbul-plugin.test.ts +62 -0
- package/src/vite/plugins/__tests__/moment-locales-plugin.test.ts +104 -0
- package/src/vite/plugins/bundle-stat-plugin.ts +24 -0
- package/src/vite/plugins/chain-source-maps-plugin.ts +26 -0
- package/src/vite/plugins/clean-plugin.ts +46 -0
- package/src/vite/plugins/design-system-guard-plugin.ts +34 -0
- package/src/vite/plugins/ignore-modules-plugin.ts +31 -5
- package/src/vite/plugins/index.ts +7 -0
- package/src/vite/plugins/istanbul-plugin.ts +19 -0
- package/src/vite/plugins/magic-comments-plugin/__tests__/magic-comments-plugin.test.ts +105 -0
- package/src/vite/plugins/magic-comments-plugin/__tests__/parse-magic-comments.test.ts +40 -0
- package/src/vite/plugins/magic-comments-plugin/index.ts +1 -0
- package/src/vite/plugins/magic-comments-plugin/magic-comments-plugin.ts +63 -0
- package/src/vite/plugins/magic-comments-plugin/parse-magic-comments.ts +39 -0
- package/src/vite/plugins/metadata-plugin.ts +1 -1
- package/src/vite/plugins/moment-locales-plugin.ts +41 -0
- package/src/vite/plugins/shared-dependencies-plugin/__tests__/assemble-iife.test.ts +29 -0
- package/src/vite/plugins/shared-dependencies-plugin/__tests__/assert-no-dynamic-css.test.ts +113 -0
- package/src/vite/plugins/shared-dependencies-plugin/__tests__/flatten.test.ts +23 -0
- package/src/vite/plugins/{__tests__ → shared-dependencies-plugin/__tests__}/shared-dependencies-plugin.test.ts +38 -4
- package/src/vite/plugins/shared-dependencies-plugin/assemble-iife.ts +114 -0
- package/src/vite/plugins/shared-dependencies-plugin/assert-no-dynamic-css.ts +58 -0
- package/src/vite/plugins/shared-dependencies-plugin/flatten.ts +8 -0
- package/src/vite/plugins/shared-dependencies-plugin/index.ts +1 -0
- package/src/vite/plugins/{shared-dependencies-plugin.ts → shared-dependencies-plugin/shared-dependencies-plugin.ts} +24 -115
- package/src/vite/plugins/utils/import-esm.ts +15 -0
- package/src/vite/plugins/utils/index.ts +2 -0
- package/src/vite/rolldown-oxc.d.ts +20 -0
- package/src/webpack/__tests__/bundle-webpack.test.ts +8 -8
- package/src/webpack/__tests__/create-webpack-config-shared-dependencies.test.ts +54 -5
- package/src/webpack/__tests__/create-webpack-config-web-component.test.ts +70 -12
- package/src/webpack/__tests__/create-webpack-config.test.ts +92 -9
- package/src/webpack/configs/optimization-config.ts +47 -25
- package/src/webpack/configs/output-config.ts +1 -2
- package/src/webpack/configs/plugins/assets-manifest-plugin.ts +16 -4
- package/src/webpack/configs/plugins/bundle-analyser-plugin.ts +3 -25
- package/src/webpack/configs/plugins/define-process-env-plugin.ts +10 -0
- package/src/webpack/configs/plugins/ignore-plugin/__tests__/ignore-plugin.test.ts +76 -24
- package/src/webpack/configs/plugins/ignore-plugin/empty-module.ts +7 -0
- package/src/webpack/configs/plugins/ignore-plugin/ignore-plugin.ts +59 -9
- package/src/webpack/configs/plugins/index.ts +1 -0
- package/src/webpack/configs/plugins/moment-locales-plugin.ts +2 -2
- package/src/webpack/configs/plugins-config.ts +2 -0
- package/src/webpack/configs/rules/font-rules.ts +2 -2
- package/src/webpack/configs/rules/image-rules.ts +2 -2
- package/src/webpack/create-webpack-config.ts +11 -4
- package/src/webpack/create-webpack-configs.ts +2 -8
- package/src/webpack/types.ts +1 -4
- package/src/webpack/utils/create-webpack-build-context.ts +1 -6
- package/tsconfig/base.json +1 -1
- package/tsconfig/types.d.ts +10 -0
- package/dist/core/get-output-path.d.ts +0 -3
- package/dist/core/get-output-path.d.ts.map +0 -1
- package/dist/core/get-output-path.js +0 -29
- package/dist/core/get-output-path.js.map +0 -1
- package/dist/vite/plugins/shared-dependencies-plugin.d.ts.map +0 -1
- package/dist/vite/plugins/shared-dependencies-plugin.js.map +0 -1
- package/src/core/__tests__/get-output-path.test.ts +0 -64
- package/src/core/get-output-path.ts +0 -15
- /package/dist/vite/plugins/{shared-dependencies-plugin.d.ts → shared-dependencies-plugin/shared-dependencies-plugin.d.ts} +0 -0
|
@@ -2,11 +2,12 @@ import HtmlWebpackPlugin from 'html-webpack-plugin';
|
|
|
2
2
|
import { fs, vol } from 'memfs';
|
|
3
3
|
import MiniCssExtractPlugin from 'mini-css-extract-plugin';
|
|
4
4
|
import path from 'path';
|
|
5
|
+
import TerserPlugin from 'terser-webpack-plugin';
|
|
5
6
|
import { DefinePlugin } from 'webpack';
|
|
6
7
|
import { WebpackAssetsManifest } from 'webpack-assets-manifest';
|
|
7
8
|
import VirtualModulesPlugin from 'webpack-virtual-modules';
|
|
8
9
|
import yargs from 'yargs';
|
|
9
|
-
import { generateMetadata } from '../../core';
|
|
10
|
+
import { CHUNK_PATTERNS, generateMetadata } from '../../core';
|
|
10
11
|
import {
|
|
11
12
|
getFolders,
|
|
12
13
|
getPackageData,
|
|
@@ -16,8 +17,11 @@ import {
|
|
|
16
17
|
isWebComponent,
|
|
17
18
|
} from '../../utils';
|
|
18
19
|
import { miniCssPluginStyleRules } from '../__mocks__';
|
|
19
|
-
import {
|
|
20
|
-
|
|
20
|
+
import {
|
|
21
|
+
createWebpackConfig,
|
|
22
|
+
webpackDevConfigFileName,
|
|
23
|
+
webpackProdConfigFileName,
|
|
24
|
+
} from '../create-webpack-config';
|
|
21
25
|
import { getCallerFile, splitByEntry } from '../utils';
|
|
22
26
|
|
|
23
27
|
jest.mock('fs', () => fs);
|
|
@@ -26,6 +30,7 @@ jest.mock('mini-css-extract-plugin', () =>
|
|
|
26
30
|
Object.assign(jest.fn(), { loader: 'MiniCssExtractPlugin.loader' })
|
|
27
31
|
);
|
|
28
32
|
jest.mock('moment-locales-webpack-plugin', () => jest.fn());
|
|
33
|
+
jest.mock('terser-webpack-plugin', () => jest.fn());
|
|
29
34
|
jest.mock('webpack', () => ({
|
|
30
35
|
DefinePlugin: jest.fn(),
|
|
31
36
|
IgnorePlugin: jest.fn(),
|
|
@@ -103,6 +108,7 @@ describe(`[startup] ${createWebpackConfig.name}`, () => {
|
|
|
103
108
|
jest.mocked(DefinePlugin).mockImplementation(mockPlugIn('DefinePlugin'));
|
|
104
109
|
jest.mocked(HtmlWebpackPlugin).mockImplementation(mockPlugIn('HtmlWebpackPlugin'));
|
|
105
110
|
jest.mocked(VirtualModulesPlugin).mockImplementation(mockPlugIn('VirtualModulesPlugin'));
|
|
111
|
+
jest.mocked(TerserPlugin).mockImplementation(mockPlugIn('TerserPlugin'));
|
|
106
112
|
jest.mocked(WebpackAssetsManifest).mockImplementation(mockPlugIn('WebpackAssetsManifest'));
|
|
107
113
|
jest.mocked(yargs).mockImplementation(() => ({ argv: {} }) as any);
|
|
108
114
|
|
|
@@ -135,7 +141,7 @@ describe(`[startup] ${createWebpackConfig.name}`, () => {
|
|
|
135
141
|
},
|
|
136
142
|
servicetitan: {
|
|
137
143
|
name: 'servicetitan',
|
|
138
|
-
test:
|
|
144
|
+
test: CHUNK_PATTERNS.servicetitan,
|
|
139
145
|
chunks: 'all',
|
|
140
146
|
},
|
|
141
147
|
};
|
|
@@ -208,7 +214,7 @@ describe(`[startup] ${createWebpackConfig.name}`, () => {
|
|
|
208
214
|
entrypoints: {
|
|
209
215
|
foo: {
|
|
210
216
|
assets: {
|
|
211
|
-
css: ['main.css', 'servicetitan.css', '
|
|
217
|
+
css: ['main.css', 'servicetitan.css', 'vendor-core.css'],
|
|
212
218
|
},
|
|
213
219
|
},
|
|
214
220
|
},
|
|
@@ -218,7 +224,9 @@ describe(`[startup] ${createWebpackConfig.name}`, () => {
|
|
|
218
224
|
|
|
219
225
|
const transform: any = jest.mocked(WebpackAssetsManifest).mock.calls[0][0]?.transform;
|
|
220
226
|
expect(transform(assets)).toEqual(
|
|
221
|
-
expect.objectContaining({
|
|
227
|
+
expect.objectContaining({
|
|
228
|
+
css: ['servicetitan.css', 'main.css', 'vendor-core.css'],
|
|
229
|
+
})
|
|
222
230
|
);
|
|
223
231
|
});
|
|
224
232
|
|
|
@@ -394,6 +402,44 @@ describe(`[startup] ${createWebpackConfig.name}`, () => {
|
|
|
394
402
|
path.join(process.cwd(), destination, 'bundle', 'headless')
|
|
395
403
|
);
|
|
396
404
|
});
|
|
405
|
+
|
|
406
|
+
test('omits "optimization.splitChunks.cacheGroups"', () => {
|
|
407
|
+
// @ts-expect-error because splitChunks is polymorphic
|
|
408
|
+
expect(subject().optimization?.splitChunks.cacheGroups).toEqual({});
|
|
409
|
+
});
|
|
410
|
+
|
|
411
|
+
describe('when mode is production', () => {
|
|
412
|
+
beforeEach(() =>
|
|
413
|
+
Object.assign((overrides.configuration ??= {}), { mode: 'production' })
|
|
414
|
+
);
|
|
415
|
+
|
|
416
|
+
test('configures "optimization.splitChunks.cacheGroups"', () => {
|
|
417
|
+
// @ts-expect-error because splitChunks is polymorphic
|
|
418
|
+
expect(subject().optimization?.splitChunks.cacheGroups).toEqual({
|
|
419
|
+
'servicetitan': {
|
|
420
|
+
name: 'servicetitan',
|
|
421
|
+
test: CHUNK_PATTERNS.servicetitan,
|
|
422
|
+
chunks: 'all',
|
|
423
|
+
},
|
|
424
|
+
'vendor-core': {
|
|
425
|
+
name: 'vendor-core',
|
|
426
|
+
test: CHUNK_PATTERNS['vendor-core'],
|
|
427
|
+
chunks: 'all',
|
|
428
|
+
},
|
|
429
|
+
'kendo': {
|
|
430
|
+
name: 'kendo',
|
|
431
|
+
test: CHUNK_PATTERNS.kendo,
|
|
432
|
+
chunks: 'all',
|
|
433
|
+
},
|
|
434
|
+
'vendor': {
|
|
435
|
+
name: 'vendor',
|
|
436
|
+
test: CHUNK_PATTERNS.vendor,
|
|
437
|
+
chunks: 'all',
|
|
438
|
+
priority: -5,
|
|
439
|
+
},
|
|
440
|
+
});
|
|
441
|
+
});
|
|
442
|
+
});
|
|
397
443
|
});
|
|
398
444
|
|
|
399
445
|
describe.each([webpackDevConfigFileName, webpackProdConfigFileName])(
|
|
@@ -416,20 +462,26 @@ describe(`[startup] ${createWebpackConfig.name}`, () => {
|
|
|
416
462
|
expect(subject().devtool).toBe('source-map');
|
|
417
463
|
});
|
|
418
464
|
|
|
419
|
-
test('adds "
|
|
465
|
+
test('adds "vendor-core", "kendo", and "vendor" to "optimization.splitChunks.cacheGroups"', () => {
|
|
420
466
|
// @ts-expect-error because splitChunks is polymorphic
|
|
421
467
|
expect(subject().optimization?.splitChunks.cacheGroups).toEqual({
|
|
422
468
|
...baseCacheGroups,
|
|
423
|
-
|
|
424
|
-
name: '
|
|
425
|
-
test:
|
|
469
|
+
'vendor-core': {
|
|
470
|
+
name: 'vendor-core',
|
|
471
|
+
test: CHUNK_PATTERNS['vendor-core'],
|
|
426
472
|
chunks: 'all',
|
|
427
473
|
},
|
|
428
|
-
kendo: {
|
|
474
|
+
'kendo': {
|
|
429
475
|
name: 'kendo',
|
|
430
|
-
test:
|
|
476
|
+
test: CHUNK_PATTERNS.kendo,
|
|
431
477
|
chunks: 'all',
|
|
432
478
|
},
|
|
479
|
+
'vendor': {
|
|
480
|
+
name: 'vendor',
|
|
481
|
+
test: CHUNK_PATTERNS.vendor,
|
|
482
|
+
chunks: 'all',
|
|
483
|
+
priority: -5,
|
|
484
|
+
},
|
|
433
485
|
});
|
|
434
486
|
});
|
|
435
487
|
|
|
@@ -437,6 +489,12 @@ describe(`[startup] ${createWebpackConfig.name}`, () => {
|
|
|
437
489
|
expect(subject().output?.uniqueName).toEqual(options.name);
|
|
438
490
|
});
|
|
439
491
|
|
|
492
|
+
test('enables terser compress and mangle', () => {
|
|
493
|
+
expect(subject().optimization?.minimizer).toContainEqual(
|
|
494
|
+
new TerserPlugin({ terserOptions: { compress: true, mangle: true } })
|
|
495
|
+
);
|
|
496
|
+
});
|
|
497
|
+
|
|
440
498
|
describe('when headless option is set to true', () => {
|
|
441
499
|
beforeEach(() => (options.headless = true));
|
|
442
500
|
|
|
@@ -6,15 +6,17 @@ import MomentLocalesPlugin from 'moment-locales-webpack-plugin';
|
|
|
6
6
|
import os from 'os';
|
|
7
7
|
import path from 'path';
|
|
8
8
|
import TerserPlugin from 'terser-webpack-plugin';
|
|
9
|
-
import { IgnorePlugin, ProvidePlugin } from 'webpack';
|
|
9
|
+
import { DefinePlugin, IgnorePlugin, ProvidePlugin } from 'webpack';
|
|
10
10
|
import WebpackDevServer from 'webpack-dev-server';
|
|
11
11
|
import yargs from 'yargs';
|
|
12
12
|
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
|
|
13
13
|
const FilterWarningsPlugin = require('webpack-filter-warnings-plugin');
|
|
14
14
|
|
|
15
15
|
import { getPackageManager } from '@servicetitan/install';
|
|
16
|
+
import { CHUNK_PATTERNS } from '../../core';
|
|
16
17
|
import {
|
|
17
18
|
getConfiguration,
|
|
19
|
+
getExposeProcessEnv,
|
|
18
20
|
getFolders,
|
|
19
21
|
getPackageData,
|
|
20
22
|
getPackages,
|
|
@@ -29,10 +31,9 @@ import {
|
|
|
29
31
|
} from '../../utils';
|
|
30
32
|
import { fileRules, productionStyleRules, styleRules } from '../__mocks__';
|
|
31
33
|
import { JS_RULE_EXCLUDE } from '../configs/constants';
|
|
34
|
+
import { createWebpackConfig } from '../create-webpack-config';
|
|
32
35
|
import { splitByEntry } from '../utils';
|
|
33
36
|
|
|
34
|
-
import { createWebpackConfig } from '../index';
|
|
35
|
-
|
|
36
37
|
jest.mock('fs', () => fs);
|
|
37
38
|
jest.mock('css-minimizer-webpack-plugin', () => jest.fn());
|
|
38
39
|
jest.mock('html-webpack-plugin', () => jest.fn());
|
|
@@ -56,6 +57,7 @@ jest.mock('@servicetitan/install', () => ({ getPackageManager: jest.fn() }));
|
|
|
56
57
|
jest.mock('../../utils', () => ({
|
|
57
58
|
...jest.requireActual('../../utils'),
|
|
58
59
|
getConfiguration: jest.fn(),
|
|
60
|
+
getExposeProcessEnv: jest.fn(),
|
|
59
61
|
getFolders: jest.fn(),
|
|
60
62
|
getPackageData: jest.fn(),
|
|
61
63
|
getPackages: jest.fn(),
|
|
@@ -201,6 +203,26 @@ describe(`[startup] ${createWebpackConfig.name}`, () => {
|
|
|
201
203
|
expect(subject().output!.path).toEqual(path.join(process.cwd(), destination, 'bundle'));
|
|
202
204
|
});
|
|
203
205
|
|
|
206
|
+
describe('with custom "output.path"', () => {
|
|
207
|
+
const output = { path: '/foo' };
|
|
208
|
+
|
|
209
|
+
beforeEach(() => (overrides.configuration!.output = output));
|
|
210
|
+
|
|
211
|
+
test('uses custom output.path', () => {
|
|
212
|
+
expect(subject().output!.path).toEqual(output.path);
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
describe('when package is web component', () => {
|
|
216
|
+
beforeEach(() => jest.mocked(isWebComponent).mockReturnValue(true));
|
|
217
|
+
|
|
218
|
+
test('uses default output.path', () => {
|
|
219
|
+
expect(subject().output!.path).toEqual(
|
|
220
|
+
path.join(process.cwd(), destination, 'bundle', 'full')
|
|
221
|
+
);
|
|
222
|
+
});
|
|
223
|
+
});
|
|
224
|
+
});
|
|
225
|
+
|
|
204
226
|
test('configures "optimization"', () => {
|
|
205
227
|
expect(subject().optimization).toEqual({
|
|
206
228
|
chunkIds: 'named',
|
|
@@ -487,10 +509,11 @@ describe(`[startup] ${createWebpackConfig.name}`, () => {
|
|
|
487
509
|
);
|
|
488
510
|
});
|
|
489
511
|
|
|
490
|
-
test('configures
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
512
|
+
test('configures IgnoreOptionalDependenciesPlugin', () => {
|
|
513
|
+
const plugin = subject().plugins?.find(
|
|
514
|
+
p => p?.constructor.name === 'IgnoreOptionalDependenciesPlugin'
|
|
515
|
+
);
|
|
516
|
+
expect(plugin).toBeDefined();
|
|
494
517
|
});
|
|
495
518
|
|
|
496
519
|
describe('when buildStat option is set to true', () => {
|
|
@@ -509,9 +532,10 @@ describe(`[startup] ${createWebpackConfig.name}`, () => {
|
|
|
509
532
|
function reportTitle(type?: string) {
|
|
510
533
|
const date = new Date();
|
|
511
534
|
|
|
512
|
-
const
|
|
535
|
+
const zeroPad = (n: number) => n.toString().padStart(2, '0');
|
|
536
|
+
const timestamp = `${date.getFullYear()}-${zeroPad(
|
|
513
537
|
date.getMonth() + 1
|
|
514
|
-
}-${date.getDate()} ${date.getHours()}:${date.getMinutes()}`;
|
|
538
|
+
)}-${zeroPad(date.getDate())} ${zeroPad(date.getHours())}:${zeroPad(date.getMinutes())}`;
|
|
515
539
|
|
|
516
540
|
return `${packageName.replace('@servicetitan/', '')}${
|
|
517
541
|
type ? ` (${type})` : ''
|
|
@@ -595,6 +619,33 @@ describe(`[startup] ${createWebpackConfig.name}`, () => {
|
|
|
595
619
|
expect(subject().optimization?.runtimeChunk).toBe('single');
|
|
596
620
|
});
|
|
597
621
|
|
|
622
|
+
test('configures "optimization.splitChunks.cacheGroups"', () => {
|
|
623
|
+
// @ts-expect-error because splitChunks is polymorphic
|
|
624
|
+
expect(subject().optimization?.splitChunks.cacheGroups).toEqual({
|
|
625
|
+
'servicetitan': {
|
|
626
|
+
name: 'servicetitan',
|
|
627
|
+
test: CHUNK_PATTERNS.servicetitan,
|
|
628
|
+
chunks: 'all',
|
|
629
|
+
},
|
|
630
|
+
'vendor-core': {
|
|
631
|
+
name: 'vendor-core',
|
|
632
|
+
test: CHUNK_PATTERNS['vendor-core'],
|
|
633
|
+
chunks: 'all',
|
|
634
|
+
},
|
|
635
|
+
'kendo': {
|
|
636
|
+
name: 'kendo',
|
|
637
|
+
test: CHUNK_PATTERNS.kendo,
|
|
638
|
+
chunks: 'all',
|
|
639
|
+
},
|
|
640
|
+
'vendor': {
|
|
641
|
+
name: 'vendor',
|
|
642
|
+
test: CHUNK_PATTERNS.vendor,
|
|
643
|
+
chunks: 'all',
|
|
644
|
+
priority: -5,
|
|
645
|
+
},
|
|
646
|
+
});
|
|
647
|
+
});
|
|
648
|
+
|
|
598
649
|
test('configures "optimization.minimize"', () => {
|
|
599
650
|
expect(subject().optimization?.minimize).toBe(true);
|
|
600
651
|
});
|
|
@@ -681,4 +732,36 @@ describe(`[startup] ${createWebpackConfig.name}`, () => {
|
|
|
681
732
|
expect(subject).toThrow('package does not expose shared dependencies');
|
|
682
733
|
});
|
|
683
734
|
});
|
|
735
|
+
|
|
736
|
+
describe('with "expose-process-env"', () => {
|
|
737
|
+
const variable = 'API_URL';
|
|
738
|
+
const value = 'https://api.example.com';
|
|
739
|
+
|
|
740
|
+
beforeEach(() => {
|
|
741
|
+
jest.mocked(getExposeProcessEnv).mockReturnValue([variable]);
|
|
742
|
+
process.env[variable] = value;
|
|
743
|
+
});
|
|
744
|
+
|
|
745
|
+
afterEach(() => delete process.env[variable]);
|
|
746
|
+
|
|
747
|
+
test('defines the variable via DefinePlugin', () => {
|
|
748
|
+
subject();
|
|
749
|
+
|
|
750
|
+
expect(DefinePlugin).toHaveBeenCalledWith({
|
|
751
|
+
[`process.env.${variable}`]: JSON.stringify(value),
|
|
752
|
+
});
|
|
753
|
+
});
|
|
754
|
+
|
|
755
|
+
describe('when variable is not set', () => {
|
|
756
|
+
beforeEach(() => delete process.env[variable]);
|
|
757
|
+
|
|
758
|
+
test('defines the variable as undefined', () => {
|
|
759
|
+
subject();
|
|
760
|
+
|
|
761
|
+
expect(DefinePlugin).toHaveBeenCalledWith({
|
|
762
|
+
[`process.env.${variable}`]: 'undefined',
|
|
763
|
+
});
|
|
764
|
+
});
|
|
765
|
+
});
|
|
766
|
+
});
|
|
684
767
|
});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import CssMinimizerWebpackPlugin from 'css-minimizer-webpack-plugin';
|
|
2
2
|
import TerserPlugin from 'terser-webpack-plugin';
|
|
3
3
|
import { Configuration } from 'webpack';
|
|
4
|
+
import { CHUNK_PATTERNS } from '../../core';
|
|
4
5
|
import { Overrides, WebpackBuildContext } from '../types';
|
|
5
6
|
|
|
6
7
|
type Config = Configuration['optimization'];
|
|
@@ -23,15 +24,26 @@ export function optimizationConfig(context: WebpackBuildContext, _: Overrides):
|
|
|
23
24
|
optimization.runtimeChunk = 'single';
|
|
24
25
|
}
|
|
25
26
|
|
|
26
|
-
[minimizeConfig, sharedDependenciesConfig, webComponentConfig].forEach(handler =>
|
|
27
|
+
[hostConfig, minimizeConfig, sharedDependenciesConfig, webComponentConfig].forEach(handler =>
|
|
27
28
|
handler(optimization, context)
|
|
28
29
|
);
|
|
29
30
|
|
|
30
31
|
return { optimization };
|
|
31
32
|
}
|
|
32
33
|
|
|
34
|
+
function hostConfig(optimization: ConfigWithCacheGroups, context: WebpackBuildContext) {
|
|
35
|
+
const { isProduction } = context.build;
|
|
36
|
+
const { isWebComponent } = context.package;
|
|
37
|
+
if (isWebComponent || !isProduction) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
Object.assign(optimization.splitChunks.cacheGroups, vendorGroups());
|
|
42
|
+
}
|
|
43
|
+
|
|
33
44
|
function minimizeConfig(optimization: ConfigWithCacheGroups, context: WebpackBuildContext) {
|
|
34
45
|
const { isProduction } = context.build;
|
|
46
|
+
const { isWebComponent } = context.package;
|
|
35
47
|
const { codeCoverage } = context.options;
|
|
36
48
|
const { minify } = context.bundlerConfig;
|
|
37
49
|
if (!isProduction) {
|
|
@@ -45,9 +57,13 @@ function minimizeConfig(optimization: ConfigWithCacheGroups, context: WebpackBui
|
|
|
45
57
|
return;
|
|
46
58
|
}
|
|
47
59
|
|
|
60
|
+
/*
|
|
61
|
+
* MFE source maps are available to Datadog, so compress and mangle are OK.
|
|
62
|
+
* Disable for hosts until their source maps are uploaded too.
|
|
63
|
+
*/
|
|
48
64
|
const terserOptions = {
|
|
49
|
-
compress:
|
|
50
|
-
mangle:
|
|
65
|
+
compress: !!isWebComponent,
|
|
66
|
+
mangle: !!isWebComponent,
|
|
51
67
|
...(typeof minifyJs === 'object' ? minifyJs : {}),
|
|
52
68
|
};
|
|
53
69
|
|
|
@@ -76,6 +92,8 @@ function sharedDependenciesConfig(
|
|
|
76
92
|
name: 'anvil2',
|
|
77
93
|
chunks: 'all',
|
|
78
94
|
enforce: true,
|
|
95
|
+
// Must outrank vendor groups so anvil2 CSS lands in separate chunk
|
|
96
|
+
priority: 10,
|
|
79
97
|
},
|
|
80
98
|
});
|
|
81
99
|
}
|
|
@@ -83,38 +101,42 @@ function sharedDependenciesConfig(
|
|
|
83
101
|
function webComponentConfig(optimization: ConfigWithCacheGroups, context: WebpackBuildContext) {
|
|
84
102
|
const { headless, isProduction } = context.build;
|
|
85
103
|
const { isWebComponent } = context.package;
|
|
86
|
-
if (!isWebComponent
|
|
104
|
+
if (!isWebComponent) {
|
|
87
105
|
return;
|
|
88
106
|
}
|
|
89
107
|
|
|
108
|
+
const groups = vendorGroups();
|
|
109
|
+
const styles = { name: 'main', type: 'css/mini-extract', chunks: 'all', enforce: true };
|
|
110
|
+
|
|
90
111
|
Object.assign(optimization.splitChunks.cacheGroups, {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
112
|
+
...(headless ? {} : { styles }),
|
|
113
|
+
// assets-manifest-plugin requires servicetitan to order CSS correctly (headless has no CSS)
|
|
114
|
+
...(isProduction ? groups : headless ? {} : { servicetitan: groups.servicetitan }),
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function vendorGroups() {
|
|
119
|
+
return {
|
|
120
|
+
'servicetitan': {
|
|
98
121
|
name: 'servicetitan',
|
|
99
|
-
test:
|
|
122
|
+
test: CHUNK_PATTERNS.servicetitan,
|
|
100
123
|
chunks: 'all',
|
|
101
124
|
},
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
return;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
Object.assign(optimization.splitChunks.cacheGroups, {
|
|
109
|
-
common: {
|
|
110
|
-
name: 'common',
|
|
111
|
-
test: /[\\/]node_modules[\\/](axios|classnames|formstate|mobx|mobx-react|mobx-utils|react|react-dom|react-router|react-router-dom)[\\/]/,
|
|
125
|
+
'vendor-core': {
|
|
126
|
+
name: 'vendor-core',
|
|
127
|
+
test: CHUNK_PATTERNS['vendor-core'],
|
|
112
128
|
chunks: 'all',
|
|
113
129
|
},
|
|
114
|
-
kendo: {
|
|
130
|
+
'kendo': {
|
|
115
131
|
name: 'kendo',
|
|
116
|
-
test:
|
|
132
|
+
test: CHUNK_PATTERNS.kendo,
|
|
117
133
|
chunks: 'all',
|
|
118
134
|
},
|
|
119
|
-
|
|
135
|
+
'vendor': {
|
|
136
|
+
name: 'vendor',
|
|
137
|
+
test: CHUNK_PATTERNS.vendor,
|
|
138
|
+
chunks: 'all',
|
|
139
|
+
priority: -5,
|
|
140
|
+
},
|
|
141
|
+
};
|
|
120
142
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Configuration } from 'webpack';
|
|
2
|
-
import { BuildContext, getBundleType, getCdnPath
|
|
2
|
+
import { BuildContext, getBundleType, getCdnPath } from '../../core';
|
|
3
3
|
import { Overrides } from '../types';
|
|
4
4
|
|
|
5
5
|
type Config = Configuration['output'];
|
|
@@ -11,7 +11,6 @@ export function outputConfig(context: BuildContext, _: Overrides): Result {
|
|
|
11
11
|
|
|
12
12
|
const output: Config = {
|
|
13
13
|
filename: '[name].bundle.js',
|
|
14
|
-
path: getOutputPath(context),
|
|
15
14
|
clean: getClean(context),
|
|
16
15
|
...(emitExposedDependencies ? { chunkLoadingGlobal: `sharedChunk${name}` } : {}),
|
|
17
16
|
};
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { WebpackAssetsManifest } from 'webpack-assets-manifest';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
BuildContext,
|
|
4
|
+
generateExposedDependenciesMetadata,
|
|
5
|
+
generateMetadata,
|
|
6
|
+
sortSharedCss,
|
|
7
|
+
} from '../../../core';
|
|
3
8
|
import { Overrides } from '../../types';
|
|
4
9
|
|
|
5
10
|
interface EntryPoints {
|
|
@@ -22,13 +27,15 @@ export function assetsManifestPlugin(context: BuildContext, _: Overrides) {
|
|
|
22
27
|
entrypoints: Record<string, { assets: Record<string, string[]> }>;
|
|
23
28
|
}): EntryPoints {
|
|
24
29
|
const getAssetsByType = (type: string) => {
|
|
25
|
-
|
|
30
|
+
const assetsForType = Object.values(assets.entrypoints).flatMap(
|
|
26
31
|
({ assets }) => assets[type] ?? []
|
|
27
32
|
);
|
|
33
|
+
// Dedupe chunks shared by entry points
|
|
34
|
+
return [...new Set(assetsForType)];
|
|
28
35
|
};
|
|
29
36
|
|
|
30
37
|
return {
|
|
31
|
-
css: ensureDesignSystemCssIsFirst(getAssetsByType('css')),
|
|
38
|
+
css: ensureDesignSystemCssIsFirst(context, getAssetsByType('css')),
|
|
32
39
|
js: getAssetsByType('js'),
|
|
33
40
|
};
|
|
34
41
|
},
|
|
@@ -43,7 +50,12 @@ export function assetsManifestPlugin(context: BuildContext, _: Overrides) {
|
|
|
43
50
|
});
|
|
44
51
|
}
|
|
45
52
|
|
|
46
|
-
function ensureDesignSystemCssIsFirst(cssAssets: string[]) {
|
|
53
|
+
function ensureDesignSystemCssIsFirst(context: BuildContext, cssAssets: string[]) {
|
|
54
|
+
if (context.build.emitExposedDependencies) {
|
|
55
|
+
return sortSharedCss(cssAssets);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// Put MFE's 'servicetitan' CSS chunk first to give custom CSS higher precedence
|
|
47
59
|
const offset = cssAssets.findIndex(name => name.startsWith('servicetitan'));
|
|
48
60
|
return offset > 0
|
|
49
61
|
? [cssAssets[offset], ...cssAssets.filter((_, index) => index !== offset)]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import os from 'os';
|
|
2
2
|
import path from 'path';
|
|
3
|
-
import { BuildContext,
|
|
3
|
+
import { BuildContext, bundleReportFileName, bundleReportTitle } from '../../../core';
|
|
4
4
|
import { Overrides } from '../../types';
|
|
5
5
|
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
|
|
6
6
|
|
|
@@ -11,29 +11,7 @@ export function bundleAnalyzerPlugin(context: BuildContext, _: Overrides) {
|
|
|
11
11
|
|
|
12
12
|
return new BundleAnalyzerPlugin({
|
|
13
13
|
analyzerMode: 'static',
|
|
14
|
-
reportFilename: path.join(os.tmpdir(),
|
|
15
|
-
reportTitle:
|
|
14
|
+
reportFilename: path.join(os.tmpdir(), `${bundleReportFileName(context)}.html`),
|
|
15
|
+
reportTitle: bundleReportTitle(context),
|
|
16
16
|
});
|
|
17
17
|
}
|
|
18
|
-
|
|
19
|
-
function getReportFileName(context: BuildContext) {
|
|
20
|
-
const type = getBundleType(context);
|
|
21
|
-
const qualifier = type ? `-${type}` : '';
|
|
22
|
-
return `${context.package.name}${qualifier}-bundle-${Date.now()}.html`;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function getReportTitle(context: BuildContext) {
|
|
26
|
-
const unscopedName = context.package.name.replace(/^@[^/]+\//, '');
|
|
27
|
-
const type = getBundleType(context);
|
|
28
|
-
const qualifier = type ? ` (${type})` : '';
|
|
29
|
-
return `${unscopedName}${qualifier} ${formatDate(new Date())}`;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function formatDate(date: Date) {
|
|
33
|
-
const yyyy = date.getFullYear();
|
|
34
|
-
const mm = date.getMonth() + 1;
|
|
35
|
-
const dd = date.getDate();
|
|
36
|
-
const HH = date.getHours();
|
|
37
|
-
const MM = date.getMinutes();
|
|
38
|
-
return `${yyyy}-${mm}-${dd} ${HH}:${MM}`;
|
|
39
|
-
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { DefinePlugin } from 'webpack';
|
|
2
|
+
import { BuildContext, getProcessEnv } from '../../../core';
|
|
3
|
+
import { Overrides } from '../../types';
|
|
4
|
+
|
|
5
|
+
export function defineProcessEnvPlugin(context: BuildContext, _: Overrides) {
|
|
6
|
+
const definitions = getProcessEnv(context);
|
|
7
|
+
if (definitions) {
|
|
8
|
+
return new DefinePlugin(definitions);
|
|
9
|
+
}
|
|
10
|
+
}
|