@tramvai/cli 2.123.4 → 2.125.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 (58) hide show
  1. package/README.md +12 -0
  2. package/bin/spawn.js +5 -1
  3. package/lib/api/build/application.js +2 -1
  4. package/lib/api/build/application.js.map +1 -1
  5. package/lib/api/build/index.d.ts +1 -0
  6. package/lib/api/build/index.js.map +1 -1
  7. package/lib/builder/webpack/index.js +4 -2
  8. package/lib/builder/webpack/index.js.map +1 -1
  9. package/lib/builder/webpack/providers/build/client.js +0 -38
  10. package/lib/builder/webpack/providers/build/client.js.map +1 -1
  11. package/lib/builder/webpack/providers/build/clientShared.d.ts +2 -0
  12. package/lib/builder/webpack/providers/build/clientShared.js +51 -0
  13. package/lib/builder/webpack/providers/build/clientShared.js.map +1 -0
  14. package/lib/builder/webpack/tokens.d.ts +15 -3
  15. package/lib/cli/runCLI.js +4 -0
  16. package/lib/cli/runCLI.js.map +1 -1
  17. package/lib/commands/build/command.js +11 -0
  18. package/lib/commands/build/command.js.map +1 -1
  19. package/lib/di/tokens/config.d.ts +5 -1
  20. package/lib/library/babel/index.d.ts +1 -9
  21. package/lib/library/babel/index.js +1 -9
  22. package/lib/library/babel/index.js.map +1 -1
  23. package/lib/library/typescript/index.d.ts +0 -4
  24. package/lib/library/typescript/index.js +2 -2
  25. package/lib/library/typescript/index.js.map +1 -1
  26. package/lib/library/webpack/utils/files.d.ts +6 -1
  27. package/lib/library/webpack/utils/files.js +5 -2
  28. package/lib/library/webpack/utils/files.js.map +1 -1
  29. package/lib/library/webpack/utils/threadLoader.js +4 -2
  30. package/lib/library/webpack/utils/threadLoader.js.map +1 -1
  31. package/lib/library/webpack/utils/transpiler.d.ts +0 -1
  32. package/lib/library/webpack/utils/transpiler.js +7 -5
  33. package/lib/library/webpack/utils/transpiler.js.map +1 -1
  34. package/lib/schema/autogeneratedSchema.json +51 -18
  35. package/lib/typings/build/Builder.d.ts +1 -0
  36. package/lib/typings/configEntry/cli.d.ts +5 -1
  37. package/lib/utils/cpu-profile.d.ts +1 -0
  38. package/lib/utils/cpu-profile.js +35 -0
  39. package/lib/utils/cpu-profile.js.map +1 -0
  40. package/package.json +4 -5
  41. package/schema.json +51 -18
  42. package/src/api/build/application.ts +2 -1
  43. package/src/api/build/index.ts +1 -0
  44. package/src/builder/webpack/index.ts +4 -2
  45. package/src/builder/webpack/providers/build/client.ts +1 -41
  46. package/src/builder/webpack/providers/build/clientShared.ts +49 -0
  47. package/src/cli/runCLI.ts +5 -0
  48. package/src/commands/build/command.ts +11 -0
  49. package/src/library/babel/index.ts +0 -9
  50. package/src/library/typescript/index.ts +2 -2
  51. package/src/library/webpack/utils/files.ts +5 -2
  52. package/src/library/webpack/utils/threadLoader.ts +2 -0
  53. package/src/library/webpack/utils/transpiler.ts +7 -4
  54. package/src/models/config.spec.ts +2 -2
  55. package/src/schema/autogeneratedSchema.json +51 -18
  56. package/src/typings/build/Builder.ts +1 -0
  57. package/src/typings/configEntry/cli.ts +5 -1
  58. package/src/utils/cpu-profile.ts +36 -0
@@ -23,6 +23,8 @@ const createWorkerPoolConfig = (configManager: ConfigManager<CliConfigEntry>) =>
23
23
 
24
24
  const isApplicable = (configManager: ConfigManager<CliConfigEntry>) => {
25
25
  return (
26
+ // thread-loader uses child_process.fork underhood, and sometimes (50/50) work in these processes does not get into inspector.Session profile
27
+ !process.env.TRAMVAI_CPU_PROFILE &&
26
28
  // TODO: check that there is still issue with windows systems and thread-loader
27
29
  process.platform !== 'win32' &&
28
30
  // swc has inbuilt threads support, see https://swc.rs/blog/perf-swc-vs-babel#real-world-benchmark
@@ -2,7 +2,7 @@ import type Config from 'webpack-chain';
2
2
  import { sync as resolve } from 'resolve';
3
3
  import type { ConfigManager } from '../../../config/configManager';
4
4
  import { getSwcOptions } from '../../swc';
5
- import babelConfig from '../../babel';
5
+ import { babelConfigFactory } from '../../babel';
6
6
  import type { Env } from '../../../typings/Env';
7
7
  import type { Target } from '../../../typings/target';
8
8
  import type { CliConfigEntry } from '../../../typings/configEntry/cli';
@@ -18,7 +18,6 @@ export type TranspilerConfig = {
18
18
  modules: 'es6' | 'commonjs' | false;
19
19
  loader: boolean;
20
20
  removeTypeofWindow: boolean;
21
- alias: Record<string, any>;
22
21
  tramvai: boolean;
23
22
  hot: boolean;
24
23
  excludesPresetEnv: string[];
@@ -43,7 +42,7 @@ Please run "npx tramvai add --dev @tramvai/swc-integration" to fix the problem
43
42
  }
44
43
 
45
44
  if (loader === 'babel') {
46
- return rule.loader('babel-loader').options(babelConfig(transpilerConfig)).end();
45
+ return rule.loader('babel-loader').options(babelConfigFactory(transpilerConfig)).end();
47
46
  }
48
47
  };
49
48
 
@@ -54,12 +53,16 @@ export const getTranspilerConfig = (
54
53
  const { generateDataQaTag, alias, enableFillActionNamePlugin, excludesPresetEnv } = configManager;
55
54
  const { env, modern } = configManager;
56
55
 
56
+ if (alias) {
57
+ console.warn(`"alias" option deprecated and ignored as cli now supports baseUrl and paths from the app's tsconfig.json file.
58
+ Just check or add configuration to your tsconfig file and remove alias from tramvai.json`);
59
+ }
60
+
57
61
  return {
58
62
  isServer: configManager.buildType === 'server',
59
63
  env,
60
64
  generateDataQaTag,
61
65
  modern,
62
- alias,
63
66
  tramvai: true,
64
67
  removeTypeofWindow: true,
65
68
  hot: !!configManager.hotRefresh.enabled,
@@ -211,7 +211,7 @@ it('should populate defaults for overridable options', () => {
211
211
  svgo: {
212
212
  plugins: [
213
213
  {
214
- 'test-plugin': true,
214
+ name: 'test-plugin',
215
215
  },
216
216
  ],
217
217
  },
@@ -353,7 +353,7 @@ it('should populate defaults for overridable options', () => {
353
353
  "svgo": {
354
354
  "plugins": [
355
355
  {
356
- "test-plugin": true,
356
+ "name": "test-plugin",
357
357
  },
358
358
  ],
359
359
  },
@@ -1017,7 +1017,18 @@
1017
1017
  "plugins": {
1018
1018
  "title": "svgo plugins",
1019
1019
  "type": "array",
1020
- "items": {}
1020
+ "items": {
1021
+ "type": "object",
1022
+ "properties": {
1023
+ "name": {
1024
+ "type": "string"
1025
+ },
1026
+ "active": {
1027
+ "type": "boolean"
1028
+ }
1029
+ },
1030
+ "additionalProperties": false
1031
+ }
1021
1032
  }
1022
1033
  },
1023
1034
  "additionalProperties": false
@@ -1122,23 +1133,23 @@
1122
1133
  "dotAll": {
1123
1134
  "type": "boolean"
1124
1135
  },
1125
- "__@match@8195": {
1136
+ "__@match@8199": {
1126
1137
  "type": "object",
1127
1138
  "additionalProperties": false
1128
1139
  },
1129
- "__@replace@8197": {
1140
+ "__@replace@8201": {
1130
1141
  "type": "object",
1131
1142
  "additionalProperties": false
1132
1143
  },
1133
- "__@search@8200": {
1144
+ "__@search@8204": {
1134
1145
  "type": "object",
1135
1146
  "additionalProperties": false
1136
1147
  },
1137
- "__@split@8202": {
1148
+ "__@split@8206": {
1138
1149
  "type": "object",
1139
1150
  "additionalProperties": false
1140
1151
  },
1141
- "__@matchAll@8204": {
1152
+ "__@matchAll@8208": {
1142
1153
  "type": "object",
1143
1154
  "additionalProperties": false
1144
1155
  }
@@ -1659,7 +1670,18 @@
1659
1670
  "plugins": {
1660
1671
  "title": "svgo plugins",
1661
1672
  "type": "array",
1662
- "items": {}
1673
+ "items": {
1674
+ "type": "object",
1675
+ "properties": {
1676
+ "name": {
1677
+ "type": "string"
1678
+ },
1679
+ "active": {
1680
+ "type": "boolean"
1681
+ }
1682
+ },
1683
+ "additionalProperties": false
1684
+ }
1663
1685
  }
1664
1686
  },
1665
1687
  "additionalProperties": false
@@ -1764,23 +1786,23 @@
1764
1786
  "dotAll": {
1765
1787
  "type": "boolean"
1766
1788
  },
1767
- "__@match@8195": {
1789
+ "__@match@8199": {
1768
1790
  "type": "object",
1769
1791
  "additionalProperties": false
1770
1792
  },
1771
- "__@replace@8197": {
1793
+ "__@replace@8201": {
1772
1794
  "type": "object",
1773
1795
  "additionalProperties": false
1774
1796
  },
1775
- "__@search@8200": {
1797
+ "__@search@8204": {
1776
1798
  "type": "object",
1777
1799
  "additionalProperties": false
1778
1800
  },
1779
- "__@split@8202": {
1801
+ "__@split@8206": {
1780
1802
  "type": "object",
1781
1803
  "additionalProperties": false
1782
1804
  },
1783
- "__@matchAll@8204": {
1805
+ "__@matchAll@8208": {
1784
1806
  "type": "object",
1785
1807
  "additionalProperties": false
1786
1808
  }
@@ -2301,7 +2323,18 @@
2301
2323
  "plugins": {
2302
2324
  "title": "svgo plugins",
2303
2325
  "type": "array",
2304
- "items": {}
2326
+ "items": {
2327
+ "type": "object",
2328
+ "properties": {
2329
+ "name": {
2330
+ "type": "string"
2331
+ },
2332
+ "active": {
2333
+ "type": "boolean"
2334
+ }
2335
+ },
2336
+ "additionalProperties": false
2337
+ }
2305
2338
  }
2306
2339
  },
2307
2340
  "additionalProperties": false
@@ -2406,23 +2439,23 @@
2406
2439
  "dotAll": {
2407
2440
  "type": "boolean"
2408
2441
  },
2409
- "__@match@8195": {
2442
+ "__@match@8199": {
2410
2443
  "type": "object",
2411
2444
  "additionalProperties": false
2412
2445
  },
2413
- "__@replace@8197": {
2446
+ "__@replace@8201": {
2414
2447
  "type": "object",
2415
2448
  "additionalProperties": false
2416
2449
  },
2417
- "__@search@8200": {
2450
+ "__@search@8204": {
2418
2451
  "type": "object",
2419
2452
  "additionalProperties": false
2420
2453
  },
2421
- "__@split@8202": {
2454
+ "__@split@8206": {
2422
2455
  "type": "object",
2423
2456
  "additionalProperties": false
2424
2457
  },
2425
- "__@matchAll@8204": {
2458
+ "__@matchAll@8208": {
2426
2459
  "type": "object",
2427
2460
  "additionalProperties": false
2428
2461
  }
@@ -4,6 +4,7 @@ export interface BuilderCustomOptions {
4
4
 
5
5
  export interface BuilderOptions {
6
6
  shouldBuildClient: boolean;
7
+ onlyModern?: boolean;
7
8
  shouldBuildServer: boolean;
8
9
  }
9
10
 
@@ -163,7 +163,11 @@ export interface CliConfigEntry extends ConfigEntry {
163
163
  /**
164
164
  * @title svgo plugins
165
165
  */
166
- plugins?: Array<any>;
166
+ plugins?: Array<{
167
+ name: string;
168
+ active: boolean;
169
+ [key: string]: any;
170
+ }>;
167
171
  };
168
172
 
169
173
  /**
@@ -0,0 +1,36 @@
1
+ import { Session } from 'inspector';
2
+ import fs from 'fs';
3
+
4
+ // reference - https://github.com/vercel/next.js/blob/canary/packages/next/src/server/lib/cpu-profile.ts
5
+ export function enableCpuProfile(key: string) {
6
+ const session = new Session();
7
+ let saved = false;
8
+
9
+ session.connect();
10
+
11
+ session.post('Profiler.enable');
12
+ session.post('Profiler.start');
13
+
14
+ function saveProfile() {
15
+ if (saved) {
16
+ return;
17
+ }
18
+ saved = true;
19
+
20
+ session.post('Profiler.stop', (error, param) => {
21
+ if (error) {
22
+ console.error('Cannot generate CPU profiling:', error);
23
+ return;
24
+ }
25
+
26
+ // Write profile to disk
27
+ const filename = `${key}.${Date.now()}.cpuprofile`;
28
+ fs.writeFileSync(`./${filename}`, JSON.stringify(param.profile));
29
+ process.exit(0);
30
+ });
31
+ }
32
+
33
+ process.on('SIGINT', saveProfile);
34
+ process.on('SIGTERM', saveProfile);
35
+ process.on('exit', saveProfile);
36
+ }