@servicetitan/startup 38.0.0 → 38.2.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 +32 -10
- 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 +13 -0
- package/dist/cli/commands/command.d.ts.map +1 -0
- package/dist/cli/commands/command.js +74 -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.d.ts.map +1 -1
- package/dist/cli/commands/init.js +13 -5
- package/dist/cli/commands/init.js.map +1 -1
- package/dist/cli/commands/install.d.ts.map +1 -1
- package/dist/cli/commands/install.js +14 -21
- 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 -18
- 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/install.d.ts +0 -16
- package/dist/cli/commands/registry/install.d.ts.map +1 -1
- package/dist/cli/commands/registry/install.js +1 -17
- package/dist/cli/commands/registry/install.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 +37 -14
- 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-git.d.ts +7 -0
- package/dist/cli/utils/cli-git.d.ts.map +1 -1
- package/dist/cli/utils/cli-git.js +30 -0
- package/dist/cli/utils/cli-git.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 +7 -1
- package/dist/cli/utils/cli-os.d.ts.map +1 -1
- package/dist/cli/utils/cli-os.js +42 -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/telemetry/index.d.ts +3 -0
- package/dist/telemetry/index.d.ts.map +1 -0
- package/dist/telemetry/index.js +21 -0
- package/dist/telemetry/index.js.map +1 -0
- package/dist/telemetry/telemetry.d.ts +15 -0
- package/dist/telemetry/telemetry.d.ts.map +1 -0
- package/dist/telemetry/telemetry.js +176 -0
- package/dist/telemetry/telemetry.js.map +1 -0
- 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-filtering-logger.d.ts.map +1 -1
- package/dist/vite/config/create-filtering-logger.js +6 -2
- package/dist/vite/config/create-filtering-logger.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 +17 -12
- 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 +32 -26
- package/src/cli/commands/__tests__/build.test.ts +81 -20
- package/src/cli/commands/__tests__/bundle-package.test.ts +65 -0
- package/src/cli/commands/__tests__/command.test.ts +154 -0
- package/src/cli/commands/__tests__/init.test.ts +1 -1
- package/src/cli/commands/__tests__/install.test.ts +5 -72
- 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 +77 -16
- package/src/cli/commands/build.ts +15 -6
- package/src/cli/commands/bundle-package.ts +20 -0
- package/src/cli/commands/command.ts +64 -0
- package/src/cli/commands/init.ts +0 -1
- package/src/cli/commands/install.ts +5 -21
- 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/install.ts +1 -6
- package/src/cli/commands/registry/start.ts +3 -2
- package/src/cli/commands/run-task.ts +8 -2
- package/src/cli/commands/start.ts +17 -6
- 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-git.test.ts +54 -3
- package/src/cli/utils/__tests__/cli-npm.test.ts +33 -0
- package/src/cli/utils/__tests__/cli-os.test.ts +183 -4
- 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-git.ts +27 -1
- package/src/cli/utils/cli-npm.ts +19 -4
- package/src/cli/utils/cli-os.ts +44 -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/telemetry/__tests__/telemetry.test.ts +326 -0
- package/src/telemetry/index.ts +2 -0
- package/src/telemetry/telemetry.ts +134 -0
- 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-filtering-logger.test.ts +3 -2
- 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-filtering-logger.ts +8 -2
- 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-shared-dependencies.test.ts +27 -1
- 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 +22 -11
- 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,144 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import MagicString from 'magic-string';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import type { Plugin } from 'vite';
|
|
5
|
+
import type { BuildContext } from '../../../core';
|
|
6
|
+
import { findPackages } from '../../../utils';
|
|
7
|
+
|
|
8
|
+
const RUNTIME_ID = '/@react-refresh';
|
|
9
|
+
const RUNTIME_HELPERS_PATH = path.join(__dirname, 'refresh-runtime.js');
|
|
10
|
+
|
|
11
|
+
/* Triggers injectIntoGlobalHook (via the virtual module's side effect) before app code executes. */
|
|
12
|
+
const preamble = `import "${RUNTIME_ID}";`;
|
|
13
|
+
|
|
14
|
+
/*
|
|
15
|
+
* Per-module locals satisfy swc's $RefreshReg$/$RefreshSig$ calls without relying on
|
|
16
|
+
* window globals. Scoping the registration id to the served module URL ensures host and
|
|
17
|
+
* MFE servers sharing one runtime singleton cannot produce colliding refresh families.
|
|
18
|
+
*/
|
|
19
|
+
const modulePrelude = `import RefreshRuntime from "${RUNTIME_ID}";
|
|
20
|
+
const __react_refresh_id__ = import.meta.url.replace(/[?#].*$/, "");
|
|
21
|
+
var $RefreshReg$ = (type, id) => RefreshRuntime.register(type, __react_refresh_id__ + " " + id);
|
|
22
|
+
var $RefreshSig$ = () => RefreshRuntime.createSignatureFunctionForTransform();\n`;
|
|
23
|
+
|
|
24
|
+
/* Makes refreshable modules self-accepting and runs React Fast Refresh after safe updates. */
|
|
25
|
+
const postlude = `
|
|
26
|
+
import {
|
|
27
|
+
__hmr_import,
|
|
28
|
+
registerExportsForReactRefresh,
|
|
29
|
+
validateRefreshBoundaryAndEnqueueUpdate,
|
|
30
|
+
} from "${RUNTIME_ID}";
|
|
31
|
+
if (import.meta.hot) {
|
|
32
|
+
__hmr_import(__react_refresh_id__).then(currentExports => {
|
|
33
|
+
registerExportsForReactRefresh(__react_refresh_id__, currentExports);
|
|
34
|
+
import.meta.hot.accept(nextExports => {
|
|
35
|
+
if (!nextExports) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const invalidateMessage = validateRefreshBoundaryAndEnqueueUpdate(
|
|
40
|
+
__react_refresh_id__,
|
|
41
|
+
currentExports,
|
|
42
|
+
nextExports
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
if (invalidateMessage) {
|
|
46
|
+
import.meta.hot.invalidate(invalidateMessage);
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
}`;
|
|
51
|
+
|
|
52
|
+
function transformWithSourceMap(source: MagicString, id: string) {
|
|
53
|
+
return {
|
|
54
|
+
code: source.toString(),
|
|
55
|
+
map: source.generateMap({ hires: true, source: id }),
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function normalizeSlashes(filePath: string) {
|
|
60
|
+
return filePath.replaceAll('\\', '/');
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function getRefreshRuntimeCode() {
|
|
64
|
+
return `\
|
|
65
|
+
import _RefreshRuntime from "react-refresh/runtime";
|
|
66
|
+
const RefreshRuntime = window.__ReactRefreshRuntime || _RefreshRuntime;
|
|
67
|
+
if (!window.__ReactRefreshRuntime) {
|
|
68
|
+
_RefreshRuntime.injectIntoGlobalHook(window);
|
|
69
|
+
}
|
|
70
|
+
window.__ReactRefreshRuntime = RefreshRuntime;
|
|
71
|
+
${fs.readFileSync(RUNTIME_HELPERS_PATH, 'utf8')}
|
|
72
|
+
export default RefreshRuntime;`;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/* Bridges swc's refresh markers to Vite HMR and the React Fast Refresh runtime. */
|
|
76
|
+
export function reactRefreshPlugin(context: BuildContext): Plugin | undefined {
|
|
77
|
+
if (context.build.isProduction) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const refreshableModuleDirs = findPackages().map(
|
|
82
|
+
({ location }) => normalizeSlashes(location) + '/'
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
return {
|
|
86
|
+
name: 'react-refresh',
|
|
87
|
+
enforce: 'pre',
|
|
88
|
+
/* Serve react-refresh/runtime as an ESM virtual module. */
|
|
89
|
+
resolveId(source) {
|
|
90
|
+
if (source === RUNTIME_ID) {
|
|
91
|
+
return { id: RUNTIME_ID, moduleSideEffects: true };
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
load(id) {
|
|
95
|
+
if (id === RUNTIME_ID) {
|
|
96
|
+
return { code: getRefreshRuntimeCode() };
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
/* Inject the preamble before React and app code load. */
|
|
100
|
+
transformIndexHtml() {
|
|
101
|
+
return [
|
|
102
|
+
{
|
|
103
|
+
tag: 'script',
|
|
104
|
+
attrs: { type: 'module' },
|
|
105
|
+
children: preamble,
|
|
106
|
+
injectTo: 'head-prepend',
|
|
107
|
+
},
|
|
108
|
+
];
|
|
109
|
+
},
|
|
110
|
+
/* Handle modules compiled with swc refresh markers. */
|
|
111
|
+
transform: {
|
|
112
|
+
filter: { code: /\$RefreshReg\$|\$RefreshSig\$/ },
|
|
113
|
+
handler(code, id) {
|
|
114
|
+
const normalizedId = normalizeSlashes(id);
|
|
115
|
+
const isRefreshableModule = refreshableModuleDirs.some(dir =>
|
|
116
|
+
normalizedId.startsWith(dir)
|
|
117
|
+
);
|
|
118
|
+
|
|
119
|
+
/* Prevent non-workspace libraries from registering duplicate refresh families. */
|
|
120
|
+
if (!isRefreshableModule) {
|
|
121
|
+
const source = new MagicString(code);
|
|
122
|
+
const noopPreamble =
|
|
123
|
+
'var $RefreshReg$ = () => {};\nvar $RefreshSig$ = () => (t) => t;\n';
|
|
124
|
+
source.prepend(noopPreamble);
|
|
125
|
+
return transformWithSourceMap(source, id);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/*
|
|
129
|
+
* Workspace modules always get per-module refresh locals. This satisfies
|
|
130
|
+
* $RefreshSig$ calls in HOC-wrapped modules without relying on window globals.
|
|
131
|
+
* Modules with registered component families additionally get an HMR postlude.
|
|
132
|
+
*/
|
|
133
|
+
const source = new MagicString(code);
|
|
134
|
+
source.prepend(modulePrelude);
|
|
135
|
+
|
|
136
|
+
if (code.includes('$RefreshReg$')) {
|
|
137
|
+
source.append(postlude);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
return transformWithSourceMap(source, id);
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
};
|
|
144
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* MIT License
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2019-present, Yuxi (Evan) You and Vite contributors
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
/*
|
|
26
|
+
* Adapted from https://github.com/vitejs/vite-plugin-react/blob/84693214ef8cccc3357561fe4654f401a30dab62/packages/common/refresh-runtime.js.
|
|
27
|
+
* Keep this local because the helpers are bundled into that plugin's virtual
|
|
28
|
+
* runtime and are not exposed as stable public package exports.
|
|
29
|
+
*
|
|
30
|
+
* This file is served inside the browser-only /@react-refresh virtual module.
|
|
31
|
+
* It relies on that module storing the runtime on window.__ReactRefreshRuntime.
|
|
32
|
+
*/
|
|
33
|
+
const refreshCallbacks = [];
|
|
34
|
+
|
|
35
|
+
function getRefreshRuntime() {
|
|
36
|
+
return window.__ReactRefreshRuntime;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Hook for integrations to finish async work before the debounced refresh flush.
|
|
40
|
+
window.__registerBeforePerformReactRefresh = callback => {
|
|
41
|
+
refreshCallbacks.push(callback);
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
function debounce(fn, delay) {
|
|
45
|
+
let handle;
|
|
46
|
+
return () => {
|
|
47
|
+
clearTimeout(handle);
|
|
48
|
+
handle = setTimeout(fn, delay);
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const enqueueUpdate = debounce(async () => {
|
|
53
|
+
if (refreshCallbacks.length) {
|
|
54
|
+
await Promise.all(refreshCallbacks.map(callback => callback()));
|
|
55
|
+
}
|
|
56
|
+
getRefreshRuntime().performReactRefresh();
|
|
57
|
+
}, 16);
|
|
58
|
+
|
|
59
|
+
function predicateOnExport(moduleExports, predicate) {
|
|
60
|
+
for (const key in moduleExports) {
|
|
61
|
+
if (key === '__esModule') {
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
const descriptor = Object.getOwnPropertyDescriptor(moduleExports, key);
|
|
65
|
+
if (descriptor?.get) {
|
|
66
|
+
return key;
|
|
67
|
+
}
|
|
68
|
+
if (!predicate(key, moduleExports[key])) {
|
|
69
|
+
return key;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return true;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export function registerExportsForReactRefresh(id, moduleExports) {
|
|
76
|
+
for (const key in moduleExports) {
|
|
77
|
+
if (key === '__esModule') {
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
const exportValue = moduleExports[key];
|
|
81
|
+
if (getRefreshRuntime().isLikelyComponentType(exportValue)) {
|
|
82
|
+
getRefreshRuntime().register(exportValue, `${id} export ${key}`);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export function validateRefreshBoundaryAndEnqueueUpdate(id, prevExports, nextExports) {
|
|
88
|
+
if (predicateOnExport(prevExports, key => key in nextExports) !== true) {
|
|
89
|
+
return 'Could not Fast Refresh (export removed)';
|
|
90
|
+
}
|
|
91
|
+
if (predicateOnExport(nextExports, key => key in prevExports) !== true) {
|
|
92
|
+
return 'Could not Fast Refresh (new export)';
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
let hasExports = false;
|
|
96
|
+
const allExportsAreComponentsOrUnchanged = predicateOnExport(nextExports, (key, value) => {
|
|
97
|
+
hasExports = true;
|
|
98
|
+
if (getRefreshRuntime().isLikelyComponentType(value)) {
|
|
99
|
+
return true;
|
|
100
|
+
}
|
|
101
|
+
return prevExports[key] === nextExports[key];
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
if (hasExports && allExportsAreComponentsOrUnchanged === true) {
|
|
105
|
+
enqueueUpdate();
|
|
106
|
+
} else {
|
|
107
|
+
return `Could not Fast Refresh ("${allExportsAreComponentsOrUnchanged}" export is incompatible).`;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export function __hmr_import(module) {
|
|
112
|
+
return import(/* @vite-ignore */ module);
|
|
113
|
+
}
|
package/src/vite/plugins/shared-dependencies-plugin/__tests__/shared-dependencies-plugin.test.ts
CHANGED
|
@@ -14,7 +14,7 @@ jest.mock('../../../../core', () => ({
|
|
|
14
14
|
}));
|
|
15
15
|
|
|
16
16
|
describe(sharedDependenciesPlugin.name, () => {
|
|
17
|
-
const CSS_VIRTUAL_PREFIX = '\
|
|
17
|
+
const CSS_VIRTUAL_PREFIX = '\0shared-dependencies:css:';
|
|
18
18
|
const mockDependencies: Record<string, string> = {
|
|
19
19
|
'react': 'globalReact',
|
|
20
20
|
'@scope/lib': 'globalScopeLib',
|
|
@@ -32,7 +32,7 @@ describe(sharedDependenciesPlugin.name, () => {
|
|
|
32
32
|
const subject = () => sharedDependenciesPlugin(options);
|
|
33
33
|
|
|
34
34
|
test('returns plugin with correct name', () => {
|
|
35
|
-
expect(subject().name).toBe('shared-dependencies');
|
|
35
|
+
expect(subject().name).toBe('st:shared-dependencies');
|
|
36
36
|
});
|
|
37
37
|
|
|
38
38
|
test('enforces pre', () => {
|
|
@@ -204,6 +204,21 @@ describe(sharedDependenciesPlugin.name, () => {
|
|
|
204
204
|
});
|
|
205
205
|
});
|
|
206
206
|
|
|
207
|
+
describe('load filter', () => {
|
|
208
|
+
const subject = () => {
|
|
209
|
+
const plugin = sharedDependenciesPlugin(options);
|
|
210
|
+
return (plugin.load as { filter: { id: RegExp } }).filter.id;
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
test('matches the CSS virtual module ids', () => {
|
|
214
|
+
expect(subject().test(`${CSS_VIRTUAL_PREFIX}design-system`)).toBe(true);
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
test('ignores ordinary module ids', () => {
|
|
218
|
+
expect(subject().test('/src/app.tsx')).toBe(false);
|
|
219
|
+
});
|
|
220
|
+
});
|
|
221
|
+
|
|
207
222
|
describe('load', () => {
|
|
208
223
|
const cssName = 'design-system';
|
|
209
224
|
const cssImports = ['tokens.css', 'fonts.css'];
|
|
@@ -217,29 +232,19 @@ describe(sharedDependenciesPlugin.name, () => {
|
|
|
217
232
|
|
|
218
233
|
const subject = () => {
|
|
219
234
|
const plugin = sharedDependenciesPlugin(options);
|
|
220
|
-
return (plugin.load as Function).call(
|
|
221
|
-
};
|
|
222
|
-
|
|
223
|
-
const itReturnsUndefined = () => {
|
|
224
|
-
test('returns undefined', () => {
|
|
225
|
-
expect(subject()).toBeUndefined();
|
|
226
|
-
});
|
|
235
|
+
return (plugin.load as { handler: Function }).handler.call({}, id);
|
|
227
236
|
};
|
|
228
237
|
|
|
229
238
|
test('returns import statements', () => {
|
|
230
239
|
expect(subject()).toBe(cssImports.map(p => `import '${p}';`).join('\n'));
|
|
231
240
|
});
|
|
232
241
|
|
|
233
|
-
describe('when id is not a CSS virtual module', () => {
|
|
234
|
-
beforeEach(() => (id = ''));
|
|
235
|
-
|
|
236
|
-
itReturnsUndefined();
|
|
237
|
-
});
|
|
238
|
-
|
|
239
242
|
describe('with unknown CSS module', () => {
|
|
240
243
|
beforeEach(() => (id = CSS_VIRTUAL_PREFIX + 'unknown'));
|
|
241
244
|
|
|
242
|
-
|
|
245
|
+
test('returns undefined', () => {
|
|
246
|
+
expect(subject()).toBeUndefined();
|
|
247
|
+
});
|
|
243
248
|
});
|
|
244
249
|
});
|
|
245
250
|
|
|
@@ -20,7 +20,8 @@ export function sharedDependenciesPlugin({
|
|
|
20
20
|
css,
|
|
21
21
|
metadataDir,
|
|
22
22
|
}: SharedDependenciesPluginOptions): Plugin {
|
|
23
|
-
const CSS_VIRTUAL_PREFIX = '\
|
|
23
|
+
const CSS_VIRTUAL_PREFIX = '\0shared-dependencies:css:';
|
|
24
|
+
const CSS_VIRTUAL_ID_PATTERN = new RegExp(`^${CSS_VIRTUAL_PREFIX}`);
|
|
24
25
|
|
|
25
26
|
const dependencyNames = Object.keys(dependencies);
|
|
26
27
|
const dependencySet = new Set(dependencyNames);
|
|
@@ -29,7 +30,7 @@ export function sharedDependenciesPlugin({
|
|
|
29
30
|
let isProduction = false;
|
|
30
31
|
|
|
31
32
|
return {
|
|
32
|
-
name: 'shared-dependencies',
|
|
33
|
+
name: 'st:shared-dependencies',
|
|
33
34
|
enforce: 'pre',
|
|
34
35
|
|
|
35
36
|
config(_, env) {
|
|
@@ -100,16 +101,16 @@ export function sharedDependenciesPlugin({
|
|
|
100
101
|
}
|
|
101
102
|
},
|
|
102
103
|
|
|
103
|
-
load
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
104
|
+
load: {
|
|
105
|
+
filter: { id: CSS_VIRTUAL_ID_PATTERN },
|
|
106
|
+
handler(id: string) {
|
|
107
|
+
const name = id.slice(CSS_VIRTUAL_PREFIX.length);
|
|
108
|
+
const imports = cssEntries[name];
|
|
109
|
+
if (!imports) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
return imports.map(p => `import '${p}';`).join('\n');
|
|
113
|
+
},
|
|
113
114
|
},
|
|
114
115
|
|
|
115
116
|
generateBundle(_options, bundle) {
|
|
@@ -7,7 +7,7 @@ export function styleUrlsPlugin(context: BuildContext): Plugin | undefined {
|
|
|
7
7
|
const { isWebComponent } = context.package;
|
|
8
8
|
if (isWebComponent && isProduction) {
|
|
9
9
|
return {
|
|
10
|
-
name: 'style-urls',
|
|
10
|
+
name: 'st:style-urls',
|
|
11
11
|
transformIndexHtml: {
|
|
12
12
|
order: 'post',
|
|
13
13
|
handler(html, ctx) {
|
|
@@ -3,7 +3,8 @@ import type { Plugin } from 'vite';
|
|
|
3
3
|
import { BuildContext, virtualModules } from '../../core';
|
|
4
4
|
|
|
5
5
|
export function virtualModulesPlugin(context: BuildContext): Plugin | undefined {
|
|
6
|
-
const VIRTUAL_PREFIX = '\
|
|
6
|
+
const VIRTUAL_PREFIX = '\0virtual-modules:';
|
|
7
|
+
const VIRTUAL_ID_PATTERN = new RegExp(`^${VIRTUAL_PREFIX}`);
|
|
7
8
|
|
|
8
9
|
const { destination } = context.package;
|
|
9
10
|
|
|
@@ -24,7 +25,7 @@ export function virtualModulesPlugin(context: BuildContext): Plugin | undefined
|
|
|
24
25
|
}
|
|
25
26
|
|
|
26
27
|
return {
|
|
27
|
-
name: 'virtual-modules',
|
|
28
|
+
name: 'st:virtual-modules',
|
|
28
29
|
resolveId(source, importer) {
|
|
29
30
|
if (pluginModules[source]) {
|
|
30
31
|
return VIRTUAL_PREFIX + source;
|
|
@@ -36,11 +37,11 @@ export function virtualModulesPlugin(context: BuildContext): Plugin | undefined
|
|
|
36
37
|
}
|
|
37
38
|
}
|
|
38
39
|
},
|
|
39
|
-
load
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
return pluginModules[
|
|
43
|
-
}
|
|
40
|
+
load: {
|
|
41
|
+
filter: { id: VIRTUAL_ID_PATTERN },
|
|
42
|
+
handler(id) {
|
|
43
|
+
return pluginModules[id.slice(VIRTUAL_PREFIX.length)];
|
|
44
|
+
},
|
|
44
45
|
},
|
|
45
46
|
};
|
|
46
47
|
}
|
|
@@ -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
|
|
|
@@ -11,7 +11,7 @@ import { WebpackAssetsManifest } from 'webpack-assets-manifest';
|
|
|
11
11
|
import RemoveEmptyScriptsPlugin from 'webpack-remove-empty-scripts';
|
|
12
12
|
import VirtualModulesPlugin from 'webpack-virtual-modules';
|
|
13
13
|
import yargs from 'yargs';
|
|
14
|
-
import { getLaunchDarklySdkVersion } from '../../core';
|
|
14
|
+
import { CHUNK_PATTERNS, getLaunchDarklySdkVersion } from '../../core';
|
|
15
15
|
import {
|
|
16
16
|
getFolders,
|
|
17
17
|
getPackageData,
|
|
@@ -350,6 +350,32 @@ describe(`[startup] ${createWebpackConfig.name}`, () => {
|
|
|
350
350
|
cacheGroups.servicetitan.priority ?? 0
|
|
351
351
|
);
|
|
352
352
|
});
|
|
353
|
+
|
|
354
|
+
describe.each(Object.keys(CHUNK_PATTERNS))(
|
|
355
|
+
'optimization.splitChunks.cacheGroups.%s',
|
|
356
|
+
name => {
|
|
357
|
+
const cacheGroup = () =>
|
|
358
|
+
(subject().optimization!.splitChunks as any).cacheGroups[name];
|
|
359
|
+
|
|
360
|
+
test('excludes the design-system chunk', () => {
|
|
361
|
+
expect(cacheGroup().chunks({ name: 'design-system' })).toBe(false);
|
|
362
|
+
});
|
|
363
|
+
|
|
364
|
+
test('claims other chunks', () => {
|
|
365
|
+
expect(cacheGroup().chunks({ name: 'foo' })).toBe(true);
|
|
366
|
+
});
|
|
367
|
+
|
|
368
|
+
describe('when application does not share design system', () => {
|
|
369
|
+
beforeEach(() => {
|
|
370
|
+
jest.mocked(loadSharedDependencies).mockReturnValue({});
|
|
371
|
+
});
|
|
372
|
+
|
|
373
|
+
test('claims all chunks', () => {
|
|
374
|
+
expect(cacheGroup().chunks).toBe('all');
|
|
375
|
+
});
|
|
376
|
+
});
|
|
377
|
+
}
|
|
378
|
+
);
|
|
353
379
|
});
|
|
354
380
|
|
|
355
381
|
test('configures "output.chunkLoadingGlobal"', () => {
|
|
@@ -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
|
});
|