@servicetitan/startup 38.0.0 → 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/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/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/webpack-final.d.ts.map +1 -1
- package/dist/storybook-config/webpack-final.js +2 -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 +12 -1
- package/dist/vite/config/base-config.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.js +1 -1
- 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/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/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 +24 -21
- 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__/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/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/storybook-config/__tests__/vite-final.test.ts +6 -0
- package/src/storybook-config/__tests__/webpack-final.test.ts +26 -12
- package/src/storybook-config/webpack-final.ts +10 -4
- 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 +12 -4
- package/src/vite/config/__tests__/create-css-config.test.ts +2 -6
- package/src/vite/config/__tests__/create-vite-config.test.ts +6 -3
- package/src/vite/config/base-config.ts +13 -1
- 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 +1 -1
- 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__/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 +1 -1
- 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/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/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
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import type { Plugin } from 'vite';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Maps each `window` global to the import(s) that resolve to it. The key is the `window` global
|
|
5
|
+
* (`jQuery` names `window.jQuery`). Every value matches specifiers with a regex:
|
|
6
|
+
*
|
|
7
|
+
* - `RegExp` resolves matching imports to `window.<global>` (`/^jquery$/`, or
|
|
8
|
+
* `/^(moment|moment-timezone)$/` to cover several specifiers)
|
|
9
|
+
* - `{ match, exports }` resolves imports to `window.<global>.<export>`, for
|
|
10
|
+
* packages that have named imports (e.g., (`import { formatMoney } from 'accounting'`))
|
|
11
|
+
* - `{ match, member }` resolves imports to `window.<global>[member(specifier)]`, deriving the key from
|
|
12
|
+
* the function result. For example `{ match: /^@arcgis\/core\//, member: s => s.split('/').pop() }`
|
|
13
|
+
* maps `@arcgis/core/views/MapView` to `window.arcgis["MapView"]`.
|
|
14
|
+
*/
|
|
15
|
+
export type WindowExternals = Record<
|
|
16
|
+
string,
|
|
17
|
+
| RegExp
|
|
18
|
+
| {
|
|
19
|
+
match: RegExp;
|
|
20
|
+
exports?: string[];
|
|
21
|
+
}
|
|
22
|
+
| {
|
|
23
|
+
match: RegExp;
|
|
24
|
+
member?: (specifier: string) => string | false | null | undefined;
|
|
25
|
+
}
|
|
26
|
+
>;
|
|
27
|
+
|
|
28
|
+
interface Binding {
|
|
29
|
+
expression: string;
|
|
30
|
+
exports?: string[];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
interface Entry {
|
|
34
|
+
match: RegExp;
|
|
35
|
+
bind: (specifier: string) => Binding;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const VIRTUAL_PREFIX = '\0window-externals:';
|
|
39
|
+
const VIRTUAL_ID_PATTERN = new RegExp(`^${VIRTUAL_PREFIX}`);
|
|
40
|
+
|
|
41
|
+
/*
|
|
42
|
+
* Uses a global the host already puts on `window` instead of bundling the library, like webpack's
|
|
43
|
+
* `externals` with externalsType `var`/`window`. Vite/Rolldown offers no built-in way to do this
|
|
44
|
+
* for ES module builds (its `output.globals` maps externals to globals only for umd/iife output).
|
|
45
|
+
* This plugin replaces matched imports with a module that reads the global.
|
|
46
|
+
*/
|
|
47
|
+
export function windowExternalsPlugin(externals: WindowExternals): Plugin {
|
|
48
|
+
const entries: Entry[] = Object.entries(externals).map(([global, value]) => {
|
|
49
|
+
if (value instanceof RegExp) {
|
|
50
|
+
return { match: value, bind: () => ({ expression: `window.${global}` }) };
|
|
51
|
+
}
|
|
52
|
+
const { match } = value;
|
|
53
|
+
const exports = 'exports' in value ? value.exports : undefined;
|
|
54
|
+
const member = 'member' in value ? value.member : undefined;
|
|
55
|
+
return {
|
|
56
|
+
match,
|
|
57
|
+
bind: specifier => {
|
|
58
|
+
const key = member?.(specifier);
|
|
59
|
+
const expression = key
|
|
60
|
+
? `window.${global}[${JSON.stringify(key)}]`
|
|
61
|
+
: `window.${global}`;
|
|
62
|
+
return { expression, exports };
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
const bind = (specifier: string): Binding | null =>
|
|
68
|
+
entries.find(entry => entry.match.test(specifier))?.bind(specifier) ?? null;
|
|
69
|
+
|
|
70
|
+
return {
|
|
71
|
+
name: 'st:window-externals',
|
|
72
|
+
enforce: 'pre',
|
|
73
|
+
resolveId: {
|
|
74
|
+
filter: { id: entries.map(entry => entry.match) },
|
|
75
|
+
handler(source) {
|
|
76
|
+
return VIRTUAL_PREFIX + source;
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
load: {
|
|
80
|
+
filter: { id: VIRTUAL_ID_PATTERN },
|
|
81
|
+
handler(id) {
|
|
82
|
+
const binding = bind(id.slice(VIRTUAL_PREFIX.length))!;
|
|
83
|
+
if (!binding.exports?.length) {
|
|
84
|
+
return `export default ${binding.expression};`;
|
|
85
|
+
}
|
|
86
|
+
return [
|
|
87
|
+
`const _m = ${binding.expression};`,
|
|
88
|
+
'export default _m;',
|
|
89
|
+
...binding.exports.map(name => `export const ${name} = _m.${name};`),
|
|
90
|
+
].join('\n');
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
}
|
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
webpackDevConfigFileName,
|
|
19
19
|
webpackProdConfigFileName,
|
|
20
20
|
} from '../create-webpack-config';
|
|
21
|
+
import { normalizeProxyConfig } from '../utils';
|
|
21
22
|
|
|
22
23
|
jest.mock('fs', () => fs);
|
|
23
24
|
jest.mock('portfinder');
|
|
@@ -36,6 +37,10 @@ jest.mock('../create-webpack-config', () => ({
|
|
|
36
37
|
...jest.requireActual('../create-webpack-config'),
|
|
37
38
|
createWebpackConfig: jest.fn(),
|
|
38
39
|
}));
|
|
40
|
+
jest.mock('../utils', () => ({
|
|
41
|
+
...jest.requireActual('../utils'),
|
|
42
|
+
normalizeProxyConfig: jest.fn(),
|
|
43
|
+
}));
|
|
39
44
|
|
|
40
45
|
describe('[startup] Cli Utils', () => {
|
|
41
46
|
const pkg = createPackage({});
|
|
@@ -461,6 +466,33 @@ describe('[startup] Cli Utils', () => {
|
|
|
461
466
|
});
|
|
462
467
|
});
|
|
463
468
|
|
|
469
|
+
describe('with a proxy config', () => {
|
|
470
|
+
const proxy = [{ context: ['/api'], target: 'http://localhost:9000' }];
|
|
471
|
+
const normalizedProxy = [
|
|
472
|
+
{ context: ['/api'], target: 'http://localhost:9000', on: {} },
|
|
473
|
+
];
|
|
474
|
+
|
|
475
|
+
beforeEach(() => {
|
|
476
|
+
jest.mocked(createWebpackConfig).mockReturnValue({ devServer: { proxy } });
|
|
477
|
+
jest.mocked(normalizeProxyConfig).mockReturnValue(normalizedProxy);
|
|
478
|
+
});
|
|
479
|
+
|
|
480
|
+
test('normalizes the proxy config', async () => {
|
|
481
|
+
await subject();
|
|
482
|
+
|
|
483
|
+
expect(normalizeProxyConfig).toHaveBeenCalledWith(proxy);
|
|
484
|
+
});
|
|
485
|
+
|
|
486
|
+
test('constructs WebpackDevServer with the normalized proxy config', async () => {
|
|
487
|
+
await subject();
|
|
488
|
+
|
|
489
|
+
expect(WebpackDevServer).toHaveBeenCalledWith(
|
|
490
|
+
expect.objectContaining({ proxy: normalizedProxy }),
|
|
491
|
+
compiler
|
|
492
|
+
);
|
|
493
|
+
});
|
|
494
|
+
});
|
|
495
|
+
|
|
464
496
|
describe('with "emitExposedDependencies"', () => {
|
|
465
497
|
beforeEach(() => (options = { emitExposedDependencies: true }));
|
|
466
498
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import HtmlWebpackPlugin from 'html-webpack-plugin';
|
|
2
2
|
import { fs, vol } from 'memfs';
|
|
3
3
|
import MiniCssExtractPlugin from 'mini-css-extract-plugin';
|
|
4
|
+
import MinimizerPlugin from 'minimizer-webpack-plugin';
|
|
4
5
|
import path from 'path';
|
|
5
|
-
import TerserPlugin from 'terser-webpack-plugin';
|
|
6
6
|
import { DefinePlugin } from 'webpack';
|
|
7
7
|
import { WebpackAssetsManifest } from 'webpack-assets-manifest';
|
|
8
8
|
import VirtualModulesPlugin from 'webpack-virtual-modules';
|
|
@@ -31,7 +31,7 @@ jest.mock('mini-css-extract-plugin', () =>
|
|
|
31
31
|
Object.assign(jest.fn(), { loader: 'MiniCssExtractPlugin.loader' })
|
|
32
32
|
);
|
|
33
33
|
jest.mock('moment-locales-webpack-plugin', () => jest.fn());
|
|
34
|
-
jest.mock('
|
|
34
|
+
jest.mock('minimizer-webpack-plugin', () => jest.fn());
|
|
35
35
|
jest.mock('webpack', () => ({
|
|
36
36
|
DefinePlugin: jest.fn(),
|
|
37
37
|
IgnorePlugin: jest.fn(),
|
|
@@ -111,7 +111,7 @@ describe(`[startup] ${createWebpackConfig.name}`, () => {
|
|
|
111
111
|
jest.mocked(DefinePlugin).mockImplementation(mockPlugIn('DefinePlugin'));
|
|
112
112
|
jest.mocked(HtmlWebpackPlugin).mockImplementation(mockPlugIn('HtmlWebpackPlugin'));
|
|
113
113
|
jest.mocked(VirtualModulesPlugin).mockImplementation(mockPlugIn('VirtualModulesPlugin'));
|
|
114
|
-
jest.mocked(
|
|
114
|
+
jest.mocked(MinimizerPlugin).mockImplementation(mockPlugIn('MinimizerPlugin'));
|
|
115
115
|
jest.mocked(WebpackAssetsManifest).mockImplementation(mockPlugIn('WebpackAssetsManifest'));
|
|
116
116
|
jest.mocked(yargs).mockImplementation(() => ({ argv: {} }) as any);
|
|
117
117
|
|
|
@@ -497,12 +497,20 @@ describe(`[startup] ${createWebpackConfig.name}`, () => {
|
|
|
497
497
|
});
|
|
498
498
|
|
|
499
499
|
test('configures "output.uniqueName"', () => {
|
|
500
|
-
expect(subject().output?.uniqueName).toEqual(options.name);
|
|
500
|
+
expect(subject().output?.uniqueName).toEqual(`${options.name}-full`);
|
|
501
|
+
});
|
|
502
|
+
|
|
503
|
+
describe('when light option is set to true', () => {
|
|
504
|
+
beforeEach(() => (options.light = true));
|
|
505
|
+
|
|
506
|
+
test('configures "output.uniqueName" distinctly from the full bundle', () => {
|
|
507
|
+
expect(subject().output?.uniqueName).toEqual(`${options.name}-light`);
|
|
508
|
+
});
|
|
501
509
|
});
|
|
502
510
|
|
|
503
511
|
test('enables terser compress and mangle', () => {
|
|
504
512
|
expect(subject().optimization?.minimizer).toContainEqual(
|
|
505
|
-
new
|
|
513
|
+
new MinimizerPlugin({ minimizerOptions: { compress: true, mangle: true } })
|
|
506
514
|
);
|
|
507
515
|
});
|
|
508
516
|
|
|
@@ -512,6 +520,10 @@ describe(`[startup] ${createWebpackConfig.name}`, () => {
|
|
|
512
520
|
test('omits optimization.runtimeChunk', () => {
|
|
513
521
|
expect(subject().optimization?.runtimeChunk).toBeUndefined();
|
|
514
522
|
});
|
|
523
|
+
|
|
524
|
+
test('configures "output.uniqueName" distinctly from the full bundle', () => {
|
|
525
|
+
expect(subject().output?.uniqueName).toEqual(`${options.name}-headless`);
|
|
526
|
+
});
|
|
515
527
|
});
|
|
516
528
|
});
|
|
517
529
|
});
|
|
@@ -2,10 +2,10 @@ import CssMinimizerWebpackPlugin from 'css-minimizer-webpack-plugin';
|
|
|
2
2
|
import HtmlWebpackPlugin from 'html-webpack-plugin';
|
|
3
3
|
import { fs, vol } from 'memfs';
|
|
4
4
|
import MiniCssExtractPlugin from 'mini-css-extract-plugin';
|
|
5
|
+
import MinimizerPlugin from 'minimizer-webpack-plugin';
|
|
5
6
|
import MomentLocalesPlugin from 'moment-locales-webpack-plugin';
|
|
6
7
|
import os from 'os';
|
|
7
8
|
import path from 'path';
|
|
8
|
-
import TerserPlugin from 'terser-webpack-plugin';
|
|
9
9
|
import { DefinePlugin, IgnorePlugin, ProvidePlugin } from 'webpack';
|
|
10
10
|
import WebpackDevServer from 'webpack-dev-server';
|
|
11
11
|
import yargs from 'yargs';
|
|
@@ -41,7 +41,7 @@ jest.mock('mini-css-extract-plugin', () =>
|
|
|
41
41
|
Object.assign(jest.fn(), { loader: 'MiniCssExtractPlugin.loader' })
|
|
42
42
|
);
|
|
43
43
|
jest.mock('moment-locales-webpack-plugin', () => jest.fn());
|
|
44
|
-
jest.mock('
|
|
44
|
+
jest.mock('minimizer-webpack-plugin', () => jest.fn());
|
|
45
45
|
jest.mock('webpack', () => ({
|
|
46
46
|
DefinePlugin: jest.fn(),
|
|
47
47
|
IgnorePlugin: jest.fn(),
|
|
@@ -131,7 +131,7 @@ describe(`[startup] ${createWebpackConfig.name}`, () => {
|
|
|
131
131
|
jest.mocked(IgnorePlugin).mockImplementation(mockPlugIn('IgnorePlugin'));
|
|
132
132
|
jest.mocked(MomentLocalesPlugin).mockImplementation(mockPlugIn('MomentLocalesPlugin'));
|
|
133
133
|
jest.mocked(ProvidePlugin).mockImplementation(mockPlugIn('ProvidePlugin'));
|
|
134
|
-
jest.mocked(
|
|
134
|
+
jest.mocked(MinimizerPlugin).mockImplementation(mockPlugIn('MinimizerPlugin'));
|
|
135
135
|
|
|
136
136
|
jest.mocked(getConfiguration).mockImplementation(() => configuration as any);
|
|
137
137
|
jest.mocked(getWebpackConfiguration).mockImplementation(() => configuration.webpack ?? {});
|
|
@@ -582,7 +582,9 @@ describe(`[startup] ${createWebpackConfig.name}`, () => {
|
|
|
582
582
|
});
|
|
583
583
|
|
|
584
584
|
describe('when mode is "production"', () => {
|
|
585
|
-
const
|
|
585
|
+
const defaultMinimizerPluginOptions = {
|
|
586
|
+
minimizerOptions: { compress: false, mangle: false },
|
|
587
|
+
};
|
|
586
588
|
const defaultCssMinimizerOptions = {};
|
|
587
589
|
|
|
588
590
|
beforeEach(() => {
|
|
@@ -652,7 +654,7 @@ describe(`[startup] ${createWebpackConfig.name}`, () => {
|
|
|
652
654
|
|
|
653
655
|
test('configures "optimization.minimizer"', () => {
|
|
654
656
|
expect(subject().optimization?.minimizer).toEqual([
|
|
655
|
-
new
|
|
657
|
+
new MinimizerPlugin(defaultMinimizerPluginOptions),
|
|
656
658
|
new CssMinimizerWebpackPlugin(defaultCssMinimizerOptions),
|
|
657
659
|
]);
|
|
658
660
|
});
|
|
@@ -702,7 +704,9 @@ describe(`[startup] ${createWebpackConfig.name}`, () => {
|
|
|
702
704
|
|
|
703
705
|
test('applies the options', () => {
|
|
704
706
|
expect(subject().optimization?.minimizer).toEqual([
|
|
705
|
-
new
|
|
707
|
+
new MinimizerPlugin({
|
|
708
|
+
minimizerOptions: configuration.webpack?.minify?.js as any,
|
|
709
|
+
}),
|
|
706
710
|
]);
|
|
707
711
|
});
|
|
708
712
|
});
|
|
@@ -3,6 +3,7 @@ import webpack, { Configuration } from 'webpack';
|
|
|
3
3
|
import WebpackDevServer from 'webpack-dev-server';
|
|
4
4
|
import { isDevServerDisabled, isExposeSharedDependencies, isWebComponent, log } from '../utils';
|
|
5
5
|
import { createWebpackConfigs } from './create-webpack-configs';
|
|
6
|
+
import { normalizeProxyConfig } from './utils';
|
|
6
7
|
|
|
7
8
|
interface Options {
|
|
8
9
|
buildStat?: boolean;
|
|
@@ -77,8 +78,13 @@ async function runServe({ devServer = {}, ...config }: Configuration) {
|
|
|
77
78
|
host,
|
|
78
79
|
});
|
|
79
80
|
|
|
81
|
+
const proxy = devServer.proxy && normalizeProxyConfig(devServer.proxy);
|
|
82
|
+
|
|
80
83
|
return new Promise<void>((_0, reject) => {
|
|
81
|
-
const server = new WebpackDevServer(
|
|
84
|
+
const server = new WebpackDevServer(
|
|
85
|
+
{ ...devServer, host, port, ...(proxy && { proxy }) },
|
|
86
|
+
compiler
|
|
87
|
+
);
|
|
82
88
|
server.startCallback(e => {
|
|
83
89
|
if (e) {
|
|
84
90
|
server.stopCallback(() => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import CssMinimizerWebpackPlugin from 'css-minimizer-webpack-plugin';
|
|
2
|
-
import
|
|
2
|
+
import MinimizerPlugin from 'minimizer-webpack-plugin';
|
|
3
3
|
import { Configuration } from 'webpack';
|
|
4
4
|
import { CHUNK_PATTERNS } from '../../core';
|
|
5
5
|
import { Overrides, WebpackBuildContext } from '../types';
|
|
@@ -61,7 +61,7 @@ function minimizeConfig(optimization: ConfigWithCacheGroups, context: WebpackBui
|
|
|
61
61
|
* MFE source maps are available to Datadog, so compress and mangle are OK.
|
|
62
62
|
* Disable for hosts until their source maps are uploaded too.
|
|
63
63
|
*/
|
|
64
|
-
const
|
|
64
|
+
const minimizerOptions = {
|
|
65
65
|
compress: !!isWebComponent,
|
|
66
66
|
mangle: !!isWebComponent,
|
|
67
67
|
...(typeof minifyJs === 'object' ? minifyJs : {}),
|
|
@@ -72,7 +72,7 @@ function minimizeConfig(optimization: ConfigWithCacheGroups, context: WebpackBui
|
|
|
72
72
|
};
|
|
73
73
|
|
|
74
74
|
optimization.minimizer = [
|
|
75
|
-
...(minifyJs ? [new
|
|
75
|
+
...(minifyJs ? [new MinimizerPlugin({ minimizerOptions })] : []),
|
|
76
76
|
...(minifyCss ? [new CssMinimizerWebpackPlugin(cssMinimizerPluginOptions)] : []),
|
|
77
77
|
];
|
|
78
78
|
}
|
|
@@ -19,7 +19,7 @@ export function outputConfig(context: BuildContext, _: Overrides): Result {
|
|
|
19
19
|
const cdnPath = getCdnPath(context);
|
|
20
20
|
Object.assign(output, {
|
|
21
21
|
filename: '[name].[contenthash].bundle.js',
|
|
22
|
-
...(isWebComponent ? { uniqueName: name } : {}),
|
|
22
|
+
...(isWebComponent ? { uniqueName: `${name}-${getBundleType(context)}` } : {}),
|
|
23
23
|
...(cdnPath ? { publicPath: cdnPath } : {}),
|
|
24
24
|
});
|
|
25
25
|
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { log } from '../../../utils';
|
|
2
|
+
import { normalizeProxyConfig } from '../normalize-proxy-config';
|
|
3
|
+
|
|
4
|
+
jest.mock('../../../utils', () => ({
|
|
5
|
+
...jest.requireActual('../../../utils'),
|
|
6
|
+
log: { warning: jest.fn() },
|
|
7
|
+
}));
|
|
8
|
+
|
|
9
|
+
describe(`[startup] ${normalizeProxyConfig.name}`, () => {
|
|
10
|
+
const target = 'http://localhost:9000';
|
|
11
|
+
|
|
12
|
+
let proxy: Parameters<typeof normalizeProxyConfig>[0];
|
|
13
|
+
|
|
14
|
+
beforeEach(() => {
|
|
15
|
+
jest.clearAllMocks();
|
|
16
|
+
proxy = [{ context: ['/api'], target }];
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
const subject = () => normalizeProxyConfig(proxy);
|
|
20
|
+
|
|
21
|
+
test('returns items unchanged', () => {
|
|
22
|
+
expect(subject()).toEqual(proxy);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
test('does not log a warning', () => {
|
|
26
|
+
subject();
|
|
27
|
+
|
|
28
|
+
expect(log.warning).not.toHaveBeenCalled();
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
describe.each`
|
|
32
|
+
legacyOption | eventName
|
|
33
|
+
${'onProxyReq'} | ${'proxyReq'}
|
|
34
|
+
${'onProxyRes'} | ${'proxyRes'}
|
|
35
|
+
${'onProxyReqWs'} | ${'proxyReqWs'}
|
|
36
|
+
${'onOpen'} | ${'open'}
|
|
37
|
+
${'onClose'} | ${'close'}
|
|
38
|
+
${'onError'} | ${'error'}
|
|
39
|
+
`('with a "$legacyOption" handler', ({ legacyOption, eventName }) => {
|
|
40
|
+
const handler = () => {};
|
|
41
|
+
|
|
42
|
+
beforeEach(() => {
|
|
43
|
+
(proxy[0] as Record<string, unknown>)[legacyOption] = handler;
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
test(`moves the handler to "on.${eventName}"`, () => {
|
|
47
|
+
const [item] = subject() as Record<string, unknown>[];
|
|
48
|
+
|
|
49
|
+
expect((item.on as Record<string, unknown>)[eventName]).toBe(handler);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
test(`removes the legacy "${legacyOption}" option`, () => {
|
|
53
|
+
const [item] = subject() as Record<string, unknown>[];
|
|
54
|
+
|
|
55
|
+
expect(item[legacyOption]).toBeUndefined();
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
test('logs a deprecation warning', () => {
|
|
59
|
+
subject();
|
|
60
|
+
|
|
61
|
+
expect(log.warning).toHaveBeenCalled();
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
describe('with an existing "on" object', () => {
|
|
66
|
+
const existingHandler = () => {};
|
|
67
|
+
const legacyHandler = () => {};
|
|
68
|
+
|
|
69
|
+
beforeEach(() => {
|
|
70
|
+
Object.assign(proxy[0], {
|
|
71
|
+
on: { proxyRes: existingHandler },
|
|
72
|
+
onProxyReq: legacyHandler,
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
test('preserves the existing handler', () => {
|
|
77
|
+
const [item] = subject() as Record<string, unknown>[];
|
|
78
|
+
|
|
79
|
+
expect((item.on as Record<string, unknown>).proxyRes).toBe(existingHandler);
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
test('adds the migrated handler alongside it', () => {
|
|
83
|
+
const [item] = subject() as Record<string, unknown>[];
|
|
84
|
+
|
|
85
|
+
expect((item.on as Record<string, unknown>).proxyReq).toBe(legacyHandler);
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
describe('with a handler for the same event in both "on" and the legacy option', () => {
|
|
90
|
+
const onHandler = () => {};
|
|
91
|
+
const legacyHandler = () => {};
|
|
92
|
+
|
|
93
|
+
beforeEach(() => {
|
|
94
|
+
Object.assign(proxy[0], {
|
|
95
|
+
on: { proxyReq: onHandler },
|
|
96
|
+
onProxyReq: legacyHandler,
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
test('keeps the "on" handler', () => {
|
|
101
|
+
const [item] = subject() as Record<string, unknown>[];
|
|
102
|
+
|
|
103
|
+
expect((item.on as Record<string, unknown>).proxyReq).toBe(onHandler);
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
describe('with a proxy config function', () => {
|
|
108
|
+
const legacyHandler = () => {};
|
|
109
|
+
|
|
110
|
+
beforeEach(() => {
|
|
111
|
+
proxy = [() => ({ context: ['/api'], target, onProxyReq: legacyHandler }) as any];
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
test('migrates the object the function returns', () => {
|
|
115
|
+
const [item] = subject();
|
|
116
|
+
const result = (item as Function)() as Record<string, unknown>;
|
|
117
|
+
|
|
118
|
+
expect((result.on as Record<string, unknown>).proxyReq).toBe(legacyHandler);
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
});
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { Configuration } from 'webpack';
|
|
2
|
+
import { log } from '../../utils';
|
|
3
|
+
|
|
4
|
+
type DevServerConfig = NonNullable<Configuration['devServer']>;
|
|
5
|
+
type ProxyConfig = NonNullable<DevServerConfig['proxy']>;
|
|
6
|
+
type ProxyConfigItem = ProxyConfig[number];
|
|
7
|
+
|
|
8
|
+
const LEGACY_PROXY_EVENTS = {
|
|
9
|
+
onProxyReq: 'proxyReq',
|
|
10
|
+
onProxyRes: 'proxyRes',
|
|
11
|
+
onProxyReqWs: 'proxyReqWs',
|
|
12
|
+
onOpen: 'open',
|
|
13
|
+
onClose: 'close',
|
|
14
|
+
onError: 'error',
|
|
15
|
+
} as const;
|
|
16
|
+
|
|
17
|
+
export function normalizeProxyConfig(proxy: ProxyConfig): ProxyConfig {
|
|
18
|
+
return proxy.map(item =>
|
|
19
|
+
typeof item === 'function'
|
|
20
|
+
? (((...args: Parameters<typeof item>) =>
|
|
21
|
+
migrateLegacyProxyEvents(item(...args))) as typeof item)
|
|
22
|
+
: migrateLegacyProxyEvents(item)
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function migrateLegacyProxyEvents(item: ProxyConfigItem): ProxyConfigItem {
|
|
27
|
+
const source = item as Record<string, unknown>;
|
|
28
|
+
const legacyKeys = Object.keys(LEGACY_PROXY_EVENTS).filter(
|
|
29
|
+
key => source[key] !== undefined
|
|
30
|
+
) as (keyof typeof LEGACY_PROXY_EVENTS)[];
|
|
31
|
+
|
|
32
|
+
if (!legacyKeys.length) {
|
|
33
|
+
return item;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
log.warning(PROXY_EVENTS_DEPRECATION_WARNING);
|
|
37
|
+
|
|
38
|
+
const legacyOn: Record<string, unknown> = {};
|
|
39
|
+
const { on: modernOn, ...rest } = source;
|
|
40
|
+
for (const key of legacyKeys) {
|
|
41
|
+
legacyOn[LEGACY_PROXY_EVENTS[key]] = rest[key];
|
|
42
|
+
delete rest[key];
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return {
|
|
46
|
+
...rest,
|
|
47
|
+
on: { ...legacyOn, ...(modernOn as Record<string, unknown>) },
|
|
48
|
+
} as ProxyConfigItem;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const PROXY_EVENTS_DEPRECATION_WARNING = `
|
|
52
|
+
DEPRECATION WARNING: webpack-dev-server proxy config uses one or more legacy event options
|
|
53
|
+
(onProxyReq, onProxyRes, onProxyReqWs, onOpen, onClose, onError). These are moved to an "on"
|
|
54
|
+
object automatically, but support for the legacy options will be removed in a future release.
|
|
55
|
+
See the http-proxy-middleware v3 migration guide:
|
|
56
|
+
https://github.com/chimurai/http-proxy-middleware/blob/master/MIGRATION.md
|
|
57
|
+
`
|
|
58
|
+
.replace(/\n\s*/g, ' ')
|
|
59
|
+
.trim();
|
package/tsconfig/types.d.ts
CHANGED
|
@@ -23,6 +23,16 @@ declare module '@servicetitan/anvil2/*.svg' {
|
|
|
23
23
|
export default ReactComponent;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
declare module '*.png' {
|
|
27
|
+
const content: string;
|
|
28
|
+
export default content;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
declare module '*.gif' {
|
|
32
|
+
const content: string;
|
|
33
|
+
export default content;
|
|
34
|
+
}
|
|
35
|
+
|
|
26
36
|
declare module '*.less' {
|
|
27
37
|
const content: string;
|
|
28
38
|
export default content;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get-bundle-command.d.ts","sourceRoot":"","sources":["../../../src/cli/utils/get-bundle-command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAEnF"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "getBundleCommand", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return getBundleCommand;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const _resolvebundler = require("./resolve-bundler");
|
|
12
|
-
function getBundleCommand(args) {
|
|
13
|
-
return (0, _resolvebundler.resolveBundler)(args) === 'vite' ? 'startup bundle-vite' : 'startup bundle-webpack';
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
//# sourceMappingURL=get-bundle-command.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/cli/utils/get-bundle-command.ts"],"sourcesContent":["import { resolveBundler } from './resolve-bundler';\n\nexport function getBundleCommand(args: Parameters<typeof resolveBundler>[0]): string {\n return resolveBundler(args) === 'vite' ? 'startup bundle-vite' : 'startup bundle-webpack';\n}\n"],"names":["getBundleCommand","args","resolveBundler"],"mappings":";;;;+BAEgBA;;;eAAAA;;;gCAFe;AAExB,SAASA,iBAAiBC,IAA0C;IACvE,OAAOC,IAAAA,8BAAc,EAACD,UAAU,SAAS,wBAAwB;AACrE"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { getBundleCommand } from '../get-bundle-command';
|
|
2
|
-
|
|
3
|
-
describe(`[startup] ${getBundleCommand.name}`, () => {
|
|
4
|
-
let args: Parameters<typeof getBundleCommand>[0];
|
|
5
|
-
|
|
6
|
-
const subject = () => getBundleCommand(args);
|
|
7
|
-
|
|
8
|
-
describe('when bundler is vite', () => {
|
|
9
|
-
beforeEach(() => (args = { bundler: 'vite' }));
|
|
10
|
-
|
|
11
|
-
test('returns "startup bundle-vite"', () => {
|
|
12
|
-
expect(subject()).toBe('startup bundle-vite');
|
|
13
|
-
});
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
describe('when bundler is webpack', () => {
|
|
17
|
-
beforeEach(() => (args = { bundler: 'webpack' }));
|
|
18
|
-
|
|
19
|
-
test('returns "startup bundle-webpack"', () => {
|
|
20
|
-
expect(subject()).toBe('startup bundle-webpack');
|
|
21
|
-
});
|
|
22
|
-
});
|
|
23
|
-
});
|