@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,366 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import { SourceMapConsumer } from 'source-map-js';
|
|
3
|
+
import type { Plugin } from 'vite';
|
|
4
|
+
import { reactRefreshPlugin } from '..';
|
|
5
|
+
import type { BuildContext } from '../../../../core';
|
|
6
|
+
import { findPackages } from '../../../../utils';
|
|
7
|
+
|
|
8
|
+
jest.mock('../../../../utils', () => ({
|
|
9
|
+
...jest.requireActual('../../../../utils'),
|
|
10
|
+
findPackages: jest.fn(),
|
|
11
|
+
}));
|
|
12
|
+
|
|
13
|
+
type TransformHook = Extract<Plugin['transform'], { handler: unknown }>;
|
|
14
|
+
|
|
15
|
+
function expectOriginalPosition(
|
|
16
|
+
actual: ReturnType<SourceMapConsumer['originalPositionFor']>,
|
|
17
|
+
expected: { line: number; column: number; source: string }
|
|
18
|
+
) {
|
|
19
|
+
expect({ ...actual, source: actual.source?.replace(/\\/g, '/') }).toEqual(
|
|
20
|
+
expect.objectContaining({
|
|
21
|
+
...expected,
|
|
22
|
+
source: expected.source.replace(/\\/g, '/'),
|
|
23
|
+
})
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
describe('[startup] reactRefreshPlugin', () => {
|
|
28
|
+
const destination = path.join('packages', 'runtime');
|
|
29
|
+
const packageDir = path.resolve(destination) + path.sep;
|
|
30
|
+
const appModuleId = packageDir + 'src/app.tsx';
|
|
31
|
+
const workspaceLibraryModuleId = path.resolve('packages/web-components/dist/loader.js');
|
|
32
|
+
const libraryModuleId = '/node_modules/some-lib/index.js';
|
|
33
|
+
|
|
34
|
+
let code: string;
|
|
35
|
+
let context: BuildContext;
|
|
36
|
+
let id: string;
|
|
37
|
+
let source: string;
|
|
38
|
+
|
|
39
|
+
beforeEach(() => {
|
|
40
|
+
jest.clearAllMocks();
|
|
41
|
+
|
|
42
|
+
code = '';
|
|
43
|
+
id = '';
|
|
44
|
+
source = '';
|
|
45
|
+
context = {
|
|
46
|
+
build: { isProduction: false },
|
|
47
|
+
package: { destination },
|
|
48
|
+
} as unknown as BuildContext;
|
|
49
|
+
jest.mocked(findPackages).mockReturnValue([
|
|
50
|
+
{ location: path.resolve(destination) },
|
|
51
|
+
{ location: path.resolve('packages/web-components') },
|
|
52
|
+
] as ReturnType<typeof findPackages>);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
const subject = () => reactRefreshPlugin(context);
|
|
56
|
+
|
|
57
|
+
test('returns a plugin with name react-refresh', () => {
|
|
58
|
+
expect(subject()!.name).toBe('react-refresh');
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
test('enforces pre order so it runs before built-in transforms', () => {
|
|
62
|
+
expect(subject()!.enforce).toBe('pre');
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
describe('when context.build.isProduction is true', () => {
|
|
66
|
+
beforeEach(() => {
|
|
67
|
+
context.build.isProduction = true;
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
test('returns undefined', () => {
|
|
71
|
+
expect(subject()).toBeUndefined();
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
describe('resolveId', () => {
|
|
76
|
+
beforeEach(() => (source = 'some-other-module'));
|
|
77
|
+
|
|
78
|
+
const subject = () => (reactRefreshPlugin(context)!.resolveId as Function)(source);
|
|
79
|
+
|
|
80
|
+
test('returns undefined', () => {
|
|
81
|
+
expect(subject()).toBeUndefined();
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
describe('when resolving the refresh runtime id', () => {
|
|
85
|
+
beforeEach(() => (source = '/@react-refresh'));
|
|
86
|
+
|
|
87
|
+
test('returns module info', () => {
|
|
88
|
+
expect(subject()).toEqual({
|
|
89
|
+
id: source,
|
|
90
|
+
moduleSideEffects: true,
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
describe('load', () => {
|
|
97
|
+
beforeEach(() => (id = '/some-other-id'));
|
|
98
|
+
|
|
99
|
+
const subject = () => (reactRefreshPlugin(context)!.load as Function)(id);
|
|
100
|
+
|
|
101
|
+
test('returns undefined', () => {
|
|
102
|
+
expect(subject()).toBeUndefined();
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
describe('when loading the refresh runtime id', () => {
|
|
106
|
+
beforeEach(() => (id = '/@react-refresh'));
|
|
107
|
+
|
|
108
|
+
test('returns runtime code', () => {
|
|
109
|
+
expect(subject()).toEqual({
|
|
110
|
+
code: expect.stringContaining(
|
|
111
|
+
'import _RefreshRuntime from "react-refresh/runtime"'
|
|
112
|
+
),
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
test('uses the global singleton pattern', () => {
|
|
117
|
+
expect(subject().code).toContain('window.__ReactRefreshRuntime');
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
test('calls injectIntoGlobalHook', () => {
|
|
121
|
+
expect(subject().code).toContain('if (!window.__ReactRefreshRuntime)');
|
|
122
|
+
expect(subject().code).toContain('_RefreshRuntime.injectIntoGlobalHook(window)');
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
test('includes vendored Vite React refresh boundary helpers', () => {
|
|
126
|
+
expect(subject().code).toContain('export function registerExportsForReactRefresh');
|
|
127
|
+
expect(subject().code).toContain(
|
|
128
|
+
'export function validateRefreshBoundaryAndEnqueueUpdate'
|
|
129
|
+
);
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
test('allows unchanged non-component exports', () => {
|
|
133
|
+
expect(subject().code).toContain('return prevExports[key] === nextExports[key];');
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
test('invalidates incompatible exports with the Vite React message shape', () => {
|
|
137
|
+
expect(subject().code).toContain('Could not Fast Refresh');
|
|
138
|
+
expect(subject().code).toContain('export is incompatible');
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
test('exposes the hidden dynamic import helper used by the postlude', () => {
|
|
142
|
+
expect(subject().code).toContain('export function __hmr_import');
|
|
143
|
+
expect(subject().code).toContain('import(/* @vite-ignore */ module)');
|
|
144
|
+
expect(subject().code).not.toContain('require(');
|
|
145
|
+
});
|
|
146
|
+
});
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
describe('transformIndexHtml', () => {
|
|
150
|
+
const subject = () => (reactRefreshPlugin(context)!.transformIndexHtml as Function)();
|
|
151
|
+
|
|
152
|
+
test('returns a head-prepended module script', () => {
|
|
153
|
+
expect(subject()).toEqual([
|
|
154
|
+
{
|
|
155
|
+
tag: 'script',
|
|
156
|
+
attrs: { type: 'module' },
|
|
157
|
+
children: expect.any(String),
|
|
158
|
+
injectTo: 'head-prepend',
|
|
159
|
+
},
|
|
160
|
+
]);
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
test('imports the runtime as a side effect to trigger injectIntoGlobalHook early', () => {
|
|
164
|
+
expect(subject()[0].children).toContain(`import "/@react-refresh"`);
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
test('does not set window refresh globals', () => {
|
|
168
|
+
expect(subject()[0].children).not.toContain('window.$RefreshReg$');
|
|
169
|
+
expect(subject()[0].children).not.toContain('window.$RefreshSig$');
|
|
170
|
+
});
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
describe('transform', () => {
|
|
174
|
+
const transform = () => reactRefreshPlugin(context)!.transform as TransformHook;
|
|
175
|
+
const subject = () => (transform().handler as Function)(code, id);
|
|
176
|
+
|
|
177
|
+
test('filters transform calls to modules with refresh markers', () => {
|
|
178
|
+
expect(transform().filter).toEqual({ code: /\$RefreshReg\$|\$RefreshSig\$/ });
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
describe('when transforming a non-workspace library module with refresh markers', () => {
|
|
182
|
+
beforeEach(() => {
|
|
183
|
+
code = '$RefreshReg$(App, "App");';
|
|
184
|
+
id = libraryModuleId;
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
test('prepends no-op shadows', () => {
|
|
188
|
+
expect(subject()).toEqual({
|
|
189
|
+
code: expect.stringContaining('var $RefreshReg$ = () => {};'),
|
|
190
|
+
map: expect.any(Object),
|
|
191
|
+
});
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
test('maps original code after the prepended no-ops', () => {
|
|
195
|
+
const result = subject()!;
|
|
196
|
+
const consumer = new SourceMapConsumer(result.map as any);
|
|
197
|
+
const generatedLine =
|
|
198
|
+
result.code.split('\n').findIndex((line: string) => line === code) + 1;
|
|
199
|
+
|
|
200
|
+
expectOriginalPosition(
|
|
201
|
+
consumer.originalPositionFor({ line: generatedLine, column: 0 }),
|
|
202
|
+
{
|
|
203
|
+
line: 1,
|
|
204
|
+
column: 0,
|
|
205
|
+
source: id,
|
|
206
|
+
}
|
|
207
|
+
);
|
|
208
|
+
});
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
describe('when transforming a workspace library module with registered components', () => {
|
|
212
|
+
beforeEach(() => {
|
|
213
|
+
code = '$RefreshReg$(Loader, "Loader"); $RefreshSig$()';
|
|
214
|
+
id = workspaceLibraryModuleId;
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
test('appends the HMR postlude', () => {
|
|
218
|
+
expect(subject()!.code).toContain('import.meta.hot.accept');
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
test('prepends per-module locals scoped to the module URL', () => {
|
|
222
|
+
expect(subject()!.code).toContain(
|
|
223
|
+
'var $RefreshReg$ = (type, id) => RefreshRuntime.register(type, __react_refresh_id__ + " " + id)'
|
|
224
|
+
);
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
test('maps original code after the prepended module prelude', () => {
|
|
228
|
+
const result = subject()!;
|
|
229
|
+
const consumer = new SourceMapConsumer(result.map as any);
|
|
230
|
+
const generatedLine =
|
|
231
|
+
result.code.split('\n').findIndex((line: string) => line === code) + 1;
|
|
232
|
+
|
|
233
|
+
expectOriginalPosition(
|
|
234
|
+
consumer.originalPositionFor({ line: generatedLine, column: 0 }),
|
|
235
|
+
{
|
|
236
|
+
line: 1,
|
|
237
|
+
column: 0,
|
|
238
|
+
source: id,
|
|
239
|
+
}
|
|
240
|
+
);
|
|
241
|
+
});
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
describe('when transforming a workspace module in windows', () => {
|
|
245
|
+
beforeEach(() => {
|
|
246
|
+
code = '$RefreshReg$(App, "App");';
|
|
247
|
+
jest.mocked(findPackages).mockReturnValue([
|
|
248
|
+
{ location: 'C:\\repo\\uikit\\packages\\examples' },
|
|
249
|
+
] as ReturnType<typeof findPackages>);
|
|
250
|
+
id = 'C:/repo/uikit/packages/examples/src/app.tsx';
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
test('treats it as refreshable', () => {
|
|
254
|
+
expect(subject()!.code).toContain('import.meta.hot.accept');
|
|
255
|
+
});
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
describe('when transforming an app module with registered components', () => {
|
|
259
|
+
beforeEach(() => {
|
|
260
|
+
code = 'export const App = () => null; $RefreshReg$(App, "App"); $RefreshSig$()';
|
|
261
|
+
id = appModuleId;
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
test('appends the HMR postlude', () => {
|
|
265
|
+
expect(subject()!.code).toContain('import.meta.hot.accept');
|
|
266
|
+
});
|
|
267
|
+
|
|
268
|
+
test('dynamically imports the current module exports using the stable module id', () => {
|
|
269
|
+
expect(subject()!.code).toContain(
|
|
270
|
+
'__hmr_import(__react_refresh_id__).then(currentExports => {'
|
|
271
|
+
);
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
test('registers component exports before accepting updates', () => {
|
|
275
|
+
expect(subject()!.code).toContain(
|
|
276
|
+
'registerExportsForReactRefresh(__react_refresh_id__, currentExports)'
|
|
277
|
+
);
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
test('invalidates incompatible accepted updates', () => {
|
|
281
|
+
expect(subject()!.code).toContain('import.meta.hot.invalidate(invalidateMessage)');
|
|
282
|
+
});
|
|
283
|
+
|
|
284
|
+
test('delegates boundary validation to the virtual refresh runtime', () => {
|
|
285
|
+
expect(subject()!.code).toContain('validateRefreshBoundaryAndEnqueueUpdate(');
|
|
286
|
+
expect(subject()!.code).toContain('__react_refresh_id__,');
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
test('prepends per-module locals scoped to the module URL', () => {
|
|
290
|
+
expect(subject()!.code).toContain(
|
|
291
|
+
'var $RefreshReg$ = (type, id) => RefreshRuntime.register(type, __react_refresh_id__ + " " + id)'
|
|
292
|
+
);
|
|
293
|
+
});
|
|
294
|
+
|
|
295
|
+
test('maps original code after the prepended module prelude', () => {
|
|
296
|
+
const result = subject()!;
|
|
297
|
+
const consumer = new SourceMapConsumer(result.map as any);
|
|
298
|
+
const generatedLine =
|
|
299
|
+
result.code.split('\n').findIndex((line: string) => line === code) + 1;
|
|
300
|
+
|
|
301
|
+
expectOriginalPosition(
|
|
302
|
+
consumer.originalPositionFor({ line: generatedLine, column: 0 }),
|
|
303
|
+
{
|
|
304
|
+
line: 1,
|
|
305
|
+
column: 0,
|
|
306
|
+
source: id,
|
|
307
|
+
}
|
|
308
|
+
);
|
|
309
|
+
});
|
|
310
|
+
});
|
|
311
|
+
|
|
312
|
+
describe('when transforming an app module without registered components', () => {
|
|
313
|
+
beforeEach(() => {
|
|
314
|
+
code = '$RefreshSig$()';
|
|
315
|
+
id = appModuleId;
|
|
316
|
+
});
|
|
317
|
+
|
|
318
|
+
test('prepends refresh locals so $RefreshSig$ calls resolve without window globals', () => {
|
|
319
|
+
expect(subject()!.code).toContain('var $RefreshSig$');
|
|
320
|
+
});
|
|
321
|
+
|
|
322
|
+
test('does not append the HMR postlude', () => {
|
|
323
|
+
expect(subject()!.code).not.toContain('import.meta.hot.accept');
|
|
324
|
+
});
|
|
325
|
+
});
|
|
326
|
+
|
|
327
|
+
describe('when transforming an app module with a mixed registered and HOC export', () => {
|
|
328
|
+
beforeEach(() => {
|
|
329
|
+
code = `
|
|
330
|
+
const EventBusExample = lazy(() => import('./event-bus-example'));
|
|
331
|
+
export const App = provide({})(() => null);
|
|
332
|
+
$RefreshReg$(EventBusExample, "EventBusExample");
|
|
333
|
+
$RefreshSig$();`;
|
|
334
|
+
id = appModuleId;
|
|
335
|
+
});
|
|
336
|
+
|
|
337
|
+
test('dynamically imports exports even when only another value is registered', () => {
|
|
338
|
+
expect(subject()!.code).toContain(
|
|
339
|
+
'__hmr_import(__react_refresh_id__).then(currentExports => {'
|
|
340
|
+
);
|
|
341
|
+
});
|
|
342
|
+
|
|
343
|
+
test('invalidates changed non-component exports instead of swallowing the update', () => {
|
|
344
|
+
expect(subject()!.code).toContain('validateRefreshBoundaryAndEnqueueUpdate(');
|
|
345
|
+
expect(subject()!.code).toContain('import.meta.hot.invalidate(invalidateMessage)');
|
|
346
|
+
});
|
|
347
|
+
});
|
|
348
|
+
|
|
349
|
+
describe('when transforming an app module with named exports', () => {
|
|
350
|
+
beforeEach(() => {
|
|
351
|
+
code = `
|
|
352
|
+
const Component = () => null;
|
|
353
|
+
const OtherComponent = () => null;
|
|
354
|
+
export { Component as App, OtherComponent };
|
|
355
|
+
$RefreshReg$(Component, "Component");
|
|
356
|
+
$RefreshReg$(OtherComponent, "OtherComponent");`;
|
|
357
|
+
id = appModuleId;
|
|
358
|
+
});
|
|
359
|
+
|
|
360
|
+
test('uses the runtime module namespace instead of parsing export syntax', () => {
|
|
361
|
+
expect(subject()!.code).toContain('currentExports');
|
|
362
|
+
expect(subject()!.code).not.toContain('__react_refresh_current_exports__');
|
|
363
|
+
});
|
|
364
|
+
});
|
|
365
|
+
});
|
|
366
|
+
});
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__hmr_import,
|
|
3
|
+
registerExportsForReactRefresh,
|
|
4
|
+
validateRefreshBoundaryAndEnqueueUpdate,
|
|
5
|
+
} from '../refresh-runtime.js';
|
|
6
|
+
|
|
7
|
+
declare global {
|
|
8
|
+
interface Window {
|
|
9
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
10
|
+
__registerBeforePerformReactRefresh: (callback: () => Promise<void>) => void;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
describe('[startup] react refresh runtime helpers', () => {
|
|
15
|
+
const moduleId = '/dist/app.js';
|
|
16
|
+
const component = () => null;
|
|
17
|
+
|
|
18
|
+
let nextExports: Record<string, unknown>;
|
|
19
|
+
let prevExports: Record<string, unknown>;
|
|
20
|
+
let RefreshRuntime: {
|
|
21
|
+
isLikelyComponentType: jest.Mock;
|
|
22
|
+
performReactRefresh: jest.Mock;
|
|
23
|
+
register: jest.Mock;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
beforeEach(() => {
|
|
27
|
+
jest.clearAllMocks();
|
|
28
|
+
jest.useFakeTimers();
|
|
29
|
+
|
|
30
|
+
RefreshRuntime = {
|
|
31
|
+
isLikelyComponentType: jest.fn(value => value === component),
|
|
32
|
+
performReactRefresh: jest.fn(),
|
|
33
|
+
register: jest.fn(),
|
|
34
|
+
};
|
|
35
|
+
Object.defineProperty(window, '__ReactRefreshRuntime', {
|
|
36
|
+
configurable: true,
|
|
37
|
+
value: RefreshRuntime,
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
afterEach(() => {
|
|
42
|
+
jest.useRealTimers();
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
describe('registerExportsForReactRefresh', () => {
|
|
46
|
+
const subject = () => {
|
|
47
|
+
const moduleExports = {
|
|
48
|
+
App: component,
|
|
49
|
+
count: 1,
|
|
50
|
+
};
|
|
51
|
+
Object.defineProperty(moduleExports, '__esModule', {
|
|
52
|
+
enumerable: true,
|
|
53
|
+
value: true,
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
registerExportsForReactRefresh(moduleId, moduleExports);
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
test('registers component exports', () => {
|
|
60
|
+
subject();
|
|
61
|
+
|
|
62
|
+
expect(RefreshRuntime.register).toHaveBeenCalledWith(
|
|
63
|
+
component,
|
|
64
|
+
`${moduleId} export App`
|
|
65
|
+
);
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
test('skips non-component exports', () => {
|
|
69
|
+
subject();
|
|
70
|
+
|
|
71
|
+
expect(RefreshRuntime.register).toHaveBeenCalledTimes(1);
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
describe('validateRefreshBoundaryAndEnqueueUpdate', () => {
|
|
76
|
+
beforeEach(() => {
|
|
77
|
+
prevExports = { App: component };
|
|
78
|
+
nextExports = { App: component };
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
const subject = () =>
|
|
82
|
+
validateRefreshBoundaryAndEnqueueUpdate(moduleId, prevExports, nextExports);
|
|
83
|
+
|
|
84
|
+
function itQueuesASingleRefresh() {
|
|
85
|
+
test('queues a single refresh', async () => {
|
|
86
|
+
subject();
|
|
87
|
+
await jest.advanceTimersByTimeAsync(16);
|
|
88
|
+
|
|
89
|
+
expect(RefreshRuntime.performReactRefresh).toHaveBeenCalledTimes(1);
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
itQueuesASingleRefresh();
|
|
94
|
+
|
|
95
|
+
describe('with a before refresh callback', () => {
|
|
96
|
+
const callback = jest.fn(async () => {});
|
|
97
|
+
|
|
98
|
+
beforeEach(() => window.__registerBeforePerformReactRefresh(callback));
|
|
99
|
+
|
|
100
|
+
test('runs the callback before refreshing', async () => {
|
|
101
|
+
subject();
|
|
102
|
+
await jest.advanceTimersByTimeAsync(16);
|
|
103
|
+
|
|
104
|
+
expect(callback).toHaveBeenCalledTimes(1);
|
|
105
|
+
expect(RefreshRuntime.performReactRefresh).toHaveBeenCalledTimes(1);
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
describe('with __esModule exports', () => {
|
|
110
|
+
beforeEach(() => {
|
|
111
|
+
Object.defineProperty(prevExports, '__esModule', {
|
|
112
|
+
enumerable: true,
|
|
113
|
+
value: true,
|
|
114
|
+
});
|
|
115
|
+
Object.defineProperty(nextExports, '__esModule', {
|
|
116
|
+
enumerable: true,
|
|
117
|
+
value: true,
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
itQueuesASingleRefresh();
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
describe('with unchanged non-component exports', () => {
|
|
125
|
+
const unchangedValue = { stable: true };
|
|
126
|
+
|
|
127
|
+
beforeEach(() => {
|
|
128
|
+
prevExports.value = unchangedValue;
|
|
129
|
+
nextExports.value = unchangedValue;
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
itQueuesASingleRefresh();
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
describe('with changed non-component exports', () => {
|
|
136
|
+
beforeEach(() => {
|
|
137
|
+
prevExports.value = 'before';
|
|
138
|
+
nextExports.value = 'after';
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
test('returns an incompatible export message', () => {
|
|
142
|
+
expect(subject()).toBe('Could not Fast Refresh ("value" export is incompatible).');
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
describe('with removed exports', () => {
|
|
147
|
+
beforeEach(() => {
|
|
148
|
+
prevExports.value = 'before';
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
test('returns an export removed message', () => {
|
|
152
|
+
expect(subject()).toBe('Could not Fast Refresh (export removed)');
|
|
153
|
+
});
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
describe('with new exports', () => {
|
|
157
|
+
beforeEach(() => {
|
|
158
|
+
nextExports.value = 'after';
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
test('returns a new export message', () => {
|
|
162
|
+
expect(subject()).toBe('Could not Fast Refresh (new export)');
|
|
163
|
+
});
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
describe('with getter exports', () => {
|
|
167
|
+
beforeEach(() => {
|
|
168
|
+
Object.defineProperty(nextExports, 'value', {
|
|
169
|
+
enumerable: true,
|
|
170
|
+
get: () => {
|
|
171
|
+
throw new Error('getter should not run');
|
|
172
|
+
},
|
|
173
|
+
});
|
|
174
|
+
Object.defineProperty(prevExports, 'value', {
|
|
175
|
+
enumerable: true,
|
|
176
|
+
value: 'before',
|
|
177
|
+
});
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
test('returns an invalidation message', () => {
|
|
181
|
+
expect(subject()).toContain('Could not Fast Refresh');
|
|
182
|
+
});
|
|
183
|
+
});
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
describe('__hmr_import', () => {
|
|
187
|
+
const subject = () => __hmr_import('missing-refresh-runtime-test-module');
|
|
188
|
+
|
|
189
|
+
test('delegates to native dynamic import', async () => {
|
|
190
|
+
await expect(subject()).rejects.toThrow();
|
|
191
|
+
});
|
|
192
|
+
});
|
|
193
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './react-refresh-plugin';
|