@servicetitan/startup 38.0.0 → 38.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/js-yaml.js +2 -2
- package/dist/cli/commands/build.d.ts.map +1 -1
- package/dist/cli/commands/build.js +22 -9
- package/dist/cli/commands/build.js.map +1 -1
- package/dist/cli/commands/bundle-package.d.ts +6 -0
- package/dist/cli/commands/bundle-package.d.ts.map +1 -0
- package/dist/cli/commands/bundle-package.js +59 -0
- package/dist/cli/commands/bundle-package.js.map +1 -0
- package/dist/cli/commands/bundle-vite.js +13 -4
- package/dist/cli/commands/bundle-vite.js.map +1 -1
- package/dist/cli/commands/bundle-webpack.js +13 -4
- package/dist/cli/commands/bundle-webpack.js.map +1 -1
- package/dist/cli/commands/clean.js +13 -4
- package/dist/cli/commands/clean.js.map +1 -1
- package/dist/cli/commands/command.d.ts +9 -0
- package/dist/cli/commands/command.d.ts.map +1 -0
- package/dist/cli/commands/command.js +35 -0
- package/dist/cli/commands/command.js.map +1 -0
- package/dist/cli/commands/convert-eslint-config.js +14 -7
- package/dist/cli/commands/convert-eslint-config.js.map +1 -1
- package/dist/cli/commands/eslint.js +13 -4
- package/dist/cli/commands/eslint.js.map +1 -1
- package/dist/cli/commands/init.js +13 -4
- package/dist/cli/commands/init.js.map +1 -1
- package/dist/cli/commands/install.js +13 -4
- package/dist/cli/commands/install.js.map +1 -1
- package/dist/cli/commands/kendo-ui-license.js +13 -4
- package/dist/cli/commands/kendo-ui-license.js.map +1 -1
- package/dist/cli/commands/lint.js +13 -4
- package/dist/cli/commands/lint.js.map +1 -1
- package/dist/cli/commands/mfe-check.d.ts.map +1 -1
- package/dist/cli/commands/mfe-check.js +15 -7
- package/dist/cli/commands/mfe-check.js.map +1 -1
- package/dist/cli/commands/mfe-generate-metadata.js +13 -4
- package/dist/cli/commands/mfe-generate-metadata.js.map +1 -1
- package/dist/cli/commands/mfe-list.js +13 -4
- package/dist/cli/commands/mfe-list.js.map +1 -1
- package/dist/cli/commands/mfe-package-clean.js +13 -4
- package/dist/cli/commands/mfe-package-clean.js.map +1 -1
- package/dist/cli/commands/mfe-package-publish.js +13 -4
- package/dist/cli/commands/mfe-package-publish.js.map +1 -1
- package/dist/cli/commands/mfe-package-rollback.js +13 -4
- package/dist/cli/commands/mfe-package-rollback.js.map +1 -1
- package/dist/cli/commands/mfe-publish.js +13 -4
- package/dist/cli/commands/mfe-publish.js.map +1 -1
- package/dist/cli/commands/mfe-purge-cache.js +13 -4
- package/dist/cli/commands/mfe-purge-cache.js.map +1 -1
- package/dist/cli/commands/prepare-package.js +13 -4
- package/dist/cli/commands/prepare-package.js.map +1 -1
- package/dist/cli/commands/registry/build.d.ts +1 -1
- package/dist/cli/commands/registry/build.d.ts.map +1 -1
- package/dist/cli/commands/registry/build.js +3 -5
- package/dist/cli/commands/registry/build.js.map +1 -1
- package/dist/cli/commands/registry/bundle-package.d.ts +41 -0
- package/dist/cli/commands/registry/bundle-package.d.ts.map +1 -0
- package/dist/cli/commands/registry/bundle-package.js +54 -0
- package/dist/cli/commands/registry/bundle-package.js.map +1 -0
- package/dist/cli/commands/registry/command-registry.d.ts +42 -2
- package/dist/cli/commands/registry/command-registry.d.ts.map +1 -1
- package/dist/cli/commands/registry/command-registry.js +10 -19
- package/dist/cli/commands/registry/command-registry.js.map +1 -1
- package/dist/cli/commands/registry/start.d.ts +1 -1
- package/dist/cli/commands/registry/start.d.ts.map +1 -1
- package/dist/cli/commands/registry/start.js +3 -5
- package/dist/cli/commands/registry/start.js.map +1 -1
- package/dist/cli/commands/review/review.js +14 -7
- package/dist/cli/commands/review/review.js.map +1 -1
- package/dist/cli/commands/review/rules/no-deprecated-content-base.js +1 -3
- package/dist/cli/commands/review/rules/no-deprecated-content-base.js.map +1 -1
- package/dist/cli/commands/review/rules/no-direct-peer-dependencies.js +1 -3
- package/dist/cli/commands/review/rules/no-direct-peer-dependencies.js.map +1 -1
- package/dist/cli/commands/review/rules/no-typescript-entry-point.js +1 -3
- package/dist/cli/commands/review/rules/no-typescript-entry-point.js.map +1 -1
- package/dist/cli/commands/review/rules/prefer-open-ended-peer-dependencies.js +5 -12
- package/dist/cli/commands/review/rules/prefer-open-ended-peer-dependencies.js.map +1 -1
- package/dist/cli/commands/review/rules/require-compatible-launch-darkly-sdk.js +5 -12
- package/dist/cli/commands/review/rules/require-compatible-launch-darkly-sdk.js.map +1 -1
- package/dist/cli/commands/review/rules/require-explicit-side-effects.js +1 -3
- package/dist/cli/commands/review/rules/require-explicit-side-effects.js.map +1 -1
- package/dist/cli/commands/review/rules/require-one-collection-version.js +1 -3
- package/dist/cli/commands/review/rules/require-one-collection-version.js.map +1 -1
- package/dist/cli/commands/review/rules/require-servicetitan-scope.js +1 -3
- package/dist/cli/commands/review/rules/require-servicetitan-scope.js.map +1 -1
- package/dist/cli/commands/review/rules/require-tsconfig-references.js +1 -3
- package/dist/cli/commands/review/rules/require-tsconfig-references.js.map +1 -1
- package/dist/cli/commands/review/utils/compare-version.js +8 -19
- package/dist/cli/commands/review/utils/compare-version.js.map +1 -1
- package/dist/cli/commands/run-task.d.ts +1 -0
- package/dist/cli/commands/run-task.d.ts.map +1 -1
- package/dist/cli/commands/run-task.js +20 -6
- package/dist/cli/commands/run-task.js.map +1 -1
- package/dist/cli/commands/start.d.ts.map +1 -1
- package/dist/cli/commands/start.js +28 -13
- package/dist/cli/commands/start.js.map +1 -1
- package/dist/cli/commands/stylelint.js +13 -4
- package/dist/cli/commands/stylelint.js.map +1 -1
- package/dist/cli/commands/styles-check.js +13 -4
- package/dist/cli/commands/styles-check.js.map +1 -1
- package/dist/cli/commands/test/runners/jest.js +1 -3
- package/dist/cli/commands/test/runners/jest.js.map +1 -1
- package/dist/cli/commands/test/tests.js +13 -4
- package/dist/cli/commands/test/tests.js.map +1 -1
- package/dist/cli/commands/types.d.ts +1 -6
- package/dist/cli/commands/types.d.ts.map +1 -1
- package/dist/cli/commands/types.js +2 -20
- package/dist/cli/commands/types.js.map +1 -1
- package/dist/cli/commands/upload-sourcemaps.js +17 -13
- package/dist/cli/commands/upload-sourcemaps.js.map +1 -1
- package/dist/cli/index.js +1 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/tasks/cli-task.d.ts +3 -0
- package/dist/cli/tasks/cli-task.d.ts.map +1 -1
- package/dist/cli/tasks/cli-task.js +41 -9
- package/dist/cli/tasks/cli-task.js.map +1 -1
- package/dist/cli/tasks/swc-compile-package/get-swc-options.d.ts +9 -1
- package/dist/cli/tasks/swc-compile-package/get-swc-options.d.ts.map +1 -1
- package/dist/cli/tasks/swc-compile-package/get-swc-options.js +18 -2
- package/dist/cli/tasks/swc-compile-package/get-swc-options.js.map +1 -1
- package/dist/cli/tasks/swc-compile-package/swc-compile-package.d.ts +3 -1
- package/dist/cli/tasks/swc-compile-package/swc-compile-package.d.ts.map +1 -1
- package/dist/cli/tasks/swc-compile-package/swc-compile-package.js +17 -3
- package/dist/cli/tasks/swc-compile-package/swc-compile-package.js.map +1 -1
- package/dist/cli/tasks/task.d.ts +2 -1
- package/dist/cli/tasks/task.d.ts.map +1 -1
- package/dist/cli/tasks/task.js +6 -3
- package/dist/cli/tasks/task.js.map +1 -1
- package/dist/cli/tasks/tsc-compile/tsc-compile.js +1 -3
- package/dist/cli/tasks/tsc-compile/tsc-compile.js.map +1 -1
- package/dist/cli/utils/cli-npm.d.ts.map +1 -1
- package/dist/cli/utils/cli-npm.js +8 -1
- package/dist/cli/utils/cli-npm.js.map +1 -1
- package/dist/cli/utils/cli-os.d.ts +1 -0
- package/dist/cli/utils/cli-os.d.ts.map +1 -1
- package/dist/cli/utils/cli-os.js +20 -0
- package/dist/cli/utils/cli-os.js.map +1 -1
- package/dist/cli/utils/compile.d.ts.map +1 -1
- package/dist/cli/utils/compile.js +7 -4
- package/dist/cli/utils/compile.js.map +1 -1
- package/dist/cli/utils/copy-files.js +1 -0
- package/dist/cli/utils/copy-files.js.map +1 -1
- package/dist/cli/utils/index.d.ts +1 -1
- package/dist/cli/utils/index.d.ts.map +1 -1
- package/dist/cli/utils/index.js +1 -1
- package/dist/cli/utils/index.js.map +1 -1
- package/dist/cli/utils/process-tree.js +2 -6
- package/dist/cli/utils/process-tree.js.map +1 -1
- package/dist/cli/utils/resolve-bundler.d.ts.map +1 -1
- package/dist/cli/utils/resolve-bundler.js +2 -1
- package/dist/cli/utils/resolve-bundler.js.map +1 -1
- package/dist/cli/utils/ts-config.d.ts +1 -1
- package/dist/cli/utils/ts-config.d.ts.map +1 -1
- package/dist/cli/utils/ts-config.js +1 -3
- package/dist/cli/utils/ts-config.js.map +1 -1
- package/dist/cli/utils/with-exponential-backoff.d.ts +7 -0
- package/dist/cli/utils/with-exponential-backoff.d.ts.map +1 -0
- package/dist/cli/utils/with-exponential-backoff.js +28 -0
- package/dist/cli/utils/with-exponential-backoff.js.map +1 -0
- package/dist/core/constants.d.ts +2 -0
- package/dist/core/constants.d.ts.map +1 -1
- package/dist/core/constants.js +6 -1
- package/dist/core/constants.js.map +1 -1
- package/dist/postinstall.js +118 -0
- package/dist/scripts/generate-bin-wrappers.js +203 -0
- package/dist/storybook-config/swc.d.ts +6 -0
- package/dist/storybook-config/swc.d.ts.map +1 -1
- package/dist/storybook-config/webpack-final.d.ts.map +1 -1
- package/dist/storybook-config/webpack-final.js +2 -1
- package/dist/storybook-config/webpack-final.js.map +1 -1
- package/dist/utils/exit-when-parent-exits.d.ts +6 -0
- package/dist/utils/exit-when-parent-exits.d.ts.map +1 -0
- package/dist/utils/exit-when-parent-exits.js +37 -0
- package/dist/utils/exit-when-parent-exits.js.map +1 -0
- package/dist/utils/find-up.d.ts +1 -1
- package/dist/utils/find-up.d.ts.map +1 -1
- package/dist/utils/find-up.js +2 -2
- package/dist/utils/find-up.js.map +1 -1
- package/dist/utils/get-configuration.d.ts +6 -3
- package/dist/utils/get-configuration.d.ts.map +1 -1
- package/dist/utils/get-configuration.js +10 -2
- package/dist/utils/get-configuration.js.map +1 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +1 -0
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/log.js +1 -3
- package/dist/utils/log.js.map +1 -1
- package/dist/vite/build-shared-dependencies.d.ts.map +1 -1
- package/dist/vite/build-shared-dependencies.js +2 -0
- package/dist/vite/build-shared-dependencies.js.map +1 -1
- package/dist/vite/config/base-config.d.ts.map +1 -1
- package/dist/vite/config/base-config.js +12 -1
- package/dist/vite/config/base-config.js.map +1 -1
- package/dist/vite/config/create-vite-config.js +7 -2
- package/dist/vite/config/create-vite-config.js.map +1 -1
- package/dist/vite/config/load-config-file.js +8 -19
- package/dist/vite/config/load-config-file.js.map +1 -1
- package/dist/vite/index.d.ts +2 -0
- package/dist/vite/index.d.ts.map +1 -1
- package/dist/vite/index.html +2 -2
- package/dist/vite/index.js +16 -0
- package/dist/vite/index.js.map +1 -1
- package/dist/vite/plugins/chain-source-maps-plugin.js +1 -1
- package/dist/vite/plugins/chain-source-maps-plugin.js.map +1 -1
- package/dist/vite/plugins/clean-plugin.js +1 -1
- package/dist/vite/plugins/clean-plugin.js.map +1 -1
- package/dist/vite/plugins/css-injector-plugin.js +1 -1
- package/dist/vite/plugins/css-injector-plugin.js.map +1 -1
- package/dist/vite/plugins/design-system-guard-plugin.d.ts.map +1 -1
- package/dist/vite/plugins/design-system-guard-plugin.js +10 -5
- package/dist/vite/plugins/design-system-guard-plugin.js.map +1 -1
- package/dist/vite/plugins/dev-server-routing-plugin.js +1 -1
- package/dist/vite/plugins/dev-server-routing-plugin.js.map +1 -1
- package/dist/vite/plugins/externals-plugin.d.ts.map +1 -1
- package/dist/vite/plugins/externals-plugin.js +11 -5
- package/dist/vite/plugins/externals-plugin.js.map +1 -1
- package/dist/vite/plugins/html-plugin.d.ts.map +1 -1
- package/dist/vite/plugins/html-plugin.js +5 -3
- package/dist/vite/plugins/html-plugin.js.map +1 -1
- package/dist/vite/plugins/ignore-modules-plugin.d.ts +2 -2
- package/dist/vite/plugins/ignore-modules-plugin.d.ts.map +1 -1
- package/dist/vite/plugins/ignore-modules-plugin.js +36 -24
- package/dist/vite/plugins/ignore-modules-plugin.js.map +1 -1
- package/dist/vite/plugins/index.d.ts +3 -0
- package/dist/vite/plugins/index.d.ts.map +1 -1
- package/dist/vite/plugins/index.js +3 -0
- package/dist/vite/plugins/index.js.map +1 -1
- package/dist/vite/plugins/less-tilde-plugin.d.ts +8 -0
- package/dist/vite/plugins/less-tilde-plugin.d.ts.map +1 -0
- package/dist/vite/plugins/less-tilde-plugin.js +53 -0
- package/dist/vite/plugins/less-tilde-plugin.js.map +1 -0
- package/dist/vite/plugins/magic-comments-plugin/magic-comments-plugin.js +1 -1
- package/dist/vite/plugins/magic-comments-plugin/magic-comments-plugin.js.map +1 -1
- package/dist/vite/plugins/metadata-plugin.js +1 -1
- package/dist/vite/plugins/metadata-plugin.js.map +1 -1
- package/dist/vite/plugins/moment-locales-plugin.d.ts +1 -1
- package/dist/vite/plugins/moment-locales-plugin.d.ts.map +1 -1
- package/dist/vite/plugins/moment-locales-plugin.js +30 -14
- package/dist/vite/plugins/moment-locales-plugin.js.map +1 -1
- package/dist/vite/plugins/react-refresh-plugin/index.d.ts +2 -0
- package/dist/vite/plugins/react-refresh-plugin/index.d.ts.map +1 -0
- package/dist/vite/plugins/react-refresh-plugin/index.js +20 -0
- package/dist/vite/plugins/react-refresh-plugin/index.js.map +1 -0
- package/dist/vite/plugins/react-refresh-plugin/react-refresh-plugin.d.ts +4 -0
- package/dist/vite/plugins/react-refresh-plugin/react-refresh-plugin.d.ts.map +1 -0
- package/dist/vite/plugins/react-refresh-plugin/react-refresh-plugin.js +143 -0
- package/dist/vite/plugins/react-refresh-plugin/react-refresh-plugin.js.map +1 -0
- package/dist/vite/plugins/react-refresh-plugin/refresh-runtime.js +113 -0
- package/dist/vite/plugins/shared-dependencies-plugin/shared-dependencies-plugin.d.ts.map +1 -1
- package/dist/vite/plugins/shared-dependencies-plugin/shared-dependencies-plugin.js +14 -11
- package/dist/vite/plugins/shared-dependencies-plugin/shared-dependencies-plugin.js.map +1 -1
- package/dist/vite/plugins/style-urls-plugin.js +1 -1
- package/dist/vite/plugins/style-urls-plugin.js.map +1 -1
- package/dist/vite/plugins/virtual-modules-plugin.d.ts.map +1 -1
- package/dist/vite/plugins/virtual-modules-plugin.js +9 -6
- package/dist/vite/plugins/virtual-modules-plugin.js.map +1 -1
- package/dist/vite/plugins/window-externals-plugin.d.ts +22 -0
- package/dist/vite/plugins/window-externals-plugin.d.ts.map +1 -0
- package/dist/vite/plugins/window-externals-plugin.js +74 -0
- package/dist/vite/plugins/window-externals-plugin.js.map +1 -0
- package/dist/webpack/bundle-webpack.d.ts.map +1 -1
- package/dist/webpack/bundle-webpack.js +6 -1
- package/dist/webpack/bundle-webpack.js.map +1 -1
- package/dist/webpack/configs/optimization-config.js +4 -4
- package/dist/webpack/configs/optimization-config.js.map +1 -1
- package/dist/webpack/configs/output-config.js +1 -1
- package/dist/webpack/configs/output-config.js.map +1 -1
- package/dist/webpack/configs/plugins/ignore-plugin/ignore-plugin.js +1 -3
- package/dist/webpack/configs/plugins/ignore-plugin/ignore-plugin.js.map +1 -1
- package/dist/webpack/loaders/expose-loader/__tests__/__mocks__/configuration.expose-loader.js +13 -0
- package/dist/webpack/loaders/expose-loader/__tests__/__mocks__/index.js +1 -0
- package/dist/webpack/utils/index.d.ts +1 -0
- package/dist/webpack/utils/index.d.ts.map +1 -1
- package/dist/webpack/utils/index.js +1 -0
- package/dist/webpack/utils/index.js.map +1 -1
- package/dist/webpack/utils/normalize-proxy-config.d.ts +6 -0
- package/dist/webpack/utils/normalize-proxy-config.d.ts.map +1 -0
- package/dist/webpack/utils/normalize-proxy-config.js +52 -0
- package/dist/webpack/utils/normalize-proxy-config.js.map +1 -0
- package/package.json +24 -21
- package/src/cli/commands/__tests__/build.test.ts +33 -19
- package/src/cli/commands/__tests__/bundle-package.test.ts +65 -0
- package/src/cli/commands/__tests__/command.test.ts +42 -0
- package/src/cli/commands/__tests__/mfe-check.test.ts +26 -5
- package/src/cli/commands/__tests__/run-task.test.ts +20 -1
- package/src/cli/commands/__tests__/start.test.ts +35 -15
- package/src/cli/commands/build.ts +6 -5
- package/src/cli/commands/bundle-package.ts +20 -0
- package/src/cli/commands/command.ts +14 -0
- package/src/cli/commands/mfe-check.ts +6 -10
- package/src/cli/commands/registry/build.ts +3 -2
- package/src/cli/commands/registry/bundle-package.ts +22 -0
- package/src/cli/commands/registry/command-registry.ts +2 -0
- package/src/cli/commands/registry/start.ts +3 -2
- package/src/cli/commands/run-task.ts +8 -2
- package/src/cli/commands/start.ts +9 -5
- package/src/cli/commands/types.ts +2 -6
- package/src/cli/index.ts +3 -0
- package/src/cli/tasks/__tests__/cli-task.test.ts +181 -69
- package/src/cli/tasks/__tests__/task.test.ts +40 -45
- package/src/cli/tasks/cli-task.ts +43 -2
- package/src/cli/tasks/swc-compile-package/__tests__/get-swc-options.test.ts +46 -4
- package/src/cli/tasks/swc-compile-package/__tests__/swc-compile-package.test.ts +25 -4
- package/src/cli/tasks/swc-compile-package/get-swc-options.ts +14 -1
- package/src/cli/tasks/swc-compile-package/swc-compile-package.ts +6 -2
- package/src/cli/tasks/task.ts +8 -2
- package/src/cli/tasks/tsc-compile/__tests__/tsc-compile.test.ts +8 -32
- package/src/cli/tasks/tsc-compile-package/__tests__/tsc-compile-package.test.ts +10 -19
- package/src/cli/utils/__tests__/cli-npm.test.ts +33 -0
- package/src/cli/utils/__tests__/cli-os.test.ts +86 -3
- package/src/cli/utils/__tests__/compile.test.ts +37 -2
- package/src/cli/utils/__tests__/copy-files.test.ts +1 -1
- package/src/cli/utils/__tests__/with-exponential-backoff.test.ts +119 -0
- package/src/cli/utils/cli-npm.ts +19 -4
- package/src/cli/utils/cli-os.ts +14 -0
- package/src/cli/utils/compile.ts +8 -1
- package/src/cli/utils/copy-files.ts +1 -1
- package/src/cli/utils/index.ts +1 -1
- package/src/cli/utils/resolve-bundler.ts +2 -1
- package/src/cli/utils/ts-config.ts +1 -1
- package/src/cli/utils/with-exponential-backoff.ts +28 -0
- package/src/core/constants.ts +2 -0
- package/src/storybook-config/__tests__/vite-final.test.ts +6 -0
- package/src/storybook-config/__tests__/webpack-final.test.ts +26 -12
- package/src/storybook-config/webpack-final.ts +10 -4
- package/src/utils/__tests__/exit-when-parent-exits.test.ts +87 -0
- package/src/utils/__tests__/find-up.test.ts +49 -0
- package/src/utils/__tests__/get-configuration.test.ts +62 -0
- package/src/utils/exit-when-parent-exits.ts +33 -0
- package/src/utils/find-up.ts +2 -2
- package/src/utils/get-configuration.ts +14 -5
- package/src/utils/index.ts +1 -0
- package/src/vite/__tests__/build-shared-dependencies.test.ts +39 -5
- package/src/vite/build-shared-dependencies.ts +2 -1
- package/src/vite/config/__tests__/base-config.test.ts +12 -4
- package/src/vite/config/__tests__/create-css-config.test.ts +2 -6
- package/src/vite/config/__tests__/create-vite-config.test.ts +6 -3
- package/src/vite/config/base-config.ts +13 -1
- package/src/vite/config/create-vite-config.ts +6 -3
- package/src/vite/index.html +2 -2
- package/src/vite/index.ts +2 -0
- package/src/vite/plugins/__tests__/chain-source-maps-plugin.test.ts +1 -1
- package/src/vite/plugins/__tests__/clean-plugin.test.ts +1 -1
- package/src/vite/plugins/__tests__/css-injector-plugin.test.ts +1 -1
- package/src/vite/plugins/__tests__/design-system-guard-plugin.test.ts +15 -3
- package/src/vite/plugins/__tests__/dev-server-routing-plugin.test.ts +1 -1
- package/src/vite/plugins/__tests__/externals-plugin.test.ts +24 -3
- package/src/vite/plugins/__tests__/html-plugin.test.ts +10 -3
- package/src/vite/plugins/__tests__/html-template.test.ts +10 -2
- package/src/vite/plugins/__tests__/ignore-modules-plugin.test.ts +30 -6
- package/src/vite/plugins/__tests__/less-tilde-plugin.test.ts +91 -0
- package/src/vite/plugins/__tests__/metadata-plugin.test.ts +1 -1
- package/src/vite/plugins/__tests__/moment-locales-plugin.test.ts +35 -25
- package/src/vite/plugins/__tests__/style-urls-plugin.test.ts +1 -1
- package/src/vite/plugins/__tests__/virtual-modules-plugin.test.ts +20 -9
- package/src/vite/plugins/__tests__/window-externals-plugin.test.ts +128 -0
- package/src/vite/plugins/chain-source-maps-plugin.ts +1 -1
- package/src/vite/plugins/clean-plugin.ts +1 -1
- package/src/vite/plugins/css-injector-plugin.ts +1 -1
- package/src/vite/plugins/design-system-guard-plugin.ts +11 -8
- package/src/vite/plugins/dev-server-routing-plugin.ts +1 -1
- package/src/vite/plugins/externals-plugin.ts +15 -6
- package/src/vite/plugins/html-plugin.ts +4 -2
- package/src/vite/plugins/ignore-modules-plugin.ts +32 -23
- package/src/vite/plugins/index.ts +3 -0
- package/src/vite/plugins/less-tilde-plugin.ts +64 -0
- package/src/vite/plugins/magic-comments-plugin/magic-comments-plugin.ts +1 -1
- package/src/vite/plugins/metadata-plugin.ts +1 -1
- package/src/vite/plugins/moment-locales-plugin.ts +24 -14
- package/src/vite/plugins/react-refresh-plugin/README.md +165 -0
- package/src/vite/plugins/react-refresh-plugin/__tests__/react-refresh-plugin.test.ts +366 -0
- package/src/vite/plugins/react-refresh-plugin/__tests__/refresh-runtime.test.ts +193 -0
- package/src/vite/plugins/react-refresh-plugin/index.ts +1 -0
- package/src/vite/plugins/react-refresh-plugin/react-refresh-plugin.ts +144 -0
- package/src/vite/plugins/react-refresh-plugin/refresh-runtime.js +113 -0
- package/src/vite/plugins/shared-dependencies-plugin/__tests__/shared-dependencies-plugin.test.ts +21 -16
- package/src/vite/plugins/shared-dependencies-plugin/shared-dependencies-plugin.ts +13 -12
- package/src/vite/plugins/style-urls-plugin.ts +1 -1
- package/src/vite/plugins/virtual-modules-plugin.ts +8 -7
- package/src/vite/plugins/window-externals-plugin.ts +94 -0
- package/src/webpack/__tests__/bundle-webpack.test.ts +32 -0
- package/src/webpack/__tests__/create-webpack-config-web-component.test.ts +17 -5
- package/src/webpack/__tests__/create-webpack-config.test.ts +10 -6
- package/src/webpack/bundle-webpack.ts +7 -1
- package/src/webpack/configs/optimization-config.ts +3 -3
- package/src/webpack/configs/output-config.ts +1 -1
- package/src/webpack/utils/__tests__/normalize-proxy-config.test.ts +121 -0
- package/src/webpack/utils/index.ts +1 -0
- package/src/webpack/utils/normalize-proxy-config.ts +59 -0
- package/tsconfig/types.d.ts +10 -0
- package/dist/cli/utils/get-bundle-command.d.ts +0 -3
- package/dist/cli/utils/get-bundle-command.d.ts.map +0 -1
- package/dist/cli/utils/get-bundle-command.js +0 -16
- package/dist/cli/utils/get-bundle-command.js.map +0 -1
- package/src/cli/utils/__tests__/get-bundle-command.test.ts +0 -23
- package/src/cli/utils/get-bundle-command.ts +0 -5
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
magicCommentsPlugin,
|
|
21
21
|
metadataPlugin,
|
|
22
22
|
momentLocalesPlugin,
|
|
23
|
+
reactRefreshPlugin,
|
|
23
24
|
styleUrlsPlugin,
|
|
24
25
|
svgrPlugin,
|
|
25
26
|
virtualModulesPlugin,
|
|
@@ -62,6 +63,7 @@ jest.mock('../code-splitting', () => ({
|
|
|
62
63
|
}));
|
|
63
64
|
|
|
64
65
|
jest.mock('../../plugins', () => ({
|
|
66
|
+
reactRefreshPlugin: jest.fn(() => ({ name: 'reactRefresh' })),
|
|
65
67
|
bundleStatPlugin: jest.fn(() => ({ name: 'bundleStat' })),
|
|
66
68
|
chainSourceMapsPlugin: jest.fn(() => ({ name: 'chainSourceMaps' })),
|
|
67
69
|
cleanPlugin: jest.fn(() => ({ name: 'clean' })),
|
|
@@ -199,6 +201,15 @@ describe(createBaseConfig.name, () => {
|
|
|
199
201
|
}
|
|
200
202
|
});
|
|
201
203
|
|
|
204
|
+
test('includes startup-utils, react refresh, and react JSX runtimes in optimized dependencies', () => {
|
|
205
|
+
expect(subject().optimizeDeps!.include).toEqual([
|
|
206
|
+
'@servicetitan/startup-utils',
|
|
207
|
+
'react-refresh/runtime',
|
|
208
|
+
'react/jsx-runtime',
|
|
209
|
+
'react/jsx-dev-runtime',
|
|
210
|
+
]);
|
|
211
|
+
});
|
|
212
|
+
|
|
202
213
|
describe('when exposeProcessEnv lists a variable', () => {
|
|
203
214
|
const variable = 'API_URL';
|
|
204
215
|
const value = 'https://api.example.com';
|
|
@@ -223,10 +234,6 @@ describe(createBaseConfig.name, () => {
|
|
|
223
234
|
});
|
|
224
235
|
});
|
|
225
236
|
|
|
226
|
-
test('includes startup-utils in optimized dependencies', () => {
|
|
227
|
-
expect(subject().optimizeDeps!.include).toEqual(['@servicetitan/startup-utils']);
|
|
228
|
-
});
|
|
229
|
-
|
|
230
237
|
test('registers ignoreModulesPlugin for dependency pre-bundling', () => {
|
|
231
238
|
expect(subject().optimizeDeps!.rolldownOptions).toEqual({
|
|
232
239
|
plugins: [ignoreModulesPlugin(context)],
|
|
@@ -235,6 +242,7 @@ describe(createBaseConfig.name, () => {
|
|
|
235
242
|
|
|
236
243
|
test('creates plugins from factories, passing context', () => {
|
|
237
244
|
const factories = [
|
|
245
|
+
reactRefreshPlugin,
|
|
238
246
|
bundleStatPlugin,
|
|
239
247
|
cleanPlugin,
|
|
240
248
|
cssInjectorPlugin,
|
|
@@ -31,12 +31,8 @@ describe(createCssConfig.name, () => {
|
|
|
31
31
|
});
|
|
32
32
|
|
|
33
33
|
test('sets less math option', () => {
|
|
34
|
-
expect(subject()).toEqual(
|
|
35
|
-
expect.objectContaining({
|
|
36
|
-
preprocessorOptions: {
|
|
37
|
-
less: { math: bundleConstants.less.math },
|
|
38
|
-
},
|
|
39
|
-
})
|
|
34
|
+
expect(subject().preprocessorOptions?.less).toEqual(
|
|
35
|
+
expect.objectContaining({ math: bundleConstants.less.math })
|
|
40
36
|
);
|
|
41
37
|
});
|
|
42
38
|
|
|
@@ -118,7 +118,7 @@ describe(createViteConfig.name, () => {
|
|
|
118
118
|
});
|
|
119
119
|
|
|
120
120
|
test('sets warmup.clientFiles for the dev server', async () => {
|
|
121
|
-
expect((await subject()).server?.warmup?.clientFiles).
|
|
121
|
+
expect((await subject()).server?.warmup?.clientFiles).toEqual(warmupFiles);
|
|
122
122
|
});
|
|
123
123
|
|
|
124
124
|
test('warms the resolved output root', async () => {
|
|
@@ -137,8 +137,11 @@ describe(createViteConfig.name, () => {
|
|
|
137
137
|
})
|
|
138
138
|
);
|
|
139
139
|
|
|
140
|
-
test('consumer clientFiles
|
|
141
|
-
expect((await subject()).server?.warmup?.clientFiles).toEqual([
|
|
140
|
+
test('appends consumer clientFiles to the defaults', async () => {
|
|
141
|
+
expect((await subject()).server?.warmup?.clientFiles).toEqual([
|
|
142
|
+
...warmupFiles,
|
|
143
|
+
'custom/**',
|
|
144
|
+
]);
|
|
142
145
|
});
|
|
143
146
|
|
|
144
147
|
test('preserves other consumer warmup options', async () => {
|
|
@@ -23,6 +23,7 @@ import {
|
|
|
23
23
|
magicCommentsPlugin,
|
|
24
24
|
metadataPlugin,
|
|
25
25
|
momentLocalesPlugin,
|
|
26
|
+
reactRefreshPlugin,
|
|
26
27
|
styleUrlsPlugin,
|
|
27
28
|
svgrPlugin,
|
|
28
29
|
virtualModulesPlugin,
|
|
@@ -51,6 +52,7 @@ function importMetaRemap(
|
|
|
51
52
|
|
|
52
53
|
function createPlugins(context: ViteBuildContext) {
|
|
53
54
|
const entries: [string, Plugin[] | Plugin | Promise<Plugin> | undefined][] = [
|
|
55
|
+
['reactRefresh', reactRefreshPlugin(context)],
|
|
54
56
|
['bundleStat', bundleStatPlugin(context)],
|
|
55
57
|
['clean', cleanPlugin(context)],
|
|
56
58
|
['cssInjector', cssInjectorPlugin(context)],
|
|
@@ -106,6 +108,11 @@ export function createBaseConfig(context: ViteBuildContext): InlineConfig {
|
|
|
106
108
|
},
|
|
107
109
|
},
|
|
108
110
|
define: {
|
|
111
|
+
/*
|
|
112
|
+
* Some dependencies assume Node's `global` exists (webpack polyfills this
|
|
113
|
+
* automatically for browser targets; Vite does not).
|
|
114
|
+
*/
|
|
115
|
+
global: 'globalThis',
|
|
109
116
|
...importMetaRemap(
|
|
110
117
|
defineExposedDependencies(context),
|
|
111
118
|
defineExposedInstanceDependencies(context),
|
|
@@ -114,7 +121,12 @@ export function createBaseConfig(context: ViteBuildContext): InlineConfig {
|
|
|
114
121
|
...(getProcessEnv(context) ?? {}),
|
|
115
122
|
},
|
|
116
123
|
optimizeDeps: {
|
|
117
|
-
include: [
|
|
124
|
+
include: [
|
|
125
|
+
'@servicetitan/startup-utils',
|
|
126
|
+
'react-refresh/runtime',
|
|
127
|
+
'react/jsx-runtime',
|
|
128
|
+
'react/jsx-dev-runtime',
|
|
129
|
+
],
|
|
118
130
|
/*
|
|
119
131
|
* Top-level plugins don't run during dependency pre-bundling, so
|
|
120
132
|
* register ignoreModulesPlugin again here. Without this, missing
|
|
@@ -43,12 +43,15 @@ function createDevServerConfig(
|
|
|
43
43
|
outputRoot: string
|
|
44
44
|
) {
|
|
45
45
|
const { light, headless, emitExposedDependencies } = viteContext.build;
|
|
46
|
-
|
|
46
|
+
const warmup = finalConfig.server?.warmup;
|
|
47
47
|
const server = {
|
|
48
48
|
...finalConfig.server,
|
|
49
49
|
warmup: {
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
...warmup,
|
|
51
|
+
clientFiles: [
|
|
52
|
+
...getWarmupClientFiles(viteContext, outputRoot),
|
|
53
|
+
...(warmup?.clientFiles ?? []),
|
|
54
|
+
],
|
|
52
55
|
},
|
|
53
56
|
};
|
|
54
57
|
|
package/src/vite/index.html
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
<% } %> <% it.css.forEach(function(item) { %>
|
|
10
10
|
<link href="./<%= item %>" rel="stylesheet" crossorigin="anonymous" />
|
|
11
11
|
<% }); %> <% it.js.forEach(function(item) { %>
|
|
12
|
-
<script src="./<%= item %>"></script>
|
|
12
|
+
<script defer src="./<%= item %>"></script>
|
|
13
13
|
<% }); %>
|
|
14
14
|
<script type="text/javascript">
|
|
15
15
|
<% if (it.isWebComponent) { %>
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
<% if (it.isWebComponent) { %>
|
|
26
26
|
import './index';
|
|
27
27
|
<% } else { %>
|
|
28
|
-
import '
|
|
28
|
+
import './<%= it.tsOutDir %>/index';
|
|
29
29
|
<% } %>
|
|
30
30
|
</script>
|
|
31
31
|
<% if (it.isWebComponent) { %><<%~ it.name %> /><% } %>
|
package/src/vite/index.ts
CHANGED
|
@@ -23,7 +23,7 @@ describe(chainSourceMapsPlugin.name, () => {
|
|
|
23
23
|
};
|
|
24
24
|
|
|
25
25
|
test('has correct name', () => {
|
|
26
|
-
expect(chainSourceMapsPlugin().name).toBe('chain-source-maps');
|
|
26
|
+
expect(chainSourceMapsPlugin().name).toBe('st:chain-source-maps');
|
|
27
27
|
});
|
|
28
28
|
|
|
29
29
|
test('returns code with *.js.map sources as absolute paths', () => {
|
|
@@ -21,7 +21,7 @@ describe('[startup] cleanPlugin', () => {
|
|
|
21
21
|
const plugin = () => cleanPlugin(context);
|
|
22
22
|
|
|
23
23
|
test('returns a plugin named clean', () => {
|
|
24
|
-
expect(plugin().name).toBe('clean');
|
|
24
|
+
expect(plugin().name).toBe('st:clean');
|
|
25
25
|
});
|
|
26
26
|
|
|
27
27
|
test('applies only to build', () => {
|
|
@@ -14,7 +14,7 @@ describe(cssInjectorPlugin.name, () => {
|
|
|
14
14
|
const subject = () => cssInjectorPlugin(context);
|
|
15
15
|
|
|
16
16
|
test('returns a plugin with correct name', () => {
|
|
17
|
-
expect(subject()!.name).toBe('mfe-css-injector');
|
|
17
|
+
expect(subject()!.name).toBe('st:mfe-css-injector');
|
|
18
18
|
});
|
|
19
19
|
|
|
20
20
|
test('enforces post order', () => {
|
|
@@ -17,13 +17,23 @@ describe(designSystemGuardPlugin.name, () => {
|
|
|
17
17
|
const subject = () => designSystemGuardPlugin(context);
|
|
18
18
|
|
|
19
19
|
test('creates plugin with correct name', () => {
|
|
20
|
-
expect(subject().name).toBe('design-system-guard');
|
|
20
|
+
expect(subject().name).toBe('st:design-system-guard');
|
|
21
21
|
});
|
|
22
22
|
|
|
23
23
|
test('enforces pre order so it runs before built-in resolvers', () => {
|
|
24
24
|
expect(subject().enforce).toBe('pre');
|
|
25
25
|
});
|
|
26
26
|
|
|
27
|
+
describe('resolveId filter', () => {
|
|
28
|
+
const subject = () =>
|
|
29
|
+
(designSystemGuardPlugin(context) as { resolveId: { filter: unknown } }).resolveId
|
|
30
|
+
.filter;
|
|
31
|
+
|
|
32
|
+
test('runs the hook only for design-system.css imports', () => {
|
|
33
|
+
expect(subject()).toEqual({ id: /[\\/]design-system\.css$/ });
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
|
|
27
37
|
describe('resolveId', () => {
|
|
28
38
|
let pluginContext: { error: jest.Mock };
|
|
29
39
|
let source: string;
|
|
@@ -36,8 +46,10 @@ describe(designSystemGuardPlugin.name, () => {
|
|
|
36
46
|
});
|
|
37
47
|
|
|
38
48
|
const subject = () => {
|
|
39
|
-
const
|
|
40
|
-
|
|
49
|
+
const { resolveId } = designSystemGuardPlugin(context) as {
|
|
50
|
+
resolveId: { handler: Function };
|
|
51
|
+
};
|
|
52
|
+
return resolveId.handler.call(pluginContext, source, importer);
|
|
41
53
|
};
|
|
42
54
|
|
|
43
55
|
function itReportsNoError() {
|
|
@@ -40,7 +40,7 @@ describe(devServerRoutingPlugin.name, () => {
|
|
|
40
40
|
const subject = () => devServerRoutingPlugin(context);
|
|
41
41
|
|
|
42
42
|
test('returns plugin with correct name', () => {
|
|
43
|
-
expect(subject().name).toBe('dev-server-routing');
|
|
43
|
+
expect(subject().name).toBe('st:dev-server-routing');
|
|
44
44
|
});
|
|
45
45
|
|
|
46
46
|
describe('configureServer', () => {
|
|
@@ -31,7 +31,7 @@ describe(externalsPlugin.name, () => {
|
|
|
31
31
|
const subject = () => externalsPlugin(context);
|
|
32
32
|
|
|
33
33
|
test('returns plugin with correct name', () => {
|
|
34
|
-
expect(subject()!.name).toBe('externals');
|
|
34
|
+
expect(subject()!.name).toBe('st:externals');
|
|
35
35
|
});
|
|
36
36
|
|
|
37
37
|
test('enforces pre', () => {
|
|
@@ -70,12 +70,33 @@ describe(externalsPlugin.name, () => {
|
|
|
70
70
|
describe('when build is production', () => {
|
|
71
71
|
beforeEach(() => (context.build.isProduction = true));
|
|
72
72
|
|
|
73
|
+
describe('resolveId filter', () => {
|
|
74
|
+
const subject = () =>
|
|
75
|
+
(externalsPlugin(context) as { resolveId: { filter: unknown } }).resolveId.filter;
|
|
76
|
+
|
|
77
|
+
test('matches each dependency exactly', () => {
|
|
78
|
+
expect(subject()).toEqual({ id: [/^react$/, /^@scope\/lib$/] });
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
describe('when a dependency name contains regex characters', () => {
|
|
82
|
+
beforeEach(() =>
|
|
83
|
+
jest.mocked(getExternals).mockReturnValue({ 'lodash.throttle': 'x' })
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
test('escapes them', () => {
|
|
87
|
+
expect(subject()).toEqual({ id: [/^lodash\.throttle$/] });
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
|
|
73
92
|
describe('resolveId', () => {
|
|
74
93
|
let source: string;
|
|
75
94
|
|
|
76
95
|
const subject = () => {
|
|
77
|
-
const
|
|
78
|
-
|
|
96
|
+
const { resolveId } = externalsPlugin(context) as {
|
|
97
|
+
resolveId: { handler: Function };
|
|
98
|
+
};
|
|
99
|
+
return resolveId.handler.call({}, source);
|
|
79
100
|
};
|
|
80
101
|
|
|
81
102
|
describe('with known dependency', () => {
|
|
@@ -28,7 +28,7 @@ describe(htmlPlugin.name, () => {
|
|
|
28
28
|
jest.mocked(getSharedEntryPoints).mockReturnValue({ css: [], js: [] });
|
|
29
29
|
context = {
|
|
30
30
|
build: { name: 'my-app', isProduction: false },
|
|
31
|
-
package: { isWebComponent: false, source: 'src' },
|
|
31
|
+
package: { isWebComponent: false, source: 'src', destination: 'dist' },
|
|
32
32
|
bundlerConfig: { pluginOverrides: {} },
|
|
33
33
|
} as ViteBuildContext;
|
|
34
34
|
});
|
|
@@ -38,7 +38,7 @@ describe(htmlPlugin.name, () => {
|
|
|
38
38
|
const subject = () => htmlPlugin(context);
|
|
39
39
|
|
|
40
40
|
test('returns plugin with correct name', () => {
|
|
41
|
-
expect(subject().name).toBe('html');
|
|
41
|
+
expect(subject().name).toBe('st:html');
|
|
42
42
|
});
|
|
43
43
|
|
|
44
44
|
test('constructs Eta with default template directory', () => {
|
|
@@ -170,6 +170,7 @@ describe(htmlPlugin.name, () => {
|
|
|
170
170
|
isProduction: context.build.isProduction,
|
|
171
171
|
isWebComponent: context.package.isWebComponent,
|
|
172
172
|
name: context.build.name,
|
|
173
|
+
tsOutDir: context.package.destination,
|
|
173
174
|
});
|
|
174
175
|
});
|
|
175
176
|
|
|
@@ -310,7 +311,7 @@ describe(htmlPlugin.name, () => {
|
|
|
310
311
|
|
|
311
312
|
beforeEach(() => {
|
|
312
313
|
req = { url: '/other' };
|
|
313
|
-
res = { end: jest.fn() };
|
|
314
|
+
res = { end: jest.fn(), setHeader: jest.fn() };
|
|
314
315
|
next = jest.fn();
|
|
315
316
|
|
|
316
317
|
const plugin = htmlPlugin(context);
|
|
@@ -350,6 +351,12 @@ describe(htmlPlugin.name, () => {
|
|
|
350
351
|
expect(res.end).toHaveBeenCalledWith(TRANSFORMED_HTML);
|
|
351
352
|
});
|
|
352
353
|
|
|
354
|
+
test('sets HTML content type', async () => {
|
|
355
|
+
await subject();
|
|
356
|
+
|
|
357
|
+
expect(res.setHeader).toHaveBeenCalledWith('Content-Type', 'text/html');
|
|
358
|
+
});
|
|
359
|
+
|
|
353
360
|
test('does not call next middleware', async () => {
|
|
354
361
|
await subject();
|
|
355
362
|
|
|
@@ -19,7 +19,7 @@ describe('Vite host HTML template', () => {
|
|
|
19
19
|
jest.mocked(getSharedEntryPoints).mockReturnValue({ css, js });
|
|
20
20
|
context = {
|
|
21
21
|
build: { name: 'my-mfe', isProduction: true },
|
|
22
|
-
package: { isWebComponent: false, source: __dirname },
|
|
22
|
+
package: { isWebComponent: false, source: __dirname, destination: 'dist' },
|
|
23
23
|
bundlerConfig: { pluginOverrides: {} },
|
|
24
24
|
} as ViteBuildContext;
|
|
25
25
|
});
|
|
@@ -70,13 +70,21 @@ describe('Vite host HTML template', () => {
|
|
|
70
70
|
test('renders each shared JS script', () => {
|
|
71
71
|
const html = subject();
|
|
72
72
|
|
|
73
|
-
js.forEach(item => expect(html).toContain(`<script src="./${item}"></script>`));
|
|
73
|
+
js.forEach(item => expect(html).toContain(`<script defer src="./${item}"></script>`));
|
|
74
74
|
});
|
|
75
75
|
|
|
76
76
|
test('imports the host entry module', () => {
|
|
77
77
|
expect(subject()).toContain("import './dist/index'");
|
|
78
78
|
});
|
|
79
79
|
|
|
80
|
+
describe('with a non-default tsconfig outDir', () => {
|
|
81
|
+
beforeEach(() => (context.package.destination = 'lib'));
|
|
82
|
+
|
|
83
|
+
test('imports the entry from that directory', () => {
|
|
84
|
+
expect(subject()).toContain(`import './${context.package.destination}/index'`);
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
|
|
80
88
|
describe('when web component', () => {
|
|
81
89
|
beforeEach(() => {
|
|
82
90
|
context.package.isWebComponent = true;
|
|
@@ -5,7 +5,7 @@ jest.mock('../../../core', () => ({
|
|
|
5
5
|
checkResource: jest.fn(),
|
|
6
6
|
}));
|
|
7
7
|
|
|
8
|
-
describe(ignoreModulesPlugin.name
|
|
8
|
+
describe(`[startup] ${ignoreModulesPlugin.name}`, () => {
|
|
9
9
|
const moduleName = 'some-module';
|
|
10
10
|
const context = {} as BuildContext;
|
|
11
11
|
const checker = jest.fn();
|
|
@@ -18,21 +18,32 @@ describe(ignoreModulesPlugin.name, () => {
|
|
|
18
18
|
const subject = () => ignoreModulesPlugin(context);
|
|
19
19
|
|
|
20
20
|
test('creates plugin with correct name', () => {
|
|
21
|
-
expect(subject().name).toBe('ignore-modules');
|
|
21
|
+
expect(subject().name).toBe('st:ignore-modules');
|
|
22
22
|
});
|
|
23
23
|
|
|
24
24
|
test('enforces pre order so it runs before built-in resolvers', () => {
|
|
25
25
|
expect(subject().enforce).toBe('pre');
|
|
26
26
|
});
|
|
27
27
|
|
|
28
|
+
describe('resolveId filter', () => {
|
|
29
|
+
const subject = () =>
|
|
30
|
+
(ignoreModulesPlugin(context) as { resolveId: { filter: unknown } }).resolveId.filter;
|
|
31
|
+
|
|
32
|
+
test('runs the hook only for bare specifiers', () => {
|
|
33
|
+
expect(subject()).toEqual({ id: /^[@a-z]/ });
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
|
|
28
37
|
describe('resolveId', () => {
|
|
29
38
|
let importer: string | undefined;
|
|
30
39
|
|
|
31
40
|
beforeEach(() => (importer = '/importer.ts'));
|
|
32
41
|
|
|
33
42
|
const subject = () => {
|
|
34
|
-
const
|
|
35
|
-
|
|
43
|
+
const { resolveId } = ignoreModulesPlugin(context) as {
|
|
44
|
+
resolveId: { handler: Function };
|
|
45
|
+
};
|
|
46
|
+
return resolveId.handler.call({}, moduleName, importer);
|
|
36
47
|
};
|
|
37
48
|
|
|
38
49
|
const itReturnsUndefined = () => {
|
|
@@ -72,14 +83,27 @@ describe(ignoreModulesPlugin.name, () => {
|
|
|
72
83
|
});
|
|
73
84
|
});
|
|
74
85
|
|
|
86
|
+
describe('load filter', () => {
|
|
87
|
+
const subject = () =>
|
|
88
|
+
(ignoreModulesPlugin(context) as { load: { filter: { id: RegExp } } }).load.filter.id;
|
|
89
|
+
|
|
90
|
+
test('matches the plugin virtual module ids', () => {
|
|
91
|
+
expect(subject().test(`${THROW_PREFIX}${moduleName}`)).toBe(true);
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
test('ignores ordinary module ids', () => {
|
|
95
|
+
expect(subject().test('/src/app.tsx')).toBe(false);
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
|
|
75
99
|
describe('load', () => {
|
|
76
100
|
let id: string;
|
|
77
101
|
|
|
78
102
|
beforeEach(() => (id = moduleName));
|
|
79
103
|
|
|
80
104
|
const subject = () => {
|
|
81
|
-
const
|
|
82
|
-
return
|
|
105
|
+
const { load } = ignoreModulesPlugin(context) as { load: { handler: Function } };
|
|
106
|
+
return load.handler.call({}, id);
|
|
83
107
|
};
|
|
84
108
|
|
|
85
109
|
test('returns undefined', () => {
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { fs, vol } from 'memfs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { lessTildePlugin } from '../less-tilde-plugin';
|
|
4
|
+
|
|
5
|
+
jest.mock('fs', () => fs);
|
|
6
|
+
|
|
7
|
+
describe(lessTildePlugin.name, () => {
|
|
8
|
+
class FakeFileManager {
|
|
9
|
+
loadFile(...args: unknown[]) {
|
|
10
|
+
return loadFile(...args);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
let loadFile: jest.Mock;
|
|
15
|
+
let fileManager: any;
|
|
16
|
+
|
|
17
|
+
beforeEach(() => {
|
|
18
|
+
jest.clearAllMocks();
|
|
19
|
+
vol.reset();
|
|
20
|
+
loadFile = jest.fn();
|
|
21
|
+
const pluginManager = { addFileManager: (manager: any) => (fileManager = manager) };
|
|
22
|
+
lessTildePlugin().install({ FileManager: FakeFileManager } as any, pluginManager);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
describe('supports', () => {
|
|
26
|
+
let filename: string;
|
|
27
|
+
|
|
28
|
+
beforeEach(() => {
|
|
29
|
+
filename = '@servicetitan/tokens/x.less';
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
const subject = () => fileManager.supports(filename);
|
|
33
|
+
|
|
34
|
+
test('returns false', () => {
|
|
35
|
+
expect(subject()).toBe(false);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
describe('with a tilde-prefixed import', () => {
|
|
39
|
+
beforeEach(() => (filename = '~' + filename));
|
|
40
|
+
|
|
41
|
+
test('returns true', () => {
|
|
42
|
+
expect(subject()).toBe(true);
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
describe('loadFile', () => {
|
|
48
|
+
const options = {};
|
|
49
|
+
const environment = {};
|
|
50
|
+
const packagePath = '@servicetitan/tokens/dist/x.less';
|
|
51
|
+
/* The same file is resolved in every case; only the input that reaches it changes. */
|
|
52
|
+
const resolved = path.resolve('app/node_modules', packagePath);
|
|
53
|
+
|
|
54
|
+
let specifier: string;
|
|
55
|
+
let importer: string;
|
|
56
|
+
|
|
57
|
+
const subject = () => fileManager.loadFile(specifier, importer, options, environment);
|
|
58
|
+
|
|
59
|
+
beforeEach(() => {
|
|
60
|
+
vol.fromJSON({ [resolved]: '' });
|
|
61
|
+
importer = path.resolve('app');
|
|
62
|
+
specifier = `~${packagePath}`;
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
test("drops the tilde and loads the file from the importer's node_modules", () => {
|
|
66
|
+
subject();
|
|
67
|
+
|
|
68
|
+
expect(loadFile).toHaveBeenCalledWith(resolved, importer, options, environment);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
describe('when the specifier omits the extension', () => {
|
|
72
|
+
beforeEach(() => (specifier = specifier.replace('.less', '')));
|
|
73
|
+
|
|
74
|
+
test('appends .less', () => {
|
|
75
|
+
subject();
|
|
76
|
+
|
|
77
|
+
expect(loadFile).toHaveBeenCalledWith(resolved, importer, options, environment);
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
describe("when the package lives in an ancestor's node_modules", () => {
|
|
82
|
+
beforeEach(() => (importer = path.resolve('app/feature/styles')));
|
|
83
|
+
|
|
84
|
+
test('walks up from the importer to find it', () => {
|
|
85
|
+
subject();
|
|
86
|
+
|
|
87
|
+
expect(loadFile).toHaveBeenCalledWith(resolved, importer, options, environment);
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
});
|
|
@@ -4,17 +4,26 @@ import { VIRTUAL_MOMENT, momentLocalesPlugin } from '../moment-locales-plugin';
|
|
|
4
4
|
const LOCALES_TO_KEEP = ['en-au', 'en-ca', 'en-gb'];
|
|
5
5
|
const context = {} as BuildContext;
|
|
6
6
|
|
|
7
|
-
describe(momentLocalesPlugin.name
|
|
7
|
+
describe(`[startup] ${momentLocalesPlugin.name}`, () => {
|
|
8
8
|
const subject = () => momentLocalesPlugin(context);
|
|
9
9
|
|
|
10
10
|
test('creates plugin with correct name', () => {
|
|
11
|
-
expect(subject().name).toBe('moment-locales');
|
|
11
|
+
expect(subject().name).toBe('st:moment-locales');
|
|
12
12
|
});
|
|
13
13
|
|
|
14
14
|
test('enforces pre order so it runs before built-in resolvers', () => {
|
|
15
15
|
expect(subject().enforce).toBe('pre');
|
|
16
16
|
});
|
|
17
17
|
|
|
18
|
+
describe('resolveId filter', () => {
|
|
19
|
+
const subject = () =>
|
|
20
|
+
(momentLocalesPlugin(context) as { resolveId: { filter: unknown } }).resolveId.filter;
|
|
21
|
+
|
|
22
|
+
test('runs the hook only for moment and its subpaths', () => {
|
|
23
|
+
expect(subject()).toEqual({ id: [/^moment$/, /^moment\/locale\/(.+)$/] });
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
|
|
18
27
|
describe('resolveId', () => {
|
|
19
28
|
const importer = 'importer.ts';
|
|
20
29
|
let source: string;
|
|
@@ -26,8 +35,10 @@ describe(momentLocalesPlugin.name, () => {
|
|
|
26
35
|
});
|
|
27
36
|
|
|
28
37
|
const subject = () => {
|
|
29
|
-
const
|
|
30
|
-
|
|
38
|
+
const { resolveId } = momentLocalesPlugin(context) as {
|
|
39
|
+
resolveId: { handler: Function };
|
|
40
|
+
};
|
|
41
|
+
return resolveId.handler.call({ resolve }, source, importer, {});
|
|
31
42
|
};
|
|
32
43
|
|
|
33
44
|
const itReturnsUndefined = () => {
|
|
@@ -71,34 +82,33 @@ describe(momentLocalesPlugin.name, () => {
|
|
|
71
82
|
});
|
|
72
83
|
});
|
|
73
84
|
|
|
74
|
-
describe('load', () => {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
beforeEach(() => (id = 'react'));
|
|
85
|
+
describe('load filter', () => {
|
|
86
|
+
const subject = () =>
|
|
87
|
+
(momentLocalesPlugin(context) as { load: { filter: { id: RegExp } } }).load.filter.id;
|
|
78
88
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
};
|
|
89
|
+
test('matches the virtual moment module id', () => {
|
|
90
|
+
expect(subject().test(VIRTUAL_MOMENT)).toBe(true);
|
|
91
|
+
});
|
|
83
92
|
|
|
84
|
-
test('
|
|
85
|
-
expect(subject()).
|
|
93
|
+
test('ignores ordinary module ids', () => {
|
|
94
|
+
expect(subject().test('/src/app.tsx')).toBe(false);
|
|
86
95
|
});
|
|
96
|
+
});
|
|
87
97
|
|
|
88
|
-
|
|
89
|
-
|
|
98
|
+
describe('load', () => {
|
|
99
|
+
const subject = () =>
|
|
100
|
+
(momentLocalesPlugin(context) as { load: { handler: Function } }).load.handler();
|
|
90
101
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
102
|
+
test.each(LOCALES_TO_KEEP)('imports the ESM %s locale', locale => {
|
|
103
|
+
expect(subject()).toContain(`import 'moment/dist/locale/${locale}';`);
|
|
104
|
+
});
|
|
94
105
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
106
|
+
test('imports moment from the ESM build', () => {
|
|
107
|
+
expect(subject()).toContain("import moment from 'moment/dist/moment.js';");
|
|
108
|
+
});
|
|
98
109
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
});
|
|
110
|
+
test('re-exports moment as the default', () => {
|
|
111
|
+
expect(subject()).toContain('export default moment;');
|
|
102
112
|
});
|
|
103
113
|
});
|
|
104
114
|
});
|
|
@@ -21,7 +21,7 @@ describe(styleUrlsPlugin.name, () => {
|
|
|
21
21
|
};
|
|
22
22
|
|
|
23
23
|
test('returns plugin with correct name', () => {
|
|
24
|
-
expect(subject()!.name).toBe('style-urls');
|
|
24
|
+
expect(subject()!.name).toBe('st:style-urls');
|
|
25
25
|
});
|
|
26
26
|
|
|
27
27
|
describe('when package is not a web component', () => {
|