@servicetitan/startup 39.0.1 → 39.2.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/mfe-list.d.ts +0 -2
- package/dist/cli/commands/mfe-list.d.ts.map +1 -1
- package/dist/cli/commands/mfe-list.js +4 -30
- package/dist/cli/commands/mfe-list.js.map +1 -1
- package/dist/cli/commands/mfe-package-clean.js +1 -2
- package/dist/cli/commands/mfe-package-clean.js.map +1 -1
- package/dist/cli/commands/mfe-package-publish.d.ts.map +1 -1
- package/dist/cli/commands/mfe-package-publish.js +7 -5
- package/dist/cli/commands/mfe-package-publish.js.map +1 -1
- package/dist/cli/commands/mfe-package-rollback.d.ts.map +1 -1
- package/dist/cli/commands/mfe-package-rollback.js +5 -3
- package/dist/cli/commands/mfe-package-rollback.js.map +1 -1
- package/dist/cli/commands/mfe-publish.d.ts +1 -0
- package/dist/cli/commands/mfe-publish.d.ts.map +1 -1
- package/dist/cli/commands/mfe-publish.js +14 -12
- package/dist/cli/commands/mfe-publish.js.map +1 -1
- package/dist/cli/commands/registry/command-registry.d.ts +13 -4
- package/dist/cli/commands/registry/command-registry.d.ts.map +1 -1
- package/dist/cli/commands/registry/mfe-list.d.ts +2 -1
- package/dist/cli/commands/registry/mfe-list.d.ts.map +1 -1
- package/dist/cli/commands/registry/mfe-list.js +3 -1
- package/dist/cli/commands/registry/mfe-list.js.map +1 -1
- package/dist/cli/commands/registry/mfe-package-clean.d.ts +2 -1
- package/dist/cli/commands/registry/mfe-package-clean.d.ts.map +1 -1
- package/dist/cli/commands/registry/mfe-package-clean.js +4 -2
- package/dist/cli/commands/registry/mfe-package-clean.js.map +1 -1
- package/dist/cli/commands/registry/mfe-package-publish.d.ts +2 -1
- package/dist/cli/commands/registry/mfe-package-publish.d.ts.map +1 -1
- package/dist/cli/commands/registry/mfe-package-publish.js +4 -2
- package/dist/cli/commands/registry/mfe-package-publish.js.map +1 -1
- package/dist/cli/commands/registry/mfe-package-rollback.d.ts +2 -1
- package/dist/cli/commands/registry/mfe-package-rollback.d.ts.map +1 -1
- package/dist/cli/commands/registry/mfe-package-rollback.js +4 -2
- package/dist/cli/commands/registry/mfe-package-rollback.js.map +1 -1
- package/dist/cli/commands/registry/upload-sourcemaps.d.ts +5 -0
- package/dist/cli/commands/registry/upload-sourcemaps.d.ts.map +1 -1
- package/dist/cli/commands/registry/upload-sourcemaps.js +5 -0
- package/dist/cli/commands/registry/upload-sourcemaps.js.map +1 -1
- package/dist/cli/commands/review/types.js.map +1 -1
- package/dist/cli/commands/upload-sourcemaps.d.ts.map +1 -1
- package/dist/cli/commands/upload-sourcemaps.js +4 -7
- package/dist/cli/commands/upload-sourcemaps.js.map +1 -1
- package/dist/cli/commands/utils/get-mfe-registry.d.ts +4 -0
- package/dist/cli/commands/utils/get-mfe-registry.d.ts.map +1 -0
- package/dist/cli/commands/utils/get-mfe-registry.js +28 -0
- package/dist/cli/commands/utils/get-mfe-registry.js.map +1 -0
- package/dist/cli/commands/utils/get-unpkg-host.d.ts +2 -0
- package/dist/cli/commands/utils/get-unpkg-host.d.ts.map +1 -0
- package/dist/cli/commands/utils/get-unpkg-host.js +18 -0
- package/dist/cli/commands/utils/get-unpkg-host.js.map +1 -0
- package/dist/cli/commands/utils/index.d.ts +3 -1
- package/dist/cli/commands/utils/index.d.ts.map +1 -1
- package/dist/cli/commands/utils/index.js +3 -1
- package/dist/cli/commands/utils/index.js.map +1 -1
- package/dist/cli/commands/utils/login.d.ts +2 -0
- package/dist/cli/commands/utils/login.d.ts.map +1 -0
- package/dist/cli/commands/utils/login.js +56 -0
- package/dist/cli/commands/utils/login.js.map +1 -0
- package/dist/cli/commands/utils/purge-cache.d.ts.map +1 -1
- package/dist/cli/commands/utils/purge-cache.js +2 -4
- package/dist/cli/commands/utils/purge-cache.js.map +1 -1
- package/dist/cli/index.js +4 -1
- package/dist/cli/index.js.map +1 -1
- package/dist/vite/build-escaped-reg-exp.d.ts +2 -0
- package/dist/vite/build-escaped-reg-exp.d.ts.map +1 -0
- package/dist/vite/build-escaped-reg-exp.js +16 -0
- package/dist/vite/build-escaped-reg-exp.js.map +1 -0
- package/dist/vite/config/base-config.d.ts.map +1 -1
- package/dist/vite/config/base-config.js +7 -2
- package/dist/vite/config/base-config.js.map +1 -1
- package/dist/vite/config/create-resolve-config.d.ts +6 -0
- package/dist/vite/config/create-resolve-config.d.ts.map +1 -0
- package/dist/vite/config/create-resolve-config.js +52 -0
- package/dist/vite/config/create-resolve-config.js.map +1 -0
- package/dist/vite/plugins/css-injector-plugin.d.ts.map +1 -1
- package/dist/vite/plugins/css-injector-plugin.js +5 -1
- package/dist/vite/plugins/css-injector-plugin.js.map +1 -1
- package/dist/vite/plugins/externals-plugin.d.ts.map +1 -1
- package/dist/vite/plugins/externals-plugin.js +3 -3
- package/dist/vite/plugins/externals-plugin.js.map +1 -1
- package/package.json +15 -16
- package/src/cli/commands/__tests__/mfe-list.test.ts +25 -56
- package/src/cli/commands/__tests__/mfe-package-clean.test.ts +6 -0
- package/src/cli/commands/__tests__/mfe-package-publish.test.ts +52 -47
- package/src/cli/commands/__tests__/mfe-package-rollback.test.ts +4 -2
- package/src/cli/commands/__tests__/mfe-publish.test.ts +51 -14
- package/src/cli/commands/__tests__/upload-sourcemaps.test.ts +27 -13
- package/src/cli/commands/mfe-list.ts +7 -36
- package/src/cli/commands/mfe-package-clean.ts +2 -2
- package/src/cli/commands/mfe-package-publish.ts +10 -8
- package/src/cli/commands/mfe-package-rollback.ts +6 -5
- package/src/cli/commands/mfe-publish.ts +17 -16
- package/src/cli/commands/registry/mfe-list.ts +6 -1
- package/src/cli/commands/registry/mfe-package-clean.ts +7 -1
- package/src/cli/commands/registry/mfe-package-publish.ts +7 -1
- package/src/cli/commands/registry/mfe-package-rollback.ts +4 -2
- package/src/cli/commands/registry/upload-sourcemaps.ts +1 -0
- package/src/cli/commands/upload-sourcemaps.ts +4 -7
- package/src/cli/commands/utils/__tests__/get-mfe-registry.test.ts +24 -0
- package/src/cli/commands/utils/__tests__/get-unpkg-host.test.ts +32 -0
- package/src/cli/commands/utils/__tests__/login.test.ts +122 -0
- package/src/cli/commands/utils/__tests__/purge-cache.test.ts +17 -15
- package/src/cli/commands/utils/get-mfe-registry.ts +6 -0
- package/src/cli/commands/utils/get-unpkg-host.ts +8 -0
- package/src/cli/commands/utils/index.ts +3 -1
- package/src/cli/commands/utils/login.ts +38 -0
- package/src/cli/commands/utils/purge-cache.ts +2 -5
- package/src/cli/index.ts +2 -1
- package/src/vite/__tests__/build-escaped-reg-exp.test.ts +25 -0
- package/src/vite/build-escaped-reg-exp.ts +6 -0
- package/src/vite/config/__tests__/base-config.test.ts +1 -1
- package/src/vite/config/__tests__/create-resolve-config.test.ts +85 -0
- package/src/vite/config/base-config.ts +4 -2
- package/src/vite/config/create-resolve-config.ts +43 -0
- package/src/vite/plugins/__tests__/css-injector-plugin.test.ts +1 -1
- package/src/vite/plugins/css-injector-plugin.ts +6 -1
- package/src/vite/plugins/externals-plugin.ts +1 -4
- package/dist/cli/commands/utils/constants.d.ts +0 -2
- package/dist/cli/commands/utils/constants.d.ts.map +0 -1
- package/dist/cli/commands/utils/constants.js +0 -13
- package/dist/cli/commands/utils/constants.js.map +0 -1
- package/src/cli/commands/utils/constants.ts +0 -1
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Dots are the only regex-special character valid in a package name; the
|
|
3
|
+
* backslash is escaped because it is the escape character itself.
|
|
4
|
+
*/ "use strict";
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
Object.defineProperty(exports, "buildEscapedRegExp", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function() {
|
|
11
|
+
return buildEscapedRegExp;
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
const buildEscapedRegExp = (specifier)=>new RegExp(`^${specifier.replace(/[\\.]/g, '\\$&')}$`);
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=build-escaped-reg-exp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/vite/build-escaped-reg-exp.ts"],"sourcesContent":["/*\n * Dots are the only regex-special character valid in a package name; the\n * backslash is escaped because it is the escape character itself.\n */\nexport const buildEscapedRegExp = (specifier: string) =>\n new RegExp(`^${specifier.replace(/[\\\\.]/g, '\\\\$&')}$`);\n"],"names":["buildEscapedRegExp","specifier","RegExp","replace"],"mappings":"AAAA;;;CAGC;;;;+BACYA;;;eAAAA;;;AAAN,MAAMA,qBAAqB,CAACC,YAC/B,IAAIC,OAAO,CAAC,CAAC,EAAED,UAAUE,OAAO,CAAC,UAAU,QAAQ,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-config.d.ts","sourceRoot":"","sources":["../../../src/vite/config/base-config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAU,MAAM,MAAM,CAAC;AA8BjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"base-config.d.ts","sourceRoot":"","sources":["../../../src/vite/config/base-config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAU,MAAM,MAAM,CAAC;AA8BjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAmD5C,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,gBAAgB,GAAG,YAAY,CAiFxE"}
|
|
@@ -15,6 +15,7 @@ const _assetfilenames = require("./asset-file-names");
|
|
|
15
15
|
const _codesplitting = require("./code-splitting");
|
|
16
16
|
const _createcssconfig = require("./create-css-config");
|
|
17
17
|
const _createfilteringlogger = require("./create-filtering-logger");
|
|
18
|
+
const _createresolveconfig = require("./create-resolve-config");
|
|
18
19
|
function importMetaRemap(...definitions) {
|
|
19
20
|
const result = {};
|
|
20
21
|
definitions.filter((definition)=>definition !== undefined).forEach((definition)=>Object.keys(definition).forEach((item)=>{
|
|
@@ -97,6 +98,10 @@ function createPlugins(context) {
|
|
|
97
98
|
function createBaseConfig(context) {
|
|
98
99
|
var _getBundleType, _context_bundlerConfig_port, _getProcessEnv;
|
|
99
100
|
var _context_bundlerConfig_omitDefault;
|
|
101
|
+
const optimizedStartupDependencies = [
|
|
102
|
+
'@servicetitan/startup-utils',
|
|
103
|
+
'react-refresh/runtime'
|
|
104
|
+
];
|
|
100
105
|
const { isProduction } = context.build;
|
|
101
106
|
const { isWebComponent } = context.package;
|
|
102
107
|
let config = {
|
|
@@ -138,10 +143,10 @@ function createBaseConfig(context) {
|
|
|
138
143
|
...importMetaRemap((0, _core.defineExposedDependencies)(context), (0, _core.defineExposedInstanceDependencies)(context), (0, _core.defineWebComponentName)(context)),
|
|
139
144
|
...(_getProcessEnv = (0, _core.getProcessEnv)(context)) !== null && _getProcessEnv !== void 0 ? _getProcessEnv : {}
|
|
140
145
|
},
|
|
146
|
+
resolve: (0, _createresolveconfig.createResolveConfig)(context, optimizedStartupDependencies),
|
|
141
147
|
optimizeDeps: {
|
|
142
148
|
include: [
|
|
143
|
-
|
|
144
|
-
'react-refresh/runtime',
|
|
149
|
+
...optimizedStartupDependencies,
|
|
145
150
|
'react/jsx-runtime',
|
|
146
151
|
'react/jsx-dev-runtime'
|
|
147
152
|
],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/vite/config/base-config.ts"],"sourcesContent":["import type { InlineConfig, Plugin } from 'vite';\nimport {\n bundleConstants,\n defineExposedDependencies,\n defineExposedInstanceDependencies,\n defineWebComponentName,\n getBundleType,\n getCdnPath,\n getProcessEnv,\n} from '../../core';\nimport { omit } from '../../utils';\nimport {\n bundleStatPlugin,\n chainSourceMapsPlugin,\n cleanPlugin,\n cssInjectorPlugin,\n designSystemGuardPlugin,\n devServerRoutingPlugin,\n externalsPlugin,\n htmlPlugin,\n ignoreModulesPlugin,\n istanbulPlugin,\n magicCommentsPlugin,\n metadataPlugin,\n momentLocalesPlugin,\n reactRefreshPlugin,\n styleUrlsPlugin,\n svgrPlugin,\n virtualModulesPlugin,\n} from '../plugins';\nimport { ViteBuildContext } from '../types';\nimport { assetFileNames } from './asset-file-names';\nimport { getCodeSplitting } from './code-splitting';\nimport { createCssConfig } from './create-css-config';\nimport { createFilteringLogger } from './create-filtering-logger';\n\nfunction importMetaRemap(\n ...definitions: (Record<string, string> | undefined)[]\n): Record<string, string> {\n const result: Record<string, string> = {};\n\n definitions\n .filter(definition => definition !== undefined)\n .forEach(definition =>\n Object.keys(definition).forEach(item => {\n result[`import.meta.env.${item}`] = definition[item];\n })\n );\n\n return result;\n}\n\nfunction createPlugins(context: ViteBuildContext) {\n const entries: [string, Plugin[] | Plugin | Promise<Plugin> | undefined][] = [\n ['reactRefresh', reactRefreshPlugin(context)],\n ['bundleStat', bundleStatPlugin(context)],\n ['clean', cleanPlugin(context)],\n ['cssInjector', cssInjectorPlugin(context)],\n ['designSystemGuard', designSystemGuardPlugin(context)],\n ['devServerRouting', devServerRoutingPlugin(context)],\n ['externals', externalsPlugin(context)],\n ['html', htmlPlugin(context)],\n ['ignoreModules', ignoreModulesPlugin(context)],\n ['istanbul', istanbulPlugin(context)],\n ['magicComments', magicCommentsPlugin(context)],\n ['metadata', metadataPlugin(context)],\n ['momentLocales', momentLocalesPlugin(context)],\n ['styleUrls', styleUrlsPlugin(context)],\n ['svgr', svgrPlugin(context)],\n ['virtualModules', virtualModulesPlugin(context)],\n ];\n\n return entries\n .filter(\n ([name, plugin]) =>\n plugin && !context.bundlerConfig.omitDefault?.includes(`plugins.${name}`)\n )\n .flatMap(([, plugin]) => plugin);\n}\n\nexport function createBaseConfig(context: ViteBuildContext): InlineConfig {\n const { isProduction } = context.build;\n const { isWebComponent } = context.package;\n\n let config: InlineConfig = {\n cacheDir: `node_modules/.vite/${getBundleType(context) ?? 'host'}`,\n customLogger: createFilteringLogger(),\n server: {\n // Windows machines can fail to connect to \"localhost\"; bind to a fixed address instead.\n host: '127.0.0.1',\n port: context.bundlerConfig.port ?? (isWebComponent ? 8888 : 8080),\n },\n mode: isProduction ? bundleConstants.mode.production : bundleConstants.mode.development,\n configFile: false,\n oxc: { legalComments: 'none' },\n base: getCdnPath(context) || './', // eslint-disable-line @typescript-eslint/prefer-nullish-coalescing\n css: createCssConfig(isProduction),\n build: {\n /*\n * MFEs render inside shadow DOM — lazy CSS chunks would inject into document.head,\n * leaking styles into the host. Bundling all CSS into one file avoids this.\n */\n cssCodeSplit: !isWebComponent,\n sourcemap: true,\n rolldownOptions: {\n output: { assetFileNames, codeSplitting: getCodeSplitting(context) },\n plugins: [chainSourceMapsPlugin()],\n },\n },\n define: {\n /*\n * Some dependencies assume Node's `global` exists (webpack polyfills this\n * automatically for browser targets; Vite does not).\n */\n global: 'globalThis',\n ...importMetaRemap(\n defineExposedDependencies(context),\n defineExposedInstanceDependencies(context),\n defineWebComponentName(context)\n ),\n ...(getProcessEnv(context) ?? {}),\n },\n optimizeDeps: {\n include: [\n '@servicetitan/startup-utils',\n 'react-refresh/runtime',\n 'react/jsx-runtime',\n 'react/jsx-dev-runtime',\n ],\n /*\n * Top-level plugins don't run during dependency pre-bundling, so\n * register ignoreModulesPlugin again here. Without this, missing\n * optional peer dependencies inside pre-bundled packages throw at\n * runtime instead of resolving to an empty module.\n */\n rolldownOptions: {\n plugins: [ignoreModulesPlugin(context)],\n },\n },\n plugins: createPlugins(context),\n };\n\n const omitKeys = context.bundlerConfig.omitDefault?.filter(k => !k.startsWith('plugins.'));\n if (omitKeys?.length) {\n config = omit({ ...config }, omitKeys);\n }\n\n if (context.bundlerConfig.minify.js !== undefined) {\n config.build = { ...config.build, minify: !!context.bundlerConfig.minify.js };\n }\n if (context.bundlerConfig.minify.css !== undefined) {\n config.build = { ...config.build, cssMinify: !!context.bundlerConfig.minify.css };\n }\n\n // Minified output can't be mapped back to source, so skip it when instrumenting.\n if (context.options.codeCoverage) {\n config.build = { ...config.build, minify: false };\n }\n\n return config;\n}\n"],"names":["createBaseConfig","importMetaRemap","definitions","result","filter","definition","undefined","forEach","Object","keys","item","createPlugins","context","entries","reactRefreshPlugin","bundleStatPlugin","cleanPlugin","cssInjectorPlugin","designSystemGuardPlugin","devServerRoutingPlugin","externalsPlugin","htmlPlugin","ignoreModulesPlugin","istanbulPlugin","magicCommentsPlugin","metadataPlugin","momentLocalesPlugin","styleUrlsPlugin","svgrPlugin","virtualModulesPlugin","name","plugin","bundlerConfig","omitDefault","includes","flatMap","getBundleType","getProcessEnv","isProduction","build","isWebComponent","package","config","cacheDir","customLogger","createFilteringLogger","server","host","port","mode","bundleConstants","production","development","configFile","oxc","legalComments","base","getCdnPath","css","createCssConfig","cssCodeSplit","sourcemap","rolldownOptions","output","assetFileNames","codeSplitting","getCodeSplitting","plugins","chainSourceMapsPlugin","define","global","defineExposedDependencies","defineExposedInstanceDependencies","defineWebComponentName","optimizeDeps","include","omitKeys","k","startsWith","length","omit","minify","js","cssMinify","options","codeCoverage"],"mappings":";;;;+BAgFgBA;;;eAAAA;;;sBAvET;uBACc;yBAmBd;gCAEwB;+BACE;iCACD;uCACM;AAEtC,SAASC,gBACL,GAAGC,WAAmD;IAEtD,MAAMC,SAAiC,CAAC;IAExCD,YACKE,MAAM,CAACC,CAAAA,aAAcA,eAAeC,WACpCC,OAAO,CAACF,CAAAA,aACLG,OAAOC,IAAI,CAACJ,YAAYE,OAAO,CAACG,CAAAA;YAC5BP,MAAM,CAAC,CAAC,gBAAgB,EAAEO,MAAM,CAAC,GAAGL,UAAU,CAACK,KAAK;QACxD;IAGR,OAAOP;AACX;AAEA,SAASQ,cAAcC,OAAyB;IAC5C,MAAMC,UAAuE;QACzE;YAAC;YAAgBC,IAAAA,2BAAkB,EAACF;SAAS;QAC7C;YAAC;YAAcG,IAAAA,yBAAgB,EAACH;SAAS;QACzC;YAAC;YAASI,IAAAA,oBAAW,EAACJ;SAAS;QAC/B;YAAC;YAAeK,IAAAA,0BAAiB,EA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,aAAa,CAACiD,MAAM,CAACC,EAAE,KAAK5E,WAAW;QAC/CoC,OAAOH,KAAK,GAAG;YAAE,GAAGG,OAAOH,KAAK;YAAE0C,QAAQ,CAAC,CAACrE,QAAQoB,aAAa,CAACiD,MAAM,CAACC,EAAE;QAAC;IAChF;IACA,IAAItE,QAAQoB,aAAa,CAACiD,MAAM,CAACvB,GAAG,KAAKpD,WAAW;QAChDoC,OAAOH,KAAK,GAAG;YAAE,GAAGG,OAAOH,KAAK;YAAE4C,WAAW,CAAC,CAACvE,QAAQoB,aAAa,CAACiD,MAAM,CAACvB,GAAG;QAAC;IACpF;IAEA,iFAAiF;IACjF,IAAI9C,QAAQwE,OAAO,CAACC,YAAY,EAAE;QAC9B3C,OAAOH,KAAK,GAAG;YAAE,GAAGG,OAAOH,KAAK;YAAE0C,QAAQ;QAAM;IACpD;IAEA,OAAOvC;AACX"}
|
|
1
|
+
{"version":3,"sources":["../../../src/vite/config/base-config.ts"],"sourcesContent":["import type { InlineConfig, Plugin } from 'vite';\nimport {\n bundleConstants,\n defineExposedDependencies,\n defineExposedInstanceDependencies,\n defineWebComponentName,\n getBundleType,\n getCdnPath,\n getProcessEnv,\n} from '../../core';\nimport { omit } from '../../utils';\nimport {\n bundleStatPlugin,\n chainSourceMapsPlugin,\n cleanPlugin,\n cssInjectorPlugin,\n designSystemGuardPlugin,\n devServerRoutingPlugin,\n externalsPlugin,\n htmlPlugin,\n ignoreModulesPlugin,\n istanbulPlugin,\n magicCommentsPlugin,\n metadataPlugin,\n momentLocalesPlugin,\n reactRefreshPlugin,\n styleUrlsPlugin,\n svgrPlugin,\n virtualModulesPlugin,\n} from '../plugins';\nimport { ViteBuildContext } from '../types';\nimport { assetFileNames } from './asset-file-names';\nimport { getCodeSplitting } from './code-splitting';\nimport { createCssConfig } from './create-css-config';\nimport { createFilteringLogger } from './create-filtering-logger';\nimport { createResolveConfig } from './create-resolve-config';\n\nfunction importMetaRemap(\n ...definitions: (Record<string, string> | undefined)[]\n): Record<string, string> {\n const result: Record<string, string> = {};\n\n definitions\n .filter(definition => definition !== undefined)\n .forEach(definition =>\n Object.keys(definition).forEach(item => {\n result[`import.meta.env.${item}`] = definition[item];\n })\n );\n\n return result;\n}\n\nfunction createPlugins(context: ViteBuildContext) {\n const entries: [string, Plugin[] | Plugin | Promise<Plugin> | undefined][] = [\n ['reactRefresh', reactRefreshPlugin(context)],\n ['bundleStat', bundleStatPlugin(context)],\n ['clean', cleanPlugin(context)],\n ['cssInjector', cssInjectorPlugin(context)],\n ['designSystemGuard', designSystemGuardPlugin(context)],\n ['devServerRouting', devServerRoutingPlugin(context)],\n ['externals', externalsPlugin(context)],\n ['html', htmlPlugin(context)],\n ['ignoreModules', ignoreModulesPlugin(context)],\n ['istanbul', istanbulPlugin(context)],\n ['magicComments', magicCommentsPlugin(context)],\n ['metadata', metadataPlugin(context)],\n ['momentLocales', momentLocalesPlugin(context)],\n ['styleUrls', styleUrlsPlugin(context)],\n ['svgr', svgrPlugin(context)],\n ['virtualModules', virtualModulesPlugin(context)],\n ];\n\n return entries\n .filter(\n ([name, plugin]) =>\n plugin && !context.bundlerConfig.omitDefault?.includes(`plugins.${name}`)\n )\n .flatMap(([, plugin]) => plugin);\n}\n\nexport function createBaseConfig(context: ViteBuildContext): InlineConfig {\n const optimizedStartupDependencies = ['@servicetitan/startup-utils', 'react-refresh/runtime'];\n const { isProduction } = context.build;\n const { isWebComponent } = context.package;\n\n let config: InlineConfig = {\n cacheDir: `node_modules/.vite/${getBundleType(context) ?? 'host'}`,\n customLogger: createFilteringLogger(),\n server: {\n // Windows machines can fail to connect to \"localhost\"; bind to a fixed address instead.\n host: '127.0.0.1',\n port: context.bundlerConfig.port ?? (isWebComponent ? 8888 : 8080),\n },\n mode: isProduction ? bundleConstants.mode.production : bundleConstants.mode.development,\n configFile: false,\n oxc: { legalComments: 'none' },\n base: getCdnPath(context) || './', // eslint-disable-line @typescript-eslint/prefer-nullish-coalescing\n css: createCssConfig(isProduction),\n build: {\n /*\n * MFEs render inside shadow DOM — lazy CSS chunks would inject into document.head,\n * leaking styles into the host. Bundling all CSS into one file avoids this.\n */\n cssCodeSplit: !isWebComponent,\n sourcemap: true,\n rolldownOptions: {\n output: { assetFileNames, codeSplitting: getCodeSplitting(context) },\n plugins: [chainSourceMapsPlugin()],\n },\n },\n define: {\n /*\n * Some dependencies assume Node's `global` exists (webpack polyfills this\n * automatically for browser targets; Vite does not).\n */\n global: 'globalThis',\n ...importMetaRemap(\n defineExposedDependencies(context),\n defineExposedInstanceDependencies(context),\n defineWebComponentName(context)\n ),\n ...(getProcessEnv(context) ?? {}),\n },\n resolve: createResolveConfig(context, optimizedStartupDependencies),\n optimizeDeps: {\n include: [\n ...optimizedStartupDependencies,\n 'react/jsx-runtime',\n 'react/jsx-dev-runtime',\n ],\n /*\n * Top-level plugins don't run during dependency pre-bundling, so\n * register ignoreModulesPlugin again here. Without this, missing\n * optional peer dependencies inside pre-bundled packages throw at\n * runtime instead of resolving to an empty module.\n */\n rolldownOptions: {\n plugins: [ignoreModulesPlugin(context)],\n },\n },\n plugins: createPlugins(context),\n };\n\n const omitKeys = context.bundlerConfig.omitDefault?.filter(k => !k.startsWith('plugins.'));\n if (omitKeys?.length) {\n config = omit({ ...config }, omitKeys);\n }\n\n if (context.bundlerConfig.minify.js !== undefined) {\n config.build = { ...config.build, minify: !!context.bundlerConfig.minify.js };\n }\n if (context.bundlerConfig.minify.css !== undefined) {\n config.build = { ...config.build, cssMinify: !!context.bundlerConfig.minify.css };\n }\n\n // Minified output can't be mapped back to source, so skip it when instrumenting.\n if (context.options.codeCoverage) {\n config.build = { ...config.build, minify: false };\n }\n\n return config;\n}\n"],"names":["createBaseConfig","importMetaRemap","definitions","result","filter","definition","undefined","forEach","Object","keys","item","createPlugins","context","entries","reactRefreshPlugin","bundleStatPlugin","cleanPlugin","cssInjectorPlugin","designSystemGuardPlugin","devServerRoutingPlugin","externalsPlugin","htmlPlugin","ignoreModulesPlugin","istanbulPlugin","magicCommentsPlugin","metadataPlugin","momentLocalesPlugin","styleUrlsPlugin","svgrPlugin","virtualModulesPlugin","name","plugin","bundlerConfig","omitDefault","includes","flatMap","getBundleType","getProcessEnv","optimizedStartupDependencies","isProduction","build","isWebComponent","package","config","cacheDir","customLogger","createFilteringLogger","server","host","port","mode","bundleConstants","production","development","configFile","oxc","legalComments","base","getCdnPath","css","createCssConfig","cssCodeSplit","sourcemap","rolldownOptions","output","assetFileNames","codeSplitting","getCodeSplitting","plugins","chainSourceMapsPlugin","define","global","defineExposedDependencies","defineExposedInstanceDependencies","defineWebComponentName","resolve","createResolveConfig","optimizeDeps","include","omitKeys","k","startsWith","length","omit","minify","js","cssMinify","options","codeCoverage"],"mappings":";;;;+BAiFgBA;;;eAAAA;;;sBAxET;uBACc;yBAmBd;gCAEwB;+BACE;iCACD;uCACM;qCACF;AAEpC,SAASC,gBACL,GAAGC,WAAmD;IAEtD,MAAMC,SAAiC,CAAC;IAExCD,YACKE,MAAM,CAACC,CAAAA,aAAcA,eAAeC,WACpCC,OAAO,CAACF,CAAAA,aACLG,OAAOC,IAAI,CAACJ,YAAYE,OAAO,CAACG,CAAAA;YAC5BP,MAAM,CAAC,CAAC,gBAAgB,EAAEO,MAAM,CAAC,GAAGL,UAAU,CAACK,KAAK;QACxD;IAGR,OAAOP;AACX;AAEA,SAASQ,cAAcC,OAAyB;IAC5C,MAAMC,UAAuE;QACzE;YAAC;YAAgBC,IAAAA,2BAAkB,EAACF;SAAS;QAC7C;YAAC;YAAcG,IAAAA,yBAAgB,EAACH;SAAS;QACzC;YAAC;YAASI,IAAAA,oBAAW,EAACJ;SAAS;QAC/B;YAAC;YAAeK,IAAAA,0BAAiB,EAACL;SAAS;QAC3C;YAAC;YAAqBM,IAAAA,gCAAuB,EAACN;SAAS;QACvD;YAAC;YAAoBO,IAAAA,+BAAsB,EAACP;SAAS;QACrD;YAAC;YAAaQ,IAAAA,wBAAe,EAACR;SAAS;QACvC;YAAC;YAAQS,IAAAA,mBAAU,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E4C,QAAQ,CAAC,CAACxE,QAAQoB,aAAa,CAACoD,MAAM,CAACC,EAAE;QAAC;IAChF;IACA,IAAIzE,QAAQoB,aAAa,CAACoD,MAAM,CAACzB,GAAG,KAAKrD,WAAW;QAChDqC,OAAOH,KAAK,GAAG;YAAE,GAAGG,OAAOH,KAAK;YAAE8C,WAAW,CAAC,CAAC1E,QAAQoB,aAAa,CAACoD,MAAM,CAACzB,GAAG;QAAC;IACpF;IAEA,iFAAiF;IACjF,IAAI/C,QAAQ2E,OAAO,CAACC,YAAY,EAAE;QAC9B7C,OAAOH,KAAK,GAAG;YAAE,GAAGG,OAAOH,KAAK;YAAE4C,QAAQ;QAAM;IACpD;IAEA,OAAOzC;AACX"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { InlineConfig } from 'vite';
|
|
2
|
+
import type { ViteBuildContext } from '../types';
|
|
3
|
+
type Result = InlineConfig['resolve'];
|
|
4
|
+
export declare function createResolveConfig(context: ViteBuildContext, specifiers: string[]): Result;
|
|
5
|
+
export {};
|
|
6
|
+
//# sourceMappingURL=create-resolve-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-resolve-config.d.ts","sourceRoot":"","sources":["../../../src/vite/config/create-resolve-config.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AAEzC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAEjD,KAAK,MAAM,GAAG,YAAY,CAAC,SAAS,CAAC,CAAC;AAQtC,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG,MAAM,CAW3F"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "createResolveConfig", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return createResolveConfig;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _module = require("module");
|
|
12
|
+
const _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
13
|
+
const _buildescapedregexp = require("../build-escaped-reg-exp");
|
|
14
|
+
function _interop_require_default(obj) {
|
|
15
|
+
return obj && obj.__esModule ? obj : {
|
|
16
|
+
default: obj
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
const startupRequire = (0, _module.createRequire)(__filename);
|
|
20
|
+
function createResolveConfig(context, specifiers) {
|
|
21
|
+
const source = _path.default.resolve(context.package.source);
|
|
22
|
+
const alias = specifiers.filter((specifier)=>!isResolvableFrom(specifier, source)).map((specifier)=>({
|
|
23
|
+
find: (0, _buildescapedregexp.buildEscapedRegExp)(specifier),
|
|
24
|
+
replacement: resolveFromStartup(specifier)
|
|
25
|
+
}));
|
|
26
|
+
return {
|
|
27
|
+
alias
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function isResolvableFrom(specifier, source) {
|
|
31
|
+
try {
|
|
32
|
+
require.resolve(specifier, {
|
|
33
|
+
paths: [
|
|
34
|
+
source
|
|
35
|
+
]
|
|
36
|
+
});
|
|
37
|
+
return true;
|
|
38
|
+
} catch (unused) {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
function resolveFromStartup(specifier) {
|
|
43
|
+
try {
|
|
44
|
+
return startupRequire.resolve(specifier);
|
|
45
|
+
} catch (cause) {
|
|
46
|
+
throw new Error(`[startup] Cannot resolve ${specifier}`, {
|
|
47
|
+
cause
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
//# sourceMappingURL=create-resolve-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/vite/config/create-resolve-config.ts"],"sourcesContent":["import { createRequire } from 'module';\nimport path from 'path';\nimport type { InlineConfig } from 'vite';\nimport { buildEscapedRegExp } from '../build-escaped-reg-exp';\nimport type { ViteBuildContext } from '../types';\n\ntype Result = InlineConfig['resolve'];\n\nconst startupRequire = createRequire(__filename);\n\n/*\n * Returns a resolver that, when normal resolution fails for a specifier,\n * tries resolving from startup's location.\n */\nexport function createResolveConfig(context: ViteBuildContext, specifiers: string[]): Result {\n const source = path.resolve(context.package.source);\n\n const alias = specifiers\n .filter(specifier => !isResolvableFrom(specifier, source))\n .map(specifier => ({\n find: buildEscapedRegExp(specifier),\n replacement: resolveFromStartup(specifier),\n }));\n\n return { alias };\n}\n\nfunction isResolvableFrom(specifier: string, source: string): boolean {\n try {\n require.resolve(specifier, { paths: [source] });\n return true;\n } catch {\n return false;\n }\n}\n\nfunction resolveFromStartup(specifier: string): string {\n try {\n return startupRequire.resolve(specifier);\n } catch (cause) {\n throw new Error(`[startup] Cannot resolve ${specifier}`, { cause });\n }\n}\n"],"names":["createResolveConfig","startupRequire","createRequire","__filename","context","specifiers","source","path","resolve","package","alias","filter","specifier","isResolvableFrom","map","find","buildEscapedRegExp","replacement","resolveFromStartup","require","paths","cause","Error"],"mappings":";;;;+BAcgBA;;;eAAAA;;;wBAdc;6DACb;oCAEkB;;;;;;AAKnC,MAAMC,iBAAiBC,IAAAA,qBAAa,EAACC;AAM9B,SAASH,oBAAoBI,OAAyB,EAAEC,UAAoB;IAC/E,MAAMC,SAASC,aAAI,CAACC,OAAO,CAACJ,QAAQK,OAAO,CAACH,MAAM;IAElD,MAAMI,QAAQL,WACTM,MAAM,CAACC,CAAAA,YAAa,CAACC,iBAAiBD,WAAWN,SACjDQ,GAAG,CAACF,CAAAA,YAAc,CAAA;YACfG,MAAMC,IAAAA,sCAAkB,EAACJ;YACzBK,aAAaC,mBAAmBN;QACpC,CAAA;IAEJ,OAAO;QAAEF;IAAM;AACnB;AAEA,SAASG,iBAAiBD,SAAiB,EAAEN,MAAc;IACvD,IAAI;QACAa,QAAQX,OAAO,CAACI,WAAW;YAAEQ,OAAO;gBAACd;aAAO;QAAC;QAC7C,OAAO;IACX,EAAE,eAAM;QACJ,OAAO;IACX;AACJ;AAEA,SAASY,mBAAmBN,SAAiB;IACzC,IAAI;QACA,OAAOX,eAAeO,OAAO,CAACI;IAClC,EAAE,OAAOS,OAAO;QACZ,MAAM,IAAIC,MAAM,CAAC,yBAAyB,EAAEV,WAAW,EAAE;YAAES;QAAM;IACrE;AACJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"css-injector-plugin.d.ts","sourceRoot":"","sources":["../../../src/vite/plugins/css-injector-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AACnC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAgB/C,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,YAAY,GAAG,MAAM,GAAG,SAAS,
|
|
1
|
+
{"version":3,"file":"css-injector-plugin.d.ts","sourceRoot":"","sources":["../../../src/vite/plugins/css-injector-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AACnC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAgB/C,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,YAAY,GAAG,MAAM,GAAG,SAAS,CAoD3E"}
|
|
@@ -30,7 +30,11 @@ function cssInjectorPlugin(context) {
|
|
|
30
30
|
if (!importPattern.test(transformed) || !transformed.includes(callPattern)) {
|
|
31
31
|
this.error(`[startup] Failed to transform CSS module — Vite's internal output format may have changed. File: ${id}`);
|
|
32
32
|
}
|
|
33
|
-
transformed = transformed.replace(importPattern,
|
|
33
|
+
transformed = transformed.replace(importPattern, /*
|
|
34
|
+
* Leaf module, not the package root: the root reaches anvil2, whose
|
|
35
|
+
* stylesheets are rewritten here, and the cycle leaves the registry
|
|
36
|
+
* undefined.
|
|
37
|
+
*/ `import { MfeStyleRegistry as __mfe__Registry } from '@servicetitan/web-components/css-injector/mfe-style-registry'`).replace(callPattern, `__mfe__Registry.for(${JSON.stringify(name)}).injectSheet(__vite__id, __vite__css)`).replace(/import\.meta\.hot\.prune\(\(\) => __vite__removeStyle\(__vite__id\)\)/, '');
|
|
34
38
|
return {
|
|
35
39
|
code: transformed,
|
|
36
40
|
map: null
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/vite/plugins/css-injector-plugin.ts"],"sourcesContent":["import type { Plugin } from 'vite';\nimport type { BuildContext } from '../../core';\n\n/*\n * Replaces Vite's default CSS injection (<style> tags in document.head) with\n * MfeStyleRegistry.injectSheet() from @servicetitan/web-components, which\n * creates CSSStyleSheet objects that can be adopted into shadow roots.\n *\n * Works by transforming Vite's CSS module output at enforce:'post'. Vite\n * transforms CSS imports into JS modules that call updateStyle(id, css) from\n * /@vite/client — this plugin replaces that call with injectSheet().\n *\n * HMR works automatically: when a CSS file changes, Vite re-evaluates the\n * module, which re-runs injectSheet(). Existing CSSStyleSheet objects are\n * updated via replaceSync(), so all shadow roots that adopted them see the\n * change immediately.\n */\nexport function cssInjectorPlugin(context: BuildContext): Plugin | undefined {\n const { name, isProduction } = context.build;\n const { isWebComponent } = context.package;\n if (!isWebComponent || isProduction) {\n return;\n }\n\n return {\n name: 'st:mfe-css-injector',\n enforce: 'post',\n transform(code, id) {\n if (!id.endsWith('.css') && !id.endsWith('.less') && !id.endsWith('.scss')) {\n return;\n }\n if (!code.includes('__vite__updateStyle')) {\n return;\n }\n\n let transformed = code;\n\n const importPattern =\n /import \\{ updateStyle as __vite__updateStyle, removeStyle as __vite__removeStyle \\} from [^\\n]+/;\n const callPattern = '__vite__updateStyle(__vite__id, __vite__css)';\n\n if (!importPattern.test(transformed) || !transformed.includes(callPattern)) {\n this.error(\n `[startup] Failed to transform CSS module — Vite's internal output format may have changed. File: ${id}`\n );\n }\n\n transformed = transformed\n .replace(\n importPattern,\n `import { MfeStyleRegistry as __mfe__Registry } from '@servicetitan/web-components'`\n )\n .replace(\n callPattern,\n `__mfe__Registry.for(${JSON.stringify(name)}).injectSheet(__vite__id, __vite__css)`\n )\n .replace(\n /import\\.meta\\.hot\\.prune\\(\\(\\) => __vite__removeStyle\\(__vite__id\\)\\)/,\n ''\n );\n\n return { code: transformed, map: null };\n },\n };\n}\n"],"names":["cssInjectorPlugin","context","name","isProduction","build","isWebComponent","package","enforce","transform","code","id","endsWith","includes","transformed","importPattern","callPattern","test","error","replace","JSON","stringify","map"],"mappings":";;;;+BAiBgBA;;;eAAAA;;;AAAT,SAASA,kBAAkBC,OAAqB;IACnD,MAAM,EAAEC,IAAI,EAAEC,YAAY,EAAE,GAAGF,QAAQG,KAAK;IAC5C,MAAM,EAAEC,cAAc,EAAE,GAAGJ,QAAQK,OAAO;IAC1C,IAAI,CAACD,kBAAkBF,cAAc;QACjC;IACJ;IAEA,OAAO;QACHD,MAAM;QACNK,SAAS;QACTC,WAAUC,IAAI,EAAEC,EAAE;YACd,IAAI,CAACA,GAAGC,QAAQ,CAAC,WAAW,CAACD,GAAGC,QAAQ,CAAC,YAAY,CAACD,GAAGC,QAAQ,CAAC,UAAU;gBACxE;YACJ;YACA,IAAI,CAACF,KAAKG,QAAQ,CAAC,wBAAwB;gBACvC;YACJ;YAEA,IAAIC,cAAcJ;YAElB,MAAMK,gBACF;YACJ,MAAMC,cAAc;YAEpB,IAAI,CAACD,cAAcE,IAAI,CAACH,gBAAgB,CAACA,YAAYD,QAAQ,CAACG,cAAc;gBACxE,IAAI,CAACE,KAAK,CACN,CAAC,iGAAiG,EAAEP,IAAI;YAEhH;YAEAG,cAAcA,YACTK,OAAO,CACJJ,eACA,CAAC,
|
|
1
|
+
{"version":3,"sources":["../../../src/vite/plugins/css-injector-plugin.ts"],"sourcesContent":["import type { Plugin } from 'vite';\nimport type { BuildContext } from '../../core';\n\n/*\n * Replaces Vite's default CSS injection (<style> tags in document.head) with\n * MfeStyleRegistry.injectSheet() from @servicetitan/web-components, which\n * creates CSSStyleSheet objects that can be adopted into shadow roots.\n *\n * Works by transforming Vite's CSS module output at enforce:'post'. Vite\n * transforms CSS imports into JS modules that call updateStyle(id, css) from\n * /@vite/client — this plugin replaces that call with injectSheet().\n *\n * HMR works automatically: when a CSS file changes, Vite re-evaluates the\n * module, which re-runs injectSheet(). Existing CSSStyleSheet objects are\n * updated via replaceSync(), so all shadow roots that adopted them see the\n * change immediately.\n */\nexport function cssInjectorPlugin(context: BuildContext): Plugin | undefined {\n const { name, isProduction } = context.build;\n const { isWebComponent } = context.package;\n if (!isWebComponent || isProduction) {\n return;\n }\n\n return {\n name: 'st:mfe-css-injector',\n enforce: 'post',\n transform(code, id) {\n if (!id.endsWith('.css') && !id.endsWith('.less') && !id.endsWith('.scss')) {\n return;\n }\n if (!code.includes('__vite__updateStyle')) {\n return;\n }\n\n let transformed = code;\n\n const importPattern =\n /import \\{ updateStyle as __vite__updateStyle, removeStyle as __vite__removeStyle \\} from [^\\n]+/;\n const callPattern = '__vite__updateStyle(__vite__id, __vite__css)';\n\n if (!importPattern.test(transformed) || !transformed.includes(callPattern)) {\n this.error(\n `[startup] Failed to transform CSS module — Vite's internal output format may have changed. File: ${id}`\n );\n }\n\n transformed = transformed\n .replace(\n importPattern,\n /*\n * Leaf module, not the package root: the root reaches anvil2, whose\n * stylesheets are rewritten here, and the cycle leaves the registry\n * undefined.\n */\n `import { MfeStyleRegistry as __mfe__Registry } from '@servicetitan/web-components/css-injector/mfe-style-registry'`\n )\n .replace(\n callPattern,\n `__mfe__Registry.for(${JSON.stringify(name)}).injectSheet(__vite__id, __vite__css)`\n )\n .replace(\n /import\\.meta\\.hot\\.prune\\(\\(\\) => __vite__removeStyle\\(__vite__id\\)\\)/,\n ''\n );\n\n return { code: transformed, map: null };\n },\n };\n}\n"],"names":["cssInjectorPlugin","context","name","isProduction","build","isWebComponent","package","enforce","transform","code","id","endsWith","includes","transformed","importPattern","callPattern","test","error","replace","JSON","stringify","map"],"mappings":";;;;+BAiBgBA;;;eAAAA;;;AAAT,SAASA,kBAAkBC,OAAqB;IACnD,MAAM,EAAEC,IAAI,EAAEC,YAAY,EAAE,GAAGF,QAAQG,KAAK;IAC5C,MAAM,EAAEC,cAAc,EAAE,GAAGJ,QAAQK,OAAO;IAC1C,IAAI,CAACD,kBAAkBF,cAAc;QACjC;IACJ;IAEA,OAAO;QACHD,MAAM;QACNK,SAAS;QACTC,WAAUC,IAAI,EAAEC,EAAE;YACd,IAAI,CAACA,GAAGC,QAAQ,CAAC,WAAW,CAACD,GAAGC,QAAQ,CAAC,YAAY,CAACD,GAAGC,QAAQ,CAAC,UAAU;gBACxE;YACJ;YACA,IAAI,CAACF,KAAKG,QAAQ,CAAC,wBAAwB;gBACvC;YACJ;YAEA,IAAIC,cAAcJ;YAElB,MAAMK,gBACF;YACJ,MAAMC,cAAc;YAEpB,IAAI,CAACD,cAAcE,IAAI,CAACH,gBAAgB,CAACA,YAAYD,QAAQ,CAACG,cAAc;gBACxE,IAAI,CAACE,KAAK,CACN,CAAC,iGAAiG,EAAEP,IAAI;YAEhH;YAEAG,cAAcA,YACTK,OAAO,CACJJ,eACA;;;;qBAIC,GACD,CAAC,kHAAkH,CAAC,EAEvHI,OAAO,CACJH,aACA,CAAC,oBAAoB,EAAEI,KAAKC,SAAS,CAAClB,MAAM,sCAAsC,CAAC,EAEtFgB,OAAO,CACJ,yEACA;YAGR,OAAO;gBAAET,MAAMI;gBAAaQ,KAAK;YAAK;QAC1C;IACJ;AACJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"externals-plugin.d.ts","sourceRoot":"","sources":["../../../src/vite/plugins/externals-plugin.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AACnC,OAAO,EAAE,YAAY,EAAgB,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"externals-plugin.d.ts","sourceRoot":"","sources":["../../../src/vite/plugins/externals-plugin.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AACnC,OAAO,EAAE,YAAY,EAAgB,MAAM,YAAY,CAAC;AAiCxD,wBAAgB,eAAe,CAAC,OAAO,EAAE,YAAY,GAAG,MAAM,GAAG,SAAS,CAkDzE"}
|
|
@@ -11,12 +11,12 @@ Object.defineProperty(exports, "externalsPlugin", {
|
|
|
11
11
|
const _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
|
|
12
12
|
const _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
13
13
|
const _core = require("../../core");
|
|
14
|
+
const _buildescapedregexp = require("../build-escaped-reg-exp");
|
|
14
15
|
function _interop_require_default(obj) {
|
|
15
16
|
return obj && obj.__esModule ? obj : {
|
|
16
17
|
default: obj
|
|
17
18
|
};
|
|
18
19
|
}
|
|
19
|
-
/* Dots are the only valid regex-special character in package names */ const buildEscapedRegExp = (dependency)=>new RegExp(`^${dependency.replace(/\./g, '\\.')}$`);
|
|
20
20
|
function externalsPlugin(context) {
|
|
21
21
|
const entries = (0, _core.getExternals)(context);
|
|
22
22
|
if (!entries) {
|
|
@@ -42,7 +42,7 @@ function externalsPlugin(context) {
|
|
|
42
42
|
config: isProduction ? undefined : ()=>({
|
|
43
43
|
resolve: {
|
|
44
44
|
alias: Object.keys(entries).map((dep)=>({
|
|
45
|
-
find: buildEscapedRegExp(dep),
|
|
45
|
+
find: (0, _buildescapedregexp.buildEscapedRegExp)(dep),
|
|
46
46
|
replacement: _path.default.join(proxyNodeModules, dep)
|
|
47
47
|
}))
|
|
48
48
|
},
|
|
@@ -52,7 +52,7 @@ function externalsPlugin(context) {
|
|
|
52
52
|
}),
|
|
53
53
|
resolveId: isProduction ? {
|
|
54
54
|
filter: {
|
|
55
|
-
id: Object.keys(entries).map(buildEscapedRegExp)
|
|
55
|
+
id: Object.keys(entries).map(_buildescapedregexp.buildEscapedRegExp)
|
|
56
56
|
},
|
|
57
57
|
handler (source) {
|
|
58
58
|
if (source in entries) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/vite/plugins/externals-plugin.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\nimport type { Plugin } from 'vite';\nimport { BuildContext, getExternals } from '../../core';\
|
|
1
|
+
{"version":3,"sources":["../../../src/vite/plugins/externals-plugin.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\nimport type { Plugin } from 'vite';\nimport { BuildContext, getExternals } from '../../core';\nimport { buildEscapedRegExp } from '../build-escaped-reg-exp';\n\n/*\n * Externalizes shared dependencies by redirecting imports to CJS proxy modules\n * that read from the host's global shared deps registry at runtime.\n *\n * Each shared dep gets a fake package on disk (node_modules/.startup/externals/)\n * with `module.exports = SharedDependencies.Foo['scope']`.\n *\n * Three mechanisms work together, each handling a different mode:\n *\n * - resolve.alias (dev) — exact-match regex redirects `react` to the proxy package.\n * Subpath imports (react/jsx-runtime) are NOT matched and resolve normally.\n *\n * - optimizeDeps.include (dev) — forces Vite to pre-bundle the proxy packages.\n * This triggers Vite's CJS-to-ESM interop: the pre-bundled output has `export default`,\n * and Vite's import-analysis plugin rewrites consumers' named imports to property access\n * on the default export (e.g. `import { useState } from 'react'` becomes\n * `const useState = __default[\"useState\"]`). Without optimizeDeps, the raw CJS proxy\n * would be served to the browser and fail on named imports.\n *\n * - resolveId (prod) — resolve.alias doesn't run during Rolldown bundling, so resolveId\n * with enforce:'pre' intercepts shared dep imports before Vite's default resolver.\n * Rolldown handles CJS-to-ESM interop natively via __commonJSMin/__toESM helpers.\n * Only exact matches — subpath imports must NOT be redirected because they export\n * different things than the barrel.\n *\n * The disk-based proxy + optimizeDeps complexity exists because Vite's dev server serves\n * modules as native ESM without bundling — CJS virtual modules can't be served to the browser.\n * When Vite's \"full bundle\" dev mode ships (Rolldown bundles in dev, like prod), this can be\n * simplified to a single resolveId + load with a virtual CJS module for both modes (see 9ffd1815).\n */\nexport function externalsPlugin(context: BuildContext): Plugin | undefined {\n const entries = getExternals(context);\n if (!entries) {\n return;\n }\n\n const proxyModulesDir = path.resolve('node_modules', '.startup', 'externals');\n for (const [dep, proxy] of Object.entries(entries)) {\n const pkgDir = path.join(proxyModulesDir, 'node_modules', dep);\n fs.mkdirSync(pkgDir, { recursive: true });\n fs.writeFileSync(path.join(pkgDir, 'index.cjs'), `module.exports = ${proxy};`);\n fs.writeFileSync(\n path.join(pkgDir, 'package.json'),\n JSON.stringify({ name: dep, main: './index.cjs' })\n );\n }\n\n const proxyNodeModules = path.join(proxyModulesDir, 'node_modules');\n\n const { isProduction } = context.build;\n\n return {\n name: 'st:externals',\n enforce: 'pre',\n config: isProduction\n ? undefined\n : () => ({\n resolve: {\n alias: Object.keys(entries).map(dep => ({\n find: buildEscapedRegExp(dep),\n replacement: path.join(proxyNodeModules, dep),\n })),\n },\n optimizeDeps: {\n include: Object.keys(entries),\n },\n }),\n resolveId: isProduction\n ? {\n filter: {\n id: Object.keys(entries).map(buildEscapedRegExp),\n },\n handler(source: string) {\n if (source in entries) {\n return path.join(proxyNodeModules, source, 'index.cjs');\n }\n },\n }\n : undefined,\n };\n}\n"],"names":["externalsPlugin","context","entries","getExternals","proxyModulesDir","path","resolve","dep","proxy","Object","pkgDir","join","fs","mkdirSync","recursive","writeFileSync","JSON","stringify","name","main","proxyNodeModules","isProduction","build","enforce","config","undefined","alias","keys","map","find","buildEscapedRegExp","replacement","optimizeDeps","include","resolveId","filter","id","handler","source"],"mappings":";;;;+BAoCgBA;;;eAAAA;;;2DApCD;6DACE;sBAE0B;oCACR;;;;;;AAgC5B,SAASA,gBAAgBC,OAAqB;IACjD,MAAMC,UAAUC,IAAAA,kBAAY,EAACF;IAC7B,IAAI,CAACC,SAAS;QACV;IACJ;IAEA,MAAME,kBAAkBC,aAAI,CAACC,OAAO,CAAC,gBAAgB,YAAY;IACjE,KAAK,MAAM,CAACC,KAAKC,MAAM,IAAIC,OAAOP,OAAO,CAACA,SAAU;QAChD,MAAMQ,SAASL,aAAI,CAACM,IAAI,CAACP,iBAAiB,gBAAgBG;QAC1DK,WAAE,CAACC,SAAS,CAACH,QAAQ;YAAEI,WAAW;QAAK;QACvCF,WAAE,CAACG,aAAa,CAACV,aAAI,CAACM,IAAI,CAACD,QAAQ,cAAc,CAAC,iBAAiB,EAAEF,MAAM,CAAC,CAAC;QAC7EI,WAAE,CAACG,aAAa,CACZV,aAAI,CAACM,IAAI,CAACD,QAAQ,iBAClBM,KAAKC,SAAS,CAAC;YAAEC,MAAMX;YAAKY,MAAM;QAAc;IAExD;IAEA,MAAMC,mBAAmBf,aAAI,CAACM,IAAI,CAACP,iBAAiB;IAEpD,MAAM,EAAEiB,YAAY,EAAE,GAAGpB,QAAQqB,KAAK;IAEtC,OAAO;QACHJ,MAAM;QACNK,SAAS;QACTC,QAAQH,eACFI,YACA,IAAO,CAAA;gBACHnB,SAAS;oBACLoB,OAAOjB,OAAOkB,IAAI,CAACzB,SAAS0B,GAAG,CAACrB,CAAAA,MAAQ,CAAA;4BACpCsB,MAAMC,IAAAA,sCAAkB,EAACvB;4BACzBwB,aAAa1B,aAAI,CAACM,IAAI,CAACS,kBAAkBb;wBAC7C,CAAA;gBACJ;gBACAyB,cAAc;oBACVC,SAASxB,OAAOkB,IAAI,CAACzB;gBACzB;YACJ,CAAA;QACNgC,WAAWb,eACL;YACIc,QAAQ;gBACJC,IAAI3B,OAAOkB,IAAI,CAACzB,SAAS0B,GAAG,CAACE,sCAAkB;YACnD;YACAO,SAAQC,MAAc;gBAClB,IAAIA,UAAUpC,SAAS;oBACnB,OAAOG,aAAI,CAACM,IAAI,CAACS,kBAAkBkB,QAAQ;gBAC/C;YACJ;QACJ,IACAb;IACV;AACJ"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@servicetitan/startup",
|
|
3
|
-
"version": "39.0
|
|
3
|
+
"version": "39.2.0",
|
|
4
4
|
"description": "CLI to create multi-package Lerna projects with TypeScript and React",
|
|
5
5
|
"homepage": "https://docs.st.dev/docs/frontend/uikit/startup",
|
|
6
6
|
"repository": {
|
|
@@ -103,20 +103,20 @@
|
|
|
103
103
|
"@jest/core": "~30.4.2",
|
|
104
104
|
"@jest/types": "~30.4.1",
|
|
105
105
|
"@jsdevtools/coverage-istanbul-loader": "^3.0.5",
|
|
106
|
-
"@servicetitan/eslint-config": "39.0
|
|
107
|
-
"@servicetitan/install": "39.0
|
|
108
|
-
"@servicetitan/startup-utils": "39.0
|
|
109
|
-
"@servicetitan/stylelint-config": "39.0
|
|
106
|
+
"@servicetitan/eslint-config": "39.2.0",
|
|
107
|
+
"@servicetitan/install": "39.2.0",
|
|
108
|
+
"@servicetitan/startup-utils": "39.2.0",
|
|
109
|
+
"@servicetitan/stylelint-config": "39.2.0",
|
|
110
110
|
"@svgr/webpack": "^8.1.0",
|
|
111
111
|
"@swc/cli": "^0.8.1",
|
|
112
|
-
"@swc/core": "1.
|
|
112
|
+
"@swc/core": "1.16.1",
|
|
113
113
|
"@types/debug": "^4.1.12",
|
|
114
114
|
"@types/jest": "~30.0.0",
|
|
115
|
-
"@vitest/coverage-v8": "^4.1.
|
|
115
|
+
"@vitest/coverage-v8": "^4.1.11",
|
|
116
116
|
"chalk": "~4.1.2",
|
|
117
117
|
"cli-table3": "^0.6.5",
|
|
118
118
|
"cpx2": "9.0.0",
|
|
119
|
-
"css-loader": "~7.1.
|
|
119
|
+
"css-loader": "~7.1.5",
|
|
120
120
|
"css-minimizer-webpack-plugin": "^8.0.0",
|
|
121
121
|
"debug": "^4.4.3",
|
|
122
122
|
"deepmerge": "~4.3.1",
|
|
@@ -132,15 +132,15 @@
|
|
|
132
132
|
"jest-circus": "~30.4.2",
|
|
133
133
|
"jest-environment-jsdom": "~30.4.1",
|
|
134
134
|
"jest-fetch-mock": "~4.2.0",
|
|
135
|
-
"js-yaml": "~5.
|
|
135
|
+
"js-yaml": "~5.4.1",
|
|
136
136
|
"json5": "^2.2.3",
|
|
137
137
|
"lerna": "~9.0.7",
|
|
138
|
-
"less": "~4.
|
|
138
|
+
"less": "~4.9.0",
|
|
139
139
|
"less-loader": "~13.0.0",
|
|
140
140
|
"less-plugin-npm-import": "~2.1.0",
|
|
141
141
|
"lodash.kebabcase": "^4.1.1",
|
|
142
142
|
"lodash.memoize": "^4.1.2",
|
|
143
|
-
"magic-string": "^1.
|
|
143
|
+
"magic-string": "^1.2.3",
|
|
144
144
|
"memfs": "~4.68.1",
|
|
145
145
|
"mini-css-extract-plugin": "~2.10.2",
|
|
146
146
|
"minimizer-webpack-plugin": "^5.6.1",
|
|
@@ -148,7 +148,7 @@
|
|
|
148
148
|
"multimatch": "~8.0.0",
|
|
149
149
|
"patch-package": "^8.0.1",
|
|
150
150
|
"portfinder": "~1.0.38",
|
|
151
|
-
"postcss": "~8.5.
|
|
151
|
+
"postcss": "~8.5.26",
|
|
152
152
|
"prettier": "~3.9.6",
|
|
153
153
|
"react-refresh": "^0.18.0",
|
|
154
154
|
"sass": "~1.102.0",
|
|
@@ -164,11 +164,11 @@
|
|
|
164
164
|
"ts-node": "~10.9.2",
|
|
165
165
|
"typed-css-modules": "~0.9.1",
|
|
166
166
|
"typescript": "6.0.3",
|
|
167
|
-
"vite": "^8.
|
|
167
|
+
"vite": "^8.2.2",
|
|
168
168
|
"vite-bundle-analyzer": "^1.3.9",
|
|
169
169
|
"vite-plugin-istanbul": "^9.0.1",
|
|
170
170
|
"vite-plugin-svgr": "^5.2.0",
|
|
171
|
-
"vitest": "^4.1.
|
|
171
|
+
"vitest": "^4.1.11",
|
|
172
172
|
"webpack": "~5.108.4",
|
|
173
173
|
"webpack-assets-manifest": "~6.5.2",
|
|
174
174
|
"webpack-bundle-analyzer": "^5.3.1",
|
|
@@ -202,6 +202,5 @@
|
|
|
202
202
|
},
|
|
203
203
|
"cli": {
|
|
204
204
|
"webpack": false
|
|
205
|
-
}
|
|
206
|
-
"gitHead": "6e852d0d87277df097ee9fb38b096dae3fb6d68e"
|
|
205
|
+
}
|
|
207
206
|
}
|
|
@@ -1,16 +1,20 @@
|
|
|
1
|
-
import { npmWhoAmI } from '@servicetitan/install';
|
|
1
|
+
import { isCI, npmWhoAmI } from '@servicetitan/install';
|
|
2
2
|
import chalk from 'chalk';
|
|
3
3
|
import Table from 'cli-table3';
|
|
4
4
|
import { vol } from 'memfs';
|
|
5
5
|
import path from 'path';
|
|
6
|
-
import { createInterface } from 'readline/promises';
|
|
7
6
|
import { formatRelativeDate, toArray } from '../../../utils';
|
|
8
|
-
import {
|
|
7
|
+
import { npmView } from '../../utils';
|
|
9
8
|
import { MFEList } from '../mfe-list';
|
|
10
9
|
import { entry } from '../registry/mfe-list';
|
|
10
|
+
import { DEV_MFE_REGISTRY, PROD_MFE_REGISTRY, login } from '../utils';
|
|
11
11
|
|
|
12
12
|
jest.mock('@servicetitan/install');
|
|
13
13
|
jest.mock('cli-table3');
|
|
14
|
+
jest.mock('../utils', () => ({
|
|
15
|
+
...jest.requireActual('../utils'),
|
|
16
|
+
login: jest.fn(),
|
|
17
|
+
}));
|
|
14
18
|
jest.mock('fs', () => require('memfs').fs);
|
|
15
19
|
jest.mock('readline/promises', () => ({
|
|
16
20
|
createInterface: jest.fn(),
|
|
@@ -30,6 +34,7 @@ describe(`[startup] ${MFEList.name}`, () => {
|
|
|
30
34
|
let distTags: Record<string, string>;
|
|
31
35
|
let time: Record<string, string>;
|
|
32
36
|
let args: ConstructorParameters<typeof MFEList>[0];
|
|
37
|
+
let ci: boolean;
|
|
33
38
|
|
|
34
39
|
function volFromJSON(overrides: Record<string, any> = {}) {
|
|
35
40
|
vol.fromJSON({
|
|
@@ -58,8 +63,10 @@ describe(`[startup] ${MFEList.name}`, () => {
|
|
|
58
63
|
latest: versions[DEFAULT_LIMIT],
|
|
59
64
|
};
|
|
60
65
|
args = { _: [] }; // eslint-disable-line @typescript-eslint/naming-convention
|
|
66
|
+
ci = false;
|
|
61
67
|
jest.clearAllMocks();
|
|
62
68
|
jest.spyOn(process.stdout, 'write').mockImplementation(jest.fn()); // suppress output
|
|
69
|
+
jest.mocked(isCI).mockImplementation(() => ci);
|
|
63
70
|
jest.mocked(npmWhoAmI).mockReturnValue('Foo');
|
|
64
71
|
jest.mocked(npmView).mockImplementation(({ packageName }) => ({
|
|
65
72
|
'name': packageName,
|
|
@@ -357,67 +364,29 @@ describe(`[startup] ${MFEList.name}`, () => {
|
|
|
357
364
|
});
|
|
358
365
|
});
|
|
359
366
|
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
let answer: string;
|
|
363
|
-
|
|
364
|
-
beforeEach(() => {
|
|
365
|
-
answer = 'Y';
|
|
366
|
-
jest.mocked(readline.question).mockImplementation(() => Promise.resolve(answer));
|
|
367
|
-
jest.mocked(createInterface).mockReturnValue(readline as any);
|
|
368
|
-
jest.mocked(npmWhoAmI).mockReturnValue(undefined);
|
|
369
|
-
jest.mocked(isTTY).mockReturnValue(true);
|
|
370
|
-
});
|
|
371
|
-
|
|
372
|
-
test('prompts and authorizes machine', async () => {
|
|
373
|
-
await subject();
|
|
374
|
-
|
|
375
|
-
expect(readline.question).toHaveBeenCalledWith(
|
|
376
|
-
expect.stringMatching(/machine is not authorized.*Authorize\? \[Y\/n\]/)
|
|
377
|
-
);
|
|
378
|
-
expect(readline.close).toHaveBeenCalled();
|
|
379
|
-
expect(runCommand).toHaveBeenCalledWith(
|
|
380
|
-
'npx --yes verdaccio-okta-oauth@latest --registry=https://verdaccio.servicetitan.com',
|
|
381
|
-
{ quiet: true }
|
|
382
|
-
);
|
|
383
|
-
});
|
|
384
|
-
|
|
385
|
-
describe('when user does not answer', () => {
|
|
386
|
-
beforeEach(() => (answer = ''));
|
|
387
|
-
|
|
388
|
-
test('authorizes machine', async () => {
|
|
389
|
-
await subject();
|
|
390
|
-
|
|
391
|
-
expect(runCommand).toHaveBeenCalled();
|
|
392
|
-
});
|
|
393
|
-
});
|
|
394
|
-
|
|
395
|
-
describe('when user declines', () => {
|
|
396
|
-
beforeEach(() => (answer = 'n'));
|
|
367
|
+
test(`authorizes the machine for ${PROD_MFE_REGISTRY}`, async () => {
|
|
368
|
+
await subject();
|
|
397
369
|
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
});
|
|
401
|
-
});
|
|
370
|
+
expect(login).toHaveBeenCalledWith(PROD_MFE_REGISTRY);
|
|
371
|
+
});
|
|
402
372
|
|
|
403
|
-
|
|
404
|
-
|
|
373
|
+
describe('in CI environment', () => {
|
|
374
|
+
beforeEach(() => (ci = true));
|
|
405
375
|
|
|
406
|
-
|
|
407
|
-
|
|
376
|
+
test('skips authorization', async () => {
|
|
377
|
+
await subject();
|
|
408
378
|
|
|
409
|
-
|
|
410
|
-
});
|
|
379
|
+
expect(login).not.toHaveBeenCalled();
|
|
411
380
|
});
|
|
381
|
+
});
|
|
412
382
|
|
|
413
|
-
|
|
414
|
-
|
|
383
|
+
describe('with --registry', () => {
|
|
384
|
+
beforeEach(() => (args.registry = DEV_MFE_REGISTRY));
|
|
415
385
|
|
|
416
|
-
|
|
417
|
-
|
|
386
|
+
test('authorizes the machine for the specified registry', async () => {
|
|
387
|
+
await subject();
|
|
418
388
|
|
|
419
|
-
|
|
420
|
-
});
|
|
389
|
+
expect(login).toHaveBeenCalledWith(args.registry);
|
|
421
390
|
});
|
|
422
391
|
});
|
|
423
392
|
});
|
|
@@ -2,6 +2,7 @@ import { fs, vol } from 'memfs';
|
|
|
2
2
|
import { isWebComponent, log } from '../../../utils';
|
|
3
3
|
import { gitGetBranch, npmGetPackageVersionsDetails, npmUnpublish, Version } from '../../utils';
|
|
4
4
|
import { MFEPackageClean } from '../mfe-package-clean';
|
|
5
|
+
import { getMfeRegistry } from '../utils';
|
|
5
6
|
|
|
6
7
|
jest.mock('fs', () => fs);
|
|
7
8
|
jest.mock('../../../utils', () => ({
|
|
@@ -14,6 +15,10 @@ jest.mock('../../utils', () => ({
|
|
|
14
15
|
npmGetPackageVersionsDetails: jest.fn(),
|
|
15
16
|
npmUnpublish: jest.fn(),
|
|
16
17
|
}));
|
|
18
|
+
jest.mock('../utils', () => ({
|
|
19
|
+
...jest.requireActual('../utils'),
|
|
20
|
+
getMfeRegistry: jest.fn(),
|
|
21
|
+
}));
|
|
17
22
|
|
|
18
23
|
const DEFAULT_VERSIONS_TO_KEEP = 5;
|
|
19
24
|
|
|
@@ -37,6 +42,7 @@ describe(`[startup] ${MFEPackageClean.name}`, () => {
|
|
|
37
42
|
versions = getBranchVersions(gitBranch, 10);
|
|
38
43
|
|
|
39
44
|
jest.resetAllMocks();
|
|
45
|
+
jest.mocked(getMfeRegistry).mockImplementation(explicit => explicit ?? registry);
|
|
40
46
|
jest.mocked(isWebComponent).mockReturnValue(true);
|
|
41
47
|
jest.mocked(npmGetPackageVersionsDetails).mockImplementation(() => versions);
|
|
42
48
|
jest.mocked(gitGetBranch).mockImplementation(() => gitBranch);
|