@tramvai/cli 6.79.13 → 6.79.16
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/lib/api/analyze/index.d.ts +1 -1
- package/lib/api/analyze/index.d.ts.map +1 -1
- package/lib/api/start/index.d.ts +1 -1
- package/lib/api/start/index.d.ts.map +1 -1
- package/lib/builder/webpack/analyzePlugins/bundle.d.ts +1 -1
- package/lib/builder/webpack/analyzePlugins/bundle.js +1 -1
- package/lib/builder/webpack/analyzePlugins/bundle.js.map +1 -1
- package/lib/builder/webpack/analyzePlugins/rsdoctor.d.ts +0 -4
- package/lib/builder/webpack/analyzePlugins/rsdoctor.d.ts.map +1 -1
- package/lib/builder/webpack/analyzePlugins/rsdoctor.js +0 -1
- package/lib/builder/webpack/analyzePlugins/rsdoctor.js.map +1 -1
- package/lib/builder/webpack/analyzePlugins/statoscope.d.ts +3 -7
- package/lib/builder/webpack/analyzePlugins/statoscope.d.ts.map +1 -1
- package/lib/builder/webpack/analyzePlugins/statoscope.js +6 -26
- package/lib/builder/webpack/analyzePlugins/statoscope.js.map +1 -1
- package/lib/builder/webpack/analyzePlugins/stats.d.ts +12 -0
- package/lib/builder/webpack/analyzePlugins/stats.d.ts.map +1 -0
- package/lib/builder/webpack/analyzePlugins/stats.js +40 -0
- package/lib/builder/webpack/analyzePlugins/stats.js.map +1 -0
- package/lib/builder/webpack/analyzePlugins/whyBundled.d.ts +1 -1
- package/lib/builder/webpack/analyzePlugins/whyBundled.d.ts.map +1 -1
- package/lib/builder/webpack/analyzePlugins/whyBundled.js +1 -1
- package/lib/builder/webpack/analyzePlugins/whyBundled.js.map +1 -1
- package/lib/builder/webpack/providers/build/server.d.ts.map +1 -1
- package/lib/builder/webpack/providers/build/server.js +5 -2
- package/lib/builder/webpack/providers/build/server.js.map +1 -1
- package/lib/builder/webpack/providers/shared.d.ts.map +1 -1
- package/lib/builder/webpack/providers/shared.js +2 -0
- package/lib/builder/webpack/providers/shared.js.map +1 -1
- package/lib/builder/webpack/providers/start/shared.d.ts.map +1 -1
- package/lib/builder/webpack/providers/start/shared.js +10 -4
- package/lib/builder/webpack/providers/start/shared.js.map +1 -1
- package/lib/builder/webpack/types.d.ts +2 -1
- package/lib/builder/webpack/types.d.ts.map +1 -1
- package/lib/builder/webpack/types.js +3 -1
- package/lib/builder/webpack/types.js.map +1 -1
- package/lib/commands/analyze/command.js +1 -1
- package/lib/commands/analyze/command.js.map +1 -1
- package/lib/commands/build/command.d.ts.map +1 -1
- package/lib/commands/build/command.js +6 -1
- package/lib/commands/build/command.js.map +1 -1
- package/lib/commands/start/command.js +1 -1
- package/lib/commands/start/command.js.map +1 -1
- package/lib/config/configManager.d.ts +2 -1
- package/lib/config/configManager.d.ts.map +1 -1
- package/lib/config/configManager.js +1 -0
- package/lib/config/configManager.js.map +1 -1
- package/lib/library/webpack/application/client/dev.js +5 -5
- package/lib/library/webpack/application/client/dev.js.map +1 -1
- package/lib/library/webpack/application/client/prod.js +2 -2
- package/lib/library/webpack/application/client/prod.js.map +1 -1
- package/lib/library/webpack/application/server/dev.d.ts.map +1 -1
- package/lib/library/webpack/application/server/dev.js +2 -2
- package/lib/library/webpack/application/server/dev.js.map +1 -1
- package/lib/library/webpack/application/server/prod.d.ts.map +1 -1
- package/lib/library/webpack/application/server/prod.js +2 -2
- package/lib/library/webpack/application/server/prod.js.map +1 -1
- package/lib/library/webpack/blocks/optimize.d.ts.map +1 -1
- package/lib/library/webpack/blocks/optimize.js +7 -1
- package/lib/library/webpack/blocks/optimize.js.map +1 -1
- package/lib/library/webpack/child-app/common.d.ts.map +1 -1
- package/lib/library/webpack/child-app/common.js +2 -10
- package/lib/library/webpack/child-app/common.js.map +1 -1
- package/lib/library/webpack/child-app/server/common.d.ts.map +1 -1
- package/lib/library/webpack/child-app/server/common.js +2 -2
- package/lib/library/webpack/child-app/server/common.js.map +1 -1
- package/lib/library/webpack/common/main.js +1 -1
- package/lib/library/webpack/common/main.js.map +1 -1
- package/lib/library/webpack/module/common.d.ts.map +1 -1
- package/lib/library/webpack/module/common.js +2 -2
- package/lib/library/webpack/module/common.js.map +1 -1
- package/lib/schema/autogeneratedSchema.json +15 -15
- package/package.json +8 -7
- package/schema.json +15 -15
- package/src/api/analyze/index.ts +1 -1
- package/src/api/build/__integration__/build.test.ts +8 -8
- package/src/api/start/index.ts +1 -1
- package/src/builder/webpack/analyzePlugins/bundle.ts +1 -1
- package/src/builder/webpack/analyzePlugins/rsdoctor.ts +0 -2
- package/src/builder/webpack/analyzePlugins/statoscope.ts +8 -40
- package/src/builder/webpack/analyzePlugins/stats.ts +45 -0
- package/src/builder/webpack/analyzePlugins/whyBundled.ts +1 -1
- package/src/builder/webpack/providers/build/server.ts +7 -2
- package/src/builder/webpack/providers/shared.ts +2 -0
- package/src/builder/webpack/providers/start/shared.ts +10 -4
- package/src/builder/webpack/types.ts +5 -2
- package/src/commands/analyze/command.ts +1 -1
- package/src/commands/build/command.ts +6 -1
- package/src/commands/start/command.ts +1 -1
- package/src/config/configManager.ts +3 -1
- package/src/library/swc/__integration__/__snapshots__/swc.build.test.ts.snap +14 -14
- package/src/library/swc/__integration__/__snapshots__/swc.start.test.ts.snap +30 -30
- package/src/library/swc/__integration__/swc.build.test.ts +1 -1
- package/src/library/swc/__integration__/swc.start.test.ts +1 -1
- package/src/library/webpack/application/client/dev.ts +4 -4
- package/src/library/webpack/application/client/prod.ts +1 -1
- package/src/library/webpack/application/server/dev.ts +2 -1
- package/src/library/webpack/application/server/prod.ts +2 -1
- package/src/library/webpack/blocks/optimize.ts +8 -1
- package/src/library/webpack/child-app/common.ts +2 -10
- package/src/library/webpack/child-app/server/common.ts +2 -1
- package/src/library/webpack/common/main.ts +1 -1
- package/src/library/webpack/module/common.ts +3 -1
- package/src/schema/autogeneratedSchema.json +15 -15
- package/lib/library/webpack/plugins/RuntimePathPlugin.d.ts +0 -15
- package/lib/library/webpack/plugins/RuntimePathPlugin.d.ts.map +0 -1
- package/lib/library/webpack/plugins/RuntimePathPlugin.js +0 -42
- package/lib/library/webpack/plugins/RuntimePathPlugin.js.map +0 -1
- package/src/library/webpack/plugins/RuntimePathPlugin.ts +0 -59
package/schema.json
CHANGED
|
@@ -1378,23 +1378,23 @@
|
|
|
1378
1378
|
"dotAll": {
|
|
1379
1379
|
"type": "boolean"
|
|
1380
1380
|
},
|
|
1381
|
-
"__@match@
|
|
1381
|
+
"__@match@9031": {
|
|
1382
1382
|
"type": "object",
|
|
1383
1383
|
"additionalProperties": false
|
|
1384
1384
|
},
|
|
1385
|
-
"__@replace@
|
|
1385
|
+
"__@replace@9033": {
|
|
1386
1386
|
"type": "object",
|
|
1387
1387
|
"additionalProperties": false
|
|
1388
1388
|
},
|
|
1389
|
-
"__@search@
|
|
1389
|
+
"__@search@9036": {
|
|
1390
1390
|
"type": "object",
|
|
1391
1391
|
"additionalProperties": false
|
|
1392
1392
|
},
|
|
1393
|
-
"__@split@
|
|
1393
|
+
"__@split@9038": {
|
|
1394
1394
|
"type": "object",
|
|
1395
1395
|
"additionalProperties": false
|
|
1396
1396
|
},
|
|
1397
|
-
"__@matchAll@
|
|
1397
|
+
"__@matchAll@9040": {
|
|
1398
1398
|
"type": "object",
|
|
1399
1399
|
"additionalProperties": false
|
|
1400
1400
|
}
|
|
@@ -2254,23 +2254,23 @@
|
|
|
2254
2254
|
"dotAll": {
|
|
2255
2255
|
"type": "boolean"
|
|
2256
2256
|
},
|
|
2257
|
-
"__@match@
|
|
2257
|
+
"__@match@9031": {
|
|
2258
2258
|
"type": "object",
|
|
2259
2259
|
"additionalProperties": false
|
|
2260
2260
|
},
|
|
2261
|
-
"__@replace@
|
|
2261
|
+
"__@replace@9033": {
|
|
2262
2262
|
"type": "object",
|
|
2263
2263
|
"additionalProperties": false
|
|
2264
2264
|
},
|
|
2265
|
-
"__@search@
|
|
2265
|
+
"__@search@9036": {
|
|
2266
2266
|
"type": "object",
|
|
2267
2267
|
"additionalProperties": false
|
|
2268
2268
|
},
|
|
2269
|
-
"__@split@
|
|
2269
|
+
"__@split@9038": {
|
|
2270
2270
|
"type": "object",
|
|
2271
2271
|
"additionalProperties": false
|
|
2272
2272
|
},
|
|
2273
|
-
"__@matchAll@
|
|
2273
|
+
"__@matchAll@9040": {
|
|
2274
2274
|
"type": "object",
|
|
2275
2275
|
"additionalProperties": false
|
|
2276
2276
|
}
|
|
@@ -3130,23 +3130,23 @@
|
|
|
3130
3130
|
"dotAll": {
|
|
3131
3131
|
"type": "boolean"
|
|
3132
3132
|
},
|
|
3133
|
-
"__@match@
|
|
3133
|
+
"__@match@9031": {
|
|
3134
3134
|
"type": "object",
|
|
3135
3135
|
"additionalProperties": false
|
|
3136
3136
|
},
|
|
3137
|
-
"__@replace@
|
|
3137
|
+
"__@replace@9033": {
|
|
3138
3138
|
"type": "object",
|
|
3139
3139
|
"additionalProperties": false
|
|
3140
3140
|
},
|
|
3141
|
-
"__@search@
|
|
3141
|
+
"__@search@9036": {
|
|
3142
3142
|
"type": "object",
|
|
3143
3143
|
"additionalProperties": false
|
|
3144
3144
|
},
|
|
3145
|
-
"__@split@
|
|
3145
|
+
"__@split@9038": {
|
|
3146
3146
|
"type": "object",
|
|
3147
3147
|
"additionalProperties": false
|
|
3148
3148
|
},
|
|
3149
|
-
"__@matchAll@
|
|
3149
|
+
"__@matchAll@9040": {
|
|
3150
3150
|
"type": "object",
|
|
3151
3151
|
"additionalProperties": false
|
|
3152
3152
|
}
|
package/src/api/analyze/index.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { createCommand } from '../../commands/createCommand';
|
|
|
3
3
|
|
|
4
4
|
export interface Params {
|
|
5
5
|
target: string;
|
|
6
|
-
plugin?: 'bundle' | 'whybundled' | 'statoscope';
|
|
6
|
+
plugin?: 'bundle' | 'whybundled' | 'statoscope' | 'stats' | 'rsdoctor';
|
|
7
7
|
showConfig?: boolean;
|
|
8
8
|
fileCache?: boolean;
|
|
9
9
|
verboseWebpack?: boolean;
|
|
@@ -27,13 +27,13 @@ describe('@tramvai/cli build command', () => {
|
|
|
27
27
|
|
|
28
28
|
expect(normalizeFiles(clientFiles)).toMatchInlineSnapshot(`
|
|
29
29
|
[
|
|
30
|
+
"app_bundles_first_ts.js",
|
|
31
|
+
"app_bundles_main_ts.js",
|
|
32
|
+
"app_bundles_second_ts.js",
|
|
33
|
+
"app_bundles_third_ts.js",
|
|
30
34
|
"platform.css",
|
|
31
35
|
"platform.js",
|
|
32
36
|
"react.js",
|
|
33
|
-
"src_api_build___integration_____fixtures___app_bundles_first_ts.js",
|
|
34
|
-
"src_api_build___integration_____fixtures___app_bundles_main_ts.js",
|
|
35
|
-
"src_api_build___integration_____fixtures___app_bundles_second_ts.js",
|
|
36
|
-
"src_api_build___integration_____fixtures___app_bundles_third_ts.js",
|
|
37
37
|
"stats.json",
|
|
38
38
|
]
|
|
39
39
|
`);
|
|
@@ -69,13 +69,13 @@ describe('@tramvai/cli build command', () => {
|
|
|
69
69
|
|
|
70
70
|
expect(normalizeFiles(clientFiles)).toMatchInlineSnapshot(`
|
|
71
71
|
[
|
|
72
|
+
"app_bundles_first_ts.js",
|
|
73
|
+
"app_bundles_main_ts.js",
|
|
74
|
+
"app_bundles_second_ts.js",
|
|
75
|
+
"app_bundles_third_ts.js",
|
|
72
76
|
"platform.css",
|
|
73
77
|
"platform.js",
|
|
74
78
|
"react.js",
|
|
75
|
-
"src_api_build___integration_____fixtures___app_bundles_first_ts.js",
|
|
76
|
-
"src_api_build___integration_____fixtures___app_bundles_main_ts.js",
|
|
77
|
-
"src_api_build___integration_____fixtures___app_bundles_second_ts.js",
|
|
78
|
-
"src_api_build___integration_____fixtures___app_bundles_third_ts.js",
|
|
79
79
|
"stats.json",
|
|
80
80
|
]
|
|
81
81
|
`);
|
package/src/api/start/index.ts
CHANGED
|
@@ -24,7 +24,7 @@ export type Params = WithConfig<{
|
|
|
24
24
|
noClientRebuild?: boolean;
|
|
25
25
|
resolveSymlinks?: boolean;
|
|
26
26
|
showConfig?: boolean;
|
|
27
|
-
analyze?: false | 'bundle' | 'whybundled' | 'statoscope' | 'rsdoctor';
|
|
27
|
+
analyze?: false | 'bundle' | 'whybundled' | 'statoscope' | 'rsdoctor' | 'stats';
|
|
28
28
|
benchmark?: boolean;
|
|
29
29
|
withBuildStats?: boolean;
|
|
30
30
|
// @todo: not working?
|
|
@@ -5,8 +5,6 @@ type options = ConstructorParameters<typeof RsdoctorWebpackPlugin<[]>>;
|
|
|
5
5
|
export class RsdoctorAnalyzePlugin extends AnalyzePlugin {
|
|
6
6
|
requireDeps = [];
|
|
7
7
|
|
|
8
|
-
options: options = [];
|
|
9
|
-
|
|
10
8
|
// rsdoctor поднимает dev server
|
|
11
9
|
afterBuild = () => new Promise(() => null);
|
|
12
10
|
|
|
@@ -1,50 +1,18 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type StatoscopeWebpackPlugin from '@statoscope/webpack-plugin';
|
|
2
|
+
|
|
2
3
|
import { AnalyzePlugin } from '../types';
|
|
3
|
-
import type { FileStatsOptions } from '../../../library/webpack/plugins/FileStats';
|
|
4
|
-
import { FileStatsPlugin } from '../../../library/webpack/plugins/FileStats';
|
|
5
4
|
|
|
6
5
|
export class StatoscopeAnalyzePlugin extends AnalyzePlugin {
|
|
7
|
-
statsFileName = 'stats-all.json';
|
|
8
|
-
|
|
9
6
|
requireDeps = [];
|
|
10
7
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
options: [FileStatsOptions] = [
|
|
8
|
+
options = (): ConstructorParameters<typeof StatoscopeWebpackPlugin> => [
|
|
14
9
|
{
|
|
15
|
-
|
|
16
|
-
stats: {
|
|
17
|
-
hash: true, // add compilation hash
|
|
18
|
-
entrypoints: true, // add entrypoints stats
|
|
19
|
-
chunks: true, // add chunks stats
|
|
20
|
-
chunkModules: true, // add modules stats
|
|
21
|
-
reasons: true, // add modules reasons stats
|
|
22
|
-
|
|
23
|
-
assets: true, // add assets stats
|
|
24
|
-
chunkOrigins: true, // add chunks origins stats (to find out which modules require a chunk)
|
|
25
|
-
version: true, // add webpack version
|
|
26
|
-
builtAt: true, // add build at time
|
|
27
|
-
timings: true, // add build at time
|
|
28
|
-
performance: true, // add info about oversized assets
|
|
29
|
-
source: true, // add module sources (uses to find modules duplicates)
|
|
30
|
-
},
|
|
10
|
+
statsOptions: { all: true },
|
|
31
11
|
},
|
|
32
12
|
];
|
|
33
13
|
|
|
34
|
-
plugin
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
chalk.yellow(
|
|
39
|
-
`Приложение собралось и корне проекта доступен файл со всей информацией по приложению в файле ${this.statsFileName}`
|
|
40
|
-
)
|
|
41
|
-
);
|
|
42
|
-
console.log(
|
|
43
|
-
chalk.green(
|
|
44
|
-
`Далее необходимо зайти на страницу https://statoscope.tech/ и drag-on-drop перенести файл из клиентских ассетов ${this.statsFileName}`
|
|
45
|
-
)
|
|
46
|
-
);
|
|
47
|
-
|
|
48
|
-
return Promise.resolve();
|
|
49
|
-
};
|
|
14
|
+
get plugin() {
|
|
15
|
+
// eslint-disable-next-line import/no-unresolved
|
|
16
|
+
return require('@statoscope/webpack-plugin').default;
|
|
17
|
+
}
|
|
50
18
|
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
import { AnalyzePlugin } from '../types';
|
|
3
|
+
import type { FileStatsOptions } from '../../../library/webpack/plugins/FileStats';
|
|
4
|
+
import { FileStatsPlugin } from '../../../library/webpack/plugins/FileStats';
|
|
5
|
+
|
|
6
|
+
export class StatsAnalyzePlugin extends AnalyzePlugin {
|
|
7
|
+
statsFileName = 'stats-all.json';
|
|
8
|
+
|
|
9
|
+
requireDeps = [];
|
|
10
|
+
|
|
11
|
+
statsFilePath: string;
|
|
12
|
+
|
|
13
|
+
options = (): [FileStatsOptions] => [
|
|
14
|
+
{
|
|
15
|
+
filename: this.statsFileName,
|
|
16
|
+
stats: {
|
|
17
|
+
hash: true, // add compilation hash
|
|
18
|
+
entrypoints: true, // add entrypoints stats
|
|
19
|
+
chunks: true, // add chunks stats
|
|
20
|
+
chunkModules: true, // add modules stats
|
|
21
|
+
reasons: true, // add modules reasons stats
|
|
22
|
+
|
|
23
|
+
assets: true, // add assets stats
|
|
24
|
+
chunkOrigins: true, // add chunks origins stats (to find out which modules require a chunk)
|
|
25
|
+
version: true, // add webpack version
|
|
26
|
+
builtAt: true, // add build at time
|
|
27
|
+
timings: true, // add build at time
|
|
28
|
+
performance: true, // add info about oversized assets
|
|
29
|
+
source: true, // add module sources (uses to find modules duplicates)
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
];
|
|
33
|
+
|
|
34
|
+
plugin = FileStatsPlugin;
|
|
35
|
+
|
|
36
|
+
afterBuild = () => {
|
|
37
|
+
console.log(
|
|
38
|
+
chalk.yellow(
|
|
39
|
+
`Сборка завершилась успешна, сгенерирвао файл с информацией о сборке ${this.statsFileName}`
|
|
40
|
+
)
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
return Promise.resolve();
|
|
44
|
+
};
|
|
45
|
+
}
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
PROCESS_HANDLER_TOKEN,
|
|
10
10
|
SERVER_CONFIG_MANAGER_TOKEN,
|
|
11
11
|
WEBPACK_ANALYZE_PLUGIN_TOKEN,
|
|
12
|
+
WEBPACK_CLIENT_CONFIG_TOKEN,
|
|
12
13
|
WEBPACK_SERVER_COMPILER_TOKEN,
|
|
13
14
|
WEBPACK_SERVER_CONFIG_TOKEN,
|
|
14
15
|
} from '../../tokens';
|
|
@@ -19,15 +20,19 @@ import { createCompiler } from '../../utils/compiler';
|
|
|
19
20
|
export const buildServerProviders: Provider[] = [
|
|
20
21
|
provide({
|
|
21
22
|
provide: WEBPACK_SERVER_COMPILER_TOKEN,
|
|
22
|
-
useFactory: ({ webpackConfig, di, analyzePlugin }) => {
|
|
23
|
+
useFactory: ({ webpackConfig, di, analyzePlugin, clientConfig }) => {
|
|
24
|
+
// analyze server only if no client build found
|
|
25
|
+
const shouldAnalyze = !clientConfig && analyzePlugin;
|
|
26
|
+
|
|
23
27
|
return createCompiler(
|
|
24
|
-
toWebpackConfig(
|
|
28
|
+
toWebpackConfig(shouldAnalyze ? analyzePlugin.patchConfig(webpackConfig) : webpackConfig),
|
|
25
29
|
di
|
|
26
30
|
);
|
|
27
31
|
},
|
|
28
32
|
deps: {
|
|
29
33
|
webpackConfig: WEBPACK_SERVER_CONFIG_TOKEN,
|
|
30
34
|
di: DI_TOKEN,
|
|
35
|
+
clientConfig: { token: WEBPACK_CLIENT_CONFIG_TOKEN, optional: true },
|
|
31
36
|
analyzePlugin: { token: WEBPACK_ANALYZE_PLUGIN_TOKEN, optional: true },
|
|
32
37
|
},
|
|
33
38
|
}),
|
|
@@ -19,6 +19,7 @@ import { BundleAnalyzePlugin } from '../analyzePlugins/bundle';
|
|
|
19
19
|
import { StatoscopeAnalyzePlugin } from '../analyzePlugins/statoscope';
|
|
20
20
|
import { WhyBundledAnalyzePlugin } from '../analyzePlugins/whyBundled';
|
|
21
21
|
import { RsdoctorAnalyzePlugin } from '../analyzePlugins/rsdoctor';
|
|
22
|
+
import { StatsAnalyzePlugin } from '../analyzePlugins/stats';
|
|
22
23
|
import type { AnalyzePlugin } from '../types';
|
|
23
24
|
|
|
24
25
|
interface Type<T> extends Function {
|
|
@@ -29,6 +30,7 @@ const pluginMap: Record<string, Type<AnalyzePlugin>> = {
|
|
|
29
30
|
bundle: BundleAnalyzePlugin,
|
|
30
31
|
whybundled: WhyBundledAnalyzePlugin,
|
|
31
32
|
statoscope: StatoscopeAnalyzePlugin,
|
|
33
|
+
stats: StatsAnalyzePlugin,
|
|
32
34
|
rsdoctor: RsdoctorAnalyzePlugin,
|
|
33
35
|
};
|
|
34
36
|
|
|
@@ -18,10 +18,16 @@ export const startSharedProviders: Provider[] = [
|
|
|
18
18
|
provide({
|
|
19
19
|
provide: WEBPACK_COMPILER_TOKEN,
|
|
20
20
|
useFactory: ({ clientConfig, serverConfig, analyzePlugin }) => {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
if (analyzePlugin) {
|
|
22
|
+
// analyze server only if no client build found
|
|
23
|
+
if (clientConfig) {
|
|
24
|
+
analyzePlugin.patchConfig(clientConfig);
|
|
25
|
+
} else {
|
|
26
|
+
analyzePlugin.patchConfig(serverConfig);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const configs = [clientConfig, serverConfig].filter(Boolean).map(toWebpackConfig);
|
|
25
31
|
const multiCompiler = webpack(configs);
|
|
26
32
|
const { inputFileSystem } = multiCompiler.compilers[0];
|
|
27
33
|
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type Config from 'webpack-chain';
|
|
2
|
+
import { Configuration } from 'webpack';
|
|
3
|
+
|
|
2
4
|
import type { ConfigManager } from '../../config/configManager';
|
|
3
5
|
|
|
4
6
|
export type ConfigGenerator = (arg: {
|
|
@@ -9,7 +11,7 @@ export type ConfigGenerator = (arg: {
|
|
|
9
11
|
export abstract class AnalyzePlugin {
|
|
10
12
|
requireDeps?: string[];
|
|
11
13
|
|
|
12
|
-
protected options
|
|
14
|
+
protected options?: (webpackConfig: Configuration) => any[] = () => [];
|
|
13
15
|
|
|
14
16
|
protected abstract plugin;
|
|
15
17
|
|
|
@@ -24,7 +26,8 @@ export abstract class AnalyzePlugin {
|
|
|
24
26
|
};
|
|
25
27
|
|
|
26
28
|
protected patchConfigInternal(config: Config): Config {
|
|
27
|
-
config.
|
|
29
|
+
const pureWebpackConfig = config.toConfig();
|
|
30
|
+
config.plugin('analyze').use(this.plugin, this.options(pureWebpackConfig));
|
|
28
31
|
|
|
29
32
|
return config;
|
|
30
33
|
}
|
|
@@ -17,7 +17,7 @@ class AnalyzeCommand extends CLICommand<Params> {
|
|
|
17
17
|
{
|
|
18
18
|
name: '-p, --plugin',
|
|
19
19
|
value: '[plugin]',
|
|
20
|
-
description: 'Analysis plugin type <bundle|whybundled|statoscope|rsdoctor>',
|
|
20
|
+
description: 'Analysis plugin type <bundle|whybundled|statoscope|rsdoctor|stats>',
|
|
21
21
|
defaultValue: 'bundle',
|
|
22
22
|
},
|
|
23
23
|
{
|
|
@@ -32,6 +32,11 @@ class BuildCommand extends CLICommand<Params> {
|
|
|
32
32
|
value: '[disableProdOptimization]',
|
|
33
33
|
description: 'Disable optimization of bundle sizes for production (minification, etc.)',
|
|
34
34
|
},
|
|
35
|
+
{
|
|
36
|
+
name: '--readableOutput',
|
|
37
|
+
value: '[readableOutput]',
|
|
38
|
+
description: 'Disable hashed names and concatenated modules for better debug/analyze purpose',
|
|
39
|
+
},
|
|
35
40
|
{
|
|
36
41
|
name: '--showConfig',
|
|
37
42
|
value: '[showConfig]',
|
|
@@ -51,7 +56,7 @@ class BuildCommand extends CLICommand<Params> {
|
|
|
51
56
|
name: '--analyze',
|
|
52
57
|
value: '[analyze]',
|
|
53
58
|
description:
|
|
54
|
-
'Run build with analyze, supported plugins: <bundle|whybundled|statoscope|rsdoctor>',
|
|
59
|
+
'Run build with analyze, supported plugins: <bundle|whybundled|statoscope|rsdoctor|stats>',
|
|
55
60
|
},
|
|
56
61
|
{
|
|
57
62
|
name: '--fileCache',
|
|
@@ -92,7 +92,7 @@ export class StartCommand extends CLICommand<Params> {
|
|
|
92
92
|
name: '--analyze',
|
|
93
93
|
value: '[analyze]',
|
|
94
94
|
description:
|
|
95
|
-
'Run build with analyze, supported plugins: <bundle|whybundled|statoscope|rsdoctor>',
|
|
95
|
+
'Run build with analyze, supported plugins: <bundle|whybundled|statoscope|rsdoctor|stats>',
|
|
96
96
|
},
|
|
97
97
|
{
|
|
98
98
|
name: '--onlyBundles',
|
|
@@ -41,8 +41,9 @@ export interface Settings<E extends Env> {
|
|
|
41
41
|
resolveSymlinks?: boolean;
|
|
42
42
|
showConfig?: boolean;
|
|
43
43
|
onlyBundles?: string[];
|
|
44
|
-
analyze?: false | 'bundle' | 'whybundled' | 'statoscope' | 'rsdoctor';
|
|
44
|
+
analyze?: false | 'bundle' | 'whybundled' | 'statoscope' | 'rsdoctor' | 'stats';
|
|
45
45
|
disableProdOptimization?: boolean;
|
|
46
|
+
readableOutput?: boolean;
|
|
46
47
|
fileCache?: boolean;
|
|
47
48
|
}
|
|
48
49
|
|
|
@@ -136,6 +137,7 @@ export const createConfigManager = <C extends ConfigEntry = ConfigEntry, E exten
|
|
|
136
137
|
benchmark: false,
|
|
137
138
|
resolveSymlinks: true,
|
|
138
139
|
disableProdOptimization: false,
|
|
140
|
+
readableOutput: false,
|
|
139
141
|
analyze: false,
|
|
140
142
|
onlyBundles: [],
|
|
141
143
|
// according to measures fileCache in webpack doesn't affect
|
|
@@ -8,7 +8,7 @@ exports[`client: create-token-pure.ts 1`] = `
|
|
|
8
8
|
/* binding */ return TEST_TOKEN;
|
|
9
9
|
}
|
|
10
10
|
/* harmony export */ });
|
|
11
|
-
const TEST_TOKEN = /*#__PURE__*/ /*#__PURE__*/ (0, __webpack_require__("./
|
|
11
|
+
const TEST_TOKEN = /*#__PURE__*/ /*#__PURE__*/ (0, __webpack_require__("./mocks/tramvai-core.ts").E)("TEST_TOKEN");
|
|
12
12
|
"
|
|
13
13
|
`;
|
|
14
14
|
|
|
@@ -73,7 +73,7 @@ exports[`client: lazy-component.tsx 1`] = `
|
|
|
73
73
|
}
|
|
74
74
|
/* harmony export */ });
|
|
75
75
|
/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("webpack/sharing/consume/default/react/jsx-runtime/react/jsx-runtime");
|
|
76
|
-
/* harmony import */ const LazyComponent = (0, __webpack_require__("./
|
|
76
|
+
/* harmony import */ const LazyComponent = (0, __webpack_require__("./mocks/tramvai-react.ts").R)({
|
|
77
77
|
chunkName: () => "components-lazy-inner",
|
|
78
78
|
requireSync(props) {
|
|
79
79
|
return __webpack_require__(this.resolve(props));
|
|
@@ -82,11 +82,11 @@ exports[`client: lazy-component.tsx 1`] = `
|
|
|
82
82
|
const key = this.resolve(props);
|
|
83
83
|
return !!__webpack_require__.m[key];
|
|
84
84
|
},
|
|
85
|
-
importAsync: () => __webpack_require__.e(/* import() | components-lazy-inner */ "components-lazy-inner").then(__webpack_require__.bind(__webpack_require__, "./
|
|
85
|
+
importAsync: () => __webpack_require__.e(/* import() | components-lazy-inner */ "components-lazy-inner").then(__webpack_require__.bind(__webpack_require__, "./components/lazy-inner.tsx")),
|
|
86
86
|
requireAsync(props) {
|
|
87
87
|
return this.importAsync(props).then(resolved => resolved);
|
|
88
88
|
},
|
|
89
|
-
resolve: () => /*require.resolve*/ "./
|
|
89
|
+
resolve: () => /*require.resolve*/ "./components/lazy-inner.tsx"
|
|
90
90
|
}), Component = () => /*#__PURE__*/ /*#__PURE__*/ (0, react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.Fragment, {
|
|
91
91
|
children: [
|
|
92
92
|
/*#__PURE__*/
|
|
@@ -121,7 +121,7 @@ exports[`client: provider-stack.ts 1`] = `
|
|
|
121
121
|
/* binding */ return providers;
|
|
122
122
|
}
|
|
123
123
|
/* harmony export */ });
|
|
124
|
-
/* harmony import */ var _tramvai_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./
|
|
124
|
+
/* harmony import */ var _tramvai_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./mocks/tramvai-core.ts"), _create_token_pure__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("./create-token-pure.ts");
|
|
125
125
|
/* harmony import */ const providers = [ (0, _tramvai_core__WEBPACK_IMPORTED_MODULE_0__ /* .provide */ .G)({
|
|
126
126
|
provide: _create_token_pure__WEBPACK_IMPORTED_MODULE_1__.TEST_TOKEN,
|
|
127
127
|
useValue: "test"
|
|
@@ -137,7 +137,7 @@ exports[`client: react-svg.tsx 1`] = `
|
|
|
137
137
|
/* binding */ return Component;
|
|
138
138
|
}
|
|
139
139
|
/* harmony export */ });
|
|
140
|
-
/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("webpack/sharing/consume/default/react/jsx-runtime/react/jsx-runtime"), _images_logo_svg_react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("./
|
|
140
|
+
/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("webpack/sharing/consume/default/react/jsx-runtime/react/jsx-runtime"), _images_logo_svg_react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("./images/logo.svg?react");
|
|
141
141
|
/* harmony import */ const Component = () => /*#__PURE__*/ /*#__PURE__*/ (0,
|
|
142
142
|
react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("div", {
|
|
143
143
|
children: /*#__PURE__*/ /*#__PURE__*/ (0 /* ["default"] */ , react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_images_logo_svg_react__WEBPACK_IMPORTED_MODULE_1__.A, {})
|
|
@@ -153,7 +153,7 @@ exports[`client: server.inline.ts 1`] = `
|
|
|
153
153
|
/* binding */ return ForBrowser;
|
|
154
154
|
}
|
|
155
155
|
/* harmony export */ });
|
|
156
|
-
/* harmony import */ var _swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("
|
|
156
|
+
/* harmony import */ var _swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("../../../../../../node_modules/@swc/helpers/esm/_define_property.js");
|
|
157
157
|
class ForBrowser {
|
|
158
158
|
test() {
|
|
159
159
|
console.log("Ok");
|
|
@@ -189,7 +189,7 @@ exports[`server: create-token-pure.ts 1`] = `
|
|
|
189
189
|
/* binding */ return TEST_TOKEN;
|
|
190
190
|
}
|
|
191
191
|
/* harmony export */ });
|
|
192
|
-
const TEST_TOKEN = /*#__PURE__*/ /*#__PURE__*/ (0, __webpack_require__("./
|
|
192
|
+
const TEST_TOKEN = /*#__PURE__*/ /*#__PURE__*/ (0, __webpack_require__("./mocks/tramvai-core.ts").E)("TEST_TOKEN");
|
|
193
193
|
"
|
|
194
194
|
`;
|
|
195
195
|
|
|
@@ -251,8 +251,8 @@ exports[`server: lazy-component.tsx 1`] = `
|
|
|
251
251
|
/* binding */ return Component;
|
|
252
252
|
}
|
|
253
253
|
/* harmony export */ });
|
|
254
|
-
/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("webpack/sharing/consume/default/react/jsx-runtime/react/jsx-runtime"), _swc_helpers__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("
|
|
255
|
-
/* harmony import */ const LazyComponent = (0, __webpack_require__("./
|
|
254
|
+
/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("webpack/sharing/consume/default/react/jsx-runtime/react/jsx-runtime"), _swc_helpers__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("../../../../../../node_modules/@swc/helpers/esm/_interop_require_wildcard.js");
|
|
255
|
+
/* harmony import */ const LazyComponent = (0, __webpack_require__("./mocks/tramvai-react.ts").R)({
|
|
256
256
|
chunkName() {
|
|
257
257
|
return "components-lazy-inner";
|
|
258
258
|
},
|
|
@@ -263,13 +263,13 @@ exports[`server: lazy-component.tsx 1`] = `
|
|
|
263
263
|
const key = this.resolve(props);
|
|
264
264
|
return !!__webpack_require__.m[key];
|
|
265
265
|
},
|
|
266
|
-
importAsync: () => Promise.resolve().then(() => (0, _swc_helpers__WEBPACK_IMPORTED_MODULE_1__._)(__webpack_require__(/* webpackChunkName: "components-lazy-inner" */ "./
|
|
266
|
+
importAsync: () => Promise.resolve().then(() => (0, _swc_helpers__WEBPACK_IMPORTED_MODULE_1__._)(__webpack_require__(/* webpackChunkName: "components-lazy-inner" */ "./components/lazy-inner.tsx"))),
|
|
267
267
|
requireAsync(props) {
|
|
268
268
|
return this.importAsync(props).then(resolved => resolved);
|
|
269
269
|
},
|
|
270
270
|
resolve() {
|
|
271
271
|
/*require.resolve*/
|
|
272
|
-
return "./
|
|
272
|
+
return "./components/lazy-inner.tsx";
|
|
273
273
|
}
|
|
274
274
|
}), Component = () => /*#__PURE__*/ /*#__PURE__*/ (0, react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.Fragment, {
|
|
275
275
|
children: [
|
|
@@ -303,7 +303,7 @@ exports[`server: provider-stack.ts 1`] = `
|
|
|
303
303
|
/* binding */ return providers;
|
|
304
304
|
}
|
|
305
305
|
/* harmony export */ });
|
|
306
|
-
/* harmony import */ var _tramvai_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./
|
|
306
|
+
/* harmony import */ var _tramvai_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./mocks/tramvai-core.ts"), _create_token_pure__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("./create-token-pure.ts");
|
|
307
307
|
/* harmony import */ const providers = [ (0, _tramvai_core__WEBPACK_IMPORTED_MODULE_0__ /* .provide */ .G)({
|
|
308
308
|
provide: _create_token_pure__WEBPACK_IMPORTED_MODULE_1__.TEST_TOKEN,
|
|
309
309
|
useValue: "test"
|
|
@@ -318,7 +318,7 @@ exports[`server: react-svg.tsx 1`] = `
|
|
|
318
318
|
/* binding */ return Component;
|
|
319
319
|
}
|
|
320
320
|
/* harmony export */ });
|
|
321
|
-
/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("webpack/sharing/consume/default/react/jsx-runtime/react/jsx-runtime"), _images_logo_svg_react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("./
|
|
321
|
+
/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("webpack/sharing/consume/default/react/jsx-runtime/react/jsx-runtime"), _images_logo_svg_react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("./images/logo.svg?react");
|
|
322
322
|
/* harmony import */ const Component = () => /*#__PURE__*/ /*#__PURE__*/ (0,
|
|
323
323
|
react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("div", {
|
|
324
324
|
children: /*#__PURE__*/ /*#__PURE__*/ (0 /* ["default"] */ , react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_images_logo_svg_react__WEBPACK_IMPORTED_MODULE_1__.A, {})
|