@tramvai/cli 2.48.0 → 2.49.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 (47) hide show
  1. package/lib/api/benchmark/start.js +5 -7
  2. package/lib/api/benchmark/start.js.map +1 -1
  3. package/lib/api/start/providers/child-app/shared.js +1 -1
  4. package/lib/api/start/providers/child-app/shared.js.map +1 -1
  5. package/lib/api/start/providers/module/shared.js +1 -1
  6. package/lib/api/start/providers/module/shared.js.map +1 -1
  7. package/lib/builder/webpack/providers/shared.js +1 -1
  8. package/lib/builder/webpack/providers/shared.js.map +1 -1
  9. package/lib/library/babel/index.d.ts +6 -25
  10. package/lib/library/babel/index.js +3 -3
  11. package/lib/library/babel/index.js.map +1 -1
  12. package/lib/library/swc/index.d.ts +2 -18
  13. package/lib/library/swc/index.js +31 -5
  14. package/lib/library/swc/index.js.map +1 -1
  15. package/lib/library/typescript/index.d.ts +1 -1
  16. package/lib/library/webpack/blocks/js.js +7 -8
  17. package/lib/library/webpack/blocks/js.js.map +1 -1
  18. package/lib/library/webpack/blocks/resolve.js +13 -0
  19. package/lib/library/webpack/blocks/resolve.js.map +1 -1
  20. package/lib/library/webpack/blocks/ts.js +6 -2
  21. package/lib/library/webpack/blocks/ts.js.map +1 -1
  22. package/lib/library/webpack/utils/transpiler.d.ts +13 -7
  23. package/lib/library/webpack/utils/transpiler.js +5 -14
  24. package/lib/library/webpack/utils/transpiler.js.map +1 -1
  25. package/lib/library/webpack/utils/workersPool.d.ts +2 -2
  26. package/lib/library/webpack/utils/workersPool.js +24 -19
  27. package/lib/library/webpack/utils/workersPool.js.map +1 -1
  28. package/lib/schema/autogeneratedSchema.json +9 -9
  29. package/lib/typings/configEntry/common.d.ts +5 -3
  30. package/package.json +6 -5
  31. package/schema.json +9 -9
  32. package/src/api/benchmark/start.ts +6 -9
  33. package/src/api/start/providers/child-app/shared.ts +2 -2
  34. package/src/api/start/providers/module/shared.ts +2 -2
  35. package/src/builder/webpack/providers/shared.ts +2 -2
  36. package/src/commands/new/templates/app/multirepo/tramvai.json.hbs +0 -9
  37. package/src/commands/new/templates/child-app/multirepo/tramvai.json.hbs +0 -9
  38. package/src/library/babel/index.ts +4 -24
  39. package/src/library/swc/index.ts +54 -32
  40. package/src/library/webpack/blocks/js.ts +9 -10
  41. package/src/library/webpack/blocks/resolve.ts +15 -0
  42. package/src/library/webpack/blocks/ts.ts +7 -3
  43. package/src/library/webpack/utils/transpiler.ts +37 -5
  44. package/src/library/webpack/utils/workersPool.ts +20 -16
  45. package/src/schema/autogeneratedSchema.json +9 -9
  46. package/src/schema/tramvai.spec.ts +4 -4
  47. package/src/typings/configEntry/common.ts +5 -3
@@ -1 +1 @@
1
- {"version":3,"file":"workersPool.js","sourceRoot":"","sources":["../../../../src/library/webpack/utils/workersPool.ts"],"names":[],"mappings":";;;;AAAA,oEAA8C;AAC9C,gEAAyD;AACzD,oDAAoB;AAGpB,4HAA4H;AAC5H,SAAS,YAAY;IACnB,OAAO,CAAC,YAAE,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC;AAC7C,CAAC;AAED,SAAS,wBAAwB;IAC/B,MAAM,IAAI,GAAG,YAAY,EAAE,CAAC;IAE5B,mGAAmG;IACnG,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;AACnC,CAAC;AAED,MAAM,eAAe,GAAG,CAAC,aAA4B,EAAE,EAAE;IACvD,MAAM,EACJ,KAAK,EAAE,EACL,cAAc,EAAE,EAAE,YAAY,EAAE,gBAAgB,EAAE,GACnD,GACF,GAAG,aAAa,CAAC;IAElB,OAAO,gBAAgB,IAAI,EAAE,CAAC;AAChC,CAAC,CAAC;AAEF,MAAM,iBAAiB,GAAG,CAAC,aAA4B,EAAE,EAAE;IACzD,uBACE,IAAI,EAAE,OAAO,EACb,WAAW,EAAE,aAAa,C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AAEK,MAAM,sBAAsB,GAAG,CAAC,aAA4B,EAAE,EAAE;IACrE,MAAM,MAAM,GAAG,kBAAkB,CAAC;IAElC,IAAI,CAAE,8BAA8B,CAAC,MAAM,EAAE;QAC3C,YAAY,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,gBAAgB,CAAC,CAAC,CAAC;QAC/C,8BAA8B,CAAC,MAAM,GAAG,IAAI,CAAC;KAC/C;IAED,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AATW,QAAA,sBAAsB,0BASjC;AAEK,MAAM,qBAAqB,GAAG,CAAC,aAA4B,EAAE,EAAE;;IACpE,MAAA,IAAA,qBAAO,EAAC,kBAAkB,CAAC,aAAa,CAAC,CAAC,0CAAE,cAAc,EAAE,CAAC;AAC/D,CAAC,CAAC;AAFW,QAAA,qBAAqB,yBAEhC"}
@@ -172,7 +172,7 @@
172
172
  "additionalProperties": false
173
173
  },
174
174
  "alias": {
175
- "title": "Aliases for project imports",
175
+ "title": "`@@deprecated @tramvai/cli now supports baseUrl and paths from the app's tsconfig.json file.\nJust check or add configuration to your tsconfig file and remove alias from tramvai.json`",
176
176
  "additionalProperties": true,
177
177
  "type": "object"
178
178
  },
@@ -976,12 +976,12 @@
976
976
  },
977
977
  "modern": {
978
978
  "title": "Enable development build for modern browsers",
979
- "default": false,
979
+ "default": true,
980
980
  "type": "boolean"
981
981
  },
982
982
  "hotRefresh": {
983
983
  "title": "Enable react hot-refresh",
984
- "default": false,
984
+ "default": true,
985
985
  "type": "boolean"
986
986
  },
987
987
  "hotRefreshOptions": {
@@ -1289,7 +1289,7 @@
1289
1289
  "additionalProperties": false
1290
1290
  },
1291
1291
  "alias": {
1292
- "title": "Aliases for project imports",
1292
+ "title": "`@@deprecated @tramvai/cli now supports baseUrl and paths from the app's tsconfig.json file.\nJust check or add configuration to your tsconfig file and remove alias from tramvai.json`",
1293
1293
  "additionalProperties": true,
1294
1294
  "type": "object"
1295
1295
  },
@@ -1571,12 +1571,12 @@
1571
1571
  },
1572
1572
  "modern": {
1573
1573
  "title": "Enable development build for modern browsers",
1574
- "default": false,
1574
+ "default": true,
1575
1575
  "type": "boolean"
1576
1576
  },
1577
1577
  "hotRefresh": {
1578
1578
  "title": "Enable react hot-refresh",
1579
- "default": false,
1579
+ "default": true,
1580
1580
  "type": "boolean"
1581
1581
  },
1582
1582
  "hotRefreshOptions": {
@@ -1864,7 +1864,7 @@
1864
1864
  "additionalProperties": false
1865
1865
  },
1866
1866
  "alias": {
1867
- "title": "Aliases for project imports",
1867
+ "title": "`@@deprecated @tramvai/cli now supports baseUrl and paths from the app's tsconfig.json file.\nJust check or add configuration to your tsconfig file and remove alias from tramvai.json`",
1868
1868
  "additionalProperties": true,
1869
1869
  "type": "object"
1870
1870
  },
@@ -2146,12 +2146,12 @@
2146
2146
  },
2147
2147
  "modern": {
2148
2148
  "title": "Enable development build for modern browsers",
2149
- "default": false,
2149
+ "default": true,
2150
2150
  "type": "boolean"
2151
2151
  },
2152
2152
  "hotRefresh": {
2153
2153
  "title": "Enable react hot-refresh",
2154
- "default": false,
2154
+ "default": true,
2155
2155
  "type": "boolean"
2156
2156
  },
2157
2157
  "hotRefreshOptions": {
@@ -74,12 +74,12 @@ interface ServeConfig {
74
74
  sourceMap?: boolean;
75
75
  /**
76
76
  * @title Enable development build for modern browsers
77
- * @default false
77
+ * @default true
78
78
  */
79
79
  modern?: boolean;
80
80
  /**
81
81
  * @title Enable react hot-refresh
82
- * @default false
82
+ * @default true
83
83
  */
84
84
  hotRefresh?: boolean;
85
85
  /**
@@ -193,7 +193,9 @@ interface BuildConfig {
193
193
  assetsConfig?: string;
194
194
  };
195
195
  /**
196
- * @title Aliases for project imports
196
+ * @title `@@deprecated @tramvai/cli now supports baseUrl and paths from the app's tsconfig.json file.
197
+ * Just check or add configuration to your tsconfig file and remove alias from tramvai.json`
198
+ * @deprecated
197
199
  * @additionalProperties true
198
200
  */
199
201
  alias?: Record<string, any>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tramvai/cli",
3
- "version": "2.48.0",
3
+ "version": "2.49.0",
4
4
  "description": "Cli инструмент для сборки и запуска приложений",
5
5
  "files": [
6
6
  "src",
@@ -62,16 +62,16 @@
62
62
  "@tinkoff/browserslist-config": "0.2.4",
63
63
  "@tinkoff/dippy": "0.8.9",
64
64
  "@tinkoff/is-modern-lib": "2.0.4",
65
- "@tinkoff/logger": "0.10.54",
65
+ "@tinkoff/logger": "0.10.55",
66
66
  "@tinkoff/minicss-class-generator": "0.2.4",
67
67
  "@tinkoff/package-manager-wrapper": "0.1.4",
68
68
  "@tinkoff/request-core": "^0.9.2",
69
69
  "@tinkoff/request-plugin-protocol-http": "^0.11.6",
70
70
  "@tinkoff/utils": "^2.1.3",
71
71
  "@tramvai/build": "3.0.6",
72
- "@tramvai/react": "2.48.0",
73
- "@tramvai/tools-check-versions": "0.4.5",
74
- "@tramvai/tools-migrate": "0.6.6",
72
+ "@tramvai/react": "2.49.0",
73
+ "@tramvai/tools-check-versions": "0.4.6",
74
+ "@tramvai/tools-migrate": "0.6.7",
75
75
  "ajv": "^6.12.6",
76
76
  "ansi-escapes": "^4.3.2",
77
77
  "autoprefixer": "^10.4.8",
@@ -143,6 +143,7 @@
143
143
  "terser-webpack-plugin": "^5.3.5",
144
144
  "text-table": "^0.2.0",
145
145
  "thread-loader": "^3.0.4",
146
+ "tsconfig-paths-webpack-plugin": "^4.0.0",
146
147
  "universal-analytics": "^0.4.23",
147
148
  "utility-types": "^3.10.0",
148
149
  "v8-compile-cache": "^2.3.0",
package/schema.json CHANGED
@@ -193,7 +193,7 @@
193
193
  "additionalProperties": false
194
194
  },
195
195
  "alias": {
196
- "title": "Aliases for project imports",
196
+ "title": "`@@deprecated @tramvai/cli now supports baseUrl and paths from the app's tsconfig.json file.\nJust check or add configuration to your tsconfig file and remove alias from tramvai.json`",
197
197
  "additionalProperties": true,
198
198
  "type": "object"
199
199
  },
@@ -997,12 +997,12 @@
997
997
  },
998
998
  "modern": {
999
999
  "title": "Enable development build for modern browsers",
1000
- "default": false,
1000
+ "default": true,
1001
1001
  "type": "boolean"
1002
1002
  },
1003
1003
  "hotRefresh": {
1004
1004
  "title": "Enable react hot-refresh",
1005
- "default": false,
1005
+ "default": true,
1006
1006
  "type": "boolean"
1007
1007
  },
1008
1008
  "hotRefreshOptions": {
@@ -1318,7 +1318,7 @@
1318
1318
  "additionalProperties": false
1319
1319
  },
1320
1320
  "alias": {
1321
- "title": "Aliases for project imports",
1321
+ "title": "`@@deprecated @tramvai/cli now supports baseUrl and paths from the app's tsconfig.json file.\nJust check or add configuration to your tsconfig file and remove alias from tramvai.json`",
1322
1322
  "additionalProperties": true,
1323
1323
  "type": "object"
1324
1324
  },
@@ -1600,12 +1600,12 @@
1600
1600
  },
1601
1601
  "modern": {
1602
1602
  "title": "Enable development build for modern browsers",
1603
- "default": false,
1603
+ "default": true,
1604
1604
  "type": "boolean"
1605
1605
  },
1606
1606
  "hotRefresh": {
1607
1607
  "title": "Enable react hot-refresh",
1608
- "default": false,
1608
+ "default": true,
1609
1609
  "type": "boolean"
1610
1610
  },
1611
1611
  "hotRefreshOptions": {
@@ -1901,7 +1901,7 @@
1901
1901
  "additionalProperties": false
1902
1902
  },
1903
1903
  "alias": {
1904
- "title": "Aliases for project imports",
1904
+ "title": "`@@deprecated @tramvai/cli now supports baseUrl and paths from the app's tsconfig.json file.\nJust check or add configuration to your tsconfig file and remove alias from tramvai.json`",
1905
1905
  "additionalProperties": true,
1906
1906
  "type": "object"
1907
1907
  },
@@ -2183,12 +2183,12 @@
2183
2183
  },
2184
2184
  "modern": {
2185
2185
  "title": "Enable development build for modern browsers",
2186
- "default": false,
2186
+ "default": true,
2187
2187
  "type": "boolean"
2188
2188
  },
2189
2189
  "hotRefresh": {
2190
2190
  "title": "Enable react hot-refresh",
2191
- "default": false,
2191
+ "default": true,
2192
2192
  "type": "boolean"
2193
2193
  },
2194
2194
  "hotRefreshOptions": {
@@ -101,21 +101,18 @@ const runRebuild = async (di: Container, { times }: { times: number }): Promise<
101
101
  };
102
102
 
103
103
  export const benchmarkStart = async (di: Container): Promise<StartResult> => {
104
- // прогоняем один раз, чтобы очистить старые кеши и прогреть код команды
105
- await runStartCommand(di, { times: 1, shouldClearCache: true });
106
-
107
104
  const { times = 5 } = di.get(COMMAND_PARAMETERS_TOKEN) as Params;
108
105
 
109
- const cache = await runStartCommand(di, {
110
- times,
111
- shouldClearCache: false,
112
- });
113
-
114
106
  const noCache = await runStartCommand(di, {
115
- times,
107
+ times: Math.max(Math.floor(times / 3), 2),
116
108
  shouldClearCache: true,
117
109
  });
118
110
 
111
+ const cache = await runStartCommand(di, {
112
+ times: Math.max(Math.floor(times / 2), 2),
113
+ shouldClearCache: false,
114
+ });
115
+
119
116
  const rebuild = await runRebuild(di, { times });
120
117
 
121
118
  return {
@@ -10,7 +10,7 @@ import type { ChildAppConfigEntry } from '../../../../typings/configEntry/child-
10
10
  import type { Params } from '../../index';
11
11
  import { ConfigManager } from '../../../../config/configManager';
12
12
  import {
13
- closeWorkerPoolBabel,
13
+ closeWorkerPoolTranspiler,
14
14
  closeWorkerPoolStyles,
15
15
  } from '../../../../library/webpack/utils/workersPool';
16
16
  import { stopServer } from '../../utils/stopServer';
@@ -92,7 +92,7 @@ export const sharedProviders: readonly Provider[] = [
92
92
  useFactory: ({ configManager }: { configManager: typeof CONFIG_MANAGER_TOKEN }) => {
93
93
  return async () => {
94
94
  await Promise.all([
95
- closeWorkerPoolBabel(configManager),
95
+ closeWorkerPoolTranspiler(configManager),
96
96
  closeWorkerPoolStyles(configManager),
97
97
  ]);
98
98
  };
@@ -10,7 +10,7 @@ import type { ModuleConfigEntry } from '../../../../typings/configEntry/module';
10
10
  import type { Params } from '../../index';
11
11
  import { ConfigManager } from '../../../../config/configManager';
12
12
  import {
13
- closeWorkerPoolBabel,
13
+ closeWorkerPoolTranspiler,
14
14
  closeWorkerPoolStyles,
15
15
  } from '../../../../library/webpack/utils/workersPool';
16
16
  import { stopServer } from '../../utils/stopServer';
@@ -92,7 +92,7 @@ export const sharedProviders: readonly Provider[] = [
92
92
  useFactory: ({ configManager }: { configManager: typeof CONFIG_MANAGER_TOKEN }) => {
93
93
  return async () => {
94
94
  await Promise.all([
95
- closeWorkerPoolBabel(configManager),
95
+ closeWorkerPoolTranspiler(configManager),
96
96
  closeWorkerPoolStyles(configManager),
97
97
  ]);
98
98
  };
@@ -3,7 +3,7 @@ import { provide } from '@tinkoff/dippy';
3
3
  import { EventEmitter } from 'events';
4
4
  import { CONFIG_MANAGER_TOKEN } from '../../../di/tokens';
5
5
  import {
6
- closeWorkerPoolBabel,
6
+ closeWorkerPoolTranspiler,
7
7
  closeWorkerPoolStyles,
8
8
  } from '../../../library/webpack/utils/workersPool';
9
9
  import {
@@ -67,7 +67,7 @@ export const sharedProviders: Provider[] = [
67
67
  useFactory: ({ configManager }) => {
68
68
  return async () => {
69
69
  await Promise.all([
70
- closeWorkerPoolBabel(configManager),
70
+ closeWorkerPoolTranspiler(configManager),
71
71
  closeWorkerPoolStyles(configManager),
72
72
  ]);
73
73
  };
@@ -17,15 +17,6 @@
17
17
  "postcss": {
18
18
  "config": "src/postcss"
19
19
  },
20
- "alias": {
21
- "~shared": "./src/shared",
22
- "~entities": "./src/entities",
23
- "~features": "./src/features",
24
- "~widgets": "./src/widgets",
25
- "~pages": "./src/pages",
26
- "~processes": "./src/processes",
27
- "~app": "./src/app"
28
- },
29
20
  "fileSystemPages": {
30
21
  "enable": true
31
22
  }
@@ -11,15 +11,6 @@
11
11
  "postcss": {
12
12
  "config": "src/postcss"
13
13
  },
14
- "alias": {
15
- "~shared": "./src/shared",
16
- "~entities": "./src/entities",
17
- "~features": "./src/features",
18
- "~widgets": "./src/widgets",
19
- "~pages": "./src/pages",
20
- "~processes": "./src/processes",
21
- "~app": "./src/app"
22
- }
23
14
  }
24
15
  }
25
16
  }
@@ -2,8 +2,7 @@ import path from 'path';
2
2
  import browserslist from 'browserslist';
3
3
  import envTargets from '@tinkoff/browserslist-config';
4
4
  import { sync as resolve } from 'resolve';
5
- import type { Env } from '../../typings/Env';
6
- import type { Target } from '../../typings/target';
5
+ import type { TranspilerConfig } from '../webpack/utils/transpiler';
7
6
 
8
7
  const envConfig = {
9
8
  production: {
@@ -19,25 +18,6 @@ const envConfig = {
19
18
  },
20
19
  };
21
20
 
22
- interface BabelConfig {
23
- env?: Env;
24
- target?: Target;
25
- modern?: boolean;
26
- isServer?: boolean;
27
- generateDataQaTag?: boolean;
28
- enableFillActionNamePlugin?: boolean;
29
- typescript?: boolean;
30
- modules?: string | false;
31
- loader?: boolean;
32
- useESModules?: boolean;
33
- removeTypeofWindow?: boolean;
34
- alias?: Record<string, any>;
35
- tramvai?: boolean;
36
- hot?: boolean;
37
- excludesPresetEnv?: string[];
38
- rootDir?: string;
39
- }
40
-
41
21
  function hasJsxRuntime() {
42
22
  try {
43
23
  resolve('react/jsx-runtime', { basedir: process.cwd() });
@@ -59,7 +39,6 @@ export const babelConfigFactory = ({
59
39
  // @ts-expect-error
60
40
  markCreateTokenAsPure = true,
61
41
  typescript = false,
62
- useESModules = !(isServer && env === 'development'), // на сервере в режиме дев node_modules не компилятся поэтому отключаем ESModules,
63
42
  loader = true,
64
43
  removeTypeofWindow,
65
44
  alias,
@@ -67,7 +46,7 @@ export const babelConfigFactory = ({
67
46
  hot = false,
68
47
  excludesPresetEnv,
69
48
  rootDir = process.cwd(),
70
- }: BabelConfig) => {
49
+ }: Partial<TranspilerConfig>) => {
71
50
  const cfg = envConfig[env] || {};
72
51
  let resultTarget = target;
73
52
 
@@ -126,7 +105,8 @@ export const babelConfigFactory = ({
126
105
  .filter(Boolean),
127
106
 
128
107
  plugins: [
129
- ['@babel/transform-runtime', { useESModules }],
108
+ // TODO: useESModules is deprecated and should work automatically - https://babeljs.io/docs/en/babel-plugin-transform-runtime#useesmodules
109
+ ['@babel/transform-runtime', { useESModules: !(isServer && env === 'development') }],
130
110
  path.resolve(__dirname, './plugins/lazy-component/legacy-universal-replace'), // TODO: удалить плагин после того как отпадёт необходимость поддерживать легаси
131
111
  path.resolve(__dirname, './plugins/lazy-component/lazy-component'),
132
112
  generateDataQaTag && path.resolve(__dirname, './plugins/react-element-info-unique'), // Собственный плагин. Необходимо удалить в будущем
@@ -1,39 +1,55 @@
1
+ import isEmpty from '@tinkoff/utils/is/empty';
2
+ import path from 'path';
3
+ import { existsSync } from 'fs';
1
4
  import browserslist from 'browserslist';
2
5
  import envTargets from '@tinkoff/browserslist-config';
3
6
  import { sync as resolve } from 'resolve';
4
7
  import findCacheDir from 'find-cache-dir';
5
8
  import type { Config } from '@swc/core';
6
- import type { Env } from '../../typings/Env';
7
- import type { Target } from '../../typings/target';
8
-
9
- interface SWCConfig {
10
- env?: Env;
11
- target?: Target;
12
- modern?: boolean;
13
- isServer?: boolean;
14
- typescript?: boolean;
15
- modules?: Config['module']['type'] | false;
16
- removeTypeofWindow?: boolean;
17
- alias?: Record<string, any>;
18
- bugfixes?: boolean; // https://babeljs.io/docs/en/babel-preset-env#bugfixes
19
- tramvai?: boolean;
20
- hot?: boolean;
21
- rootDir?: string;
22
- }
9
+ import type { TranspilerConfig } from '../webpack/utils/transpiler';
23
10
 
24
11
  const TRAMVAI_SWC_TARGET_PATH = '@tramvai/swc-integration/target/wasm32-wasi';
25
12
 
26
- export const getSwcOptions = ({
27
- env = 'development',
28
- target,
29
- modern,
30
- isServer = false,
31
- modules = false,
32
- typescript = false,
33
- hot = false,
34
- rootDir = process.cwd(),
35
- tramvai = false,
36
- }: SWCConfig): Config => {
13
+ const NOT_SUPPORTED_FIELDS = ['alias', 'generateDataQaTag', 'enableFillActionNamePlugin'];
14
+ let warningWasShown = false;
15
+
16
+ export const getSwcOptions = (config: TranspilerConfig): Config => {
17
+ const {
18
+ env = 'development',
19
+ target,
20
+ modern,
21
+ isServer = false,
22
+ modules = false,
23
+ typescript = false,
24
+ hot = false,
25
+ removeTypeofWindow,
26
+ tramvai = false,
27
+ rootDir = process.cwd(),
28
+ } = config;
29
+
30
+ if (!warningWasShown) {
31
+ for (const field of NOT_SUPPORTED_FIELDS) {
32
+ if (config[field] && !isEmpty(config[field])) {
33
+ console.warn(
34
+ `@tramvai/swc-integration do not support "${field}" configuration. Consider removing it from tramvai.json`
35
+ );
36
+
37
+ warningWasShown = true;
38
+ }
39
+ }
40
+
41
+ const swcrcPath = path.resolve(rootDir, '.swcrc');
42
+
43
+ if (existsSync(swcrcPath)) {
44
+ console.warn(
45
+ `Found .swcrc config in the app root directory ("${swcrcPath}").
46
+ Having swc config may conflict with @tramvai/cli configuration`
47
+ );
48
+
49
+ warningWasShown = true;
50
+ }
51
+ }
52
+
37
53
  const resolveWasmFile = (pluginName: string, type: 'debug' | 'release') => {
38
54
  return resolve(`${TRAMVAI_SWC_TARGET_PATH}/${type}/${pluginName}.wasm`, {
39
55
  basedir: rootDir,
@@ -99,6 +115,8 @@ export const getSwcOptions = ({
99
115
  parser: {
100
116
  syntax: typescript ? 'typescript' : 'ecmascript',
101
117
  decorators: true,
118
+ tsx: true,
119
+ jsx: true,
102
120
  },
103
121
  transform: {
104
122
  legacyDecorator: true,
@@ -109,11 +127,15 @@ export const getSwcOptions = ({
109
127
  },
110
128
  optimizer: {
111
129
  globals: {
130
+ // let the webpack replace NODE_ENV as replacement with swc may mess up with tests
131
+ envs: [],
112
132
  // @ts-ignore
113
133
  // TODO: there is not typings for typeofs, but the field is mentioned in docs
114
- typeofs: {
115
- window: isServer ? 'undefined' : 'object',
116
- },
134
+ typeofs: removeTypeofWindow
135
+ ? {
136
+ window: isServer ? 'undefined' : 'object',
137
+ }
138
+ : {},
117
139
  },
118
140
  },
119
141
  },
@@ -123,7 +145,7 @@ export const getSwcOptions = ({
123
145
  [resolveTramvaiSwcPlugin('create_token_pure'), {}],
124
146
  [resolveTramvaiSwcPlugin('lazy_component'), {}],
125
147
  isServer && [resolveTramvaiSwcPlugin('dynamic_import_to_require'), {}],
126
- tramvai && env === 'development' && [resolveTramvaiSwcPlugin('provider-stack'), {}],
148
+ tramvai && env === 'development' && [resolveTramvaiSwcPlugin('provider_stack'), {}],
127
149
  ].filter(Boolean) as Array<[string, Record<string, any>]>,
128
150
  },
129
151
  },
@@ -1,16 +1,15 @@
1
1
  import type Config from 'webpack-chain';
2
2
  import { modernLibsFilter } from '@tinkoff/is-modern-lib';
3
- import type babelConfig from '../../babel';
4
- import { createWorkerPoolBabel } from '../utils/workersPool';
3
+ import { createWorkerPoolTranspiler } from '../utils/workersPool';
5
4
  import type { ConfigManager } from '../../../config/configManager';
5
+ import type { TranspilerConfig } from '../utils/transpiler';
6
6
  import { getTranspilerConfig, addTranspilerLoader } from '../utils/transpiler';
7
7
 
8
8
  // eslint-disable-next-line import/no-default-export
9
9
  export default (configManager: ConfigManager) => (config: Config) => {
10
- const transpilerConfig = getTranspilerConfig(configManager);
11
10
  const { transpileOnlyModernLibs } = configManager.build.configurations;
12
11
 
13
- const jsRule = (babelCfg: Parameters<typeof babelConfig>[0]) => (rule: Config.Rule) => {
12
+ const jsRule = (transpilerConfig: TranspilerConfig) => (rule: Config.Rule) => {
14
13
  const cfg = rule
15
14
  .test(/\.[cm]?js[x]?$/)
16
15
  .oneOf('default')
@@ -19,12 +18,12 @@ export default (configManager: ConfigManager) => (config: Config) => {
19
18
  cfg
20
19
  .use('thread')
21
20
  .loader('thread-loader')
22
- .options(createWorkerPoolBabel(configManager))
21
+ .options(createWorkerPoolTranspiler(configManager))
23
22
  .end()
24
23
  )
25
24
  .use('transpiler');
26
25
 
27
- return addTranspilerLoader(configManager, cfg, babelCfg);
26
+ return addTranspilerLoader(configManager, cfg, transpilerConfig);
28
27
  };
29
28
 
30
29
  if (transpileOnlyModernLibs) {
@@ -32,13 +31,13 @@ export default (configManager: ConfigManager) => (config: Config) => {
32
31
  .rule('js:project')
33
32
  .exclude.add(/node_modules/)
34
33
  .end()
35
- .batch(jsRule(transpilerConfig));
34
+ .batch(jsRule(getTranspilerConfig(configManager)));
36
35
 
37
36
  config.module
38
37
  .rule('js:node_modules')
39
38
  .include.add(modernLibsFilter)
40
39
  .end()
41
- .batch(jsRule({ ...transpilerConfig, hot: false }))
40
+ .batch(jsRule(getTranspilerConfig(configManager, { hot: false })))
42
41
  .merge({
43
42
  // TODO: некоторые пакеты неправильно описывают импорты для es модулей
44
43
  // https://github.com/babel/babel/issues/12058
@@ -49,13 +48,13 @@ export default (configManager: ConfigManager) => (config: Config) => {
49
48
  .rule('js:project')
50
49
  .exclude.add(/node_modules/)
51
50
  .end()
52
- .batch(jsRule(transpilerConfig));
51
+ .batch(jsRule(getTranspilerConfig(configManager)));
53
52
 
54
53
  config.module
55
54
  .rule('js:node_modules')
56
55
  .include.add(/node_modules/)
57
56
  .end()
58
- .batch(jsRule({ ...transpilerConfig, hot: false }))
57
+ .batch(jsRule(getTranspilerConfig(configManager, { hot: false })))
59
58
  .merge({
60
59
  // TODO: некоторые пакеты неправильно описывают импорты для es модулей
61
60
  // https://github.com/babel/babel/issues/12058
@@ -1,5 +1,7 @@
1
1
  import type Config from 'webpack-chain';
2
2
  import path from 'path';
3
+ import { existsSync } from 'fs';
4
+ import { TsconfigPathsPlugin } from 'tsconfig-paths-webpack-plugin';
3
5
  import type { ConfigManager } from '../../../config/configManager';
4
6
  import { extensions } from '../../../config/constants';
5
7
 
@@ -15,6 +17,19 @@ export default (configManager: ConfigManager) => (config: Config) => {
15
17
  ].filter(Boolean)
16
18
  );
17
19
 
20
+ const tsconfigPath = path.resolve(rootDir, 'tsconfig.json');
21
+
22
+ if (existsSync(tsconfigPath)) {
23
+ config.resolve.plugin('tsconfig-paths').use(TsconfigPathsPlugin, [
24
+ {
25
+ configFile: tsconfigPath,
26
+ extensions,
27
+ mainFields: config.resolve.mainFields.values(),
28
+ silent: true,
29
+ },
30
+ ] as ConstructorParameters<typeof TsconfigPathsPlugin>);
31
+ }
32
+
18
33
  config.resolve.extensions
19
34
  .merge(extensions)
20
35
  .end()
@@ -1,10 +1,10 @@
1
1
  import type Config from 'webpack-chain';
2
- import { createWorkerPoolBabel } from '../utils/workersPool';
2
+ import { createWorkerPoolTranspiler } from '../utils/workersPool';
3
3
  import type { ConfigManager } from '../../../config/configManager';
4
4
  import { addTranspilerLoader, getTranspilerConfig } from '../utils/transpiler';
5
5
 
6
6
  export default (configManager: ConfigManager) => (config: Config) => {
7
- const transpilerConfig = { ...getTranspilerConfig(configManager), typescript: true };
7
+ const transpilerConfig = getTranspilerConfig(configManager, { typescript: true });
8
8
 
9
9
  const cfg = config.module
10
10
  .rule('ts:project')
@@ -14,7 +14,11 @@ export default (configManager: ConfigManager) => (config: Config) => {
14
14
  .oneOf('default')
15
15
  // TODO разобраться почему на винде все плохо с thread-loader
16
16
  .when(process.platform !== 'win32', (cfg) =>
17
- cfg.use('thread').loader('thread-loader').options(createWorkerPoolBabel(configManager)).end()
17
+ cfg
18
+ .use('thread')
19
+ .loader('thread-loader')
20
+ .options(createWorkerPoolTranspiler(configManager))
21
+ .end()
18
22
  )
19
23
  .use('transpiler');
20
24