@servicetitan/startup 36.4.0 → 37.0.1
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/analyze.js +3 -0
- package/dist/cli/commands/build.d.ts.map +1 -1
- package/dist/cli/commands/build.js +4 -5
- package/dist/cli/commands/build.js.map +1 -1
- package/dist/cli/commands/bundle-vite.d.ts.map +1 -1
- package/dist/cli/commands/bundle-vite.js +18 -1
- package/dist/cli/commands/bundle-vite.js.map +1 -1
- package/dist/cli/commands/registry/build.d.ts +6 -0
- package/dist/cli/commands/registry/build.d.ts.map +1 -1
- package/dist/cli/commands/registry/build.js +10 -1
- package/dist/cli/commands/registry/build.js.map +1 -1
- package/dist/cli/commands/registry/command-registry.d.ts +12 -28
- package/dist/cli/commands/registry/command-registry.d.ts.map +1 -1
- package/dist/cli/commands/registry/command-registry.js +0 -3
- package/dist/cli/commands/registry/command-registry.js.map +1 -1
- package/dist/cli/commands/registry/start.d.ts +6 -0
- package/dist/cli/commands/registry/start.d.ts.map +1 -1
- package/dist/cli/commands/registry/start.js +10 -1
- package/dist/cli/commands/registry/start.js.map +1 -1
- package/dist/cli/commands/review/rules/index.d.ts.map +1 -1
- package/dist/cli/commands/review/rules/index.js +2 -0
- package/dist/cli/commands/review/rules/index.js.map +1 -1
- package/dist/cli/commands/review/rules/require-compatible-typescript.d.ts +13 -0
- package/dist/cli/commands/review/rules/require-compatible-typescript.d.ts.map +1 -0
- package/dist/cli/commands/review/rules/require-compatible-typescript.js +72 -0
- package/dist/cli/commands/review/rules/require-compatible-typescript.js.map +1 -0
- package/dist/cli/commands/start.d.ts.map +1 -1
- package/dist/cli/commands/start.js +3 -4
- package/dist/cli/commands/start.js.map +1 -1
- package/dist/cli/commands/test/runners/vitest.d.ts.map +1 -1
- package/dist/cli/commands/test/runners/vitest.js +7 -1
- package/dist/cli/commands/test/runners/vitest.js.map +1 -1
- package/dist/cli/index.js +1 -1
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/utils/get-bundle-command.d.ts +3 -0
- package/dist/cli/utils/get-bundle-command.d.ts.map +1 -0
- package/dist/cli/utils/get-bundle-command.js +16 -0
- package/dist/cli/utils/get-bundle-command.js.map +1 -0
- package/dist/cli/utils/get-exit-code.d.ts +12 -0
- package/dist/cli/utils/get-exit-code.d.ts.map +1 -0
- package/dist/cli/utils/get-exit-code.js +26 -0
- package/dist/cli/utils/get-exit-code.js.map +1 -0
- package/dist/cli/utils/index.d.ts +3 -0
- package/dist/cli/utils/index.d.ts.map +1 -1
- package/dist/cli/utils/index.js +3 -0
- package/dist/cli/utils/index.js.map +1 -1
- package/dist/cli/utils/resolve-bundler.d.ts +8 -0
- package/dist/cli/utils/resolve-bundler.d.ts.map +1 -0
- package/dist/cli/utils/resolve-bundler.js +24 -0
- package/dist/cli/utils/resolve-bundler.js.map +1 -0
- package/dist/core/bundle-report.d.ts +4 -0
- package/dist/core/bundle-report.d.ts.map +1 -0
- package/dist/core/bundle-report.js +43 -0
- package/dist/core/bundle-report.js.map +1 -0
- package/dist/core/check-resource/check-resource.d.ts +5 -3
- package/dist/core/check-resource/check-resource.d.ts.map +1 -1
- package/dist/core/check-resource/check-resource.js +20 -13
- package/dist/core/check-resource/check-resource.js.map +1 -1
- package/dist/core/check-resource/get-peer-dependency-meta.d.ts +11 -1
- package/dist/core/check-resource/get-peer-dependency-meta.d.ts.map +1 -1
- package/dist/core/check-resource/get-peer-dependency-meta.js +58 -2
- package/dist/core/check-resource/get-peer-dependency-meta.js.map +1 -1
- package/dist/core/check-resource/index.d.ts +1 -1
- package/dist/core/check-resource/index.d.ts.map +1 -1
- package/dist/core/check-resource/index.js.map +1 -1
- package/dist/core/check-resource/is-resolvable.d.ts +7 -0
- package/dist/core/check-resource/is-resolvable.d.ts.map +1 -0
- package/dist/core/check-resource/is-resolvable.js +31 -0
- package/dist/core/check-resource/is-resolvable.js.map +1 -0
- package/dist/core/check-resource/types.d.ts +1 -0
- package/dist/core/check-resource/types.d.ts.map +1 -1
- package/dist/core/chunk-patterns.d.ts +7 -0
- package/dist/core/chunk-patterns.d.ts.map +1 -0
- package/dist/core/chunk-patterns.js +37 -0
- package/dist/core/chunk-patterns.js.map +1 -0
- package/dist/core/create-build-context.d.ts +0 -1
- package/dist/core/create-build-context.d.ts.map +1 -1
- package/dist/core/create-build-context.js +2 -2
- package/dist/core/create-build-context.js.map +1 -1
- package/dist/core/create-extension-regexp.d.ts +5 -0
- package/dist/core/create-extension-regexp.d.ts.map +1 -0
- package/dist/core/create-extension-regexp.js +45 -0
- package/dist/core/create-extension-regexp.js.map +1 -0
- package/dist/core/get-process-env.d.ts +3 -0
- package/dist/core/get-process-env.d.ts.map +1 -0
- package/dist/core/get-process-env.js +25 -0
- package/dist/core/get-process-env.js.map +1 -0
- package/dist/core/index.d.ts +8 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +8 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/moment-locales.d.ts +2 -0
- package/dist/core/moment-locales.d.ts.map +1 -0
- package/dist/core/moment-locales.js +21 -0
- package/dist/core/moment-locales.js.map +1 -0
- package/dist/core/resolve-output-path.d.ts +3 -0
- package/dist/core/resolve-output-path.d.ts.map +1 -0
- package/dist/core/resolve-output-path.js +25 -0
- package/dist/core/resolve-output-path.js.map +1 -0
- package/dist/core/resolve-output-root.d.ts +3 -0
- package/dist/core/resolve-output-root.d.ts.map +1 -0
- package/dist/core/resolve-output-root.js +23 -0
- package/dist/core/resolve-output-root.js.map +1 -0
- package/dist/core/sort-shared-css.d.ts +2 -0
- package/dist/core/sort-shared-css.d.ts.map +1 -0
- package/dist/core/sort-shared-css.js +20 -0
- package/dist/core/sort-shared-css.js.map +1 -0
- package/dist/core/types.d.ts +1 -1
- package/dist/core/types.d.ts.map +1 -1
- package/dist/cypress/config/index.d.ts +1 -0
- package/dist/cypress/config/index.d.ts.map +1 -1
- package/dist/cypress/config/index.js +1 -0
- package/dist/cypress/config/index.js.map +1 -1
- package/dist/cypress/config/vite-config.d.ts +3 -0
- package/dist/cypress/config/vite-config.d.ts.map +1 -0
- package/dist/cypress/config/vite-config.js +58 -0
- package/dist/cypress/config/vite-config.js.map +1 -0
- package/dist/jest/resolver.d.ts.map +1 -1
- package/dist/jest/resolver.js +20 -1
- package/dist/jest/resolver.js.map +1 -1
- package/dist/storybook-config/index.d.ts +1 -0
- package/dist/storybook-config/index.d.ts.map +1 -1
- package/dist/storybook-config/index.js +1 -0
- package/dist/storybook-config/index.js.map +1 -1
- package/dist/storybook-config/vite-final.d.ts +7 -0
- package/dist/storybook-config/vite-final.d.ts.map +1 -0
- package/dist/storybook-config/vite-final.js +86 -0
- package/dist/storybook-config/vite-final.js.map +1 -0
- package/dist/utils/get-configuration.d.ts +15 -10
- package/dist/utils/get-configuration.d.ts.map +1 -1
- package/dist/utils/get-configuration.js +32 -2
- package/dist/utils/get-configuration.js.map +1 -1
- package/dist/utils/get-package-name.d.ts +2 -1
- package/dist/utils/get-package-name.d.ts.map +1 -1
- package/dist/utils/get-package-name.js +4 -2
- package/dist/utils/get-package-name.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.map +1 -1
- package/dist/utils/types.d.ts +2 -0
- package/dist/utils/types.d.ts.map +1 -0
- package/dist/utils/types.js +6 -0
- package/dist/utils/types.js.map +1 -0
- package/dist/utils/validate-shared-dependencies.d.ts.map +1 -1
- package/dist/utils/validate-shared-dependencies.js +4 -0
- package/dist/utils/validate-shared-dependencies.js.map +1 -1
- package/dist/vite/build-shared-dependencies.d.ts.map +1 -1
- package/dist/vite/build-shared-dependencies.js +1 -2
- package/dist/vite/build-shared-dependencies.js.map +1 -1
- package/dist/vite/config/asset-file-names.d.ts +4 -0
- package/dist/vite/config/asset-file-names.d.ts.map +1 -0
- package/dist/vite/config/asset-file-names.js +29 -0
- package/dist/vite/config/asset-file-names.js.map +1 -0
- package/dist/vite/config/base-config.d.ts.map +1 -1
- package/dist/vite/config/base-config.js +67 -40
- package/dist/vite/config/base-config.js.map +1 -1
- package/dist/vite/config/code-splitting.d.ts +4 -0
- package/dist/vite/config/code-splitting.d.ts.map +1 -0
- package/dist/vite/config/code-splitting.js +48 -0
- package/dist/vite/config/code-splitting.js.map +1 -0
- package/dist/vite/config/create-css-config.d.ts +3 -0
- package/dist/vite/config/create-css-config.d.ts.map +1 -0
- package/dist/vite/config/create-css-config.js +26 -0
- package/dist/vite/config/create-css-config.js.map +1 -0
- package/dist/vite/config/create-filtering-logger.d.ts +3 -0
- package/dist/vite/config/create-filtering-logger.d.ts.map +1 -0
- package/dist/vite/config/create-filtering-logger.js +37 -0
- package/dist/vite/config/create-filtering-logger.js.map +1 -0
- package/dist/vite/config/create-vite-build-context.d.ts +2 -1
- package/dist/vite/config/create-vite-build-context.d.ts.map +1 -1
- package/dist/vite/config/create-vite-build-context.js.map +1 -1
- package/dist/vite/config/create-vite-config.d.ts.map +1 -1
- package/dist/vite/config/create-vite-config.js +30 -13
- package/dist/vite/config/create-vite-config.js.map +1 -1
- package/dist/vite/config/get-warmup-client-files.d.ts +3 -0
- package/dist/vite/config/get-warmup-client-files.d.ts.map +1 -0
- package/dist/vite/config/get-warmup-client-files.js +26 -0
- package/dist/vite/config/get-warmup-client-files.js.map +1 -0
- package/dist/vite/index.html +1 -0
- package/dist/vite/plugins/bundle-stat-plugin.d.ts +4 -0
- package/dist/vite/plugins/bundle-stat-plugin.d.ts.map +1 -0
- package/dist/vite/plugins/bundle-stat-plugin.js +32 -0
- package/dist/vite/plugins/bundle-stat-plugin.js.map +1 -0
- package/dist/vite/plugins/chain-source-maps-plugin.d.ts +3 -0
- package/dist/vite/plugins/chain-source-maps-plugin.d.ts.map +1 -0
- package/dist/vite/plugins/chain-source-maps-plugin.js +37 -0
- package/dist/vite/plugins/chain-source-maps-plugin.js.map +1 -0
- package/dist/vite/plugins/clean-plugin.d.ts +4 -0
- package/dist/vite/plugins/clean-plugin.d.ts.map +1 -0
- package/dist/vite/plugins/clean-plugin.js +63 -0
- package/dist/vite/plugins/clean-plugin.js.map +1 -0
- package/dist/vite/plugins/design-system-guard-plugin.d.ts +4 -0
- package/dist/vite/plugins/design-system-guard-plugin.d.ts.map +1 -0
- package/dist/vite/plugins/design-system-guard-plugin.js +35 -0
- package/dist/vite/plugins/design-system-guard-plugin.js.map +1 -0
- package/dist/vite/plugins/ignore-modules-plugin.d.ts +21 -3
- package/dist/vite/plugins/ignore-modules-plugin.d.ts.map +1 -1
- package/dist/vite/plugins/ignore-modules-plugin.js +22 -8
- package/dist/vite/plugins/ignore-modules-plugin.js.map +1 -1
- package/dist/vite/plugins/index.d.ts +7 -0
- package/dist/vite/plugins/index.d.ts.map +1 -1
- package/dist/vite/plugins/index.js +7 -0
- package/dist/vite/plugins/index.js.map +1 -1
- package/dist/vite/plugins/istanbul-plugin.d.ts +4 -0
- package/dist/vite/plugins/istanbul-plugin.d.ts.map +1 -0
- package/dist/vite/plugins/istanbul-plugin.js +27 -0
- package/dist/vite/plugins/istanbul-plugin.js.map +1 -0
- package/dist/vite/plugins/magic-comments-plugin/index.d.ts +2 -0
- package/dist/vite/plugins/magic-comments-plugin/index.d.ts.map +1 -0
- package/dist/vite/plugins/magic-comments-plugin/index.js +20 -0
- package/dist/vite/plugins/magic-comments-plugin/index.js.map +1 -0
- package/dist/vite/plugins/magic-comments-plugin/magic-comments-plugin.d.ts +4 -0
- package/dist/vite/plugins/magic-comments-plugin/magic-comments-plugin.d.ts.map +1 -0
- package/dist/vite/plugins/magic-comments-plugin/magic-comments-plugin.js +63 -0
- package/dist/vite/plugins/magic-comments-plugin/magic-comments-plugin.js.map +1 -0
- package/dist/vite/plugins/magic-comments-plugin/parse-magic-comments.d.ts +6 -0
- package/dist/vite/plugins/magic-comments-plugin/parse-magic-comments.d.ts.map +1 -0
- package/dist/vite/plugins/magic-comments-plugin/parse-magic-comments.js +40 -0
- package/dist/vite/plugins/magic-comments-plugin/parse-magic-comments.js.map +1 -0
- package/dist/vite/plugins/metadata-plugin.js +2 -2
- package/dist/vite/plugins/metadata-plugin.js.map +1 -1
- package/dist/vite/plugins/moment-locales-plugin.d.ts +5 -0
- package/dist/vite/plugins/moment-locales-plugin.d.ts.map +1 -0
- package/dist/vite/plugins/moment-locales-plugin.js +50 -0
- package/dist/vite/plugins/moment-locales-plugin.js.map +1 -0
- package/dist/vite/plugins/shared-dependencies-plugin/assemble-iife.d.ts +14 -0
- package/dist/vite/plugins/shared-dependencies-plugin/assemble-iife.d.ts.map +1 -0
- package/dist/vite/plugins/shared-dependencies-plugin/assemble-iife.js +100 -0
- package/dist/vite/plugins/shared-dependencies-plugin/assemble-iife.js.map +1 -0
- package/dist/vite/plugins/shared-dependencies-plugin/assert-no-dynamic-css.d.ts +3 -0
- package/dist/vite/plugins/shared-dependencies-plugin/assert-no-dynamic-css.d.ts.map +1 -0
- package/dist/vite/plugins/shared-dependencies-plugin/assert-no-dynamic-css.js +56 -0
- package/dist/vite/plugins/shared-dependencies-plugin/assert-no-dynamic-css.js.map +1 -0
- package/dist/vite/plugins/shared-dependencies-plugin/flatten.d.ts +2 -0
- package/dist/vite/plugins/shared-dependencies-plugin/flatten.d.ts.map +1 -0
- package/dist/vite/plugins/shared-dependencies-plugin/flatten.js +19 -0
- package/dist/vite/plugins/shared-dependencies-plugin/flatten.js.map +1 -0
- package/dist/vite/plugins/shared-dependencies-plugin/index.d.ts +2 -0
- package/dist/vite/plugins/shared-dependencies-plugin/index.d.ts.map +1 -0
- package/dist/vite/plugins/shared-dependencies-plugin/index.js +20 -0
- package/dist/vite/plugins/shared-dependencies-plugin/index.js.map +1 -0
- package/dist/vite/plugins/shared-dependencies-plugin/shared-dependencies-plugin.d.ts.map +1 -0
- package/dist/vite/plugins/{shared-dependencies-plugin.js → shared-dependencies-plugin/shared-dependencies-plugin.js} +29 -107
- package/dist/vite/plugins/shared-dependencies-plugin/shared-dependencies-plugin.js.map +1 -0
- package/dist/vite/plugins/utils/import-esm.d.ts +2 -0
- package/dist/vite/plugins/utils/import-esm.d.ts.map +1 -0
- package/dist/vite/plugins/utils/import-esm.js +22 -0
- package/dist/vite/plugins/utils/import-esm.js.map +1 -0
- package/dist/vite/plugins/utils/index.d.ts +3 -0
- package/dist/vite/plugins/utils/index.d.ts.map +1 -0
- package/dist/vite/plugins/utils/index.js +21 -0
- package/dist/vite/plugins/utils/index.js.map +1 -0
- package/dist/webpack/configs/optimization-config.d.ts.map +1 -1
- package/dist/webpack/configs/optimization-config.js +53 -24
- package/dist/webpack/configs/optimization-config.js.map +1 -1
- package/dist/webpack/configs/output-config.d.ts.map +1 -1
- package/dist/webpack/configs/output-config.js +0 -1
- package/dist/webpack/configs/output-config.js.map +1 -1
- package/dist/webpack/configs/plugins/assets-manifest-plugin.d.ts.map +1 -1
- package/dist/webpack/configs/plugins/assets-manifest-plugin.js +11 -3
- package/dist/webpack/configs/plugins/assets-manifest-plugin.js.map +1 -1
- package/dist/webpack/configs/plugins/bundle-analyser-plugin.d.ts.map +1 -1
- package/dist/webpack/configs/plugins/bundle-analyser-plugin.js +2 -21
- package/dist/webpack/configs/plugins/bundle-analyser-plugin.js.map +1 -1
- package/dist/webpack/configs/plugins/define-process-env-plugin.d.ts +5 -0
- package/dist/webpack/configs/plugins/define-process-env-plugin.d.ts.map +1 -0
- package/dist/webpack/configs/plugins/define-process-env-plugin.js +20 -0
- package/dist/webpack/configs/plugins/define-process-env-plugin.js.map +1 -0
- package/dist/webpack/configs/plugins/filter-warnings-plugin.d.ts +1 -1
- package/dist/webpack/configs/plugins/filter-warnings-plugin.d.ts.map +1 -1
- package/dist/webpack/configs/plugins/filter-warnings-plugin.js +1 -4
- package/dist/webpack/configs/plugins/filter-warnings-plugin.js.map +1 -1
- package/dist/webpack/configs/plugins/ignore-plugin/empty-module.d.ts +2 -0
- package/dist/webpack/configs/plugins/ignore-plugin/empty-module.d.ts.map +1 -0
- package/dist/webpack/configs/plugins/ignore-plugin/empty-module.js +11 -0
- package/dist/webpack/configs/plugins/ignore-plugin/empty-module.js.map +1 -0
- package/dist/webpack/configs/plugins/ignore-plugin/ignore-plugin.d.ts +26 -3
- package/dist/webpack/configs/plugins/ignore-plugin/ignore-plugin.d.ts.map +1 -1
- package/dist/webpack/configs/plugins/ignore-plugin/ignore-plugin.js +41 -10
- package/dist/webpack/configs/plugins/ignore-plugin/ignore-plugin.js.map +1 -1
- package/dist/webpack/configs/plugins/index.d.ts +1 -0
- package/dist/webpack/configs/plugins/index.d.ts.map +1 -1
- package/dist/webpack/configs/plugins/index.js +1 -0
- package/dist/webpack/configs/plugins/index.js.map +1 -1
- package/dist/webpack/configs/plugins/moment-locales-plugin.d.ts.map +1 -1
- package/dist/webpack/configs/plugins/moment-locales-plugin.js +2 -5
- package/dist/webpack/configs/plugins/moment-locales-plugin.js.map +1 -1
- package/dist/webpack/configs/plugins-config.d.ts.map +1 -1
- package/dist/webpack/configs/plugins-config.js +1 -0
- package/dist/webpack/configs/plugins-config.js.map +1 -1
- package/dist/webpack/configs/rules/font-rules.d.ts.map +1 -1
- package/dist/webpack/configs/rules/font-rules.js +2 -1
- package/dist/webpack/configs/rules/font-rules.js.map +1 -1
- package/dist/webpack/configs/rules/image-rules.d.ts.map +1 -1
- package/dist/webpack/configs/rules/image-rules.js +2 -1
- package/dist/webpack/configs/rules/image-rules.js.map +1 -1
- package/dist/webpack/create-webpack-config.d.ts.map +1 -1
- package/dist/webpack/create-webpack-config.js +8 -3
- package/dist/webpack/create-webpack-config.js.map +1 -1
- package/dist/webpack/create-webpack-configs.d.ts.map +1 -1
- package/dist/webpack/create-webpack-configs.js +4 -12
- package/dist/webpack/create-webpack-configs.js.map +1 -1
- package/dist/webpack/types.d.ts +1 -1
- package/dist/webpack/types.d.ts.map +1 -1
- package/dist/webpack/utils/create-webpack-build-context.d.ts.map +1 -1
- package/dist/webpack/utils/create-webpack-build-context.js +1 -2
- package/dist/webpack/utils/create-webpack-build-context.js.map +1 -1
- package/package.json +22 -18
- package/src/cli/commands/__tests__/build.test.ts +33 -5
- package/src/cli/commands/__tests__/bundle-vite.test.ts +50 -1
- package/src/cli/commands/__tests__/start.test.ts +17 -4
- package/src/cli/commands/build.ts +5 -6
- package/src/cli/commands/bundle-vite.ts +13 -0
- package/src/cli/commands/registry/build.ts +6 -1
- package/src/cli/commands/registry/command-registry.ts +0 -1
- package/src/cli/commands/registry/start.ts +6 -1
- package/src/cli/commands/review/rules/__tests__/require-compatible-typescript.test.ts +127 -0
- package/src/cli/commands/review/rules/index.ts +2 -0
- package/src/cli/commands/review/rules/require-compatible-typescript.ts +64 -0
- package/src/cli/commands/start.ts +4 -4
- package/src/cli/commands/test/runners/__tests__/vitest.test.ts +8 -1
- package/src/cli/commands/test/runners/vitest.ts +5 -3
- package/src/cli/index.ts +2 -2
- package/src/cli/utils/__tests__/get-bundle-command.test.ts +23 -0
- package/src/cli/utils/__tests__/get-exit-code.test.ts +41 -0
- package/src/cli/utils/__tests__/resolve-bundler.test.ts +64 -0
- package/src/cli/utils/get-bundle-command.ts +5 -0
- package/src/cli/utils/get-exit-code.ts +17 -0
- package/src/cli/utils/index.ts +3 -0
- package/src/cli/utils/resolve-bundler.ts +23 -0
- package/src/core/__tests__/bundle-report.test.ts +60 -0
- package/src/core/__tests__/create-extension-regexp.test.ts +32 -0
- package/src/core/__tests__/resolve-output-path.test.ts +45 -0
- package/src/core/__tests__/resolve-output-root.test.ts +37 -0
- package/src/core/__tests__/sort-shared-css.test.ts +39 -0
- package/src/core/bundle-report.ts +33 -0
- package/src/core/check-resource/__tests__/check-resource.test.ts +21 -7
- package/src/core/check-resource/__tests__/get-peer-dependency-meta.test.ts +70 -13
- package/src/core/check-resource/__tests__/is-resolvable.test.ts +20 -0
- package/src/core/check-resource/check-resource.ts +17 -16
- package/src/core/check-resource/get-peer-dependency-meta.ts +67 -4
- package/src/core/check-resource/index.ts +1 -1
- package/src/core/check-resource/is-resolvable.ts +19 -0
- package/src/core/check-resource/types.ts +2 -0
- package/src/core/chunk-patterns.ts +30 -0
- package/src/core/create-build-context.ts +2 -2
- package/src/core/create-extension-regexp.ts +7 -0
- package/src/core/get-process-env.ts +17 -0
- package/src/core/index.ts +8 -1
- package/src/core/moment-locales.ts +6 -0
- package/src/core/resolve-output-path.ts +10 -0
- package/src/core/resolve-output-root.ts +8 -0
- package/src/core/sort-shared-css.ts +7 -0
- package/src/core/types.ts +1 -1
- package/src/cypress/config/__tests__/vite-config.test.ts +72 -0
- package/src/cypress/config/index.ts +1 -0
- package/src/cypress/config/vite-config.ts +37 -0
- package/src/jest/__tests__/resolver.test.ts +42 -1
- package/src/jest/resolver.ts +17 -1
- package/src/storybook-config/__tests__/vite-final.test.ts +122 -0
- package/src/storybook-config/index.ts +1 -0
- package/src/storybook-config/vite-final.ts +65 -0
- package/src/utils/__tests__/get-configuration.test.ts +82 -5
- package/src/utils/__tests__/get-package-name.test.ts +57 -0
- package/src/utils/__tests__/validate-shared-dependencies.test.ts +50 -35
- package/src/utils/get-configuration.ts +50 -15
- package/src/utils/get-package-name.ts +8 -2
- package/src/utils/index.ts +1 -0
- package/src/utils/types.ts +1 -0
- package/src/utils/validate-shared-dependencies.ts +15 -1
- package/src/vite/__tests__/build-shared-dependencies.test.ts +13 -26
- package/src/vite/__tests__/validate-shared-dependencies.test.ts +30 -19
- package/src/vite/build-shared-dependencies.ts +3 -7
- package/src/vite/config/__tests__/asset-file-names.test.ts +40 -0
- package/src/vite/config/__tests__/base-config.test.ts +99 -31
- package/src/vite/config/__tests__/code-splitting.test.ts +34 -0
- package/src/vite/config/__tests__/create-css-config.test.ts +58 -0
- package/src/vite/config/__tests__/create-filtering-logger.test.ts +51 -0
- package/src/vite/config/__tests__/create-vite-build-context.test.ts +5 -2
- package/src/vite/config/__tests__/create-vite-config.test.ts +91 -13
- package/src/vite/config/__tests__/get-warmup-client-files.test.ts +20 -0
- package/src/vite/config/asset-file-names.ts +20 -0
- package/src/vite/config/base-config.ts +45 -37
- package/src/vite/config/code-splitting.ts +23 -0
- package/src/vite/config/create-css-config.ts +16 -0
- package/src/vite/config/create-filtering-logger.ts +34 -0
- package/src/vite/config/create-vite-build-context.ts +3 -5
- package/src/vite/config/create-vite-config.ts +45 -12
- package/src/vite/config/get-warmup-client-files.ts +13 -0
- package/src/vite/index.html +1 -0
- package/src/vite/plugins/__tests__/bundle-stat-plugin.test.ts +70 -0
- package/src/vite/plugins/__tests__/chain-source-maps-plugin.test.ts +58 -0
- package/src/vite/plugins/__tests__/clean-plugin.test.ts +121 -0
- package/src/vite/plugins/__tests__/design-system-guard-plugin.test.ts +83 -0
- package/src/vite/plugins/__tests__/html-template.test.ts +6 -0
- package/src/vite/plugins/__tests__/ignore-modules-plugin.test.ts +29 -7
- package/src/vite/plugins/__tests__/istanbul-plugin.test.ts +62 -0
- package/src/vite/plugins/__tests__/moment-locales-plugin.test.ts +104 -0
- package/src/vite/plugins/bundle-stat-plugin.ts +24 -0
- package/src/vite/plugins/chain-source-maps-plugin.ts +26 -0
- package/src/vite/plugins/clean-plugin.ts +46 -0
- package/src/vite/plugins/design-system-guard-plugin.ts +34 -0
- package/src/vite/plugins/ignore-modules-plugin.ts +36 -7
- package/src/vite/plugins/index.ts +7 -0
- package/src/vite/plugins/istanbul-plugin.ts +19 -0
- package/src/vite/plugins/magic-comments-plugin/__tests__/magic-comments-plugin.test.ts +105 -0
- package/src/vite/plugins/magic-comments-plugin/__tests__/parse-magic-comments.test.ts +40 -0
- package/src/vite/plugins/magic-comments-plugin/index.ts +1 -0
- package/src/vite/plugins/magic-comments-plugin/magic-comments-plugin.ts +63 -0
- package/src/vite/plugins/magic-comments-plugin/parse-magic-comments.ts +39 -0
- package/src/vite/plugins/metadata-plugin.ts +1 -1
- package/src/vite/plugins/moment-locales-plugin.ts +41 -0
- package/src/vite/plugins/shared-dependencies-plugin/__tests__/assemble-iife.test.ts +29 -0
- package/src/vite/plugins/shared-dependencies-plugin/__tests__/assert-no-dynamic-css.test.ts +113 -0
- package/src/vite/plugins/shared-dependencies-plugin/__tests__/flatten.test.ts +23 -0
- package/src/vite/plugins/{__tests__ → shared-dependencies-plugin/__tests__}/shared-dependencies-plugin.test.ts +38 -4
- package/src/vite/plugins/shared-dependencies-plugin/assemble-iife.ts +114 -0
- package/src/vite/plugins/shared-dependencies-plugin/assert-no-dynamic-css.ts +58 -0
- package/src/vite/plugins/shared-dependencies-plugin/flatten.ts +8 -0
- package/src/vite/plugins/shared-dependencies-plugin/index.ts +1 -0
- package/src/vite/plugins/{shared-dependencies-plugin.ts → shared-dependencies-plugin/shared-dependencies-plugin.ts} +24 -115
- package/src/vite/plugins/utils/import-esm.ts +15 -0
- package/src/vite/plugins/utils/index.ts +2 -0
- package/src/vite/rolldown-oxc.d.ts +20 -0
- package/src/webpack/__tests__/bundle-webpack.test.ts +8 -8
- package/src/webpack/__tests__/create-webpack-config-shared-dependencies.test.ts +54 -5
- package/src/webpack/__tests__/create-webpack-config-web-component.test.ts +81 -12
- package/src/webpack/__tests__/create-webpack-config.test.ts +92 -9
- package/src/webpack/configs/optimization-config.ts +47 -25
- package/src/webpack/configs/output-config.ts +1 -2
- package/src/webpack/configs/plugins/assets-manifest-plugin.ts +16 -4
- package/src/webpack/configs/plugins/bundle-analyser-plugin.ts +3 -25
- package/src/webpack/configs/plugins/define-process-env-plugin.ts +10 -0
- package/src/webpack/configs/plugins/filter-warnings-plugin.ts +1 -5
- package/src/webpack/configs/plugins/ignore-plugin/__tests__/ignore-plugin.test.ts +76 -24
- package/src/webpack/configs/plugins/ignore-plugin/empty-module.ts +7 -0
- package/src/webpack/configs/plugins/ignore-plugin/ignore-plugin.ts +59 -9
- package/src/webpack/configs/plugins/index.ts +1 -0
- package/src/webpack/configs/plugins/moment-locales-plugin.ts +2 -2
- package/src/webpack/configs/plugins-config.ts +2 -0
- package/src/webpack/configs/rules/font-rules.ts +2 -2
- package/src/webpack/configs/rules/image-rules.ts +2 -2
- package/src/webpack/create-webpack-config.ts +11 -4
- package/src/webpack/create-webpack-configs.ts +2 -8
- package/src/webpack/types.ts +1 -4
- package/src/webpack/utils/create-webpack-build-context.ts +1 -6
- package/tsconfig/base.json +1 -1
- package/tsconfig/types.d.ts +10 -0
- package/dist/core/get-output-path.d.ts +0 -3
- package/dist/core/get-output-path.d.ts.map +0 -1
- package/dist/core/get-output-path.js +0 -29
- package/dist/core/get-output-path.js.map +0 -1
- package/dist/vite/plugins/shared-dependencies-plugin.d.ts.map +0 -1
- package/dist/vite/plugins/shared-dependencies-plugin.js.map +0 -1
- package/src/core/__tests__/get-output-path.test.ts +0 -64
- package/src/core/get-output-path.ts +0 -15
- /package/dist/vite/plugins/{shared-dependencies-plugin.d.ts → shared-dependencies-plugin/shared-dependencies-plugin.d.ts} +0 -0
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import path from 'path';
|
|
2
|
-
import { bundleConstants, generateExposedDependenciesMetadata } from '
|
|
2
|
+
import { bundleConstants, generateExposedDependenciesMetadata } from '../../../../core';
|
|
3
3
|
import {
|
|
4
4
|
sharedDependenciesPlugin,
|
|
5
5
|
type SharedDependenciesPluginOptions,
|
|
6
6
|
} from '../shared-dependencies-plugin';
|
|
7
7
|
|
|
8
|
-
jest.mock('
|
|
8
|
+
jest.mock('../../../../core', () => ({
|
|
9
|
+
...jest.requireActual('../../../../core'),
|
|
9
10
|
bundleConstants: {
|
|
10
11
|
mode: { production: 'production', development: 'development' },
|
|
11
12
|
},
|
|
@@ -259,11 +260,19 @@ describe(sharedDependenciesPlugin.name, () => {
|
|
|
259
260
|
type: 'chunk',
|
|
260
261
|
isEntry: false,
|
|
261
262
|
code: sharedChunk.code,
|
|
263
|
+
imports: [],
|
|
264
|
+
dynamicImports: [],
|
|
262
265
|
},
|
|
263
266
|
...Object.fromEntries(
|
|
264
267
|
Object.keys(mockDependencies).map(dependency => [
|
|
265
268
|
entryFileName(dependency),
|
|
266
|
-
{
|
|
269
|
+
{
|
|
270
|
+
type: 'chunk',
|
|
271
|
+
isEntry: true,
|
|
272
|
+
code: `${dependency} code`,
|
|
273
|
+
imports: [],
|
|
274
|
+
dynamicImports: [],
|
|
275
|
+
},
|
|
267
276
|
])
|
|
268
277
|
),
|
|
269
278
|
'styles.bundle.css': { type: 'asset' },
|
|
@@ -383,7 +392,13 @@ describe(sharedDependenciesPlugin.name, () => {
|
|
|
383
392
|
describe('with CSS entries', () => {
|
|
384
393
|
beforeEach(() => {
|
|
385
394
|
options.css = { 'design-system': ['tokens.css'] };
|
|
386
|
-
bundle['design-system.cjs.js'] = {
|
|
395
|
+
bundle['design-system.cjs.js'] = {
|
|
396
|
+
type: 'chunk',
|
|
397
|
+
isEntry: true,
|
|
398
|
+
code: '',
|
|
399
|
+
imports: [],
|
|
400
|
+
dynamicImports: [],
|
|
401
|
+
};
|
|
387
402
|
});
|
|
388
403
|
|
|
389
404
|
test('removes CSS entry chunks from bundle', () => {
|
|
@@ -392,6 +407,25 @@ describe(sharedDependenciesPlugin.name, () => {
|
|
|
392
407
|
expect(bundle['design-system.cjs.js']).toBeUndefined();
|
|
393
408
|
});
|
|
394
409
|
});
|
|
410
|
+
|
|
411
|
+
describe('when bundle has anvil2 CSS before design-system CSS', () => {
|
|
412
|
+
beforeEach(() => {
|
|
413
|
+
bundle['anvil2.bundle.css'] = { type: 'asset' };
|
|
414
|
+
bundle['design-system.bundle.css'] = { type: 'asset' };
|
|
415
|
+
});
|
|
416
|
+
|
|
417
|
+
test('puts design-system CSS before anvil2 CSS in entrypoints.json', () => {
|
|
418
|
+
subject();
|
|
419
|
+
|
|
420
|
+
const call = emitFile.mock.calls.find(
|
|
421
|
+
(c: any) => c[0].fileName === 'entrypoints.json'
|
|
422
|
+
);
|
|
423
|
+
const { css } = JSON.parse(call[0].source);
|
|
424
|
+
expect(css.indexOf('design-system.bundle.css')).toBeLessThan(
|
|
425
|
+
css.indexOf('anvil2.bundle.css')
|
|
426
|
+
);
|
|
427
|
+
});
|
|
428
|
+
});
|
|
395
429
|
});
|
|
396
430
|
|
|
397
431
|
describe('writeBundle', () => {
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
export interface ModuleFactory {
|
|
2
|
+
/** Module id used as the factory's key and require() argument (e.g. `react`, `./_chunk.js`). */
|
|
3
|
+
id: string;
|
|
4
|
+
/** The chunk's generated code, run inside `function(module, exports, require) { ... }`. */
|
|
5
|
+
code: string;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface Expose {
|
|
9
|
+
/** Global path the dependency is published under (e.g. `SharedDependencies.React`). */
|
|
10
|
+
variable: string;
|
|
11
|
+
/** Module id resolved through the scoped require when the global is accessed. */
|
|
12
|
+
dependency: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function indent(spaces: number) {
|
|
16
|
+
return ' '.repeat(spaces);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/*
|
|
20
|
+
* Wraps the bundle's module factories and expose calls in the runtime IIFE.
|
|
21
|
+
* The IIFE installs a per-scope require system on globalThis so each MFE gets
|
|
22
|
+
* isolated module instances of the shared dependencies.
|
|
23
|
+
*/
|
|
24
|
+
export function assembleIife(modules: ModuleFactory[], exposes: Expose[]): string {
|
|
25
|
+
const factories = modules.map(
|
|
26
|
+
({ id, code }) =>
|
|
27
|
+
`'${id}': function(module, exports, require) {\n${indent(12)}${code}\n${indent(8)}}`
|
|
28
|
+
);
|
|
29
|
+
const exposeCalls = exposes.map(
|
|
30
|
+
({ variable, dependency }) => `expose('${variable}', '${dependency}');`
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
return `\
|
|
34
|
+
(function () {
|
|
35
|
+
const STORAGE_KEY = Symbol.for('SERVICETITAN_EXPOSE_LOADER_STORAGE');
|
|
36
|
+
const g = globalThis;
|
|
37
|
+
|
|
38
|
+
if (g[STORAGE_KEY] === undefined) {
|
|
39
|
+
g[STORAGE_KEY] = Object.assign(Object.create(null), {
|
|
40
|
+
clear(scope) {
|
|
41
|
+
delete this[scope];
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
var storage = g[STORAGE_KEY];
|
|
47
|
+
|
|
48
|
+
var modules = {
|
|
49
|
+
${factories.join(`,\n${indent(8)}`)}
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
function createScopedRequire(scope) {
|
|
53
|
+
const cache = (storage[scope] = storage[scope] || Object.create(null));
|
|
54
|
+
|
|
55
|
+
function require(id) {
|
|
56
|
+
if (cache[id]) {
|
|
57
|
+
return cache[id].exports;
|
|
58
|
+
}
|
|
59
|
+
if (!modules[id]) {
|
|
60
|
+
throw new Error('Module not found: ' + id);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const module = (cache[id] = { id, loaded: false, exports: {} });
|
|
64
|
+
modules[id](module, module.exports, require);
|
|
65
|
+
module.loaded = true;
|
|
66
|
+
|
|
67
|
+
const keys = Object.keys(module.exports);
|
|
68
|
+
if (module.exports.__esModule && keys.length === 1 && keys[0] === 'default') {
|
|
69
|
+
module.exports = module.exports.default;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return module.exports;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
Object.setPrototypeOf(require, {
|
|
76
|
+
resolve(id) {
|
|
77
|
+
return id;
|
|
78
|
+
},
|
|
79
|
+
});
|
|
80
|
+
return require;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function expose(path, moduleId) {
|
|
84
|
+
const parts = path.split('.');
|
|
85
|
+
let obj = g;
|
|
86
|
+
|
|
87
|
+
for (let i = 0; i < parts.length - 1; i++) {
|
|
88
|
+
if (obj[parts[i]] === undefined) {
|
|
89
|
+
obj[parts[i]] = Object.create(null);
|
|
90
|
+
}
|
|
91
|
+
obj = obj[parts[i]];
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
obj[parts[parts.length - 1]] = new Proxy(
|
|
95
|
+
Object.assign(Object.create(null), {
|
|
96
|
+
getStorage() {
|
|
97
|
+
return storage;
|
|
98
|
+
},
|
|
99
|
+
}),
|
|
100
|
+
{
|
|
101
|
+
get(target, scope, receiver) {
|
|
102
|
+
if (scope === 'getStorage') {
|
|
103
|
+
return Reflect.get(target, scope, receiver);
|
|
104
|
+
}
|
|
105
|
+
return createScopedRequire(scope)(moduleId);
|
|
106
|
+
},
|
|
107
|
+
}
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
${exposeCalls.join(`\n${indent(4)}`)}
|
|
112
|
+
})();
|
|
113
|
+
`;
|
|
114
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { OutputBundle, OutputChunk } from 'rolldown';
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* Output bundles only include statically imported CSS. CSS pulled in by a dynamic
|
|
5
|
+
* import() lands in a separate async chunk that is omitted from entrypoints.json
|
|
6
|
+
* and silently fails to load. Fail the build when the bundle references CSS that
|
|
7
|
+
* does not land in entrypoints.json.
|
|
8
|
+
*/
|
|
9
|
+
export function assertNoDynamicCss(bundle: OutputBundle): void {
|
|
10
|
+
for (const entry of Object.values(bundle)) {
|
|
11
|
+
if (!(entry.type === 'chunk' && entry.isEntry)) {
|
|
12
|
+
continue;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const includedCss = importedCss(entry);
|
|
16
|
+
const excludedCss = [...allCss(entry, bundle)].filter(css => !includedCss.has(css));
|
|
17
|
+
|
|
18
|
+
if (excludedCss.length > 0) {
|
|
19
|
+
throw new Error(
|
|
20
|
+
`Shared dependency chunk "${entry.name}" pulls in CSS through a dynamic import ` +
|
|
21
|
+
`(${excludedCss.join(', ')}). Shared dependencies only include statically imported ` +
|
|
22
|
+
`CSS. Dynamically imported CSS will not load on the host.`
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/*
|
|
29
|
+
* Return every CSS file imported by the entry and recursively by anything it imports.
|
|
30
|
+
*/
|
|
31
|
+
function allCss(entry: OutputChunk, bundle: OutputBundle): Set<string> {
|
|
32
|
+
const result = new Set<string>();
|
|
33
|
+
const visited = new Set<string>();
|
|
34
|
+
const stack = [entry];
|
|
35
|
+
|
|
36
|
+
while (stack.length > 0) {
|
|
37
|
+
const chunk = stack.pop()!;
|
|
38
|
+
importedCss(chunk).forEach(file => result.add(file));
|
|
39
|
+
|
|
40
|
+
for (const fileName of [...chunk.imports, ...chunk.dynamicImports]) {
|
|
41
|
+
const imported = bundle[fileName];
|
|
42
|
+
if (imported?.type === 'chunk' && !visited.has(fileName)) {
|
|
43
|
+
visited.add(fileName);
|
|
44
|
+
stack.push(imported);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return result;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function importedCss(chunk: OutputChunk): ReadonlySet<string> {
|
|
53
|
+
return (
|
|
54
|
+
// Vite adds `viteMetadata` to Rolldown chunks; cast because its type augmentation is not in scope here.
|
|
55
|
+
(chunk as { viteMetadata?: { importedCss?: Set<string> } }).viteMetadata?.importedCss ??
|
|
56
|
+
new Set<string>()
|
|
57
|
+
);
|
|
58
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Replaces `/` with `-` so scoped packages stay flat in Rolldown output.
|
|
3
|
+
* Without this, `@scope/foo` emits into a subdirectory and its require()
|
|
4
|
+
* calls use `../` paths that don't match the IIFE's flat module keys.
|
|
5
|
+
*/
|
|
6
|
+
export function flatten(dep: string): string {
|
|
7
|
+
return dep.replace(/\//g, '-');
|
|
8
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './shared-dependencies-plugin';
|
|
@@ -1,16 +1,10 @@
|
|
|
1
1
|
import crypto from 'crypto';
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import { Plugin } from 'vite';
|
|
4
|
-
import { bundleConstants, generateExposedDependenciesMetadata } from '
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
* Without this, `@scope/foo` emits into a subdirectory and its require()
|
|
9
|
-
* calls use `../` paths that don't match the IIFE's flat module keys.
|
|
10
|
-
*/
|
|
11
|
-
function flatName(dep: string) {
|
|
12
|
-
return dep.replace('/', '-');
|
|
13
|
-
}
|
|
4
|
+
import { bundleConstants, generateExposedDependenciesMetadata, sortSharedCss } from '../../../core';
|
|
5
|
+
import { assembleIife, Expose, ModuleFactory } from './assemble-iife';
|
|
6
|
+
import { assertNoDynamicCss } from './assert-no-dynamic-css';
|
|
7
|
+
import { flatten } from './flatten';
|
|
14
8
|
|
|
15
9
|
export interface SharedDependenciesPluginOptions {
|
|
16
10
|
dependencies: Record<string, string>;
|
|
@@ -18,9 +12,8 @@ export interface SharedDependenciesPluginOptions {
|
|
|
18
12
|
metadataDir?: string;
|
|
19
13
|
}
|
|
20
14
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
15
|
+
// Suffix for the CJS entry files emitted by `entryFileNames` below.
|
|
16
|
+
const ENTRY_FILE_SUFFIX = '.cjs.js';
|
|
24
17
|
|
|
25
18
|
export function sharedDependenciesPlugin({
|
|
26
19
|
dependencies,
|
|
@@ -44,7 +37,7 @@ export function sharedDependenciesPlugin({
|
|
|
44
37
|
|
|
45
38
|
const input: Record<string, string> = {};
|
|
46
39
|
for (const dependency of dependencyNames) {
|
|
47
|
-
input[
|
|
40
|
+
input[flatten(dependency)] = dependency;
|
|
48
41
|
}
|
|
49
42
|
for (const name of cssInputNames) {
|
|
50
43
|
input[name] = CSS_VIRTUAL_PREFIX + name;
|
|
@@ -53,7 +46,7 @@ export function sharedDependenciesPlugin({
|
|
|
53
46
|
return {
|
|
54
47
|
// Relative base so CSS font URLs resolve from the CSS file's directory, not site root
|
|
55
48
|
base: './',
|
|
56
|
-
// Must match host build mode
|
|
49
|
+
// Must match host build mode; mismatch causes react-dom/client usingClientEntryPoint errors
|
|
57
50
|
define: {
|
|
58
51
|
'process.env.NODE_ENV': JSON.stringify(env.mode),
|
|
59
52
|
},
|
|
@@ -69,12 +62,12 @@ export function sharedDependenciesPlugin({
|
|
|
69
62
|
*/
|
|
70
63
|
format: 'cjs',
|
|
71
64
|
exports: 'named',
|
|
72
|
-
entryFileNames:
|
|
65
|
+
entryFileNames: `[name]${ENTRY_FILE_SUFFIX}`,
|
|
73
66
|
chunkFileNames: '_[name]-[hash].js',
|
|
74
67
|
assetFileNames: assetInfo => {
|
|
75
68
|
const rawName = assetInfo.names?.[0] ?? '';
|
|
76
69
|
const ext = rawName.split('.').pop() ?? '';
|
|
77
|
-
// Strip scope prefix added by
|
|
70
|
+
// Strip scope prefix added by flatten (e.g. @servicetitan-anvil2 to anvil2)
|
|
78
71
|
const name = rawName
|
|
79
72
|
.replace(/^@[^-]+-/, '')
|
|
80
73
|
.replace(/\.[^.]+$/, '');
|
|
@@ -120,41 +113,39 @@ export function sharedDependenciesPlugin({
|
|
|
120
113
|
},
|
|
121
114
|
|
|
122
115
|
generateBundle(_options, bundle) {
|
|
123
|
-
|
|
124
|
-
|
|
116
|
+
assertNoDynamicCss(bundle);
|
|
117
|
+
|
|
118
|
+
const modules: ModuleFactory[] = [];
|
|
119
|
+
const exposes: Expose[] = [];
|
|
125
120
|
|
|
126
121
|
for (const [fileName, chunk] of Object.entries(bundle)) {
|
|
127
122
|
if (chunk.type !== 'chunk') {
|
|
128
123
|
continue;
|
|
129
124
|
}
|
|
130
125
|
if (!chunk.isEntry) {
|
|
131
|
-
|
|
132
|
-
`'./${fileName}': function(module, exports, require) {\n${indent(12)}${chunk.code}\n${indent(8)}}`
|
|
133
|
-
);
|
|
126
|
+
modules.push({ id: `./${fileName}`, code: chunk.code });
|
|
134
127
|
delete bundle[fileName];
|
|
135
128
|
}
|
|
136
129
|
}
|
|
137
130
|
|
|
138
131
|
for (const [dependency, variable] of Object.entries(dependencies)) {
|
|
139
|
-
const entryFileName = `${
|
|
132
|
+
const entryFileName = `${flatten(dependency)}${ENTRY_FILE_SUFFIX}`;
|
|
140
133
|
const chunk = bundle[entryFileName];
|
|
141
134
|
if (chunk?.type !== 'chunk') {
|
|
142
135
|
throw new Error(
|
|
143
136
|
`Expected entry chunk for ${dependency}, got type: ${chunk?.type ?? 'undefined'}`
|
|
144
137
|
);
|
|
145
138
|
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
);
|
|
149
|
-
exposes.push(`expose('${variable}', '${dependency}');`);
|
|
139
|
+
modules.push({ id: dependency, code: chunk.code });
|
|
140
|
+
exposes.push({ variable, dependency });
|
|
150
141
|
delete bundle[entryFileName];
|
|
151
142
|
}
|
|
152
143
|
|
|
153
144
|
for (const name of cssInputNames) {
|
|
154
|
-
delete bundle[`${name}
|
|
145
|
+
delete bundle[`${name}${ENTRY_FILE_SUFFIX}`];
|
|
155
146
|
}
|
|
156
147
|
|
|
157
|
-
const code =
|
|
148
|
+
const code = assembleIife(modules, exposes);
|
|
158
149
|
const hash = crypto.createHash('md5').update(code).digest('hex').slice(0, 20);
|
|
159
150
|
const sharedFileName = isProduction ? `shared.${hash}.bundle.js` : 'shared.bundle.js';
|
|
160
151
|
|
|
@@ -164,7 +155,9 @@ export function sharedDependenciesPlugin({
|
|
|
164
155
|
source: code,
|
|
165
156
|
});
|
|
166
157
|
|
|
167
|
-
const cssFiles =
|
|
158
|
+
const cssFiles = sortSharedCss(
|
|
159
|
+
Object.keys(bundle).filter(f => f.endsWith('.bundle.css'))
|
|
160
|
+
);
|
|
168
161
|
const entrypoints = { css: cssFiles, js: [sharedFileName] };
|
|
169
162
|
this.emitFile({
|
|
170
163
|
type: 'asset',
|
|
@@ -178,7 +171,7 @@ export function sharedDependenciesPlugin({
|
|
|
178
171
|
/*
|
|
179
172
|
* dir is always set when build.outDir is configured (our case).
|
|
180
173
|
* Rolldown types it as optional, but falling back to '' would
|
|
181
|
-
* silently resolve to cwd
|
|
174
|
+
* silently resolve to cwd; better to crash than write wrong metadata.
|
|
182
175
|
*/
|
|
183
176
|
generateExposedDependenciesMetadata(metadataDir, () =>
|
|
184
177
|
path.resolve(options.dir!, 'entrypoints.json')
|
|
@@ -187,87 +180,3 @@ export function sharedDependenciesPlugin({
|
|
|
187
180
|
: undefined,
|
|
188
181
|
};
|
|
189
182
|
}
|
|
190
|
-
|
|
191
|
-
function assembleIIFE(factories: string[], exposes: string[]): string {
|
|
192
|
-
return `\
|
|
193
|
-
(function () {
|
|
194
|
-
const STORAGE_KEY = Symbol.for('SERVICETITAN_EXPOSE_LOADER_STORAGE');
|
|
195
|
-
const g = globalThis;
|
|
196
|
-
|
|
197
|
-
if (g[STORAGE_KEY] === undefined) {
|
|
198
|
-
g[STORAGE_KEY] = Object.assign(Object.create(null), {
|
|
199
|
-
clear(scope) {
|
|
200
|
-
delete this[scope];
|
|
201
|
-
},
|
|
202
|
-
});
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
var storage = g[STORAGE_KEY];
|
|
206
|
-
|
|
207
|
-
var modules = {
|
|
208
|
-
${factories.join(`,\n${indent(8)}`)}
|
|
209
|
-
};
|
|
210
|
-
|
|
211
|
-
function createScopedRequire(scope) {
|
|
212
|
-
const cache = (storage[scope] = storage[scope] || Object.create(null));
|
|
213
|
-
|
|
214
|
-
function require(id) {
|
|
215
|
-
if (cache[id]) {
|
|
216
|
-
return cache[id].exports;
|
|
217
|
-
}
|
|
218
|
-
if (!modules[id]) {
|
|
219
|
-
throw new Error('Module not found: ' + id);
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
const module = (cache[id] = { id, loaded: false, exports: {} });
|
|
223
|
-
modules[id](module, module.exports, require);
|
|
224
|
-
module.loaded = true;
|
|
225
|
-
|
|
226
|
-
const keys = Object.keys(module.exports);
|
|
227
|
-
if (module.exports.__esModule && keys.length === 1 && keys[0] === 'default') {
|
|
228
|
-
module.exports = module.exports.default;
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
return module.exports;
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
Object.setPrototypeOf(require, {
|
|
235
|
-
resolve(id) {
|
|
236
|
-
return id;
|
|
237
|
-
},
|
|
238
|
-
});
|
|
239
|
-
return require;
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
function expose(path, moduleId) {
|
|
243
|
-
const parts = path.split('.');
|
|
244
|
-
let obj = g;
|
|
245
|
-
|
|
246
|
-
for (let i = 0; i < parts.length - 1; i++) {
|
|
247
|
-
if (obj[parts[i]] === undefined) {
|
|
248
|
-
obj[parts[i]] = Object.create(null);
|
|
249
|
-
}
|
|
250
|
-
obj = obj[parts[i]];
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
obj[parts[parts.length - 1]] = new Proxy(
|
|
254
|
-
Object.assign(Object.create(null), {
|
|
255
|
-
getStorage() {
|
|
256
|
-
return storage;
|
|
257
|
-
},
|
|
258
|
-
}),
|
|
259
|
-
{
|
|
260
|
-
get(target, scope, receiver) {
|
|
261
|
-
if (scope === 'getStorage') {
|
|
262
|
-
return Reflect.get(target, scope, receiver);
|
|
263
|
-
}
|
|
264
|
-
return createScopedRequire(scope)(moduleId);
|
|
265
|
-
},
|
|
266
|
-
}
|
|
267
|
-
);
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
${exposes.join(`\n${indent(4)}`)}
|
|
271
|
-
})();
|
|
272
|
-
`;
|
|
273
|
-
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Load an ES module from CommonJS output. SWC rewrites a plain dynamic
|
|
3
|
+
* import() to require(), which throws on ESM-only packages (those whose
|
|
4
|
+
* package exports have no "require" entry, e.g. vite-plugin-istanbul). Hiding
|
|
5
|
+
* the import() inside a Function keeps it native so it isn't rewritten.
|
|
6
|
+
*/
|
|
7
|
+
// eslint-disable-next-line @typescript-eslint/no-implied-eval
|
|
8
|
+
const nativeImport = new Function('specifier', 'return import(specifier)') as (
|
|
9
|
+
specifier: string
|
|
10
|
+
) => Promise<unknown>;
|
|
11
|
+
|
|
12
|
+
/* istanbul ignore next -- native import can't run in jest; verified at runtime */
|
|
13
|
+
export function importEsm<T = unknown>(specifier: string): Promise<T> {
|
|
14
|
+
return nativeImport(specifier) as Promise<T>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* rolldown@1.x ships an incomplete `TransformOptions` for its `rolldown/utils` entry: it
|
|
3
|
+
* omits the `minify` and `legalComments` oxc transform options, even though the runtime
|
|
4
|
+
* honors both. Vite surfaces these options through `OxcOptions` (`Omit<TransformOptions, …>`),
|
|
5
|
+
* so the gap shows up wherever we set `oxc` (e.g. base-config.ts, build-shared-dependencies.ts).
|
|
6
|
+
*
|
|
7
|
+
* Until rolldown's published types include them, augment `TransformOptions` to match the
|
|
8
|
+
* runtime. (`moduleResolution: "node10"` previously hid this by failing to resolve
|
|
9
|
+
* `rolldown/utils` at all, leaving `OxcOptions` as `any`.)
|
|
10
|
+
*/
|
|
11
|
+
declare module 'rolldown/utils' {
|
|
12
|
+
import type { MinifyOptions } from 'rolldown/utils';
|
|
13
|
+
|
|
14
|
+
interface TransformOptions {
|
|
15
|
+
minify?: boolean | MinifyOptions;
|
|
16
|
+
legalComments?: 'none' | 'inline' | 'eof' | 'external' | { linked: string };
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export {};
|
|
@@ -231,11 +231,10 @@ describe('[startup] Cli Utils', () => {
|
|
|
231
231
|
await subject();
|
|
232
232
|
|
|
233
233
|
expect(createWebpackConfig).toHaveBeenCalledWith(
|
|
234
|
-
expect.anything(),
|
|
235
234
|
expect.objectContaining({
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
})
|
|
235
|
+
configuration: expect.objectContaining({ output: prodOutput }),
|
|
236
|
+
}),
|
|
237
|
+
expect.objectContaining({ emitExposedDependencies: true })
|
|
239
238
|
);
|
|
240
239
|
});
|
|
241
240
|
}
|
|
@@ -263,11 +262,12 @@ describe('[startup] Cli Utils', () => {
|
|
|
263
262
|
await subject();
|
|
264
263
|
|
|
265
264
|
expect(createWebpackConfig).toHaveBeenCalledWith(
|
|
266
|
-
expect.anything(),
|
|
267
265
|
expect.objectContaining({
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
266
|
+
configuration: expect.objectContaining({
|
|
267
|
+
output: devOutput,
|
|
268
|
+
}),
|
|
269
|
+
}),
|
|
270
|
+
expect.objectContaining({ emitExposedDependencies: true })
|
|
271
271
|
);
|
|
272
272
|
});
|
|
273
273
|
});
|
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
pick,
|
|
24
24
|
} from '../../utils';
|
|
25
25
|
import { miniCssPluginStyleRules } from '../__mocks__';
|
|
26
|
-
import { createWebpackConfig } from '../
|
|
26
|
+
import { createWebpackConfig } from '../create-webpack-config';
|
|
27
27
|
import { getModuleEntryPath } from '../utils';
|
|
28
28
|
|
|
29
29
|
jest.mock('fs', () => fs);
|
|
@@ -336,6 +336,19 @@ describe(`[startup] ${createWebpackConfig.name}`, () => {
|
|
|
336
336
|
name: 'anvil2',
|
|
337
337
|
chunks: 'all',
|
|
338
338
|
enforce: true,
|
|
339
|
+
priority: 10,
|
|
340
|
+
});
|
|
341
|
+
});
|
|
342
|
+
|
|
343
|
+
describe('in production', () => {
|
|
344
|
+
beforeEach(() => (overrides.configuration!.mode = 'production'));
|
|
345
|
+
|
|
346
|
+
test('ranks anvil2 above the servicetitan vendor group', () => {
|
|
347
|
+
const { cacheGroups } = subject().optimization!.splitChunks as any;
|
|
348
|
+
|
|
349
|
+
expect(cacheGroups.anvil2.priority).toBeGreaterThan(
|
|
350
|
+
cacheGroups.servicetitan.priority ?? 0
|
|
351
|
+
);
|
|
339
352
|
});
|
|
340
353
|
});
|
|
341
354
|
|
|
@@ -350,12 +363,12 @@ describe(`[startup] ${createWebpackConfig.name}`, () => {
|
|
|
350
363
|
});
|
|
351
364
|
|
|
352
365
|
describe('with custom "output.path"', () => {
|
|
353
|
-
const
|
|
366
|
+
const outputPath = path.resolve(process.cwd(), 'foo');
|
|
354
367
|
|
|
355
|
-
beforeEach(() => (
|
|
368
|
+
beforeEach(() => (overrides.configuration!.output = { path: outputPath }));
|
|
356
369
|
|
|
357
|
-
test('
|
|
358
|
-
expect(subject().output?.path).toBe(path.join(
|
|
370
|
+
test('uses custom "output.path"', () => {
|
|
371
|
+
expect(subject().output?.path).toBe(path.join(outputPath, 'shared'));
|
|
359
372
|
});
|
|
360
373
|
});
|
|
361
374
|
|
|
@@ -370,6 +383,42 @@ describe(`[startup] ${createWebpackConfig.name}`, () => {
|
|
|
370
383
|
);
|
|
371
384
|
});
|
|
372
385
|
|
|
386
|
+
test('WebpackAssetsManifest plugin moves design-system CSS before anvil2 CSS', () => {
|
|
387
|
+
const assets = {
|
|
388
|
+
entrypoints: {
|
|
389
|
+
'shared': { assets: { css: ['anvil2.bundle.css'] } },
|
|
390
|
+
'design-system': { assets: { css: ['design-system.bundle.css'] } },
|
|
391
|
+
},
|
|
392
|
+
};
|
|
393
|
+
|
|
394
|
+
subject();
|
|
395
|
+
|
|
396
|
+
const transform: any =
|
|
397
|
+
jest.mocked(WebpackAssetsManifest).mock.calls[0][0]?.transform;
|
|
398
|
+
expect(transform(assets)).toEqual(
|
|
399
|
+
expect.objectContaining({
|
|
400
|
+
css: ['design-system.bundle.css', 'anvil2.bundle.css'],
|
|
401
|
+
})
|
|
402
|
+
);
|
|
403
|
+
});
|
|
404
|
+
|
|
405
|
+
test('WebpackAssetsManifest plugin dedupes a chunk shared by entry points', () => {
|
|
406
|
+
const assets = {
|
|
407
|
+
entrypoints: {
|
|
408
|
+
'shared': { assets: { css: ['servicetitan.bundle.css'] } },
|
|
409
|
+
'design-system': { assets: { css: ['servicetitan.bundle.css'] } },
|
|
410
|
+
},
|
|
411
|
+
};
|
|
412
|
+
|
|
413
|
+
subject();
|
|
414
|
+
|
|
415
|
+
const transform: any =
|
|
416
|
+
jest.mocked(WebpackAssetsManifest).mock.calls[0][0]?.transform;
|
|
417
|
+
expect(transform(assets)).toEqual(
|
|
418
|
+
expect.objectContaining({ css: ['servicetitan.bundle.css'] })
|
|
419
|
+
);
|
|
420
|
+
});
|
|
421
|
+
|
|
373
422
|
test('generates exposed-dependencies-metadata.json when WebpackAssetsManifest plugin is done', () => {
|
|
374
423
|
const entryPointsPath = path.join(process.cwd(), destination, 'entrypoints.json');
|
|
375
424
|
const manifest = { getOutputPath: () => entryPointsPath };
|