@tramvai/cli 2.119.5 → 2.121.2
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/lib/builder/webpack/devServer/server.js +10 -0
- package/lib/builder/webpack/devServer/server.js.map +1 -1
- package/lib/builder/webpack/tokens.d.ts +3 -0
- package/lib/config/configManager.js +12 -13
- package/lib/config/configManager.js.map +1 -1
- package/lib/di/tokens/config.d.ts +1 -0
- package/lib/library/webpack/application/client/dev.js +6 -14
- package/lib/library/webpack/application/client/dev.js.map +1 -1
- package/lib/library/webpack/application/client/prod/optimization/splitChunks.js +14 -1
- package/lib/library/webpack/application/client/prod/optimization/splitChunks.js.map +1 -1
- package/lib/library/webpack/blocks/configToEnv.js +6 -3
- package/lib/library/webpack/blocks/configToEnv.js.map +1 -1
- package/lib/library/webpack/blocks/pwa/client.js +24 -2
- package/lib/library/webpack/blocks/pwa/client.js.map +1 -1
- package/lib/library/webpack/common/main.js +3 -1
- package/lib/library/webpack/common/main.js.map +1 -1
- package/lib/library/webpack/plugins/PwaIconsPlugin.d.ts +3 -1
- package/lib/library/webpack/plugins/PwaIconsPlugin.js +7 -6
- package/lib/library/webpack/plugins/PwaIconsPlugin.js.map +1 -1
- package/lib/library/webpack/plugins/WebManifestPlugin.d.ts +6 -2
- package/lib/library/webpack/plugins/WebManifestPlugin.js +23 -3
- package/lib/library/webpack/plugins/WebManifestPlugin.js.map +1 -1
- package/lib/schema/autogeneratedSchema.json +43 -16
- package/lib/typings/configEntry/cli.d.ts +7 -0
- package/lib/typings/pwa/index.d.ts +1 -1
- package/package.json +5 -5
- package/schema.json +43 -16
- package/src/api/start/__integration__/__fixtures__/app/server.tsx +1 -0
- package/src/api/start/__integration__/start.test.ts +2 -0
- package/src/builder/webpack/devServer/server.ts +13 -0
- package/src/config/configManager.ts +10 -13
- package/src/library/webpack/application/client/dev.ts +9 -17
- package/src/library/webpack/application/client/prod/optimization/splitChunks.ts +18 -1
- package/src/library/webpack/blocks/configToEnv.ts +6 -2
- package/src/library/webpack/blocks/pwa/client.ts +36 -2
- package/src/library/webpack/common/main.ts +3 -1
- package/src/library/webpack/plugins/PwaIconsPlugin.ts +14 -7
- package/src/library/webpack/plugins/WebManifestPlugin.ts +35 -5
- package/src/models/config.spec.ts +4 -0
- package/src/schema/autogeneratedSchema.json +43 -16
- package/src/schema/tramvai.spec.ts +2 -0
- package/src/typings/configEntry/cli.ts +7 -0
- package/src/typings/pwa/index.ts +1 -1
|
@@ -8,7 +8,11 @@ const pluginName = 'PwaIconsPlugin';
|
|
|
8
8
|
export class PwaIconsPlugin implements webpack.WebpackPluginInstance {
|
|
9
9
|
private hash: string;
|
|
10
10
|
|
|
11
|
-
constructor(
|
|
11
|
+
constructor(
|
|
12
|
+
private options: PwaIconOptions & {
|
|
13
|
+
mode: 'production' | 'development';
|
|
14
|
+
}
|
|
15
|
+
) {
|
|
12
16
|
this.options = options;
|
|
13
17
|
}
|
|
14
18
|
|
|
@@ -16,7 +20,7 @@ export class PwaIconsPlugin implements webpack.WebpackPluginInstance {
|
|
|
16
20
|
const { webpack } = compiler;
|
|
17
21
|
const { Compilation } = webpack;
|
|
18
22
|
const { RawSource } = webpack.sources;
|
|
19
|
-
const { src, dest, sizes } = this.options;
|
|
23
|
+
const { src, dest, sizes, mode } = this.options;
|
|
20
24
|
|
|
21
25
|
compiler.hooks.thisCompilation.tap(pluginName, (compilation) => {
|
|
22
26
|
// watch icon source file
|
|
@@ -27,7 +31,8 @@ export class PwaIconsPlugin implements webpack.WebpackPluginInstance {
|
|
|
27
31
|
compilation.hooks.processAssets.tapPromise(
|
|
28
32
|
{
|
|
29
33
|
name: pluginName,
|
|
30
|
-
|
|
34
|
+
// to work before WebManifestPlugin
|
|
35
|
+
stage: Compilation.PROCESS_ASSETS_STAGE_ADDITIONS - 1,
|
|
31
36
|
},
|
|
32
37
|
async () => {
|
|
33
38
|
try {
|
|
@@ -59,21 +64,23 @@ export class PwaIconsPlugin implements webpack.WebpackPluginInstance {
|
|
|
59
64
|
})
|
|
60
65
|
.toBuffer()
|
|
61
66
|
.then((content) => ({
|
|
62
|
-
filename: `${dest}/${size}x${size}
|
|
67
|
+
filename: `${dest}/${size}x${size}${
|
|
68
|
+
mode === 'development' ? '' : `.${this.hash}`
|
|
69
|
+
}.png`,
|
|
63
70
|
content,
|
|
64
71
|
}));
|
|
65
72
|
});
|
|
66
73
|
|
|
67
74
|
const results = await Promise.all(promises);
|
|
68
75
|
|
|
69
|
-
results.forEach(({ filename, content }) => {
|
|
76
|
+
results.forEach(({ filename, content }, i) => {
|
|
70
77
|
const source = new RawSource(content);
|
|
71
78
|
const asset = compilation.getAsset(filename);
|
|
72
79
|
|
|
73
80
|
if (asset) {
|
|
74
|
-
compilation.updateAsset(filename, source);
|
|
81
|
+
compilation.updateAsset(filename, source, { _pwaIconSize: sizes[i] });
|
|
75
82
|
} else {
|
|
76
|
-
compilation.emitAsset(filename, source);
|
|
83
|
+
compilation.emitAsset(filename, source, { _pwaIconSize: sizes[i] });
|
|
77
84
|
}
|
|
78
85
|
});
|
|
79
86
|
} catch (e) {
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import type webpack from 'webpack';
|
|
2
2
|
import type { Compiler } from 'webpack';
|
|
3
|
-
import type { WebManifestOptions } from '../../../typings/pwa';
|
|
3
|
+
import type { PwaIconOptions, WebManifestOptions } from '../../../typings/pwa';
|
|
4
4
|
|
|
5
5
|
const pluginName = 'WebManifestPlugin';
|
|
6
6
|
|
|
7
7
|
export class WebManifestPlugin implements webpack.WebpackPluginInstance {
|
|
8
|
-
constructor(
|
|
8
|
+
constructor(
|
|
9
|
+
private options: { manifest: WebManifestOptions; icon: PwaIconOptions; assetsPrefix: string }
|
|
10
|
+
) {
|
|
9
11
|
this.options = options;
|
|
10
12
|
}
|
|
11
13
|
|
|
@@ -13,7 +15,11 @@ export class WebManifestPlugin implements webpack.WebpackPluginInstance {
|
|
|
13
15
|
const { webpack } = compiler;
|
|
14
16
|
const { Compilation } = webpack;
|
|
15
17
|
const { RawSource } = webpack.sources;
|
|
16
|
-
const {
|
|
18
|
+
const {
|
|
19
|
+
manifest: { dest, enabled, ...content },
|
|
20
|
+
icon,
|
|
21
|
+
assetsPrefix,
|
|
22
|
+
} = this.options;
|
|
17
23
|
|
|
18
24
|
compiler.hooks.thisCompilation.tap(pluginName, (compilation) => {
|
|
19
25
|
compilation.hooks.processAssets.tap(
|
|
@@ -21,10 +27,34 @@ export class WebManifestPlugin implements webpack.WebpackPluginInstance {
|
|
|
21
27
|
name: pluginName,
|
|
22
28
|
stage: Compilation.PROCESS_ASSETS_STAGE_ADDITIONS,
|
|
23
29
|
},
|
|
24
|
-
() => {
|
|
30
|
+
(compilationAssets) => {
|
|
31
|
+
if (!content.icons && icon?.src) {
|
|
32
|
+
const assets = Object.keys(compilationAssets);
|
|
33
|
+
|
|
34
|
+
assets.forEach((asset) => {
|
|
35
|
+
const assetInfo = compilation.assetsInfo.get(asset);
|
|
36
|
+
// asset info `_pwaIconSize` added in PwaIconsPlugin
|
|
37
|
+
const size = assetInfo._pwaIconSize;
|
|
38
|
+
|
|
39
|
+
if (size) {
|
|
40
|
+
if (!content.icons) {
|
|
41
|
+
content.icons = [];
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
content.icons.push({
|
|
45
|
+
src: `${assetsPrefix}${asset}`,
|
|
46
|
+
sizes: `${size}x${size}`,
|
|
47
|
+
type: 'image/png',
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
|
|
25
53
|
const manifestFilename = dest.replace(/^\//, '');
|
|
26
54
|
|
|
27
|
-
compilation.emitAsset(manifestFilename, new RawSource(JSON.stringify(content, null, 2))
|
|
55
|
+
compilation.emitAsset(manifestFilename, new RawSource(JSON.stringify(content, null, 2)), {
|
|
56
|
+
_webmanifestFilename: manifestFilename,
|
|
57
|
+
});
|
|
28
58
|
}
|
|
29
59
|
);
|
|
30
60
|
});
|
|
@@ -102,6 +102,7 @@ it('should populate defaults for config', () => {
|
|
|
102
102
|
"root": "src",
|
|
103
103
|
"serverApiDir": "src/api",
|
|
104
104
|
"shared": {
|
|
105
|
+
"criticalChunks": [],
|
|
105
106
|
"deps": [],
|
|
106
107
|
"flexibleTramvaiVersions": true,
|
|
107
108
|
},
|
|
@@ -159,6 +160,7 @@ it('should populate defaults for config', () => {
|
|
|
159
160
|
},
|
|
160
161
|
"root": "packages/child-app",
|
|
161
162
|
"shared": {
|
|
163
|
+
"criticalChunks": [],
|
|
162
164
|
"deps": [],
|
|
163
165
|
"flexibleTramvaiVersions": true,
|
|
164
166
|
},
|
|
@@ -337,6 +339,7 @@ it('should populate defaults for overridable options', () => {
|
|
|
337
339
|
"root": "src",
|
|
338
340
|
"serverApiDir": "src/api",
|
|
339
341
|
"shared": {
|
|
342
|
+
"criticalChunks": [],
|
|
340
343
|
"deps": [],
|
|
341
344
|
"flexibleTramvaiVersions": true,
|
|
342
345
|
},
|
|
@@ -408,6 +411,7 @@ it('should populate defaults for overridable options', () => {
|
|
|
408
411
|
},
|
|
409
412
|
"root": "packages/child-app",
|
|
410
413
|
"shared": {
|
|
414
|
+
"criticalChunks": [],
|
|
411
415
|
"deps": [],
|
|
412
416
|
"flexibleTramvaiVersions": true,
|
|
413
417
|
},
|
|
@@ -652,7 +652,7 @@
|
|
|
652
652
|
"type": "boolean"
|
|
653
653
|
},
|
|
654
654
|
"dest": {
|
|
655
|
-
"title": "Name of generated manifest file (will be placed in \"output.client\" directory). You can use `[hash]` placeholder for manifest cache busting",
|
|
655
|
+
"title": "Name of generated manifest file (will be placed in \"output.client\" directory). You can use `[hash]` placeholder for manifest cache busting in production mode",
|
|
656
656
|
"default": "/manifest.[hash].json",
|
|
657
657
|
"type": "string"
|
|
658
658
|
},
|
|
@@ -1122,23 +1122,23 @@
|
|
|
1122
1122
|
"dotAll": {
|
|
1123
1123
|
"type": "boolean"
|
|
1124
1124
|
},
|
|
1125
|
-
"__@match@
|
|
1125
|
+
"__@match@8168": {
|
|
1126
1126
|
"type": "object",
|
|
1127
1127
|
"additionalProperties": false
|
|
1128
1128
|
},
|
|
1129
|
-
"__@replace@
|
|
1129
|
+
"__@replace@8170": {
|
|
1130
1130
|
"type": "object",
|
|
1131
1131
|
"additionalProperties": false
|
|
1132
1132
|
},
|
|
1133
|
-
"__@search@
|
|
1133
|
+
"__@search@8173": {
|
|
1134
1134
|
"type": "object",
|
|
1135
1135
|
"additionalProperties": false
|
|
1136
1136
|
},
|
|
1137
|
-
"__@split@
|
|
1137
|
+
"__@split@8175": {
|
|
1138
1138
|
"type": "object",
|
|
1139
1139
|
"additionalProperties": false
|
|
1140
1140
|
},
|
|
1141
|
-
"__@matchAll@
|
|
1141
|
+
"__@matchAll@8177": {
|
|
1142
1142
|
"type": "object",
|
|
1143
1143
|
"additionalProperties": false
|
|
1144
1144
|
}
|
|
@@ -1344,6 +1344,15 @@
|
|
|
1344
1344
|
"default": true,
|
|
1345
1345
|
"type": "boolean"
|
|
1346
1346
|
},
|
|
1347
|
+
"criticalChunks": {
|
|
1348
|
+
"title": "add chunks to preload as critical in-parallel with \"platform.js\"",
|
|
1349
|
+
"description": "this option is useful when you need to create async boundary for app dependencies.\nMore info - https://webpack.js.org/concepts/module-federation/#uncaught-error-shared-module-is-not-available-for-eager-consumption",
|
|
1350
|
+
"default": [],
|
|
1351
|
+
"type": "array",
|
|
1352
|
+
"items": {
|
|
1353
|
+
"type": "string"
|
|
1354
|
+
}
|
|
1355
|
+
},
|
|
1347
1356
|
"deps": {
|
|
1348
1357
|
"title": "list of the dependencies that will be shared",
|
|
1349
1358
|
"default": [],
|
|
@@ -1755,23 +1764,23 @@
|
|
|
1755
1764
|
"dotAll": {
|
|
1756
1765
|
"type": "boolean"
|
|
1757
1766
|
},
|
|
1758
|
-
"__@match@
|
|
1767
|
+
"__@match@8168": {
|
|
1759
1768
|
"type": "object",
|
|
1760
1769
|
"additionalProperties": false
|
|
1761
1770
|
},
|
|
1762
|
-
"__@replace@
|
|
1771
|
+
"__@replace@8170": {
|
|
1763
1772
|
"type": "object",
|
|
1764
1773
|
"additionalProperties": false
|
|
1765
1774
|
},
|
|
1766
|
-
"__@search@
|
|
1775
|
+
"__@search@8173": {
|
|
1767
1776
|
"type": "object",
|
|
1768
1777
|
"additionalProperties": false
|
|
1769
1778
|
},
|
|
1770
|
-
"__@split@
|
|
1779
|
+
"__@split@8175": {
|
|
1771
1780
|
"type": "object",
|
|
1772
1781
|
"additionalProperties": false
|
|
1773
1782
|
},
|
|
1774
|
-
"__@matchAll@
|
|
1783
|
+
"__@matchAll@8177": {
|
|
1775
1784
|
"type": "object",
|
|
1776
1785
|
"additionalProperties": false
|
|
1777
1786
|
}
|
|
@@ -1977,6 +1986,15 @@
|
|
|
1977
1986
|
"default": true,
|
|
1978
1987
|
"type": "boolean"
|
|
1979
1988
|
},
|
|
1989
|
+
"criticalChunks": {
|
|
1990
|
+
"title": "add chunks to preload as critical in-parallel with \"platform.js\"",
|
|
1991
|
+
"description": "this option is useful when you need to create async boundary for app dependencies.\nMore info - https://webpack.js.org/concepts/module-federation/#uncaught-error-shared-module-is-not-available-for-eager-consumption",
|
|
1992
|
+
"default": [],
|
|
1993
|
+
"type": "array",
|
|
1994
|
+
"items": {
|
|
1995
|
+
"type": "string"
|
|
1996
|
+
}
|
|
1997
|
+
},
|
|
1980
1998
|
"deps": {
|
|
1981
1999
|
"title": "list of the dependencies that will be shared",
|
|
1982
2000
|
"default": [],
|
|
@@ -2388,23 +2406,23 @@
|
|
|
2388
2406
|
"dotAll": {
|
|
2389
2407
|
"type": "boolean"
|
|
2390
2408
|
},
|
|
2391
|
-
"__@match@
|
|
2409
|
+
"__@match@8168": {
|
|
2392
2410
|
"type": "object",
|
|
2393
2411
|
"additionalProperties": false
|
|
2394
2412
|
},
|
|
2395
|
-
"__@replace@
|
|
2413
|
+
"__@replace@8170": {
|
|
2396
2414
|
"type": "object",
|
|
2397
2415
|
"additionalProperties": false
|
|
2398
2416
|
},
|
|
2399
|
-
"__@search@
|
|
2417
|
+
"__@search@8173": {
|
|
2400
2418
|
"type": "object",
|
|
2401
2419
|
"additionalProperties": false
|
|
2402
2420
|
},
|
|
2403
|
-
"__@split@
|
|
2421
|
+
"__@split@8175": {
|
|
2404
2422
|
"type": "object",
|
|
2405
2423
|
"additionalProperties": false
|
|
2406
2424
|
},
|
|
2407
|
-
"__@matchAll@
|
|
2425
|
+
"__@matchAll@8177": {
|
|
2408
2426
|
"type": "object",
|
|
2409
2427
|
"additionalProperties": false
|
|
2410
2428
|
}
|
|
@@ -2610,6 +2628,15 @@
|
|
|
2610
2628
|
"default": true,
|
|
2611
2629
|
"type": "boolean"
|
|
2612
2630
|
},
|
|
2631
|
+
"criticalChunks": {
|
|
2632
|
+
"title": "add chunks to preload as critical in-parallel with \"platform.js\"",
|
|
2633
|
+
"description": "this option is useful when you need to create async boundary for app dependencies.\nMore info - https://webpack.js.org/concepts/module-federation/#uncaught-error-shared-module-is-not-available-for-eager-consumption",
|
|
2634
|
+
"default": [],
|
|
2635
|
+
"type": "array",
|
|
2636
|
+
"items": {
|
|
2637
|
+
"type": "string"
|
|
2638
|
+
}
|
|
2639
|
+
},
|
|
2613
2640
|
"deps": {
|
|
2614
2641
|
"title": "list of the dependencies that will be shared",
|
|
2615
2642
|
"default": [],
|
|
@@ -125,6 +125,7 @@ describe('JSON schema для tramvai.json', () => {
|
|
|
125
125
|
"root": "src/app",
|
|
126
126
|
"serverApiDir": "src/api",
|
|
127
127
|
"shared": {
|
|
128
|
+
"criticalChunks": [],
|
|
128
129
|
"deps": [],
|
|
129
130
|
"flexibleTramvaiVersions": true,
|
|
130
131
|
},
|
|
@@ -182,6 +183,7 @@ describe('JSON schema для tramvai.json', () => {
|
|
|
182
183
|
},
|
|
183
184
|
"root": "src/module",
|
|
184
185
|
"shared": {
|
|
186
|
+
"criticalChunks": [],
|
|
185
187
|
"deps": [],
|
|
186
188
|
"flexibleTramvaiVersions": true,
|
|
187
189
|
},
|
|
@@ -302,6 +302,13 @@ export interface CliConfigEntry extends ConfigEntry {
|
|
|
302
302
|
* @default true
|
|
303
303
|
*/
|
|
304
304
|
flexibleTramvaiVersions: boolean;
|
|
305
|
+
/**
|
|
306
|
+
* @title add chunks to preload as critical in-parallel with "platform.js"
|
|
307
|
+
* @description this option is useful when you need to create async boundary for app dependencies.
|
|
308
|
+
* More info - https://webpack.js.org/concepts/module-federation/#uncaught-error-shared-module-is-not-available-for-eager-consumption
|
|
309
|
+
* @default []
|
|
310
|
+
*/
|
|
311
|
+
criticalChunks: string[];
|
|
305
312
|
/**
|
|
306
313
|
* @title list of the dependencies that will be shared
|
|
307
314
|
* @default []
|
package/src/typings/pwa/index.ts
CHANGED
|
@@ -5,7 +5,7 @@ export type WebManifestOptions = {
|
|
|
5
5
|
*/
|
|
6
6
|
enabled?: boolean;
|
|
7
7
|
/**
|
|
8
|
-
* @title Name of generated manifest file (will be placed in "output.client" directory). You can use `[hash]` placeholder for manifest cache busting
|
|
8
|
+
* @title Name of generated manifest file (will be placed in "output.client" directory). You can use `[hash]` placeholder for manifest cache busting in production mode
|
|
9
9
|
* @default "/manifest.[hash].json"
|
|
10
10
|
*/
|
|
11
11
|
dest?: string;
|