@tramvai/cli 2.75.0 → 2.77.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 (53) hide show
  1. package/lib/builder/webpack/tokens.d.ts +21 -0
  2. package/lib/config/configManager.js +2 -1
  3. package/lib/config/configManager.js.map +1 -1
  4. package/lib/di/tokens/config.d.ts +7 -0
  5. package/lib/library/webpack/blocks/css.js +9 -2
  6. package/lib/library/webpack/blocks/css.js.map +1 -1
  7. package/lib/library/webpack/child-app/client/common.js +3 -17
  8. package/lib/library/webpack/child-app/client/common.js.map +1 -1
  9. package/lib/library/webpack/child-app/common.js +29 -11
  10. package/lib/library/webpack/child-app/common.js.map +1 -1
  11. package/lib/library/webpack/child-app/moduleFederationShared.d.ts +2 -1
  12. package/lib/library/webpack/child-app/moduleFederationShared.js +37 -11
  13. package/lib/library/webpack/child-app/moduleFederationShared.js.map +1 -1
  14. package/lib/library/webpack/child-app/server/common.js +11 -8
  15. package/lib/library/webpack/child-app/server/common.js.map +1 -1
  16. package/lib/library/webpack/common/main.js +3 -0
  17. package/lib/library/webpack/common/main.js.map +1 -1
  18. package/lib/library/webpack/loaders/childAppFallback.d.ts +6 -0
  19. package/lib/library/webpack/loaders/childAppFallback.js +26 -0
  20. package/lib/library/webpack/loaders/childAppFallback.js.map +1 -0
  21. package/lib/library/webpack/types/webpack.d.ts +2 -0
  22. package/lib/schema/autogeneratedSchema.json +262 -230
  23. package/lib/typings/configEntry/application.d.ts +1 -1
  24. package/lib/typings/configEntry/cli.d.ts +30 -0
  25. package/package.json +12 -11
  26. package/schema.json +262 -230
  27. package/src/api/build/__integration__/build.test.ts +0 -4
  28. package/src/config/configManager.ts +2 -1
  29. package/src/library/babel/plugins/__snapshots__/provider-stack.spec.ts.snap +2 -9
  30. package/src/library/babel/plugins/lazy-component/__snapshots__/lazy-component.spec.ts.snap +6 -70
  31. package/src/library/babel/plugins/lazy-component/__snapshots__/legacy-universal-replace.spec.ts.snap +2 -25
  32. package/src/library/swc/__integration__/__snapshots__/swc.build.test.ts.snap +2 -5
  33. package/src/library/swc/__integration__/__snapshots__/swc.start.test.ts.snap +31 -33
  34. package/src/library/webpack/application/client/dev.ts +1 -1
  35. package/src/library/webpack/application/client/prod.ts +1 -1
  36. package/src/library/webpack/blocks/css.ts +9 -2
  37. package/src/library/webpack/child-app/client/common.ts +3 -22
  38. package/src/library/webpack/child-app/common.ts +36 -14
  39. package/src/library/webpack/child-app/moduleFederationShared.ts +44 -2
  40. package/src/library/webpack/child-app/server/common.ts +13 -12
  41. package/src/library/webpack/common/main.ts +7 -0
  42. package/src/library/webpack/loaders/childAppFallback.ts +31 -0
  43. package/src/library/webpack/types/webpack.ts +5 -0
  44. package/src/models/config.spec.ts +12 -0
  45. package/src/schema/autogeneratedSchema.json +262 -230
  46. package/src/schema/tramvai.spec.ts +6 -0
  47. package/src/typings/configEntry/application.ts +1 -1
  48. package/src/typings/configEntry/cli.ts +33 -0
  49. package/src/typings/webpack-chain/index.d.ts +1 -1
  50. package/lib/library/webpack/plugins/LazyLibraryInitialization.d.ts +0 -20
  51. package/lib/library/webpack/plugins/LazyLibraryInitialization.js +0 -58
  52. package/lib/library/webpack/plugins/LazyLibraryInitialization.js.map +0 -1
  53. package/src/library/webpack/plugins/LazyLibraryInitialization.ts +0 -70
@@ -150,177 +150,120 @@
150
150
  "type": "boolean"
151
151
  },
152
152
  "typescript": {
153
- "anyOf": [
154
- {
153
+ "type": "object",
154
+ "properties": {
155
+ "memoryLimit": {
156
+ "type": "number"
157
+ },
158
+ "configFile": {
159
+ "type": "string"
160
+ },
161
+ "configOverwrite": {
155
162
  "type": "object",
156
163
  "properties": {
157
- "enabled": {
158
- "type": "boolean"
159
- },
160
- "memoryLimit": {
161
- "type": "number"
162
- },
163
- "configFile": {
164
- "type": "string"
165
- },
166
- "configOverwrite": {
167
- "type": "object",
168
- "properties": {
169
- "extends": {
170
- "type": "string"
171
- },
172
- "compilerOptions": {
173
- "type": "object",
174
- "properties": {},
175
- "additionalProperties": true
176
- },
177
- "include": {
178
- "type": "array",
179
- "items": {
180
- "type": "string"
181
- }
182
- },
183
- "exclude": {
184
- "type": "array",
185
- "items": {
186
- "type": "string"
187
- }
188
- },
189
- "files": {
190
- "type": "array",
191
- "items": {
192
- "type": "string"
193
- }
194
- },
195
- "references": {
196
- "type": "array",
197
- "items": {
198
- "type": "object",
199
- "properties": {
200
- "path": {
201
- "type": "string"
202
- },
203
- "prepend": {
204
- "type": "boolean"
205
- }
206
- },
207
- "additionalProperties": false
208
- }
209
- }
210
- },
211
- "additionalProperties": false
212
- },
213
- "context": {
214
- "type": "string"
215
- },
216
- "build": {
217
- "type": "boolean"
218
- },
219
- "mode": {
220
- "enum": [
221
- "readonly",
222
- "write-dts",
223
- "write-references",
224
- "write-tsbuildinfo"
225
- ],
164
+ "extends": {
226
165
  "type": "string"
227
166
  },
228
- "diagnosticOptions": {
229
- "type": "object",
230
- "properties": {
231
- "syntactic": {
232
- "type": "boolean"
233
- },
234
- "semantic": {
235
- "type": "boolean"
236
- },
237
- "declaration": {
238
- "type": "boolean"
239
- },
240
- "global": {
241
- "type": "boolean"
242
- }
243
- },
244
- "additionalProperties": false
245
- },
246
- "extensions": {
247
- "type": "object",
248
- "properties": {
249
- "vue": {
250
- "anyOf": [
251
- {
252
- "type": "object",
253
- "properties": {
254
- "enabled": {
255
- "type": "boolean"
256
- },
257
- "compiler": {
258
- "type": "string"
259
- }
260
- },
261
- "additionalProperties": false
262
- },
263
- {
264
- "type": "boolean"
265
- }
266
- ]
267
- }
268
- },
269
- "additionalProperties": false
167
+ "compilerOptions": {},
168
+ "include": {
169
+ "type": "array",
170
+ "items": {
171
+ "type": "string"
172
+ }
270
173
  },
271
- "profile": {
272
- "type": "boolean"
174
+ "exclude": {
175
+ "type": "array",
176
+ "items": {
177
+ "type": "string"
178
+ }
273
179
  },
274
- "typescriptPath": {
275
- "type": "string"
276
- }
277
- },
278
- "additionalProperties": false
279
- },
280
- {
281
- "type": "boolean"
282
- }
283
- ]
284
- },
285
- "eslint": {
286
- "type": "object",
287
- "properties": {
288
- "files": {
289
- "anyOf": [
290
- {
180
+ "files": {
291
181
  "type": "array",
292
182
  "items": {
293
183
  "type": "string"
294
184
  }
295
185
  },
296
- {
297
- "type": "string"
186
+ "references": {
187
+ "type": "array",
188
+ "items": {
189
+ "type": "object",
190
+ "properties": {
191
+ "path": {
192
+ "type": "string"
193
+ },
194
+ "prepend": {
195
+ "type": "boolean"
196
+ }
197
+ },
198
+ "additionalProperties": false
199
+ }
298
200
  }
299
- ]
201
+ },
202
+ "additionalProperties": false
300
203
  },
301
- "enabled": {
204
+ "context": {
205
+ "type": "string"
206
+ },
207
+ "build": {
302
208
  "type": "boolean"
303
209
  },
304
- "memoryLimit": {
305
- "type": "number"
210
+ "mode": {
211
+ "enum": [
212
+ "readonly",
213
+ "write-dts",
214
+ "write-references",
215
+ "write-tsbuildinfo"
216
+ ],
217
+ "type": "string"
306
218
  },
307
- "options": {
219
+ "diagnosticOptions": {
308
220
  "type": "object",
309
221
  "properties": {
310
- "cwd": {
311
- "type": "string"
222
+ "syntactic": {
223
+ "type": "boolean"
312
224
  },
313
- "extensions": {
314
- "type": "array",
315
- "items": {
316
- "type": "string"
317
- }
225
+ "semantic": {
226
+ "type": "boolean"
227
+ },
228
+ "declaration": {
229
+ "type": "boolean"
318
230
  },
319
- "fix": {
231
+ "global": {
320
232
  "type": "boolean"
321
233
  }
322
234
  },
323
235
  "additionalProperties": false
236
+ },
237
+ "extensions": {
238
+ "type": "object",
239
+ "properties": {
240
+ "vue": {
241
+ "anyOf": [
242
+ {
243
+ "type": "object",
244
+ "properties": {
245
+ "enabled": {
246
+ "type": "boolean"
247
+ },
248
+ "compiler": {
249
+ "type": "string"
250
+ }
251
+ },
252
+ "additionalProperties": false
253
+ },
254
+ {
255
+ "type": "boolean"
256
+ }
257
+ ]
258
+ }
259
+ },
260
+ "additionalProperties": false
261
+ },
262
+ "profile": {
263
+ "type": "boolean"
264
+ },
265
+ "typescriptPath": {
266
+ "type": "string"
324
267
  }
325
268
  },
326
269
  "additionalProperties": false
@@ -335,20 +278,37 @@
335
278
  "type": "object",
336
279
  "properties": {
337
280
  "type": {
338
- "anyOf": [
339
- {
340
- "type": "object",
341
- "additionalProperties": false
342
- },
343
- {
344
- "enum": [
345
- "basic",
346
- "codeframe"
347
- ],
348
- "type": "string"
349
- }
281
+ "type": "string",
282
+ "enum": [
283
+ "basic"
284
+ ]
285
+ },
286
+ "pathType": {
287
+ "enum": [
288
+ "absolute",
289
+ "relative"
290
+ ],
291
+ "type": "string"
292
+ }
293
+ },
294
+ "additionalProperties": false
295
+ },
296
+ {
297
+ "type": "object",
298
+ "properties": {
299
+ "type": {
300
+ "type": "string",
301
+ "enum": [
302
+ "codeframe"
350
303
  ]
351
304
  },
305
+ "pathType": {
306
+ "enum": [
307
+ "absolute",
308
+ "relative"
309
+ ],
310
+ "type": "string"
311
+ },
352
312
  "options": {
353
313
  "type": "object",
354
314
  "properties": {
@@ -405,9 +365,6 @@
405
365
  "file": {
406
366
  "type": "string"
407
367
  },
408
- "origin": {
409
- "type": "string"
410
- },
411
368
  "severity": {
412
369
  "enum": [
413
370
  "error",
@@ -435,9 +392,6 @@
435
392
  "file": {
436
393
  "type": "string"
437
394
  },
438
- "origin": {
439
- "type": "string"
440
- },
441
395
  "severity": {
442
396
  "enum": [
443
397
  "error",
@@ -468,9 +422,6 @@
468
422
  "file": {
469
423
  "type": "string"
470
424
  },
471
- "origin": {
472
- "type": "string"
473
- },
474
425
  "severity": {
475
426
  "enum": [
476
427
  "error",
@@ -498,9 +449,6 @@
498
449
  "file": {
499
450
  "type": "string"
500
451
  },
501
- "origin": {
502
- "type": "string"
503
- },
504
452
  "severity": {
505
453
  "enum": [
506
454
  "error",
@@ -520,73 +468,31 @@
520
468
  "additionalProperties": false
521
469
  },
522
470
  "logger": {
523
- "type": "object",
524
- "properties": {
525
- "infrastructure": {
526
- "anyOf": [
527
- {
471
+ "anyOf": [
472
+ {
473
+ "type": "object",
474
+ "properties": {
475
+ "log": {
528
476
  "type": "object",
529
- "properties": {
530
- "info": {
531
- "type": "object",
532
- "additionalProperties": false
533
- },
534
- "log": {
535
- "type": "object",
536
- "additionalProperties": false
537
- },
538
- "error": {
539
- "type": "object",
540
- "additionalProperties": false
541
- }
542
- },
543
477
  "additionalProperties": false
544
478
  },
545
- {
546
- "enum": [
547
- "console",
548
- "silent",
549
- "webpack-infrastructure"
550
- ],
551
- "type": "string"
552
- }
553
- ]
554
- },
555
- "issues": {
556
- "anyOf": [
557
- {
479
+ "error": {
558
480
  "type": "object",
559
- "properties": {
560
- "info": {
561
- "type": "object",
562
- "additionalProperties": false
563
- },
564
- "log": {
565
- "type": "object",
566
- "additionalProperties": false
567
- },
568
- "error": {
569
- "type": "object",
570
- "additionalProperties": false
571
- }
572
- },
573
481
  "additionalProperties": false
574
- },
575
- {
576
- "enum": [
577
- "console",
578
- "silent",
579
- "webpack-infrastructure"
580
- ],
581
- "type": "string"
582
482
  }
583
- ]
483
+ },
484
+ "additionalProperties": false
584
485
  },
585
- "devServer": {
586
- "type": "boolean"
486
+ {
487
+ "enum": [
488
+ "webpack-infrastructure"
489
+ ],
490
+ "type": "string"
587
491
  }
588
- },
589
- "additionalProperties": false
492
+ ]
493
+ },
494
+ "devServer": {
495
+ "type": "boolean"
590
496
  }
591
497
  },
592
498
  "additionalProperties": false
@@ -1079,6 +985,48 @@
1079
985
  }
1080
986
  },
1081
987
  "additionalProperties": false
988
+ },
989
+ "shared": {
990
+ "title": "Specify dependencies that will be shared between application and child-apps",
991
+ "description": "Properly defining that dependencies may greatly reduce filesize of loaded js on the client",
992
+ "default": {},
993
+ "type": "object",
994
+ "properties": {
995
+ "defaultTramvaiDependencies": {
996
+ "title": "Should default dependencies list be added to shared list",
997
+ "description": "It includes the list of commonly used dependencies in the child-apps\nBy default, it is enabled in application in case of",
998
+ "type": "boolean"
999
+ },
1000
+ "deps": {
1001
+ "title": "list of the dependencies that will be shared",
1002
+ "default": [],
1003
+ "type": "array",
1004
+ "items": {
1005
+ "anyOf": [
1006
+ {
1007
+ "type": "object",
1008
+ "properties": {
1009
+ "name": {
1010
+ "title": "name of the dependency import",
1011
+ "type": "string"
1012
+ },
1013
+ "singleton": {
1014
+ "title": "if dependency is marked as singleton the dependency will be initialized only once and will not be updated",
1015
+ "description": "Do not overuse that feature as it may lead to subtle bugs in case of different versions on different sides",
1016
+ "default": ": false",
1017
+ "type": "boolean"
1018
+ }
1019
+ },
1020
+ "additionalProperties": false
1021
+ },
1022
+ {
1023
+ "type": "string"
1024
+ }
1025
+ ]
1026
+ }
1027
+ }
1028
+ },
1029
+ "additionalProperties": false
1082
1030
  }
1083
1031
  },
1084
1032
  "required": [
@@ -1551,6 +1499,48 @@
1551
1499
  }
1552
1500
  },
1553
1501
  "additionalProperties": false
1502
+ },
1503
+ "shared": {
1504
+ "title": "Specify dependencies that will be shared between application and child-apps",
1505
+ "description": "Properly defining that dependencies may greatly reduce filesize of loaded js on the client",
1506
+ "default": {},
1507
+ "type": "object",
1508
+ "properties": {
1509
+ "defaultTramvaiDependencies": {
1510
+ "title": "Should default dependencies list be added to shared list",
1511
+ "description": "It includes the list of commonly used dependencies in the child-apps\nBy default, it is enabled in application in case of",
1512
+ "type": "boolean"
1513
+ },
1514
+ "deps": {
1515
+ "title": "list of the dependencies that will be shared",
1516
+ "default": [],
1517
+ "type": "array",
1518
+ "items": {
1519
+ "anyOf": [
1520
+ {
1521
+ "type": "object",
1522
+ "properties": {
1523
+ "name": {
1524
+ "title": "name of the dependency import",
1525
+ "type": "string"
1526
+ },
1527
+ "singleton": {
1528
+ "title": "if dependency is marked as singleton the dependency will be initialized only once and will not be updated",
1529
+ "description": "Do not overuse that feature as it may lead to subtle bugs in case of different versions on different sides",
1530
+ "default": ": false",
1531
+ "type": "boolean"
1532
+ }
1533
+ },
1534
+ "additionalProperties": false
1535
+ },
1536
+ {
1537
+ "type": "string"
1538
+ }
1539
+ ]
1540
+ }
1541
+ }
1542
+ },
1543
+ "additionalProperties": false
1554
1544
  }
1555
1545
  },
1556
1546
  "required": [
@@ -2023,6 +2013,48 @@
2023
2013
  }
2024
2014
  },
2025
2015
  "additionalProperties": false
2016
+ },
2017
+ "shared": {
2018
+ "title": "Specify dependencies that will be shared between application and child-apps",
2019
+ "description": "Properly defining that dependencies may greatly reduce filesize of loaded js on the client",
2020
+ "default": {},
2021
+ "type": "object",
2022
+ "properties": {
2023
+ "defaultTramvaiDependencies": {
2024
+ "title": "Should default dependencies list be added to shared list",
2025
+ "description": "It includes the list of commonly used dependencies in the child-apps\nBy default, it is enabled in application in case of",
2026
+ "type": "boolean"
2027
+ },
2028
+ "deps": {
2029
+ "title": "list of the dependencies that will be shared",
2030
+ "default": [],
2031
+ "type": "array",
2032
+ "items": {
2033
+ "anyOf": [
2034
+ {
2035
+ "type": "object",
2036
+ "properties": {
2037
+ "name": {
2038
+ "title": "name of the dependency import",
2039
+ "type": "string"
2040
+ },
2041
+ "singleton": {
2042
+ "title": "if dependency is marked as singleton the dependency will be initialized only once and will not be updated",
2043
+ "description": "Do not overuse that feature as it may lead to subtle bugs in case of different versions on different sides",
2044
+ "default": ": false",
2045
+ "type": "boolean"
2046
+ }
2047
+ },
2048
+ "additionalProperties": false
2049
+ },
2050
+ {
2051
+ "type": "string"
2052
+ }
2053
+ ]
2054
+ }
2055
+ }
2056
+ },
2057
+ "additionalProperties": false
2026
2058
  }
2027
2059
  },
2028
2060
  "required": [
@@ -93,6 +93,9 @@ describe('JSON schema для tramvai.json', () => {
93
93
  "postcss": {},
94
94
  "root": "src/app",
95
95
  "serverApiDir": "src/api",
96
+ "shared": {
97
+ "deps": [],
98
+ },
96
99
  "sourceMap": false,
97
100
  "splitChunks": {
98
101
  "commonChunkSplitNumber": 3,
@@ -142,6 +145,9 @@ describe('JSON schema для tramvai.json', () => {
142
145
  "cssLocalIdentName": "[hash:base64:5]",
143
146
  },
144
147
  "root": "src/module",
148
+ "shared": {
149
+ "deps": [],
150
+ },
145
151
  "sourceMap": false,
146
152
  "terser": {
147
153
  "parallel": true,
@@ -1,5 +1,5 @@
1
1
  // eslint-disable-next-line no-restricted-imports
2
- import type { ForkTsCheckerWebpackPluginOptions } from 'fork-ts-checker-webpack-plugin/lib/ForkTsCheckerWebpackPluginOptions';
2
+ import type { ForkTsCheckerWebpackPluginOptions } from 'fork-ts-checker-webpack-plugin/lib/plugin-options';
3
3
  import type { CliConfigEntry, Experiments } from './cli';
4
4
  import type { OverridableOption } from './common';
5
5
 
@@ -268,4 +268,37 @@ export interface CliConfigEntry extends ConfigEntry {
268
268
  client?: Notifications;
269
269
  server?: Notifications;
270
270
  };
271
+ /**
272
+ * @title Specify dependencies that will be shared between application and child-apps
273
+ * @description Properly defining that dependencies may greatly reduce filesize of loaded js on the client
274
+ * @default {}
275
+ */
276
+ shared: {
277
+ /**
278
+ * @title Should default dependencies list be added to shared list
279
+ * @description It includes the list of commonly used dependencies in the child-apps
280
+ * By default, it is enabled in application in case of @tramvai/module-child-app is specified in package.json
281
+ * and for child-apps
282
+ */
283
+ defaultTramvaiDependencies?: boolean;
284
+ /**
285
+ * @title list of the dependencies that will be shared
286
+ * @default []
287
+ */
288
+ deps: Array<
289
+ | string
290
+ | {
291
+ /**
292
+ * @title name of the dependency import
293
+ */
294
+ name: string;
295
+ /**
296
+ * @title if dependency is marked as singleton the dependency will be initialized only once and will not be updated
297
+ * @description Do not overuse that feature as it may lead to subtle bugs in case of different versions on different sides
298
+ * @default: false
299
+ */
300
+ singleton: boolean;
301
+ }
302
+ >;
303
+ };
271
304
  }
@@ -116,7 +116,7 @@ declare module 'webpack-chain' {
116
116
 
117
117
  stats(value: webpack.Options.Stats): this;
118
118
 
119
- target(value: string | string[]): this;
119
+ target(value: string | string[] | false): this;
120
120
 
121
121
  watch(value: boolean): this;
122
122