@tramvai/cli 5.24.0 → 5.41.1

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 (130) hide show
  1. package/README.md +38 -0
  2. package/bin/platform.js +26 -1
  3. package/bin/spawn.js +36 -8
  4. package/lib/api/build/index.d.ts +1 -0
  5. package/lib/api/build/index.d.ts.map +1 -1
  6. package/lib/api/build/index.js.map +1 -1
  7. package/lib/api/start-prod/providers/application.js +2 -2
  8. package/lib/api/start-prod/providers/application.js.map +1 -1
  9. package/lib/builder/webpack/devServer/pool/process/pool.d.ts.map +1 -1
  10. package/lib/builder/webpack/devServer/pool/process/pool.js +2 -1
  11. package/lib/builder/webpack/devServer/pool/process/pool.js.map +1 -1
  12. package/lib/builder/webpack/devServer/pool/thread/pool.d.ts.map +1 -1
  13. package/lib/builder/webpack/devServer/pool/thread/pool.js +2 -1
  14. package/lib/builder/webpack/devServer/pool/thread/pool.js.map +1 -1
  15. package/lib/builder/webpack/devServer/server.d.ts.map +1 -1
  16. package/lib/builder/webpack/devServer/server.js +31 -2
  17. package/lib/builder/webpack/devServer/server.js.map +1 -1
  18. package/lib/builder/webpack/tokens.d.ts +3 -3
  19. package/lib/cli/CLI.d.ts +1 -1
  20. package/lib/cli/CLI.d.ts.map +1 -1
  21. package/lib/cli/CLI.js +2 -2
  22. package/lib/cli/CLI.js.map +1 -1
  23. package/lib/cli/index.d.ts.map +1 -1
  24. package/lib/cli/index.js +1 -2
  25. package/lib/cli/index.js.map +1 -1
  26. package/lib/commands/add/add.d.ts +3 -2
  27. package/lib/commands/add/add.d.ts.map +1 -1
  28. package/lib/commands/add/add.js +8 -2
  29. package/lib/commands/add/add.js.map +1 -1
  30. package/lib/commands/add/checkPackageValidator.d.ts +1 -1
  31. package/lib/commands/add/checkPackageValidator.d.ts.map +1 -1
  32. package/lib/commands/add/checkPackageValidator.js +7 -2
  33. package/lib/commands/add/checkPackageValidator.js.map +1 -1
  34. package/lib/commands/add/command.d.ts +8 -3
  35. package/lib/commands/add/command.d.ts.map +1 -1
  36. package/lib/commands/add/command.js +6 -1
  37. package/lib/commands/add/command.js.map +1 -1
  38. package/lib/commands/new/new.d.ts.map +1 -1
  39. package/lib/commands/new/new.js +22 -20
  40. package/lib/commands/new/new.js.map +1 -1
  41. package/lib/commands/new/steps/installDependencies.d.ts +4 -3
  42. package/lib/commands/new/steps/installDependencies.d.ts.map +1 -1
  43. package/lib/commands/new/steps/installDependencies.js +58 -20
  44. package/lib/commands/new/steps/installDependencies.js.map +1 -1
  45. package/lib/commands/update/update.d.ts.map +1 -1
  46. package/lib/commands/update/update.js +14 -3
  47. package/lib/commands/update/update.js.map +1 -1
  48. package/lib/commands/update/updatePackageJson.d.ts +1 -1
  49. package/lib/commands/update/updatePackageJson.d.ts.map +1 -1
  50. package/lib/commands/update/updatePackageJson.js +5 -11
  51. package/lib/commands/update/updatePackageJson.js.map +1 -1
  52. package/lib/config/configManager.d.ts +1 -1
  53. package/lib/config/configManager.d.ts.map +1 -1
  54. package/lib/config/constants.d.ts +0 -1
  55. package/lib/config/constants.d.ts.map +1 -1
  56. package/lib/config/constants.js +1 -2
  57. package/lib/config/constants.js.map +1 -1
  58. package/lib/config/utils.d.ts +2 -0
  59. package/lib/config/utils.d.ts.map +1 -0
  60. package/lib/config/utils.js +19 -0
  61. package/lib/config/utils.js.map +1 -0
  62. package/lib/di/tokens/config.d.ts +1 -1
  63. package/lib/library/webpack/application/client/dev.js +1 -1
  64. package/lib/library/webpack/application/client/dev.js.map +1 -1
  65. package/lib/library/webpack/application/client/prod/optimization/splitChunks.d.ts.map +1 -1
  66. package/lib/library/webpack/application/client/prod/optimization/splitChunks.js +51 -1
  67. package/lib/library/webpack/application/client/prod/optimization/splitChunks.js.map +1 -1
  68. package/lib/library/webpack/application/common.d.ts.map +1 -1
  69. package/lib/library/webpack/application/common.js +12 -0
  70. package/lib/library/webpack/application/common.js.map +1 -1
  71. package/lib/library/webpack/application/server/dev.js +1 -1
  72. package/lib/library/webpack/application/server/dev.js.map +1 -1
  73. package/lib/library/webpack/utils/threadLoader.d.ts.map +1 -1
  74. package/lib/library/webpack/utils/threadLoader.js +1 -0
  75. package/lib/library/webpack/utils/threadLoader.js.map +1 -1
  76. package/lib/models/context.d.ts +3 -3
  77. package/lib/models/context.d.ts.map +1 -1
  78. package/lib/models/context.js +1 -2
  79. package/lib/models/context.js.map +1 -1
  80. package/lib/schema/autogeneratedSchema.json +34 -24
  81. package/lib/typings/configEntry/application.d.ts +10 -0
  82. package/lib/typings/configEntry/application.d.ts.map +1 -1
  83. package/lib/typings/configEntry/cli.d.ts +1 -1
  84. package/lib/typings/configEntry/cli.d.ts.map +1 -1
  85. package/lib/utils/commands/dependencies/findTramvaiVersion.js +1 -1
  86. package/lib/utils/commands/dependencies/findTramvaiVersion.js.map +1 -1
  87. package/lib/utils/commands/dependencies/getWorkspaceRootByAppName.d.ts +3 -0
  88. package/lib/utils/commands/dependencies/getWorkspaceRootByAppName.d.ts.map +1 -0
  89. package/lib/utils/commands/dependencies/getWorkspaceRootByAppName.js +8 -0
  90. package/lib/utils/commands/dependencies/getWorkspaceRootByAppName.js.map +1 -0
  91. package/lib/utils/npmRequire.js +1 -1
  92. package/lib/utils/npmRequire.js.map +1 -1
  93. package/package.json +5 -4
  94. package/schema.json +34 -24
  95. package/src/api/build/index.ts +1 -0
  96. package/src/api/start-prod/providers/application.ts +2 -2
  97. package/src/builder/webpack/devServer/pool/process/pool.ts +3 -2
  98. package/src/builder/webpack/devServer/pool/thread/pool.ts +3 -2
  99. package/src/builder/webpack/devServer/server.ts +38 -2
  100. package/src/cli/CLI.ts +1 -3
  101. package/src/cli/index.ts +1 -3
  102. package/src/commands/add/add.ts +17 -3
  103. package/src/commands/add/checkPackageValidator.ts +6 -2
  104. package/src/commands/add/command.ts +6 -1
  105. package/src/commands/new/new.ts +34 -21
  106. package/src/commands/new/steps/installDependencies.ts +75 -27
  107. package/src/commands/new/templates/monorepo-block/package.json.hbs +5 -0
  108. package/src/commands/new/templates/shared/package.json.hbs +2 -1
  109. package/src/commands/update/update.ts +26 -3
  110. package/src/commands/update/updatePackageJson.spec.ts +16 -10
  111. package/src/commands/update/updatePackageJson.ts +10 -15
  112. package/src/config/configManager.ts +1 -1
  113. package/src/config/constants.ts +0 -2
  114. package/src/config/utils.ts +18 -0
  115. package/src/library/swc/__integration__/swc.start.test.ts +3 -0
  116. package/src/library/webpack/application/client/dev.ts +1 -1
  117. package/src/library/webpack/application/client/prod/optimization/splitChunks.ts +66 -2
  118. package/src/library/webpack/application/common.ts +13 -0
  119. package/src/library/webpack/application/server/dev.ts +1 -1
  120. package/src/library/webpack/utils/threadLoader.ts +1 -0
  121. package/src/models/config.spec.ts +4 -0
  122. package/src/models/context.ts +3 -2
  123. package/src/schema/autogeneratedSchema.json +34 -24
  124. package/src/schema/tramvai.spec.ts +2 -0
  125. package/src/typings/configEntry/application.ts +11 -0
  126. package/src/typings/configEntry/cli.ts +6 -1
  127. package/src/typings/webpack-chain/index.d.ts +1 -0
  128. package/src/utils/commands/dependencies/findTramvaiVersion.ts +1 -1
  129. package/src/utils/commands/dependencies/getWorkspaceRootByAppName.ts +5 -0
  130. package/src/utils/npmRequire.ts +1 -1
@@ -4,6 +4,8 @@ import { getLatestPackageVersion } from '../../utils/commands/dependencies/getLa
4
4
  import { migrate } from '../../utils/commands/dependencies/migrate';
5
5
  import { updatePackageJson } from './updatePackageJson';
6
6
  import { checkVersions } from '../../utils/commands/dependencies/checkVersions';
7
+ import moduleVersion from '../../utils/moduleVersion';
8
+ import { findTramvaiVersion } from '../../utils/commands/dependencies/findTramvaiVersion';
7
9
 
8
10
  export type Params = {
9
11
  to: string;
@@ -13,15 +15,36 @@ export default async (
13
15
  context: Context,
14
16
  { to: version = 'latest' }: Params
15
17
  ): Promise<CommandResult> => {
16
- const versionNumber = await getLatestPackageVersion('@tramvai/core', version);
18
+ const targetVersion = await getLatestPackageVersion('@tramvai/cli', version);
19
+ const currentVersion = await findTramvaiVersion();
20
+
21
+ if (!currentVersion) {
22
+ throw new Error(
23
+ 'Could not resolve tramvai version from package.json. Do you have @tramvai/core installed?'
24
+ );
25
+ }
26
+
27
+ if (currentVersion === version) {
28
+ throw new Error(
29
+ 'The installed version is equal to the current version, no update is required.'
30
+ );
31
+ }
17
32
 
18
33
  context.logger.event({
19
34
  type: 'info',
20
35
  event: 'resolving-version',
21
- message: `Tramvai version resolved to ${versionNumber}`,
36
+ message: `Tramvai version resolved to ${targetVersion}`,
22
37
  });
23
38
 
24
- await updatePackageJson(versionNumber, version === 'prerelease');
39
+ if (context.packageManager.workspaces) {
40
+ await Promise.all(
41
+ context.packageManager.workspaces.map((directory) =>
42
+ updatePackageJson(targetVersion, currentVersion, version === 'prerelease', directory)
43
+ )
44
+ );
45
+ }
46
+
47
+ await updatePackageJson(targetVersion, currentVersion, version === 'prerelease');
25
48
 
26
49
  context.logger.event({
27
50
  type: 'info',
@@ -1,8 +1,12 @@
1
+ import { resolve } from 'path';
1
2
  import { updatePackageJson } from './updatePackageJson';
2
3
 
3
4
  const LATEST_TRAMVAI_VERSION = '1.115.6';
4
5
  const LATEST_LIB_VERSION = '0.8.23';
5
6
  const PRERELEASE_LIB_VERSION = '2.0.1';
7
+ const CURRENT_TRAMVAI_VERSION = '1.93.2';
8
+
9
+ const packageJsonPath = resolve('package.json');
6
10
 
7
11
  let mockPackageJson: Record<string, any>;
8
12
  const mockFsWrite = jest.fn();
@@ -38,13 +42,13 @@ beforeEach(() => {
38
42
  it('should update tramvai deps to latest versions', async () => {
39
43
  mockPackageJson = {
40
44
  dependencies: {
41
- '@tramvai/core': '1.93.2',
42
- '@tramvai/module-common': '1.93.2',
45
+ '@tramvai/core': CURRENT_TRAMVAI_VERSION,
46
+ '@tramvai/module-common': CURRENT_TRAMVAI_VERSION,
43
47
  '@tinkoff/router': '^0.2.3',
44
48
  '@tinkoff/url': '0.3.2',
45
49
  },
46
50
  devDependencies: {
47
- '@tramvai/cli': '1.93.2',
51
+ '@tramvai/cli': CURRENT_TRAMVAI_VERSION,
48
52
  },
49
53
  peerDependencies: {
50
54
  '@tinkoff/dippy': '0.7.10',
@@ -72,11 +76,12 @@ it('should update tramvai deps to latest versions', async () => {
72
76
  return {};
73
77
  });
74
78
 
75
- await updatePackageJson(LATEST_TRAMVAI_VERSION);
79
+ await updatePackageJson(LATEST_TRAMVAI_VERSION, CURRENT_TRAMVAI_VERSION);
76
80
 
81
+ // eslint-disable-next-line jest/no-interpolation-in-snapshots
77
82
  expect(mockFsWrite.mock.calls[0]).toMatchInlineSnapshot(`
78
83
  [
79
- "package.json",
84
+ "${packageJsonPath}",
80
85
  "{
81
86
  "dependencies": {
82
87
  "@tramvai/core": "1.115.6",
@@ -98,14 +103,14 @@ it('should update tramvai deps to latest versions', async () => {
98
103
  it('prerelease should be used for dependant libs', async () => {
99
104
  mockPackageJson = {
100
105
  dependencies: {
101
- '@tramvai/core': '1.93.2',
102
- '@tramvai/module-common': '1.93.2',
106
+ '@tramvai/core': CURRENT_TRAMVAI_VERSION,
107
+ '@tramvai/module-common': CURRENT_TRAMVAI_VERSION,
103
108
  '@tinkoff/router': '^0.2.3',
104
109
  '@tinkoff/url': '0.3.2',
105
110
  '@tinkoff/pack-polyfills': '1.0.0',
106
111
  },
107
112
  devDependencies: {
108
- '@tramvai/cli': '1.93.2',
113
+ '@tramvai/cli': CURRENT_TRAMVAI_VERSION,
109
114
  },
110
115
  peerDependencies: {
111
116
  '@tinkoff/dippy': '0.7.10',
@@ -133,11 +138,12 @@ it('prerelease should be used for dependant libs', async () => {
133
138
  return {};
134
139
  });
135
140
 
136
- await updatePackageJson(LATEST_TRAMVAI_VERSION, true);
141
+ await updatePackageJson(LATEST_TRAMVAI_VERSION, CURRENT_TRAMVAI_VERSION, true);
137
142
 
143
+ // eslint-disable-next-line jest/no-interpolation-in-snapshots
138
144
  expect(mockFsWrite.mock.calls[0]).toMatchInlineSnapshot(`
139
145
  [
140
- "package.json",
146
+ "${packageJsonPath}",
141
147
  "{
142
148
  "dependencies": {
143
149
  "@tramvai/core": "1.115.6",
@@ -3,6 +3,7 @@ import fs from 'fs';
3
3
  import pMap from 'p-map';
4
4
  import type { Ora } from 'ora';
5
5
  import ora from 'ora';
6
+ import { resolve } from 'path';
6
7
  import { packageHasVersion } from '../../utils/commands/dependencies/packageHasVersion';
7
8
  import { getLibPackageVersion } from './dependantLibs';
8
9
  import { isDependantLib, isUnifiedVersion } from '../../utils/tramvaiVersions';
@@ -61,21 +62,15 @@ const updateDependencies = (
61
62
  );
62
63
  };
63
64
 
64
- export const updatePackageJson = async (version: string, prerelease?: boolean) => {
65
- const file = fs.readFileSync('package.json');
65
+ export const updatePackageJson = async (
66
+ version: string,
67
+ currentVersion: string,
68
+ prerelease?: boolean,
69
+ path = '.'
70
+ ) => {
71
+ const packageJsonPath = resolve(path, 'package.json');
72
+ const file = fs.readFileSync(packageJsonPath);
66
73
  const content = JSON.parse(file.toString());
67
- const currentVersion = getVersionFromDep(content.dependencies['@tramvai/core']);
68
-
69
- if (!currentVersion) {
70
- throw new Error(
71
- "Couldn't resolve current tramvai version, do you have '@tramvai/core' package in your dependencies?"
72
- );
73
- }
74
-
75
- if (currentVersion === version) {
76
- console.error('The installed version is equal to the current version, no update is required.');
77
- return;
78
- }
79
74
 
80
75
  const spinner = ora(`Updating package.json versions`).start();
81
76
 
@@ -90,7 +85,7 @@ export const updatePackageJson = async (version: string, prerelease?: boolean) =
90
85
  spinner
91
86
  );
92
87
 
93
- fs.writeFileSync('package.json', JSON.stringify(content, null, 2));
88
+ fs.writeFileSync(packageJsonPath, JSON.stringify(content, null, 2));
94
89
  } finally {
95
90
  spinner.stop();
96
91
  }
@@ -25,7 +25,7 @@ export interface Settings<E extends Env> {
25
25
  rootDir?: string;
26
26
  version?: string;
27
27
  buildType?: BuildType;
28
- debug?: boolean;
28
+ debug?: string | boolean;
29
29
  verboseWebpack?: boolean;
30
30
  trace?: boolean;
31
31
  sourceMap?: boolean;
@@ -1,5 +1,3 @@
1
1
  export const extensions = ['.mjs', '.js', '.jsx', '.ts', '.tsx'];
2
2
 
3
- export const DEBUG_ARGV = ['--inspect', '-r', 'source-map-support/register'];
4
-
5
3
  export const TRACE_ARGV = ['--trace-warnings', '--trace-uncaught'];
@@ -0,0 +1,18 @@
1
+ export function getDebugArg(debugEnv: boolean | string | undefined) {
2
+ if (!debugEnv) {
3
+ return [];
4
+ }
5
+
6
+ const sourceMapsArg = ['-r', 'source-map-support/register'];
7
+ const baseDebugArgs = ['--inspect', ...sourceMapsArg];
8
+
9
+ if (debugEnv === 'wait') {
10
+ return ['--inspect-wait', ...sourceMapsArg];
11
+ }
12
+
13
+ if (debugEnv === 'break') {
14
+ return ['--inspect-brk', ...sourceMapsArg];
15
+ }
16
+
17
+ return baseDebugArgs;
18
+ }
@@ -33,6 +33,9 @@ beforeAll(async () => {
33
33
  strictErrorHandle: true,
34
34
  config: {
35
35
  name: 'swc-app',
36
+ webpack: {
37
+ devtool: 'eval',
38
+ },
36
39
  type: 'application',
37
40
  root: './',
38
41
  experiments: {
@@ -45,7 +45,7 @@ export const webpackClientConfig = ({
45
45
 
46
46
  config.mode('development');
47
47
 
48
- config.devtool(configManager.webpack.devtool ?? 'eval');
48
+ config.devtool(configManager.webpack.devtool ?? false);
49
49
 
50
50
  if (configManager.sourceMap) {
51
51
  config.batch(sourcemaps(configManager));
@@ -65,6 +65,50 @@ export const resolveFrameworksPaths = (rootDir: string, frameworksList: string[]
65
65
  return topLevelFrameworkPaths;
66
66
  };
67
67
 
68
+ const tramvaiScopes = ['@tramvai/', '@tramvai-tinkoff/'];
69
+ const tinkoffPackages = [
70
+ '@tinkoff/router',
71
+ '@tinkoff/logger',
72
+ '@tinkoff/dippy',
73
+ '@tinkoff/user-agent',
74
+ '@tinkoff/module-loader-client',
75
+ '@tinkoff/meta-tags-generate',
76
+ '@tinkoff/browser-cookies',
77
+ '@tinkoff/errors',
78
+ '@tinkoff/layout-factory',
79
+ '@tinkoff/url',
80
+ '@tinkoff/roles',
81
+ '@tinkoff/hook-runner',
82
+ '@tinkoff/pubsub',
83
+ '@tinkoff/browser-timings',
84
+ ];
85
+ const tinkoffPackagesSet = new Set(tinkoffPackages);
86
+
87
+ function isTramvaiPackage(packageName: string | undefined) {
88
+ if (!packageName) return false;
89
+
90
+ return (
91
+ tramvaiScopes.some((scope) => packageName.startsWith(scope)) ||
92
+ tinkoffPackagesSet.has(packageName)
93
+ );
94
+ }
95
+
96
+ function normalizePath(packagePath: string) {
97
+ return packagePath.endsWith('/') ? packagePath : `${packagePath}/`;
98
+ }
99
+
100
+ const tramvaiPackagesPaths = [...tramvaiScopes, ...tinkoffPackages].map((packageName) =>
101
+ normalizePath(`/node_modules/${packageName}`)
102
+ );
103
+
104
+ function isTramvaiResource(resource: string | undefined) {
105
+ if (!resource) return false;
106
+
107
+ return tramvaiPackagesPaths.some((tramvaiPackagePath) => resource.includes(tramvaiPackagePath));
108
+ }
109
+
110
+ type CacheGroup = Exclude<Required<SplitChunksOptions>, boolean>['cacheGroups'][string];
111
+
68
112
  // eslint-disable-next-line max-statements
69
113
  export const splitChunksConfig =
70
114
  (configManager: ConfigManager<ApplicationConfigEntry>) => (config: Config) => {
@@ -72,13 +116,13 @@ export const splitChunksConfig =
72
116
 
73
117
  const topLevelFrameworkPaths = resolveFrameworksPaths(rootDir, ['react', 'react-dom']);
74
118
 
75
- const reactCacheGroup: Exclude<Required<SplitChunksOptions>, boolean>['cacheGroups'][string] = {
119
+ const reactCacheGroup: CacheGroup = {
76
120
  chunks: 'all',
77
121
  name: 'react',
78
122
  // This regex ignores nested copies of framework libraries so they're bundled with their issuer.
79
123
  // test: /(?<!node_modules.*)[\\/]node_modules[\\/](react|react-dom|scheduler|prop-types|use-subscription)[\\/]/,
80
124
  test(module: webpack.Module) {
81
- const resource = module.nameForCondition && module.nameForCondition();
125
+ const resource = module.nameForCondition?.();
82
126
 
83
127
  if (!resource) {
84
128
  return false;
@@ -93,6 +137,24 @@ export const splitChunksConfig =
93
137
  // Don't let webpack eliminate this chunk (prevents this chunk from becoming a part of the commons chunk)
94
138
  enforce: true,
95
139
  };
140
+
141
+ const tramvaiCacheGroup: CacheGroup = splitChunks.frameworkChunk
142
+ ? {
143
+ chunks: 'initial',
144
+ name: 'tramvai',
145
+ test(module: webpack.Module) {
146
+ const resource = module.nameForCondition?.();
147
+ const packageName = (module as webpack.NormalModule).resourceResolveData
148
+ ?.descriptionFileData?.name as string | undefined;
149
+
150
+ return isTramvaiPackage(packageName) || isTramvaiResource(resource);
151
+ },
152
+ priority: 35,
153
+ // Don't let webpack eliminate this chunk (prevents this chunk from becoming a part of the commons chunk)
154
+ enforce: true,
155
+ }
156
+ : false;
157
+
96
158
  let webpackSplitChunks: SplitChunksOptions = false;
97
159
 
98
160
  switch (splitChunks.mode) {
@@ -130,6 +192,7 @@ export const splitChunksConfig =
130
192
  default: false,
131
193
  defaultVendors: false,
132
194
  reactCacheGroup,
195
+ tramvaiCacheGroup,
133
196
  shared,
134
197
  },
135
198
  };
@@ -141,6 +204,7 @@ export const splitChunksConfig =
141
204
  default: false,
142
205
  defaultVendors: false,
143
206
  reactCacheGroup,
207
+ tramvaiCacheGroup,
144
208
  commons: {
145
209
  name: 'common-chunk',
146
210
  minChunks: splitChunks.commonChunkSplitNumber,
@@ -9,6 +9,7 @@ import { ModuleFederationIgnoreEntries } from '../plugins/ModuleFederationIgnore
9
9
  import { rootErrorBoundaryFactory } from '../blocks/rootErrorBoundary';
10
10
  import type { ModuleFederationFixRangeOptions } from '../plugins/ModuleFederationFixRange';
11
11
  import { ModuleFederationFixRange } from '../plugins/ModuleFederationFixRange';
12
+ import { FileStatsPlugin } from '../plugins/FileStats';
12
13
 
13
14
  export const commonApplication =
14
15
  (configManager: ConfigManager<ApplicationConfigEntry>) => (config: Config) => {
@@ -19,6 +20,18 @@ export const commonApplication =
19
20
  } as ModuleFederationPluginOptions,
20
21
  ]);
21
22
 
23
+ if (configManager.withModulesStats) {
24
+ config.plugin('stats-modules-plugin').use(FileStatsPlugin, [
25
+ {
26
+ filename: 'stats-modules.json',
27
+ stats: {
28
+ chunks: true,
29
+ chunkModules: true,
30
+ },
31
+ },
32
+ ]);
33
+ }
34
+
22
35
  config
23
36
  .plugin('module-federation-ignore-entries')
24
37
  .use(ModuleFederationIgnoreEntries, [
@@ -36,7 +36,7 @@ export const webpackServerConfig = ({
36
36
 
37
37
  config.mode('development');
38
38
 
39
- config.devtool(configManager.webpack.devtool);
39
+ config.devtool(configManager.webpack.devtool ?? false);
40
40
 
41
41
  if (configManager.sourceMap) {
42
42
  config.batch(sourcemaps(configManager));
@@ -25,6 +25,7 @@ const isApplicable = (configManager: ConfigManager<CliConfigEntry>) => {
25
25
  return (
26
26
  // thread-loader uses child_process.fork under the hood, and sometimes (50/50) work in these processes does not get into inspector.Session profile
27
27
  !process.env.TRAMVAI_CPU_PROFILE &&
28
+ !process.env.TRAMVAI_DEBUG_BUILD &&
28
29
  // TODO: check that there is still issue with windows systems and thread-loader
29
30
  process.platform !== 'win32' &&
30
31
  // swc has inbuilt threads support, see https://swc.rs/blog/perf-swc-vs-babel#real-world-benchmark
@@ -116,6 +116,7 @@ it('should populate defaults for config', () => {
116
116
  "sourceMap": false,
117
117
  "splitChunks": {
118
118
  "commonChunkSplitNumber": 3,
119
+ "frameworkChunk": false,
119
120
  "granularChunksMinSize": 20000,
120
121
  "granularChunksSplitNumber": 2,
121
122
  "mode": "granularChunks",
@@ -126,6 +127,7 @@ it('should populate defaults for config', () => {
126
127
  "transpileOnlyModernLibs": true,
127
128
  "type": "application",
128
129
  "webpack": {},
130
+ "withModulesStats": false,
129
131
  },
130
132
  "child-app": {
131
133
  "cssMinimize": "css-minimizer",
@@ -366,6 +368,7 @@ it('should populate defaults for overridable options', () => {
366
368
  "sourceMap": false,
367
369
  "splitChunks": {
368
370
  "commonChunkSplitNumber": 3,
371
+ "frameworkChunk": false,
369
372
  "granularChunksMinSize": 20000,
370
373
  "granularChunksSplitNumber": 2,
371
374
  "mode": "granularChunks",
@@ -385,6 +388,7 @@ it('should populate defaults for overridable options', () => {
385
388
  "webpack": {
386
389
  "devtool": "eval-source-map",
387
390
  },
391
+ "withModulesStats": false,
388
392
  },
389
393
  "child-app": {
390
394
  "cssMinimize": "css-minimizer",
@@ -1,4 +1,4 @@
1
- import type { PackageManager } from '@tinkoff/package-manager-wrapper';
1
+ import { resolvePackageManager, type PackageManager } from '@tinkoff/package-manager-wrapper';
2
2
  import type { Logger } from './logger';
3
3
  import type { Command, CommandResult } from './command';
4
4
  import type { Task, TaskResult } from './task';
@@ -6,13 +6,14 @@ import type { ConfigManager } from './config';
6
6
  import type { Analytics } from './analytics';
7
7
 
8
8
  export class Context {
9
+ public packageManager: PackageManager;
10
+
9
11
  constructor(
10
12
  public config: ConfigManager,
11
13
  public logger: Logger,
12
14
  public analytics: Analytics,
13
15
  public cliRootDir: string,
14
16
  public cliPackageManager: PackageManager,
15
- public packageManager: PackageManager,
16
17
  public runTask: (name, params?) => Promise<TaskResult>,
17
18
  public runCommand: (name, params?) => Promise<CommandResult>,
18
19
  public getTasks: () => Task[],
@@ -116,6 +116,11 @@
116
116
  "granularChunks"
117
117
  ]
118
118
  },
119
+ "frameworkChunk": {
120
+ "title": "Move tramvai packages into a separate chunk",
121
+ "default": false,
122
+ "type": "boolean"
123
+ },
119
124
  "granularChunksSplitNumber": {
120
125
  "title": "Move module to shared chunk if used at least as many times in other chunks",
121
126
  "default": 2,
@@ -983,6 +988,11 @@
983
988
  },
984
989
  "additionalProperties": false
985
990
  },
991
+ "withModulesStats": {
992
+ "title": "Enable generation of stats modules file for polyfill usage analysis",
993
+ "default": false,
994
+ "type": "boolean"
995
+ },
986
996
  "sourceMap": {
987
997
  "cli_overridable": "",
988
998
  "title": "Enable source maps",
@@ -1227,23 +1237,23 @@
1227
1237
  "dotAll": {
1228
1238
  "type": "boolean"
1229
1239
  },
1230
- "__@match@7341": {
1240
+ "__@match@7843": {
1231
1241
  "type": "object",
1232
1242
  "additionalProperties": false
1233
1243
  },
1234
- "__@replace@7343": {
1244
+ "__@replace@7845": {
1235
1245
  "type": "object",
1236
1246
  "additionalProperties": false
1237
1247
  },
1238
- "__@search@7346": {
1248
+ "__@search@7848": {
1239
1249
  "type": "object",
1240
1250
  "additionalProperties": false
1241
1251
  },
1242
- "__@split@7348": {
1252
+ "__@split@7850": {
1243
1253
  "type": "object",
1244
1254
  "additionalProperties": false
1245
1255
  },
1246
- "__@matchAll@7350": {
1256
+ "__@matchAll@7852": {
1247
1257
  "type": "object",
1248
1258
  "additionalProperties": false
1249
1259
  }
@@ -1275,9 +1285,9 @@
1275
1285
  "eval",
1276
1286
  "eval-cheap-module-source-map",
1277
1287
  "eval-cheap-source-map",
1278
- "eval-source-map"
1279
- ],
1280
- "type": "string"
1288
+ "eval-source-map",
1289
+ false
1290
+ ]
1281
1291
  }
1282
1292
  },
1283
1293
  "additionalProperties": false
@@ -1979,23 +1989,23 @@
1979
1989
  "dotAll": {
1980
1990
  "type": "boolean"
1981
1991
  },
1982
- "__@match@7341": {
1992
+ "__@match@7843": {
1983
1993
  "type": "object",
1984
1994
  "additionalProperties": false
1985
1995
  },
1986
- "__@replace@7343": {
1996
+ "__@replace@7845": {
1987
1997
  "type": "object",
1988
1998
  "additionalProperties": false
1989
1999
  },
1990
- "__@search@7346": {
2000
+ "__@search@7848": {
1991
2001
  "type": "object",
1992
2002
  "additionalProperties": false
1993
2003
  },
1994
- "__@split@7348": {
2004
+ "__@split@7850": {
1995
2005
  "type": "object",
1996
2006
  "additionalProperties": false
1997
2007
  },
1998
- "__@matchAll@7350": {
2008
+ "__@matchAll@7852": {
1999
2009
  "type": "object",
2000
2010
  "additionalProperties": false
2001
2011
  }
@@ -2027,9 +2037,9 @@
2027
2037
  "eval",
2028
2038
  "eval-cheap-module-source-map",
2029
2039
  "eval-cheap-source-map",
2030
- "eval-source-map"
2031
- ],
2032
- "type": "string"
2040
+ "eval-source-map",
2041
+ false
2042
+ ]
2033
2043
  }
2034
2044
  },
2035
2045
  "additionalProperties": false
@@ -2731,23 +2741,23 @@
2731
2741
  "dotAll": {
2732
2742
  "type": "boolean"
2733
2743
  },
2734
- "__@match@7341": {
2744
+ "__@match@7843": {
2735
2745
  "type": "object",
2736
2746
  "additionalProperties": false
2737
2747
  },
2738
- "__@replace@7343": {
2748
+ "__@replace@7845": {
2739
2749
  "type": "object",
2740
2750
  "additionalProperties": false
2741
2751
  },
2742
- "__@search@7346": {
2752
+ "__@search@7848": {
2743
2753
  "type": "object",
2744
2754
  "additionalProperties": false
2745
2755
  },
2746
- "__@split@7348": {
2756
+ "__@split@7850": {
2747
2757
  "type": "object",
2748
2758
  "additionalProperties": false
2749
2759
  },
2750
- "__@matchAll@7350": {
2760
+ "__@matchAll@7852": {
2751
2761
  "type": "object",
2752
2762
  "additionalProperties": false
2753
2763
  }
@@ -2779,9 +2789,9 @@
2779
2789
  "eval",
2780
2790
  "eval-cheap-module-source-map",
2781
2791
  "eval-cheap-source-map",
2782
- "eval-source-map"
2783
- ],
2784
- "type": "string"
2792
+ "eval-source-map",
2793
+ false
2794
+ ]
2785
2795
  }
2786
2796
  },
2787
2797
  "additionalProperties": false
@@ -145,6 +145,7 @@ describe('JSON schema для tramvai.json', () => {
145
145
  "sourceMap": false,
146
146
  "splitChunks": {
147
147
  "commonChunkSplitNumber": 3,
148
+ "frameworkChunk": false,
148
149
  "granularChunksMinSize": 20000,
149
150
  "granularChunksSplitNumber": 2,
150
151
  "mode": "granularChunks",
@@ -155,6 +156,7 @@ describe('JSON schema для tramvai.json', () => {
155
156
  "transpileOnlyModernLibs": true,
156
157
  "type": "application",
157
158
  "webpack": {},
159
+ "withModulesStats": false,
158
160
  },
159
161
  "module": {
160
162
  "cssMinimize": "css-minimizer",
@@ -189,6 +189,11 @@ export interface ApplicationConfigEntry extends CliConfigEntry {
189
189
  * @default "granularChunks"
190
190
  */
191
191
  mode: 'granularChunks' | 'commonChunk' | false;
192
+ /**
193
+ * @title Move tramvai packages into a separate chunk
194
+ * @default false
195
+ */
196
+ frameworkChunk: boolean;
192
197
  /**
193
198
  * @title Move module to shared chunk if used at least as many times in other chunks
194
199
  * @default 2
@@ -221,4 +226,10 @@ export interface ApplicationConfigEntry extends CliConfigEntry {
221
226
  * @default {}
222
227
  */
223
228
  experiments: ApplicationExperiments;
229
+
230
+ /**
231
+ * @title Enable generation of stats modules file for polyfill usage analysis
232
+ * @default false
233
+ */
234
+ withModulesStats: boolean;
224
235
  }
@@ -251,7 +251,12 @@ export interface CliConfigEntry extends ConfigEntry {
251
251
  /**
252
252
  * @title Use the specified type of source maps for building in development mode
253
253
  */
254
- devtool: 'eval' | 'eval-cheap-source-map' | 'eval-cheap-module-source-map' | 'eval-source-map';
254
+ devtool:
255
+ | false
256
+ | 'eval'
257
+ | 'eval-cheap-source-map'
258
+ | 'eval-cheap-module-source-map'
259
+ | 'eval-source-map';
255
260
  };
256
261
 
257
262
  // options that affect only production builds
@@ -434,6 +434,7 @@ declare module 'webpack-chain' {
434
434
  }
435
435
 
436
436
  type DevTool =
437
+ | boolean
437
438
  | 'eval'
438
439
  | 'eval-cheap-source-map'
439
440
  | 'eval-cheap-module-source-map'
@@ -10,7 +10,7 @@ const getVersionFromDep = (dep?: string) => {
10
10
  export const findTramvaiVersion = async () => {
11
11
  const file = fs.readFileSync('package.json');
12
12
  const content = JSON.parse(file.toString());
13
- const currentVersion = getVersionFromDep(content.dependencies['@tramvai/core']);
13
+ const currentVersion = getVersionFromDep(content.devDependencies['@tramvai/cli']);
14
14
 
15
15
  return currentVersion;
16
16
  };