@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.
Files changed (97) hide show
  1. package/dist/cli/commands/build.d.ts +1 -0
  2. package/dist/cli/commands/build.d.ts.map +1 -1
  3. package/dist/cli/commands/build.js +1 -0
  4. package/dist/cli/commands/build.js.map +1 -1
  5. package/dist/cli/commands/bundle-package.d.ts +5 -3
  6. package/dist/cli/commands/bundle-package.d.ts.map +1 -1
  7. package/dist/cli/commands/bundle-package.js +7 -2
  8. package/dist/cli/commands/bundle-package.js.map +1 -1
  9. package/dist/cli/commands/start.d.ts +5 -4
  10. package/dist/cli/commands/start.d.ts.map +1 -1
  11. package/dist/cli/commands/start.js +3 -0
  12. package/dist/cli/commands/start.js.map +1 -1
  13. package/dist/cli/utils/bundle.d.ts +2 -0
  14. package/dist/cli/utils/bundle.d.ts.map +1 -1
  15. package/dist/cli/utils/bundle.js +14 -7
  16. package/dist/cli/utils/bundle.js.map +1 -1
  17. package/dist/cli/utils/tsc.js +4 -2
  18. package/dist/cli/utils/tsc.js.map +1 -1
  19. package/dist/utils/get-jest-config.js +1 -1
  20. package/dist/utils/get-jest-config.js.map +1 -1
  21. package/dist/webpack/configs/amd-config.d.ts +6 -0
  22. package/dist/webpack/configs/amd-config.d.ts.map +1 -0
  23. package/dist/webpack/configs/amd-config.js +8 -0
  24. package/dist/webpack/configs/amd-config.js.map +1 -0
  25. package/dist/webpack/configs/dev-server-config.d.ts.map +1 -1
  26. package/dist/webpack/configs/dev-server-config.js +1 -5
  27. package/dist/webpack/configs/dev-server-config.js.map +1 -1
  28. package/dist/webpack/configs/index.d.ts +1 -0
  29. package/dist/webpack/configs/index.d.ts.map +1 -1
  30. package/dist/webpack/configs/index.js +1 -0
  31. package/dist/webpack/configs/index.js.map +1 -1
  32. package/dist/webpack/configs/plugins/provide-react-plugin.d.ts +1 -1
  33. package/dist/webpack/configs/plugins/provide-react-plugin.d.ts.map +1 -1
  34. package/dist/webpack/configs/plugins/provide-react-plugin.js +2 -2
  35. package/dist/webpack/configs/plugins/provide-react-plugin.js.map +1 -1
  36. package/dist/webpack/configs/rules/tsx-rules.d.ts +1 -1
  37. package/dist/webpack/configs/rules/tsx-rules.d.ts.map +1 -1
  38. package/dist/webpack/configs/rules/tsx-rules.js +27 -7
  39. package/dist/webpack/configs/rules/tsx-rules.js.map +1 -1
  40. package/dist/webpack/configs/types.d.ts +1 -0
  41. package/dist/webpack/configs/types.d.ts.map +1 -1
  42. package/dist/webpack/configs/utils/generate-metadata.d.ts.map +1 -1
  43. package/dist/webpack/configs/utils/generate-metadata.js +5 -1
  44. package/dist/webpack/configs/utils/generate-metadata.js.map +1 -1
  45. package/dist/webpack/configs/utils/get-web-components-version.d.ts +2 -0
  46. package/dist/webpack/configs/utils/get-web-components-version.d.ts.map +1 -0
  47. package/dist/webpack/configs/utils/get-web-components-version.js +13 -0
  48. package/dist/webpack/configs/utils/get-web-components-version.js.map +1 -0
  49. package/dist/webpack/create-webpack-config.d.ts.map +1 -1
  50. package/dist/webpack/create-webpack-config.js +3 -1
  51. package/dist/webpack/create-webpack-config.js.map +1 -1
  52. package/dist/webpack/types.d.ts +2 -0
  53. package/dist/webpack/types.d.ts.map +1 -1
  54. package/package.json +8 -6
  55. package/src/cli/commands/__tests__/build.test.ts +14 -0
  56. package/src/cli/commands/__tests__/bundle-package.test.ts +8 -4
  57. package/src/cli/commands/__tests__/init.test.ts +5 -4
  58. package/src/cli/commands/__tests__/mfe-package-clean.test.ts +4 -3
  59. package/src/cli/commands/__tests__/mfe-package-publish.test.ts +5 -4
  60. package/src/cli/commands/__tests__/mfe-publish.test.ts +4 -3
  61. package/src/cli/commands/__tests__/start.test.ts +14 -0
  62. package/src/cli/commands/__tests__/styles-check.test.ts +12 -11
  63. package/src/cli/commands/build.ts +2 -0
  64. package/src/cli/commands/bundle-package.ts +13 -5
  65. package/src/cli/commands/start.ts +8 -4
  66. package/src/cli/utils/__tests__/bundle.test.ts +15 -14
  67. package/src/cli/utils/__tests__/eslint.test.ts +11 -4
  68. package/src/cli/utils/__tests__/get-module-type.test.ts +10 -15
  69. package/src/cli/utils/__tests__/is-module-installed.test.ts +6 -7
  70. package/src/cli/utils/__tests__/tcm.test.ts +6 -5
  71. package/src/cli/utils/__tests__/tsc.test.ts +7 -8
  72. package/src/cli/utils/bundle.ts +25 -7
  73. package/src/cli/utils/tsc.ts +7 -9
  74. package/src/utils/__tests__/get-configuration.test.ts +20 -14
  75. package/src/utils/__tests__/get-destination-folders.test.ts +11 -13
  76. package/src/utils/__tests__/get-folders.test.ts +8 -6
  77. package/src/utils/__tests__/get-jest-config.test.ts +1 -1
  78. package/src/utils/__tests__/get-tsconfig.test.ts +6 -4
  79. package/src/utils/__tests__/read-json.test.ts +12 -16
  80. package/src/utils/get-jest-config.ts +1 -1
  81. package/src/webpack/__tests__/create-webpack-config-web-component.test.ts +6 -5
  82. package/src/webpack/__tests__/create-webpack-config.test.ts +53 -10
  83. package/src/webpack/configs/amd-config.ts +8 -0
  84. package/src/webpack/configs/dev-server-config.ts +2 -9
  85. package/src/webpack/configs/index.ts +1 -0
  86. package/src/webpack/configs/plugins/provide-react-plugin.ts +2 -2
  87. package/src/webpack/configs/rules/tsx-rules.ts +32 -10
  88. package/src/webpack/configs/types.ts +1 -0
  89. package/src/webpack/configs/utils/__tests__/generate-metadata.test.ts +17 -13
  90. package/src/webpack/configs/utils/__tests__/get-startup-version.test.ts +6 -10
  91. package/src/webpack/configs/utils/__tests__/get-web-components-version.test.ts +25 -0
  92. package/src/webpack/configs/utils/generate-metadata.ts +5 -1
  93. package/src/webpack/configs/utils/get-web-components-version.ts +8 -0
  94. package/src/webpack/create-webpack-config.ts +5 -1
  95. package/src/webpack/types.ts +2 -0
  96. package/template/.gitignore +7 -0
  97. package/template/.stylelintignore +1 -0
@@ -0,0 +1,8 @@
1
+ import { Configuration } from 'webpack';
2
+ import { Context, Overrides } from './types';
3
+
4
+ type Result = Pick<Configuration, 'amd'>;
5
+
6
+ export function amdConfig(_context: Context, _: Overrides): Result {
7
+ return { amd: false };
8
+ }
@@ -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 }) => path.join(location, getFolders(location).source));
33
+ .map(({ location }) => location);
41
34
 
42
35
  return watchIgnore.length ? { watchOptions: { ignored: watchIgnore } } : undefined;
43
36
  }
@@ -1,3 +1,4 @@
1
+ export * from './amd-config';
1
2
  export * from './cache-config';
2
3
  export * from './dev-server-config';
3
4
  export * from './devtool-config';
@@ -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
- const loader = esbuild
6
- ? {
7
- loader: 'esbuild-loader',
8
- options: { loader: 'tsx', target: 'es2018' },
9
- }
10
- : {
11
- loader: 'ts-loader',
12
- options: { transpileOnly: true },
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
  {
@@ -5,6 +5,7 @@ export { Overrides } from '../types';
5
5
  export interface Context extends Options {
6
6
  destination: string;
7
7
  esbuild: boolean;
8
+ experimentalBundlers: boolean;
8
9
  isCustomStyleRules: boolean;
9
10
  isExposeSharedDependencies: boolean;
10
11
  isProduction: boolean;
@@ -1,21 +1,25 @@
1
- import fs from 'fs';
2
- import mockFS from 'mock-fs';
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(fs.readFileSync(`${destination}/metadata.json`, 'utf8'));
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
- mockFS(packageFS());
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(() => mockFS.restore());
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: { '@servicetitan/startup': startupVersion },
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
- mockFS({
66
+ vol.fromJSON({
59
67
  ...packageFS(),
60
- [destination]: {
61
- bundle: {
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 mockFS from 'mock-fs';
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
- mockFS({
10
- // eslint-disable-next-line @typescript-eslint/naming-convention
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(() => mockFS.restore());
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: { '@servicetitan/startup': getStartupVersion() },
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 } : {}) },
@@ -0,0 +1,8 @@
1
+ import path from 'path';
2
+ import { readJson } from '../../../utils';
3
+
4
+ export function getWebComponentsVersion() {
5
+ return readJson(
6
+ path.join(path.dirname(require.resolve('@servicetitan/web-components')), '../package.json')
7
+ ).version;
8
+ }
@@ -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
  );
@@ -7,6 +7,8 @@ export interface Options {
7
7
  embed?: boolean;
8
8
  buildStat?: boolean;
9
9
  name?: string;
10
+ esbuild?: boolean;
11
+ experimentalBundlers?: boolean;
10
12
  }
11
13
 
12
14
  export interface Overrides {
@@ -6,6 +6,13 @@
6
6
  # Node.js
7
7
  node_modules/
8
8
 
9
+ # yalc store
10
+ .yalc/
11
+ yalc.lock
12
+
13
+ #SonarQube
14
+ .scannerwork/
15
+
9
16
  *.css.d.ts
10
17
  *.less.d.ts
11
18
  *.scss.d.ts
@@ -0,0 +1 @@
1
+ /coverage