@servicetitan/startup 37.0.2 → 38.1.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/js-yaml.js +2 -2
- package/dist/cli/commands/build.d.ts.map +1 -1
- package/dist/cli/commands/build.js +22 -9
- package/dist/cli/commands/build.js.map +1 -1
- package/dist/cli/commands/bundle-package.d.ts +6 -0
- package/dist/cli/commands/bundle-package.d.ts.map +1 -0
- package/dist/cli/commands/bundle-package.js +59 -0
- package/dist/cli/commands/bundle-package.js.map +1 -0
- package/dist/cli/commands/bundle-vite.js +13 -4
- package/dist/cli/commands/bundle-vite.js.map +1 -1
- package/dist/cli/commands/bundle-webpack.js +13 -4
- package/dist/cli/commands/bundle-webpack.js.map +1 -1
- package/dist/cli/commands/clean.js +13 -4
- package/dist/cli/commands/clean.js.map +1 -1
- package/dist/cli/commands/command.d.ts +9 -0
- package/dist/cli/commands/command.d.ts.map +1 -0
- package/dist/cli/commands/command.js +35 -0
- package/dist/cli/commands/command.js.map +1 -0
- package/dist/cli/commands/convert-eslint-config.js +14 -7
- package/dist/cli/commands/convert-eslint-config.js.map +1 -1
- package/dist/cli/commands/eslint.js +13 -4
- package/dist/cli/commands/eslint.js.map +1 -1
- package/dist/cli/commands/init.js +13 -4
- package/dist/cli/commands/init.js.map +1 -1
- package/dist/cli/commands/install.js +13 -4
- package/dist/cli/commands/install.js.map +1 -1
- package/dist/cli/commands/kendo-ui-license.js +13 -4
- package/dist/cli/commands/kendo-ui-license.js.map +1 -1
- package/dist/cli/commands/lint.js +13 -4
- package/dist/cli/commands/lint.js.map +1 -1
- package/dist/cli/commands/mfe-check.d.ts.map +1 -1
- package/dist/cli/commands/mfe-check.js +15 -7
- package/dist/cli/commands/mfe-check.js.map +1 -1
- package/dist/cli/commands/mfe-generate-metadata.js +13 -4
- package/dist/cli/commands/mfe-generate-metadata.js.map +1 -1
- package/dist/cli/commands/mfe-list.js +13 -4
- package/dist/cli/commands/mfe-list.js.map +1 -1
- package/dist/cli/commands/mfe-package-clean.js +13 -4
- package/dist/cli/commands/mfe-package-clean.js.map +1 -1
- package/dist/cli/commands/mfe-package-publish.js +13 -4
- package/dist/cli/commands/mfe-package-publish.js.map +1 -1
- package/dist/cli/commands/mfe-package-rollback.js +13 -4
- package/dist/cli/commands/mfe-package-rollback.js.map +1 -1
- package/dist/cli/commands/mfe-publish.js +13 -4
- package/dist/cli/commands/mfe-publish.js.map +1 -1
- package/dist/cli/commands/mfe-purge-cache.js +13 -4
- package/dist/cli/commands/mfe-purge-cache.js.map +1 -1
- package/dist/cli/commands/prepare-package.js +13 -4
- package/dist/cli/commands/prepare-package.js.map +1 -1
- package/dist/cli/commands/registry/build.d.ts +1 -1
- package/dist/cli/commands/registry/build.d.ts.map +1 -1
- package/dist/cli/commands/registry/build.js +3 -5
- package/dist/cli/commands/registry/build.js.map +1 -1
- package/dist/cli/commands/registry/bundle-package.d.ts +41 -0
- package/dist/cli/commands/registry/bundle-package.d.ts.map +1 -0
- package/dist/cli/commands/registry/bundle-package.js +54 -0
- package/dist/cli/commands/registry/bundle-package.js.map +1 -0
- package/dist/cli/commands/registry/command-registry.d.ts +42 -2
- package/dist/cli/commands/registry/command-registry.d.ts.map +1 -1
- package/dist/cli/commands/registry/command-registry.js +10 -19
- package/dist/cli/commands/registry/command-registry.js.map +1 -1
- package/dist/cli/commands/registry/start.d.ts +1 -1
- package/dist/cli/commands/registry/start.d.ts.map +1 -1
- package/dist/cli/commands/registry/start.js +3 -5
- package/dist/cli/commands/registry/start.js.map +1 -1
- package/dist/cli/commands/review/review.js +14 -7
- package/dist/cli/commands/review/review.js.map +1 -1
- package/dist/cli/commands/review/rules/no-deprecated-content-base.js +1 -3
- package/dist/cli/commands/review/rules/no-deprecated-content-base.js.map +1 -1
- package/dist/cli/commands/review/rules/no-direct-peer-dependencies.js +1 -3
- package/dist/cli/commands/review/rules/no-direct-peer-dependencies.js.map +1 -1
- package/dist/cli/commands/review/rules/no-typescript-entry-point.js +1 -3
- package/dist/cli/commands/review/rules/no-typescript-entry-point.js.map +1 -1
- package/dist/cli/commands/review/rules/prefer-open-ended-peer-dependencies.js +5 -12
- package/dist/cli/commands/review/rules/prefer-open-ended-peer-dependencies.js.map +1 -1
- package/dist/cli/commands/review/rules/require-compatible-launch-darkly-sdk.js +5 -12
- package/dist/cli/commands/review/rules/require-compatible-launch-darkly-sdk.js.map +1 -1
- package/dist/cli/commands/review/rules/require-explicit-side-effects.js +1 -3
- package/dist/cli/commands/review/rules/require-explicit-side-effects.js.map +1 -1
- package/dist/cli/commands/review/rules/require-one-collection-version.js +1 -3
- package/dist/cli/commands/review/rules/require-one-collection-version.js.map +1 -1
- package/dist/cli/commands/review/rules/require-servicetitan-scope.js +1 -3
- package/dist/cli/commands/review/rules/require-servicetitan-scope.js.map +1 -1
- package/dist/cli/commands/review/rules/require-tsconfig-references.js +1 -3
- package/dist/cli/commands/review/rules/require-tsconfig-references.js.map +1 -1
- package/dist/cli/commands/review/types.d.ts.map +1 -1
- package/dist/cli/commands/review/types.js.map +1 -1
- package/dist/cli/commands/review/utils/compare-version.js +8 -19
- package/dist/cli/commands/review/utils/compare-version.js.map +1 -1
- package/dist/cli/commands/run-task.d.ts +1 -0
- package/dist/cli/commands/run-task.d.ts.map +1 -1
- package/dist/cli/commands/run-task.js +20 -6
- package/dist/cli/commands/run-task.js.map +1 -1
- package/dist/cli/commands/start.d.ts.map +1 -1
- package/dist/cli/commands/start.js +28 -13
- package/dist/cli/commands/start.js.map +1 -1
- package/dist/cli/commands/stylelint.js +13 -4
- package/dist/cli/commands/stylelint.js.map +1 -1
- package/dist/cli/commands/styles-check.js +13 -4
- package/dist/cli/commands/styles-check.js.map +1 -1
- package/dist/cli/commands/test/runners/jest.js +1 -3
- package/dist/cli/commands/test/runners/jest.js.map +1 -1
- package/dist/cli/commands/test/tests.js +13 -4
- package/dist/cli/commands/test/tests.js.map +1 -1
- package/dist/cli/commands/types.d.ts +1 -6
- package/dist/cli/commands/types.d.ts.map +1 -1
- package/dist/cli/commands/types.js +2 -20
- package/dist/cli/commands/types.js.map +1 -1
- package/dist/cli/commands/upload-sourcemaps.js +17 -13
- package/dist/cli/commands/upload-sourcemaps.js.map +1 -1
- package/dist/cli/index.js +1 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/tasks/cli-task.d.ts +3 -0
- package/dist/cli/tasks/cli-task.d.ts.map +1 -1
- package/dist/cli/tasks/cli-task.js +41 -9
- package/dist/cli/tasks/cli-task.js.map +1 -1
- package/dist/cli/tasks/swc-compile-package/get-swc-options.d.ts +9 -1
- package/dist/cli/tasks/swc-compile-package/get-swc-options.d.ts.map +1 -1
- package/dist/cli/tasks/swc-compile-package/get-swc-options.js +18 -2
- package/dist/cli/tasks/swc-compile-package/get-swc-options.js.map +1 -1
- package/dist/cli/tasks/swc-compile-package/swc-compile-package.d.ts +3 -1
- package/dist/cli/tasks/swc-compile-package/swc-compile-package.d.ts.map +1 -1
- package/dist/cli/tasks/swc-compile-package/swc-compile-package.js +17 -3
- package/dist/cli/tasks/swc-compile-package/swc-compile-package.js.map +1 -1
- package/dist/cli/tasks/task.d.ts +2 -1
- package/dist/cli/tasks/task.d.ts.map +1 -1
- package/dist/cli/tasks/task.js +6 -3
- package/dist/cli/tasks/task.js.map +1 -1
- package/dist/cli/tasks/tsc-compile/tsc-compile.js +1 -3
- package/dist/cli/tasks/tsc-compile/tsc-compile.js.map +1 -1
- package/dist/cli/utils/cli-npm.d.ts.map +1 -1
- package/dist/cli/utils/cli-npm.js +8 -1
- package/dist/cli/utils/cli-npm.js.map +1 -1
- package/dist/cli/utils/cli-os.d.ts +1 -0
- package/dist/cli/utils/cli-os.d.ts.map +1 -1
- package/dist/cli/utils/cli-os.js +20 -0
- package/dist/cli/utils/cli-os.js.map +1 -1
- package/dist/cli/utils/compile.d.ts.map +1 -1
- package/dist/cli/utils/compile.js +7 -4
- package/dist/cli/utils/compile.js.map +1 -1
- package/dist/cli/utils/copy-files.js +1 -0
- package/dist/cli/utils/copy-files.js.map +1 -1
- package/dist/cli/utils/index.d.ts +1 -1
- package/dist/cli/utils/index.d.ts.map +1 -1
- package/dist/cli/utils/index.js +1 -1
- package/dist/cli/utils/index.js.map +1 -1
- package/dist/cli/utils/process-tree.js +2 -6
- package/dist/cli/utils/process-tree.js.map +1 -1
- package/dist/cli/utils/resolve-bundler.d.ts.map +1 -1
- package/dist/cli/utils/resolve-bundler.js +2 -1
- package/dist/cli/utils/resolve-bundler.js.map +1 -1
- package/dist/cli/utils/ts-config.d.ts +1 -1
- package/dist/cli/utils/ts-config.d.ts.map +1 -1
- package/dist/cli/utils/ts-config.js +1 -3
- package/dist/cli/utils/ts-config.js.map +1 -1
- package/dist/cli/utils/with-exponential-backoff.d.ts +7 -0
- package/dist/cli/utils/with-exponential-backoff.d.ts.map +1 -0
- package/dist/cli/utils/with-exponential-backoff.js +28 -0
- package/dist/cli/utils/with-exponential-backoff.js.map +1 -0
- package/dist/core/constants.d.ts +2 -0
- package/dist/core/constants.d.ts.map +1 -1
- package/dist/core/constants.js +6 -1
- package/dist/core/constants.js.map +1 -1
- package/dist/cypress/config/vite-config.d.ts.map +1 -1
- package/dist/cypress/config/vite-config.js +23 -3
- package/dist/cypress/config/vite-config.js.map +1 -1
- package/dist/cypress/config/webpack-config.d.ts.map +1 -1
- package/dist/cypress/config/webpack-config.js +5 -0
- package/dist/cypress/config/webpack-config.js.map +1 -1
- package/dist/postinstall.js +118 -0
- package/dist/scripts/generate-bin-wrappers.js +203 -0
- package/dist/storybook-config/swc.d.ts +6 -0
- package/dist/storybook-config/swc.d.ts.map +1 -1
- package/dist/storybook-config/vite-final.d.ts.map +1 -1
- package/dist/storybook-config/vite-final.js +32 -6
- package/dist/storybook-config/vite-final.js.map +1 -1
- package/dist/storybook-config/webpack-final.d.ts.map +1 -1
- package/dist/storybook-config/webpack-final.js +3 -1
- package/dist/storybook-config/webpack-final.js.map +1 -1
- package/dist/utils/exit-when-parent-exits.d.ts +6 -0
- package/dist/utils/exit-when-parent-exits.d.ts.map +1 -0
- package/dist/utils/exit-when-parent-exits.js +37 -0
- package/dist/utils/exit-when-parent-exits.js.map +1 -0
- package/dist/utils/find-up.d.ts +1 -1
- package/dist/utils/find-up.d.ts.map +1 -1
- package/dist/utils/find-up.js +2 -2
- package/dist/utils/find-up.js.map +1 -1
- package/dist/utils/get-configuration.d.ts +6 -3
- package/dist/utils/get-configuration.d.ts.map +1 -1
- package/dist/utils/get-configuration.js +10 -2
- package/dist/utils/get-configuration.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 +1 -0
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/log.js +1 -3
- package/dist/utils/log.js.map +1 -1
- package/dist/vite/build-shared-dependencies.d.ts.map +1 -1
- package/dist/vite/build-shared-dependencies.js +2 -0
- package/dist/vite/build-shared-dependencies.js.map +1 -1
- package/dist/vite/config/base-config.d.ts.map +1 -1
- package/dist/vite/config/base-config.js +14 -1
- package/dist/vite/config/base-config.js.map +1 -1
- package/dist/vite/config/create-filtering-logger.d.ts.map +1 -1
- package/dist/vite/config/create-filtering-logger.js +12 -1
- package/dist/vite/config/create-filtering-logger.js.map +1 -1
- package/dist/vite/config/create-vite-build-context.d.ts.map +1 -1
- package/dist/vite/config/create-vite-build-context.js +4 -1
- package/dist/vite/config/create-vite-build-context.js.map +1 -1
- package/dist/vite/config/create-vite-config.js +7 -2
- package/dist/vite/config/create-vite-config.js.map +1 -1
- package/dist/vite/config/load-config-file.js +8 -19
- package/dist/vite/config/load-config-file.js.map +1 -1
- package/dist/vite/index.d.ts +2 -0
- package/dist/vite/index.d.ts.map +1 -1
- package/dist/vite/index.html +2 -2
- package/dist/vite/index.js +16 -0
- package/dist/vite/index.js.map +1 -1
- package/dist/vite/plugins/chain-source-maps-plugin.js +1 -1
- package/dist/vite/plugins/chain-source-maps-plugin.js.map +1 -1
- package/dist/vite/plugins/clean-plugin.js +1 -1
- package/dist/vite/plugins/clean-plugin.js.map +1 -1
- package/dist/vite/plugins/css-injector-plugin.js +1 -1
- package/dist/vite/plugins/css-injector-plugin.js.map +1 -1
- package/dist/vite/plugins/design-system-guard-plugin.d.ts.map +1 -1
- package/dist/vite/plugins/design-system-guard-plugin.js +10 -5
- package/dist/vite/plugins/design-system-guard-plugin.js.map +1 -1
- package/dist/vite/plugins/dev-server-routing-plugin.d.ts +1 -1
- package/dist/vite/plugins/dev-server-routing-plugin.d.ts.map +1 -1
- package/dist/vite/plugins/dev-server-routing-plugin.js +4 -3
- package/dist/vite/plugins/dev-server-routing-plugin.js.map +1 -1
- package/dist/vite/plugins/externals-plugin.d.ts.map +1 -1
- package/dist/vite/plugins/externals-plugin.js +11 -5
- package/dist/vite/plugins/externals-plugin.js.map +1 -1
- package/dist/vite/plugins/html-plugin.d.ts.map +1 -1
- package/dist/vite/plugins/html-plugin.js +5 -3
- package/dist/vite/plugins/html-plugin.js.map +1 -1
- package/dist/vite/plugins/ignore-modules-plugin.d.ts +2 -2
- package/dist/vite/plugins/ignore-modules-plugin.d.ts.map +1 -1
- package/dist/vite/plugins/ignore-modules-plugin.js +36 -24
- package/dist/vite/plugins/ignore-modules-plugin.js.map +1 -1
- package/dist/vite/plugins/index.d.ts +3 -0
- package/dist/vite/plugins/index.d.ts.map +1 -1
- package/dist/vite/plugins/index.js +3 -0
- package/dist/vite/plugins/index.js.map +1 -1
- package/dist/vite/plugins/istanbul-plugin.d.ts.map +1 -1
- package/dist/vite/plugins/istanbul-plugin.js +33 -1
- package/dist/vite/plugins/istanbul-plugin.js.map +1 -1
- package/dist/vite/plugins/less-tilde-plugin.d.ts +8 -0
- package/dist/vite/plugins/less-tilde-plugin.d.ts.map +1 -0
- package/dist/vite/plugins/less-tilde-plugin.js +53 -0
- package/dist/vite/plugins/less-tilde-plugin.js.map +1 -0
- package/dist/vite/plugins/magic-comments-plugin/magic-comments-plugin.js +1 -1
- package/dist/vite/plugins/magic-comments-plugin/magic-comments-plugin.js.map +1 -1
- package/dist/vite/plugins/metadata-plugin.js +1 -1
- package/dist/vite/plugins/metadata-plugin.js.map +1 -1
- package/dist/vite/plugins/moment-locales-plugin.d.ts +1 -1
- package/dist/vite/plugins/moment-locales-plugin.d.ts.map +1 -1
- package/dist/vite/plugins/moment-locales-plugin.js +30 -14
- package/dist/vite/plugins/moment-locales-plugin.js.map +1 -1
- package/dist/vite/plugins/react-refresh-plugin/index.d.ts +2 -0
- package/dist/vite/plugins/react-refresh-plugin/index.d.ts.map +1 -0
- package/dist/vite/plugins/react-refresh-plugin/index.js +20 -0
- package/dist/vite/plugins/react-refresh-plugin/index.js.map +1 -0
- package/dist/vite/plugins/react-refresh-plugin/react-refresh-plugin.d.ts +4 -0
- package/dist/vite/plugins/react-refresh-plugin/react-refresh-plugin.d.ts.map +1 -0
- package/dist/vite/plugins/react-refresh-plugin/react-refresh-plugin.js +143 -0
- package/dist/vite/plugins/react-refresh-plugin/react-refresh-plugin.js.map +1 -0
- package/dist/vite/plugins/react-refresh-plugin/refresh-runtime.js +113 -0
- package/dist/vite/plugins/shared-dependencies-plugin/shared-dependencies-plugin.d.ts.map +1 -1
- package/dist/vite/plugins/shared-dependencies-plugin/shared-dependencies-plugin.js +14 -11
- package/dist/vite/plugins/shared-dependencies-plugin/shared-dependencies-plugin.js.map +1 -1
- package/dist/vite/plugins/style-urls-plugin.js +1 -1
- package/dist/vite/plugins/style-urls-plugin.js.map +1 -1
- package/dist/vite/plugins/virtual-modules-plugin.d.ts.map +1 -1
- package/dist/vite/plugins/virtual-modules-plugin.js +9 -6
- package/dist/vite/plugins/virtual-modules-plugin.js.map +1 -1
- package/dist/vite/plugins/window-externals-plugin.d.ts +22 -0
- package/dist/vite/plugins/window-externals-plugin.d.ts.map +1 -0
- package/dist/vite/plugins/window-externals-plugin.js +74 -0
- package/dist/vite/plugins/window-externals-plugin.js.map +1 -0
- package/dist/vite/types.d.ts +4 -1
- package/dist/vite/types.d.ts.map +1 -1
- package/dist/webpack/bundle-webpack.d.ts.map +1 -1
- package/dist/webpack/bundle-webpack.js +6 -1
- package/dist/webpack/bundle-webpack.js.map +1 -1
- package/dist/webpack/configs/optimization-config.js +4 -4
- package/dist/webpack/configs/optimization-config.js.map +1 -1
- package/dist/webpack/configs/output-config.js +1 -1
- package/dist/webpack/configs/output-config.js.map +1 -1
- package/dist/webpack/configs/plugins/ignore-plugin/ignore-plugin.js +1 -3
- package/dist/webpack/configs/plugins/ignore-plugin/ignore-plugin.js.map +1 -1
- package/dist/webpack/loaders/expose-loader/__tests__/__mocks__/configuration.expose-loader.js +13 -0
- package/dist/webpack/loaders/expose-loader/__tests__/__mocks__/index.js +1 -0
- package/dist/webpack/utils/index.d.ts +1 -0
- package/dist/webpack/utils/index.d.ts.map +1 -1
- package/dist/webpack/utils/index.js +1 -0
- package/dist/webpack/utils/index.js.map +1 -1
- package/dist/webpack/utils/normalize-proxy-config.d.ts +6 -0
- package/dist/webpack/utils/normalize-proxy-config.d.ts.map +1 -0
- package/dist/webpack/utils/normalize-proxy-config.js +52 -0
- package/dist/webpack/utils/normalize-proxy-config.js.map +1 -0
- package/package.json +25 -22
- package/src/cli/commands/__tests__/build.test.ts +33 -19
- package/src/cli/commands/__tests__/bundle-package.test.ts +65 -0
- package/src/cli/commands/__tests__/bundle-vite.test.ts +1 -0
- package/src/cli/commands/__tests__/command.test.ts +42 -0
- package/src/cli/commands/__tests__/mfe-check.test.ts +26 -5
- package/src/cli/commands/__tests__/run-task.test.ts +20 -1
- package/src/cli/commands/__tests__/start.test.ts +35 -15
- package/src/cli/commands/build.ts +6 -5
- package/src/cli/commands/bundle-package.ts +20 -0
- package/src/cli/commands/command.ts +14 -0
- package/src/cli/commands/mfe-check.ts +6 -10
- package/src/cli/commands/registry/build.ts +3 -2
- package/src/cli/commands/registry/bundle-package.ts +22 -0
- package/src/cli/commands/registry/command-registry.ts +2 -0
- package/src/cli/commands/registry/start.ts +3 -2
- package/src/cli/commands/review/types.ts +1 -3
- package/src/cli/commands/run-task.ts +8 -2
- package/src/cli/commands/start.ts +9 -5
- package/src/cli/commands/types.ts +2 -6
- package/src/cli/index.ts +3 -0
- package/src/cli/tasks/__tests__/cli-task.test.ts +181 -69
- package/src/cli/tasks/__tests__/task.test.ts +40 -45
- package/src/cli/tasks/cli-task.ts +43 -2
- package/src/cli/tasks/swc-compile-package/__tests__/get-swc-options.test.ts +46 -4
- package/src/cli/tasks/swc-compile-package/__tests__/swc-compile-package.test.ts +25 -4
- package/src/cli/tasks/swc-compile-package/get-swc-options.ts +14 -1
- package/src/cli/tasks/swc-compile-package/swc-compile-package.ts +6 -2
- package/src/cli/tasks/task.ts +8 -2
- package/src/cli/tasks/tsc-compile/__tests__/tsc-compile.test.ts +8 -32
- package/src/cli/tasks/tsc-compile-package/__tests__/tsc-compile-package.test.ts +10 -19
- package/src/cli/utils/__tests__/cli-npm.test.ts +33 -0
- package/src/cli/utils/__tests__/cli-os.test.ts +86 -3
- package/src/cli/utils/__tests__/compile.test.ts +37 -2
- package/src/cli/utils/__tests__/copy-files.test.ts +1 -1
- package/src/cli/utils/__tests__/with-exponential-backoff.test.ts +119 -0
- package/src/cli/utils/cli-npm.ts +19 -4
- package/src/cli/utils/cli-os.ts +14 -0
- package/src/cli/utils/compile.ts +8 -1
- package/src/cli/utils/copy-files.ts +1 -1
- package/src/cli/utils/index.ts +1 -1
- package/src/cli/utils/resolve-bundler.ts +2 -1
- package/src/cli/utils/ts-config.ts +1 -1
- package/src/cli/utils/with-exponential-backoff.ts +28 -0
- package/src/core/constants.ts +2 -0
- package/src/cypress/config/__tests__/vite-config.test.ts +21 -11
- package/src/cypress/config/__tests__/webpack-config.test.ts +17 -0
- package/src/cypress/config/vite-config.ts +18 -3
- package/src/cypress/config/webpack-config.ts +2 -0
- package/src/storybook-config/__tests__/vite-final.test.ts +71 -11
- package/src/storybook-config/__tests__/webpack-final.test.ts +30 -6
- package/src/storybook-config/vite-final.ts +23 -2
- package/src/storybook-config/webpack-final.ts +10 -2
- package/src/utils/__tests__/exit-when-parent-exits.test.ts +87 -0
- package/src/utils/__tests__/find-up.test.ts +49 -0
- package/src/utils/__tests__/get-configuration.test.ts +62 -0
- package/src/utils/exit-when-parent-exits.ts +33 -0
- package/src/utils/find-up.ts +2 -2
- package/src/utils/get-configuration.ts +14 -5
- package/src/utils/index.ts +1 -0
- package/src/vite/__tests__/build-shared-dependencies.test.ts +39 -5
- package/src/vite/build-shared-dependencies.ts +2 -1
- package/src/vite/config/__tests__/base-config.test.ts +16 -4
- package/src/vite/config/__tests__/create-css-config.test.ts +2 -6
- package/src/vite/config/__tests__/create-filtering-logger.test.ts +9 -0
- package/src/vite/config/__tests__/create-vite-build-context.test.ts +25 -0
- package/src/vite/config/__tests__/create-vite-config.test.ts +6 -3
- package/src/vite/config/base-config.ts +18 -2
- package/src/vite/config/create-filtering-logger.ts +13 -2
- package/src/vite/config/create-vite-build-context.ts +1 -0
- package/src/vite/config/create-vite-config.ts +6 -3
- package/src/vite/index.html +2 -2
- package/src/vite/index.ts +2 -0
- package/src/vite/plugins/__tests__/chain-source-maps-plugin.test.ts +1 -1
- package/src/vite/plugins/__tests__/clean-plugin.test.ts +1 -1
- package/src/vite/plugins/__tests__/css-injector-plugin.test.ts +1 -1
- package/src/vite/plugins/__tests__/design-system-guard-plugin.test.ts +15 -3
- package/src/vite/plugins/__tests__/dev-server-routing-plugin.test.ts +121 -99
- package/src/vite/plugins/__tests__/externals-plugin.test.ts +24 -3
- package/src/vite/plugins/__tests__/html-plugin.test.ts +10 -3
- package/src/vite/plugins/__tests__/html-template.test.ts +10 -2
- package/src/vite/plugins/__tests__/ignore-modules-plugin.test.ts +30 -6
- package/src/vite/plugins/__tests__/istanbul-plugin.test.ts +42 -1
- package/src/vite/plugins/__tests__/less-tilde-plugin.test.ts +91 -0
- package/src/vite/plugins/__tests__/metadata-plugin.test.ts +1 -1
- package/src/vite/plugins/__tests__/moment-locales-plugin.test.ts +35 -25
- package/src/vite/plugins/__tests__/style-urls-plugin.test.ts +1 -1
- package/src/vite/plugins/__tests__/virtual-modules-plugin.test.ts +20 -9
- package/src/vite/plugins/__tests__/window-externals-plugin.test.ts +128 -0
- package/src/vite/plugins/chain-source-maps-plugin.ts +1 -1
- package/src/vite/plugins/clean-plugin.ts +1 -1
- package/src/vite/plugins/css-injector-plugin.ts +1 -1
- package/src/vite/plugins/design-system-guard-plugin.ts +11 -8
- package/src/vite/plugins/dev-server-routing-plugin.ts +4 -4
- package/src/vite/plugins/externals-plugin.ts +15 -6
- package/src/vite/plugins/html-plugin.ts +4 -2
- package/src/vite/plugins/ignore-modules-plugin.ts +32 -23
- package/src/vite/plugins/index.ts +3 -0
- package/src/vite/plugins/istanbul-plugin.ts +28 -1
- package/src/vite/plugins/less-tilde-plugin.ts +64 -0
- package/src/vite/plugins/magic-comments-plugin/magic-comments-plugin.ts +1 -1
- package/src/vite/plugins/metadata-plugin.ts +1 -1
- package/src/vite/plugins/moment-locales-plugin.ts +24 -14
- package/src/vite/plugins/react-refresh-plugin/README.md +165 -0
- package/src/vite/plugins/react-refresh-plugin/__tests__/react-refresh-plugin.test.ts +366 -0
- package/src/vite/plugins/react-refresh-plugin/__tests__/refresh-runtime.test.ts +193 -0
- package/src/vite/plugins/react-refresh-plugin/index.ts +1 -0
- package/src/vite/plugins/react-refresh-plugin/react-refresh-plugin.ts +144 -0
- package/src/vite/plugins/react-refresh-plugin/refresh-runtime.js +113 -0
- package/src/vite/plugins/shared-dependencies-plugin/__tests__/shared-dependencies-plugin.test.ts +21 -16
- package/src/vite/plugins/shared-dependencies-plugin/shared-dependencies-plugin.ts +13 -12
- package/src/vite/plugins/style-urls-plugin.ts +1 -1
- package/src/vite/plugins/virtual-modules-plugin.ts +8 -7
- package/src/vite/plugins/window-externals-plugin.ts +94 -0
- package/src/vite/types.ts +4 -1
- package/src/webpack/__tests__/bundle-webpack.test.ts +32 -0
- package/src/webpack/__tests__/create-webpack-config-web-component.test.ts +17 -5
- package/src/webpack/__tests__/create-webpack-config.test.ts +10 -6
- package/src/webpack/bundle-webpack.ts +7 -1
- package/src/webpack/configs/optimization-config.ts +3 -3
- package/src/webpack/configs/output-config.ts +1 -1
- package/src/webpack/utils/__tests__/normalize-proxy-config.test.ts +121 -0
- package/src/webpack/utils/index.ts +1 -0
- package/src/webpack/utils/normalize-proxy-config.ts +59 -0
- package/tsconfig/types.d.ts +10 -0
- package/dist/cli/utils/get-bundle-command.d.ts +0 -3
- package/dist/cli/utils/get-bundle-command.d.ts.map +0 -1
- package/dist/cli/utils/get-bundle-command.js +0 -16
- package/dist/cli/utils/get-bundle-command.js.map +0 -1
- package/src/cli/utils/__tests__/get-bundle-command.test.ts +0 -23
- package/src/cli/utils/get-bundle-command.ts +0 -5
|
@@ -1,26 +1,52 @@
|
|
|
1
1
|
import type { InlineConfig } from 'vite';
|
|
2
2
|
import { createCssConfig } from '../../vite/config/create-css-config';
|
|
3
|
-
import {
|
|
3
|
+
import { createFilteringLogger } from '../../vite/config/create-filtering-logger';
|
|
4
|
+
import { ignoreModulesPlugin, svgrPlugin } from '../../vite/plugins';
|
|
4
5
|
import { viteFinal } from '../vite-final';
|
|
5
6
|
|
|
6
|
-
jest.mock('../../vite/plugins
|
|
7
|
+
jest.mock('../../vite/plugins');
|
|
8
|
+
jest.mock('../../vite/config/create-filtering-logger');
|
|
9
|
+
jest.mock('../../vite/config/create-css-config', () => ({
|
|
10
|
+
createCssConfig: jest.fn(() => ({
|
|
11
|
+
modules: { localsConvention: 'camelCaseOnly' },
|
|
12
|
+
preprocessorOptions: { less: { math: 'always' } },
|
|
13
|
+
})),
|
|
14
|
+
}));
|
|
7
15
|
|
|
8
16
|
describe(`[startup/storybook-config] ${viteFinal.name}`, () => {
|
|
9
|
-
const mockSvgrPlugin = { name: 'vite-plugin-svgr' }
|
|
17
|
+
const mockSvgrPlugin: any = { name: 'vite-plugin-svgr' };
|
|
18
|
+
const mockIgnoreModulesPlugin: any = { name: 'ignore-modules' };
|
|
19
|
+
const mockFilteringLogger: any = { name: 'filteringLoggeer' };
|
|
10
20
|
let config: InlineConfig;
|
|
11
21
|
let configType: 'DEVELOPMENT' | 'PRODUCTION' | undefined;
|
|
12
22
|
|
|
13
23
|
beforeEach(() => {
|
|
14
24
|
jest.clearAllMocks();
|
|
15
25
|
jest.mocked(svgrPlugin).mockReturnValue(mockSvgrPlugin);
|
|
26
|
+
jest.mocked(ignoreModulesPlugin).mockReturnValue(mockIgnoreModulesPlugin);
|
|
27
|
+
jest.mocked(createFilteringLogger).mockReturnValue(mockFilteringLogger);
|
|
16
28
|
config = {};
|
|
17
29
|
configType = undefined;
|
|
18
30
|
});
|
|
19
31
|
|
|
20
32
|
const subject = () => viteFinal(config, { configType });
|
|
21
33
|
|
|
22
|
-
test('adds svgr plugin', () => {
|
|
23
|
-
expect(subject()).
|
|
34
|
+
test('adds the svgr plugin', () => {
|
|
35
|
+
expect(subject().plugins).toContain(mockSvgrPlugin);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
test('adds the ignore-modules plugin', () => {
|
|
39
|
+
expect(subject().plugins).toContain(mockIgnoreModulesPlugin);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
test('adds the filtering logger', () => {
|
|
43
|
+
expect(subject().customLogger).toBe(mockFilteringLogger);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
test('registers the ignore-modules plugin for the dependency pre-bundler', () => {
|
|
47
|
+
expect(subject().optimizeDeps!.rolldownOptions).toEqual({
|
|
48
|
+
plugins: [mockIgnoreModulesPlugin],
|
|
49
|
+
});
|
|
24
50
|
});
|
|
25
51
|
|
|
26
52
|
test('dedupes react', () => {
|
|
@@ -30,11 +56,11 @@ describe(`[startup/storybook-config] ${viteFinal.name}`, () => {
|
|
|
30
56
|
});
|
|
31
57
|
|
|
32
58
|
test('pre-bundles react', () => {
|
|
33
|
-
expect(subject()).toEqual(
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
);
|
|
59
|
+
expect(subject().optimizeDeps!.include).toEqual([
|
|
60
|
+
'react',
|
|
61
|
+
'react-dom',
|
|
62
|
+
'react/jsx-runtime',
|
|
63
|
+
]);
|
|
38
64
|
});
|
|
39
65
|
|
|
40
66
|
describe.each([
|
|
@@ -90,7 +116,9 @@ describe(`[startup/storybook-config] ${viteFinal.name}`, () => {
|
|
|
90
116
|
|
|
91
117
|
test('preserves existing plugins', () => {
|
|
92
118
|
expect(subject()).toEqual(
|
|
93
|
-
expect.objectContaining({
|
|
119
|
+
expect.objectContaining({
|
|
120
|
+
plugins: [existingPlugin, mockSvgrPlugin, mockIgnoreModulesPlugin],
|
|
121
|
+
})
|
|
94
122
|
);
|
|
95
123
|
});
|
|
96
124
|
});
|
|
@@ -119,4 +147,36 @@ describe(`[startup/storybook-config] ${viteFinal.name}`, () => {
|
|
|
119
147
|
]);
|
|
120
148
|
});
|
|
121
149
|
});
|
|
150
|
+
|
|
151
|
+
describe('when config already contains optimizeDeps.rolldownOptions', () => {
|
|
152
|
+
const existingPlugin = { name: 'existing' };
|
|
153
|
+
|
|
154
|
+
beforeEach(() => {
|
|
155
|
+
config = {
|
|
156
|
+
optimizeDeps: { rolldownOptions: { plugins: [existingPlugin] } },
|
|
157
|
+
};
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
test('preserves existing rolldownOptions plugins', () => {
|
|
161
|
+
expect(subject().optimizeDeps!.rolldownOptions).toEqual({
|
|
162
|
+
plugins: [existingPlugin, mockIgnoreModulesPlugin],
|
|
163
|
+
});
|
|
164
|
+
});
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
describe('when config already contains a single (non-array) rolldownOptions plugin', () => {
|
|
168
|
+
const existingPlugin = { name: 'existing' };
|
|
169
|
+
|
|
170
|
+
beforeEach(() => {
|
|
171
|
+
config = {
|
|
172
|
+
optimizeDeps: { rolldownOptions: { plugins: existingPlugin } },
|
|
173
|
+
};
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
test('preserves the existing rolldownOptions plugin', () => {
|
|
177
|
+
expect(subject().optimizeDeps!.rolldownOptions).toEqual({
|
|
178
|
+
plugins: [existingPlugin, mockIgnoreModulesPlugin],
|
|
179
|
+
});
|
|
180
|
+
});
|
|
181
|
+
});
|
|
122
182
|
});
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import type { Configuration } from 'webpack';
|
|
2
2
|
import { rulesConfig } from '../../webpack/configs';
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
filterWarningsPlugin,
|
|
5
|
+
ignorePlugin,
|
|
6
|
+
miniCssExtractPlugin,
|
|
7
|
+
} from '../../webpack/configs/plugins';
|
|
4
8
|
import { Overrides } from '../../webpack/types';
|
|
5
9
|
import { webpackFinal } from '../webpack-final';
|
|
6
10
|
|
|
@@ -18,6 +22,8 @@ describe(`[startup/storybook-config] ${webpackFinal.name}`, () => {
|
|
|
18
22
|
{ test: /\.svg$/, use: ['svg-loader'] },
|
|
19
23
|
{ test: /\.css$/, use: ['css-loader'] },
|
|
20
24
|
];
|
|
25
|
+
const mockFilterWarningsPlugin: any = { name: 'FilterWarningsPlugin' };
|
|
26
|
+
const mockIgnorePlugin: any = { name: 'IgnorePlugin' };
|
|
21
27
|
const mockMiniCssExtractPlugin: any = { name: 'MiniCssExtractPlugin' };
|
|
22
28
|
let config: Configuration;
|
|
23
29
|
let overrides: Overrides | undefined;
|
|
@@ -25,6 +31,8 @@ describe(`[startup/storybook-config] ${webpackFinal.name}`, () => {
|
|
|
25
31
|
beforeEach(() => {
|
|
26
32
|
jest.clearAllMocks();
|
|
27
33
|
jest.mocked(rulesConfig).mockReturnValue({ rules: mockRules });
|
|
34
|
+
jest.mocked(filterWarningsPlugin).mockReturnValue(mockFilterWarningsPlugin);
|
|
35
|
+
jest.mocked(ignorePlugin).mockReturnValue(mockIgnorePlugin);
|
|
28
36
|
jest.mocked(miniCssExtractPlugin).mockReturnValue(mockMiniCssExtractPlugin);
|
|
29
37
|
config = {};
|
|
30
38
|
overrides = undefined;
|
|
@@ -51,8 +59,16 @@ describe(`[startup/storybook-config] ${webpackFinal.name}`, () => {
|
|
|
51
59
|
);
|
|
52
60
|
});
|
|
53
61
|
|
|
62
|
+
test('adds FilterWarningPlugin to config', () => {
|
|
63
|
+
expect(subject().plugins).toContain(mockFilterWarningsPlugin);
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
test('adds IgnorePlugin to config', () => {
|
|
67
|
+
expect(subject().plugins).toContain(mockIgnorePlugin);
|
|
68
|
+
});
|
|
69
|
+
|
|
54
70
|
test('adds MiniCssExtractPlugin to config', () => {
|
|
55
|
-
expect(subject().plugins).
|
|
71
|
+
expect(subject().plugins).toContain(mockMiniCssExtractPlugin);
|
|
56
72
|
});
|
|
57
73
|
|
|
58
74
|
describe('when config contains rules', () => {
|
|
@@ -70,18 +86,26 @@ describe(`[startup/storybook-config] ${webpackFinal.name}`, () => {
|
|
|
70
86
|
|
|
71
87
|
describe('when config contains plugins', () => {
|
|
72
88
|
const configPlugin: any = { name: 'MockPlugin' };
|
|
89
|
+
const defaultPlugIns = [
|
|
90
|
+
mockMiniCssExtractPlugin,
|
|
91
|
+
mockIgnorePlugin,
|
|
92
|
+
mockFilterWarningsPlugin,
|
|
93
|
+
];
|
|
73
94
|
|
|
74
95
|
beforeEach(() => (config.plugins = [configPlugin]));
|
|
75
96
|
|
|
76
|
-
test('appends
|
|
77
|
-
expect(subject().plugins).toEqual([configPlugin,
|
|
97
|
+
test('appends default plugins to config', () => {
|
|
98
|
+
expect(subject().plugins).toEqual([configPlugin, ...defaultPlugIns]);
|
|
78
99
|
});
|
|
79
100
|
|
|
80
101
|
describe('when MiniCssExtractPlugin is disabled', () => {
|
|
81
102
|
beforeEach(() => jest.mocked(miniCssExtractPlugin).mockReturnValue(undefined));
|
|
82
103
|
|
|
83
|
-
test('
|
|
84
|
-
expect(subject().plugins).toEqual(
|
|
104
|
+
test('omits plugin', () => {
|
|
105
|
+
expect(subject().plugins).toEqual([
|
|
106
|
+
configPlugin,
|
|
107
|
+
...defaultPlugIns.filter(plugin => plugin !== mockMiniCssExtractPlugin),
|
|
108
|
+
]);
|
|
85
109
|
});
|
|
86
110
|
});
|
|
87
111
|
});
|
|
@@ -2,7 +2,8 @@ import { inspect } from 'node:util';
|
|
|
2
2
|
import type { InlineConfig } from 'vite';
|
|
3
3
|
import { log } from '../utils';
|
|
4
4
|
import { createCssConfig } from '../vite/config/create-css-config';
|
|
5
|
-
import {
|
|
5
|
+
import { createFilteringLogger } from '../vite/config/create-filtering-logger';
|
|
6
|
+
import { ignoreModulesPlugin, svgrPlugin } from '../vite/plugins';
|
|
6
7
|
import type { ViteBuildContext } from '../vite/types';
|
|
7
8
|
|
|
8
9
|
interface ViteFinalOptions {
|
|
@@ -27,7 +28,11 @@ export function viteFinal(
|
|
|
27
28
|
): InlineConfig {
|
|
28
29
|
const isProduction = configType === 'PRODUCTION';
|
|
29
30
|
const css = createCssConfig(isProduction);
|
|
30
|
-
const plugins = [
|
|
31
|
+
const plugins = [
|
|
32
|
+
svgrPlugin(getContext()),
|
|
33
|
+
ignoreModulesPlugin({ package: { dependencies: {} } }),
|
|
34
|
+
];
|
|
35
|
+
const existingRolldownPlugins = config.optimizeDeps?.rolldownOptions?.plugins;
|
|
31
36
|
|
|
32
37
|
const merged: InlineConfig = {
|
|
33
38
|
...config,
|
|
@@ -46,8 +51,24 @@ export function viteFinal(
|
|
|
46
51
|
optimizeDeps: {
|
|
47
52
|
...config.optimizeDeps,
|
|
48
53
|
include: [...new Set([...(config.optimizeDeps?.include ?? []), ...REACT_OPTIMIZE])],
|
|
54
|
+
/*
|
|
55
|
+
* Top-level plugins don't run during dependency pre-bundling, so
|
|
56
|
+
* register ignoreModulesPlugin again here. Without this, missing
|
|
57
|
+
* optional peer dependencies inside pre-bundled packages throw at
|
|
58
|
+
* runtime instead of resolving to an empty module.
|
|
59
|
+
*/
|
|
60
|
+
rolldownOptions: {
|
|
61
|
+
...config.optimizeDeps?.rolldownOptions,
|
|
62
|
+
plugins: [
|
|
63
|
+
...(Array.isArray(existingRolldownPlugins)
|
|
64
|
+
? existingRolldownPlugins
|
|
65
|
+
: [existingRolldownPlugins].filter(Boolean)),
|
|
66
|
+
ignoreModulesPlugin({ package: { dependencies: {} } }),
|
|
67
|
+
],
|
|
68
|
+
},
|
|
49
69
|
},
|
|
50
70
|
plugins: [...(config.plugins ?? []), ...plugins],
|
|
71
|
+
customLogger: createFilteringLogger(),
|
|
51
72
|
};
|
|
52
73
|
|
|
53
74
|
/* istanbul ignore next: debug only */
|
|
@@ -3,7 +3,11 @@ import { inspect } from 'node:util';
|
|
|
3
3
|
import type { Configuration } from 'webpack';
|
|
4
4
|
import { log } from '../utils';
|
|
5
5
|
import { rulesConfig } from '../webpack/configs';
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
filterWarningsPlugin,
|
|
8
|
+
ignorePlugin,
|
|
9
|
+
miniCssExtractPlugin,
|
|
10
|
+
} from '../webpack/configs/plugins';
|
|
7
11
|
import { Overrides, WebpackBuildContext } from '../webpack/types';
|
|
8
12
|
|
|
9
13
|
export function webpackFinal(config: Configuration, overrides: Overrides = {}): Configuration {
|
|
@@ -48,7 +52,11 @@ function getContext(config: Configuration): WebpackBuildContext {
|
|
|
48
52
|
}
|
|
49
53
|
|
|
50
54
|
function getPlugins(context: WebpackBuildContext, overrides: Overrides) {
|
|
51
|
-
return [
|
|
55
|
+
return [
|
|
56
|
+
miniCssExtractPlugin(context, overrides),
|
|
57
|
+
ignorePlugin(context, {}),
|
|
58
|
+
filterWarningsPlugin(context, {}),
|
|
59
|
+
].filter(plugin => !!plugin);
|
|
52
60
|
}
|
|
53
61
|
|
|
54
62
|
function getRules(context: WebpackBuildContext, overrides: Overrides) {
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jest-environment node
|
|
3
|
+
*/
|
|
4
|
+
import { exitWhenParentExits } from '../exit-when-parent-exits';
|
|
5
|
+
import { log } from '../log';
|
|
6
|
+
|
|
7
|
+
jest.mock('../log', () => ({ log: { info: jest.fn() } }));
|
|
8
|
+
|
|
9
|
+
describe(`[startup] ${exitWhenParentExits.name}`, () => {
|
|
10
|
+
const command = 'some-task';
|
|
11
|
+
const parentPid = 4321;
|
|
12
|
+
let callback: (() => void) | undefined;
|
|
13
|
+
let killSpy: jest.SpyInstance;
|
|
14
|
+
let exitSpy: jest.SpyInstance;
|
|
15
|
+
|
|
16
|
+
beforeEach(() => {
|
|
17
|
+
jest.clearAllMocks();
|
|
18
|
+
jest.useFakeTimers();
|
|
19
|
+
callback = undefined;
|
|
20
|
+
killSpy = jest.spyOn(process, 'kill').mockImplementation(jest.fn());
|
|
21
|
+
exitSpy = jest.spyOn(process, 'exit').mockImplementation(jest.fn() as any);
|
|
22
|
+
process.env.STARTUP_PARENT_PID = String(parentPid);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
afterEach(() => {
|
|
26
|
+
jest.useRealTimers();
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
const subject = () => {
|
|
30
|
+
exitWhenParentExits(command, callback);
|
|
31
|
+
jest.advanceTimersByTime(1000);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
test('polls whether the parent process is still running', () => {
|
|
35
|
+
subject();
|
|
36
|
+
|
|
37
|
+
expect(killSpy).toHaveBeenCalledWith(parentPid, 0);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
describe('with no process.env.STARTUP_PARENT_PID', () => {
|
|
41
|
+
beforeEach(() => delete process.env.STARTUP_PARENT_PID);
|
|
42
|
+
|
|
43
|
+
test('does not poll', () => {
|
|
44
|
+
subject();
|
|
45
|
+
|
|
46
|
+
expect(killSpy).not.toHaveBeenCalled();
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
describe('when the parent process has exited', () => {
|
|
51
|
+
beforeEach(() => {
|
|
52
|
+
killSpy.mockImplementation(() => {
|
|
53
|
+
throw new Error('ESRCH');
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
test('logs shutdown message', () => {
|
|
58
|
+
subject();
|
|
59
|
+
|
|
60
|
+
expect(log.info).toHaveBeenCalledWith(`${command} shutting down`);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
test('exits the process', () => {
|
|
64
|
+
subject();
|
|
65
|
+
|
|
66
|
+
expect(exitSpy).toHaveBeenCalledWith(0);
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
describe('with a callback', () => {
|
|
70
|
+
beforeEach(() => (callback = jest.fn()));
|
|
71
|
+
|
|
72
|
+
test('does not exit the process', () => {
|
|
73
|
+
subject();
|
|
74
|
+
|
|
75
|
+
expect(exitSpy).not.toHaveBeenCalled();
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
test('calls the callback', () => {
|
|
79
|
+
subject();
|
|
80
|
+
|
|
81
|
+
jest.advanceTimersByTime(1000);
|
|
82
|
+
|
|
83
|
+
expect(callback).toHaveBeenCalled();
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
});
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import { findUp } from '../find-up';
|
|
3
|
+
|
|
4
|
+
describe(findUp.name, () => {
|
|
5
|
+
let callback: jest.Mock;
|
|
6
|
+
let from: string | undefined;
|
|
7
|
+
|
|
8
|
+
const subject = () => findUp(callback, from);
|
|
9
|
+
|
|
10
|
+
beforeEach(() => {
|
|
11
|
+
jest.clearAllMocks();
|
|
12
|
+
callback = jest.fn();
|
|
13
|
+
from = undefined;
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
test('searches upward from the current working directory', () => {
|
|
17
|
+
subject();
|
|
18
|
+
|
|
19
|
+
['.', '..', '../..'].forEach((dir, index) =>
|
|
20
|
+
expect(callback).toHaveBeenNthCalledWith(index + 1, path.resolve(dir))
|
|
21
|
+
);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
test('returns undefined', () => {
|
|
25
|
+
expect(subject()).toBeUndefined();
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
describe('when a directory matches', () => {
|
|
29
|
+
const result = 'foo';
|
|
30
|
+
|
|
31
|
+
beforeEach(() => callback.mockReturnValueOnce(undefined).mockReturnValueOnce(result));
|
|
32
|
+
|
|
33
|
+
test('returns the callback result', () => {
|
|
34
|
+
expect(subject()).toBe(result);
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
describe('with a starting directory', () => {
|
|
39
|
+
beforeEach(() => (from = path.resolve('a/b/c')));
|
|
40
|
+
|
|
41
|
+
test('searches upward from the specified directory', () => {
|
|
42
|
+
subject();
|
|
43
|
+
|
|
44
|
+
['.', '..', '../..'].forEach((dir, index) =>
|
|
45
|
+
expect(callback).toHaveBeenNthCalledWith(index + 1, path.resolve(from!, dir))
|
|
46
|
+
);
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
});
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
getExposeProcessEnv,
|
|
8
8
|
getJestConfiguration,
|
|
9
9
|
getReviewConfiguration,
|
|
10
|
+
getSharedDependencies,
|
|
10
11
|
getStylelintConfiguration,
|
|
11
12
|
getViteConfiguration,
|
|
12
13
|
getVitestConfiguration,
|
|
@@ -243,6 +244,67 @@ describe('[startup] Utils', () => {
|
|
|
243
244
|
});
|
|
244
245
|
});
|
|
245
246
|
|
|
247
|
+
describe(getSharedDependencies.name, () => {
|
|
248
|
+
const sharedDependencies = { react: 'SharedDependencies.React' };
|
|
249
|
+
let locationOrJson: Parameters<typeof getSharedDependencies>[0];
|
|
250
|
+
|
|
251
|
+
beforeEach(() => (locationOrJson = undefined));
|
|
252
|
+
|
|
253
|
+
const subject = () => getSharedDependencies(locationOrJson);
|
|
254
|
+
|
|
255
|
+
itReturns(subject, undefined);
|
|
256
|
+
|
|
257
|
+
describe('with "cli.shared-dependencies"', () => {
|
|
258
|
+
beforeEach(() =>
|
|
259
|
+
mockPackageJson({ cli: { 'shared-dependencies': sharedDependencies } })
|
|
260
|
+
);
|
|
261
|
+
|
|
262
|
+
test('returns "cli.shared-dependencies"', () => {
|
|
263
|
+
expect(subject()).toEqual(sharedDependencies);
|
|
264
|
+
});
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
describe('with "cli.webpack.shared-dependencies"', () => {
|
|
268
|
+
beforeEach(() =>
|
|
269
|
+
mockPackageJson({ cli: { webpack: { 'shared-dependencies': sharedDependencies } } })
|
|
270
|
+
);
|
|
271
|
+
|
|
272
|
+
test('returns "cli.webpack.shared-dependencies"', () => {
|
|
273
|
+
expect(subject()).toEqual(sharedDependencies);
|
|
274
|
+
});
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
describe('with both top-level and webpack "shared-dependencies"', () => {
|
|
278
|
+
beforeEach(() =>
|
|
279
|
+
mockPackageJson({
|
|
280
|
+
cli: {
|
|
281
|
+
'shared-dependencies': sharedDependencies,
|
|
282
|
+
'webpack': { 'shared-dependencies': { mobx: 'SharedDependencies.MobX' } },
|
|
283
|
+
},
|
|
284
|
+
})
|
|
285
|
+
);
|
|
286
|
+
|
|
287
|
+
test('returns top-level "cli.shared-dependencies"', () => {
|
|
288
|
+
expect(subject()).toEqual(sharedDependencies);
|
|
289
|
+
});
|
|
290
|
+
});
|
|
291
|
+
|
|
292
|
+
describe('with a location', () => {
|
|
293
|
+
beforeEach(() => {
|
|
294
|
+
locationOrJson = 'packages/foo';
|
|
295
|
+
vol.fromJSON({
|
|
296
|
+
[`packages/foo/${packageJson}`]: JSON.stringify({
|
|
297
|
+
cli: { 'shared-dependencies': sharedDependencies },
|
|
298
|
+
}),
|
|
299
|
+
});
|
|
300
|
+
});
|
|
301
|
+
|
|
302
|
+
test("returns location's shared dependencies", () => {
|
|
303
|
+
expect(subject()).toEqual(sharedDependencies);
|
|
304
|
+
});
|
|
305
|
+
});
|
|
306
|
+
});
|
|
307
|
+
|
|
246
308
|
describe(getViteConfiguration.name, () => {
|
|
247
309
|
const subject = () => getViteConfiguration();
|
|
248
310
|
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { log } from './log';
|
|
2
|
+
|
|
3
|
+
const POLL_INTERVAL_MS = 1000;
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Exits current process when the parent identified by process.env.STARTUP_PARENT_PID
|
|
7
|
+
* is no longer running. Use `callback` to override default behavior.
|
|
8
|
+
*/
|
|
9
|
+
export function exitWhenParentExits(command: string, callback: () => void = () => process.exit(0)) {
|
|
10
|
+
const parentPid = Number(process.env.STARTUP_PARENT_PID);
|
|
11
|
+
if (!parentPid) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const interval = setInterval(() => {
|
|
16
|
+
if (!isRunning(parentPid)) {
|
|
17
|
+
clearInterval(interval);
|
|
18
|
+
log.info(`${command} shutting down`);
|
|
19
|
+
callback();
|
|
20
|
+
}
|
|
21
|
+
}, POLL_INTERVAL_MS);
|
|
22
|
+
interval.unref();
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function isRunning(pid: number) {
|
|
26
|
+
try {
|
|
27
|
+
// signal 0 sends nothing; it only checks whether the pid exists
|
|
28
|
+
process.kill(pid, 0);
|
|
29
|
+
return true;
|
|
30
|
+
} catch {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
}
|
package/src/utils/find-up.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
2
|
|
|
3
|
-
export function findUp<T>(callback: (directory: string) => T | undefined) {
|
|
4
|
-
let directory = path.resolve(
|
|
3
|
+
export function findUp<T>(callback: (directory: string) => T | undefined, from = './') {
|
|
4
|
+
let directory = path.resolve(from);
|
|
5
5
|
do {
|
|
6
6
|
const result = callback(directory);
|
|
7
7
|
if (result) {
|
|
@@ -8,6 +8,7 @@ import type svgr from 'vite-plugin-svgr';
|
|
|
8
8
|
import type { ViteUserConfig } from 'vitest/config';
|
|
9
9
|
import type { Configuration as WebpackDevServerConfiguration } from 'webpack-dev-server';
|
|
10
10
|
import type { ReviewConfiguration } from '../cli/commands/review';
|
|
11
|
+
import { bundleConstants } from '../core/constants';
|
|
11
12
|
import { getFolders } from './get-folders';
|
|
12
13
|
import { getPackageName } from './get-package-name';
|
|
13
14
|
import { log } from './log';
|
|
@@ -18,7 +19,7 @@ type VitePluginSvgrOptions = NonNullable<Parameters<typeof svgr>[0]>;
|
|
|
18
19
|
|
|
19
20
|
type ElementType<T> = T extends readonly (infer ElementType)[] ? ElementType : never;
|
|
20
21
|
|
|
21
|
-
export type Bundler =
|
|
22
|
+
export type Bundler = ElementType<typeof bundleConstants.bundlers>;
|
|
22
23
|
|
|
23
24
|
export const allowedWebpackDevServerOptions = ['headers', 'port', 'proxy', 'static'] as const;
|
|
24
25
|
|
|
@@ -69,6 +70,7 @@ export interface NodeConfiguration {
|
|
|
69
70
|
/* eslint-disable @typescript-eslint/naming-convention */
|
|
70
71
|
export enum CommandName {
|
|
71
72
|
'build' = 'build',
|
|
73
|
+
'bundle-package' = 'bundle-package',
|
|
72
74
|
'bundle-vite' = 'bundle-vite',
|
|
73
75
|
'bundle-webpack' = 'bundle-webpack',
|
|
74
76
|
'clean' = 'clean',
|
|
@@ -144,7 +146,7 @@ interface WebComponentOptions {
|
|
|
144
146
|
branches?: Record<string, WebComponentBranchConfigs>;
|
|
145
147
|
}
|
|
146
148
|
|
|
147
|
-
type Configuration = {
|
|
149
|
+
export type Configuration = {
|
|
148
150
|
'bundler'?: Bundler;
|
|
149
151
|
'jest'?: JestConfiguration;
|
|
150
152
|
'legacy'?: boolean;
|
|
@@ -277,10 +279,17 @@ export function isViteDevServerDisabled() {
|
|
|
277
279
|
return getViteConfiguration().devServer === false;
|
|
278
280
|
}
|
|
279
281
|
|
|
280
|
-
export function
|
|
282
|
+
export function getSharedDependencies(locationOrJson?: LocationOrJson) {
|
|
281
283
|
return (
|
|
282
|
-
|
|
283
|
-
|
|
284
|
+
getConfiguration(locationOrJson)['shared-dependencies'] ??
|
|
285
|
+
getWebpackConfiguration(locationOrJson)['shared-dependencies']
|
|
286
|
+
);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
export function isExposeSharedDependencies(locationOrJson?: LocationOrJson) {
|
|
290
|
+
return (
|
|
291
|
+
(getConfiguration(locationOrJson)['expose-shared-dependencies'] ??
|
|
292
|
+
getWebpackConfiguration(locationOrJson)['expose-shared-dependencies']) === true
|
|
284
293
|
);
|
|
285
294
|
}
|
|
286
295
|
|
package/src/utils/index.ts
CHANGED
|
@@ -18,11 +18,14 @@ jest.mock('../../core', () => ({
|
|
|
18
18
|
jest.mock('../config', () => ({
|
|
19
19
|
createViteConfig: jest.fn(),
|
|
20
20
|
}));
|
|
21
|
+
jest.mock('../plugins', () => ({
|
|
22
|
+
cleanPlugin: jest.fn(() => ({ name: 'clean' })),
|
|
23
|
+
}));
|
|
21
24
|
jest.mock('../plugins/shared-dependencies-plugin', () => ({
|
|
22
25
|
sharedDependenciesPlugin: jest.fn(() => ({ name: 'shared-dependencies' })),
|
|
23
26
|
}));
|
|
24
27
|
|
|
25
|
-
describe(buildSharedDependencies.name
|
|
28
|
+
describe(`[startup] ${buildSharedDependencies.name}`, () => {
|
|
26
29
|
const viteConfig: any = {};
|
|
27
30
|
let options: any;
|
|
28
31
|
let context: BuildContext;
|
|
@@ -52,17 +55,48 @@ describe(buildSharedDependencies.name, () => {
|
|
|
52
55
|
});
|
|
53
56
|
});
|
|
54
57
|
|
|
55
|
-
test('
|
|
58
|
+
test.each(['clean', 'shared-dependencies'])('registers the %s plugin', async name => {
|
|
56
59
|
await subject();
|
|
57
60
|
|
|
58
|
-
expect(
|
|
61
|
+
expect(build).toHaveBeenCalledWith(
|
|
59
62
|
expect.objectContaining({
|
|
60
|
-
|
|
61
|
-
metadataDir: context.package.destination,
|
|
63
|
+
plugins: expect.arrayContaining([{ name }]),
|
|
62
64
|
})
|
|
63
65
|
);
|
|
64
66
|
});
|
|
65
67
|
|
|
68
|
+
test('passes dependencies and metadataDir to shared-dependencies plugin', async () => {
|
|
69
|
+
await subject();
|
|
70
|
+
|
|
71
|
+
expect(sharedDependenciesPlugin).toHaveBeenCalledWith({
|
|
72
|
+
css: {},
|
|
73
|
+
dependencies: context.package.sharedDependencies,
|
|
74
|
+
metadataDir: context.package.destination,
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
describe('when package depends on design system', () => {
|
|
79
|
+
beforeEach(() => {
|
|
80
|
+
context.package.sharedDependencies['@servicetitan/design-system'] = 'DesignSystem';
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
test('passes design system css to shared-dependencies plugin', async () => {
|
|
84
|
+
await subject();
|
|
85
|
+
|
|
86
|
+
expect(sharedDependenciesPlugin).toHaveBeenCalledWith(
|
|
87
|
+
expect.objectContaining({
|
|
88
|
+
css: {
|
|
89
|
+
'design-system': [
|
|
90
|
+
'@servicetitan/tokens/core/tokens.css',
|
|
91
|
+
'@servicetitan/anvil-fonts/dist/css/anvil-fonts.css',
|
|
92
|
+
'@servicetitan/design-system/dist/system.min.css',
|
|
93
|
+
],
|
|
94
|
+
},
|
|
95
|
+
})
|
|
96
|
+
);
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
|
|
66
100
|
test('builds with development mode', async () => {
|
|
67
101
|
await subject();
|
|
68
102
|
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
resolveOutputPath,
|
|
8
8
|
} from '../core';
|
|
9
9
|
import { createViteConfig } from './config';
|
|
10
|
+
import { cleanPlugin } from './plugins';
|
|
10
11
|
import { sharedDependenciesPlugin } from './plugins/shared-dependencies-plugin';
|
|
11
12
|
|
|
12
13
|
export async function buildSharedDependencies(options: BuildContextOptions) {
|
|
@@ -20,7 +21,7 @@ export async function buildSharedDependencies(options: BuildContextOptions) {
|
|
|
20
21
|
legalComments: 'none',
|
|
21
22
|
},
|
|
22
23
|
mode: getMode(context),
|
|
23
|
-
plugins: [getSharedDependenciesPlugin(context)],
|
|
24
|
+
plugins: [cleanPlugin(context), getSharedDependenciesPlugin(context)],
|
|
24
25
|
build: {
|
|
25
26
|
outDir: resolveOutputPath(context, config.build?.outDir),
|
|
26
27
|
minify: config.build?.minify,
|