@servicetitan/startup 34.2.1 → 34.3.0-beta.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/dist/cli/commands/build.d.ts +16 -0
- package/dist/cli/commands/build.d.ts.map +1 -1
- package/dist/cli/commands/build.js +15 -2
- package/dist/cli/commands/build.js.map +1 -1
- package/dist/cli/commands/bundle-vite.d.ts +66 -0
- package/dist/cli/commands/bundle-vite.d.ts.map +1 -0
- package/dist/cli/commands/bundle-vite.js +184 -0
- package/dist/cli/commands/bundle-vite.js.map +1 -0
- package/dist/cli/commands/get-command.d.ts.map +1 -1
- package/dist/cli/commands/get-command.js +2 -0
- package/dist/cli/commands/get-command.js.map +1 -1
- package/dist/cli/commands/mfe-check.d.ts.map +1 -1
- package/dist/cli/commands/mfe-check.js +2 -2
- package/dist/cli/commands/mfe-check.js.map +1 -1
- package/dist/cli/commands/mfe-generate-metadata.js +2 -2
- package/dist/cli/commands/mfe-generate-metadata.js.map +1 -1
- package/dist/cli/commands/mfe-package-publish.js.map +1 -1
- package/dist/cli/commands/start.d.ts +8 -0
- package/dist/cli/commands/start.d.ts.map +1 -1
- package/dist/cli/commands/start.js +8 -2
- package/dist/cli/commands/start.js.map +1 -1
- package/dist/cli/tasks/swc-compile-package.js +127 -0
- package/dist/cli/tasks/swc-compile-package.js.map +1 -0
- package/dist/cli/tasks/tsc-compile-package.js +46 -0
- package/dist/cli/tasks/tsc-compile-package.js.map +1 -0
- package/dist/cli/tasks/tsc-compile.js +68 -0
- package/dist/cli/tasks/tsc-compile.js.map +1 -0
- package/dist/cli/utils/bundle.d.ts +2 -5
- package/dist/cli/utils/bundle.d.ts.map +1 -1
- package/dist/cli/utils/bundle.js +18 -98
- package/dist/cli/utils/bundle.js.map +1 -1
- package/dist/core/check-resource/check-resource.d.ts +3 -0
- package/dist/core/check-resource/check-resource.d.ts.map +1 -0
- package/dist/core/check-resource/check-resource.js +40 -0
- package/dist/core/check-resource/check-resource.js.map +1 -0
- package/dist/core/check-resource/get-package-json.d.ts.map +1 -0
- package/dist/core/check-resource/get-package-json.js +37 -0
- package/dist/core/check-resource/get-package-json.js.map +1 -0
- package/dist/core/check-resource/index.d.ts +2 -0
- package/dist/core/check-resource/index.d.ts.map +1 -0
- package/dist/core/check-resource/index.js +13 -0
- package/dist/core/check-resource/index.js.map +1 -0
- package/dist/core/check-resource/is-optional-peer-dependency.d.ts.map +1 -0
- package/dist/core/check-resource/is-optional-peer-dependency.js +27 -0
- package/dist/core/check-resource/is-optional-peer-dependency.js.map +1 -0
- package/dist/core/check-resource/is-optional-react-dom-peer-dependency.d.ts.map +1 -0
- package/dist/core/check-resource/is-optional-react-dom-peer-dependency.js +15 -0
- package/dist/core/check-resource/is-optional-react-dom-peer-dependency.js.map +1 -0
- package/dist/core/context.d.ts +14 -0
- package/dist/core/context.d.ts.map +1 -0
- package/dist/core/context.js +62 -0
- package/dist/core/context.js.map +1 -0
- package/dist/core/defines/exposed-dependencies.d.ts +5 -0
- package/dist/core/defines/exposed-dependencies.d.ts.map +1 -0
- package/dist/core/defines/exposed-dependencies.js +26 -0
- package/dist/core/defines/exposed-dependencies.js.map +1 -0
- package/dist/core/defines/exposed-instance-dependencies.d.ts +5 -0
- package/dist/core/defines/exposed-instance-dependencies.d.ts.map +1 -0
- package/dist/core/defines/exposed-instance-dependencies.js +29 -0
- package/dist/core/defines/exposed-instance-dependencies.js.map +1 -0
- package/dist/core/defines/index.d.ts +4 -0
- package/dist/core/defines/index.d.ts.map +1 -0
- package/dist/core/defines/index.js +26 -0
- package/dist/core/defines/index.js.map +1 -0
- package/dist/core/defines/web-component-name.d.ts +5 -0
- package/dist/core/defines/web-component-name.d.ts.map +1 -0
- package/dist/core/defines/web-component-name.js +23 -0
- package/dist/core/defines/web-component-name.js.map +1 -0
- package/dist/core/externals.d.ts +3 -0
- package/dist/core/externals.d.ts.map +1 -0
- package/dist/core/externals.js +29 -0
- package/dist/core/externals.js.map +1 -0
- package/dist/core/get-exposed-dependencies-entry-points.d.ts +11 -0
- package/dist/core/get-exposed-dependencies-entry-points.d.ts.map +1 -0
- package/dist/core/get-exposed-dependencies-entry-points.js +82 -0
- package/dist/core/get-exposed-dependencies-entry-points.js.map +1 -0
- package/dist/core/index.d.ts +9 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +26 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/types.d.ts +55 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/types.js +6 -0
- package/dist/core/types.js.map +1 -0
- package/dist/core/utils/build-metadata.d.ts.map +1 -0
- package/dist/core/utils/build-metadata.js +50 -0
- package/dist/core/utils/build-metadata.js.map +1 -0
- package/dist/core/utils/generate-metadata.d.ts +3 -0
- package/dist/core/utils/generate-metadata.d.ts.map +1 -0
- package/dist/core/utils/generate-metadata.js +40 -0
- package/dist/core/utils/generate-metadata.js.map +1 -0
- package/dist/core/utils/get-bundle-type.d.ts +3 -0
- package/dist/core/utils/get-bundle-type.d.ts.map +1 -0
- package/dist/core/utils/get-bundle-type.js +27 -0
- package/dist/core/utils/get-bundle-type.js.map +1 -0
- package/dist/core/utils/get-exposed-dependencies.d.ts.map +1 -0
- package/dist/core/utils/get-exposed-dependencies.js +21 -0
- package/dist/core/utils/get-exposed-dependencies.js.map +1 -0
- package/dist/core/utils/get-launchdarkly-sdk-version.d.ts.map +1 -0
- package/dist/core/utils/get-launchdarkly-sdk-version.js +26 -0
- package/dist/core/utils/get-launchdarkly-sdk-version.js.map +1 -0
- package/dist/core/utils/get-output-path.d.ts +3 -0
- package/dist/core/utils/get-output-path.d.ts.map +1 -0
- package/dist/core/utils/get-output-path.js +32 -0
- package/dist/core/utils/get-output-path.js.map +1 -0
- package/dist/core/utils/get-web-components-version.d.ts.map +1 -0
- package/dist/core/utils/get-web-components-version.js +22 -0
- package/dist/core/utils/get-web-components-version.js.map +1 -0
- package/dist/core/utils/index.d.ts +9 -0
- package/dist/core/utils/index.d.ts.map +1 -0
- package/dist/core/utils/index.js +27 -0
- package/dist/core/utils/index.js.map +1 -0
- package/dist/core/utils/stringify-config.d.ts +2 -0
- package/dist/core/utils/stringify-config.d.ts.map +1 -0
- package/dist/core/utils/stringify-config.js +35 -0
- package/dist/core/utils/stringify-config.js.map +1 -0
- package/dist/core/virtual-modules.d.ts +9 -0
- package/dist/core/virtual-modules.d.ts.map +1 -0
- package/dist/core/virtual-modules.js +84 -0
- package/dist/core/virtual-modules.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/storybook-config/webpack-final.d.ts +1 -1
- package/dist/storybook-config/webpack-final.d.ts.map +1 -1
- package/dist/storybook-config/webpack-final.js +18 -6
- package/dist/storybook-config/webpack-final.js.map +1 -1
- package/dist/utils/get-configuration.d.ts +28 -0
- package/dist/utils/get-configuration.d.ts.map +1 -1
- package/dist/utils/get-configuration.js +42 -1
- package/dist/utils/get-configuration.js.map +1 -1
- package/dist/utils/get-package-data.d.ts.map +1 -1
- package/dist/utils/get-package-data.js +3 -2
- package/dist/utils/get-package-data.js.map +1 -1
- package/dist/vite/base-config.d.ts +4 -0
- package/dist/vite/base-config.d.ts.map +1 -0
- package/dist/vite/base-config.js +65 -0
- package/dist/vite/base-config.js.map +1 -0
- package/dist/vite/build-shared-deps.d.ts +3 -0
- package/dist/vite/build-shared-deps.d.ts.map +1 -0
- package/dist/vite/build-shared-deps.js +310 -0
- package/dist/vite/build-shared-deps.js.map +1 -0
- package/dist/vite/create-vite-config.d.ts +3 -0
- package/dist/vite/create-vite-config.d.ts.map +1 -0
- package/dist/vite/create-vite-config.js +52 -0
- package/dist/vite/create-vite-config.js.map +1 -0
- package/dist/vite/define-config.d.ts +12 -0
- package/dist/vite/define-config.d.ts.map +1 -0
- package/dist/vite/define-config.js +15 -0
- package/dist/vite/define-config.js.map +1 -0
- package/dist/vite/load-config-file.d.ts +6 -0
- package/dist/vite/load-config-file.d.ts.map +1 -0
- package/dist/vite/load-config-file.js +107 -0
- package/dist/vite/load-config-file.js.map +1 -0
- package/dist/vite/merge-config.d.ts +6 -0
- package/dist/vite/merge-config.d.ts.map +1 -0
- package/dist/vite/merge-config.js +106 -0
- package/dist/vite/merge-config.js.map +1 -0
- package/dist/vite/plugins/css-injector-plugin.d.ts +15 -0
- package/dist/vite/plugins/css-injector-plugin.d.ts.map +1 -0
- package/dist/vite/plugins/css-injector-plugin.js +76 -0
- package/dist/vite/plugins/css-injector-plugin.js.map +1 -0
- package/dist/vite/plugins/dev-bundle-routing-plugin.d.ts +7 -0
- package/dist/vite/plugins/dev-bundle-routing-plugin.d.ts.map +1 -0
- package/dist/vite/plugins/dev-bundle-routing-plugin.js +48 -0
- package/dist/vite/plugins/dev-bundle-routing-plugin.js.map +1 -0
- package/dist/vite/plugins/dev-server-routing-plugin.d.ts +12 -0
- package/dist/vite/plugins/dev-server-routing-plugin.d.ts.map +1 -0
- package/dist/vite/plugins/dev-server-routing-plugin.js +85 -0
- package/dist/vite/plugins/dev-server-routing-plugin.js.map +1 -0
- package/dist/vite/plugins/externals-plugin.d.ts +4 -0
- package/dist/vite/plugins/externals-plugin.d.ts.map +1 -0
- package/dist/vite/plugins/externals-plugin.js +39 -0
- package/dist/vite/plugins/externals-plugin.js.map +1 -0
- package/dist/vite/plugins/full-bundle-proxy-plugin.d.ts +14 -0
- package/dist/vite/plugins/full-bundle-proxy-plugin.d.ts.map +1 -0
- package/dist/vite/plugins/full-bundle-proxy-plugin.js +48 -0
- package/dist/vite/plugins/full-bundle-proxy-plugin.js.map +1 -0
- package/dist/vite/plugins/html-plugin.d.ts +5 -0
- package/dist/vite/plugins/html-plugin.d.ts.map +1 -0
- package/dist/vite/plugins/html-plugin.js +74 -0
- package/dist/vite/plugins/html-plugin.js.map +1 -0
- package/dist/vite/plugins/ignore-modules-plugin.d.ts +4 -0
- package/dist/vite/plugins/ignore-modules-plugin.d.ts.map +1 -0
- package/dist/vite/plugins/ignore-modules-plugin.js +30 -0
- package/dist/vite/plugins/ignore-modules-plugin.js.map +1 -0
- package/dist/vite/plugins/index.d.ts +10 -0
- package/dist/vite/plugins/index.d.ts.map +1 -0
- package/dist/vite/plugins/index.js +28 -0
- package/dist/vite/plugins/index.js.map +1 -0
- package/dist/vite/plugins/metadata-plugin.d.ts +4 -0
- package/dist/vite/plugins/metadata-plugin.d.ts.map +1 -0
- package/dist/vite/plugins/metadata-plugin.js +86 -0
- package/dist/vite/plugins/metadata-plugin.js.map +1 -0
- package/dist/vite/plugins/outdir-rewrite-plugin.d.ts +9 -0
- package/dist/vite/plugins/outdir-rewrite-plugin.d.ts.map +1 -0
- package/dist/vite/plugins/preview-static-files-plugin.d.ts +9 -0
- package/dist/vite/plugins/preview-static-files-plugin.d.ts.map +1 -0
- package/dist/vite/plugins/preview-static-files-plugin.js +50 -0
- package/dist/vite/plugins/preview-static-files-plugin.js.map +1 -0
- package/dist/vite/plugins/shared-deps-dev-server-plugin.d.ts +11 -0
- package/dist/vite/plugins/shared-deps-dev-server-plugin.d.ts.map +1 -0
- package/dist/vite/plugins/shared-deps-rewrite-plugin.d.ts +10 -0
- package/dist/vite/plugins/shared-deps-rewrite-plugin.d.ts.map +1 -0
- package/dist/vite/plugins/shared-deps-rewrite-plugin.js +51 -0
- package/dist/vite/plugins/shared-deps-rewrite-plugin.js.map +1 -0
- package/dist/vite/plugins/style-urls-plugin.d.ts +4 -0
- package/dist/vite/plugins/style-urls-plugin.d.ts.map +1 -0
- package/dist/vite/plugins/style-urls-plugin.js +29 -0
- package/dist/vite/plugins/style-urls-plugin.js.map +1 -0
- package/dist/vite/plugins/svgr-plugin.d.ts +4 -0
- package/dist/vite/plugins/svgr-plugin.d.ts.map +1 -0
- package/dist/vite/plugins/svgr-plugin.js +31 -0
- package/dist/vite/plugins/svgr-plugin.js.map +1 -0
- package/dist/vite/plugins/virtual-modules-plugin.d.ts +4 -0
- package/dist/vite/plugins/virtual-modules-plugin.d.ts.map +1 -0
- package/dist/vite/plugins/virtual-modules-plugin.js +71 -0
- package/dist/vite/plugins/virtual-modules-plugin.js.map +1 -0
- package/dist/webpack/configs/amd-config.d.ts +3 -2
- package/dist/webpack/configs/amd-config.d.ts.map +1 -1
- package/dist/webpack/configs/amd-config.js.map +1 -1
- package/dist/webpack/configs/cache-config.d.ts +3 -2
- package/dist/webpack/configs/cache-config.d.ts.map +1 -1
- package/dist/webpack/configs/cache-config.js +1 -1
- package/dist/webpack/configs/cache-config.js.map +1 -1
- package/dist/webpack/configs/dev-server-config.d.ts +3 -2
- package/dist/webpack/configs/dev-server-config.d.ts.map +1 -1
- package/dist/webpack/configs/dev-server-config.js +1 -1
- package/dist/webpack/configs/dev-server-config.js.map +1 -1
- package/dist/webpack/configs/devtool-config.d.ts +3 -2
- package/dist/webpack/configs/devtool-config.d.ts.map +1 -1
- package/dist/webpack/configs/devtool-config.js +1 -1
- package/dist/webpack/configs/devtool-config.js.map +1 -1
- package/dist/webpack/configs/entry.config.d.ts +3 -2
- package/dist/webpack/configs/entry.config.d.ts.map +1 -1
- package/dist/webpack/configs/entry.config.js +6 -5
- package/dist/webpack/configs/entry.config.js.map +1 -1
- package/dist/webpack/configs/externals-config.d.ts +3 -2
- package/dist/webpack/configs/externals-config.d.ts.map +1 -1
- package/dist/webpack/configs/externals-config.js +4 -14
- package/dist/webpack/configs/externals-config.js.map +1 -1
- package/dist/webpack/configs/index.d.ts +0 -1
- package/dist/webpack/configs/index.d.ts.map +1 -1
- package/dist/webpack/configs/index.js.map +1 -1
- package/dist/webpack/configs/loaders/css-loader.d.ts +2 -2
- package/dist/webpack/configs/loaders/css-loader.d.ts.map +1 -1
- package/dist/webpack/configs/loaders/css-loader.js +2 -1
- package/dist/webpack/configs/loaders/css-loader.js.map +1 -1
- package/dist/webpack/configs/loaders/style-loader.d.ts +2 -2
- package/dist/webpack/configs/loaders/style-loader.d.ts.map +1 -1
- package/dist/webpack/configs/loaders/style-loader.js +4 -1
- package/dist/webpack/configs/loaders/style-loader.js.map +1 -1
- package/dist/webpack/configs/module-config.d.ts +3 -2
- package/dist/webpack/configs/module-config.d.ts.map +1 -1
- package/dist/webpack/configs/module-config.js.map +1 -1
- package/dist/webpack/configs/optimization-config.d.ts +3 -2
- package/dist/webpack/configs/optimization-config.d.ts.map +1 -1
- package/dist/webpack/configs/optimization-config.js +10 -7
- package/dist/webpack/configs/optimization-config.js.map +1 -1
- package/dist/webpack/configs/output-config.d.ts +3 -2
- package/dist/webpack/configs/output-config.d.ts.map +1 -1
- package/dist/webpack/configs/output-config.js +15 -24
- package/dist/webpack/configs/output-config.js.map +1 -1
- package/dist/webpack/configs/plugins/assets-manifest-plugin.d.ts +3 -8
- package/dist/webpack/configs/plugins/assets-manifest-plugin.d.ts.map +1 -1
- package/dist/webpack/configs/plugins/assets-manifest-plugin.js +10 -47
- package/dist/webpack/configs/plugins/assets-manifest-plugin.js.map +1 -1
- package/dist/webpack/configs/plugins/bundle-analyser-plugin.d.ts +3 -2
- package/dist/webpack/configs/plugins/bundle-analyser-plugin.d.ts.map +1 -1
- package/dist/webpack/configs/plugins/bundle-analyser-plugin.js +6 -6
- package/dist/webpack/configs/plugins/bundle-analyser-plugin.js.map +1 -1
- package/dist/webpack/configs/plugins/define-exposed-dependencies-plugin.d.ts +3 -2
- package/dist/webpack/configs/plugins/define-exposed-dependencies-plugin.d.ts.map +1 -1
- package/dist/webpack/configs/plugins/define-exposed-dependencies-plugin.js +4 -13
- package/dist/webpack/configs/plugins/define-exposed-dependencies-plugin.js.map +1 -1
- package/dist/webpack/configs/plugins/define-exposed-instance-dependencies-plugin.d.ts +3 -2
- package/dist/webpack/configs/plugins/define-exposed-instance-dependencies-plugin.d.ts.map +1 -1
- package/dist/webpack/configs/plugins/define-exposed-instance-dependencies-plugin.js +4 -12
- package/dist/webpack/configs/plugins/define-exposed-instance-dependencies-plugin.js.map +1 -1
- package/dist/webpack/configs/plugins/define-web-component-name-plugin.d.ts +3 -2
- package/dist/webpack/configs/plugins/define-web-component-name-plugin.d.ts.map +1 -1
- package/dist/webpack/configs/plugins/define-web-component-name-plugin.js +4 -6
- package/dist/webpack/configs/plugins/define-web-component-name-plugin.js.map +1 -1
- package/dist/webpack/configs/plugins/filter-warnings-plugin.d.ts +3 -2
- package/dist/webpack/configs/plugins/filter-warnings-plugin.d.ts.map +1 -1
- package/dist/webpack/configs/plugins/filter-warnings-plugin.js +2 -2
- package/dist/webpack/configs/plugins/filter-warnings-plugin.js.map +1 -1
- package/dist/webpack/configs/plugins/html-plugin.d.ts +3 -2
- package/dist/webpack/configs/plugins/html-plugin.d.ts.map +1 -1
- package/dist/webpack/configs/plugins/html-plugin.js +5 -2
- package/dist/webpack/configs/plugins/html-plugin.js.map +1 -1
- package/dist/webpack/configs/plugins/html-tags-plugin.d.ts +3 -2
- package/dist/webpack/configs/plugins/html-tags-plugin.d.ts.map +1 -1
- package/dist/webpack/configs/plugins/html-tags-plugin.js +8 -19
- package/dist/webpack/configs/plugins/html-tags-plugin.js.map +1 -1
- package/dist/webpack/configs/plugins/ignore-plugin/get-package-json.js +1 -1
- package/dist/webpack/configs/plugins/ignore-plugin/get-package-json.js.map +1 -1
- package/dist/webpack/configs/plugins/ignore-plugin/ignore-plugin.d.ts +17 -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 +45 -6
- package/dist/webpack/configs/plugins/ignore-plugin/ignore-plugin.js.map +1 -1
- package/dist/webpack/configs/plugins/mini-css-extract-plugin.d.ts +3 -2
- package/dist/webpack/configs/plugins/mini-css-extract-plugin.d.ts.map +1 -1
- package/dist/webpack/configs/plugins/mini-css-extract-plugin.js +4 -2
- package/dist/webpack/configs/plugins/mini-css-extract-plugin.js.map +1 -1
- package/dist/webpack/configs/plugins/moment-locales-plugin.d.ts +3 -2
- package/dist/webpack/configs/plugins/moment-locales-plugin.d.ts.map +1 -1
- package/dist/webpack/configs/plugins/moment-locales-plugin.js.map +1 -1
- package/dist/webpack/configs/plugins/remove-empty-scripts-plugin.d.ts +3 -2
- package/dist/webpack/configs/plugins/remove-empty-scripts-plugin.d.ts.map +1 -1
- package/dist/webpack/configs/plugins/remove-empty-scripts-plugin.js +1 -1
- package/dist/webpack/configs/plugins/remove-empty-scripts-plugin.js.map +1 -1
- package/dist/webpack/configs/plugins/virtual-modules-plugin.d.ts +3 -3
- package/dist/webpack/configs/plugins/virtual-modules-plugin.d.ts.map +1 -1
- package/dist/webpack/configs/plugins/virtual-modules-plugin.js +13 -56
- package/dist/webpack/configs/plugins/virtual-modules-plugin.js.map +1 -1
- package/dist/webpack/configs/plugins/watch-run-plugin.d.ts +3 -2
- package/dist/webpack/configs/plugins/watch-run-plugin.d.ts.map +1 -1
- package/dist/webpack/configs/plugins/watch-run-plugin.js.map +1 -1
- package/dist/webpack/configs/plugins-config.d.ts +3 -2
- package/dist/webpack/configs/plugins-config.d.ts.map +1 -1
- package/dist/webpack/configs/plugins-config.js.map +1 -1
- package/dist/webpack/configs/resolve-config.d.ts +3 -2
- package/dist/webpack/configs/resolve-config.d.ts.map +1 -1
- package/dist/webpack/configs/resolve-config.js.map +1 -1
- package/dist/webpack/configs/rules/css-rules.d.ts +2 -2
- package/dist/webpack/configs/rules/css-rules.d.ts.map +1 -1
- package/dist/webpack/configs/rules/css-rules.js +2 -1
- package/dist/webpack/configs/rules/css-rules.js.map +1 -1
- package/dist/webpack/configs/rules/font-rules.d.ts +2 -2
- package/dist/webpack/configs/rules/font-rules.d.ts.map +1 -1
- package/dist/webpack/configs/rules/font-rules.js.map +1 -1
- package/dist/webpack/configs/rules/image-rules.d.ts +2 -2
- package/dist/webpack/configs/rules/image-rules.d.ts.map +1 -1
- package/dist/webpack/configs/rules/image-rules.js.map +1 -1
- package/dist/webpack/configs/rules/js-rules.d.ts +2 -2
- package/dist/webpack/configs/rules/js-rules.d.ts.map +1 -1
- package/dist/webpack/configs/rules/js-rules.js +3 -1
- package/dist/webpack/configs/rules/js-rules.js.map +1 -1
- package/dist/webpack/configs/rules/less-rules.d.ts +2 -2
- package/dist/webpack/configs/rules/less-rules.d.ts.map +1 -1
- package/dist/webpack/configs/rules/less-rules.js.map +1 -1
- package/dist/webpack/configs/rules/scss-rules.d.ts +2 -2
- package/dist/webpack/configs/rules/scss-rules.d.ts.map +1 -1
- package/dist/webpack/configs/rules/scss-rules.js.map +1 -1
- package/dist/webpack/configs/rules/svg-rules.d.ts +2 -2
- package/dist/webpack/configs/rules/svg-rules.d.ts.map +1 -1
- package/dist/webpack/configs/rules/svg-rules.js.map +1 -1
- package/dist/webpack/configs/rules-config.d.ts +3 -2
- package/dist/webpack/configs/rules-config.d.ts.map +1 -1
- package/dist/webpack/configs/rules-config.js +2 -2
- package/dist/webpack/configs/rules-config.js.map +1 -1
- package/dist/webpack/configs/stats-config.d.ts +3 -2
- package/dist/webpack/configs/stats-config.d.ts.map +1 -1
- package/dist/webpack/configs/stats-config.js.map +1 -1
- package/dist/webpack/configs/watch-options-config.d.ts +2 -2
- package/dist/webpack/configs/watch-options-config.d.ts.map +1 -1
- package/dist/webpack/configs/watch-options-config.js +2 -2
- package/dist/webpack/configs/watch-options-config.js.map +1 -1
- package/dist/webpack/create-webpack-config.d.ts +10 -0
- package/dist/webpack/create-webpack-config.d.ts.map +1 -1
- package/dist/webpack/create-webpack-config.js +109 -41
- package/dist/webpack/create-webpack-config.js.map +1 -1
- package/dist/webpack/types.d.ts +4 -11
- package/dist/webpack/types.d.ts.map +1 -1
- package/dist/webpack/utils/index.d.ts +0 -1
- package/dist/webpack/utils/index.d.ts.map +1 -1
- package/dist/webpack/utils/index.js +0 -1
- package/dist/webpack/utils/index.js.map +1 -1
- package/package.json +13 -10
- package/patches/vite-plugin-css-injected-by-js+3.5.2.patch +63 -0
- package/src/cli/commands/__tests__/mfe-generate-metadata.test.ts +3 -4
- package/src/cli/commands/build.ts +7 -2
- package/src/cli/commands/bundle-vite.ts +112 -0
- package/src/cli/commands/get-command.ts +2 -0
- package/src/cli/commands/mfe-check.ts +1 -2
- package/src/cli/commands/mfe-generate-metadata.ts +1 -1
- package/src/cli/commands/mfe-package-publish.ts +1 -1
- package/src/cli/commands/start.ts +5 -2
- package/src/cli/utils/__tests__/bundle.test.ts +19 -10
- package/src/cli/utils/bundle.ts +20 -101
- package/src/{webpack/configs/plugins/ignore-plugin → core/check-resource}/__tests__/check-resource.test.ts +18 -5
- package/src/{webpack/configs/plugins/ignore-plugin → core/check-resource}/check-resource.ts +4 -4
- package/src/{webpack/configs/plugins/ignore-plugin → core/check-resource}/get-package-json.ts +2 -2
- package/src/core/check-resource/index.ts +1 -0
- package/src/core/context.ts +65 -0
- package/src/core/defines/exposed-dependencies.ts +21 -0
- package/src/core/defines/exposed-instance-dependencies.ts +19 -0
- package/src/core/defines/index.ts +3 -0
- package/src/core/defines/web-component-name.ts +15 -0
- package/src/core/externals.ts +23 -0
- package/src/core/get-exposed-dependencies-entry-points.ts +59 -0
- package/src/core/index.ts +8 -0
- package/src/core/types.ts +59 -0
- package/src/{webpack/configs → core}/utils/__tests__/build-metadata.test.ts +2 -2
- package/src/{webpack/configs → core}/utils/__tests__/generate-metadata.test.ts +27 -13
- package/src/{webpack/configs → core}/utils/build-metadata.ts +1 -1
- package/src/{webpack/configs → core}/utils/generate-metadata.ts +7 -6
- package/src/core/utils/get-bundle-type.ts +20 -0
- package/src/{webpack/configs → core}/utils/get-launchdarkly-sdk-version.ts +1 -1
- package/src/core/utils/get-output-path.ts +18 -0
- package/src/{webpack/configs → core}/utils/get-web-components-version.ts +1 -1
- package/src/core/utils/index.ts +8 -0
- package/src/core/virtual-modules.ts +76 -0
- package/src/index.ts +1 -0
- package/src/storybook-config/__tests__/webpack-final.test.ts +5 -2
- package/src/storybook-config/webpack-final.ts +24 -10
- package/src/utils/__tests__/get-configuration.test.ts +99 -1
- package/src/utils/__tests__/get-package-data.test.ts +35 -1
- package/src/utils/get-configuration.ts +92 -1
- package/src/utils/get-package-data.ts +3 -1
- package/src/vite/__tests__/define-config.test.ts +13 -0
- package/src/vite/__tests__/load-config-file.test.ts +115 -0
- package/src/vite/__tests__/merge-config.test.ts +173 -0
- package/src/vite/base-config.ts +70 -0
- package/src/vite/build-shared-deps.ts +320 -0
- package/src/vite/create-vite-config.ts +50 -0
- package/src/vite/define-config.ts +20 -0
- package/src/vite/index.html +29 -0
- package/src/vite/load-config-file.ts +54 -0
- package/src/vite/merge-config.ts +93 -0
- package/src/vite/plugins/css-injector-plugin.ts +85 -0
- package/src/vite/plugins/dev-server-routing-plugin.ts +89 -0
- package/src/vite/plugins/externals-plugin.ts +27 -0
- package/src/vite/plugins/html-plugin.ts +65 -0
- package/src/vite/plugins/ignore-modules-plugin.ts +22 -0
- package/src/vite/plugins/index.ts +9 -0
- package/src/vite/plugins/metadata-plugin.ts +78 -0
- package/src/vite/plugins/style-urls-plugin.ts +34 -0
- package/src/vite/plugins/svgr-plugin.ts +11 -0
- package/src/vite/plugins/virtual-modules-plugin.ts +74 -0
- package/src/webpack/__tests__/create-webpack-config-shared-dependencies.test.ts +2 -2
- package/src/webpack/__tests__/create-webpack-config-web-component.test.ts +11 -11
- package/src/webpack/__tests__/create-webpack-config.test.ts +3 -2
- package/src/webpack/configs/amd-config.ts +3 -2
- package/src/webpack/configs/cache-config.ts +4 -3
- package/src/webpack/configs/dev-server-config.ts +8 -3
- package/src/webpack/configs/devtool-config.ts +4 -3
- package/src/webpack/configs/entry.config.ts +8 -7
- package/src/webpack/configs/externals-config.ts +5 -21
- package/src/webpack/configs/index.ts +0 -1
- package/src/webpack/configs/loaders/css-loader.ts +3 -2
- package/src/webpack/configs/loaders/style-loader.ts +5 -5
- package/src/webpack/configs/module-config.ts +3 -2
- package/src/webpack/configs/optimization-config.ts +16 -11
- package/src/webpack/configs/output-config.ts +16 -22
- package/src/webpack/configs/plugins/assets-manifest-plugin.ts +9 -36
- package/src/webpack/configs/plugins/bundle-analyser-plugin.ts +8 -8
- package/src/webpack/configs/plugins/define-exposed-dependencies-plugin.ts +7 -15
- package/src/webpack/configs/plugins/define-exposed-instance-dependencies-plugin.ts +7 -13
- package/src/webpack/configs/plugins/define-web-component-name-plugin.ts +7 -8
- package/src/webpack/configs/plugins/filter-warnings-plugin.ts +4 -3
- package/src/webpack/configs/plugins/html-plugin.ts +7 -6
- package/src/webpack/configs/plugins/html-tags-plugin.ts +7 -16
- package/src/webpack/configs/plugins/ignore-plugin/empty-module.js +1 -0
- package/src/webpack/configs/plugins/ignore-plugin/ignore-plugin.ts +48 -6
- package/src/webpack/configs/plugins/mini-css-extract-plugin.ts +10 -5
- package/src/webpack/configs/plugins/moment-locales-plugin.ts +3 -2
- package/src/webpack/configs/plugins/remove-empty-scripts-plugin.ts +4 -3
- package/src/webpack/configs/plugins/virtual-modules-plugin.ts +13 -65
- package/src/webpack/configs/plugins/watch-run-plugin.ts +3 -2
- package/src/webpack/configs/plugins-config.ts +3 -2
- package/src/webpack/configs/resolve-config.ts +3 -2
- package/src/webpack/configs/rules/css-rules.ts +4 -3
- package/src/webpack/configs/rules/font-rules.ts +2 -2
- package/src/webpack/configs/rules/image-rules.ts +2 -2
- package/src/webpack/configs/rules/js-rules.ts +4 -2
- package/src/webpack/configs/rules/less-rules.ts +2 -2
- package/src/webpack/configs/rules/scss-rules.ts +2 -2
- package/src/webpack/configs/rules/svg-rules.ts +2 -2
- package/src/webpack/configs/rules-config.ts +9 -5
- package/src/webpack/configs/stats-config.ts +3 -2
- package/src/webpack/configs/watch-options-config.ts +3 -3
- package/src/webpack/create-webpack-config.ts +88 -43
- package/src/webpack/types.ts +7 -11
- package/src/webpack/utils/index.ts +0 -1
- package/dist/webpack/configs/plugins/ignore-plugin/check-resource.d.ts +0 -3
- package/dist/webpack/configs/plugins/ignore-plugin/check-resource.d.ts.map +0 -1
- package/dist/webpack/configs/plugins/ignore-plugin/get-package-json.d.ts.map +0 -1
- package/dist/webpack/configs/plugins/ignore-plugin/is-optional-peer-dependency.d.ts.map +0 -1
- package/dist/webpack/configs/plugins/ignore-plugin/is-optional-react-dom-peer-dependency.d.ts.map +0 -1
- package/dist/webpack/configs/types.d.ts +0 -35
- package/dist/webpack/configs/types.d.ts.map +0 -1
- package/dist/webpack/configs/utils/build-metadata.d.ts.map +0 -1
- package/dist/webpack/configs/utils/generate-metadata.d.ts +0 -3
- package/dist/webpack/configs/utils/generate-metadata.d.ts.map +0 -1
- package/dist/webpack/configs/utils/get-bundle-type.d.ts +0 -3
- package/dist/webpack/configs/utils/get-bundle-type.d.ts.map +0 -1
- package/dist/webpack/configs/utils/get-exposed-dependencies.d.ts.map +0 -1
- package/dist/webpack/configs/utils/get-launchdarkly-sdk-version.d.ts.map +0 -1
- package/dist/webpack/configs/utils/get-web-components-version.d.ts.map +0 -1
- package/dist/webpack/configs/utils/index.d.ts +0 -4
- package/dist/webpack/configs/utils/index.d.ts.map +0 -1
- package/src/webpack/configs/types.ts +0 -38
- package/src/webpack/configs/utils/get-bundle-type.ts +0 -22
- package/src/webpack/configs/utils/index.ts +0 -3
- /package/dist/{webpack/configs/plugins/ignore-plugin → core/check-resource}/get-package-json.d.ts +0 -0
- /package/dist/{webpack/configs/plugins/ignore-plugin → core/check-resource}/is-optional-peer-dependency.d.ts +0 -0
- /package/dist/{webpack/configs/plugins/ignore-plugin → core/check-resource}/is-optional-react-dom-peer-dependency.d.ts +0 -0
- /package/dist/{webpack/configs → core}/utils/build-metadata.d.ts +0 -0
- /package/dist/{webpack/configs → core}/utils/get-exposed-dependencies.d.ts +0 -0
- /package/dist/{webpack/configs → core}/utils/get-launchdarkly-sdk-version.d.ts +0 -0
- /package/dist/{webpack/configs → core}/utils/get-web-components-version.d.ts +0 -0
- /package/src/{webpack/configs/plugins/ignore-plugin → core/check-resource}/__tests__/get-package-json.test.ts +0 -0
- /package/src/{webpack/configs/plugins/ignore-plugin → core/check-resource}/__tests__/is-optional-peer-dependency.test.ts +0 -0
- /package/src/{webpack/configs/plugins/ignore-plugin → core/check-resource}/__tests__/is-optional-react-dom-peer-dependency.test.ts +0 -0
- /package/src/{webpack/configs/plugins/ignore-plugin → core/check-resource}/is-optional-peer-dependency.ts +0 -0
- /package/src/{webpack/configs/plugins/ignore-plugin → core/check-resource}/is-optional-react-dom-peer-dependency.ts +0 -0
- /package/src/{webpack/configs → core}/utils/__tests__/get-exposed-dependencies.test.ts +0 -0
- /package/src/{webpack/configs → core}/utils/__tests__/get-launchdarkly-sdk-version.test.ts +0 -0
- /package/src/{webpack/configs → core}/utils/__tests__/get-web-components-version.test.ts +0 -0
- /package/src/{webpack/configs → core}/utils/get-exposed-dependencies.ts +0 -0
- /package/src/{webpack → core}/utils/stringify-config.ts +0 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { rolldown } from 'rolldown';
|
|
4
|
+
import type { BuildContext } from '../core/types';
|
|
5
|
+
import type { ViteConfigOverride } from './define-config';
|
|
6
|
+
|
|
7
|
+
type ConfigFileExport = ViteConfigOverride | ((context: BuildContext) => ViteConfigOverride);
|
|
8
|
+
|
|
9
|
+
const PROD_FILES = ['vite.prod.config.ts', 'vite.prod.config.js'] as const;
|
|
10
|
+
const DEV_FILES = ['vite.dev.config.ts', 'vite.dev.config.js'] as const;
|
|
11
|
+
|
|
12
|
+
export async function loadConfigFile(
|
|
13
|
+
root: string,
|
|
14
|
+
isProduction: boolean
|
|
15
|
+
): Promise<ConfigFileExport | undefined> {
|
|
16
|
+
const candidates = isProduction ? PROD_FILES : DEV_FILES;
|
|
17
|
+
const configPath = candidates.map(f => path.join(root, f)).find(f => fs.existsSync(f));
|
|
18
|
+
|
|
19
|
+
if (!configPath) {
|
|
20
|
+
return undefined;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const bundle = await rolldown({
|
|
24
|
+
input: configPath,
|
|
25
|
+
external: [/^[^./]/],
|
|
26
|
+
});
|
|
27
|
+
const { output } = await bundle.generate({ format: 'cjs' });
|
|
28
|
+
const code = output[0].code;
|
|
29
|
+
|
|
30
|
+
/*
|
|
31
|
+
* Write to node_modules/.vite-temp/ (same approach as Vite) so Node can resolve
|
|
32
|
+
* package imports relative to the project's node_modules
|
|
33
|
+
*/
|
|
34
|
+
const tmpDir = path.resolve(root, 'node_modules', '.vite-temp');
|
|
35
|
+
if (!fs.existsSync(tmpDir)) {
|
|
36
|
+
fs.mkdirSync(tmpDir, { recursive: true });
|
|
37
|
+
}
|
|
38
|
+
const tmpFile = path.join(
|
|
39
|
+
tmpDir,
|
|
40
|
+
`vite-config-${Date.now()}-${Math.random().toString(36).slice(2)}.cjs`
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
try {
|
|
44
|
+
fs.writeFileSync(tmpFile, code);
|
|
45
|
+
const mod = await import(tmpFile);
|
|
46
|
+
return mod.default;
|
|
47
|
+
} finally {
|
|
48
|
+
try {
|
|
49
|
+
fs.unlinkSync(tmpFile);
|
|
50
|
+
} catch {
|
|
51
|
+
// ignore cleanup errors
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import type { InlineConfig, Plugin } from 'vite';
|
|
2
|
+
import { mergeConfig } from 'vite';
|
|
3
|
+
import type { BuildContext } from '../core/types';
|
|
4
|
+
import { omit } from '../utils';
|
|
5
|
+
import type { ViteConfiguration } from '../utils/get-configuration';
|
|
6
|
+
import type { ViteConfigOverride } from './define-config';
|
|
7
|
+
import {
|
|
8
|
+
cssInjectorPlugin,
|
|
9
|
+
devServerRoutingPlugin,
|
|
10
|
+
externalsPlugin,
|
|
11
|
+
htmlPlugin,
|
|
12
|
+
ignoreModulesPlugin,
|
|
13
|
+
metadataPlugin,
|
|
14
|
+
styleUrlsPlugin,
|
|
15
|
+
svgrPlugin,
|
|
16
|
+
virtualModulesPlugin,
|
|
17
|
+
} from './plugins';
|
|
18
|
+
|
|
19
|
+
function resolveOverrides(pkgJsonConfig: ViteConfiguration, fileConfig: ViteConfigOverride) {
|
|
20
|
+
const {
|
|
21
|
+
omitDefault: pkgOmit = [],
|
|
22
|
+
pluginOverrides: pkgPluginOverrides = {},
|
|
23
|
+
minify: pkgMinify = {},
|
|
24
|
+
config: pkgViteConfig = {},
|
|
25
|
+
} = pkgJsonConfig;
|
|
26
|
+
const {
|
|
27
|
+
omitDefault: fileOmit = [],
|
|
28
|
+
pluginOverrides: filePluginOverrides = {},
|
|
29
|
+
minify: fileMinify = {},
|
|
30
|
+
config: fileViteConfig = {},
|
|
31
|
+
} = fileConfig;
|
|
32
|
+
|
|
33
|
+
return {
|
|
34
|
+
omitDefault: [...pkgOmit, ...fileOmit],
|
|
35
|
+
pluginOverrides: {
|
|
36
|
+
htmlTemplate: {
|
|
37
|
+
...pkgPluginOverrides.htmlTemplate,
|
|
38
|
+
...filePluginOverrides.htmlTemplate,
|
|
39
|
+
},
|
|
40
|
+
svgr: { ...pkgPluginOverrides.svgr, ...filePluginOverrides.svgr },
|
|
41
|
+
},
|
|
42
|
+
minify: { ...pkgMinify, ...fileMinify },
|
|
43
|
+
pkgViteConfig,
|
|
44
|
+
fileViteConfig,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function createPlugins(context: BuildContext, overrides: ReturnType<typeof resolveOverrides>) {
|
|
49
|
+
const entries: [string, Plugin | Plugin[]][] = [
|
|
50
|
+
['htmlTemplate', htmlPlugin(context, overrides.pluginOverrides.htmlTemplate)],
|
|
51
|
+
['svgr', svgrPlugin(overrides.pluginOverrides.svgr)],
|
|
52
|
+
['externals', externalsPlugin(context)],
|
|
53
|
+
['virtualModules', virtualModulesPlugin(context)],
|
|
54
|
+
['cssInjector', cssInjectorPlugin(context)],
|
|
55
|
+
['styleUrls', styleUrlsPlugin(context)],
|
|
56
|
+
['metadata', metadataPlugin(context)],
|
|
57
|
+
['devServerRouting', devServerRoutingPlugin(context)],
|
|
58
|
+
['ignoreModules', ignoreModulesPlugin(context)],
|
|
59
|
+
];
|
|
60
|
+
|
|
61
|
+
return entries
|
|
62
|
+
.filter(([name]) => !overrides.omitDefault.includes(`plugins.${name}`))
|
|
63
|
+
.flatMap(([, plugin]) => (Array.isArray(plugin) ? plugin : [plugin]));
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export function mergeViteConfigs(
|
|
67
|
+
baseConfig: InlineConfig,
|
|
68
|
+
pkgJsonConfig: ViteConfiguration,
|
|
69
|
+
fileConfig: ViteConfigOverride,
|
|
70
|
+
context: BuildContext
|
|
71
|
+
): InlineConfig {
|
|
72
|
+
const overrides = resolveOverrides(pkgJsonConfig, fileConfig);
|
|
73
|
+
const { omitDefault, minify, pkgViteConfig, fileViteConfig } = overrides;
|
|
74
|
+
|
|
75
|
+
const baseWithOmit = omit(
|
|
76
|
+
{ ...baseConfig },
|
|
77
|
+
omitDefault.filter(k => !k.startsWith('plugins.'))
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
if (minify.js !== undefined) {
|
|
81
|
+
baseWithOmit.build = { ...baseWithOmit.build, minify: !!minify.js };
|
|
82
|
+
}
|
|
83
|
+
if (minify.css !== undefined) {
|
|
84
|
+
baseWithOmit.build = {
|
|
85
|
+
...baseWithOmit.build,
|
|
86
|
+
cssMinify: !!minify.css,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const plugins = createPlugins(context, overrides);
|
|
91
|
+
baseWithOmit.plugins = plugins;
|
|
92
|
+
return mergeConfig(mergeConfig(baseWithOmit, pkgViteConfig), fileViteConfig);
|
|
93
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import type { Plugin } from 'vite';
|
|
2
|
+
import cssInjectedByJsPlugin from 'vite-plugin-css-injected-by-js';
|
|
3
|
+
import type { BuildContext } from '../../core';
|
|
4
|
+
|
|
5
|
+
interface StyleData {
|
|
6
|
+
css: string;
|
|
7
|
+
attributes: Record<string, string>;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
declare global {
|
|
11
|
+
interface Window {
|
|
12
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
13
|
+
__VITE_WEB_COMPONENT_STYLES__?: Record<string, StyleData[]>;
|
|
14
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
15
|
+
__injectWebComponentStyles__?: Record<string, ((style: StyleData) => void)[]>;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function cssInjectorPlugin({ build: { name, isProduction } }: BuildContext): Plugin[] {
|
|
20
|
+
if (isProduction) {
|
|
21
|
+
return [];
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return cssInjectedByJsPlugin({
|
|
25
|
+
dev: {
|
|
26
|
+
enableDev: true,
|
|
27
|
+
removeStyleCodeFunction: function removeStyleCodeFunction(id: string, styleId: string) {
|
|
28
|
+
const componentName = styleId;
|
|
29
|
+
const styles = window.__VITE_WEB_COMPONENT_STYLES__?.[componentName];
|
|
30
|
+
|
|
31
|
+
if (!styles) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Find the style with matching data-vite-dev-id
|
|
36
|
+
const styleIndex = styles.findIndex(
|
|
37
|
+
style => style.attributes['data-vite-dev-id'] === id
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
if (styleIndex !== -1) {
|
|
41
|
+
// Empty the CSS content
|
|
42
|
+
styles[styleIndex].css = '';
|
|
43
|
+
|
|
44
|
+
// Call callbacks with empty style data
|
|
45
|
+
const callbacks = window.__injectWebComponentStyles__?.[componentName];
|
|
46
|
+
if (callbacks) {
|
|
47
|
+
callbacks.forEach(callback => callback(styles[styleIndex]));
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
styleId: name,
|
|
53
|
+
injectCodeFunction: function injectWebComponentStyles(cssCode, options) {
|
|
54
|
+
const componentName = options.styleId as string;
|
|
55
|
+
const styleData = {
|
|
56
|
+
css: cssCode,
|
|
57
|
+
attributes: options.attributes!,
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
// Store in array for components that haven't initialized yet
|
|
61
|
+
window.__VITE_WEB_COMPONENT_STYLES__ ??= {};
|
|
62
|
+
window.__VITE_WEB_COMPONENT_STYLES__[componentName] ??= [];
|
|
63
|
+
|
|
64
|
+
// Check if style with this data-vite-dev-id already exists
|
|
65
|
+
const devId = options.attributes!['data-vite-dev-id'];
|
|
66
|
+
const existingIndex = window.__VITE_WEB_COMPONENT_STYLES__[componentName].findIndex(
|
|
67
|
+
style => style.attributes['data-vite-dev-id'] === devId
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
if (existingIndex !== -1) {
|
|
71
|
+
// Update existing style
|
|
72
|
+
window.__VITE_WEB_COMPONENT_STYLES__[componentName][existingIndex] = styleData;
|
|
73
|
+
} else {
|
|
74
|
+
// Add new style
|
|
75
|
+
window.__VITE_WEB_COMPONENT_STYLES__[componentName].push(styleData);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// Call all registered callbacks with the style data
|
|
79
|
+
const callbacks = window.__injectWebComponentStyles__?.[componentName];
|
|
80
|
+
if (callbacks) {
|
|
81
|
+
callbacks.forEach(callback => callback(styleData));
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
});
|
|
85
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import type { Plugin } from 'vite';
|
|
4
|
+
import type { BuildContext } from '../../core';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Configures URL rewrites and static file serving for dev and preview servers.
|
|
8
|
+
* All server middleware logic is centralized here for discoverability.
|
|
9
|
+
*
|
|
10
|
+
* - Host dev: rewrites `/shared/...` → `/dist/bundle/shared/...` (shared deps on disk)
|
|
11
|
+
* - MFE dev: strips output path prefix `/dist/bundle/full/...` → `/...`
|
|
12
|
+
* - Prod preview: serves static files (metadata.json) from the destination directory
|
|
13
|
+
*/
|
|
14
|
+
export function devServerRoutingPlugin(context: BuildContext): Plugin {
|
|
15
|
+
const { isProduction } = context.build;
|
|
16
|
+
const { isWebComponent, destination } = context.package;
|
|
17
|
+
let outDir = '';
|
|
18
|
+
|
|
19
|
+
return {
|
|
20
|
+
name: 'dev-server-routing',
|
|
21
|
+
|
|
22
|
+
configResolved(config) {
|
|
23
|
+
outDir = config.build.outDir;
|
|
24
|
+
},
|
|
25
|
+
|
|
26
|
+
configureServer(server) {
|
|
27
|
+
if (isWebComponent) {
|
|
28
|
+
// MFE dev: strip output path prefix so the dev server can resolve files
|
|
29
|
+
const prefix = '/' + path.relative(process.cwd(), outDir) + '/';
|
|
30
|
+
|
|
31
|
+
server.middlewares.use((req, _res, next) => {
|
|
32
|
+
const url = req.url ?? '';
|
|
33
|
+
if (url.startsWith(prefix)) {
|
|
34
|
+
req.url = '/' + url.slice(prefix.length);
|
|
35
|
+
}
|
|
36
|
+
next();
|
|
37
|
+
});
|
|
38
|
+
} else {
|
|
39
|
+
/*
|
|
40
|
+
* Host dev: if a file exists inside outDir (e.g. shared deps at
|
|
41
|
+
* dist/bundle/shared/), rewrite the URL so Vite can serve it.
|
|
42
|
+
*/
|
|
43
|
+
const outDirPrefix = '/' + path.relative(process.cwd(), outDir) + '/';
|
|
44
|
+
|
|
45
|
+
server.middlewares.use((req, _res, next) => {
|
|
46
|
+
const url = req.url ?? '';
|
|
47
|
+
if (url !== '/' && !url.startsWith(outDirPrefix)) {
|
|
48
|
+
const candidate = path.join(outDir, url);
|
|
49
|
+
if (fs.existsSync(candidate) && !fs.statSync(candidate).isDirectory()) {
|
|
50
|
+
req.url = outDirPrefix + url.slice(1);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
next();
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
|
|
58
|
+
configurePreviewServer(server) {
|
|
59
|
+
if (!isProduction || !isWebComponent) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Preview: serve static files from destination that aren't in build.outDir
|
|
64
|
+
const destDir = path.resolve(destination);
|
|
65
|
+
const mountPath = '/' + path.relative(process.cwd(), destDir);
|
|
66
|
+
|
|
67
|
+
server.middlewares.use(mountPath, (req, res, next) => {
|
|
68
|
+
const filePath = path.join(destDir, req.url ?? '');
|
|
69
|
+
|
|
70
|
+
if (!fs.existsSync(filePath) || fs.statSync(filePath).isDirectory()) {
|
|
71
|
+
return next();
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const ext = path.extname(filePath);
|
|
75
|
+
const contentTypes: Record<string, string> = {
|
|
76
|
+
'.js': 'application/javascript',
|
|
77
|
+
'.css': 'text/css',
|
|
78
|
+
'.json': 'application/json',
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
if (contentTypes[ext]) {
|
|
82
|
+
res.setHeader('Content-Type', contentTypes[ext]);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
fs.createReadStream(filePath).pipe(res);
|
|
86
|
+
});
|
|
87
|
+
},
|
|
88
|
+
};
|
|
89
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { Plugin } from 'vite';
|
|
2
|
+
import { BuildContext, getExternalsMapping } from '../../core';
|
|
3
|
+
|
|
4
|
+
export function externalsPlugin(context: BuildContext): Plugin[] {
|
|
5
|
+
const entries = getExternalsMapping(context);
|
|
6
|
+
if (!entries) {
|
|
7
|
+
return [];
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
return [
|
|
11
|
+
{
|
|
12
|
+
name: 'externals',
|
|
13
|
+
resolveId(source: string) {
|
|
14
|
+
if (source in entries) {
|
|
15
|
+
return { id: '\0external:' + source, external: false };
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
load(id: string) {
|
|
19
|
+
if (!id.startsWith('\0external:')) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
const dep = id.slice('\0external:'.length);
|
|
23
|
+
return `module.exports = ${entries[dep]};`;
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
];
|
|
27
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { Eta } from 'eta';
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import type { Plugin } from 'vite';
|
|
5
|
+
import { BuildContext, getSharedEntryPoints } from '../../core';
|
|
6
|
+
import type { HtmlTemplatePluginOptions } from '../../utils';
|
|
7
|
+
|
|
8
|
+
export function htmlPlugin(context: BuildContext, options: HtmlTemplatePluginOptions = {}): Plugin {
|
|
9
|
+
const { isWebComponent } = context.package;
|
|
10
|
+
const { name } = context.build;
|
|
11
|
+
const { css, js } = getSharedEntryPoints(context);
|
|
12
|
+
|
|
13
|
+
const htmlTemplatePath = options.template
|
|
14
|
+
? path.resolve(options.template)
|
|
15
|
+
: path.join(
|
|
16
|
+
path.dirname(require.resolve('@servicetitan/startup')),
|
|
17
|
+
'../src/vite/index.html'
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
const eta = new Eta({ views: path.dirname(htmlTemplatePath) });
|
|
21
|
+
|
|
22
|
+
function renderHtml() {
|
|
23
|
+
return eta.render(path.basename(htmlTemplatePath), {
|
|
24
|
+
title: options.title ?? 'ServiceTitan',
|
|
25
|
+
favicon: options.favicon,
|
|
26
|
+
css,
|
|
27
|
+
js,
|
|
28
|
+
isWebComponent,
|
|
29
|
+
name,
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return {
|
|
34
|
+
name: 'html-template',
|
|
35
|
+
configureServer(server) {
|
|
36
|
+
return () => {
|
|
37
|
+
server.middlewares.use(async (req, res, next) => {
|
|
38
|
+
if (req.url !== '/' && !req.url?.endsWith('.html')) {
|
|
39
|
+
return next();
|
|
40
|
+
}
|
|
41
|
+
let html = renderHtml();
|
|
42
|
+
html = await server.transformIndexHtml(req.url!, html);
|
|
43
|
+
res.end(html);
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
},
|
|
47
|
+
// TODO: look into similarity with virtual-modules-plugin
|
|
48
|
+
resolveId(id: string, importer: string | undefined) {
|
|
49
|
+
if (id.endsWith('.html')) {
|
|
50
|
+
return path.resolve('index.html');
|
|
51
|
+
}
|
|
52
|
+
if (importer?.includes('/index.html') && id.startsWith('.')) {
|
|
53
|
+
const resolved = path.resolve(id + '.js');
|
|
54
|
+
if (fs.existsSync(resolved)) {
|
|
55
|
+
return resolved;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
load(id: string) {
|
|
60
|
+
if (id === path.resolve('index.html')) {
|
|
61
|
+
return renderHtml();
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Plugin } from 'vite';
|
|
2
|
+
import { BuildContext, checkResource } from '../../core';
|
|
3
|
+
|
|
4
|
+
export function ignoreModulesPlugin(context: BuildContext): Plugin {
|
|
5
|
+
const VIRTUAL_PREFIX = '\0IGNORE';
|
|
6
|
+
|
|
7
|
+
const checker = checkResource(context);
|
|
8
|
+
|
|
9
|
+
return {
|
|
10
|
+
name: 'ignore-modules-plugin',
|
|
11
|
+
resolveId(source, importer) {
|
|
12
|
+
if (importer && checker(source, importer)) {
|
|
13
|
+
return `${VIRTUAL_PREFIX}${source}`;
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
load(id) {
|
|
17
|
+
if (id.startsWith(VIRTUAL_PREFIX)) {
|
|
18
|
+
return 'export default {}';
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from './css-injector-plugin';
|
|
2
|
+
export * from './dev-server-routing-plugin';
|
|
3
|
+
export * from './externals-plugin';
|
|
4
|
+
export * from './html-plugin';
|
|
5
|
+
export * from './ignore-modules-plugin';
|
|
6
|
+
export * from './metadata-plugin';
|
|
7
|
+
export * from './style-urls-plugin';
|
|
8
|
+
export * from './svgr-plugin';
|
|
9
|
+
export * from './virtual-modules-plugin';
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import type { Plugin } from 'vite';
|
|
4
|
+
import { BuildContext, generateMetadata } from '../../core';
|
|
5
|
+
|
|
6
|
+
export function metadataPlugin(context: BuildContext): Plugin[] {
|
|
7
|
+
if (!context.package.isWebComponent) {
|
|
8
|
+
return [];
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
let outDir = '';
|
|
12
|
+
|
|
13
|
+
return [
|
|
14
|
+
{
|
|
15
|
+
name: 'entrypoints',
|
|
16
|
+
configResolved(config) {
|
|
17
|
+
outDir = config.build.outDir;
|
|
18
|
+
},
|
|
19
|
+
configureServer(server) {
|
|
20
|
+
server.httpServer?.once('listening', () => {
|
|
21
|
+
const address = server.httpServer?.address();
|
|
22
|
+
if (!address || typeof address === 'string') {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const entrypoints = {
|
|
27
|
+
type: 'module',
|
|
28
|
+
port: address.port,
|
|
29
|
+
css: [],
|
|
30
|
+
js: ['@vite/client', '@id/__x00__VIRTUAL./index'],
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const entrypointsPath = path.join(outDir, 'entrypoints.json');
|
|
34
|
+
const dir = path.dirname(entrypointsPath);
|
|
35
|
+
|
|
36
|
+
if (!fs.existsSync(dir)) {
|
|
37
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
fs.writeFileSync(entrypointsPath, JSON.stringify(entrypoints, null, 2));
|
|
41
|
+
|
|
42
|
+
// eslint-disable-next-line no-console
|
|
43
|
+
console.log(`\nEntrypoints written to: ${entrypointsPath}`);
|
|
44
|
+
|
|
45
|
+
generateMetadata(context);
|
|
46
|
+
});
|
|
47
|
+
},
|
|
48
|
+
writeBundle(options, bundle) {
|
|
49
|
+
if (!options.dir) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const js: string[] = [];
|
|
54
|
+
const css: string[] = [];
|
|
55
|
+
|
|
56
|
+
for (const chunk of Object.values(bundle)) {
|
|
57
|
+
if (chunk.type === 'chunk' && chunk.isEntry) {
|
|
58
|
+
js.push(chunk.fileName);
|
|
59
|
+
}
|
|
60
|
+
if (chunk.type === 'asset' && chunk.fileName.endsWith('.css')) {
|
|
61
|
+
css.push(chunk.fileName);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
fs.writeFileSync(
|
|
66
|
+
path.join(options.dir, 'entrypoints.json'),
|
|
67
|
+
JSON.stringify({ type: 'module', css, js }, null, 2)
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
generateMetadata(context);
|
|
71
|
+
fs.copyFileSync(
|
|
72
|
+
path.join(context.package.destination, 'metadata.json'),
|
|
73
|
+
path.join(options.dir, 'metadata.json')
|
|
74
|
+
);
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
];
|
|
78
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { Plugin } from 'vite';
|
|
2
|
+
import type { BuildContext } from '../../core';
|
|
3
|
+
|
|
4
|
+
export function styleUrlsPlugin({
|
|
5
|
+
package: { isWebComponent },
|
|
6
|
+
build: { isProduction },
|
|
7
|
+
}: BuildContext): Plugin[] {
|
|
8
|
+
if (!isWebComponent || !isProduction) {
|
|
9
|
+
return [];
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
return [
|
|
13
|
+
{
|
|
14
|
+
name: 'style-urls',
|
|
15
|
+
transformIndexHtml: {
|
|
16
|
+
order: 'post' as const,
|
|
17
|
+
handler(html, ctx) {
|
|
18
|
+
const css = ctx.bundle
|
|
19
|
+
? Object.values(ctx.bundle)
|
|
20
|
+
.filter(
|
|
21
|
+
chunk => chunk.type === 'asset' && chunk.fileName.endsWith('.css')
|
|
22
|
+
)
|
|
23
|
+
.map(chunk => chunk.fileName)
|
|
24
|
+
: [];
|
|
25
|
+
|
|
26
|
+
return html.replace(
|
|
27
|
+
'style-urls="%5B%5D"',
|
|
28
|
+
`style-urls="${encodeURIComponent(JSON.stringify(css))}"`
|
|
29
|
+
);
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
];
|
|
34
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Plugin } from 'vite';
|
|
2
|
+
import svgr from 'vite-plugin-svgr';
|
|
3
|
+
import type { SvgrPluginOptions } from '../../utils';
|
|
4
|
+
|
|
5
|
+
export function svgrPlugin(options: SvgrPluginOptions = {}): Plugin {
|
|
6
|
+
return svgr({
|
|
7
|
+
include: options.include ?? ['**/*.svg?component', '**/@servicetitan/anvil2/**/*.svg'],
|
|
8
|
+
exclude: options.exclude,
|
|
9
|
+
...(options.svgrOptions ? { svgrOptions: options.svgrOptions } : {}),
|
|
10
|
+
});
|
|
11
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import type { Plugin } from 'vite';
|
|
3
|
+
import { BuildContext, virtualModules } from '../../core';
|
|
4
|
+
|
|
5
|
+
function devWebComponentIndexCode(code: string) {
|
|
6
|
+
const lines = code.split('\n');
|
|
7
|
+
|
|
8
|
+
const lastLineIndex = lines.length - 1;
|
|
9
|
+
|
|
10
|
+
if (lines[lastLineIndex].includes('register(App,')) {
|
|
11
|
+
lines[lastLineIndex] = lines[lastLineIndex].replace(
|
|
12
|
+
'register(App,',
|
|
13
|
+
'register(WrappedApp,'
|
|
14
|
+
);
|
|
15
|
+
lines.unshift("import { withStyleInjector } from '@servicetitan/web-components';");
|
|
16
|
+
lines.splice(lastLineIndex + 1, 0, '', 'const WrappedApp = withStyleInjector(App);', '');
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return lines.join('\n');
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function virtualModulesPlugin(context: BuildContext): Plugin[] {
|
|
23
|
+
const VIRTUAL_PREFIX = '\0VIRTUAL';
|
|
24
|
+
|
|
25
|
+
const { destination } = context.package;
|
|
26
|
+
const { isProduction } = context.build;
|
|
27
|
+
|
|
28
|
+
const modules = virtualModules(context);
|
|
29
|
+
|
|
30
|
+
const viteModules: Record<string, string> = {};
|
|
31
|
+
|
|
32
|
+
if (modules.index) {
|
|
33
|
+
viteModules['./index'] = isProduction
|
|
34
|
+
? modules.index
|
|
35
|
+
: devWebComponentIndexCode(modules.index);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (modules.designSystem) {
|
|
39
|
+
viteModules['./design-system.css'] = modules.designSystem;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
let rootDir = '';
|
|
43
|
+
|
|
44
|
+
if (Object.keys(viteModules).length === 0) {
|
|
45
|
+
return [];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return [
|
|
49
|
+
{
|
|
50
|
+
name: 'virtual-modules-plugin',
|
|
51
|
+
resolveId(source, importer) {
|
|
52
|
+
if (viteModules[source]) {
|
|
53
|
+
return `${VIRTUAL_PREFIX}${source}`;
|
|
54
|
+
}
|
|
55
|
+
if (importer?.startsWith(VIRTUAL_PREFIX)) {
|
|
56
|
+
const importerNoPrefix = importer.slice(VIRTUAL_PREFIX.length);
|
|
57
|
+
if (viteModules[importerNoPrefix] && source.startsWith('.')) {
|
|
58
|
+
return path.resolve(rootDir, source + '.js');
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
load(id) {
|
|
63
|
+
if (id.startsWith(VIRTUAL_PREFIX)) {
|
|
64
|
+
const idNoPrefix = id.slice(VIRTUAL_PREFIX.length);
|
|
65
|
+
|
|
66
|
+
return viteModules[idNoPrefix];
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
configResolved(config) {
|
|
70
|
+
rootDir = path.join(config.root, destination);
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
];
|
|
74
|
+
}
|
|
@@ -10,6 +10,7 @@ import { WebpackAssetsManifest } from 'webpack-assets-manifest';
|
|
|
10
10
|
import RemoveEmptyScriptsPlugin from 'webpack-remove-empty-scripts';
|
|
11
11
|
import VirtualModulesPlugin from 'webpack-virtual-modules';
|
|
12
12
|
import yargs from 'yargs';
|
|
13
|
+
import { getLaunchDarklySdkVersion } from '../../core';
|
|
13
14
|
import {
|
|
14
15
|
getFolders,
|
|
15
16
|
getPackageData,
|
|
@@ -23,7 +24,6 @@ import {
|
|
|
23
24
|
pick,
|
|
24
25
|
} from '../../utils';
|
|
25
26
|
import { miniCssPluginStyleRules } from '../__mocks__';
|
|
26
|
-
import { getLaunchDarklySdkVersion } from '../configs/utils/get-launchdarkly-sdk-version';
|
|
27
27
|
import { createWebpackConfig } from '../index';
|
|
28
28
|
import { getModuleEntryPath } from '../utils';
|
|
29
29
|
|
|
@@ -53,7 +53,7 @@ jest.mock('../../utils', () => ({
|
|
|
53
53
|
isExposeSharedDependencies: jest.fn(),
|
|
54
54
|
loadSharedDependencies: jest.fn(),
|
|
55
55
|
}));
|
|
56
|
-
jest.mock('
|
|
56
|
+
jest.mock('../../core/utils/get-launchdarkly-sdk-version');
|
|
57
57
|
jest.mock('../utils', () => ({
|
|
58
58
|
...jest.requireActual('../utils'),
|
|
59
59
|
getCallerFile: jest.fn(),
|