@servicetitan/startup 37.0.2 → 38.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/js-yaml.js +2 -2
- package/dist/cli/commands/build.d.ts.map +1 -1
- package/dist/cli/commands/build.js +22 -9
- package/dist/cli/commands/build.js.map +1 -1
- package/dist/cli/commands/bundle-package.d.ts +6 -0
- package/dist/cli/commands/bundle-package.d.ts.map +1 -0
- package/dist/cli/commands/bundle-package.js +59 -0
- package/dist/cli/commands/bundle-package.js.map +1 -0
- package/dist/cli/commands/bundle-vite.js +13 -4
- package/dist/cli/commands/bundle-vite.js.map +1 -1
- package/dist/cli/commands/bundle-webpack.js +13 -4
- package/dist/cli/commands/bundle-webpack.js.map +1 -1
- package/dist/cli/commands/clean.js +13 -4
- package/dist/cli/commands/clean.js.map +1 -1
- package/dist/cli/commands/command.d.ts +9 -0
- package/dist/cli/commands/command.d.ts.map +1 -0
- package/dist/cli/commands/command.js +35 -0
- package/dist/cli/commands/command.js.map +1 -0
- package/dist/cli/commands/convert-eslint-config.js +14 -7
- package/dist/cli/commands/convert-eslint-config.js.map +1 -1
- package/dist/cli/commands/eslint.js +13 -4
- package/dist/cli/commands/eslint.js.map +1 -1
- package/dist/cli/commands/init.js +13 -4
- package/dist/cli/commands/init.js.map +1 -1
- package/dist/cli/commands/install.js +13 -4
- package/dist/cli/commands/install.js.map +1 -1
- package/dist/cli/commands/kendo-ui-license.js +13 -4
- package/dist/cli/commands/kendo-ui-license.js.map +1 -1
- package/dist/cli/commands/lint.js +13 -4
- package/dist/cli/commands/lint.js.map +1 -1
- package/dist/cli/commands/mfe-check.d.ts.map +1 -1
- package/dist/cli/commands/mfe-check.js +15 -7
- package/dist/cli/commands/mfe-check.js.map +1 -1
- package/dist/cli/commands/mfe-generate-metadata.js +13 -4
- package/dist/cli/commands/mfe-generate-metadata.js.map +1 -1
- package/dist/cli/commands/mfe-list.js +13 -4
- package/dist/cli/commands/mfe-list.js.map +1 -1
- package/dist/cli/commands/mfe-package-clean.js +13 -4
- package/dist/cli/commands/mfe-package-clean.js.map +1 -1
- package/dist/cli/commands/mfe-package-publish.js +13 -4
- package/dist/cli/commands/mfe-package-publish.js.map +1 -1
- package/dist/cli/commands/mfe-package-rollback.js +13 -4
- package/dist/cli/commands/mfe-package-rollback.js.map +1 -1
- package/dist/cli/commands/mfe-publish.js +13 -4
- package/dist/cli/commands/mfe-publish.js.map +1 -1
- package/dist/cli/commands/mfe-purge-cache.js +13 -4
- package/dist/cli/commands/mfe-purge-cache.js.map +1 -1
- package/dist/cli/commands/prepare-package.js +13 -4
- package/dist/cli/commands/prepare-package.js.map +1 -1
- package/dist/cli/commands/registry/build.d.ts +1 -1
- package/dist/cli/commands/registry/build.d.ts.map +1 -1
- package/dist/cli/commands/registry/build.js +3 -5
- package/dist/cli/commands/registry/build.js.map +1 -1
- package/dist/cli/commands/registry/bundle-package.d.ts +41 -0
- package/dist/cli/commands/registry/bundle-package.d.ts.map +1 -0
- package/dist/cli/commands/registry/bundle-package.js +54 -0
- package/dist/cli/commands/registry/bundle-package.js.map +1 -0
- package/dist/cli/commands/registry/command-registry.d.ts +42 -2
- package/dist/cli/commands/registry/command-registry.d.ts.map +1 -1
- package/dist/cli/commands/registry/command-registry.js +10 -19
- package/dist/cli/commands/registry/command-registry.js.map +1 -1
- package/dist/cli/commands/registry/start.d.ts +1 -1
- package/dist/cli/commands/registry/start.d.ts.map +1 -1
- package/dist/cli/commands/registry/start.js +3 -5
- package/dist/cli/commands/registry/start.js.map +1 -1
- package/dist/cli/commands/review/review.js +14 -7
- package/dist/cli/commands/review/review.js.map +1 -1
- package/dist/cli/commands/review/rules/no-deprecated-content-base.js +1 -3
- package/dist/cli/commands/review/rules/no-deprecated-content-base.js.map +1 -1
- package/dist/cli/commands/review/rules/no-direct-peer-dependencies.js +1 -3
- package/dist/cli/commands/review/rules/no-direct-peer-dependencies.js.map +1 -1
- package/dist/cli/commands/review/rules/no-typescript-entry-point.js +1 -3
- package/dist/cli/commands/review/rules/no-typescript-entry-point.js.map +1 -1
- package/dist/cli/commands/review/rules/prefer-open-ended-peer-dependencies.js +5 -12
- package/dist/cli/commands/review/rules/prefer-open-ended-peer-dependencies.js.map +1 -1
- package/dist/cli/commands/review/rules/require-compatible-launch-darkly-sdk.js +5 -12
- package/dist/cli/commands/review/rules/require-compatible-launch-darkly-sdk.js.map +1 -1
- package/dist/cli/commands/review/rules/require-explicit-side-effects.js +1 -3
- package/dist/cli/commands/review/rules/require-explicit-side-effects.js.map +1 -1
- package/dist/cli/commands/review/rules/require-one-collection-version.js +1 -3
- package/dist/cli/commands/review/rules/require-one-collection-version.js.map +1 -1
- package/dist/cli/commands/review/rules/require-servicetitan-scope.js +1 -3
- package/dist/cli/commands/review/rules/require-servicetitan-scope.js.map +1 -1
- package/dist/cli/commands/review/rules/require-tsconfig-references.js +1 -3
- package/dist/cli/commands/review/rules/require-tsconfig-references.js.map +1 -1
- package/dist/cli/commands/review/types.d.ts.map +1 -1
- package/dist/cli/commands/review/types.js.map +1 -1
- package/dist/cli/commands/review/utils/compare-version.js +8 -19
- package/dist/cli/commands/review/utils/compare-version.js.map +1 -1
- package/dist/cli/commands/run-task.d.ts +1 -0
- package/dist/cli/commands/run-task.d.ts.map +1 -1
- package/dist/cli/commands/run-task.js +20 -6
- package/dist/cli/commands/run-task.js.map +1 -1
- package/dist/cli/commands/start.d.ts.map +1 -1
- package/dist/cli/commands/start.js +28 -13
- package/dist/cli/commands/start.js.map +1 -1
- package/dist/cli/commands/stylelint.js +13 -4
- package/dist/cli/commands/stylelint.js.map +1 -1
- package/dist/cli/commands/styles-check.js +13 -4
- package/dist/cli/commands/styles-check.js.map +1 -1
- package/dist/cli/commands/test/runners/jest.js +1 -3
- package/dist/cli/commands/test/runners/jest.js.map +1 -1
- package/dist/cli/commands/test/tests.js +13 -4
- package/dist/cli/commands/test/tests.js.map +1 -1
- package/dist/cli/commands/types.d.ts +1 -6
- package/dist/cli/commands/types.d.ts.map +1 -1
- package/dist/cli/commands/types.js +2 -20
- package/dist/cli/commands/types.js.map +1 -1
- package/dist/cli/commands/upload-sourcemaps.js +17 -13
- package/dist/cli/commands/upload-sourcemaps.js.map +1 -1
- package/dist/cli/index.js +1 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/tasks/cli-task.d.ts +3 -0
- package/dist/cli/tasks/cli-task.d.ts.map +1 -1
- package/dist/cli/tasks/cli-task.js +41 -9
- package/dist/cli/tasks/cli-task.js.map +1 -1
- package/dist/cli/tasks/swc-compile-package/get-swc-options.d.ts +9 -1
- package/dist/cli/tasks/swc-compile-package/get-swc-options.d.ts.map +1 -1
- package/dist/cli/tasks/swc-compile-package/get-swc-options.js +18 -2
- package/dist/cli/tasks/swc-compile-package/get-swc-options.js.map +1 -1
- package/dist/cli/tasks/swc-compile-package/swc-compile-package.d.ts +3 -1
- package/dist/cli/tasks/swc-compile-package/swc-compile-package.d.ts.map +1 -1
- package/dist/cli/tasks/swc-compile-package/swc-compile-package.js +17 -3
- package/dist/cli/tasks/swc-compile-package/swc-compile-package.js.map +1 -1
- package/dist/cli/tasks/task.d.ts +2 -1
- package/dist/cli/tasks/task.d.ts.map +1 -1
- package/dist/cli/tasks/task.js +6 -3
- package/dist/cli/tasks/task.js.map +1 -1
- package/dist/cli/tasks/tsc-compile/tsc-compile.js +1 -3
- package/dist/cli/tasks/tsc-compile/tsc-compile.js.map +1 -1
- package/dist/cli/utils/cli-npm.d.ts.map +1 -1
- package/dist/cli/utils/cli-npm.js +8 -1
- package/dist/cli/utils/cli-npm.js.map +1 -1
- package/dist/cli/utils/cli-os.d.ts +1 -0
- package/dist/cli/utils/cli-os.d.ts.map +1 -1
- package/dist/cli/utils/cli-os.js +20 -0
- package/dist/cli/utils/cli-os.js.map +1 -1
- package/dist/cli/utils/compile.d.ts.map +1 -1
- package/dist/cli/utils/compile.js +7 -4
- package/dist/cli/utils/compile.js.map +1 -1
- package/dist/cli/utils/copy-files.js +1 -0
- package/dist/cli/utils/copy-files.js.map +1 -1
- package/dist/cli/utils/index.d.ts +1 -1
- package/dist/cli/utils/index.d.ts.map +1 -1
- package/dist/cli/utils/index.js +1 -1
- package/dist/cli/utils/index.js.map +1 -1
- package/dist/cli/utils/process-tree.js +2 -6
- package/dist/cli/utils/process-tree.js.map +1 -1
- package/dist/cli/utils/resolve-bundler.d.ts.map +1 -1
- package/dist/cli/utils/resolve-bundler.js +2 -1
- package/dist/cli/utils/resolve-bundler.js.map +1 -1
- package/dist/cli/utils/ts-config.d.ts +1 -1
- package/dist/cli/utils/ts-config.d.ts.map +1 -1
- package/dist/cli/utils/ts-config.js +1 -3
- package/dist/cli/utils/ts-config.js.map +1 -1
- package/dist/cli/utils/with-exponential-backoff.d.ts +7 -0
- package/dist/cli/utils/with-exponential-backoff.d.ts.map +1 -0
- package/dist/cli/utils/with-exponential-backoff.js +28 -0
- package/dist/cli/utils/with-exponential-backoff.js.map +1 -0
- package/dist/core/constants.d.ts +2 -0
- package/dist/core/constants.d.ts.map +1 -1
- package/dist/core/constants.js +6 -1
- package/dist/core/constants.js.map +1 -1
- package/dist/cypress/config/vite-config.d.ts.map +1 -1
- package/dist/cypress/config/vite-config.js +23 -3
- package/dist/cypress/config/vite-config.js.map +1 -1
- package/dist/cypress/config/webpack-config.d.ts.map +1 -1
- package/dist/cypress/config/webpack-config.js +5 -0
- package/dist/cypress/config/webpack-config.js.map +1 -1
- package/dist/postinstall.js +118 -0
- package/dist/scripts/generate-bin-wrappers.js +203 -0
- package/dist/storybook-config/swc.d.ts +6 -0
- package/dist/storybook-config/swc.d.ts.map +1 -1
- package/dist/storybook-config/vite-final.d.ts.map +1 -1
- package/dist/storybook-config/vite-final.js +32 -6
- package/dist/storybook-config/vite-final.js.map +1 -1
- package/dist/storybook-config/webpack-final.d.ts.map +1 -1
- package/dist/storybook-config/webpack-final.js +3 -1
- package/dist/storybook-config/webpack-final.js.map +1 -1
- package/dist/utils/exit-when-parent-exits.d.ts +6 -0
- package/dist/utils/exit-when-parent-exits.d.ts.map +1 -0
- package/dist/utils/exit-when-parent-exits.js +37 -0
- package/dist/utils/exit-when-parent-exits.js.map +1 -0
- package/dist/utils/find-up.d.ts +1 -1
- package/dist/utils/find-up.d.ts.map +1 -1
- package/dist/utils/find-up.js +2 -2
- package/dist/utils/find-up.js.map +1 -1
- package/dist/utils/get-configuration.d.ts +6 -3
- package/dist/utils/get-configuration.d.ts.map +1 -1
- package/dist/utils/get-configuration.js +10 -2
- package/dist/utils/get-configuration.js.map +1 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +1 -0
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/log.js +1 -3
- package/dist/utils/log.js.map +1 -1
- package/dist/vite/build-shared-dependencies.d.ts.map +1 -1
- package/dist/vite/build-shared-dependencies.js +2 -0
- package/dist/vite/build-shared-dependencies.js.map +1 -1
- package/dist/vite/config/base-config.d.ts.map +1 -1
- package/dist/vite/config/base-config.js +14 -1
- package/dist/vite/config/base-config.js.map +1 -1
- package/dist/vite/config/create-filtering-logger.d.ts.map +1 -1
- package/dist/vite/config/create-filtering-logger.js +12 -1
- package/dist/vite/config/create-filtering-logger.js.map +1 -1
- package/dist/vite/config/create-vite-build-context.d.ts.map +1 -1
- package/dist/vite/config/create-vite-build-context.js +4 -1
- package/dist/vite/config/create-vite-build-context.js.map +1 -1
- package/dist/vite/config/create-vite-config.js +7 -2
- package/dist/vite/config/create-vite-config.js.map +1 -1
- package/dist/vite/config/load-config-file.js +8 -19
- package/dist/vite/config/load-config-file.js.map +1 -1
- package/dist/vite/index.d.ts +2 -0
- package/dist/vite/index.d.ts.map +1 -1
- package/dist/vite/index.html +2 -2
- package/dist/vite/index.js +16 -0
- package/dist/vite/index.js.map +1 -1
- package/dist/vite/plugins/chain-source-maps-plugin.js +1 -1
- package/dist/vite/plugins/chain-source-maps-plugin.js.map +1 -1
- package/dist/vite/plugins/clean-plugin.js +1 -1
- package/dist/vite/plugins/clean-plugin.js.map +1 -1
- package/dist/vite/plugins/css-injector-plugin.js +1 -1
- package/dist/vite/plugins/css-injector-plugin.js.map +1 -1
- package/dist/vite/plugins/design-system-guard-plugin.d.ts.map +1 -1
- package/dist/vite/plugins/design-system-guard-plugin.js +10 -5
- package/dist/vite/plugins/design-system-guard-plugin.js.map +1 -1
- package/dist/vite/plugins/dev-server-routing-plugin.d.ts +1 -1
- package/dist/vite/plugins/dev-server-routing-plugin.d.ts.map +1 -1
- package/dist/vite/plugins/dev-server-routing-plugin.js +4 -3
- package/dist/vite/plugins/dev-server-routing-plugin.js.map +1 -1
- package/dist/vite/plugins/externals-plugin.d.ts.map +1 -1
- package/dist/vite/plugins/externals-plugin.js +11 -5
- package/dist/vite/plugins/externals-plugin.js.map +1 -1
- package/dist/vite/plugins/html-plugin.d.ts.map +1 -1
- package/dist/vite/plugins/html-plugin.js +5 -3
- package/dist/vite/plugins/html-plugin.js.map +1 -1
- package/dist/vite/plugins/ignore-modules-plugin.d.ts +2 -2
- package/dist/vite/plugins/ignore-modules-plugin.d.ts.map +1 -1
- package/dist/vite/plugins/ignore-modules-plugin.js +36 -24
- package/dist/vite/plugins/ignore-modules-plugin.js.map +1 -1
- package/dist/vite/plugins/index.d.ts +3 -0
- package/dist/vite/plugins/index.d.ts.map +1 -1
- package/dist/vite/plugins/index.js +3 -0
- package/dist/vite/plugins/index.js.map +1 -1
- package/dist/vite/plugins/istanbul-plugin.d.ts.map +1 -1
- package/dist/vite/plugins/istanbul-plugin.js +33 -1
- package/dist/vite/plugins/istanbul-plugin.js.map +1 -1
- package/dist/vite/plugins/less-tilde-plugin.d.ts +8 -0
- package/dist/vite/plugins/less-tilde-plugin.d.ts.map +1 -0
- package/dist/vite/plugins/less-tilde-plugin.js +53 -0
- package/dist/vite/plugins/less-tilde-plugin.js.map +1 -0
- package/dist/vite/plugins/magic-comments-plugin/magic-comments-plugin.js +1 -1
- package/dist/vite/plugins/magic-comments-plugin/magic-comments-plugin.js.map +1 -1
- package/dist/vite/plugins/metadata-plugin.js +1 -1
- package/dist/vite/plugins/metadata-plugin.js.map +1 -1
- package/dist/vite/plugins/moment-locales-plugin.d.ts +1 -1
- package/dist/vite/plugins/moment-locales-plugin.d.ts.map +1 -1
- package/dist/vite/plugins/moment-locales-plugin.js +30 -14
- package/dist/vite/plugins/moment-locales-plugin.js.map +1 -1
- package/dist/vite/plugins/react-refresh-plugin/index.d.ts +2 -0
- package/dist/vite/plugins/react-refresh-plugin/index.d.ts.map +1 -0
- package/dist/vite/plugins/react-refresh-plugin/index.js +20 -0
- package/dist/vite/plugins/react-refresh-plugin/index.js.map +1 -0
- package/dist/vite/plugins/react-refresh-plugin/react-refresh-plugin.d.ts +4 -0
- package/dist/vite/plugins/react-refresh-plugin/react-refresh-plugin.d.ts.map +1 -0
- package/dist/vite/plugins/react-refresh-plugin/react-refresh-plugin.js +143 -0
- package/dist/vite/plugins/react-refresh-plugin/react-refresh-plugin.js.map +1 -0
- package/dist/vite/plugins/react-refresh-plugin/refresh-runtime.js +113 -0
- package/dist/vite/plugins/shared-dependencies-plugin/shared-dependencies-plugin.d.ts.map +1 -1
- package/dist/vite/plugins/shared-dependencies-plugin/shared-dependencies-plugin.js +14 -11
- package/dist/vite/plugins/shared-dependencies-plugin/shared-dependencies-plugin.js.map +1 -1
- package/dist/vite/plugins/style-urls-plugin.js +1 -1
- package/dist/vite/plugins/style-urls-plugin.js.map +1 -1
- package/dist/vite/plugins/virtual-modules-plugin.d.ts.map +1 -1
- package/dist/vite/plugins/virtual-modules-plugin.js +9 -6
- package/dist/vite/plugins/virtual-modules-plugin.js.map +1 -1
- package/dist/vite/plugins/window-externals-plugin.d.ts +22 -0
- package/dist/vite/plugins/window-externals-plugin.d.ts.map +1 -0
- package/dist/vite/plugins/window-externals-plugin.js +74 -0
- package/dist/vite/plugins/window-externals-plugin.js.map +1 -0
- package/dist/vite/types.d.ts +4 -1
- package/dist/vite/types.d.ts.map +1 -1
- package/dist/webpack/bundle-webpack.d.ts.map +1 -1
- package/dist/webpack/bundle-webpack.js +6 -1
- package/dist/webpack/bundle-webpack.js.map +1 -1
- package/dist/webpack/configs/optimization-config.js +4 -4
- package/dist/webpack/configs/optimization-config.js.map +1 -1
- package/dist/webpack/configs/output-config.js +1 -1
- package/dist/webpack/configs/output-config.js.map +1 -1
- package/dist/webpack/configs/plugins/ignore-plugin/ignore-plugin.js +1 -3
- package/dist/webpack/configs/plugins/ignore-plugin/ignore-plugin.js.map +1 -1
- package/dist/webpack/loaders/expose-loader/__tests__/__mocks__/configuration.expose-loader.js +13 -0
- package/dist/webpack/loaders/expose-loader/__tests__/__mocks__/index.js +1 -0
- package/dist/webpack/utils/index.d.ts +1 -0
- package/dist/webpack/utils/index.d.ts.map +1 -1
- package/dist/webpack/utils/index.js +1 -0
- package/dist/webpack/utils/index.js.map +1 -1
- package/dist/webpack/utils/normalize-proxy-config.d.ts +6 -0
- package/dist/webpack/utils/normalize-proxy-config.d.ts.map +1 -0
- package/dist/webpack/utils/normalize-proxy-config.js +52 -0
- package/dist/webpack/utils/normalize-proxy-config.js.map +1 -0
- package/package.json +25 -22
- package/src/cli/commands/__tests__/build.test.ts +33 -19
- package/src/cli/commands/__tests__/bundle-package.test.ts +65 -0
- package/src/cli/commands/__tests__/bundle-vite.test.ts +1 -0
- package/src/cli/commands/__tests__/command.test.ts +42 -0
- package/src/cli/commands/__tests__/mfe-check.test.ts +26 -5
- package/src/cli/commands/__tests__/run-task.test.ts +20 -1
- package/src/cli/commands/__tests__/start.test.ts +35 -15
- package/src/cli/commands/build.ts +6 -5
- package/src/cli/commands/bundle-package.ts +20 -0
- package/src/cli/commands/command.ts +14 -0
- package/src/cli/commands/mfe-check.ts +6 -10
- package/src/cli/commands/registry/build.ts +3 -2
- package/src/cli/commands/registry/bundle-package.ts +22 -0
- package/src/cli/commands/registry/command-registry.ts +2 -0
- package/src/cli/commands/registry/start.ts +3 -2
- package/src/cli/commands/review/types.ts +1 -3
- package/src/cli/commands/run-task.ts +8 -2
- package/src/cli/commands/start.ts +9 -5
- package/src/cli/commands/types.ts +2 -6
- package/src/cli/index.ts +3 -0
- package/src/cli/tasks/__tests__/cli-task.test.ts +181 -69
- package/src/cli/tasks/__tests__/task.test.ts +40 -45
- package/src/cli/tasks/cli-task.ts +43 -2
- package/src/cli/tasks/swc-compile-package/__tests__/get-swc-options.test.ts +46 -4
- package/src/cli/tasks/swc-compile-package/__tests__/swc-compile-package.test.ts +25 -4
- package/src/cli/tasks/swc-compile-package/get-swc-options.ts +14 -1
- package/src/cli/tasks/swc-compile-package/swc-compile-package.ts +6 -2
- package/src/cli/tasks/task.ts +8 -2
- package/src/cli/tasks/tsc-compile/__tests__/tsc-compile.test.ts +8 -32
- package/src/cli/tasks/tsc-compile-package/__tests__/tsc-compile-package.test.ts +10 -19
- package/src/cli/utils/__tests__/cli-npm.test.ts +33 -0
- package/src/cli/utils/__tests__/cli-os.test.ts +86 -3
- package/src/cli/utils/__tests__/compile.test.ts +37 -2
- package/src/cli/utils/__tests__/copy-files.test.ts +1 -1
- package/src/cli/utils/__tests__/with-exponential-backoff.test.ts +119 -0
- package/src/cli/utils/cli-npm.ts +19 -4
- package/src/cli/utils/cli-os.ts +14 -0
- package/src/cli/utils/compile.ts +8 -1
- package/src/cli/utils/copy-files.ts +1 -1
- package/src/cli/utils/index.ts +1 -1
- package/src/cli/utils/resolve-bundler.ts +2 -1
- package/src/cli/utils/ts-config.ts +1 -1
- package/src/cli/utils/with-exponential-backoff.ts +28 -0
- package/src/core/constants.ts +2 -0
- package/src/cypress/config/__tests__/vite-config.test.ts +21 -11
- package/src/cypress/config/__tests__/webpack-config.test.ts +17 -0
- package/src/cypress/config/vite-config.ts +18 -3
- package/src/cypress/config/webpack-config.ts +2 -0
- package/src/storybook-config/__tests__/vite-final.test.ts +71 -11
- package/src/storybook-config/__tests__/webpack-final.test.ts +30 -6
- package/src/storybook-config/vite-final.ts +23 -2
- package/src/storybook-config/webpack-final.ts +10 -2
- package/src/utils/__tests__/exit-when-parent-exits.test.ts +87 -0
- package/src/utils/__tests__/find-up.test.ts +49 -0
- package/src/utils/__tests__/get-configuration.test.ts +62 -0
- package/src/utils/exit-when-parent-exits.ts +33 -0
- package/src/utils/find-up.ts +2 -2
- package/src/utils/get-configuration.ts +14 -5
- package/src/utils/index.ts +1 -0
- package/src/vite/__tests__/build-shared-dependencies.test.ts +39 -5
- package/src/vite/build-shared-dependencies.ts +2 -1
- package/src/vite/config/__tests__/base-config.test.ts +16 -4
- package/src/vite/config/__tests__/create-css-config.test.ts +2 -6
- package/src/vite/config/__tests__/create-filtering-logger.test.ts +9 -0
- package/src/vite/config/__tests__/create-vite-build-context.test.ts +25 -0
- package/src/vite/config/__tests__/create-vite-config.test.ts +6 -3
- package/src/vite/config/base-config.ts +18 -2
- package/src/vite/config/create-filtering-logger.ts +13 -2
- package/src/vite/config/create-vite-build-context.ts +1 -0
- package/src/vite/config/create-vite-config.ts +6 -3
- package/src/vite/index.html +2 -2
- package/src/vite/index.ts +2 -0
- package/src/vite/plugins/__tests__/chain-source-maps-plugin.test.ts +1 -1
- package/src/vite/plugins/__tests__/clean-plugin.test.ts +1 -1
- package/src/vite/plugins/__tests__/css-injector-plugin.test.ts +1 -1
- package/src/vite/plugins/__tests__/design-system-guard-plugin.test.ts +15 -3
- package/src/vite/plugins/__tests__/dev-server-routing-plugin.test.ts +121 -99
- package/src/vite/plugins/__tests__/externals-plugin.test.ts +24 -3
- package/src/vite/plugins/__tests__/html-plugin.test.ts +10 -3
- package/src/vite/plugins/__tests__/html-template.test.ts +10 -2
- package/src/vite/plugins/__tests__/ignore-modules-plugin.test.ts +30 -6
- package/src/vite/plugins/__tests__/istanbul-plugin.test.ts +42 -1
- package/src/vite/plugins/__tests__/less-tilde-plugin.test.ts +91 -0
- package/src/vite/plugins/__tests__/metadata-plugin.test.ts +1 -1
- package/src/vite/plugins/__tests__/moment-locales-plugin.test.ts +35 -25
- package/src/vite/plugins/__tests__/style-urls-plugin.test.ts +1 -1
- package/src/vite/plugins/__tests__/virtual-modules-plugin.test.ts +20 -9
- package/src/vite/plugins/__tests__/window-externals-plugin.test.ts +128 -0
- package/src/vite/plugins/chain-source-maps-plugin.ts +1 -1
- package/src/vite/plugins/clean-plugin.ts +1 -1
- package/src/vite/plugins/css-injector-plugin.ts +1 -1
- package/src/vite/plugins/design-system-guard-plugin.ts +11 -8
- package/src/vite/plugins/dev-server-routing-plugin.ts +4 -4
- package/src/vite/plugins/externals-plugin.ts +15 -6
- package/src/vite/plugins/html-plugin.ts +4 -2
- package/src/vite/plugins/ignore-modules-plugin.ts +32 -23
- package/src/vite/plugins/index.ts +3 -0
- package/src/vite/plugins/istanbul-plugin.ts +28 -1
- package/src/vite/plugins/less-tilde-plugin.ts +64 -0
- package/src/vite/plugins/magic-comments-plugin/magic-comments-plugin.ts +1 -1
- package/src/vite/plugins/metadata-plugin.ts +1 -1
- package/src/vite/plugins/moment-locales-plugin.ts +24 -14
- package/src/vite/plugins/react-refresh-plugin/README.md +165 -0
- package/src/vite/plugins/react-refresh-plugin/__tests__/react-refresh-plugin.test.ts +366 -0
- package/src/vite/plugins/react-refresh-plugin/__tests__/refresh-runtime.test.ts +193 -0
- package/src/vite/plugins/react-refresh-plugin/index.ts +1 -0
- package/src/vite/plugins/react-refresh-plugin/react-refresh-plugin.ts +144 -0
- package/src/vite/plugins/react-refresh-plugin/refresh-runtime.js +113 -0
- package/src/vite/plugins/shared-dependencies-plugin/__tests__/shared-dependencies-plugin.test.ts +21 -16
- package/src/vite/plugins/shared-dependencies-plugin/shared-dependencies-plugin.ts +13 -12
- package/src/vite/plugins/style-urls-plugin.ts +1 -1
- package/src/vite/plugins/virtual-modules-plugin.ts +8 -7
- package/src/vite/plugins/window-externals-plugin.ts +94 -0
- package/src/vite/types.ts +4 -1
- package/src/webpack/__tests__/bundle-webpack.test.ts +32 -0
- package/src/webpack/__tests__/create-webpack-config-web-component.test.ts +17 -5
- package/src/webpack/__tests__/create-webpack-config.test.ts +10 -6
- package/src/webpack/bundle-webpack.ts +7 -1
- package/src/webpack/configs/optimization-config.ts +3 -3
- package/src/webpack/configs/output-config.ts +1 -1
- package/src/webpack/utils/__tests__/normalize-proxy-config.test.ts +121 -0
- package/src/webpack/utils/index.ts +1 -0
- package/src/webpack/utils/normalize-proxy-config.ts +59 -0
- package/tsconfig/types.d.ts +10 -0
- package/dist/cli/utils/get-bundle-command.d.ts +0 -3
- package/dist/cli/utils/get-bundle-command.d.ts.map +0 -1
- package/dist/cli/utils/get-bundle-command.js +0 -16
- package/dist/cli/utils/get-bundle-command.js.map +0 -1
- package/src/cli/utils/__tests__/get-bundle-command.test.ts +0 -23
- package/src/cli/utils/get-bundle-command.ts +0 -5
|
@@ -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', () => {
|
|
@@ -7,7 +7,7 @@ jest.mock('../../../core', () => ({
|
|
|
7
7
|
}));
|
|
8
8
|
|
|
9
9
|
describe(virtualModulesPlugin.name, () => {
|
|
10
|
-
const VIRTUAL_PREFIX = '\
|
|
10
|
+
const VIRTUAL_PREFIX = '\0virtual-modules:';
|
|
11
11
|
const indexCode = "import App from './app';\nregister(App, 'my-component');";
|
|
12
12
|
const designSystemCss = '@import "design-system";';
|
|
13
13
|
|
|
@@ -33,7 +33,7 @@ describe(virtualModulesPlugin.name, () => {
|
|
|
33
33
|
beforeEach(() => (modules.index = indexCode));
|
|
34
34
|
|
|
35
35
|
test('returns plugin with correct name', () => {
|
|
36
|
-
expect(subject()!.name).toBe('virtual-modules');
|
|
36
|
+
expect(subject()!.name).toBe('st:virtual-modules');
|
|
37
37
|
});
|
|
38
38
|
|
|
39
39
|
describe('resolveId', () => {
|
|
@@ -62,19 +62,30 @@ describe(virtualModulesPlugin.name, () => {
|
|
|
62
62
|
});
|
|
63
63
|
});
|
|
64
64
|
|
|
65
|
+
describe('load filter', () => {
|
|
66
|
+
const subject = () => {
|
|
67
|
+
const plugin = virtualModulesPlugin(context)!;
|
|
68
|
+
return (plugin.load as { filter: { id: RegExp } }).filter.id;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
test('matches virtual module ids', () => {
|
|
72
|
+
expect(subject().test(`${VIRTUAL_PREFIX}./index`)).toBe(true);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
test('ignores ordinary module ids', () => {
|
|
76
|
+
expect(subject().test('/src/app.tsx')).toBe(false);
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
|
|
65
80
|
describe('load', () => {
|
|
66
81
|
const subject = () => {
|
|
67
82
|
const plugin = virtualModulesPlugin(context)!;
|
|
68
|
-
return (id: string) => (plugin.load as Function).call(
|
|
83
|
+
return (id: string) => (plugin.load as { handler: Function }).handler.call({}, id);
|
|
69
84
|
};
|
|
70
85
|
|
|
71
86
|
test('returns module code for virtual id', () => {
|
|
72
87
|
expect(subject()(`${VIRTUAL_PREFIX}./index`)).toBe(indexCode);
|
|
73
88
|
});
|
|
74
|
-
|
|
75
|
-
test('returns undefined for non-virtual id', () => {
|
|
76
|
-
expect(subject()('./index')).toBeUndefined();
|
|
77
|
-
});
|
|
78
89
|
});
|
|
79
90
|
});
|
|
80
91
|
|
|
@@ -90,8 +101,8 @@ describe(virtualModulesPlugin.name, () => {
|
|
|
90
101
|
|
|
91
102
|
test('loads design system code', () => {
|
|
92
103
|
const plugin = subject()!;
|
|
93
|
-
const result = (plugin.load as Function).call(
|
|
94
|
-
|
|
104
|
+
const result = (plugin.load as { handler: Function }).handler.call(
|
|
105
|
+
{},
|
|
95
106
|
`${VIRTUAL_PREFIX}./design-system.css`
|
|
96
107
|
);
|
|
97
108
|
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { windowExternalsPlugin } from '../window-externals-plugin';
|
|
2
|
+
|
|
3
|
+
describe(`[startup] ${windowExternalsPlugin.name}`, () => {
|
|
4
|
+
const VIRTUAL_PREFIX = '\0window-externals:';
|
|
5
|
+
const plugin = windowExternalsPlugin({
|
|
6
|
+
jQuery: /^jquery$/,
|
|
7
|
+
moment: /^(moment|moment-timezone)$/,
|
|
8
|
+
accounting: { match: /^accounting$/, exports: ['formatMoney', 'formatNumber'] },
|
|
9
|
+
arcgis: { match: /^@arcgis\/core\//, member: s => s.split('/').pop() },
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
test("resolves before Vite's own resolver", () => {
|
|
13
|
+
expect(plugin.enforce).toBe('pre');
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
describe('resolveId filter', () => {
|
|
17
|
+
const subject = () => (plugin.resolveId as { filter: unknown }).filter;
|
|
18
|
+
|
|
19
|
+
test('scopes the hook to each entry regex', () => {
|
|
20
|
+
expect(subject()).toEqual({
|
|
21
|
+
id: [/^jquery$/, /^(moment|moment-timezone)$/, /^accounting$/, /^@arcgis\/core\//],
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
describe('resolveId', () => {
|
|
27
|
+
let source: string;
|
|
28
|
+
|
|
29
|
+
const subject = () =>
|
|
30
|
+
(plugin.resolveId as { handler: (s: string) => string | null }).handler(source);
|
|
31
|
+
|
|
32
|
+
function itClaimsTheId() {
|
|
33
|
+
test('claims the id', () => {
|
|
34
|
+
expect(subject()).toBe(`${VIRTUAL_PREFIX}${source}`);
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
describe('when source matches a regex entry', () => {
|
|
39
|
+
beforeEach(() => (source = 'jquery'));
|
|
40
|
+
|
|
41
|
+
itClaimsTheId();
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
describe.each(['moment', 'moment-timezone'])(
|
|
45
|
+
'when source matches a multi-specifier regex',
|
|
46
|
+
specifier => {
|
|
47
|
+
beforeEach(() => (source = specifier));
|
|
48
|
+
|
|
49
|
+
itClaimsTheId();
|
|
50
|
+
}
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
describe('when source matches a { match, exports } entry', () => {
|
|
54
|
+
beforeEach(() => (source = 'accounting'));
|
|
55
|
+
|
|
56
|
+
itClaimsTheId();
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
describe('when source matches a { match, member } entry', () => {
|
|
60
|
+
beforeEach(() => (source = '@arcgis/core/views/MapView'));
|
|
61
|
+
|
|
62
|
+
itClaimsTheId();
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
describe('load filter', () => {
|
|
67
|
+
const subject = () => (plugin.load as { filter: { id: RegExp } }).filter.id;
|
|
68
|
+
|
|
69
|
+
test('matches the plugin virtual module ids', () => {
|
|
70
|
+
expect(subject().test(`${VIRTUAL_PREFIX}jquery`)).toBe(true);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
test('ignores ordinary module ids', () => {
|
|
74
|
+
expect(subject().test('/src/app.tsx')).toBe(false);
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
describe('load', () => {
|
|
79
|
+
let id: string;
|
|
80
|
+
|
|
81
|
+
const subject = () =>
|
|
82
|
+
(plugin.load as { handler: (i: string) => string | null }).handler(id);
|
|
83
|
+
|
|
84
|
+
function itEmitsWindowGlobal(name: string) {
|
|
85
|
+
test('emits window.<global>', () => {
|
|
86
|
+
expect(subject()).toBe(`export default window.${name};`);
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
describe('when id matches a regex entry', () => {
|
|
91
|
+
beforeEach(() => (id = `${VIRTUAL_PREFIX}jquery`));
|
|
92
|
+
|
|
93
|
+
itEmitsWindowGlobal('jQuery');
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
describe.each(['moment', 'moment-timezone'])(
|
|
97
|
+
'when id matches a multi-specifier regex',
|
|
98
|
+
specifier => {
|
|
99
|
+
beforeEach(() => (id = `${VIRTUAL_PREFIX}${specifier}`));
|
|
100
|
+
|
|
101
|
+
itEmitsWindowGlobal('moment');
|
|
102
|
+
}
|
|
103
|
+
);
|
|
104
|
+
|
|
105
|
+
describe('when id matches a { match, member } entry', () => {
|
|
106
|
+
beforeEach(() => (id = `${VIRTUAL_PREFIX}@arcgis/core/views/MapView`));
|
|
107
|
+
|
|
108
|
+
test('emits window.<global>[<member>]', () => {
|
|
109
|
+
expect(subject()).toBe('export default window.arcgis["MapView"];');
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
describe('when id matches a { match, exports } entry', () => {
|
|
114
|
+
beforeEach(() => (id = `${VIRTUAL_PREFIX}accounting`));
|
|
115
|
+
|
|
116
|
+
test('emits the default plus a named re-export per declared name', () => {
|
|
117
|
+
expect(subject()).toBe(
|
|
118
|
+
[
|
|
119
|
+
'const _m = window.accounting;',
|
|
120
|
+
'export default _m;',
|
|
121
|
+
'export const formatMoney = _m.formatMoney;',
|
|
122
|
+
'export const formatNumber = _m.formatNumber;',
|
|
123
|
+
].join('\n')
|
|
124
|
+
);
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
});
|
|
@@ -9,7 +9,7 @@ import type { Plugin } from 'rolldown';
|
|
|
9
9
|
*/
|
|
10
10
|
export function chainSourceMapsPlugin(): Plugin {
|
|
11
11
|
return {
|
|
12
|
-
name: 'chain-source-maps',
|
|
12
|
+
name: 'st:chain-source-maps',
|
|
13
13
|
load(id) {
|
|
14
14
|
const mapPath = `${id}.map`;
|
|
15
15
|
if (id.endsWith('.js') && fs.existsSync(mapPath)) {
|
|
@@ -23,7 +23,7 @@ export function cssInjectorPlugin(context: BuildContext): Plugin | undefined {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
return {
|
|
26
|
-
name: 'mfe-css-injector',
|
|
26
|
+
name: 'st:mfe-css-injector',
|
|
27
27
|
enforce: 'post',
|
|
28
28
|
transform(code, id) {
|
|
29
29
|
if (!id.endsWith('.css') && !id.endsWith('.less') && !id.endsWith('.scss')) {
|
|
@@ -20,15 +20,18 @@ export function designSystemGuardPlugin(context: BuildContext): Plugin {
|
|
|
20
20
|
!emitExposedDependencies;
|
|
21
21
|
|
|
22
22
|
return {
|
|
23
|
-
name: 'design-system-guard',
|
|
23
|
+
name: 'st:design-system-guard',
|
|
24
24
|
enforce: 'pre',
|
|
25
|
-
resolveId
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
25
|
+
resolveId: {
|
|
26
|
+
filter: { id: DESIGN_SYSTEM_CSS },
|
|
27
|
+
handler(source, importer) {
|
|
28
|
+
if (designSystemInSharedBundle && importer && DESIGN_SYSTEM_CSS.test(source)) {
|
|
29
|
+
const filename = path.parse(importer).name;
|
|
30
|
+
this.error(
|
|
31
|
+
`do not import design-system.css in "${filename}"; it is automatically included as a shared dependency`
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
},
|
|
32
35
|
},
|
|
33
36
|
};
|
|
34
37
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import path from 'path';
|
|
3
|
-
import type
|
|
3
|
+
import { normalizePath, type Plugin } from 'vite';
|
|
4
4
|
import { getBundleType, type BuildContext } from '../../core';
|
|
5
5
|
import { log } from '../../utils';
|
|
6
6
|
|
|
@@ -38,14 +38,14 @@ export function devServerRoutingPlugin(context: BuildContext): Plugin {
|
|
|
38
38
|
};
|
|
39
39
|
|
|
40
40
|
return {
|
|
41
|
-
name: 'dev-server-routing',
|
|
41
|
+
name: 'st:dev-server-routing',
|
|
42
42
|
|
|
43
43
|
configResolved(config) {
|
|
44
44
|
outDir = config.build.outDir;
|
|
45
45
|
},
|
|
46
46
|
|
|
47
47
|
configureServer(server) {
|
|
48
|
-
const outDirRelative = `/${path.relative(process.cwd(), outDir)}/`;
|
|
48
|
+
const outDirRelative = `/${normalizePath(path.relative(process.cwd(), outDir))}/`;
|
|
49
49
|
|
|
50
50
|
server.middlewares.use((req, _res, next) => {
|
|
51
51
|
logRequest(req);
|
|
@@ -72,7 +72,7 @@ export function devServerRoutingPlugin(context: BuildContext): Plugin {
|
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
const destDir = path.resolve(destination);
|
|
75
|
-
const mountPath = '/' + path.relative(process.cwd(), destDir);
|
|
75
|
+
const mountPath = '/' + normalizePath(path.relative(process.cwd(), destDir));
|
|
76
76
|
|
|
77
77
|
const contentTypes: Record<string, string> = {
|
|
78
78
|
'.js': 'application/javascript',
|
|
@@ -3,6 +3,10 @@ import path from 'path';
|
|
|
3
3
|
import type { Plugin } from 'vite';
|
|
4
4
|
import { BuildContext, getExternals } from '../../core';
|
|
5
5
|
|
|
6
|
+
/* Dots are the only valid regex-special character in package names */
|
|
7
|
+
const buildEscapedRegExp = (dependency: string) =>
|
|
8
|
+
new RegExp(`^${dependency.replace(/\./g, '\\.')}$`);
|
|
9
|
+
|
|
6
10
|
/*
|
|
7
11
|
* Externalizes shared dependencies by redirecting imports to CJS proxy modules
|
|
8
12
|
* that read from the host's global shared deps registry at runtime.
|
|
@@ -55,14 +59,14 @@ export function externalsPlugin(context: BuildContext): Plugin | undefined {
|
|
|
55
59
|
const { isProduction } = context.build;
|
|
56
60
|
|
|
57
61
|
return {
|
|
58
|
-
name: 'externals',
|
|
62
|
+
name: 'st:externals',
|
|
59
63
|
enforce: 'pre',
|
|
60
64
|
config: isProduction
|
|
61
65
|
? undefined
|
|
62
66
|
: () => ({
|
|
63
67
|
resolve: {
|
|
64
68
|
alias: Object.keys(entries).map(dep => ({
|
|
65
|
-
find:
|
|
69
|
+
find: buildEscapedRegExp(dep),
|
|
66
70
|
replacement: path.join(proxyNodeModules, dep),
|
|
67
71
|
})),
|
|
68
72
|
},
|
|
@@ -71,10 +75,15 @@ export function externalsPlugin(context: BuildContext): Plugin | undefined {
|
|
|
71
75
|
},
|
|
72
76
|
}),
|
|
73
77
|
resolveId: isProduction
|
|
74
|
-
?
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
+
? {
|
|
79
|
+
filter: {
|
|
80
|
+
id: Object.keys(entries).map(buildEscapedRegExp),
|
|
81
|
+
},
|
|
82
|
+
handler(source: string) {
|
|
83
|
+
if (source in entries) {
|
|
84
|
+
return path.join(proxyNodeModules, source, 'index.cjs');
|
|
85
|
+
}
|
|
86
|
+
},
|
|
78
87
|
}
|
|
79
88
|
: undefined,
|
|
80
89
|
};
|
|
@@ -7,7 +7,7 @@ import { ViteBuildContext } from '../types';
|
|
|
7
7
|
|
|
8
8
|
export function htmlPlugin(context: ViteBuildContext): Plugin {
|
|
9
9
|
const { name, isProduction } = context.build;
|
|
10
|
-
const { isWebComponent } = context.package;
|
|
10
|
+
const { isWebComponent, destination } = context.package;
|
|
11
11
|
const { css, js } = getSharedEntryPoints(context);
|
|
12
12
|
const { pluginOverrides } = context.bundlerConfig;
|
|
13
13
|
|
|
@@ -26,6 +26,7 @@ export function htmlPlugin(context: ViteBuildContext): Plugin {
|
|
|
26
26
|
isProduction,
|
|
27
27
|
isWebComponent,
|
|
28
28
|
name,
|
|
29
|
+
tsOutDir: destination,
|
|
29
30
|
});
|
|
30
31
|
}
|
|
31
32
|
|
|
@@ -42,7 +43,7 @@ export function htmlPlugin(context: ViteBuildContext): Plugin {
|
|
|
42
43
|
const VIRTUAL_HTML_PATH = path.resolve(INDEX_HTML);
|
|
43
44
|
|
|
44
45
|
return {
|
|
45
|
-
name: 'html',
|
|
46
|
+
name: 'st:html',
|
|
46
47
|
/*
|
|
47
48
|
* Auto-detect favicon.ico in vite's publicDir so projects following
|
|
48
49
|
* the convention get a working favicon link without explicit config.
|
|
@@ -64,6 +65,7 @@ export function htmlPlugin(context: ViteBuildContext): Plugin {
|
|
|
64
65
|
}
|
|
65
66
|
let html = renderHtml();
|
|
66
67
|
html = await server.transformIndexHtml(req.url, html);
|
|
68
|
+
res.setHeader('Content-Type', 'text/html');
|
|
67
69
|
res.end(html);
|
|
68
70
|
});
|
|
69
71
|
};
|
|
@@ -2,8 +2,11 @@ import type { Plugin } from 'vite';
|
|
|
2
2
|
import { checkResource } from '../../core';
|
|
3
3
|
import type { PackageContext } from '../../core/types';
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
const VIRTUAL_PREFIX = '\0ignore-modules:';
|
|
6
|
+
const VIRTUAL_ID_PATTERN = new RegExp(`^${VIRTUAL_PREFIX}`);
|
|
7
|
+
|
|
8
|
+
export const THROW_PREFIX = `${VIRTUAL_PREFIX}throw:`;
|
|
9
|
+
export const EMPTY_PREFIX = `${VIRTUAL_PREFIX}empty:`;
|
|
7
10
|
|
|
8
11
|
/**
|
|
9
12
|
* Handles optional peer dependencies that are not installed.
|
|
@@ -26,29 +29,35 @@ export function ignoreModulesPlugin(context: {
|
|
|
26
29
|
const checker = checkResource(context);
|
|
27
30
|
|
|
28
31
|
return {
|
|
29
|
-
name: 'ignore-modules',
|
|
32
|
+
name: 'st:ignore-modules',
|
|
30
33
|
enforce: 'pre',
|
|
31
|
-
resolveId
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
34
|
+
resolveId: {
|
|
35
|
+
filter: { id: /^[@a-z]/ }, // Only bare specifiers can be optional peers
|
|
36
|
+
handler(source, importer) {
|
|
37
|
+
if (!importer) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
const mode = checker({ resource: source, importer });
|
|
41
|
+
if (mode === 'throw') {
|
|
42
|
+
return `${THROW_PREFIX}${source}`;
|
|
43
|
+
}
|
|
44
|
+
if (mode === 'empty') {
|
|
45
|
+
return `${EMPTY_PREFIX}${source}`;
|
|
46
|
+
}
|
|
47
|
+
},
|
|
42
48
|
},
|
|
43
|
-
load
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
load: {
|
|
50
|
+
filter: { id: VIRTUAL_ID_PATTERN },
|
|
51
|
+
handler(id) {
|
|
52
|
+
if (id.startsWith(THROW_PREFIX)) {
|
|
53
|
+
const source = id.slice(THROW_PREFIX.length);
|
|
54
|
+
const message = JSON.stringify(`Cannot find module '${source}'`);
|
|
55
|
+
return `throw Object.assign(new Error(${message}), { code: 'MODULE_NOT_FOUND' });`;
|
|
56
|
+
}
|
|
57
|
+
if (id.startsWith(EMPTY_PREFIX)) {
|
|
58
|
+
return 'export {};';
|
|
59
|
+
}
|
|
60
|
+
},
|
|
52
61
|
},
|
|
53
62
|
};
|
|
54
63
|
}
|
|
@@ -8,9 +8,12 @@ export * from './externals-plugin';
|
|
|
8
8
|
export * from './html-plugin';
|
|
9
9
|
export * from './ignore-modules-plugin';
|
|
10
10
|
export * from './istanbul-plugin';
|
|
11
|
+
export * from './less-tilde-plugin';
|
|
11
12
|
export * from './magic-comments-plugin';
|
|
12
13
|
export * from './metadata-plugin';
|
|
13
14
|
export * from './moment-locales-plugin';
|
|
15
|
+
export * from './react-refresh-plugin';
|
|
14
16
|
export * from './style-urls-plugin';
|
|
15
17
|
export * from './svgr-plugin';
|
|
16
18
|
export * from './virtual-modules-plugin';
|
|
19
|
+
export * from './window-externals-plugin';
|