@servicetitan/startup 22.19.0 → 22.21.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 +1 -0
- package/dist/cli/commands/build.d.ts.map +1 -1
- package/dist/cli/commands/build.js +1 -0
- package/dist/cli/commands/build.js.map +1 -1
- package/dist/cli/commands/bundle-package.d.ts +5 -3
- package/dist/cli/commands/bundle-package.d.ts.map +1 -1
- package/dist/cli/commands/bundle-package.js +7 -2
- package/dist/cli/commands/bundle-package.js.map +1 -1
- package/dist/cli/commands/start.d.ts +5 -4
- package/dist/cli/commands/start.d.ts.map +1 -1
- package/dist/cli/commands/start.js +3 -0
- package/dist/cli/commands/start.js.map +1 -1
- package/dist/cli/utils/bundle.d.ts +2 -0
- package/dist/cli/utils/bundle.d.ts.map +1 -1
- package/dist/cli/utils/bundle.js +14 -7
- package/dist/cli/utils/bundle.js.map +1 -1
- package/dist/cli/utils/tsc.js +4 -2
- package/dist/cli/utils/tsc.js.map +1 -1
- package/dist/utils/get-jest-config.js +1 -1
- package/dist/utils/get-jest-config.js.map +1 -1
- package/dist/webpack/configs/amd-config.d.ts +6 -0
- package/dist/webpack/configs/amd-config.d.ts.map +1 -0
- package/dist/webpack/configs/amd-config.js +8 -0
- package/dist/webpack/configs/amd-config.js.map +1 -0
- package/dist/webpack/configs/dev-server-config.d.ts.map +1 -1
- package/dist/webpack/configs/dev-server-config.js +1 -5
- package/dist/webpack/configs/dev-server-config.js.map +1 -1
- package/dist/webpack/configs/index.d.ts +1 -0
- package/dist/webpack/configs/index.d.ts.map +1 -1
- package/dist/webpack/configs/index.js +1 -0
- package/dist/webpack/configs/index.js.map +1 -1
- package/dist/webpack/configs/plugins/provide-react-plugin.d.ts +1 -1
- package/dist/webpack/configs/plugins/provide-react-plugin.d.ts.map +1 -1
- package/dist/webpack/configs/plugins/provide-react-plugin.js +2 -2
- package/dist/webpack/configs/plugins/provide-react-plugin.js.map +1 -1
- package/dist/webpack/configs/rules/tsx-rules.d.ts +1 -1
- package/dist/webpack/configs/rules/tsx-rules.d.ts.map +1 -1
- package/dist/webpack/configs/rules/tsx-rules.js +27 -7
- package/dist/webpack/configs/rules/tsx-rules.js.map +1 -1
- package/dist/webpack/configs/types.d.ts +1 -0
- package/dist/webpack/configs/types.d.ts.map +1 -1
- package/dist/webpack/configs/utils/generate-metadata.d.ts.map +1 -1
- package/dist/webpack/configs/utils/generate-metadata.js +5 -1
- package/dist/webpack/configs/utils/generate-metadata.js.map +1 -1
- package/dist/webpack/configs/utils/get-web-components-version.d.ts +2 -0
- package/dist/webpack/configs/utils/get-web-components-version.d.ts.map +1 -0
- package/dist/webpack/configs/utils/get-web-components-version.js +13 -0
- package/dist/webpack/configs/utils/get-web-components-version.js.map +1 -0
- package/dist/webpack/create-webpack-config.d.ts.map +1 -1
- package/dist/webpack/create-webpack-config.js +3 -1
- package/dist/webpack/create-webpack-config.js.map +1 -1
- package/dist/webpack/types.d.ts +2 -0
- package/dist/webpack/types.d.ts.map +1 -1
- package/package.json +8 -6
- package/src/cli/commands/__tests__/build.test.ts +14 -0
- package/src/cli/commands/__tests__/bundle-package.test.ts +8 -4
- package/src/cli/commands/__tests__/init.test.ts +5 -4
- package/src/cli/commands/__tests__/mfe-package-clean.test.ts +4 -3
- package/src/cli/commands/__tests__/mfe-package-publish.test.ts +5 -4
- package/src/cli/commands/__tests__/mfe-publish.test.ts +4 -3
- package/src/cli/commands/__tests__/start.test.ts +14 -0
- package/src/cli/commands/__tests__/styles-check.test.ts +12 -11
- package/src/cli/commands/build.ts +2 -0
- package/src/cli/commands/bundle-package.ts +13 -5
- package/src/cli/commands/start.ts +8 -4
- package/src/cli/utils/__tests__/bundle.test.ts +15 -14
- package/src/cli/utils/__tests__/eslint.test.ts +11 -4
- package/src/cli/utils/__tests__/get-module-type.test.ts +10 -15
- package/src/cli/utils/__tests__/is-module-installed.test.ts +6 -7
- package/src/cli/utils/__tests__/tcm.test.ts +6 -5
- package/src/cli/utils/__tests__/tsc.test.ts +7 -8
- package/src/cli/utils/bundle.ts +25 -7
- package/src/cli/utils/tsc.ts +7 -9
- package/src/utils/__tests__/get-configuration.test.ts +20 -14
- package/src/utils/__tests__/get-destination-folders.test.ts +11 -13
- package/src/utils/__tests__/get-folders.test.ts +8 -6
- package/src/utils/__tests__/get-jest-config.test.ts +1 -1
- package/src/utils/__tests__/get-tsconfig.test.ts +6 -4
- package/src/utils/__tests__/read-json.test.ts +12 -16
- package/src/utils/get-jest-config.ts +1 -1
- package/src/webpack/__tests__/create-webpack-config-web-component.test.ts +6 -5
- package/src/webpack/__tests__/create-webpack-config.test.ts +53 -10
- package/src/webpack/configs/amd-config.ts +8 -0
- package/src/webpack/configs/dev-server-config.ts +2 -9
- package/src/webpack/configs/index.ts +1 -0
- package/src/webpack/configs/plugins/provide-react-plugin.ts +2 -2
- package/src/webpack/configs/rules/tsx-rules.ts +32 -10
- package/src/webpack/configs/types.ts +1 -0
- package/src/webpack/configs/utils/__tests__/generate-metadata.test.ts +17 -13
- package/src/webpack/configs/utils/__tests__/get-startup-version.test.ts +6 -10
- package/src/webpack/configs/utils/__tests__/get-web-components-version.test.ts +25 -0
- package/src/webpack/configs/utils/generate-metadata.ts +5 -1
- package/src/webpack/configs/utils/get-web-components-version.ts +8 -0
- package/src/webpack/create-webpack-config.ts +5 -1
- package/src/webpack/types.ts +2 -0
- package/template/.gitignore +7 -0
- package/template/.stylelintignore +1 -0
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
import path from 'path';
|
|
2
1
|
import { Configuration } from 'webpack';
|
|
3
|
-
import {
|
|
4
|
-
PackageType,
|
|
5
|
-
getDevServerConfiguration,
|
|
6
|
-
getFolders,
|
|
7
|
-
getPackageName,
|
|
8
|
-
getPackages,
|
|
9
|
-
} from '../../utils';
|
|
2
|
+
import { PackageType, getDevServerConfiguration, getPackageName, getPackages } from '../../utils';
|
|
10
3
|
import { statsConfig } from './stats-config';
|
|
11
4
|
import { Context, Overrides } from './types';
|
|
12
5
|
|
|
@@ -37,7 +30,7 @@ export function devServerConfig(context: Context, overrides: Overrides): Result
|
|
|
37
30
|
function watchOptionsConfig() {
|
|
38
31
|
const watchIgnore = getPackages({ scope: getPackageName() })
|
|
39
32
|
.filter(({ type }) => type === PackageType.TSC)
|
|
40
|
-
.map(({ location }) =>
|
|
33
|
+
.map(({ location }) => location);
|
|
41
34
|
|
|
42
35
|
return watchIgnore.length ? { watchOptions: { ignored: watchIgnore } } : undefined;
|
|
43
36
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ProvidePlugin } from 'webpack';
|
|
2
2
|
import { Context, Overrides } from '../types';
|
|
3
3
|
|
|
4
|
-
export function provideReactPlugin({ esbuild }: Context, _: Overrides) {
|
|
5
|
-
if (!esbuild) {
|
|
4
|
+
export function provideReactPlugin({ esbuild, experimentalBundlers }: Context, _: Overrides) {
|
|
5
|
+
if (!(esbuild || experimentalBundlers)) {
|
|
6
6
|
return;
|
|
7
7
|
}
|
|
8
8
|
|
|
@@ -1,16 +1,38 @@
|
|
|
1
1
|
import { RuleSetRule } from 'webpack';
|
|
2
2
|
import { Context } from '../types';
|
|
3
3
|
|
|
4
|
-
export function tsxRules({ esbuild }: Context): RuleSetRule[] {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
4
|
+
export function tsxRules({ esbuild, experimentalBundlers }: Context): RuleSetRule[] {
|
|
5
|
+
let loader: Record<string, any> = {
|
|
6
|
+
loader: 'ts-loader',
|
|
7
|
+
options: { transpileOnly: true },
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
if (esbuild) {
|
|
11
|
+
loader = {
|
|
12
|
+
loader: 'esbuild-loader',
|
|
13
|
+
options: { loader: 'tsx', target: 'es2018' },
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
if (experimentalBundlers) {
|
|
18
|
+
loader = {
|
|
19
|
+
loader: 'swc-loader',
|
|
20
|
+
options: {
|
|
21
|
+
jsc: {
|
|
22
|
+
parser: {
|
|
23
|
+
syntax: 'typescript',
|
|
24
|
+
tsx: true,
|
|
25
|
+
decorators: true,
|
|
26
|
+
},
|
|
27
|
+
target: 'es2018',
|
|
28
|
+
transform: {
|
|
29
|
+
legacyDecorator: true,
|
|
30
|
+
decoratorMetadata: true,
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
}
|
|
14
36
|
|
|
15
37
|
return [
|
|
16
38
|
{
|
|
@@ -1,21 +1,25 @@
|
|
|
1
|
-
import fs from '
|
|
2
|
-
import
|
|
1
|
+
import { fs, vol } from 'memfs';
|
|
2
|
+
import * as mockedFs from 'fs';
|
|
3
3
|
import { createPackage } from '../../../../__mocks__';
|
|
4
4
|
import { Context } from '../../types';
|
|
5
5
|
import { getStartupVersion } from '../get-startup-version';
|
|
6
|
+
import { getWebComponentsVersion } from '../get-web-components-version';
|
|
6
7
|
|
|
7
8
|
import { generateMetadata } from '../generate-metadata';
|
|
8
9
|
|
|
10
|
+
jest.mock('fs', () => fs);
|
|
9
11
|
jest.mock('../get-startup-version');
|
|
12
|
+
jest.mock('../get-web-components-version');
|
|
10
13
|
|
|
11
14
|
describe(`[startup] ${generateMetadata.name}`, () => {
|
|
12
15
|
const pkg = createPackage({});
|
|
13
16
|
const destination = 'dist';
|
|
14
17
|
const startupVersion = '1.0';
|
|
18
|
+
const webComponentsVersion = '2.0';
|
|
15
19
|
let context: Partial<Context>;
|
|
16
20
|
|
|
17
21
|
function generatedMetadata(destination: string) {
|
|
18
|
-
return JSON.parse(
|
|
22
|
+
return JSON.parse(mockedFs.readFileSync(`${destination}/metadata.json`, 'utf8'));
|
|
19
23
|
}
|
|
20
24
|
|
|
21
25
|
function packageFS() {
|
|
@@ -23,8 +27,9 @@ describe(`[startup] ${generateMetadata.name}`, () => {
|
|
|
23
27
|
}
|
|
24
28
|
|
|
25
29
|
beforeEach(() => {
|
|
26
|
-
|
|
30
|
+
vol.fromJSON(packageFS());
|
|
27
31
|
jest.mocked(getStartupVersion).mockReturnValue(startupVersion);
|
|
32
|
+
jest.mocked(getWebComponentsVersion).mockReturnValue(webComponentsVersion);
|
|
28
33
|
|
|
29
34
|
context = {
|
|
30
35
|
destination,
|
|
@@ -34,7 +39,7 @@ describe(`[startup] ${generateMetadata.name}`, () => {
|
|
|
34
39
|
};
|
|
35
40
|
});
|
|
36
41
|
|
|
37
|
-
afterEach(() =>
|
|
42
|
+
afterEach(() => vol.reset());
|
|
38
43
|
|
|
39
44
|
const subject = () => generateMetadata(context as any);
|
|
40
45
|
|
|
@@ -43,7 +48,10 @@ describe(`[startup] ${generateMetadata.name}`, () => {
|
|
|
43
48
|
|
|
44
49
|
expect(generatedMetadata(destination)).toEqual({
|
|
45
50
|
name: context.name,
|
|
46
|
-
bundledWith: {
|
|
51
|
+
bundledWith: {
|
|
52
|
+
'@servicetitan/startup': startupVersion,
|
|
53
|
+
'@servicetitan/web-components': webComponentsVersion,
|
|
54
|
+
},
|
|
47
55
|
dependencies: context.packageData!.dependencies,
|
|
48
56
|
sharedDependencies: context.sharedDependencies,
|
|
49
57
|
entrypoints: {},
|
|
@@ -55,14 +63,10 @@ describe(`[startup] ${generateMetadata.name}`, () => {
|
|
|
55
63
|
const light = { css: 'baz', js: 'qux' };
|
|
56
64
|
|
|
57
65
|
beforeEach(() => {
|
|
58
|
-
|
|
66
|
+
vol.fromJSON({
|
|
59
67
|
...packageFS(),
|
|
60
|
-
[destination]:
|
|
61
|
-
|
|
62
|
-
full: { 'entrypoints.json': JSON.stringify(full) },
|
|
63
|
-
light: { 'entrypoints.json': JSON.stringify(light) },
|
|
64
|
-
},
|
|
65
|
-
},
|
|
68
|
+
[`${destination}/bundle/full/entrypoints.json`]: JSON.stringify(full),
|
|
69
|
+
[`${destination}/bundle/light/entrypoints.json`]: JSON.stringify(light),
|
|
66
70
|
});
|
|
67
71
|
});
|
|
68
72
|
|
|
@@ -1,23 +1,19 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { fs, vol } from 'memfs';
|
|
2
2
|
|
|
3
3
|
import { getStartupVersion } from '../get-startup-version';
|
|
4
4
|
|
|
5
|
+
jest.mock('fs', () => fs);
|
|
6
|
+
|
|
5
7
|
describe(`[startup] ${getStartupVersion.name}`, () => {
|
|
6
8
|
const startupVersion = '1.2.3';
|
|
7
9
|
|
|
8
10
|
beforeEach(() => {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
node_modules: {
|
|
12
|
-
'@servicetitan': {
|
|
13
|
-
'package.json': JSON.stringify({ version: startupVersion }),
|
|
14
|
-
'startup': { 'index.js': '' },
|
|
15
|
-
},
|
|
16
|
-
},
|
|
11
|
+
vol.fromJSON({
|
|
12
|
+
'packages/startup/package.json': JSON.stringify({ version: startupVersion }),
|
|
17
13
|
});
|
|
18
14
|
});
|
|
19
15
|
|
|
20
|
-
afterEach(() =>
|
|
16
|
+
afterEach(() => vol.reset());
|
|
21
17
|
|
|
22
18
|
const subject = () => getStartupVersion();
|
|
23
19
|
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { fs, vol } from 'memfs';
|
|
2
|
+
|
|
3
|
+
import { getWebComponentsVersion } from '../get-web-components-version';
|
|
4
|
+
|
|
5
|
+
jest.mock('fs', () => fs);
|
|
6
|
+
|
|
7
|
+
describe(`[startup] ${getWebComponentsVersion.name}`, () => {
|
|
8
|
+
const webComponentsVersion = '1.2.3';
|
|
9
|
+
|
|
10
|
+
beforeEach(() => {
|
|
11
|
+
vol.fromJSON({
|
|
12
|
+
'packages/web-components/package.json': JSON.stringify({
|
|
13
|
+
version: webComponentsVersion,
|
|
14
|
+
}),
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
afterEach(() => vol.reset());
|
|
19
|
+
|
|
20
|
+
const subject = () => getWebComponentsVersion();
|
|
21
|
+
|
|
22
|
+
test('returns version from @servicetitan/web-components package', () => {
|
|
23
|
+
expect(subject()).toEqual(webComponentsVersion);
|
|
24
|
+
});
|
|
25
|
+
});
|
|
@@ -4,6 +4,7 @@ import { log, readJsonSafe } from '../../../utils';
|
|
|
4
4
|
import { Context } from '../types';
|
|
5
5
|
|
|
6
6
|
import { getStartupVersion } from './get-startup-version';
|
|
7
|
+
import { getWebComponentsVersion } from './get-web-components-version';
|
|
7
8
|
|
|
8
9
|
export function generateMetadata(context: Context) {
|
|
9
10
|
const { destination, name, packageData, sharedDependencies } = context;
|
|
@@ -17,7 +18,10 @@ export function generateMetadata(context: Context) {
|
|
|
17
18
|
const light = readJsonSafe(path.join(destination, 'bundle', 'light', 'entrypoints.json'));
|
|
18
19
|
const metadata = {
|
|
19
20
|
name,
|
|
20
|
-
bundledWith: {
|
|
21
|
+
bundledWith: {
|
|
22
|
+
'@servicetitan/startup': getStartupVersion(),
|
|
23
|
+
'@servicetitan/web-components': getWebComponentsVersion(),
|
|
24
|
+
},
|
|
21
25
|
sharedDependencies,
|
|
22
26
|
dependencies: packageData.dependencies,
|
|
23
27
|
entrypoints: { ...(full ? { full } : {}), ...(light ? { light } : {}) },
|
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
} from '../utils';
|
|
15
15
|
import {
|
|
16
16
|
Context,
|
|
17
|
+
amdConfig,
|
|
17
18
|
cacheConfig,
|
|
18
19
|
devServerConfig,
|
|
19
20
|
devtoolConfig,
|
|
@@ -41,7 +42,9 @@ export function createWebpackConfig(overrides: Overrides, options: Options = {})
|
|
|
41
42
|
|
|
42
43
|
const context: Context = {
|
|
43
44
|
destination,
|
|
44
|
-
esbuild: !!(argv as Arguments).esbuild,
|
|
45
|
+
esbuild: options.esbuild ?? !!(argv as Arguments).esbuild ?? false,
|
|
46
|
+
experimentalBundlers:
|
|
47
|
+
options.experimentalBundlers ?? !!(argv as Arguments)['experimental-bundlers'] ?? false,
|
|
45
48
|
isCustomStyleRules: isCustomStyleRules(),
|
|
46
49
|
isExposeSharedDependencies: isExposeSharedDependencies(),
|
|
47
50
|
isProduction: configuration.mode === 'production',
|
|
@@ -72,6 +75,7 @@ export function createWebpackConfig(overrides: Overrides, options: Options = {})
|
|
|
72
75
|
pluginsConfig,
|
|
73
76
|
resolveConfig,
|
|
74
77
|
statsConfig,
|
|
78
|
+
amdConfig,
|
|
75
79
|
].reduce((result, fn) => ({ ...result, ...fn(context, overrides) }), {}),
|
|
76
80
|
configuration
|
|
77
81
|
);
|
package/src/webpack/types.ts
CHANGED
package/template/.gitignore
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/coverage
|