@servicetitan/startup 22.19.0 → 22.20.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/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/create-webpack-config.d.ts.map +1 -1
- package/dist/webpack/create-webpack-config.js +2 -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 +7 -5
- 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 +6 -7
- package/src/cli/utils/bundle.ts +25 -7
- 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-tsconfig.test.ts +6 -4
- package/src/utils/__tests__/read-json.test.ts +12 -16
- package/src/webpack/__tests__/create-webpack-config-web-component.test.ts +6 -5
- package/src/webpack/__tests__/create-webpack-config.test.ts +48 -9
- 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 +9 -12
- package/src/webpack/configs/utils/__tests__/get-startup-version.test.ts +6 -10
- package/src/webpack/create-webpack-config.ts +3 -1
- package/src/webpack/types.ts +2 -0
- package/template/.gitignore +4 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import fs from '
|
|
2
|
-
import mockFS from 'mock-fs';
|
|
1
|
+
import { fs, vol } from 'memfs';
|
|
3
2
|
import { getPackages } from '../get-packages';
|
|
4
3
|
|
|
5
4
|
import { getDestinationFolders } from '../get-destination-folders';
|
|
6
5
|
|
|
6
|
+
jest.mock('fs', () => fs);
|
|
7
7
|
jest.mock('../get-packages', () => ({ getPackages: jest.fn() }));
|
|
8
8
|
|
|
9
9
|
describe('[startup] Utils', () => {
|
|
@@ -12,28 +12,26 @@ describe('[startup] Utils', () => {
|
|
|
12
12
|
|
|
13
13
|
beforeEach(() => {
|
|
14
14
|
locations = ['foo', 'bar'];
|
|
15
|
-
|
|
15
|
+
vol.fromJSON(packageFS(locations));
|
|
16
16
|
jest.mocked(getPackages).mockImplementation((): any =>
|
|
17
17
|
locations.map(location => ({ location: `packages/${location}` }))
|
|
18
18
|
);
|
|
19
19
|
});
|
|
20
20
|
|
|
21
|
-
afterEach(() =>
|
|
21
|
+
afterEach(() => vol.reset());
|
|
22
22
|
|
|
23
23
|
const subject = () => getDestinationFolders();
|
|
24
24
|
|
|
25
25
|
function packageFS(locations: string[]) {
|
|
26
26
|
const packages = Object.fromEntries(
|
|
27
27
|
locations.map(location => [
|
|
28
|
-
location
|
|
29
|
-
{
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}),
|
|
33
|
-
},
|
|
28
|
+
`packages/${location}/tsconfig.json`,
|
|
29
|
+
JSON.stringify({
|
|
30
|
+
compilerOptions: { outDir: `${location}outDir` },
|
|
31
|
+
}),
|
|
34
32
|
])
|
|
35
33
|
);
|
|
36
|
-
return
|
|
34
|
+
return packages;
|
|
37
35
|
}
|
|
38
36
|
|
|
39
37
|
function expectedOutDirs(locations: string[]) {
|
|
@@ -45,7 +43,7 @@ describe('[startup] Utils', () => {
|
|
|
45
43
|
});
|
|
46
44
|
|
|
47
45
|
describe('when package has no tsconfig', () => {
|
|
48
|
-
beforeEach(() =>
|
|
46
|
+
beforeEach(() => fs.rmSync(`packages/${locations[0]}/tsconfig.json`));
|
|
49
47
|
|
|
50
48
|
test('omits location from result', () => {
|
|
51
49
|
expect(subject()).toEqual(expectedOutDirs(locations.slice(1)));
|
|
@@ -54,7 +52,7 @@ describe('[startup] Utils', () => {
|
|
|
54
52
|
|
|
55
53
|
describe('when tsconfig has no "outDir"', () => {
|
|
56
54
|
beforeEach(() => {
|
|
57
|
-
|
|
55
|
+
vol.fromJSON({ [`packages/${locations[0]}/tsconfig.json`]: JSON.stringify({}) });
|
|
58
56
|
});
|
|
59
57
|
|
|
60
58
|
test('omits location from result', () => {
|
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { fs, vol } from 'memfs';
|
|
2
2
|
|
|
3
3
|
import { getFolders } from '..';
|
|
4
4
|
|
|
5
|
+
jest.mock('fs', () => fs);
|
|
6
|
+
|
|
5
7
|
describe('[Startup] utils:get-folders', () => {
|
|
6
8
|
afterAll(() => {
|
|
7
|
-
|
|
9
|
+
vol.reset();
|
|
8
10
|
});
|
|
9
11
|
|
|
10
12
|
test('getFolders throws an exception if "compilerOptions.rootDir" isn\'t defined', () => {
|
|
11
|
-
|
|
13
|
+
vol.fromJSON({
|
|
12
14
|
'package.json': JSON.stringify({}),
|
|
13
15
|
'tsconfig.json': JSON.stringify({ compilerOptions: { ourDir: 'dist' } }),
|
|
14
16
|
});
|
|
@@ -25,7 +27,7 @@ describe('[Startup] utils:get-folders', () => {
|
|
|
25
27
|
});
|
|
26
28
|
|
|
27
29
|
test('getFolders throws an exception if "compilerOptions.outDir" isn\'t defined', () => {
|
|
28
|
-
|
|
30
|
+
vol.fromJSON({
|
|
29
31
|
'package.json': JSON.stringify({}),
|
|
30
32
|
'tsconfig.json': JSON.stringify({ compilerOptions: { rootDir: 'src' } }),
|
|
31
33
|
});
|
|
@@ -42,7 +44,7 @@ describe('[Startup] utils:get-folders', () => {
|
|
|
42
44
|
});
|
|
43
45
|
|
|
44
46
|
test('"compilerOptions.outDir" used as the destination', () => {
|
|
45
|
-
|
|
47
|
+
vol.fromJSON({
|
|
46
48
|
'package.json': JSON.stringify({}),
|
|
47
49
|
'tsconfig.json': JSON.stringify({
|
|
48
50
|
compilerOptions: { rootDir: 'src', outDir: 'path' },
|
|
@@ -53,7 +55,7 @@ describe('[Startup] utils:get-folders', () => {
|
|
|
53
55
|
});
|
|
54
56
|
|
|
55
57
|
test('"compilerOptions.rootDir" used as the source', () => {
|
|
56
|
-
|
|
58
|
+
vol.fromJSON({
|
|
57
59
|
'package.json': JSON.stringify({}),
|
|
58
60
|
'tsconfig.json': JSON.stringify({
|
|
59
61
|
compilerOptions: { rootDir: 'path', outDir: 'dist' },
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { fs, vol } from 'memfs';
|
|
2
2
|
import path from 'path';
|
|
3
3
|
|
|
4
4
|
import { getTsConfig } from '../get-tsconfig';
|
|
5
5
|
|
|
6
|
+
jest.mock('fs', () => fs);
|
|
7
|
+
|
|
6
8
|
describe(`[startup] Utils`, () => {
|
|
7
9
|
describe(`${getTsConfig.name}`, () => {
|
|
8
10
|
const defaultConfig = 'tsconfig.json';
|
|
@@ -13,14 +15,14 @@ describe(`[startup] Utils`, () => {
|
|
|
13
15
|
|
|
14
16
|
beforeEach(() => (location = undefined));
|
|
15
17
|
|
|
16
|
-
afterEach(() =>
|
|
18
|
+
afterEach(() => vol.reset());
|
|
17
19
|
|
|
18
20
|
test(`returns ${defaultConfig}`, () => {
|
|
19
21
|
expect(subject()).toBe(defaultConfig);
|
|
20
22
|
});
|
|
21
23
|
|
|
22
24
|
describe(`when ${buildConfig} is present`, () => {
|
|
23
|
-
beforeEach(() =>
|
|
25
|
+
beforeEach(() => vol.fromJSON({ [buildConfig]: JSON.stringify({}) }));
|
|
24
26
|
|
|
25
27
|
test(`returns ${buildConfig}`, () => {
|
|
26
28
|
expect(subject()).toBe(buildConfig);
|
|
@@ -36,7 +38,7 @@ describe(`[startup] Utils`, () => {
|
|
|
36
38
|
|
|
37
39
|
describe(`when ${buildConfig} is present`, () => {
|
|
38
40
|
beforeEach(() => {
|
|
39
|
-
|
|
41
|
+
vol.fromJSON({ [`packages/foo/${buildConfig}`]: JSON.stringify({}) });
|
|
40
42
|
});
|
|
41
43
|
|
|
42
44
|
test(`returns {location}/${buildConfig}`, () => {
|
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { fs, vol } from 'memfs';
|
|
2
2
|
|
|
3
3
|
import { readJson } from '..';
|
|
4
4
|
|
|
5
|
+
jest.mock('fs', () => fs);
|
|
6
|
+
|
|
5
7
|
describe('[Startup] utils:read-json', () => {
|
|
6
8
|
afterAll(() => {
|
|
7
|
-
|
|
9
|
+
vol.reset();
|
|
8
10
|
});
|
|
9
11
|
|
|
10
12
|
test('readJson works with the current directory', () => {
|
|
11
|
-
|
|
13
|
+
vol.fromJSON({
|
|
12
14
|
'file.json': JSON.stringify({
|
|
13
15
|
a: true,
|
|
14
16
|
b: 'string',
|
|
@@ -28,20 +30,14 @@ describe('[Startup] utils:read-json', () => {
|
|
|
28
30
|
});
|
|
29
31
|
|
|
30
32
|
test('readJson works with the nested directory', () => {
|
|
31
|
-
|
|
32
|
-
path: {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
b: 'string',
|
|
38
|
-
c: {
|
|
39
|
-
d: 7,
|
|
40
|
-
},
|
|
41
|
-
}),
|
|
42
|
-
},
|
|
33
|
+
vol.fromJSON({
|
|
34
|
+
'path/to/folder/file.json': JSON.stringify({
|
|
35
|
+
a: true,
|
|
36
|
+
b: 'string',
|
|
37
|
+
c: {
|
|
38
|
+
d: 7,
|
|
43
39
|
},
|
|
44
|
-
},
|
|
40
|
+
}),
|
|
45
41
|
});
|
|
46
42
|
|
|
47
43
|
expect(readJson('./path/to/folder/file.json')).toEqual({
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import HtmlWebpackPlugin from 'html-webpack-plugin';
|
|
2
2
|
import MiniCssExtractPlugin from 'mini-css-extract-plugin';
|
|
3
|
-
import
|
|
3
|
+
import { fs, vol } from 'memfs';
|
|
4
4
|
import path from 'path';
|
|
5
5
|
import { DefinePlugin } from 'webpack';
|
|
6
6
|
import WebpackAssetsManifest from 'webpack-assets-manifest';
|
|
@@ -14,6 +14,7 @@ import { featureCohort, getCallerFile, splitByEntry } from '../utils';
|
|
|
14
14
|
|
|
15
15
|
import { createWebpackConfig } from '../index';
|
|
16
16
|
|
|
17
|
+
jest.mock('fs', () => fs);
|
|
17
18
|
jest.mock('fork-ts-checker-webpack-plugin', () => jest.fn());
|
|
18
19
|
jest.mock('html-webpack-plugin', () => jest.fn());
|
|
19
20
|
jest.mock('mini-css-extract-plugin', () =>
|
|
@@ -86,10 +87,10 @@ describe(`[startup] ${createWebpackConfig.name}`, () => {
|
|
|
86
87
|
jest.mocked(getPackages).mockReturnValue([]);
|
|
87
88
|
jest.mocked(getTsConfig).mockReturnValue(tsConfig);
|
|
88
89
|
|
|
89
|
-
|
|
90
|
+
vol.fromJSON({ [packageJson]: JSON.stringify({ name: packageName }) });
|
|
90
91
|
});
|
|
91
92
|
|
|
92
|
-
afterEach(() =>
|
|
93
|
+
afterEach(() => vol.reset());
|
|
93
94
|
|
|
94
95
|
const subject = () => createWebpackConfig(overrides, options);
|
|
95
96
|
|
|
@@ -222,9 +223,9 @@ describe(`[startup] ${createWebpackConfig.name}`, () => {
|
|
|
222
223
|
|
|
223
224
|
describe('when design-system.css exists', () => {
|
|
224
225
|
beforeEach(() => {
|
|
225
|
-
|
|
226
|
+
vol.fromJSON({
|
|
226
227
|
[packageJson]: JSON.stringify({ name: packageName }),
|
|
227
|
-
[source
|
|
228
|
+
[`${source}/design-system.css`]: '',
|
|
228
229
|
});
|
|
229
230
|
});
|
|
230
231
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import ForkTsCheckerWebpackPlugin from 'fork-ts-checker-webpack-plugin';
|
|
2
2
|
import HtmlWebpackPlugin from 'html-webpack-plugin';
|
|
3
3
|
import MiniCssExtractPlugin from 'mini-css-extract-plugin';
|
|
4
|
-
import
|
|
4
|
+
import { fs, vol } from 'memfs';
|
|
5
5
|
import MomentLocalesPlugin from 'moment-locales-webpack-plugin';
|
|
6
6
|
import os from 'os';
|
|
7
7
|
import path from 'path';
|
|
@@ -28,6 +28,7 @@ import { featureCohort, splitByEntry } from '../utils';
|
|
|
28
28
|
|
|
29
29
|
import { createWebpackConfig } from '../index';
|
|
30
30
|
|
|
31
|
+
jest.mock('fs', () => fs);
|
|
31
32
|
jest.mock('fork-ts-checker-webpack-plugin', () => jest.fn());
|
|
32
33
|
jest.mock('html-webpack-plugin', () => jest.fn());
|
|
33
34
|
jest.mock('mini-css-extract-plugin', () =>
|
|
@@ -124,10 +125,10 @@ describe(`[startup] ${createWebpackConfig.name}`, () => {
|
|
|
124
125
|
|
|
125
126
|
Object.keys(argv).forEach(key => delete (argv as any)[key]);
|
|
126
127
|
|
|
127
|
-
|
|
128
|
+
vol.fromJSON({ [packageJson]: JSON.stringify({ name: packageName }) });
|
|
128
129
|
});
|
|
129
130
|
|
|
130
|
-
afterEach(() =>
|
|
131
|
+
afterEach(() => vol.reset());
|
|
131
132
|
|
|
132
133
|
const subject = () => createWebpackConfig(overrides, options);
|
|
133
134
|
|
|
@@ -226,25 +227,63 @@ describe(`[startup] ${createWebpackConfig.name}`, () => {
|
|
|
226
227
|
});
|
|
227
228
|
});
|
|
228
229
|
|
|
229
|
-
|
|
230
|
-
beforeEach(() => Object.assign(argv, { esbuild: true }));
|
|
231
|
-
|
|
230
|
+
function itConfiguresTsLoader() {
|
|
232
231
|
test('configures ".tsx" rules to use esbuild-loader', () => {
|
|
232
|
+
expect(subject().module?.rules).toContainEqual({
|
|
233
|
+
test: /\.tsx?$/,
|
|
234
|
+
exclude: /node_modules/,
|
|
235
|
+
use: [{ loader: 'esbuild-loader', options: { loader: 'tsx', target: 'es2018' } }],
|
|
236
|
+
});
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
function itConfiguresSwcLoader() {
|
|
240
|
+
test('configures ".tsx" rules to use swc-loader', () => {
|
|
233
241
|
expect(subject().module?.rules).toContainEqual({
|
|
234
242
|
test: /\.tsx?$/,
|
|
235
243
|
exclude: /node_modules/,
|
|
236
244
|
use: [
|
|
237
245
|
{
|
|
238
|
-
loader: '
|
|
239
|
-
options: {
|
|
246
|
+
loader: 'swc-loader',
|
|
247
|
+
options: {
|
|
248
|
+
jsc: {
|
|
249
|
+
parser: { syntax: 'typescript', tsx: true, decorators: true },
|
|
250
|
+
target: 'es2018',
|
|
251
|
+
transform: { legacyDecorator: true, decoratorMetadata: true },
|
|
252
|
+
},
|
|
253
|
+
},
|
|
240
254
|
},
|
|
241
255
|
],
|
|
242
256
|
});
|
|
243
257
|
});
|
|
244
|
-
|
|
258
|
+
}
|
|
259
|
+
function itConfiguresReactToLoadAutomatically() {
|
|
245
260
|
test('configures React to load automatically', () => {
|
|
246
261
|
expect(subject().plugins).toContainEqual(new ProvidePlugin({ React: 'react' }));
|
|
247
262
|
});
|
|
263
|
+
}
|
|
264
|
+
describe('with --esbuild command line argument', () => {
|
|
265
|
+
beforeEach(() => Object.assign(argv, { esbuild: true }));
|
|
266
|
+
itConfiguresTsLoader();
|
|
267
|
+
itConfiguresReactToLoadAutomatically();
|
|
268
|
+
});
|
|
269
|
+
describe('with esbuild option', () => {
|
|
270
|
+
beforeEach(() => {
|
|
271
|
+
options = { esbuild: true };
|
|
272
|
+
});
|
|
273
|
+
itConfiguresTsLoader();
|
|
274
|
+
itConfiguresReactToLoadAutomatically();
|
|
275
|
+
});
|
|
276
|
+
describe('with experimental-bundlers option', () => {
|
|
277
|
+
beforeEach(() => {
|
|
278
|
+
options = { experimentalBundlers: true };
|
|
279
|
+
});
|
|
280
|
+
itConfiguresSwcLoader();
|
|
281
|
+
itConfiguresReactToLoadAutomatically();
|
|
282
|
+
});
|
|
283
|
+
describe('with --experimental-bundlers command line argument', () => {
|
|
284
|
+
beforeEach(() => Object.assign(argv, { 'experimental-bundlers': true }));
|
|
285
|
+
itConfiguresSwcLoader();
|
|
286
|
+
itConfiguresReactToLoadAutomatically();
|
|
248
287
|
});
|
|
249
288
|
|
|
250
289
|
test('configures ".css" rule to exclude .module.css files', () => {
|
|
@@ -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,11 +1,12 @@
|
|
|
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
6
|
|
|
7
7
|
import { generateMetadata } from '../generate-metadata';
|
|
8
8
|
|
|
9
|
+
jest.mock('fs', () => fs);
|
|
9
10
|
jest.mock('../get-startup-version');
|
|
10
11
|
|
|
11
12
|
describe(`[startup] ${generateMetadata.name}`, () => {
|
|
@@ -15,7 +16,7 @@ describe(`[startup] ${generateMetadata.name}`, () => {
|
|
|
15
16
|
let context: Partial<Context>;
|
|
16
17
|
|
|
17
18
|
function generatedMetadata(destination: string) {
|
|
18
|
-
return JSON.parse(
|
|
19
|
+
return JSON.parse(mockedFs.readFileSync(`${destination}/metadata.json`, 'utf8'));
|
|
19
20
|
}
|
|
20
21
|
|
|
21
22
|
function packageFS() {
|
|
@@ -23,7 +24,7 @@ describe(`[startup] ${generateMetadata.name}`, () => {
|
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
beforeEach(() => {
|
|
26
|
-
|
|
27
|
+
vol.fromJSON(packageFS());
|
|
27
28
|
jest.mocked(getStartupVersion).mockReturnValue(startupVersion);
|
|
28
29
|
|
|
29
30
|
context = {
|
|
@@ -34,7 +35,7 @@ describe(`[startup] ${generateMetadata.name}`, () => {
|
|
|
34
35
|
};
|
|
35
36
|
});
|
|
36
37
|
|
|
37
|
-
afterEach(() =>
|
|
38
|
+
afterEach(() => vol.reset());
|
|
38
39
|
|
|
39
40
|
const subject = () => generateMetadata(context as any);
|
|
40
41
|
|
|
@@ -55,14 +56,10 @@ describe(`[startup] ${generateMetadata.name}`, () => {
|
|
|
55
56
|
const light = { css: 'baz', js: 'qux' };
|
|
56
57
|
|
|
57
58
|
beforeEach(() => {
|
|
58
|
-
|
|
59
|
+
vol.fromJSON({
|
|
59
60
|
...packageFS(),
|
|
60
|
-
[destination]:
|
|
61
|
-
|
|
62
|
-
full: { 'entrypoints.json': JSON.stringify(full) },
|
|
63
|
-
light: { 'entrypoints.json': JSON.stringify(light) },
|
|
64
|
-
},
|
|
65
|
-
},
|
|
61
|
+
[`${destination}/bundle/full/entrypoints.json`]: JSON.stringify(full),
|
|
62
|
+
[`${destination}/bundle/light/entrypoints.json`]: JSON.stringify(light),
|
|
66
63
|
});
|
|
67
64
|
});
|
|
68
65
|
|
|
@@ -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
|
|
|
@@ -41,7 +41,9 @@ export function createWebpackConfig(overrides: Overrides, options: Options = {})
|
|
|
41
41
|
|
|
42
42
|
const context: Context = {
|
|
43
43
|
destination,
|
|
44
|
-
esbuild: !!(argv as Arguments).esbuild,
|
|
44
|
+
esbuild: options.esbuild ?? !!(argv as Arguments).esbuild ?? false,
|
|
45
|
+
experimentalBundlers:
|
|
46
|
+
options.experimentalBundlers ?? !!(argv as Arguments)['experimental-bundlers'] ?? false,
|
|
45
47
|
isCustomStyleRules: isCustomStyleRules(),
|
|
46
48
|
isExposeSharedDependencies: isExposeSharedDependencies(),
|
|
47
49
|
isProduction: configuration.mode === 'production',
|
package/src/webpack/types.ts
CHANGED