@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
|
@@ -8,7 +8,14 @@ Object.defineProperty(exports, "istanbulPlugin", {
|
|
|
8
8
|
return istanbulPlugin;
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
|
+
const _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
12
|
+
const _core = require("../../core");
|
|
11
13
|
const _utils = require("./utils");
|
|
14
|
+
function _interop_require_default(obj) {
|
|
15
|
+
return obj && obj.__esModule ? obj : {
|
|
16
|
+
default: obj
|
|
17
|
+
};
|
|
18
|
+
}
|
|
12
19
|
function istanbulPlugin(context) {
|
|
13
20
|
if (!context.options.codeCoverage) {
|
|
14
21
|
return;
|
|
@@ -17,11 +24,36 @@ function istanbulPlugin(context) {
|
|
|
17
24
|
return (0, _utils.importEsm)('vite-plugin-istanbul').then(({ default: istanbul })=>istanbul({
|
|
18
25
|
exclude: [
|
|
19
26
|
'**/node_modules/**',
|
|
20
|
-
'**/.yalc/**'
|
|
27
|
+
'**/.yalc/**',
|
|
28
|
+
...sharedDependenciesExclude(context)
|
|
21
29
|
],
|
|
22
30
|
requireEnv: false,
|
|
23
31
|
forceBuildInstrument: true
|
|
24
32
|
}));
|
|
25
33
|
}
|
|
34
|
+
/*
|
|
35
|
+
* devServerRoutingPlugin serves the prebuilt shared-dependencies bundle (react, mobx, the
|
|
36
|
+
* design system, etc.) straight from disk at dev time. Instrumenting that vendor code breaks
|
|
37
|
+
* Vite's import analysis on the huge instrumented output and provides no useful coverage.
|
|
38
|
+
*
|
|
39
|
+
* vite-plugin-istanbul matches exclude patterns against paths relative to process.cwd()
|
|
40
|
+
* (via test-exclude's default `relativePath` behavior), so the pattern must be cwd-relative
|
|
41
|
+
* rather than absolute.
|
|
42
|
+
*/ function sharedDependenciesExclude(context) {
|
|
43
|
+
if (!context.package.isExposeSharedDependencies) {
|
|
44
|
+
return [];
|
|
45
|
+
}
|
|
46
|
+
const sharedContext = {
|
|
47
|
+
...context,
|
|
48
|
+
build: {
|
|
49
|
+
...context.build,
|
|
50
|
+
emitExposedDependencies: true
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
const outputPath = (0, _core.resolveOutputPath)(sharedContext, context.bundlerConfig.outDir);
|
|
54
|
+
return [
|
|
55
|
+
_path.default.join(_path.default.relative(process.cwd(), outputPath), '**').replace(/\\/g, '/')
|
|
56
|
+
];
|
|
57
|
+
}
|
|
26
58
|
|
|
27
59
|
//# sourceMappingURL=istanbul-plugin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/vite/plugins/istanbul-plugin.ts"],"sourcesContent":["import type { Plugin } from 'vite';\nimport { ViteBuildContext } from '../types';\nimport { importEsm } from './utils';\n\nexport function istanbulPlugin(context: ViteBuildContext): Promise<Plugin> | undefined {\n if (!context.options.codeCoverage) {\n return;\n }\n\n // vite-plugin-istanbul is ESM-only; load it natively so SWC doesn't rewrite to require.\n return importEsm<typeof import('vite-plugin-istanbul')>('vite-plugin-istanbul').then(\n ({ default: istanbul }) =>\n istanbul({\n exclude: ['**/node_modules/**'
|
|
1
|
+
{"version":3,"sources":["../../../src/vite/plugins/istanbul-plugin.ts"],"sourcesContent":["import path from 'path';\nimport type { Plugin } from 'vite';\nimport { resolveOutputPath } from '../../core';\nimport { ViteBuildContext } from '../types';\nimport { importEsm } from './utils';\n\nexport function istanbulPlugin(context: ViteBuildContext): Promise<Plugin> | undefined {\n if (!context.options.codeCoverage) {\n return;\n }\n\n // vite-plugin-istanbul is ESM-only; load it natively so SWC doesn't rewrite to require.\n return importEsm<typeof import('vite-plugin-istanbul')>('vite-plugin-istanbul').then(\n ({ default: istanbul }) =>\n istanbul({\n exclude: [\n '**/node_modules/**',\n '**/.yalc/**',\n ...sharedDependenciesExclude(context),\n ],\n requireEnv: false,\n forceBuildInstrument: true,\n })\n );\n}\n\n/*\n * devServerRoutingPlugin serves the prebuilt shared-dependencies bundle (react, mobx, the\n * design system, etc.) straight from disk at dev time. Instrumenting that vendor code breaks\n * Vite's import analysis on the huge instrumented output and provides no useful coverage.\n *\n * vite-plugin-istanbul matches exclude patterns against paths relative to process.cwd()\n * (via test-exclude's default `relativePath` behavior), so the pattern must be cwd-relative\n * rather than absolute.\n */\nfunction sharedDependenciesExclude(context: ViteBuildContext): string[] {\n if (!context.package.isExposeSharedDependencies) {\n return [];\n }\n const sharedContext = {\n ...context,\n build: { ...context.build, emitExposedDependencies: true },\n };\n const outputPath = resolveOutputPath(sharedContext, context.bundlerConfig.outDir);\n return [path.join(path.relative(process.cwd(), outputPath), '**').replace(/\\\\/g, '/')];\n}\n"],"names":["istanbulPlugin","context","options","codeCoverage","importEsm","then","default","istanbul","exclude","sharedDependenciesExclude","requireEnv","forceBuildInstrument","package","isExposeSharedDependencies","sharedContext","build","emitExposedDependencies","outputPath","resolveOutputPath","bundlerConfig","outDir","path","join","relative","process","cwd","replace"],"mappings":";;;;+BAMgBA;;;eAAAA;;;6DANC;sBAEiB;uBAER;;;;;;AAEnB,SAASA,eAAeC,OAAyB;IACpD,IAAI,CAACA,QAAQC,OAAO,CAACC,YAAY,EAAE;QAC/B;IACJ;IAEA,wFAAwF;IACxF,OAAOC,IAAAA,gBAAS,EAAwC,wBAAwBC,IAAI,CAChF,CAAC,EAAEC,SAASC,QAAQ,EAAE,GAClBA,SAAS;YACLC,SAAS;gBACL;gBACA;mBACGC,0BAA0BR;aAChC;YACDS,YAAY;YACZC,sBAAsB;QAC1B;AAEZ;AAEA;;;;;;;;CAQC,GACD,SAASF,0BAA0BR,OAAyB;IACxD,IAAI,CAACA,QAAQW,OAAO,CAACC,0BAA0B,EAAE;QAC7C,OAAO,EAAE;IACb;IACA,MAAMC,gBAAgB;QAClB,GAAGb,OAAO;QACVc,OAAO;YAAE,GAAGd,QAAQc,KAAK;YAAEC,yBAAyB;QAAK;IAC7D;IACA,MAAMC,aAAaC,IAAAA,uBAAiB,EAACJ,eAAeb,QAAQkB,aAAa,CAACC,MAAM;IAChF,OAAO;QAACC,aAAI,CAACC,IAAI,CAACD,aAAI,CAACE,QAAQ,CAACC,QAAQC,GAAG,IAAIR,aAAa,MAAMS,OAAO,CAAC,OAAO;KAAK;AAC1F"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"less-tilde-plugin.d.ts","sourceRoot":"","sources":["../../../src/vite/plugins/less-tilde-plugin.ts"],"names":[],"mappings":"AAIA,UAAU,iBAAiB;IACvB,cAAc,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;CAC1C;AAQD,wBAAgB,eAAe;kBAET,GAAG,iBAAiB,iBAAiB;EAK1D"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "lessTildePlugin", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return lessTildePlugin;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
|
|
12
|
+
const _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
13
|
+
const _utils = require("../../utils");
|
|
14
|
+
function _interop_require_default(obj) {
|
|
15
|
+
return obj && obj.__esModule ? obj : {
|
|
16
|
+
default: obj
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
function lessTildePlugin() {
|
|
20
|
+
return {
|
|
21
|
+
install (less, pluginManager) {
|
|
22
|
+
const TildeFileManager = createTildeFileManager(less);
|
|
23
|
+
pluginManager.addFileManager(new TildeFileManager());
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
/*
|
|
28
|
+
* A FileManager subclass bound to the Less instance Vite passes to the plugin. It claims `~`
|
|
29
|
+
* imports and rewrites them to a node_modules path before delegating to the base loader.
|
|
30
|
+
*/ function createTildeFileManager(less) {
|
|
31
|
+
return class extends less.FileManager {
|
|
32
|
+
supports(filename) {
|
|
33
|
+
return filename.startsWith('~');
|
|
34
|
+
}
|
|
35
|
+
loadFile(filename, currentDirectory, options, environment) {
|
|
36
|
+
return super.loadFile(resolveFromNodeModules(filename.slice(1), currentDirectory), currentDirectory, options, environment);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
/*
|
|
41
|
+
* Resolve a bare `pkg/path` specifier against the nearest node_modules, walking up from the
|
|
42
|
+
* importing file's directory, so the import binds to the importer's dependencies (matching
|
|
43
|
+
* webpack, and covering both pnpm's symlinked store and npm's hoisted tree).
|
|
44
|
+
*/ function resolveFromNodeModules(specifier, fromDirectory) {
|
|
45
|
+
const withExtension = _path.default.extname(specifier) ? specifier : `${specifier}.less`;
|
|
46
|
+
const resolved = (0, _utils.findUp)((directory)=>{
|
|
47
|
+
const candidate = _path.default.join(directory, 'node_modules', withExtension);
|
|
48
|
+
return _fs.default.existsSync(candidate) ? candidate : undefined;
|
|
49
|
+
}, fromDirectory);
|
|
50
|
+
return resolved !== null && resolved !== void 0 ? resolved : withExtension;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
//# sourceMappingURL=less-tilde-plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/vite/plugins/less-tilde-plugin.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\nimport { findUp } from '../../utils';\n\ninterface LessPluginManager {\n addFileManager(manager: unknown): void;\n}\n\n/*\n * Less plugin that resolves webpack-style `~pkg` imports (e.g. `~@servicetitan/tokens/...`) from\n * node_modules. Vite's Less integration does not understand the `~` prefix, so without this every\n * style importing a package with `~` fails to resolve. Mirrors the old less-loader behavior to\n * ease webpack-to-Vite migration.\n */\nexport function lessTildePlugin() {\n return {\n install(less: any, pluginManager: LessPluginManager) {\n const TildeFileManager = createTildeFileManager(less);\n pluginManager.addFileManager(new TildeFileManager());\n },\n };\n}\n\n/*\n * A FileManager subclass bound to the Less instance Vite passes to the plugin. It claims `~`\n * imports and rewrites them to a node_modules path before delegating to the base loader.\n */\nfunction createTildeFileManager(less: any) {\n return class extends less.FileManager {\n supports(filename: string) {\n return filename.startsWith('~');\n }\n\n loadFile(\n filename: string,\n currentDirectory: string,\n options: unknown,\n environment: unknown\n ) {\n return super.loadFile(\n resolveFromNodeModules(filename.slice(1), currentDirectory),\n currentDirectory,\n options,\n environment\n );\n }\n };\n}\n\n/*\n * Resolve a bare `pkg/path` specifier against the nearest node_modules, walking up from the\n * importing file's directory, so the import binds to the importer's dependencies (matching\n * webpack, and covering both pnpm's symlinked store and npm's hoisted tree).\n */\nfunction resolveFromNodeModules(specifier: string, fromDirectory: string): string {\n const withExtension = path.extname(specifier) ? specifier : `${specifier}.less`;\n\n const resolved = findUp(directory => {\n const candidate = path.join(directory, 'node_modules', withExtension);\n return fs.existsSync(candidate) ? candidate : undefined;\n }, fromDirectory);\n\n return resolved ?? withExtension;\n}\n"],"names":["lessTildePlugin","install","less","pluginManager","TildeFileManager","createTildeFileManager","addFileManager","FileManager","supports","filename","startsWith","loadFile","currentDirectory","options","environment","resolveFromNodeModules","slice","specifier","fromDirectory","withExtension","path","extname","resolved","findUp","directory","candidate","join","fs","existsSync","undefined"],"mappings":";;;;+BAcgBA;;;eAAAA;;;2DAdD;6DACE;uBACM;;;;;;AAYhB,SAASA;IACZ,OAAO;QACHC,SAAQC,IAAS,EAAEC,aAAgC;YAC/C,MAAMC,mBAAmBC,uBAAuBH;YAChDC,cAAcG,cAAc,CAAC,IAAIF;QACrC;IACJ;AACJ;AAEA;;;CAGC,GACD,SAASC,uBAAuBH,IAAS;IACrC,OAAO,cAAcA,KAAKK,WAAW;QACjCC,SAASC,QAAgB,EAAE;YACvB,OAAOA,SAASC,UAAU,CAAC;QAC/B;QAEAC,SACIF,QAAgB,EAChBG,gBAAwB,EACxBC,OAAgB,EAChBC,WAAoB,EACtB;YACE,OAAO,KAAK,CAACH,SACTI,uBAAuBN,SAASO,KAAK,CAAC,IAAIJ,mBAC1CA,kBACAC,SACAC;QAER;IACJ;AACJ;AAEA;;;;CAIC,GACD,SAASC,uBAAuBE,SAAiB,EAAEC,aAAqB;IACpE,MAAMC,gBAAgBC,aAAI,CAACC,OAAO,CAACJ,aAAaA,YAAY,GAAGA,UAAU,KAAK,CAAC;IAE/E,MAAMK,WAAWC,IAAAA,aAAM,EAACC,CAAAA;QACpB,MAAMC,YAAYL,aAAI,CAACM,IAAI,CAACF,WAAW,gBAAgBL;QACvD,OAAOQ,WAAE,CAACC,UAAU,CAACH,aAAaA,YAAYI;IAClD,GAAGX;IAEH,OAAOI,qBAAAA,sBAAAA,WAAYH;AACvB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/vite/plugins/magic-comments-plugin/magic-comments-plugin.ts"],"sourcesContent":["import type { Plugin } from 'vite';\nimport { ViteBuildContext } from '../../types';\nimport { parseMagicComments } from './parse-magic-comments';\n\n/* Mirrors Vite's default chunk file naming. A magic comment only substitutes the [name] token. */\nconst CHUNK_FILE_NAME = 'assets/[name]-[hash].js';\n\n/*\n * Honors `webpackChunkName` magic comments on dynamic imports. Vite splits dynamic\n * imports into separate chunks, named after the source file; this renames the chunk\n * to specified `webpackChunkName`. Warns when a name is reused by different modules.\n */\nexport function magicCommentsPlugin(context: ViteBuildContext): Plugin | undefined {\n if (!context.build.isProduction) {\n return;\n }\n\n const chunkNames = new Map<string, string>();\n const moduleByName = new Map<string, string>();\n\n return {\n name: 'magic-comments',\n apply: 'build',\n enforce: 'pre',\n config: () => ({\n build: {\n rolldownOptions: {\n output: {\n chunkFileNames: (chunk: { facadeModuleId?: string | null }) => {\n const name =\n chunk.facadeModuleId && chunkNames.get(chunk.facadeModuleId);\n return name ? CHUNK_FILE_NAME.replace('[name]', name) : CHUNK_FILE_NAME;\n },\n },\n },\n },\n }),\n transform: {\n filter: { id: { exclude: /node_modules/ }, code: 'webpackChunkName' },\n async handler(code, id) {\n const comments = await parseMagicComments(code);\n const resolved = await Promise.all(\n comments.map(({ importPath }) => this.resolve(importPath, id))\n );\n comments.forEach(({ chunkName }, index) => {\n const module = resolved[index];\n if (!module) {\n return;\n }\n const claimedBy = moduleByName.get(chunkName);\n if (claimedBy && claimedBy !== module.id) {\n this.warn(\n `webpackChunkName \"${chunkName}\" is used by multiple modules; Vite emits a separate chunk for each rather than merging them.`\n );\n } else {\n moduleByName.set(chunkName, module.id);\n }\n chunkNames.set(module.id, chunkName);\n });\n },\n },\n };\n}\n"],"names":["magicCommentsPlugin","CHUNK_FILE_NAME","context","build","isProduction","chunkNames","Map","moduleByName","name","apply","enforce","config","rolldownOptions","output","chunkFileNames","chunk","facadeModuleId","get","replace","transform","filter","id","exclude","code","handler","comments","parseMagicComments","resolved","Promise","all","map","importPath","resolve","forEach","chunkName","index","module","claimedBy","warn","set"],"mappings":";;;;+BAYgBA;;;eAAAA;;;oCAVmB;AAEnC,gGAAgG,GAChG,MAAMC,kBAAkB;AAOjB,SAASD,oBAAoBE,OAAyB;IACzD,IAAI,CAACA,QAAQC,KAAK,CAACC,YAAY,EAAE;QAC7B;IACJ;IAEA,MAAMC,aAAa,IAAIC;IACvB,MAAMC,eAAe,IAAID;IAEzB,OAAO;QACHE,MAAM;QACNC,OAAO;QACPC,SAAS;QACTC,QAAQ,IAAO,CAAA;gBACXR,OAAO;oBACHS,iBAAiB;wBACbC,QAAQ;4BACJC,gBAAgB,CAACC;gCACb,MAAMP,OACFO,MAAMC,cAAc,IAAIX,WAAWY,GAAG,CAACF,MAAMC,cAAc;gCAC/D,OAAOR,OAAOP,gBAAgBiB,OAAO,CAAC,UAAUV,QAAQP;4BAC5D;wBACJ;oBACJ;gBACJ;YACJ,CAAA;QACAkB,WAAW;YACPC,QAAQ;gBAAEC,IAAI;oBAAEC,SAAS;gBAAe;gBAAGC,MAAM;YAAmB;YACpE,MAAMC,SAAQD,IAAI,EAAEF,EAAE;gBAClB,MAAMI,WAAW,MAAMC,IAAAA,sCAAkB,EAACH;gBAC1C,MAAMI,WAAW,MAAMC,QAAQC,GAAG,CAC9BJ,SAASK,GAAG,CAAC,CAAC,EAAEC,UAAU,EAAE,GAAK,IAAI,CAACC,OAAO,CAACD,YAAYV;gBAE9DI,SAASQ,OAAO,CAAC,CAAC,EAAEC,SAAS,EAAE,EAAEC;oBAC7B,MAAMC,SAAST,QAAQ,CAACQ,MAAM;oBAC9B,IAAI,CAACC,QAAQ;wBACT;oBACJ;oBACA,MAAMC,YAAY9B,aAAaU,GAAG,CAACiB;oBACnC,IAAIG,aAAaA,cAAcD,OAAOf,EAAE,EAAE;wBACtC,IAAI,CAACiB,IAAI,CACL,CAAC,kBAAkB,EAAEJ,UAAU,6FAA6F,CAAC;oBAErI,OAAO;wBACH3B,aAAagC,GAAG,CAACL,WAAWE,OAAOf,EAAE;oBACzC;oBACAhB,WAAWkC,GAAG,CAACH,OAAOf,EAAE,EAAEa;gBAC9B;YACJ;QACJ;IACJ;AACJ"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/vite/plugins/magic-comments-plugin/magic-comments-plugin.ts"],"sourcesContent":["import type { Plugin } from 'vite';\nimport { ViteBuildContext } from '../../types';\nimport { parseMagicComments } from './parse-magic-comments';\n\n/* Mirrors Vite's default chunk file naming. A magic comment only substitutes the [name] token. */\nconst CHUNK_FILE_NAME = 'assets/[name]-[hash].js';\n\n/*\n * Honors `webpackChunkName` magic comments on dynamic imports. Vite splits dynamic\n * imports into separate chunks, named after the source file; this renames the chunk\n * to specified `webpackChunkName`. Warns when a name is reused by different modules.\n */\nexport function magicCommentsPlugin(context: ViteBuildContext): Plugin | undefined {\n if (!context.build.isProduction) {\n return;\n }\n\n const chunkNames = new Map<string, string>();\n const moduleByName = new Map<string, string>();\n\n return {\n name: 'st:magic-comments',\n apply: 'build',\n enforce: 'pre',\n config: () => ({\n build: {\n rolldownOptions: {\n output: {\n chunkFileNames: (chunk: { facadeModuleId?: string | null }) => {\n const name =\n chunk.facadeModuleId && chunkNames.get(chunk.facadeModuleId);\n return name ? CHUNK_FILE_NAME.replace('[name]', name) : CHUNK_FILE_NAME;\n },\n },\n },\n },\n }),\n transform: {\n filter: { id: { exclude: /node_modules/ }, code: 'webpackChunkName' },\n async handler(code, id) {\n const comments = await parseMagicComments(code);\n const resolved = await Promise.all(\n comments.map(({ importPath }) => this.resolve(importPath, id))\n );\n comments.forEach(({ chunkName }, index) => {\n const module = resolved[index];\n if (!module) {\n return;\n }\n const claimedBy = moduleByName.get(chunkName);\n if (claimedBy && claimedBy !== module.id) {\n this.warn(\n `webpackChunkName \"${chunkName}\" is used by multiple modules; Vite emits a separate chunk for each rather than merging them.`\n );\n } else {\n moduleByName.set(chunkName, module.id);\n }\n chunkNames.set(module.id, chunkName);\n });\n },\n },\n };\n}\n"],"names":["magicCommentsPlugin","CHUNK_FILE_NAME","context","build","isProduction","chunkNames","Map","moduleByName","name","apply","enforce","config","rolldownOptions","output","chunkFileNames","chunk","facadeModuleId","get","replace","transform","filter","id","exclude","code","handler","comments","parseMagicComments","resolved","Promise","all","map","importPath","resolve","forEach","chunkName","index","module","claimedBy","warn","set"],"mappings":";;;;+BAYgBA;;;eAAAA;;;oCAVmB;AAEnC,gGAAgG,GAChG,MAAMC,kBAAkB;AAOjB,SAASD,oBAAoBE,OAAyB;IACzD,IAAI,CAACA,QAAQC,KAAK,CAACC,YAAY,EAAE;QAC7B;IACJ;IAEA,MAAMC,aAAa,IAAIC;IACvB,MAAMC,eAAe,IAAID;IAEzB,OAAO;QACHE,MAAM;QACNC,OAAO;QACPC,SAAS;QACTC,QAAQ,IAAO,CAAA;gBACXR,OAAO;oBACHS,iBAAiB;wBACbC,QAAQ;4BACJC,gBAAgB,CAACC;gCACb,MAAMP,OACFO,MAAMC,cAAc,IAAIX,WAAWY,GAAG,CAACF,MAAMC,cAAc;gCAC/D,OAAOR,OAAOP,gBAAgBiB,OAAO,CAAC,UAAUV,QAAQP;4BAC5D;wBACJ;oBACJ;gBACJ;YACJ,CAAA;QACAkB,WAAW;YACPC,QAAQ;gBAAEC,IAAI;oBAAEC,SAAS;gBAAe;gBAAGC,MAAM;YAAmB;YACpE,MAAMC,SAAQD,IAAI,EAAEF,EAAE;gBAClB,MAAMI,WAAW,MAAMC,IAAAA,sCAAkB,EAACH;gBAC1C,MAAMI,WAAW,MAAMC,QAAQC,GAAG,CAC9BJ,SAASK,GAAG,CAAC,CAAC,EAAEC,UAAU,EAAE,GAAK,IAAI,CAACC,OAAO,CAACD,YAAYV;gBAE9DI,SAASQ,OAAO,CAAC,CAAC,EAAEC,SAAS,EAAE,EAAEC;oBAC7B,MAAMC,SAAST,QAAQ,CAACQ,MAAM;oBAC9B,IAAI,CAACC,QAAQ;wBACT;oBACJ;oBACA,MAAMC,YAAY9B,aAAaU,GAAG,CAACiB;oBACnC,IAAIG,aAAaA,cAAcD,OAAOf,EAAE,EAAE;wBACtC,IAAI,CAACiB,IAAI,CACL,CAAC,kBAAkB,EAAEJ,UAAU,6FAA6F,CAAC;oBAErI,OAAO;wBACH3B,aAAagC,GAAG,CAACL,WAAWE,OAAOf,EAAE;oBACzC;oBACAhB,WAAWkC,GAAG,CAACH,OAAOf,EAAE,EAAEa;gBAC9B;YACJ;QACJ;IACJ;AACJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/vite/plugins/metadata-plugin.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\nimport type { Plugin } from 'vite';\nimport { BuildContext, generateMetadata } from '../../core';\nimport { getCssFileNames } from './utils';\n\nexport function metadataPlugin(context: BuildContext): Plugin | undefined {\n if (!context.package.isWebComponent) {\n return;\n }\n\n let outDir = '';\n\n return {\n name: 'metadata',\n configResolved(config) {\n outDir = config.build.outDir;\n },\n configureServer(server) {\n server.httpServer?.once('listening', () => {\n const address = server.httpServer?.address();\n if (!address || typeof address === 'string') {\n return;\n }\n\n const entrypoints = {\n module: true,\n port: address.port,\n css: [],\n js: ['@vite/client', '@id/__x00__VIRTUAL./index'],\n };\n\n const entrypointsPath = path.join(outDir, 'entrypoints.json');\n fs.mkdirSync(path.dirname(entrypointsPath), { recursive: true });\n fs.writeFileSync(entrypointsPath, JSON.stringify(entrypoints, null, 2));\n\n generateMetadata(context);\n });\n },\n writeBundle(options, bundle) {\n if (!options.dir) {\n throw new Error(\n 'web-component build requires output.dir — output.file is not supported'\n );\n }\n\n const js: string[] = [];\n\n for (const chunk of Object.values(bundle)) {\n if (chunk.type === 'chunk' && chunk.isEntry) {\n js.push(chunk.fileName);\n }\n }\n\n const css = getCssFileNames(bundle);\n\n fs.writeFileSync(\n path.join(options.dir, 'entrypoints.json'),\n JSON.stringify({ module: true, css, js }, null, 2)\n );\n\n generateMetadata(context);\n },\n };\n}\n"],"names":["metadataPlugin","context","package","isWebComponent","outDir","name","configResolved","config","build","configureServer","server","httpServer","once","address","entrypoints","module","port","css","js","entrypointsPath","path","join","fs","mkdirSync","dirname","recursive","writeFileSync","JSON","stringify","generateMetadata","writeBundle","options","bundle","dir","Error","chunk","Object","values","type","isEntry","push","fileName","getCssFileNames"],"mappings":";;;;+BAMgBA;;;eAAAA;;;2DAND;6DACE;sBAE8B;uBACf;;;;;;AAEzB,SAASA,eAAeC,OAAqB;IAChD,IAAI,CAACA,QAAQC,OAAO,CAACC,cAAc,EAAE;QACjC;IACJ;IAEA,IAAIC,SAAS;IAEb,OAAO;QACHC,MAAM;QACNC,gBAAeC,MAAM;YACjBH,SAASG,OAAOC,KAAK,CAACJ,MAAM;QAChC;QACAK,iBAAgBC,MAAM;gBAClBA;aAAAA,qBAAAA,OAAOC,UAAU,cAAjBD,yCAAAA,mBAAmBE,IAAI,CAAC,aAAa;oBACjBF;gBAAhB,MAAMG,WAAUH,qBAAAA,OAAOC,UAAU,cAAjBD,yCAAAA,mBAAmBG,OAAO;gBAC1C,IAAI,CAACA,WAAW,OAAOA,YAAY,UAAU;oBACzC;gBACJ;gBAEA,MAAMC,cAAc;oBAChBC,QAAQ;oBACRC,MAAMH,QAAQG,IAAI;oBAClBC,KAAK,EAAE;oBACPC,IAAI;wBAAC;wBAAgB;qBAA4B;gBACrD;gBAEA,MAAMC,kBAAkBC,aAAI,CAACC,IAAI,CAACjB,QAAQ;gBAC1CkB,WAAE,CAACC,SAAS,CAACH,aAAI,CAACI,OAAO,CAACL,kBAAkB;oBAAEM,WAAW;gBAAK;gBAC9DH,WAAE,CAACI,aAAa,CAACP,iBAAiBQ,KAAKC,SAAS,CAACd,aAAa,MAAM;gBAEpEe,IAAAA,sBAAgB,EAAC5B;YACrB;QACJ;QACA6B,aAAYC,OAAO,EAAEC,MAAM;YACvB,IAAI,CAACD,QAAQE,GAAG,EAAE;gBACd,MAAM,IAAIC,MACN;YAER;YAEA,MAAMhB,KAAe,EAAE;YAEvB,KAAK,MAAMiB,SAASC,OAAOC,MAAM,CAACL,QAAS;gBACvC,IAAIG,MAAMG,IAAI,KAAK,WAAWH,MAAMI,OAAO,EAAE;oBACzCrB,GAAGsB,IAAI,CAACL,MAAMM,QAAQ;gBAC1B;YACJ;YAEA,MAAMxB,MAAMyB,IAAAA,sBAAe,EAACV;YAE5BV,WAAE,CAACI,aAAa,CACZN,aAAI,CAACC,IAAI,CAACU,QAAQE,GAAG,EAAE,qBACvBN,KAAKC,SAAS,CAAC;gBAAEb,QAAQ;gBAAME;gBAAKC;YAAG,GAAG,MAAM;YAGpDW,IAAAA,sBAAgB,EAAC5B;QACrB;IACJ;AACJ"}
|
|
1
|
+
{"version":3,"sources":["../../../src/vite/plugins/metadata-plugin.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\nimport type { Plugin } from 'vite';\nimport { BuildContext, generateMetadata } from '../../core';\nimport { getCssFileNames } from './utils';\n\nexport function metadataPlugin(context: BuildContext): Plugin | undefined {\n if (!context.package.isWebComponent) {\n return;\n }\n\n let outDir = '';\n\n return {\n name: 'st:metadata',\n configResolved(config) {\n outDir = config.build.outDir;\n },\n configureServer(server) {\n server.httpServer?.once('listening', () => {\n const address = server.httpServer?.address();\n if (!address || typeof address === 'string') {\n return;\n }\n\n const entrypoints = {\n module: true,\n port: address.port,\n css: [],\n js: ['@vite/client', '@id/__x00__VIRTUAL./index'],\n };\n\n const entrypointsPath = path.join(outDir, 'entrypoints.json');\n fs.mkdirSync(path.dirname(entrypointsPath), { recursive: true });\n fs.writeFileSync(entrypointsPath, JSON.stringify(entrypoints, null, 2));\n\n generateMetadata(context);\n });\n },\n writeBundle(options, bundle) {\n if (!options.dir) {\n throw new Error(\n 'web-component build requires output.dir — output.file is not supported'\n );\n }\n\n const js: string[] = [];\n\n for (const chunk of Object.values(bundle)) {\n if (chunk.type === 'chunk' && chunk.isEntry) {\n js.push(chunk.fileName);\n }\n }\n\n const css = getCssFileNames(bundle);\n\n fs.writeFileSync(\n path.join(options.dir, 'entrypoints.json'),\n JSON.stringify({ module: true, css, js }, null, 2)\n );\n\n generateMetadata(context);\n },\n };\n}\n"],"names":["metadataPlugin","context","package","isWebComponent","outDir","name","configResolved","config","build","configureServer","server","httpServer","once","address","entrypoints","module","port","css","js","entrypointsPath","path","join","fs","mkdirSync","dirname","recursive","writeFileSync","JSON","stringify","generateMetadata","writeBundle","options","bundle","dir","Error","chunk","Object","values","type","isEntry","push","fileName","getCssFileNames"],"mappings":";;;;+BAMgBA;;;eAAAA;;;2DAND;6DACE;sBAE8B;uBACf;;;;;;AAEzB,SAASA,eAAeC,OAAqB;IAChD,IAAI,CAACA,QAAQC,OAAO,CAACC,cAAc,EAAE;QACjC;IACJ;IAEA,IAAIC,SAAS;IAEb,OAAO;QACHC,MAAM;QACNC,gBAAeC,MAAM;YACjBH,SAASG,OAAOC,KAAK,CAACJ,MAAM;QAChC;QACAK,iBAAgBC,MAAM;gBAClBA;aAAAA,qBAAAA,OAAOC,UAAU,cAAjBD,yCAAAA,mBAAmBE,IAAI,CAAC,aAAa;oBACjBF;gBAAhB,MAAMG,WAAUH,qBAAAA,OAAOC,UAAU,cAAjBD,yCAAAA,mBAAmBG,OAAO;gBAC1C,IAAI,CAACA,WAAW,OAAOA,YAAY,UAAU;oBACzC;gBACJ;gBAEA,MAAMC,cAAc;oBAChBC,QAAQ;oBACRC,MAAMH,QAAQG,IAAI;oBAClBC,KAAK,EAAE;oBACPC,IAAI;wBAAC;wBAAgB;qBAA4B;gBACrD;gBAEA,MAAMC,kBAAkBC,aAAI,CAACC,IAAI,CAACjB,QAAQ;gBAC1CkB,WAAE,CAACC,SAAS,CAACH,aAAI,CAACI,OAAO,CAACL,kBAAkB;oBAAEM,WAAW;gBAAK;gBAC9DH,WAAE,CAACI,aAAa,CAACP,iBAAiBQ,KAAKC,SAAS,CAACd,aAAa,MAAM;gBAEpEe,IAAAA,sBAAgB,EAAC5B;YACrB;QACJ;QACA6B,aAAYC,OAAO,EAAEC,MAAM;YACvB,IAAI,CAACD,QAAQE,GAAG,EAAE;gBACd,MAAM,IAAIC,MACN;YAER;YAEA,MAAMhB,KAAe,EAAE;YAEvB,KAAK,MAAMiB,SAASC,OAAOC,MAAM,CAACL,QAAS;gBACvC,IAAIG,MAAMG,IAAI,KAAK,WAAWH,MAAMI,OAAO,EAAE;oBACzCrB,GAAGsB,IAAI,CAACL,MAAMM,QAAQ;gBAC1B;YACJ;YAEA,MAAMxB,MAAMyB,IAAAA,sBAAe,EAACV;YAE5BV,WAAE,CAACI,aAAa,CACZN,aAAI,CAACC,IAAI,CAACU,QAAQE,GAAG,EAAE,qBACvBN,KAAKC,SAAS,CAAC;gBAAEb,QAAQ;gBAAME;gBAAKC;YAAG,GAAG,MAAM;YAGpDW,IAAAA,sBAAgB,EAAC5B;QACrB;IACJ;AACJ"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Plugin } from 'vite';
|
|
2
2
|
import { BuildContext } from '../../core';
|
|
3
|
-
export declare const VIRTUAL_MOMENT = "\
|
|
3
|
+
export declare const VIRTUAL_MOMENT = "\0moment-locales";
|
|
4
4
|
export declare function momentLocalesPlugin(_context: BuildContext): Plugin;
|
|
5
5
|
//# sourceMappingURL=moment-locales-plugin.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"moment-locales-plugin.d.ts","sourceRoot":"","sources":["../../../src/vite/plugins/moment-locales-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AACnC,OAAO,EAAE,YAAY,EAAkB,MAAM,YAAY,CAAC;AAE1D,eAAO,MAAM,cAAc,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"moment-locales-plugin.d.ts","sourceRoot":"","sources":["../../../src/vite/plugins/moment-locales-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AACnC,OAAO,EAAE,YAAY,EAAkB,MAAM,YAAY,CAAC;AAE1D,eAAO,MAAM,cAAc,qBAAqB,CAAC;AAajD,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,YAAY,GAAG,MAAM,CAkClE"}
|
|
@@ -17,30 +17,46 @@ _export(exports, {
|
|
|
17
17
|
}
|
|
18
18
|
});
|
|
19
19
|
const _core = require("../../core");
|
|
20
|
-
const VIRTUAL_MOMENT = '\
|
|
20
|
+
const VIRTUAL_MOMENT = '\0moment-locales';
|
|
21
|
+
const VIRTUAL_ID_PATTERN = new RegExp(`^${VIRTUAL_MOMENT}`);
|
|
21
22
|
const UMD_LOCALE = /^moment\/locale\/(.+)$/;
|
|
22
23
|
function momentLocalesPlugin(_context) {
|
|
23
24
|
return {
|
|
24
|
-
name: 'moment-locales',
|
|
25
|
+
name: 'st:moment-locales',
|
|
25
26
|
enforce: 'pre',
|
|
26
|
-
resolveId
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
27
|
+
resolveId: {
|
|
28
|
+
filter: {
|
|
29
|
+
id: [
|
|
30
|
+
/^moment$/,
|
|
31
|
+
UMD_LOCALE
|
|
32
|
+
]
|
|
33
|
+
},
|
|
34
|
+
handler (source, importer, options) {
|
|
35
|
+
var _UMD_LOCALE_exec;
|
|
36
|
+
if (source === 'moment') {
|
|
37
|
+
return VIRTUAL_MOMENT;
|
|
38
|
+
}
|
|
39
|
+
// Redirect explicit UMD locale imports to the ESM build so they share that instance.
|
|
40
|
+
const locale = (_UMD_LOCALE_exec = UMD_LOCALE.exec(source)) === null || _UMD_LOCALE_exec === void 0 ? void 0 : _UMD_LOCALE_exec[1];
|
|
41
|
+
if (locale) {
|
|
42
|
+
return this.resolve(`moment/dist/locale/${locale}`, importer, options);
|
|
43
|
+
}
|
|
35
44
|
}
|
|
36
45
|
},
|
|
37
|
-
load
|
|
38
|
-
|
|
46
|
+
load: {
|
|
47
|
+
filter: {
|
|
48
|
+
id: VIRTUAL_ID_PATTERN
|
|
49
|
+
},
|
|
50
|
+
handler () {
|
|
39
51
|
return [
|
|
40
52
|
..._core.MOMENT_LOCALES.map((locale)=>`import 'moment/dist/locale/${locale}';`),
|
|
41
53
|
`import moment from 'moment/dist/moment.js';`,
|
|
42
54
|
`export * from 'moment/dist/moment.js';`,
|
|
43
|
-
`export default moment
|
|
55
|
+
`export default moment;`,
|
|
56
|
+
/*
|
|
57
|
+
* moment attaches these to the function itself rather than declaring them as
|
|
58
|
+
* real ES named exports, so `export *` above doesn't forward them.
|
|
59
|
+
*/ `export const isMoment = moment.isMoment;`
|
|
44
60
|
].join('\n');
|
|
45
61
|
}
|
|
46
62
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/vite/plugins/moment-locales-plugin.ts"],"sourcesContent":["import type { Plugin } from 'vite';\nimport { BuildContext, MOMENT_LOCALES } from '../../core';\n\nexport const VIRTUAL_MOMENT = '\\
|
|
1
|
+
{"version":3,"sources":["../../../src/vite/plugins/moment-locales-plugin.ts"],"sourcesContent":["import type { Plugin } from 'vite';\nimport { BuildContext, MOMENT_LOCALES } from '../../core';\n\nexport const VIRTUAL_MOMENT = '\\0moment-locales';\nconst VIRTUAL_ID_PATTERN = new RegExp(`^${VIRTUAL_MOMENT}`);\n\nconst UMD_LOCALE = /^moment\\/locale\\/(.+)$/;\n\n/*\n * Statically bundle the supported moment locales for parity with webpack's\n * MomentLocalesPlugin. We need this because moment loads locales via a dynamic\n * require that, with Rolldown, never loads.\n *\n * Resolve everything through moment/dist (the ESM build) else Rolldown creates\n * a separate UMD instance from what the app uses.\n */\nexport function momentLocalesPlugin(_context: BuildContext): Plugin {\n return {\n name: 'st:moment-locales',\n enforce: 'pre',\n resolveId: {\n filter: { id: [/^moment$/, UMD_LOCALE] },\n handler(source, importer, options) {\n if (source === 'moment') {\n return VIRTUAL_MOMENT;\n }\n // Redirect explicit UMD locale imports to the ESM build so they share that instance.\n const locale = UMD_LOCALE.exec(source)?.[1];\n if (locale) {\n return this.resolve(`moment/dist/locale/${locale}`, importer, options);\n }\n },\n },\n load: {\n filter: { id: VIRTUAL_ID_PATTERN },\n handler() {\n return [\n ...MOMENT_LOCALES.map(locale => `import 'moment/dist/locale/${locale}';`),\n `import moment from 'moment/dist/moment.js';`,\n `export * from 'moment/dist/moment.js';`,\n `export default moment;`,\n /*\n * moment attaches these to the function itself rather than declaring them as\n * real ES named exports, so `export *` above doesn't forward them.\n */\n `export const isMoment = moment.isMoment;`,\n ].join('\\n');\n },\n },\n };\n}\n"],"names":["VIRTUAL_MOMENT","momentLocalesPlugin","VIRTUAL_ID_PATTERN","RegExp","UMD_LOCALE","_context","name","enforce","resolveId","filter","id","handler","source","importer","options","locale","exec","resolve","load","MOMENT_LOCALES","map","join"],"mappings":";;;;;;;;;;;QAGaA;eAAAA;;QAaGC;eAAAA;;;sBAf6B;AAEtC,MAAMD,iBAAiB;AAC9B,MAAME,qBAAqB,IAAIC,OAAO,CAAC,CAAC,EAAEH,gBAAgB;AAE1D,MAAMI,aAAa;AAUZ,SAASH,oBAAoBI,QAAsB;IACtD,OAAO;QACHC,MAAM;QACNC,SAAS;QACTC,WAAW;YACPC,QAAQ;gBAAEC,IAAI;oBAAC;oBAAYN;iBAAW;YAAC;YACvCO,SAAQC,MAAM,EAAEC,QAAQ,EAAEC,OAAO;oBAKdV;gBAJf,IAAIQ,WAAW,UAAU;oBACrB,OAAOZ;gBACX;gBACA,qFAAqF;gBACrF,MAAMe,UAASX,mBAAAA,WAAWY,IAAI,CAACJ,qBAAhBR,uCAAAA,gBAAyB,CAAC,EAAE;gBAC3C,IAAIW,QAAQ;oBACR,OAAO,IAAI,CAACE,OAAO,CAAC,CAAC,mBAAmB,EAAEF,QAAQ,EAAEF,UAAUC;gBAClE;YACJ;QACJ;QACAI,MAAM;YACFT,QAAQ;gBAAEC,IAAIR;YAAmB;YACjCS;gBACI,OAAO;uBACAQ,oBAAc,CAACC,GAAG,CAACL,CAAAA,SAAU,CAAC,2BAA2B,EAAEA,OAAO,EAAE,CAAC;oBACxE,CAAC,2CAA2C,CAAC;oBAC7C,CAAC,sCAAsC,CAAC;oBACxC,CAAC,sBAAsB,CAAC;oBACxB;;;qBAGC,GACD,CAAC,wCAAwC,CAAC;iBAC7C,CAACM,IAAI,CAAC;YACX;QACJ;IACJ;AACJ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/vite/plugins/react-refresh-plugin/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
_export_star(require("./react-refresh-plugin"), exports);
|
|
6
|
+
function _export_star(from, to) {
|
|
7
|
+
Object.keys(from).forEach(function(k) {
|
|
8
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
9
|
+
Object.defineProperty(to, k, {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function() {
|
|
12
|
+
return from[k];
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
return from;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/vite/plugins/react-refresh-plugin/index.ts"],"sourcesContent":["export * from './react-refresh-plugin';\n"],"names":[],"mappings":";;;;qBAAc"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react-refresh-plugin.d.ts","sourceRoot":"","sources":["../../../../src/vite/plugins/react-refresh-plugin/react-refresh-plugin.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AACnC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAuElD,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,YAAY,GAAG,MAAM,GAAG,SAAS,CAoE5E"}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "reactRefreshPlugin", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return reactRefreshPlugin;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
|
|
12
|
+
const _magicstring = /*#__PURE__*/ _interop_require_default(require("magic-string"));
|
|
13
|
+
const _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
14
|
+
const _utils = require("../../../utils");
|
|
15
|
+
function _interop_require_default(obj) {
|
|
16
|
+
return obj && obj.__esModule ? obj : {
|
|
17
|
+
default: obj
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
const RUNTIME_ID = '/@react-refresh';
|
|
21
|
+
const RUNTIME_HELPERS_PATH = _path.default.join(__dirname, 'refresh-runtime.js');
|
|
22
|
+
/* Triggers injectIntoGlobalHook (via the virtual module's side effect) before app code executes. */ const preamble = `import "${RUNTIME_ID}";`;
|
|
23
|
+
/*
|
|
24
|
+
* Per-module locals satisfy swc's $RefreshReg$/$RefreshSig$ calls without relying on
|
|
25
|
+
* window globals. Scoping the registration id to the served module URL ensures host and
|
|
26
|
+
* MFE servers sharing one runtime singleton cannot produce colliding refresh families.
|
|
27
|
+
*/ const modulePrelude = `import RefreshRuntime from "${RUNTIME_ID}";
|
|
28
|
+
const __react_refresh_id__ = import.meta.url.replace(/[?#].*$/, "");
|
|
29
|
+
var $RefreshReg$ = (type, id) => RefreshRuntime.register(type, __react_refresh_id__ + " " + id);
|
|
30
|
+
var $RefreshSig$ = () => RefreshRuntime.createSignatureFunctionForTransform();\n`;
|
|
31
|
+
/* Makes refreshable modules self-accepting and runs React Fast Refresh after safe updates. */ const postlude = `
|
|
32
|
+
import {
|
|
33
|
+
__hmr_import,
|
|
34
|
+
registerExportsForReactRefresh,
|
|
35
|
+
validateRefreshBoundaryAndEnqueueUpdate,
|
|
36
|
+
} from "${RUNTIME_ID}";
|
|
37
|
+
if (import.meta.hot) {
|
|
38
|
+
__hmr_import(__react_refresh_id__).then(currentExports => {
|
|
39
|
+
registerExportsForReactRefresh(__react_refresh_id__, currentExports);
|
|
40
|
+
import.meta.hot.accept(nextExports => {
|
|
41
|
+
if (!nextExports) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const invalidateMessage = validateRefreshBoundaryAndEnqueueUpdate(
|
|
46
|
+
__react_refresh_id__,
|
|
47
|
+
currentExports,
|
|
48
|
+
nextExports
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
if (invalidateMessage) {
|
|
52
|
+
import.meta.hot.invalidate(invalidateMessage);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
}`;
|
|
57
|
+
function transformWithSourceMap(source, id) {
|
|
58
|
+
return {
|
|
59
|
+
code: source.toString(),
|
|
60
|
+
map: source.generateMap({
|
|
61
|
+
hires: true,
|
|
62
|
+
source: id
|
|
63
|
+
})
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
function normalizeSlashes(filePath) {
|
|
67
|
+
return filePath.replaceAll('\\', '/');
|
|
68
|
+
}
|
|
69
|
+
function getRefreshRuntimeCode() {
|
|
70
|
+
return `\
|
|
71
|
+
import _RefreshRuntime from "react-refresh/runtime";
|
|
72
|
+
const RefreshRuntime = window.__ReactRefreshRuntime || _RefreshRuntime;
|
|
73
|
+
if (!window.__ReactRefreshRuntime) {
|
|
74
|
+
_RefreshRuntime.injectIntoGlobalHook(window);
|
|
75
|
+
}
|
|
76
|
+
window.__ReactRefreshRuntime = RefreshRuntime;
|
|
77
|
+
${_fs.default.readFileSync(RUNTIME_HELPERS_PATH, 'utf8')}
|
|
78
|
+
export default RefreshRuntime;`;
|
|
79
|
+
}
|
|
80
|
+
function reactRefreshPlugin(context) {
|
|
81
|
+
if (context.build.isProduction) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
const refreshableModuleDirs = (0, _utils.findPackages)().map(({ location })=>normalizeSlashes(location) + '/');
|
|
85
|
+
return {
|
|
86
|
+
name: 'react-refresh',
|
|
87
|
+
enforce: 'pre',
|
|
88
|
+
/* Serve react-refresh/runtime as an ESM virtual module. */ resolveId (source) {
|
|
89
|
+
if (source === RUNTIME_ID) {
|
|
90
|
+
return {
|
|
91
|
+
id: RUNTIME_ID,
|
|
92
|
+
moduleSideEffects: true
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
load (id) {
|
|
97
|
+
if (id === RUNTIME_ID) {
|
|
98
|
+
return {
|
|
99
|
+
code: getRefreshRuntimeCode()
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
/* Inject the preamble before React and app code load. */ transformIndexHtml () {
|
|
104
|
+
return [
|
|
105
|
+
{
|
|
106
|
+
tag: 'script',
|
|
107
|
+
attrs: {
|
|
108
|
+
type: 'module'
|
|
109
|
+
},
|
|
110
|
+
children: preamble,
|
|
111
|
+
injectTo: 'head-prepend'
|
|
112
|
+
}
|
|
113
|
+
];
|
|
114
|
+
},
|
|
115
|
+
/* Handle modules compiled with swc refresh markers. */ transform: {
|
|
116
|
+
filter: {
|
|
117
|
+
code: /\$RefreshReg\$|\$RefreshSig\$/
|
|
118
|
+
},
|
|
119
|
+
handler (code, id) {
|
|
120
|
+
const normalizedId = normalizeSlashes(id);
|
|
121
|
+
const isRefreshableModule = refreshableModuleDirs.some((dir)=>normalizedId.startsWith(dir));
|
|
122
|
+
/* Prevent non-workspace libraries from registering duplicate refresh families. */ if (!isRefreshableModule) {
|
|
123
|
+
const source = new _magicstring.default(code);
|
|
124
|
+
const noopPreamble = 'var $RefreshReg$ = () => {};\nvar $RefreshSig$ = () => (t) => t;\n';
|
|
125
|
+
source.prepend(noopPreamble);
|
|
126
|
+
return transformWithSourceMap(source, id);
|
|
127
|
+
}
|
|
128
|
+
/*
|
|
129
|
+
* Workspace modules always get per-module refresh locals. This satisfies
|
|
130
|
+
* $RefreshSig$ calls in HOC-wrapped modules without relying on window globals.
|
|
131
|
+
* Modules with registered component families additionally get an HMR postlude.
|
|
132
|
+
*/ const source = new _magicstring.default(code);
|
|
133
|
+
source.prepend(modulePrelude);
|
|
134
|
+
if (code.includes('$RefreshReg$')) {
|
|
135
|
+
source.append(postlude);
|
|
136
|
+
}
|
|
137
|
+
return transformWithSourceMap(source, id);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
//# sourceMappingURL=react-refresh-plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/vite/plugins/react-refresh-plugin/react-refresh-plugin.ts"],"sourcesContent":["import fs from 'fs';\nimport MagicString from 'magic-string';\nimport path from 'path';\nimport type { Plugin } from 'vite';\nimport type { BuildContext } from '../../../core';\nimport { findPackages } from '../../../utils';\n\nconst RUNTIME_ID = '/@react-refresh';\nconst RUNTIME_HELPERS_PATH = path.join(__dirname, 'refresh-runtime.js');\n\n/* Triggers injectIntoGlobalHook (via the virtual module's side effect) before app code executes. */\nconst preamble = `import \"${RUNTIME_ID}\";`;\n\n/*\n * Per-module locals satisfy swc's $RefreshReg$/$RefreshSig$ calls without relying on\n * window globals. Scoping the registration id to the served module URL ensures host and\n * MFE servers sharing one runtime singleton cannot produce colliding refresh families.\n */\nconst modulePrelude = `import RefreshRuntime from \"${RUNTIME_ID}\";\nconst __react_refresh_id__ = import.meta.url.replace(/[?#].*$/, \"\");\nvar $RefreshReg$ = (type, id) => RefreshRuntime.register(type, __react_refresh_id__ + \" \" + id);\nvar $RefreshSig$ = () => RefreshRuntime.createSignatureFunctionForTransform();\\n`;\n\n/* Makes refreshable modules self-accepting and runs React Fast Refresh after safe updates. */\nconst postlude = `\nimport {\n __hmr_import,\n registerExportsForReactRefresh,\n validateRefreshBoundaryAndEnqueueUpdate,\n} from \"${RUNTIME_ID}\";\nif (import.meta.hot) {\n __hmr_import(__react_refresh_id__).then(currentExports => {\n registerExportsForReactRefresh(__react_refresh_id__, currentExports);\n import.meta.hot.accept(nextExports => {\n if (!nextExports) {\n return;\n }\n\n const invalidateMessage = validateRefreshBoundaryAndEnqueueUpdate(\n __react_refresh_id__,\n currentExports,\n nextExports\n );\n\n if (invalidateMessage) {\n import.meta.hot.invalidate(invalidateMessage);\n }\n });\n });\n}`;\n\nfunction transformWithSourceMap(source: MagicString, id: string) {\n return {\n code: source.toString(),\n map: source.generateMap({ hires: true, source: id }),\n };\n}\n\nfunction normalizeSlashes(filePath: string) {\n return filePath.replaceAll('\\\\', '/');\n}\n\nfunction getRefreshRuntimeCode() {\n return `\\\nimport _RefreshRuntime from \"react-refresh/runtime\";\nconst RefreshRuntime = window.__ReactRefreshRuntime || _RefreshRuntime;\nif (!window.__ReactRefreshRuntime) {\n _RefreshRuntime.injectIntoGlobalHook(window);\n}\nwindow.__ReactRefreshRuntime = RefreshRuntime;\n${fs.readFileSync(RUNTIME_HELPERS_PATH, 'utf8')}\nexport default RefreshRuntime;`;\n}\n\n/* Bridges swc's refresh markers to Vite HMR and the React Fast Refresh runtime. */\nexport function reactRefreshPlugin(context: BuildContext): Plugin | undefined {\n if (context.build.isProduction) {\n return;\n }\n\n const refreshableModuleDirs = findPackages().map(\n ({ location }) => normalizeSlashes(location) + '/'\n );\n\n return {\n name: 'react-refresh',\n enforce: 'pre',\n /* Serve react-refresh/runtime as an ESM virtual module. */\n resolveId(source) {\n if (source === RUNTIME_ID) {\n return { id: RUNTIME_ID, moduleSideEffects: true };\n }\n },\n load(id) {\n if (id === RUNTIME_ID) {\n return { code: getRefreshRuntimeCode() };\n }\n },\n /* Inject the preamble before React and app code load. */\n transformIndexHtml() {\n return [\n {\n tag: 'script',\n attrs: { type: 'module' },\n children: preamble,\n injectTo: 'head-prepend',\n },\n ];\n },\n /* Handle modules compiled with swc refresh markers. */\n transform: {\n filter: { code: /\\$RefreshReg\\$|\\$RefreshSig\\$/ },\n handler(code, id) {\n const normalizedId = normalizeSlashes(id);\n const isRefreshableModule = refreshableModuleDirs.some(dir =>\n normalizedId.startsWith(dir)\n );\n\n /* Prevent non-workspace libraries from registering duplicate refresh families. */\n if (!isRefreshableModule) {\n const source = new MagicString(code);\n const noopPreamble =\n 'var $RefreshReg$ = () => {};\\nvar $RefreshSig$ = () => (t) => t;\\n';\n source.prepend(noopPreamble);\n return transformWithSourceMap(source, id);\n }\n\n /*\n * Workspace modules always get per-module refresh locals. This satisfies\n * $RefreshSig$ calls in HOC-wrapped modules without relying on window globals.\n * Modules with registered component families additionally get an HMR postlude.\n */\n const source = new MagicString(code);\n source.prepend(modulePrelude);\n\n if (code.includes('$RefreshReg$')) {\n source.append(postlude);\n }\n\n return transformWithSourceMap(source, id);\n },\n },\n };\n}\n"],"names":["reactRefreshPlugin","RUNTIME_ID","RUNTIME_HELPERS_PATH","path","join","__dirname","preamble","modulePrelude","postlude","transformWithSourceMap","source","id","code","toString","map","generateMap","hires","normalizeSlashes","filePath","replaceAll","getRefreshRuntimeCode","fs","readFileSync","context","build","isProduction","refreshableModuleDirs","findPackages","location","name","enforce","resolveId","moduleSideEffects","load","transformIndexHtml","tag","attrs","type","children","injectTo","transform","filter","handler","normalizedId","isRefreshableModule","some","dir","startsWith","MagicString","noopPreamble","prepend","includes","append"],"mappings":";;;;+BA2EgBA;;;eAAAA;;;2DA3ED;oEACS;6DACP;uBAGY;;;;;;AAE7B,MAAMC,aAAa;AACnB,MAAMC,uBAAuBC,aAAI,CAACC,IAAI,CAACC,WAAW;AAElD,kGAAkG,GAClG,MAAMC,WAAW,CAAC,QAAQ,EAAEL,WAAW,EAAE,CAAC;AAE1C;;;;CAIC,GACD,MAAMM,gBAAgB,CAAC,4BAA4B,EAAEN,WAAW;;;gFAGgB,CAAC;AAEjF,4FAA4F,GAC5F,MAAMO,WAAW,CAAC;;;;;QAKV,EAAEP,WAAW;;;;;;;;;;;;;;;;;;;;CAoBpB,CAAC;AAEF,SAASQ,uBAAuBC,MAAmB,EAAEC,EAAU;IAC3D,OAAO;QACHC,MAAMF,OAAOG,QAAQ;QACrBC,KAAKJ,OAAOK,WAAW,CAAC;YAAEC,OAAO;YAAMN,QAAQC;QAAG;IACtD;AACJ;AAEA,SAASM,iBAAiBC,QAAgB;IACtC,OAAOA,SAASC,UAAU,CAAC,MAAM;AACrC;AAEA,SAASC;IACL,OAAO,CAAC;;;;;;;AAOZ,EAAEC,WAAE,CAACC,YAAY,CAACpB,sBAAsB,QAAQ;8BAClB,CAAC;AAC/B;AAGO,SAASF,mBAAmBuB,OAAqB;IACpD,IAAIA,QAAQC,KAAK,CAACC,YAAY,EAAE;QAC5B;IACJ;IAEA,MAAMC,wBAAwBC,IAAAA,mBAAY,IAAGb,GAAG,CAC5C,CAAC,EAAEc,QAAQ,EAAE,GAAKX,iBAAiBW,YAAY;IAGnD,OAAO;QACHC,MAAM;QACNC,SAAS;QACT,yDAAyD,GACzDC,WAAUrB,MAAM;YACZ,IAAIA,WAAWT,YAAY;gBACvB,OAAO;oBAAEU,IAAIV;oBAAY+B,mBAAmB;gBAAK;YACrD;QACJ;QACAC,MAAKtB,EAAE;YACH,IAAIA,OAAOV,YAAY;gBACnB,OAAO;oBAAEW,MAAMQ;gBAAwB;YAC3C;QACJ;QACA,uDAAuD,GACvDc;YACI,OAAO;gBACH;oBACIC,KAAK;oBACLC,OAAO;wBAAEC,MAAM;oBAAS;oBACxBC,UAAUhC;oBACViC,UAAU;gBACd;aACH;QACL;QACA,qDAAqD,GACrDC,WAAW;YACPC,QAAQ;gBAAE7B,MAAM;YAAgC;YAChD8B,SAAQ9B,IAAI,EAAED,EAAE;gBACZ,MAAMgC,eAAe1B,iBAAiBN;gBACtC,MAAMiC,sBAAsBlB,sBAAsBmB,IAAI,CAACC,CAAAA,MACnDH,aAAaI,UAAU,CAACD;gBAG5B,gFAAgF,GAChF,IAAI,CAACF,qBAAqB;oBACtB,MAAMlC,SAAS,IAAIsC,oBAAW,CAACpC;oBAC/B,MAAMqC,eACF;oBACJvC,OAAOwC,OAAO,CAACD;oBACf,OAAOxC,uBAAuBC,QAAQC;gBAC1C;gBAEA;;;;iBAIC,GACD,MAAMD,SAAS,IAAIsC,oBAAW,CAACpC;gBAC/BF,OAAOwC,OAAO,CAAC3C;gBAEf,IAAIK,KAAKuC,QAAQ,CAAC,iBAAiB;oBAC/BzC,OAAO0C,MAAM,CAAC5C;gBAClB;gBAEA,OAAOC,uBAAuBC,QAAQC;YAC1C;QACJ;IACJ;AACJ"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* MIT License
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2019-present, Yuxi (Evan) You and Vite contributors
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
/*
|
|
26
|
+
* Adapted from https://github.com/vitejs/vite-plugin-react/blob/84693214ef8cccc3357561fe4654f401a30dab62/packages/common/refresh-runtime.js.
|
|
27
|
+
* Keep this local because the helpers are bundled into that plugin's virtual
|
|
28
|
+
* runtime and are not exposed as stable public package exports.
|
|
29
|
+
*
|
|
30
|
+
* This file is served inside the browser-only /@react-refresh virtual module.
|
|
31
|
+
* It relies on that module storing the runtime on window.__ReactRefreshRuntime.
|
|
32
|
+
*/
|
|
33
|
+
const refreshCallbacks = [];
|
|
34
|
+
|
|
35
|
+
function getRefreshRuntime() {
|
|
36
|
+
return window.__ReactRefreshRuntime;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Hook for integrations to finish async work before the debounced refresh flush.
|
|
40
|
+
window.__registerBeforePerformReactRefresh = callback => {
|
|
41
|
+
refreshCallbacks.push(callback);
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
function debounce(fn, delay) {
|
|
45
|
+
let handle;
|
|
46
|
+
return () => {
|
|
47
|
+
clearTimeout(handle);
|
|
48
|
+
handle = setTimeout(fn, delay);
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const enqueueUpdate = debounce(async () => {
|
|
53
|
+
if (refreshCallbacks.length) {
|
|
54
|
+
await Promise.all(refreshCallbacks.map(callback => callback()));
|
|
55
|
+
}
|
|
56
|
+
getRefreshRuntime().performReactRefresh();
|
|
57
|
+
}, 16);
|
|
58
|
+
|
|
59
|
+
function predicateOnExport(moduleExports, predicate) {
|
|
60
|
+
for (const key in moduleExports) {
|
|
61
|
+
if (key === '__esModule') {
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
const descriptor = Object.getOwnPropertyDescriptor(moduleExports, key);
|
|
65
|
+
if (descriptor?.get) {
|
|
66
|
+
return key;
|
|
67
|
+
}
|
|
68
|
+
if (!predicate(key, moduleExports[key])) {
|
|
69
|
+
return key;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return true;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export function registerExportsForReactRefresh(id, moduleExports) {
|
|
76
|
+
for (const key in moduleExports) {
|
|
77
|
+
if (key === '__esModule') {
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
const exportValue = moduleExports[key];
|
|
81
|
+
if (getRefreshRuntime().isLikelyComponentType(exportValue)) {
|
|
82
|
+
getRefreshRuntime().register(exportValue, `${id} export ${key}`);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export function validateRefreshBoundaryAndEnqueueUpdate(id, prevExports, nextExports) {
|
|
88
|
+
if (predicateOnExport(prevExports, key => key in nextExports) !== true) {
|
|
89
|
+
return 'Could not Fast Refresh (export removed)';
|
|
90
|
+
}
|
|
91
|
+
if (predicateOnExport(nextExports, key => key in prevExports) !== true) {
|
|
92
|
+
return 'Could not Fast Refresh (new export)';
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
let hasExports = false;
|
|
96
|
+
const allExportsAreComponentsOrUnchanged = predicateOnExport(nextExports, (key, value) => {
|
|
97
|
+
hasExports = true;
|
|
98
|
+
if (getRefreshRuntime().isLikelyComponentType(value)) {
|
|
99
|
+
return true;
|
|
100
|
+
}
|
|
101
|
+
return prevExports[key] === nextExports[key];
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
if (hasExports && allExportsAreComponentsOrUnchanged === true) {
|
|
105
|
+
enqueueUpdate();
|
|
106
|
+
} else {
|
|
107
|
+
return `Could not Fast Refresh ("${allExportsAreComponentsOrUnchanged}" export is incompatible).`;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export function __hmr_import(module) {
|
|
112
|
+
return import(/* @vite-ignore */ module);
|
|
113
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared-dependencies-plugin.d.ts","sourceRoot":"","sources":["../../../../src/vite/plugins/shared-dependencies-plugin/shared-dependencies-plugin.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAM9B,MAAM,WAAW,+BAA+B;IAC5C,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACrC,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IAC/B,WAAW,CAAC,EAAE,MAAM,CAAC;CACxB;AAKD,wBAAgB,wBAAwB,CAAC,EACrC,YAAY,EACZ,GAAG,EACH,WAAW,GACd,EAAE,+BAA+B,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"shared-dependencies-plugin.d.ts","sourceRoot":"","sources":["../../../../src/vite/plugins/shared-dependencies-plugin/shared-dependencies-plugin.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAM9B,MAAM,WAAW,+BAA+B;IAC5C,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACrC,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IAC/B,WAAW,CAAC,EAAE,MAAM,CAAC;CACxB;AAKD,wBAAgB,wBAAwB,CAAC,EACrC,YAAY,EACZ,GAAG,EACH,WAAW,GACd,EAAE,+BAA+B,GAAG,MAAM,CAiK1C"}
|