@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
|
@@ -33,6 +33,7 @@ import { assetFileNames } from './asset-file-names';
|
|
|
33
33
|
import { getCodeSplitting } from './code-splitting';
|
|
34
34
|
import { createCssConfig } from './create-css-config';
|
|
35
35
|
import { createFilteringLogger } from './create-filtering-logger';
|
|
36
|
+
import { createResolveConfig } from './create-resolve-config';
|
|
36
37
|
|
|
37
38
|
function importMetaRemap(
|
|
38
39
|
...definitions: (Record<string, string> | undefined)[]
|
|
@@ -79,6 +80,7 @@ function createPlugins(context: ViteBuildContext) {
|
|
|
79
80
|
}
|
|
80
81
|
|
|
81
82
|
export function createBaseConfig(context: ViteBuildContext): InlineConfig {
|
|
83
|
+
const optimizedStartupDependencies = ['@servicetitan/startup-utils', 'react-refresh/runtime'];
|
|
82
84
|
const { isProduction } = context.build;
|
|
83
85
|
const { isWebComponent } = context.package;
|
|
84
86
|
|
|
@@ -120,10 +122,10 @@ export function createBaseConfig(context: ViteBuildContext): InlineConfig {
|
|
|
120
122
|
),
|
|
121
123
|
...(getProcessEnv(context) ?? {}),
|
|
122
124
|
},
|
|
125
|
+
resolve: createResolveConfig(context, optimizedStartupDependencies),
|
|
123
126
|
optimizeDeps: {
|
|
124
127
|
include: [
|
|
125
|
-
|
|
126
|
-
'react-refresh/runtime',
|
|
128
|
+
...optimizedStartupDependencies,
|
|
127
129
|
'react/jsx-runtime',
|
|
128
130
|
'react/jsx-dev-runtime',
|
|
129
131
|
],
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { createRequire } from 'module';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import type { InlineConfig } from 'vite';
|
|
4
|
+
import { buildEscapedRegExp } from '../build-escaped-reg-exp';
|
|
5
|
+
import type { ViteBuildContext } from '../types';
|
|
6
|
+
|
|
7
|
+
type Result = InlineConfig['resolve'];
|
|
8
|
+
|
|
9
|
+
const startupRequire = createRequire(__filename);
|
|
10
|
+
|
|
11
|
+
/*
|
|
12
|
+
* Returns a resolver that, when normal resolution fails for a specifier,
|
|
13
|
+
* tries resolving from startup's location.
|
|
14
|
+
*/
|
|
15
|
+
export function createResolveConfig(context: ViteBuildContext, specifiers: string[]): Result {
|
|
16
|
+
const source = path.resolve(context.package.source);
|
|
17
|
+
|
|
18
|
+
const alias = specifiers
|
|
19
|
+
.filter(specifier => !isResolvableFrom(specifier, source))
|
|
20
|
+
.map(specifier => ({
|
|
21
|
+
find: buildEscapedRegExp(specifier),
|
|
22
|
+
replacement: resolveFromStartup(specifier),
|
|
23
|
+
}));
|
|
24
|
+
|
|
25
|
+
return { alias };
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function isResolvableFrom(specifier: string, source: string): boolean {
|
|
29
|
+
try {
|
|
30
|
+
require.resolve(specifier, { paths: [source] });
|
|
31
|
+
return true;
|
|
32
|
+
} catch {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function resolveFromStartup(specifier: string): string {
|
|
38
|
+
try {
|
|
39
|
+
return startupRequire.resolve(specifier);
|
|
40
|
+
} catch (cause) {
|
|
41
|
+
throw new Error(`[startup] Cannot resolve ${specifier}`, { cause });
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -64,7 +64,7 @@ describe(cssInjectorPlugin.name, () => {
|
|
|
64
64
|
const result = transform(viteCssOutput, viteId);
|
|
65
65
|
|
|
66
66
|
expect(result.code).toContain(
|
|
67
|
-
`import { MfeStyleRegistry as __mfe__Registry } from '@servicetitan/web-components'`
|
|
67
|
+
`import { MfeStyleRegistry as __mfe__Registry } from '@servicetitan/web-components/css-injector/mfe-style-registry'`
|
|
68
68
|
);
|
|
69
69
|
});
|
|
70
70
|
|
|
@@ -48,7 +48,12 @@ export function cssInjectorPlugin(context: BuildContext): Plugin | undefined {
|
|
|
48
48
|
transformed = transformed
|
|
49
49
|
.replace(
|
|
50
50
|
importPattern,
|
|
51
|
-
|
|
51
|
+
/*
|
|
52
|
+
* Leaf module, not the package root: the root reaches anvil2, whose
|
|
53
|
+
* stylesheets are rewritten here, and the cycle leaves the registry
|
|
54
|
+
* undefined.
|
|
55
|
+
*/
|
|
56
|
+
`import { MfeStyleRegistry as __mfe__Registry } from '@servicetitan/web-components/css-injector/mfe-style-registry'`
|
|
52
57
|
)
|
|
53
58
|
.replace(
|
|
54
59
|
callPattern,
|
|
@@ -2,10 +2,7 @@ import fs from 'fs';
|
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import type { Plugin } from 'vite';
|
|
4
4
|
import { BuildContext, getExternals } from '../../core';
|
|
5
|
-
|
|
6
|
-
/* Dots are the only valid regex-special character in package names */
|
|
7
|
-
const buildEscapedRegExp = (dependency: string) =>
|
|
8
|
-
new RegExp(`^${dependency.replace(/\./g, '\\.')}$`);
|
|
5
|
+
import { buildEscapedRegExp } from '../build-escaped-reg-exp';
|
|
9
6
|
|
|
10
7
|
/*
|
|
11
8
|
* Externalizes shared dependencies by redirecting imports to CJS proxy modules
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/utils/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,oBAAoB,uCAAuC,CAAC"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "DEFAULT_MFE_REGISTRY", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return DEFAULT_MFE_REGISTRY;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const DEFAULT_MFE_REGISTRY = 'https://verdaccio.servicetitan.com';
|
|
12
|
-
|
|
13
|
-
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/cli/commands/utils/constants.ts"],"sourcesContent":["export const DEFAULT_MFE_REGISTRY = 'https://verdaccio.servicetitan.com';\n"],"names":["DEFAULT_MFE_REGISTRY"],"mappings":";;;;+BAAaA;;;eAAAA;;;AAAN,MAAMA,uBAAuB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const DEFAULT_MFE_REGISTRY = 'https://verdaccio.servicetitan.com';
|