@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.
- package/README.md +12 -0
- package/bin/spawn.js +5 -1
- package/lib/api/build/application.js +2 -1
- package/lib/api/build/application.js.map +1 -1
- package/lib/api/build/index.d.ts +1 -0
- package/lib/api/build/index.js.map +1 -1
- package/lib/builder/webpack/index.js +4 -2
- package/lib/builder/webpack/index.js.map +1 -1
- package/lib/builder/webpack/providers/build/client.js +0 -38
- package/lib/builder/webpack/providers/build/client.js.map +1 -1
- package/lib/builder/webpack/providers/build/clientShared.d.ts +2 -0
- package/lib/builder/webpack/providers/build/clientShared.js +51 -0
- package/lib/builder/webpack/providers/build/clientShared.js.map +1 -0
- package/lib/builder/webpack/tokens.d.ts +15 -3
- package/lib/cli/runCLI.js +4 -0
- package/lib/cli/runCLI.js.map +1 -1
- package/lib/commands/build/command.js +11 -0
- package/lib/commands/build/command.js.map +1 -1
- package/lib/di/tokens/config.d.ts +5 -1
- package/lib/library/babel/index.d.ts +1 -9
- package/lib/library/babel/index.js +1 -9
- package/lib/library/babel/index.js.map +1 -1
- package/lib/library/typescript/index.d.ts +0 -4
- package/lib/library/typescript/index.js +2 -2
- package/lib/library/typescript/index.js.map +1 -1
- package/lib/library/webpack/utils/files.d.ts +6 -1
- package/lib/library/webpack/utils/files.js +5 -2
- package/lib/library/webpack/utils/files.js.map +1 -1
- package/lib/library/webpack/utils/threadLoader.js +4 -2
- package/lib/library/webpack/utils/threadLoader.js.map +1 -1
- package/lib/library/webpack/utils/transpiler.d.ts +0 -1
- package/lib/library/webpack/utils/transpiler.js +7 -5
- package/lib/library/webpack/utils/transpiler.js.map +1 -1
- package/lib/schema/autogeneratedSchema.json +51 -18
- package/lib/typings/build/Builder.d.ts +1 -0
- package/lib/typings/configEntry/cli.d.ts +5 -1
- package/lib/utils/cpu-profile.d.ts +1 -0
- package/lib/utils/cpu-profile.js +35 -0
- package/lib/utils/cpu-profile.js.map +1 -0
- package/package.json +4 -5
- package/schema.json +51 -18
- package/src/api/build/application.ts +2 -1
- package/src/api/build/index.ts +1 -0
- package/src/builder/webpack/index.ts +4 -2
- package/src/builder/webpack/providers/build/client.ts +1 -41
- package/src/builder/webpack/providers/build/clientShared.ts +49 -0
- package/src/cli/runCLI.ts +5 -0
- package/src/commands/build/command.ts +11 -0
- package/src/library/babel/index.ts +0 -9
- package/src/library/typescript/index.ts +2 -2
- package/src/library/webpack/utils/files.ts +5 -2
- package/src/library/webpack/utils/threadLoader.ts +2 -0
- package/src/library/webpack/utils/transpiler.ts +7 -4
- package/src/models/config.spec.ts +2 -2
- package/src/schema/autogeneratedSchema.json +51 -18
- package/src/typings/build/Builder.ts +1 -0
- package/src/typings/configEntry/cli.ts +5 -1
- package/src/utils/cpu-profile.ts +36 -0
|
@@ -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@
|
|
1136
|
+
"__@match@8199": {
|
|
1126
1137
|
"type": "object",
|
|
1127
1138
|
"additionalProperties": false
|
|
1128
1139
|
},
|
|
1129
|
-
"__@replace@
|
|
1140
|
+
"__@replace@8201": {
|
|
1130
1141
|
"type": "object",
|
|
1131
1142
|
"additionalProperties": false
|
|
1132
1143
|
},
|
|
1133
|
-
"__@search@
|
|
1144
|
+
"__@search@8204": {
|
|
1134
1145
|
"type": "object",
|
|
1135
1146
|
"additionalProperties": false
|
|
1136
1147
|
},
|
|
1137
|
-
"__@split@
|
|
1148
|
+
"__@split@8206": {
|
|
1138
1149
|
"type": "object",
|
|
1139
1150
|
"additionalProperties": false
|
|
1140
1151
|
},
|
|
1141
|
-
"__@matchAll@
|
|
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@
|
|
1789
|
+
"__@match@8199": {
|
|
1768
1790
|
"type": "object",
|
|
1769
1791
|
"additionalProperties": false
|
|
1770
1792
|
},
|
|
1771
|
-
"__@replace@
|
|
1793
|
+
"__@replace@8201": {
|
|
1772
1794
|
"type": "object",
|
|
1773
1795
|
"additionalProperties": false
|
|
1774
1796
|
},
|
|
1775
|
-
"__@search@
|
|
1797
|
+
"__@search@8204": {
|
|
1776
1798
|
"type": "object",
|
|
1777
1799
|
"additionalProperties": false
|
|
1778
1800
|
},
|
|
1779
|
-
"__@split@
|
|
1801
|
+
"__@split@8206": {
|
|
1780
1802
|
"type": "object",
|
|
1781
1803
|
"additionalProperties": false
|
|
1782
1804
|
},
|
|
1783
|
-
"__@matchAll@
|
|
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@
|
|
2442
|
+
"__@match@8199": {
|
|
2410
2443
|
"type": "object",
|
|
2411
2444
|
"additionalProperties": false
|
|
2412
2445
|
},
|
|
2413
|
-
"__@replace@
|
|
2446
|
+
"__@replace@8201": {
|
|
2414
2447
|
"type": "object",
|
|
2415
2448
|
"additionalProperties": false
|
|
2416
2449
|
},
|
|
2417
|
-
"__@search@
|
|
2450
|
+
"__@search@8204": {
|
|
2418
2451
|
"type": "object",
|
|
2419
2452
|
"additionalProperties": false
|
|
2420
2453
|
},
|
|
2421
|
-
"__@split@
|
|
2454
|
+
"__@split@8206": {
|
|
2422
2455
|
"type": "object",
|
|
2423
2456
|
"additionalProperties": false
|
|
2424
2457
|
},
|
|
2425
|
-
"__@matchAll@
|
|
2458
|
+
"__@matchAll@8208": {
|
|
2426
2459
|
"type": "object",
|
|
2427
2460
|
"additionalProperties": false
|
|
2428
2461
|
}
|
|
@@ -151,7 +151,11 @@ export interface CliConfigEntry extends ConfigEntry {
|
|
|
151
151
|
/**
|
|
152
152
|
* @title svgo plugins
|
|
153
153
|
*/
|
|
154
|
-
plugins?: Array<
|
|
154
|
+
plugins?: Array<{
|
|
155
|
+
name: string;
|
|
156
|
+
active: boolean;
|
|
157
|
+
[key: string]: any;
|
|
158
|
+
}>;
|
|
155
159
|
};
|
|
156
160
|
/**
|
|
157
161
|
* @title Settings for image-webpack-loader
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function enableCpuProfile(key: string): void;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.enableCpuProfile = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const inspector_1 = require("inspector");
|
|
6
|
+
const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
7
|
+
// reference - https://github.com/vercel/next.js/blob/canary/packages/next/src/server/lib/cpu-profile.ts
|
|
8
|
+
function enableCpuProfile(key) {
|
|
9
|
+
const session = new inspector_1.Session();
|
|
10
|
+
let saved = false;
|
|
11
|
+
session.connect();
|
|
12
|
+
session.post('Profiler.enable');
|
|
13
|
+
session.post('Profiler.start');
|
|
14
|
+
function saveProfile() {
|
|
15
|
+
if (saved) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
saved = true;
|
|
19
|
+
session.post('Profiler.stop', (error, param) => {
|
|
20
|
+
if (error) {
|
|
21
|
+
console.error('Cannot generate CPU profiling:', error);
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
// Write profile to disk
|
|
25
|
+
const filename = `${key}.${Date.now()}.cpuprofile`;
|
|
26
|
+
fs_1.default.writeFileSync(`./${filename}`, JSON.stringify(param.profile));
|
|
27
|
+
process.exit(0);
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
process.on('SIGINT', saveProfile);
|
|
31
|
+
process.on('SIGTERM', saveProfile);
|
|
32
|
+
process.on('exit', saveProfile);
|
|
33
|
+
}
|
|
34
|
+
exports.enableCpuProfile = enableCpuProfile;
|
|
35
|
+
//# sourceMappingURL=cpu-profile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cpu-profile.js","sourceRoot":"","sources":["../../src/utils/cpu-profile.ts"],"names":[],"mappings":";;;;AAAA,yCAAoC;AACpC,oDAAoB;AAEpB,wGAAwG;AACxG,SAAgB,gBAAgB,CAAC,GAAW;IAC1C,MAAM,OAAO,GAAG,IAAI,mBAAO,EAAE,CAAC;IAC9B,IAAI,KAAK,GAAG,KAAK,CAAC;IAElB,OAAO,CAAC,OAAO,EAAE,CAAC;IAElB,OAAO,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;IAChC,OAAO,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;IAE/B,SAAS,WAAW;QAClB,IAAI,KAAK,EAAE;YACT,OAAO;SACR;QACD,KAAK,GAAG,IAAI,CAAC;QAEb,OAAO,CAAC,IAAI,CAAC,eAAe,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;YAC7C,IAAI,KAAK,EAAE;gBACT,OAAO,CAAC,KAAK,CAAC,gCAAgC,EAAE,KAAK,CAAC,CAAC;gBACvD,OAAO;aACR;YAED,wBAAwB;YACxB,MAAM,QAAQ,GAAG,GAAG,GAAG,IAAI,IAAI,CAAC,GAAG,EAAE,aAAa,CAAC;YACnD,YAAE,CAAC,aAAa,CAAC,KAAK,QAAQ,EAAE,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;YACjE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC,CAAC,CAAC;IACL,CAAC;IAED,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;IAClC,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;IACnC,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;AAClC,CAAC;AA/BD,4CA+BC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tramvai/cli",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.125.0",
|
|
4
4
|
"description": "Cli инструмент для сборки и запуска приложений",
|
|
5
5
|
"files": [
|
|
6
6
|
"src",
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
"@tinkoff/utils": "^2.1.3",
|
|
72
72
|
"@tinkoff/webpack-dedupe-plugin": "1.0.5",
|
|
73
73
|
"@tramvai/build": "3.1.3",
|
|
74
|
-
"@tramvai/react": "2.
|
|
74
|
+
"@tramvai/react": "2.125.0",
|
|
75
75
|
"@tramvai/tools-check-versions": "0.4.15",
|
|
76
76
|
"@tramvai/tools-migrate": "0.6.19",
|
|
77
77
|
"ajv": "^6.12.6",
|
|
@@ -80,7 +80,6 @@
|
|
|
80
80
|
"babel-loader": "^8.2.5",
|
|
81
81
|
"babel-plugin-dynamic-import-node": "^2.3.3",
|
|
82
82
|
"babel-plugin-lodash": "^3.3.4",
|
|
83
|
-
"babel-plugin-module-resolver": "^4.1.0",
|
|
84
83
|
"babel-plugin-transform-define": "^2.0.1",
|
|
85
84
|
"babel-plugin-transform-react-remove-prop-types": "^0.4.24",
|
|
86
85
|
"boxen": "^4.2.0",
|
|
@@ -147,8 +146,8 @@
|
|
|
147
146
|
"source-map-loader": "^4.0.0",
|
|
148
147
|
"spark-md5": "^3.0.2",
|
|
149
148
|
"stoppable": "^1.1.0",
|
|
150
|
-
"svgo": "^
|
|
151
|
-
"svgo-loader": "^
|
|
149
|
+
"svgo": "^3.0.2",
|
|
150
|
+
"svgo-loader": "^4.0.0",
|
|
152
151
|
"terser-webpack-plugin": "^5.3.9",
|
|
153
152
|
"text-table": "^0.2.0",
|
|
154
153
|
"thread-loader": "^3.0.4",
|
package/schema.json
CHANGED
|
@@ -1038,7 +1038,18 @@
|
|
|
1038
1038
|
"plugins": {
|
|
1039
1039
|
"title": "svgo plugins",
|
|
1040
1040
|
"type": "array",
|
|
1041
|
-
"items": {
|
|
1041
|
+
"items": {
|
|
1042
|
+
"type": "object",
|
|
1043
|
+
"properties": {
|
|
1044
|
+
"name": {
|
|
1045
|
+
"type": "string"
|
|
1046
|
+
},
|
|
1047
|
+
"active": {
|
|
1048
|
+
"type": "boolean"
|
|
1049
|
+
}
|
|
1050
|
+
},
|
|
1051
|
+
"additionalProperties": false
|
|
1052
|
+
}
|
|
1042
1053
|
}
|
|
1043
1054
|
},
|
|
1044
1055
|
"additionalProperties": false
|
|
@@ -1143,23 +1154,23 @@
|
|
|
1143
1154
|
"dotAll": {
|
|
1144
1155
|
"type": "boolean"
|
|
1145
1156
|
},
|
|
1146
|
-
"__@match@
|
|
1157
|
+
"__@match@8199": {
|
|
1147
1158
|
"type": "object",
|
|
1148
1159
|
"additionalProperties": false
|
|
1149
1160
|
},
|
|
1150
|
-
"__@replace@
|
|
1161
|
+
"__@replace@8201": {
|
|
1151
1162
|
"type": "object",
|
|
1152
1163
|
"additionalProperties": false
|
|
1153
1164
|
},
|
|
1154
|
-
"__@search@
|
|
1165
|
+
"__@search@8204": {
|
|
1155
1166
|
"type": "object",
|
|
1156
1167
|
"additionalProperties": false
|
|
1157
1168
|
},
|
|
1158
|
-
"__@split@
|
|
1169
|
+
"__@split@8206": {
|
|
1159
1170
|
"type": "object",
|
|
1160
1171
|
"additionalProperties": false
|
|
1161
1172
|
},
|
|
1162
|
-
"__@matchAll@
|
|
1173
|
+
"__@matchAll@8208": {
|
|
1163
1174
|
"type": "object",
|
|
1164
1175
|
"additionalProperties": false
|
|
1165
1176
|
}
|
|
@@ -1688,7 +1699,18 @@
|
|
|
1688
1699
|
"plugins": {
|
|
1689
1700
|
"title": "svgo plugins",
|
|
1690
1701
|
"type": "array",
|
|
1691
|
-
"items": {
|
|
1702
|
+
"items": {
|
|
1703
|
+
"type": "object",
|
|
1704
|
+
"properties": {
|
|
1705
|
+
"name": {
|
|
1706
|
+
"type": "string"
|
|
1707
|
+
},
|
|
1708
|
+
"active": {
|
|
1709
|
+
"type": "boolean"
|
|
1710
|
+
}
|
|
1711
|
+
},
|
|
1712
|
+
"additionalProperties": false
|
|
1713
|
+
}
|
|
1692
1714
|
}
|
|
1693
1715
|
},
|
|
1694
1716
|
"additionalProperties": false
|
|
@@ -1793,23 +1815,23 @@
|
|
|
1793
1815
|
"dotAll": {
|
|
1794
1816
|
"type": "boolean"
|
|
1795
1817
|
},
|
|
1796
|
-
"__@match@
|
|
1818
|
+
"__@match@8199": {
|
|
1797
1819
|
"type": "object",
|
|
1798
1820
|
"additionalProperties": false
|
|
1799
1821
|
},
|
|
1800
|
-
"__@replace@
|
|
1822
|
+
"__@replace@8201": {
|
|
1801
1823
|
"type": "object",
|
|
1802
1824
|
"additionalProperties": false
|
|
1803
1825
|
},
|
|
1804
|
-
"__@search@
|
|
1826
|
+
"__@search@8204": {
|
|
1805
1827
|
"type": "object",
|
|
1806
1828
|
"additionalProperties": false
|
|
1807
1829
|
},
|
|
1808
|
-
"__@split@
|
|
1830
|
+
"__@split@8206": {
|
|
1809
1831
|
"type": "object",
|
|
1810
1832
|
"additionalProperties": false
|
|
1811
1833
|
},
|
|
1812
|
-
"__@matchAll@
|
|
1834
|
+
"__@matchAll@8208": {
|
|
1813
1835
|
"type": "object",
|
|
1814
1836
|
"additionalProperties": false
|
|
1815
1837
|
}
|
|
@@ -2338,7 +2360,18 @@
|
|
|
2338
2360
|
"plugins": {
|
|
2339
2361
|
"title": "svgo plugins",
|
|
2340
2362
|
"type": "array",
|
|
2341
|
-
"items": {
|
|
2363
|
+
"items": {
|
|
2364
|
+
"type": "object",
|
|
2365
|
+
"properties": {
|
|
2366
|
+
"name": {
|
|
2367
|
+
"type": "string"
|
|
2368
|
+
},
|
|
2369
|
+
"active": {
|
|
2370
|
+
"type": "boolean"
|
|
2371
|
+
}
|
|
2372
|
+
},
|
|
2373
|
+
"additionalProperties": false
|
|
2374
|
+
}
|
|
2342
2375
|
}
|
|
2343
2376
|
},
|
|
2344
2377
|
"additionalProperties": false
|
|
@@ -2443,23 +2476,23 @@
|
|
|
2443
2476
|
"dotAll": {
|
|
2444
2477
|
"type": "boolean"
|
|
2445
2478
|
},
|
|
2446
|
-
"__@match@
|
|
2479
|
+
"__@match@8199": {
|
|
2447
2480
|
"type": "object",
|
|
2448
2481
|
"additionalProperties": false
|
|
2449
2482
|
},
|
|
2450
|
-
"__@replace@
|
|
2483
|
+
"__@replace@8201": {
|
|
2451
2484
|
"type": "object",
|
|
2452
2485
|
"additionalProperties": false
|
|
2453
2486
|
},
|
|
2454
|
-
"__@search@
|
|
2487
|
+
"__@search@8204": {
|
|
2455
2488
|
"type": "object",
|
|
2456
2489
|
"additionalProperties": false
|
|
2457
2490
|
},
|
|
2458
|
-
"__@split@
|
|
2491
|
+
"__@split@8206": {
|
|
2459
2492
|
"type": "object",
|
|
2460
2493
|
"additionalProperties": false
|
|
2461
2494
|
},
|
|
2462
|
-
"__@matchAll@
|
|
2495
|
+
"__@matchAll@8208": {
|
|
2463
2496
|
"type": "object",
|
|
2464
2497
|
"additionalProperties": false
|
|
2465
2498
|
}
|
|
@@ -10,7 +10,7 @@ import { registerProviders } from '../../utils/di';
|
|
|
10
10
|
|
|
11
11
|
export const buildApplication = async (di: Container): Result => {
|
|
12
12
|
const options = di.get(COMMAND_PARAMETERS_TOKEN as Params);
|
|
13
|
-
const { buildType = 'all' } = options;
|
|
13
|
+
const { buildType = 'all', onlyModern } = options;
|
|
14
14
|
|
|
15
15
|
const shouldBuildClient = buildType === 'client' || buildType === 'all';
|
|
16
16
|
const shouldBuildServer = buildType === 'server' || buildType === 'all';
|
|
@@ -24,6 +24,7 @@ export const buildApplication = async (di: Container): Result => {
|
|
|
24
24
|
options: {
|
|
25
25
|
shouldBuildClient,
|
|
26
26
|
shouldBuildServer,
|
|
27
|
+
onlyModern,
|
|
27
28
|
},
|
|
28
29
|
});
|
|
29
30
|
|
package/src/api/build/index.ts
CHANGED
|
@@ -22,6 +22,7 @@ import {
|
|
|
22
22
|
} from './tokens';
|
|
23
23
|
import { resolveDone } from './utils/resolveDone';
|
|
24
24
|
import { registerProviders } from '../../utils/di';
|
|
25
|
+
import { buildClientSharedProviders } from './providers/build/clientShared';
|
|
25
26
|
import { buildClientProviders } from './providers/build/client';
|
|
26
27
|
import { buildClientModernProviders } from './providers/build/clientModern';
|
|
27
28
|
import { buildServerProviders } from './providers/build/server';
|
|
@@ -37,7 +38,7 @@ export const webpackProviders: Provider[] = [
|
|
|
37
38
|
useFactory: ({ di }) => {
|
|
38
39
|
return {
|
|
39
40
|
name: BUILDER_NAME,
|
|
40
|
-
createBuilder({ options: { shouldBuildClient, shouldBuildServer } }) {
|
|
41
|
+
createBuilder({ options: { shouldBuildClient, shouldBuildServer, onlyModern } }) {
|
|
41
42
|
registerProviders(di, [
|
|
42
43
|
...sharedProviders,
|
|
43
44
|
...(shouldBuildClient ? clientProviders : []),
|
|
@@ -84,7 +85,8 @@ export const webpackProviders: Provider[] = [
|
|
|
84
85
|
},
|
|
85
86
|
async build({ modern }) {
|
|
86
87
|
registerProviders(di, [
|
|
87
|
-
...(shouldBuildClient ?
|
|
88
|
+
...(shouldBuildClient ? buildClientSharedProviders : []),
|
|
89
|
+
...(shouldBuildClient && !onlyModern ? buildClientProviders : []),
|
|
88
90
|
...(shouldBuildClient && modern ? buildClientModernProviders : []),
|
|
89
91
|
...(shouldBuildServer ? buildServerProviders : []),
|
|
90
92
|
]);
|
|
@@ -1,18 +1,11 @@
|
|
|
1
1
|
import type { Provider } from '@tinkoff/dippy';
|
|
2
2
|
import { provide } from '@tinkoff/dippy';
|
|
3
|
-
import rimraf from 'rimraf';
|
|
4
3
|
import webpack from 'webpack';
|
|
5
|
-
import {
|
|
6
|
-
CLI_PACKAGE_MANAGER,
|
|
7
|
-
CLI_ROOT_DIR_TOKEN,
|
|
8
|
-
CONFIG_MANAGER_TOKEN,
|
|
9
|
-
} from '../../../../di/tokens';
|
|
4
|
+
import { CONFIG_MANAGER_TOKEN } from '../../../../di/tokens';
|
|
10
5
|
import { toWebpackConfig } from '../../../../library/webpack/utils/toWebpackConfig';
|
|
11
|
-
import { npmRequire } from '../../../../utils/npmRequire';
|
|
12
6
|
import {
|
|
13
7
|
CLIENT_CONFIG_MANAGER_TOKEN,
|
|
14
8
|
CLOSE_HANDLER_TOKEN,
|
|
15
|
-
INIT_HANDLER_TOKEN,
|
|
16
9
|
PROCESS_HANDLER_TOKEN,
|
|
17
10
|
WEBPACK_CLIENT_COMPILER_TOKEN,
|
|
18
11
|
WEBPACK_CLIENT_CONFIG_TOKEN,
|
|
@@ -42,39 +35,6 @@ export const buildClientProviders: Provider[] = [
|
|
|
42
35
|
webpackConfig: WEBPACK_CLIENT_CONFIG_TOKEN,
|
|
43
36
|
},
|
|
44
37
|
}),
|
|
45
|
-
provide({
|
|
46
|
-
provide: INIT_HANDLER_TOKEN,
|
|
47
|
-
multi: true,
|
|
48
|
-
useFactory: ({ configManager }) => {
|
|
49
|
-
return function clearBuildDir() {
|
|
50
|
-
return rimraf.sync(`${configManager.buildPath}/**`, {});
|
|
51
|
-
};
|
|
52
|
-
},
|
|
53
|
-
deps: {
|
|
54
|
-
configManager: CLIENT_CONFIG_MANAGER_TOKEN,
|
|
55
|
-
},
|
|
56
|
-
}),
|
|
57
|
-
provide({
|
|
58
|
-
provide: INIT_HANDLER_TOKEN,
|
|
59
|
-
multi: true,
|
|
60
|
-
useFactory: ({ configManager, rootDir, packageManager }) => {
|
|
61
|
-
return async function prepareImageOptimization() {
|
|
62
|
-
if (configManager.imageOptimization?.enabled) {
|
|
63
|
-
await npmRequire({
|
|
64
|
-
cliRootDir: rootDir,
|
|
65
|
-
packageManager,
|
|
66
|
-
packageName: 'image-webpack-loader',
|
|
67
|
-
description: 'Устанавливаем зависимости для опции imageOptimization',
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
},
|
|
72
|
-
deps: {
|
|
73
|
-
configManager: CLIENT_CONFIG_MANAGER_TOKEN,
|
|
74
|
-
rootDir: CLI_ROOT_DIR_TOKEN,
|
|
75
|
-
packageManager: CLI_PACKAGE_MANAGER,
|
|
76
|
-
},
|
|
77
|
-
}),
|
|
78
38
|
provide({
|
|
79
39
|
provide: PROCESS_HANDLER_TOKEN,
|
|
80
40
|
multi: true,
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { Provider } from '@tinkoff/dippy';
|
|
2
|
+
import { optional } from '@tinkoff/dippy';
|
|
3
|
+
import { provide } from '@tinkoff/dippy';
|
|
4
|
+
import rimraf from 'rimraf';
|
|
5
|
+
import { CLI_PACKAGE_MANAGER, CLI_ROOT_DIR_TOKEN } from '../../../../di/tokens';
|
|
6
|
+
import { npmRequire } from '../../../../utils/npmRequire';
|
|
7
|
+
import {
|
|
8
|
+
CLIENT_CONFIG_MANAGER_TOKEN,
|
|
9
|
+
CLIENT_MODERN_CONFIG_MANAGER_TOKEN,
|
|
10
|
+
INIT_HANDLER_TOKEN,
|
|
11
|
+
} from '../../tokens';
|
|
12
|
+
|
|
13
|
+
export const buildClientSharedProviders: Provider[] = [
|
|
14
|
+
provide({
|
|
15
|
+
provide: INIT_HANDLER_TOKEN,
|
|
16
|
+
multi: true,
|
|
17
|
+
useFactory: ({ configManager, modernConfigManager }) => {
|
|
18
|
+
return function clearBuildDir() {
|
|
19
|
+
return rimraf.sync(`${(configManager || modernConfigManager).buildPath}/**`, {});
|
|
20
|
+
};
|
|
21
|
+
},
|
|
22
|
+
deps: {
|
|
23
|
+
configManager: optional(CLIENT_CONFIG_MANAGER_TOKEN),
|
|
24
|
+
modernConfigManager: optional(CLIENT_MODERN_CONFIG_MANAGER_TOKEN),
|
|
25
|
+
},
|
|
26
|
+
}),
|
|
27
|
+
provide({
|
|
28
|
+
provide: INIT_HANDLER_TOKEN,
|
|
29
|
+
multi: true,
|
|
30
|
+
useFactory: ({ configManager, modernConfigManager, rootDir, packageManager }) => {
|
|
31
|
+
return async function prepareImageOptimization() {
|
|
32
|
+
if ((configManager || modernConfigManager).imageOptimization?.enabled) {
|
|
33
|
+
await npmRequire({
|
|
34
|
+
cliRootDir: rootDir,
|
|
35
|
+
packageManager,
|
|
36
|
+
packageName: 'image-webpack-loader',
|
|
37
|
+
description: 'Устанавливаем зависимости для опции imageOptimization',
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
},
|
|
42
|
+
deps: {
|
|
43
|
+
configManager: optional(CLIENT_CONFIG_MANAGER_TOKEN),
|
|
44
|
+
modernConfigManager: optional(CLIENT_MODERN_CONFIG_MANAGER_TOKEN),
|
|
45
|
+
rootDir: CLI_ROOT_DIR_TOKEN,
|
|
46
|
+
packageManager: CLI_PACKAGE_MANAGER,
|
|
47
|
+
},
|
|
48
|
+
}),
|
|
49
|
+
];
|
package/src/cli/runCLI.ts
CHANGED
|
@@ -2,6 +2,7 @@ import exit from 'exit';
|
|
|
2
2
|
|
|
3
3
|
import { fixYarnSettingsOverride } from '../utils/fixYarnSettingsOverride';
|
|
4
4
|
import { handleErrors } from '../utils/handleErrors';
|
|
5
|
+
import { enableCpuProfile } from '../utils/cpu-profile';
|
|
5
6
|
|
|
6
7
|
// to use V8's code cache to speed up instantiation time
|
|
7
8
|
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
|
@@ -10,6 +11,10 @@ import('v8-compile-cache');
|
|
|
10
11
|
handleErrors();
|
|
11
12
|
fixYarnSettingsOverride();
|
|
12
13
|
|
|
14
|
+
if (process.env.TRAMVAI_CPU_PROFILE) {
|
|
15
|
+
enableCpuProfile('tramvai-cli');
|
|
16
|
+
}
|
|
17
|
+
|
|
13
18
|
export default (pathCli: string) => {
|
|
14
19
|
const cli = require(pathCli).cliInitialized;
|
|
15
20
|
|
|
@@ -57,6 +57,17 @@ class BuildCommand extends CLICommand<Params> {
|
|
|
57
57
|
transformer: (value: string) => value !== 'false',
|
|
58
58
|
description: 'Enable/disable persistent file cache for used cli builder',
|
|
59
59
|
},
|
|
60
|
+
{
|
|
61
|
+
name: '--modern',
|
|
62
|
+
value: '[modern]',
|
|
63
|
+
description: 'modern compilation code with es2015+',
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
name: '--onlyModern',
|
|
67
|
+
value: '[onlyModern]',
|
|
68
|
+
transformer: (value: string) => value !== 'false',
|
|
69
|
+
description: 'Emit only modern build from client compilation',
|
|
70
|
+
},
|
|
60
71
|
];
|
|
61
72
|
|
|
62
73
|
alias = 'b';
|
|
@@ -42,7 +42,6 @@ export const babelConfigFactory = ({
|
|
|
42
42
|
typescript = false,
|
|
43
43
|
loader = true,
|
|
44
44
|
removeTypeofWindow,
|
|
45
|
-
alias,
|
|
46
45
|
tramvai = false,
|
|
47
46
|
hot = false,
|
|
48
47
|
excludesPresetEnv,
|
|
@@ -125,14 +124,6 @@ export const babelConfigFactory = ({
|
|
|
125
124
|
enableFillActionNamePlugin && path.resolve(__dirname, './plugins/fill-action-name'), // Собственный плагин. Необходимо удалить в будущем
|
|
126
125
|
markCreateTokenAsPure && path.resolve(__dirname, './plugins/create-token-pure'),
|
|
127
126
|
['lodash', { id: ['ramda'] }],
|
|
128
|
-
[
|
|
129
|
-
'module-resolver',
|
|
130
|
-
{
|
|
131
|
-
root: ['./'],
|
|
132
|
-
extensions: ['.js', '.jsx', '.ts', '.tsx'],
|
|
133
|
-
alias,
|
|
134
|
-
},
|
|
135
|
-
],
|
|
136
127
|
isServer && 'babel-plugin-dynamic-import-node',
|
|
137
128
|
[
|
|
138
129
|
'@babel/plugin-proposal-decorators',
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import path from 'path';
|
|
2
2
|
import omit from '@tinkoff/utils/object/omit';
|
|
3
3
|
import type { Env } from '../../typings/Env';
|
|
4
|
-
import
|
|
4
|
+
import { babelConfigFactory } from '../babel';
|
|
5
5
|
|
|
6
6
|
const rootDir = process.cwd();
|
|
7
7
|
|
|
@@ -24,7 +24,7 @@ export default (options: Options) => {
|
|
|
24
24
|
// для лоадера конфиг отличается от plain babel config, нужно преобразовывать
|
|
25
25
|
babelOptions: omit(
|
|
26
26
|
['cacheDirectory', 'cacheIdentifier'],
|
|
27
|
-
|
|
27
|
+
babelConfigFactory({
|
|
28
28
|
env,
|
|
29
29
|
isServer,
|
|
30
30
|
modern,
|
|
@@ -29,12 +29,15 @@ export const addSvgrLoader = (
|
|
|
29
29
|
|
|
30
30
|
export const getSvgoOptions = (configManager: ConfigManager<CliConfigEntry>) => {
|
|
31
31
|
return {
|
|
32
|
+
configFile: false,
|
|
32
33
|
plugins: configManager.svgo?.plugins ?? [
|
|
33
34
|
{
|
|
34
|
-
|
|
35
|
+
name: 'cleanupIds',
|
|
36
|
+
active: false,
|
|
35
37
|
},
|
|
36
38
|
{
|
|
37
|
-
|
|
39
|
+
name: 'collapseGroups',
|
|
40
|
+
active: false,
|
|
38
41
|
},
|
|
39
42
|
],
|
|
40
43
|
};
|