@tramvai/cli 2.51.2 → 2.56.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.
- package/README.md +12 -0
- package/lib/api/benchmark/build.js +4 -6
- package/lib/api/benchmark/build.js.map +1 -1
- package/lib/api/index.d.ts +1 -0
- package/lib/api/index.js +1 -0
- package/lib/api/index.js.map +1 -1
- package/lib/api/start/providers/child-app/shared.js +1 -4
- package/lib/api/start/providers/child-app/shared.js.map +1 -1
- package/lib/api/start/providers/module/shared.js +1 -4
- package/lib/api/start/providers/module/shared.js.map +1 -1
- package/lib/api/start/utils/banner.js +17 -6
- package/lib/api/start/utils/banner.js.map +1 -1
- package/lib/api/start/utils/tips/index.d.ts +4 -0
- package/lib/api/start/utils/tips/index.js +82 -0
- package/lib/api/start/utils/tips/index.js.map +1 -0
- package/lib/api/start/utils/tips/tips.d.ts +2 -0
- package/lib/api/start/utils/tips/tips.js +127 -0
- package/lib/api/start/utils/tips/tips.js.map +1 -0
- package/lib/api/start/utils/tips/types.d.ts +10 -0
- package/lib/api/start/utils/tips/types.js +3 -0
- package/lib/api/start/utils/tips/types.js.map +1 -0
- package/lib/builder/webpack/providers/shared.js +1 -4
- package/lib/builder/webpack/providers/shared.js.map +1 -1
- package/lib/library/webpack/utils/workersPool.d.ts +0 -7
- package/lib/library/webpack/utils/workersPool.js +1 -18
- package/lib/library/webpack/utils/workersPool.js.map +1 -1
- package/package.json +4 -5
- package/src/api/benchmark/build.ts +5 -8
- package/src/api/index.ts +1 -1
- package/src/api/start/providers/child-app/shared.ts +2 -8
- package/src/api/start/providers/module/shared.ts +2 -8
- package/src/api/start/utils/banner.ts +21 -6
- package/src/api/start/utils/tips/index.ts +107 -0
- package/src/api/start/utils/tips/tips.ts +139 -0
- package/src/api/start/utils/tips/types.ts +12 -0
- package/src/builder/webpack/providers/shared.ts +2 -8
- package/src/library/swc/__integration__/__snapshots__/swc.build.test.ts.snap +7 -2
- package/src/library/swc/__integration__/__snapshots__/swc.start.test.ts.snap +6 -0
- package/src/library/webpack/utils/workersPool.ts +0 -25
package/README.md
CHANGED
|
@@ -161,6 +161,7 @@ Configuration is provided through json-file with the name `tramvai.json` in the
|
|
|
161
161
|
### build or serve config?
|
|
162
162
|
|
|
163
163
|
When you are deciding where to put specific settings in `tramvai.json` consider next statements:
|
|
164
|
+
|
|
164
165
|
- `serve` config is only for development builds (using `tramvai start`)
|
|
165
166
|
- `build` config mostly focused on production builds (`tramvai build`, `tramvai analyze`, `tramvai start-prod`) but may affect development builds as well (is this case this configs are merged)
|
|
166
167
|
|
|
@@ -237,3 +238,14 @@ For setting access through local network follow next steps:
|
|
|
237
238
|
3. from the testing device open the new page in the browser and use the ip address from the previous step as domain name
|
|
238
239
|
|
|
239
240
|
> When calling @tramvai/cli using npm you need to pass `--` before any additional arguments, e.g. command should look similar to this `npm start -- --staticHost 192.168.1.3`
|
|
241
|
+
|
|
242
|
+
### How to enable paths mapping
|
|
243
|
+
|
|
244
|
+
In case you want to use special imports instead of pure relative paths in your code.
|
|
245
|
+
|
|
246
|
+
More details and examples you can find in typescript documentation:
|
|
247
|
+
|
|
248
|
+
- [baseUrl](https://www.typescriptlang.org/docs/handbook/module-resolution.html#base-url)
|
|
249
|
+
- [path mapping](https://www.typescriptlang.org/docs/handbook/module-resolution.html#path-mapping)
|
|
250
|
+
|
|
251
|
+
@tramvai/cli will reuse options `baseUrl` and `paths` from the app's `tsconfig.json` to provide path mapping functionality.
|
|
@@ -32,17 +32,15 @@ const runBuildCommand = (di, { times, shouldClearCache, }) => tslib_1.__awaiter(
|
|
|
32
32
|
};
|
|
33
33
|
});
|
|
34
34
|
const benchmarkBuild = (di) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
35
|
-
// прогоняем один раз, чтобы очистить старые кеши и прогреть код команды
|
|
36
|
-
yield runBuildCommand(di, { times: 1, shouldClearCache: true });
|
|
37
35
|
const { times = 5 } = di.get(tokens_1.COMMAND_PARAMETERS_TOKEN);
|
|
36
|
+
const noCache = yield runBuildCommand(di, {
|
|
37
|
+
times: Math.max(Math.floor(times / 2), 2),
|
|
38
|
+
shouldClearCache: true,
|
|
39
|
+
});
|
|
38
40
|
const cache = yield runBuildCommand(di, {
|
|
39
41
|
times,
|
|
40
42
|
shouldClearCache: false,
|
|
41
43
|
});
|
|
42
|
-
const noCache = yield runBuildCommand(di, {
|
|
43
|
-
times,
|
|
44
|
-
shouldClearCache: true,
|
|
45
|
-
});
|
|
46
44
|
return {
|
|
47
45
|
cache: getResultStats(cache),
|
|
48
46
|
noCache: getResultStats(noCache),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.js","sourceRoot":"","sources":["../../../src/api/benchmark/build.ts"],"names":[],"mappings":";;;;AAEA,4CAAiF;AAGjF,yCAAgD;AAChD,mDAAyD;AAOzD,MAAM,cAAc,GAAG,CAAC,EACtB,aAAa,EACb,aAAa,GAId,EAAY,EAAE;IACb,OAAO;QACL,MAAM,EAAE,IAAA,uBAAe,EAAC,aAAa,CAAC;QACtC,MAAM,EAAE,IAAA,uBAAe,EAAC,aAAa,CAAC;KACvC,CAAC;AACJ,CAAC,CAAC;AAOF,MAAM,eAAe,GAAG,CACtB,EAAa,EACb,EACE,KAAK,EACL,gBAAgB,GAIjB,EACiB,EAAE;IACpB,MAAM,aAAa,GAAa,KAAK,CAAC,KAAK,CAAC,CAAC;IAC7C,MAAM,aAAa,GAAa,KAAK,CAAC,KAAK,CAAC,CAAC;IAE7C,MAAM,EAAE,cAAc,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,iCAAwB,CAAgB,CAAC;IAE3E,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,EAAE,CAAC,EAAE,EAAE;QAC9B,IAAI,gBAAgB,EAAE;YACpB,MAAM,IAAA,gCAAmB,EAAC,EAAE,CAAC,CAAC;SAC/B;QAED,MAAM,EAAE,aAAa,EAAE,QAAQ,EAAE,GAAG,MAAO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aAC1C,GAAG,CAAC,6BAAoB,CAAC;aACzB,GAAG,CAAC,OAAO,EAAE,cAAc,CAAyB,CAAC;QACxD,MAAM,KAAK,GAAG,QAAQ,EAAE,CAAC;QAEzB,aAAa,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,eAAe,CAAC;QACzC,aAAa,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,eAAe,CAAC;KAC1C;IAED,OAAO;QACL,aAAa;QACb,aAAa;KACd,CAAC;AACJ,CAAC,CAAA,CAAC;AAEK,MAAM,cAAc,GAAG,CAAO,EAAa,EAAwB,EAAE;IAC1E,MAAM,EAAE,KAAK,GAAG,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,iCAAwB,CAAW,CAAC;IAEjE,MAAM,OAAO,GAAG,MAAM,eAAe,CAAC,EAAE,EAAE;QACxC,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC;QACzC,gBAAgB,EAAE,IAAI;KACvB,CAAC,CAAC;IAEH,MAAM,KAAK,GAAG,MAAM,eAAe,CAAC,EAAE,EAAE;QACtC,KAAK;QACL,gBAAgB,EAAE,KAAK;KACxB,CAAC,CAAC;IAEH,OAAO;QACL,KAAK,EAAE,cAAc,CAAC,KAAK,CAAC;QAC5B,OAAO,EAAE,cAAc,CAAC,OAAO,CAAC;KACjC,CAAC;AACJ,CAAC,CAAA,CAAC;AAjBW,QAAA,cAAc,kBAiBzB"}
|
package/lib/api/index.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ export { postcssAssetsWebpackRulesFactory } from '../library/webpack/blocks/post
|
|
|
16
16
|
export { extractCssPluginFactory } from '../library/webpack/blocks/extractCssPlugin';
|
|
17
17
|
export { configToEnv } from '../library/webpack/blocks/configToEnv';
|
|
18
18
|
export * from '../typings/public';
|
|
19
|
+
export * from './start/utils/tips/types';
|
|
19
20
|
export declare const start: StartCommand;
|
|
20
21
|
export declare const build: BuildCommand;
|
|
21
22
|
export declare const benchmark: BenchmarkCommand;
|
package/lib/api/index.js
CHANGED
|
@@ -29,6 +29,7 @@ Object.defineProperty(exports, "extractCssPluginFactory", { enumerable: true, ge
|
|
|
29
29
|
var configToEnv_1 = require("../library/webpack/blocks/configToEnv");
|
|
30
30
|
Object.defineProperty(exports, "configToEnv", { enumerable: true, get: function () { return configToEnv_1.configToEnv; } });
|
|
31
31
|
tslib_1.__exportStar(require("../typings/public"), exports);
|
|
32
|
+
tslib_1.__exportStar(require("./start/utils/tips/types"), exports);
|
|
32
33
|
const app = (0, createApp_1.createApp)({
|
|
33
34
|
commands: {
|
|
34
35
|
start: () => Promise.resolve().then(() => tslib_1.__importStar(require('./start'))),
|
package/lib/api/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":";;;;AAAA,6CAAiD;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":";;;;AAAA,6CAAiD;AACjD,yCAKsB;AACtB,qDAAkD;AAQlD,uDAA6B;AAC7B,yDAAwD;AAA/C,8GAAA,aAAa,OAAA;AACtB,2CAA2E;AAAlE,gHAAA,aAAa,OAA0B;AAChD,8DAA6D;AAApD,oHAAA,gBAAgB,OAAA;AACzB,sDAAqD;AAA5C,4GAAA,YAAY,OAAA;AACrB,0CAAsD;AAA7C,2GAAA,kBAAkB,OAAA;AAC3B,qEAAsF;AAA7E,4HAAA,6BAA6B,OAAA;AACtC,qDAAuE;AAA9D,6GAAA,sBAAsB,OAAA;AAC/B,uDAAyE;AAAhE,+GAAA,uBAAuB,OAAA;AAChC,yEAA2F;AAAlF,iIAAA,gCAAgC,OAAA;AACzC,+EAAqF;AAA5E,2HAAA,uBAAuB,OAAA;AAChC,qEAAoE;AAA3D,0GAAA,WAAW,OAAA;AACpB,4DAAkC;AAClC,mEAAyC;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,EAAE,UAAU,EAAE,SAAS,CAAC,CAAC;AACjD,CAAC,CAAC;AAFW,QAAA,KAAK,SAEhB;AAEK,MAAM,SAAS,GAAqB,CAAC,UAAU,EAAE,SAAS,GAAG,EAAE,EAAE,EAAE;IACxE,OAAO,GAAG,CAAC,GAAG,CAAC,WAAW,EAAE,UAAU,EAAE,SAAS,CAAC,CAAC;AACrD,CAAC,CAAC;AAFW,QAAA,SAAS,aAEpB;AAEK,MAAM,OAAO,GAAmB,CAAC,UAAU,EAAE,SAAS,GAAG,EAAE,EAAE,EAAE;IACpE,OAAO,GAAG,CAAC,GAAG,CAAC,SAAS,EAAE,UAAU,EAAE,SAAS,CAAC,CAAC;AACnD,CAAC,CAAC;AAFW,QAAA,OAAO,WAElB;AAEK,MAAM,SAAS,GAAqB,CAAC,UAAU,EAAE,SAAS,GAAG,EAAE,EAAE,EAAE;IACxE,OAAO,GAAG,CAAC,GAAG,CAAC,YAAY,EAAE,UAAU,EAAE,SAAS,CAAC,CAAC;AACtD,CAAC,CAAC;AAFW,QAAA,SAAS,aAEpB"}
|
|
@@ -66,10 +66,7 @@ exports.sharedProviders = [
|
|
|
66
66
|
multi: true,
|
|
67
67
|
useFactory: ({ configManager }) => {
|
|
68
68
|
return () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
69
|
-
yield
|
|
70
|
-
(0, workersPool_1.closeWorkerPoolTranspiler)(configManager),
|
|
71
|
-
(0, workersPool_1.closeWorkerPoolStyles)(configManager),
|
|
72
|
-
]);
|
|
69
|
+
yield (0, workersPool_1.closeWorkerPoolTranspiler)(configManager);
|
|
73
70
|
});
|
|
74
71
|
},
|
|
75
72
|
deps: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../../../../src/api/start/providers/child-app/shared.ts"],"names":[],"mappings":";;;;AACA,yCAAuE;AACvE,kDAK+B;AAG/B,oEAAiE;AACjE,+
|
|
1
|
+
{"version":3,"file":"shared.js","s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C;KACF;IACD;QACE,OAAO,EAAE,4BAAmB;QAC5B,KAAK,EAAE,IAAI;QACX,UAAU,EAAE,CAAC,EAAE,YAAY,EAAgD,EAAE,EAAE;YAC7E,OAAO,GAAG,EAAE;gBACV,OAAO,IAAA,uBAAU,EAAC,YAAY,CAAC,CAAC;YAClC,CAAC,CAAC;QACJ,CAAC;QACD,IAAI,EAAE;YACJ,YAAY,EAAE,4BAAmB;SAClC;KACF;IACD;QACE,OAAO,EAAE,4BAAmB;QAC5B,KAAK,EAAE,IAAI;QACX,UAAU,EAAE,CAAC,EAAE,aAAa,EAAkD,EAAE,EAAE;YAChF,OAAO,GAAS,EAAE;gBAChB,MAAM,IAAA,uCAAyB,EAAC,aAAa,CAAC,CAAC;YACjD,CAAC,CAAA,CAAC;QACJ,CAAC;QACD,IAAI,EAAE;YACJ,aAAa,EAAE,6BAAoB;SACpC;KACF;CACO,CAAC"}
|
|
@@ -66,10 +66,7 @@ exports.sharedProviders = [
|
|
|
66
66
|
multi: true,
|
|
67
67
|
useFactory: ({ configManager }) => {
|
|
68
68
|
return () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
69
|
-
|
|
70
|
-
(0, workersPool_1.closeWorkerPoolTranspiler)(configManager),
|
|
71
|
-
(0, workersPool_1.closeWorkerPoolStyles)(configManager),
|
|
72
|
-
]);
|
|
69
|
+
(0, workersPool_1.closeWorkerPoolTranspiler)(configManager);
|
|
73
70
|
});
|
|
74
71
|
},
|
|
75
72
|
deps: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../../../../src/api/start/providers/module/shared.ts"],"names":[],"mappings":";;;;AACA,yCAAuE;AACvE,kDAK+B;AAG/B,oEAAiE;AACjE,+
|
|
1
|
+
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../../../../src/api/start/providers/module/shared.ts"],"names":[],"mappings":";;;;AACA,yCAAuE;AACvE,kDAK+B;AAG/B,oEAAiE;AACjE,+E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AE;YAC7E,OAAO,GAAG,EAAE;gBACV,OAAO,IAAA,uBAAU,EAAC,YAAY,CAAC,CAAC;YAClC,CAAC,CAAC;QACJ,CAAC;QACD,IAAI,EAAE;YACJ,YAAY,EAAE,4BAAmB;SAClC;KACF;IACD;QACE,OAAO,EAAE,4BAAmB;QAC5B,KAAK,EAAE,IAAI;QACX,UAAU,EAAE,CAAC,EAAE,aAAa,EAAkD,EAAE,EAAE;YAChF,OAAO,GAAS,EAAE;gBAChB,IAAA,uCAAyB,EAAC,aAAa,CAAC,CAAC;YAC3C,CAAC,CAAA,CAAC;QACJ,CAAC;QACD,IAAI,EAAE;YACJ,aAAa,EAAE,6BAAoB;SACpC;KACF;CACO,CAAC"}
|
|
@@ -5,7 +5,9 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
6
6
|
const formatting_1 = require("../../../utils/formatting");
|
|
7
7
|
const tokens_1 = require("../../../di/tokens");
|
|
8
|
+
const tips_1 = require("./tips");
|
|
8
9
|
const label = (name) => chalk_1.default.bold.cyan(`▸ ${name}:`);
|
|
10
|
+
const link = (url) => chalk_1.default.underline.blue(url);
|
|
9
11
|
function showBanner(di) {
|
|
10
12
|
if (!di.get({ token: tokens_1.UI_SHOW_BANNER_TOKEN, optional: true })) {
|
|
11
13
|
return;
|
|
@@ -27,15 +29,24 @@ function showBanner(di) {
|
|
|
27
29
|
const staticServer = `http://${config.staticHost.replace('0.0.0.0', 'localhost')}:${config.staticPort}`;
|
|
28
30
|
if (config.type === 'application') {
|
|
29
31
|
// Listeners
|
|
30
|
-
messageLines.push(chalk_1.default.bold('Static: ') +
|
|
31
|
-
messageLines.push(chalk_1.default.bold('App: ') +
|
|
32
|
+
messageLines.push(chalk_1.default.bold('Static: ') + link(staticServer));
|
|
33
|
+
messageLines.push(chalk_1.default.bold('App: ') + link(server));
|
|
32
34
|
}
|
|
33
35
|
if (config.type === 'child-app') {
|
|
34
|
-
messageLines.push(chalk_1.default.bold('Base Url: ') +
|
|
36
|
+
messageLines.push(chalk_1.default.bold('Base Url: ') + link(`${server}/`));
|
|
35
37
|
messageLines.push(chalk_1.default.bold('JS: ') +
|
|
36
|
-
|
|
37
|
-
messageLines.push(chalk_1.default.bold('CSS: ') +
|
|
38
|
-
|
|
38
|
+
link(`${config.name}/${config.name}_(client|server)@${config.version}.js`));
|
|
39
|
+
messageLines.push(chalk_1.default.bold('CSS: ') + link(`${config.name}/${config.name}@${config.version}.css`));
|
|
40
|
+
}
|
|
41
|
+
const tip = (0, tips_1.getTip)(di);
|
|
42
|
+
if (tip) {
|
|
43
|
+
messageLines.push(`
|
|
44
|
+
${chalk_1.default.italic.yellow('Tip of the day:')}
|
|
45
|
+
|
|
46
|
+
${tip.text}
|
|
47
|
+
|
|
48
|
+
${chalk_1.default.bold.green('Related documentation:')}
|
|
49
|
+
${link(`${(0, tips_1.getDocUrl)(tip.docLink)}`)}`);
|
|
39
50
|
}
|
|
40
51
|
di.get(tokens_1.STDOUT_TOKEN).write((0, formatting_1.successBox)(titleLines, messageLines));
|
|
41
52
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"banner.js","sourceRoot":"","sources":["../../../../src/api/start/utils/banner.ts"],"names":[],"mappings":";;;;AAAA,0DAA0B;AAE1B,0DAAuD;AACvD,+CAA8F;
|
|
1
|
+
{"version":3,"file":"banner.js","sourceRoot":"","sources":["../../../../src/api/start/utils/banner.ts"],"names":[],"mappings":";;;;AAAA,0DAA0B;AAE1B,0DAAuD;AACvD,+CAA8F;AAC9F,iCAA2C;AAE3C,MAAM,KAAK,GAAG,CAAC,IAAI,EAAE,EAAE,CAAC,eAAK,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,GAAG,CAAC,CAAC;AACtD,MAAM,IAAI,GAAG,CAAC,GAAG,EAAE,EAAE,CAAC,eAAK,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAEhD,SAAgB,UA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AAC;AACnE,CAAC;AA9DD,gCA8DC"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getDocUrl = exports.getTip = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const shuffle_1 = tslib_1.__importDefault(require("@tinkoff/utils/array/shuffle"));
|
|
6
|
+
const path_1 = tslib_1.__importDefault(require("path"));
|
|
7
|
+
const find_cache_dir_1 = tslib_1.__importDefault(require("find-cache-dir"));
|
|
8
|
+
const fs_extra_1 = require("fs-extra");
|
|
9
|
+
const tips_1 = require("./tips");
|
|
10
|
+
const SHOW_ALL_TIPS_WINDOW = 1000 * 60 * 60 * 5; // 5 hours
|
|
11
|
+
const SHOW_SINGLE_TIP_WINDOW = 1000 * 60 * 60 * 24 * 14; // 2 weeks
|
|
12
|
+
let docUrl = 'https://tramvai.dev/docs/';
|
|
13
|
+
let tips = tips_1.tips;
|
|
14
|
+
try {
|
|
15
|
+
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
16
|
+
const { tips: privateTips, docUrl: privateDocUrl } = require('@tramvai-tinkoff/cli-tips');
|
|
17
|
+
tips = tips.concat(privateTips);
|
|
18
|
+
docUrl = privateDocUrl;
|
|
19
|
+
}
|
|
20
|
+
catch (_) { }
|
|
21
|
+
const cacheDirectory = (0, find_cache_dir_1.default)({ name: 'tramvai' });
|
|
22
|
+
const tipsFile = path_1.default.resolve(cacheDirectory !== null && cacheDirectory !== void 0 ? cacheDirectory : '', 'showed-tips');
|
|
23
|
+
const DEFAULT_TIP_USAGE_INFO = {
|
|
24
|
+
lastTimeShowed: 0,
|
|
25
|
+
lastTimeShowedByTip: {},
|
|
26
|
+
};
|
|
27
|
+
const getTipUsageInfo = () => {
|
|
28
|
+
if (!cacheDirectory) {
|
|
29
|
+
return DEFAULT_TIP_USAGE_INFO;
|
|
30
|
+
}
|
|
31
|
+
try {
|
|
32
|
+
return (0, fs_extra_1.readJSONSync)(tipsFile);
|
|
33
|
+
}
|
|
34
|
+
catch (_) {
|
|
35
|
+
return DEFAULT_TIP_USAGE_INFO;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
const updateTipUsageInfo = (usageInfo) => {
|
|
39
|
+
if (!cacheDirectory) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
try {
|
|
43
|
+
(0, fs_extra_1.outputJsonSync)(tipsFile, Object.assign(Object.assign({}, usageInfo), { lastTimeShowed: Date.now() }), {
|
|
44
|
+
spaces: 2,
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
catch (_) { }
|
|
48
|
+
};
|
|
49
|
+
const getTip = (di) => {
|
|
50
|
+
if (process.env.TRAMVAI_DISABLE_TIPS) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
const tipUsageInfo = getTipUsageInfo();
|
|
54
|
+
const now = Date.now();
|
|
55
|
+
// show tips only once in a time window
|
|
56
|
+
if (now - tipUsageInfo.lastTimeShowed < SHOW_ALL_TIPS_WINDOW) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
// ignore tips that were showed recently
|
|
60
|
+
// add shuffle to pick up random tip
|
|
61
|
+
const filteredTips = (0, shuffle_1.default)(tips.filter((tip) => {
|
|
62
|
+
return (!tipUsageInfo.lastTimeShowedByTip[tip.docLink] ||
|
|
63
|
+
now - tipUsageInfo.lastTimeShowedByTip[tip.docLink] > SHOW_SINGLE_TIP_WINDOW);
|
|
64
|
+
}));
|
|
65
|
+
let tip;
|
|
66
|
+
for (const possibleTip of filteredTips) {
|
|
67
|
+
tipUsageInfo.lastTimeShowedByTip[possibleTip.docLink] = Date.now();
|
|
68
|
+
if (possibleTip.isApplicable(di)) {
|
|
69
|
+
// show first tip that is applicable
|
|
70
|
+
tip = possibleTip;
|
|
71
|
+
break;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
updateTipUsageInfo(tipUsageInfo);
|
|
75
|
+
return tip;
|
|
76
|
+
};
|
|
77
|
+
exports.getTip = getTip;
|
|
78
|
+
const getDocUrl = (relativeUrl) => {
|
|
79
|
+
return `${docUrl}${relativeUrl}`;
|
|
80
|
+
};
|
|
81
|
+
exports.getDocUrl = getDocUrl;
|
|
82
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/api/start/utils/tips/index.ts"],"names":[],"mappings":";;;;AAAA,mFAAmD;AAEnD,wDAAwB;AAExB,4EAA0C;AAC1C,uCAAwD;AACxD,iCAA4C;AAG5C,MAAM,oBAAoB,GAAG,IAAI,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,UAAU;AAC3D,MAAM,sBAAsB,GAAG,IAAI,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,UAAU;AAEnE,IAAI,MAAM,GAAG,2BAA2B,CAAC;AACzC,IAAI,IAAI,GAAG,WAAU,CAAC;AAEtB,IAAI;IACF,6DAA6D;IAC7D,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC,2BAA2B,CAAC,CAAC;IAE1F,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;IAEhC,MAAM,GAAG,aAAa,CAAC;CACxB;AAAC,OAAO,CAAC,EAAE,GAAE;AAEd,MAAM,cAAc,GAAG,IAAA,wBAAY,EAAC,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC;AACzD,MAAM,QAAQ,GAAG,cAAI,CAAC,OAAO,CAAC,cAAc,aAAd,cAAc,cAAd,cAAc,GAAI,EAAE,EAAE,aAAa,CAAC,CAAC;AAEnE,MAAM,sBAAsB,GAAwB;IAClD,cAAc,EAAE,CAAC;IACjB,mBAAmB,EAAE,EAAE;CACxB,CAAC;AAEF,MAAM,eAAe,GAAG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CAAC,mBAAmB,CAAC,WAAW,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAEnE,IAAI,WAAW,CAAC,YAAY,CAAC,EAAE,CAAC,EAAE;YAChC,oCAAoC;YACpC,GAAG,GAAG,WAAW,CAAC;YAClB,MAAM;SACP;KACF;IAED,kBAAkB,CAAC,YAAY,CAAC,CAAC;IAEjC,OAAO,GAAG,CAAC;AACb,CAAC,CAAC;AAvCW,QAAA,MAAM,UAuCjB;AAEK,MAAM,SAAS,GAAG,CAAC,WAAmB,EAAE,EAAE;IAC/C,OAAO,GAAG,MAAM,GAAG,WAAW,EAAE,CAAC;AACnC,CAAC,CAAC;AAFW,QAAA,SAAS,aAEpB"}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.tips = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const path_1 = tslib_1.__importDefault(require("path"));
|
|
6
|
+
const fs_extra_1 = require("fs-extra");
|
|
7
|
+
const resolve_1 = require("resolve");
|
|
8
|
+
const tokens_1 = require("../../../../di/tokens");
|
|
9
|
+
const DEFAULT_ROOT_DIR = process.cwd();
|
|
10
|
+
const safeRequireResolve = (id, rootDir = DEFAULT_ROOT_DIR) => {
|
|
11
|
+
try {
|
|
12
|
+
return (0, resolve_1.sync)(id, { basedir: rootDir });
|
|
13
|
+
}
|
|
14
|
+
catch (_) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
exports.tips = [
|
|
19
|
+
{
|
|
20
|
+
text: `Suffer from the slow builds/rebuilds while using @tramvai/cli?
|
|
21
|
+
Consider to test out swc support.`,
|
|
22
|
+
docLink: 'references/cli/experiments#swc',
|
|
23
|
+
isApplicable(di) {
|
|
24
|
+
var _a, _b, _c, _d, _e, _f;
|
|
25
|
+
const configManager = di.get(tokens_1.CONFIG_MANAGER_TOKEN);
|
|
26
|
+
return (((_c = (_b = (_a = configManager.serve.configurations) === null || _a === void 0 ? void 0 : _a.experiments) === null || _b === void 0 ? void 0 : _b.transpilation) === null || _c === void 0 ? void 0 : _c.loader) !== 'swc' &&
|
|
27
|
+
((_f = (_e = (_d = configManager.build.configurations) === null || _d === void 0 ? void 0 : _d.experiments) === null || _e === void 0 ? void 0 : _e.transpilation) === null || _f === void 0 ? void 0 : _f.loader) !== 'swc');
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
text: `Ship modern code to browser`,
|
|
32
|
+
docLink: 'how-to/how-enable-modern',
|
|
33
|
+
isApplicable(di) {
|
|
34
|
+
const configManager = di.get(tokens_1.CONFIG_MANAGER_TOKEN);
|
|
35
|
+
return configManager.modern !== true;
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
text: `Forget about reloading page with hotRefresh cli option`,
|
|
40
|
+
docLink: 'references/cli/start/#react-hot-refresh',
|
|
41
|
+
isApplicable(di) {
|
|
42
|
+
const configManager = di.get(tokens_1.CONFIG_MANAGER_TOKEN);
|
|
43
|
+
return configManager.hotRefresh !== true;
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
text: `You can use file-based routing with tramvai.
|
|
48
|
+
It may reduce the boilerplate code required with bundles`,
|
|
49
|
+
docLink: 'features/routing/file-system-pages',
|
|
50
|
+
isApplicable(di) {
|
|
51
|
+
const configManager = di.get(tokens_1.CONFIG_MANAGER_TOKEN);
|
|
52
|
+
const { rootDir, root } = configManager;
|
|
53
|
+
const { fileSystemPages } = configManager.build.configurations;
|
|
54
|
+
if (!fileSystemPages.enable) {
|
|
55
|
+
return true;
|
|
56
|
+
}
|
|
57
|
+
const routesDir = path_1.default.resolve(rootDir, root, fileSystemPages.routesDir || '');
|
|
58
|
+
if (!(0, fs_extra_1.existsSync)(routesDir)) {
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
return false;
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
text: `@tramvai/react-query is a great way to manage requests in React components`,
|
|
66
|
+
docLink: 'references/tramvai/react-query',
|
|
67
|
+
isApplicable() {
|
|
68
|
+
return !safeRequireResolve('@tramvai/react-query');
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
text: `Did you know tramvai has a set of helpers for testing?`,
|
|
73
|
+
docLink: 'guides/testing',
|
|
74
|
+
isApplicable() {
|
|
75
|
+
return (!safeRequireResolve('@tramvai/test-unit') ||
|
|
76
|
+
!safeRequireResolve('@tramvai/test-integration'));
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
text: `Do you love typescript as we do?
|
|
81
|
+
Check out our guide how to use typescript with tramvai`,
|
|
82
|
+
docLink: 'guides/strong-typing',
|
|
83
|
+
isApplicable() {
|
|
84
|
+
return true;
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
text: `In case if you are looking how to optimize your bundle`,
|
|
89
|
+
docLink: 'guides/bundle-optimization',
|
|
90
|
+
isApplicable() {
|
|
91
|
+
return true;
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
text: `tramvai now supports tsconfig.paths.
|
|
96
|
+
So you can remove alias config from tramvai.json`,
|
|
97
|
+
docLink: 'references/cli/base#how-to-enable-paths-mapping',
|
|
98
|
+
isApplicable(di) {
|
|
99
|
+
var _a;
|
|
100
|
+
const configManager = di.get(tokens_1.CONFIG_MANAGER_TOKEN);
|
|
101
|
+
return !!((_a = configManager.build.configurations) === null || _a === void 0 ? void 0 : _a.alias);
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
text: `Do you use storybook?
|
|
106
|
+
Check storybook integration with tramvai`,
|
|
107
|
+
docLink: 'guides/storybook',
|
|
108
|
+
isApplicable(di) {
|
|
109
|
+
const { rootDir } = di.get(tokens_1.CONFIG_MANAGER_TOKEN);
|
|
110
|
+
let storybookDir = path_1.default.resolve(rootDir, 'storybook');
|
|
111
|
+
if (!(0, fs_extra_1.existsSync)(storybookDir)) {
|
|
112
|
+
storybookDir = rootDir;
|
|
113
|
+
}
|
|
114
|
+
return (safeRequireResolve('@storybook/react', storybookDir) &&
|
|
115
|
+
!safeRequireResolve('@tramvai/storybook-addon'));
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
text: `Looking for another way to render your app?
|
|
120
|
+
Check available render modes in tramvai`,
|
|
121
|
+
docLink: 'references/modules/page-render-mode',
|
|
122
|
+
isApplicable(di) {
|
|
123
|
+
return !safeRequireResolve('@tramvai/module-page-render-mode');
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
];
|
|
127
|
+
//# sourceMappingURL=tips.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tips.js","sourceRoot":"","sources":["../../../../../src/api/start/utils/tips/tips.ts"],"names":[],"mappings":";;;;AAAA,wDAAwB;AACxB,uCAAsC;AACtC,qCAA8C;AAC9C,kDAA6D;AAG7D,MAAM,gBAAgB,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;AAEvC,MAAM,kBAAkB,GAAG,CAAC,EAAU,EAAE,OAAO,GAAG,gBAAgB,EAAE,EAAE;IACpE,IAAI;QACF,OAAO,IAAA,cAAW,EAAC,EAAE,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC;KAC9C;IAAC,OAAO,CAAC,EAAE;QACV,OAAO,IAAI,CAAC;KACb;AACH,CAAC,CAAC;AAEW,QAAA,IAAI,GAAiB;IAChC;QACE,IAAI,EAAE;kCACwB;QAC9B,OAAO,EAAE,gCAAgC;QACzC,YAAY,CAAC,EAAE;;YACb,MAAM,aAAa,GAAG,EAAE,CAAC,GAAG,CAAC,6BAAoB,CAAC,CAAC;YAEnD,OAAO,CACL,CAAA,MAAA,MAAA,MAAA,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kB,CAAC,0BAA0B,CAAC,CAChD,CAAC;QACJ,CAAC;KACF;IACD;QACE,IAAI,EAAE;wCAC8B;QACpC,OAAO,EAAE,qCAAqC;QAC9C,YAAY,CAAC,EAAE;YACb,OAAO,CAAC,kBAAkB,CAAC,kCAAkC,CAAC,CAAC;QACjE,CAAC;KACF;CACF,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Container } from '@tinkoff/dippy';
|
|
2
|
+
export interface TramvaiTip {
|
|
3
|
+
text: string;
|
|
4
|
+
docLink: string;
|
|
5
|
+
isApplicable: (di: Container) => boolean;
|
|
6
|
+
}
|
|
7
|
+
export interface TramvaiTipUsageInfo {
|
|
8
|
+
lastTimeShowed: number;
|
|
9
|
+
lastTimeShowedByTip: Record<string, number>;
|
|
10
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/api/start/utils/tips/types.ts"],"names":[],"mappings":""}
|
|
@@ -57,10 +57,7 @@ exports.sharedProviders = [
|
|
|
57
57
|
multi: true,
|
|
58
58
|
useFactory: ({ configManager }) => {
|
|
59
59
|
return () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
60
|
-
yield
|
|
61
|
-
(0, workersPool_1.closeWorkerPoolTranspiler)(configManager),
|
|
62
|
-
(0, workersPool_1.closeWorkerPoolStyles)(configManager),
|
|
63
|
-
]);
|
|
60
|
+
yield (0, workersPool_1.closeWorkerPoolTranspiler)(configManager);
|
|
64
61
|
});
|
|
65
62
|
},
|
|
66
63
|
deps: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../../../src/builder/webpack/providers/shared.ts"],"names":[],"mappings":";;;;AACA,0CAAyC;AACzC,mCAAsC;AACtC,+CAA0D;AAC1D,
|
|
1
|
+
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../../../src/builder/webpack/providers/shared.ts"],"names":[],"mappings":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AAE,cAAc,EAAE,oBAAoB,EAAE,cAAc,EAAE,EAAE,EAAE;YACrF,OAAO,GAAG,EAAE;gBACV,cAAc,IAAI,IAAA,iCAAiB,EAAC,cAAc,EAAE,YAAY,EAAE,QAAQ,CAAC,CAAC;gBAC5E,oBAAoB;oBAClB,IAAA,iCAAiB,EAAC,oBAAoB,EAAE,YAAY,EAAE,cAAc,CAAC,CAAC;gBACxE,cAAc,IAAI,IAAA,iCAAiB,EAAC,cAAc,EAAE,YAAY,EAAE,QAAQ,CAAC,CAAC;YAC9E,CAAC,CAAC;QACJ,CAAC;QACD,IAAI,EAAE;YACJ,YAAY,EAAE,4BAAmB;YACjC,cAAc,EAAE,EAAE,KAAK,EAAE,sCAA6B,EAAE,QAAQ,EAAE,IAAI,EAAE;YACxE,oBAAoB,EAAE,EAAE,KAAK,EAAE,6CAAoC,EAAE,QAAQ,EAAE,IAAI,EAAE;YACrF,cAAc,EAAE,EAAE,KAAK,EAAE,sCAA6B,EAAE,QAAQ,EAAE,IAAI,EAAE;SACzE;KACF,CAAC;IACF,IAAA,eAAO,EAAC;QACN,OAAO,EAAE,4BAAmB;QAC5B,KAAK,EAAE,IAAI;QACX,UAAU,EAAE,CAAC,EAAE,aAAa,EAAE,EAAE,EAAE;YAChC,OAAO,GAAS,EAAE;gBAChB,MAAM,IAAA,uCAAyB,EAAC,aAAa,CAAC,CAAC;YACjD,CAAC,CAAA,CAAC;QACJ,CAAC;QACD,IAAI,EAAE;YACJ,aAAa,EAAE,6BAAoB;SACpC;KACF,CAAC;CACH,CAAC"}
|
|
@@ -5,10 +5,3 @@ export declare const createWorkerPoolTranspiler: (configManager: ConfigManager)
|
|
|
5
5
|
workers: number;
|
|
6
6
|
};
|
|
7
7
|
export declare const closeWorkerPoolTranspiler: (configManager: ConfigManager) => void;
|
|
8
|
-
export declare const createWorkerPoolStyles: (configManager: ConfigManager) => (configManager: ConfigManager) => {
|
|
9
|
-
name: string;
|
|
10
|
-
workerParallelJobs: number;
|
|
11
|
-
workers: number;
|
|
12
|
-
poolTimeout: number;
|
|
13
|
-
};
|
|
14
|
-
export declare const closeWorkerPoolStyles: (configManager: ConfigManager) => void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.closeWorkerPoolTranspiler = exports.createWorkerPoolTranspiler = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const threadLoader = tslib_1.__importStar(require("thread-loader"));
|
|
6
6
|
const workerPools_1 = require("thread-loader/dist/workerPools");
|
|
@@ -47,21 +47,4 @@ const closeWorkerPoolTranspiler = (configManager) => {
|
|
|
47
47
|
(_a = (0, workerPools_1.getPool)(createTranspilerConfig(configManager))) === null || _a === void 0 ? void 0 : _a.disposeWorkers();
|
|
48
48
|
};
|
|
49
49
|
exports.closeWorkerPoolTranspiler = closeWorkerPoolTranspiler;
|
|
50
|
-
const createStylesConfig = (configManager) => {
|
|
51
|
-
return Object.assign({ name: 'styles', workerParallelJobs: 2, workers: Math.max(getCpuNumber(), 2), poolTimeout: configManager.env === 'development' ? Infinity : undefined }, getCustomConfig(configManager));
|
|
52
|
-
};
|
|
53
|
-
const createWorkerPoolStyles = (configManager) => {
|
|
54
|
-
const config = createStylesConfig;
|
|
55
|
-
if (!exports.createWorkerPoolStyles.warmup) {
|
|
56
|
-
threadLoader.warmup(config, ['postcss-loader']);
|
|
57
|
-
exports.createWorkerPoolStyles.warmup = true;
|
|
58
|
-
}
|
|
59
|
-
return config;
|
|
60
|
-
};
|
|
61
|
-
exports.createWorkerPoolStyles = createWorkerPoolStyles;
|
|
62
|
-
const closeWorkerPoolStyles = (configManager) => {
|
|
63
|
-
var _a;
|
|
64
|
-
(_a = (0, workerPools_1.getPool)(createStylesConfig(configManager))) === null || _a === void 0 ? void 0 : _a.disposeWorkers();
|
|
65
|
-
};
|
|
66
|
-
exports.closeWorkerPoolStyles = closeWorkerPoolStyles;
|
|
67
50
|
//# sourceMappingURL=workersPool.js.map
|
|
@@ -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,sBAAsB,GAAG,CAAC,aAA4B,EAAE,EAAE;IAC9D,uBACE,IAAI,EAAE,YAAY,EAClB,WAAW,EAAE,aAAa,CAAC,GAAG,KAAK,aAAa,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,EACvE,OAAO,EAAE,wBAAwB,EAAE,IAChC,eAAe,CAAC,aAAa,CAAC,EACjC;AACJ,CAAC,CAAC;AAEK,MAAM,0BAA0B,GAAG,CAAC,aAA4B,EAAE,EAAE;IACzE,MAAM,MAAM,GAAG,sBAAsB,CAAC,aAAa,CAAC,CAAC;IAErD,IAAI,CAAE,kCAAkC,CAAC,MAAM,EAAE;QAC/C,IAAI,aAAa,CAAC,WAAW,CAAC,aAAa,CAAC,MAAM,KAAK,KAAK,EAAE;YAC5D,YAAY,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,YAAY,EAAE,WAAW,CAAC,CAAC,CAAC;SAC1D;aAAM;YACL,YAAY,CAAC,MAAM,CAAC,MAAM,EAAE;gBAC1B,cAAc;gBACd,mBAAmB;gBACnB,0BAA0B;gBAC1B,qBAAqB;gBACrB,iCAAiC;gBACjC,qBAAqB;aACtB,CAAC,CAAC;SACJ;QACA,kCAAkC,CAAC,MAAM,GAAG,IAAI,CAAC;KACnD;IAED,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AApBW,QAAA,0BAA0B,8BAoBrC;AAEK,MAAM,yBAAyB,GAAG,CAAC,aAA4B,EAAE,EAAE;;IACxE,MAAA,IAAA,qBAAO,EAAC,sBAAsB,CAAC,aAAa,CAAC,CAAC,0CAAE,cAAc,EAAE,CAAC;AACnE,CAAC,CAAC;AAFW,QAAA,yBAAyB,6BAEpC
|
|
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,EA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description": "Cli инструмент для сборки и запуска приложений",
|
|
5
5
|
"files": [
|
|
6
6
|
"src",
|
|
@@ -44,7 +44,6 @@
|
|
|
44
44
|
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
|
45
45
|
"@babel/plugin-transform-duplicate-keys": "^7.18.9",
|
|
46
46
|
"@babel/plugin-transform-react-constant-elements": "^7.18.12",
|
|
47
|
-
"@babel/plugin-transform-react-inline-elements": "^7.18.6",
|
|
48
47
|
"@babel/plugin-transform-runtime": "^7.18.10",
|
|
49
48
|
"@babel/preset-env": "^7.18.10",
|
|
50
49
|
"@babel/preset-react": "^7.18.6",
|
|
@@ -60,7 +59,7 @@
|
|
|
60
59
|
"@sentry/node": "^6.2.5",
|
|
61
60
|
"@svgr/webpack": "^6.4.0",
|
|
62
61
|
"@tinkoff/browserslist-config": "0.2.4",
|
|
63
|
-
"@tinkoff/dippy": "0.8.
|
|
62
|
+
"@tinkoff/dippy": "0.8.10",
|
|
64
63
|
"@tinkoff/is-modern-lib": "2.0.5",
|
|
65
64
|
"@tinkoff/logger": "0.10.55",
|
|
66
65
|
"@tinkoff/minicss-class-generator": "0.2.4",
|
|
@@ -69,7 +68,7 @@
|
|
|
69
68
|
"@tinkoff/request-plugin-protocol-http": "^0.11.6",
|
|
70
69
|
"@tinkoff/utils": "^2.1.3",
|
|
71
70
|
"@tramvai/build": "3.0.6",
|
|
72
|
-
"@tramvai/react": "2.
|
|
71
|
+
"@tramvai/react": "2.56.1",
|
|
73
72
|
"@tramvai/tools-check-versions": "0.4.6",
|
|
74
73
|
"@tramvai/tools-migrate": "0.6.7",
|
|
75
74
|
"ajv": "^6.12.6",
|
|
@@ -160,7 +159,7 @@
|
|
|
160
159
|
"wrap-ansi": "^7.0.0"
|
|
161
160
|
},
|
|
162
161
|
"devDependencies": {
|
|
163
|
-
"@swc/core": "^1.3.
|
|
162
|
+
"@swc/core": "^1.3.24",
|
|
164
163
|
"@tramvai/tools-generate-schema": "0.1.3",
|
|
165
164
|
"@types/compression": "^1.7.2",
|
|
166
165
|
"@types/express": "^4.17.13",
|
|
@@ -65,19 +65,16 @@ const runBuildCommand = async (
|
|
|
65
65
|
};
|
|
66
66
|
|
|
67
67
|
export const benchmarkBuild = async (di: Container): Promise<BuildResult> => {
|
|
68
|
-
// прогоняем один раз, чтобы очистить старые кеши и прогреть код команды
|
|
69
|
-
await runBuildCommand(di, { times: 1, shouldClearCache: true });
|
|
70
|
-
|
|
71
68
|
const { times = 5 } = di.get(COMMAND_PARAMETERS_TOKEN) as Params;
|
|
72
69
|
|
|
73
|
-
const
|
|
74
|
-
times,
|
|
75
|
-
shouldClearCache:
|
|
70
|
+
const noCache = await runBuildCommand(di, {
|
|
71
|
+
times: Math.max(Math.floor(times / 2), 2),
|
|
72
|
+
shouldClearCache: true,
|
|
76
73
|
});
|
|
77
74
|
|
|
78
|
-
const
|
|
75
|
+
const cache = await runBuildCommand(di, {
|
|
79
76
|
times,
|
|
80
|
-
shouldClearCache:
|
|
77
|
+
shouldClearCache: false,
|
|
81
78
|
});
|
|
82
79
|
|
|
83
80
|
return {
|
package/src/api/index.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { writableNoopStream } from 'noop-stream';
|
|
2
|
-
import type { Provider } from '@tinkoff/dippy';
|
|
3
2
|
import {
|
|
4
3
|
ANALYTICS_PACKAGE_INFO_TOKEN,
|
|
5
4
|
COMMAND_PARAMETERS_TOKEN,
|
|
@@ -27,6 +26,7 @@ export { postcssAssetsWebpackRulesFactory } from '../library/webpack/blocks/post
|
|
|
27
26
|
export { extractCssPluginFactory } from '../library/webpack/blocks/extractCssPlugin';
|
|
28
27
|
export { configToEnv } from '../library/webpack/blocks/configToEnv';
|
|
29
28
|
export * from '../typings/public';
|
|
29
|
+
export * from './start/utils/tips/types';
|
|
30
30
|
|
|
31
31
|
const app = createApp({
|
|
32
32
|
commands: {
|
|
@@ -9,10 +9,7 @@ import {
|
|
|
9
9
|
import type { ChildAppConfigEntry } from '../../../../typings/configEntry/child-app';
|
|
10
10
|
import type { Params } from '../../index';
|
|
11
11
|
import { ConfigManager } from '../../../../config/configManager';
|
|
12
|
-
import {
|
|
13
|
-
closeWorkerPoolTranspiler,
|
|
14
|
-
closeWorkerPoolStyles,
|
|
15
|
-
} from '../../../../library/webpack/utils/workersPool';
|
|
12
|
+
import { closeWorkerPoolTranspiler } from '../../../../library/webpack/utils/workersPool';
|
|
16
13
|
import { stopServer } from '../../utils/stopServer';
|
|
17
14
|
import { createServer } from '../../utils/createServer';
|
|
18
15
|
import { listenServer } from '../../utils/listenServer';
|
|
@@ -91,10 +88,7 @@ export const sharedProviders: readonly Provider[] = [
|
|
|
91
88
|
multi: true,
|
|
92
89
|
useFactory: ({ configManager }: { configManager: typeof CONFIG_MANAGER_TOKEN }) => {
|
|
93
90
|
return async () => {
|
|
94
|
-
await
|
|
95
|
-
closeWorkerPoolTranspiler(configManager),
|
|
96
|
-
closeWorkerPoolStyles(configManager),
|
|
97
|
-
]);
|
|
91
|
+
await closeWorkerPoolTranspiler(configManager);
|
|
98
92
|
};
|
|
99
93
|
},
|
|
100
94
|
deps: {
|
|
@@ -9,10 +9,7 @@ import {
|
|
|
9
9
|
import type { ModuleConfigEntry } from '../../../../typings/configEntry/module';
|
|
10
10
|
import type { Params } from '../../index';
|
|
11
11
|
import { ConfigManager } from '../../../../config/configManager';
|
|
12
|
-
import {
|
|
13
|
-
closeWorkerPoolTranspiler,
|
|
14
|
-
closeWorkerPoolStyles,
|
|
15
|
-
} from '../../../../library/webpack/utils/workersPool';
|
|
12
|
+
import { closeWorkerPoolTranspiler } from '../../../../library/webpack/utils/workersPool';
|
|
16
13
|
import { stopServer } from '../../utils/stopServer';
|
|
17
14
|
import { createServer } from '../../utils/createServer';
|
|
18
15
|
import { listenServer } from '../../utils/listenServer';
|
|
@@ -91,10 +88,7 @@ export const sharedProviders: readonly Provider[] = [
|
|
|
91
88
|
multi: true,
|
|
92
89
|
useFactory: ({ configManager }: { configManager: typeof CONFIG_MANAGER_TOKEN }) => {
|
|
93
90
|
return async () => {
|
|
94
|
-
|
|
95
|
-
closeWorkerPoolTranspiler(configManager),
|
|
96
|
-
closeWorkerPoolStyles(configManager),
|
|
97
|
-
]);
|
|
91
|
+
closeWorkerPoolTranspiler(configManager);
|
|
98
92
|
};
|
|
99
93
|
},
|
|
100
94
|
deps: {
|
|
@@ -2,8 +2,10 @@ import chalk from 'chalk';
|
|
|
2
2
|
import type { Container } from '@tinkoff/dippy';
|
|
3
3
|
import { successBox } from '../../../utils/formatting';
|
|
4
4
|
import { UI_SHOW_BANNER_TOKEN, CONFIG_MANAGER_TOKEN, STDOUT_TOKEN } from '../../../di/tokens';
|
|
5
|
+
import { getDocUrl, getTip } from './tips';
|
|
5
6
|
|
|
6
7
|
const label = (name) => chalk.bold.cyan(`▸ ${name}:`);
|
|
8
|
+
const link = (url) => chalk.underline.blue(url);
|
|
7
9
|
|
|
8
10
|
export function showBanner(di: Container) {
|
|
9
11
|
if (!di.get({ token: UI_SHOW_BANNER_TOKEN, optional: true })) {
|
|
@@ -35,21 +37,34 @@ export function showBanner(di: Container) {
|
|
|
35
37
|
|
|
36
38
|
if (config.type === 'application') {
|
|
37
39
|
// Listeners
|
|
38
|
-
messageLines.push(chalk.bold('Static: ') +
|
|
39
|
-
messageLines.push(chalk.bold('App: ') +
|
|
40
|
+
messageLines.push(chalk.bold('Static: ') + link(staticServer));
|
|
41
|
+
messageLines.push(chalk.bold('App: ') + link(server));
|
|
40
42
|
}
|
|
41
43
|
|
|
42
44
|
if (config.type === 'child-app') {
|
|
43
|
-
messageLines.push(chalk.bold('Base Url: ') +
|
|
45
|
+
messageLines.push(chalk.bold('Base Url: ') + link(`${server}/`));
|
|
44
46
|
|
|
45
47
|
messageLines.push(
|
|
46
48
|
chalk.bold('JS: ') +
|
|
47
|
-
|
|
49
|
+
link(`${config.name}/${config.name}_(client|server)@${config.version}.js`)
|
|
48
50
|
);
|
|
49
51
|
|
|
50
52
|
messageLines.push(
|
|
51
|
-
chalk.bold('CSS: ') +
|
|
52
|
-
|
|
53
|
+
chalk.bold('CSS: ') + link(`${config.name}/${config.name}@${config.version}.css`)
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const tip = getTip(di);
|
|
58
|
+
|
|
59
|
+
if (tip) {
|
|
60
|
+
messageLines.push(
|
|
61
|
+
`
|
|
62
|
+
${chalk.italic.yellow('Tip of the day:')}
|
|
63
|
+
|
|
64
|
+
${tip.text}
|
|
65
|
+
|
|
66
|
+
${chalk.bold.green('Related documentation:')}
|
|
67
|
+
${link(`${getDocUrl(tip.docLink)}`)}`
|
|
53
68
|
);
|
|
54
69
|
}
|
|
55
70
|
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import shuffle from '@tinkoff/utils/array/shuffle';
|
|
2
|
+
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import type { Container } from '@tinkoff/dippy';
|
|
5
|
+
import findCacheDir from 'find-cache-dir';
|
|
6
|
+
import { readJSONSync, outputJsonSync } from 'fs-extra';
|
|
7
|
+
import { tips as publicTips } from './tips';
|
|
8
|
+
import type { TramvaiTip, TramvaiTipUsageInfo } from './types';
|
|
9
|
+
|
|
10
|
+
const SHOW_ALL_TIPS_WINDOW = 1000 * 60 * 60 * 5; // 5 hours
|
|
11
|
+
const SHOW_SINGLE_TIP_WINDOW = 1000 * 60 * 60 * 24 * 14; // 2 weeks
|
|
12
|
+
|
|
13
|
+
let docUrl = 'https://tramvai.dev/docs/';
|
|
14
|
+
let tips = publicTips;
|
|
15
|
+
|
|
16
|
+
try {
|
|
17
|
+
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
18
|
+
const { tips: privateTips, docUrl: privateDocUrl } = require('@tramvai-tinkoff/cli-tips');
|
|
19
|
+
|
|
20
|
+
tips = tips.concat(privateTips);
|
|
21
|
+
|
|
22
|
+
docUrl = privateDocUrl;
|
|
23
|
+
} catch (_) {}
|
|
24
|
+
|
|
25
|
+
const cacheDirectory = findCacheDir({ name: 'tramvai' });
|
|
26
|
+
const tipsFile = path.resolve(cacheDirectory ?? '', 'showed-tips');
|
|
27
|
+
|
|
28
|
+
const DEFAULT_TIP_USAGE_INFO: TramvaiTipUsageInfo = {
|
|
29
|
+
lastTimeShowed: 0,
|
|
30
|
+
lastTimeShowedByTip: {},
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const getTipUsageInfo = (): TramvaiTipUsageInfo => {
|
|
34
|
+
if (!cacheDirectory) {
|
|
35
|
+
return DEFAULT_TIP_USAGE_INFO;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
try {
|
|
39
|
+
return readJSONSync(tipsFile);
|
|
40
|
+
} catch (_) {
|
|
41
|
+
return DEFAULT_TIP_USAGE_INFO;
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const updateTipUsageInfo = (usageInfo: TramvaiTipUsageInfo) => {
|
|
46
|
+
if (!cacheDirectory) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
try {
|
|
51
|
+
outputJsonSync(
|
|
52
|
+
tipsFile,
|
|
53
|
+
{
|
|
54
|
+
...usageInfo,
|
|
55
|
+
lastTimeShowed: Date.now(),
|
|
56
|
+
} as TramvaiTipUsageInfo,
|
|
57
|
+
{
|
|
58
|
+
spaces: 2,
|
|
59
|
+
}
|
|
60
|
+
);
|
|
61
|
+
} catch (_) {}
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export const getTip = (di: Container): TramvaiTip | undefined => {
|
|
65
|
+
if (process.env.TRAMVAI_DISABLE_TIPS) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const tipUsageInfo: TramvaiTipUsageInfo = getTipUsageInfo();
|
|
70
|
+
const now = Date.now();
|
|
71
|
+
|
|
72
|
+
// show tips only once in a time window
|
|
73
|
+
if (now - tipUsageInfo.lastTimeShowed < SHOW_ALL_TIPS_WINDOW) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// ignore tips that were showed recently
|
|
78
|
+
// add shuffle to pick up random tip
|
|
79
|
+
const filteredTips = shuffle(
|
|
80
|
+
tips.filter((tip) => {
|
|
81
|
+
return (
|
|
82
|
+
!tipUsageInfo.lastTimeShowedByTip[tip.docLink] ||
|
|
83
|
+
now - tipUsageInfo.lastTimeShowedByTip[tip.docLink] > SHOW_SINGLE_TIP_WINDOW
|
|
84
|
+
);
|
|
85
|
+
})
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
let tip;
|
|
89
|
+
|
|
90
|
+
for (const possibleTip of filteredTips) {
|
|
91
|
+
tipUsageInfo.lastTimeShowedByTip[possibleTip.docLink] = Date.now();
|
|
92
|
+
|
|
93
|
+
if (possibleTip.isApplicable(di)) {
|
|
94
|
+
// show first tip that is applicable
|
|
95
|
+
tip = possibleTip;
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
updateTipUsageInfo(tipUsageInfo);
|
|
101
|
+
|
|
102
|
+
return tip;
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
export const getDocUrl = (relativeUrl: string) => {
|
|
106
|
+
return `${docUrl}${relativeUrl}`;
|
|
107
|
+
};
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import { existsSync } from 'fs-extra';
|
|
3
|
+
import { sync as resolveSync } from 'resolve';
|
|
4
|
+
import { CONFIG_MANAGER_TOKEN } from '../../../../di/tokens';
|
|
5
|
+
import type { TramvaiTip } from './types';
|
|
6
|
+
|
|
7
|
+
const DEFAULT_ROOT_DIR = process.cwd();
|
|
8
|
+
|
|
9
|
+
const safeRequireResolve = (id: string, rootDir = DEFAULT_ROOT_DIR) => {
|
|
10
|
+
try {
|
|
11
|
+
return resolveSync(id, { basedir: rootDir });
|
|
12
|
+
} catch (_) {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export const tips: TramvaiTip[] = [
|
|
18
|
+
{
|
|
19
|
+
text: `Suffer from the slow builds/rebuilds while using @tramvai/cli?
|
|
20
|
+
Consider to test out swc support.`,
|
|
21
|
+
docLink: 'references/cli/experiments#swc',
|
|
22
|
+
isApplicable(di) {
|
|
23
|
+
const configManager = di.get(CONFIG_MANAGER_TOKEN);
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
configManager.serve.configurations?.experiments?.transpilation?.loader !== 'swc' &&
|
|
27
|
+
configManager.build.configurations?.experiments?.transpilation?.loader !== 'swc'
|
|
28
|
+
);
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
text: `Ship modern code to browser`,
|
|
33
|
+
docLink: 'how-to/how-enable-modern',
|
|
34
|
+
isApplicable(di) {
|
|
35
|
+
const configManager = di.get(CONFIG_MANAGER_TOKEN);
|
|
36
|
+
|
|
37
|
+
return configManager.modern !== true;
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
text: `Forget about reloading page with hotRefresh cli option`,
|
|
42
|
+
docLink: 'references/cli/start/#react-hot-refresh',
|
|
43
|
+
isApplicable(di) {
|
|
44
|
+
const configManager = di.get(CONFIG_MANAGER_TOKEN);
|
|
45
|
+
|
|
46
|
+
return configManager.hotRefresh !== true;
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
text: `You can use file-based routing with tramvai.
|
|
51
|
+
It may reduce the boilerplate code required with bundles`,
|
|
52
|
+
docLink: 'features/routing/file-system-pages',
|
|
53
|
+
isApplicable(di) {
|
|
54
|
+
const configManager = di.get(CONFIG_MANAGER_TOKEN);
|
|
55
|
+
const { rootDir, root } = configManager;
|
|
56
|
+
const { fileSystemPages } = configManager.build.configurations;
|
|
57
|
+
|
|
58
|
+
if (!fileSystemPages.enable) {
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const routesDir = path.resolve(rootDir, root, fileSystemPages.routesDir || '');
|
|
63
|
+
|
|
64
|
+
if (!existsSync(routesDir)) {
|
|
65
|
+
return true;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return false;
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
text: `@tramvai/react-query is a great way to manage requests in React components`,
|
|
73
|
+
docLink: 'references/tramvai/react-query',
|
|
74
|
+
isApplicable() {
|
|
75
|
+
return !safeRequireResolve('@tramvai/react-query');
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
text: `Did you know tramvai has a set of helpers for testing?`,
|
|
80
|
+
docLink: 'guides/testing',
|
|
81
|
+
isApplicable() {
|
|
82
|
+
return (
|
|
83
|
+
!safeRequireResolve('@tramvai/test-unit') ||
|
|
84
|
+
!safeRequireResolve('@tramvai/test-integration')
|
|
85
|
+
);
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
text: `Do you love typescript as we do?
|
|
90
|
+
Check out our guide how to use typescript with tramvai`,
|
|
91
|
+
docLink: 'guides/strong-typing',
|
|
92
|
+
isApplicable() {
|
|
93
|
+
return true;
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
text: `In case if you are looking how to optimize your bundle`,
|
|
98
|
+
docLink: 'guides/bundle-optimization',
|
|
99
|
+
isApplicable() {
|
|
100
|
+
return true;
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
text: `tramvai now supports tsconfig.paths.
|
|
105
|
+
So you can remove alias config from tramvai.json`,
|
|
106
|
+
docLink: 'references/cli/base#how-to-enable-paths-mapping',
|
|
107
|
+
isApplicable(di) {
|
|
108
|
+
const configManager = di.get(CONFIG_MANAGER_TOKEN);
|
|
109
|
+
|
|
110
|
+
return !!configManager.build.configurations?.alias;
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
text: `Do you use storybook?
|
|
115
|
+
Check storybook integration with tramvai`,
|
|
116
|
+
docLink: 'guides/storybook',
|
|
117
|
+
isApplicable(di) {
|
|
118
|
+
const { rootDir } = di.get(CONFIG_MANAGER_TOKEN);
|
|
119
|
+
let storybookDir = path.resolve(rootDir, 'storybook');
|
|
120
|
+
|
|
121
|
+
if (!existsSync(storybookDir)) {
|
|
122
|
+
storybookDir = rootDir;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
return (
|
|
126
|
+
safeRequireResolve('@storybook/react', storybookDir) &&
|
|
127
|
+
!safeRequireResolve('@tramvai/storybook-addon')
|
|
128
|
+
);
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
text: `Looking for another way to render your app?
|
|
133
|
+
Check available render modes in tramvai`,
|
|
134
|
+
docLink: 'references/modules/page-render-mode',
|
|
135
|
+
isApplicable(di) {
|
|
136
|
+
return !safeRequireResolve('@tramvai/module-page-render-mode');
|
|
137
|
+
},
|
|
138
|
+
},
|
|
139
|
+
];
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Container } from '@tinkoff/dippy';
|
|
2
|
+
|
|
3
|
+
export interface TramvaiTip {
|
|
4
|
+
text: string;
|
|
5
|
+
docLink: string;
|
|
6
|
+
isApplicable: (di: Container) => boolean;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface TramvaiTipUsageInfo {
|
|
10
|
+
lastTimeShowed: number;
|
|
11
|
+
lastTimeShowedByTip: Record<string, number>;
|
|
12
|
+
}
|
|
@@ -2,10 +2,7 @@ import type { Provider } from '@tinkoff/dippy';
|
|
|
2
2
|
import { provide } from '@tinkoff/dippy';
|
|
3
3
|
import { EventEmitter } from 'events';
|
|
4
4
|
import { CONFIG_MANAGER_TOKEN } from '../../../di/tokens';
|
|
5
|
-
import {
|
|
6
|
-
closeWorkerPoolTranspiler,
|
|
7
|
-
closeWorkerPoolStyles,
|
|
8
|
-
} from '../../../library/webpack/utils/workersPool';
|
|
5
|
+
import { closeWorkerPoolTranspiler } from '../../../library/webpack/utils/workersPool';
|
|
9
6
|
import {
|
|
10
7
|
CLOSE_HANDLER_TOKEN,
|
|
11
8
|
EVENT_EMITTER_TOKEN,
|
|
@@ -66,10 +63,7 @@ export const sharedProviders: Provider[] = [
|
|
|
66
63
|
multi: true,
|
|
67
64
|
useFactory: ({ configManager }) => {
|
|
68
65
|
return async () => {
|
|
69
|
-
await
|
|
70
|
-
closeWorkerPoolTranspiler(configManager),
|
|
71
|
-
closeWorkerPoolStyles(configManager),
|
|
72
|
-
]);
|
|
66
|
+
await closeWorkerPoolTranspiler(configManager);
|
|
73
67
|
};
|
|
74
68
|
},
|
|
75
69
|
deps: {
|
|
@@ -14,7 +14,8 @@ exports[`client-legacy: create-token-pure.ts 1`] = `
|
|
|
14
14
|
|
|
15
15
|
exports[`client-legacy: images/logo.svg\\?react 1`] = `
|
|
16
16
|
" /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("webpack/sharing/consume/default/react/jsx-runtime/react/jsx-runtime");
|
|
17
|
-
/* harmony import */
|
|
17
|
+
/* harmony import */ __webpack_require__("webpack/sharing/consume/default/react/react");
|
|
18
|
+
function _extends() {
|
|
18
19
|
return _extends = Object.assign || function(target) {
|
|
19
20
|
for (var i = 1; i < arguments.length; i++) {
|
|
20
21
|
var source = arguments[i];
|
|
@@ -206,7 +207,8 @@ exports[`client-modern: images/logo.svg\\?react 1`] = `
|
|
|
206
207
|
}
|
|
207
208
|
/* harmony export */ });
|
|
208
209
|
/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("webpack/sharing/consume/default/react/jsx-runtime/react/jsx-runtime");
|
|
209
|
-
/* harmony import */
|
|
210
|
+
/* harmony import */ __webpack_require__("webpack/sharing/consume/default/react/react");
|
|
211
|
+
function _extends() {
|
|
210
212
|
return _extends = Object.assign || function(target) {
|
|
211
213
|
for (var i = 1; i < arguments.length; i++) {
|
|
212
214
|
var source = arguments[i];
|
|
@@ -377,6 +379,9 @@ exports[`server: images/logo.svg\\?react 1`] = `
|
|
|
377
379
|
/* harmony export */ });
|
|
378
380
|
/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("webpack/sharing/consume/default/react/jsx-runtime/react/jsx-runtime");
|
|
379
381
|
/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__);
|
|
382
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("webpack/sharing/consume/default/react/react");
|
|
383
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);
|
|
384
|
+
|
|
380
385
|
|
|
381
386
|
const SvgLogo = (props)=>/*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("svg", {
|
|
382
387
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -55,6 +55,8 @@ exports[`client: images/logo.svg\\?react 1`] = `
|
|
|
55
55
|
/* harmony export */ });
|
|
56
56
|
/* harmony import */ var react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("webpack/sharing/consume/default/react/jsx-dev-runtime/react/jsx-dev-runtime");
|
|
57
57
|
/* harmony import */ var react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_0__);
|
|
58
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("webpack/sharing/consume/default/react/react");
|
|
59
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);
|
|
58
60
|
function _extends() {
|
|
59
61
|
_extends = Object.assign || function(target) {
|
|
60
62
|
for(var i = 1; i < arguments.length; i++){
|
|
@@ -70,6 +72,7 @@ function _extends() {
|
|
|
70
72
|
return _extends.apply(this, arguments);
|
|
71
73
|
}
|
|
72
74
|
|
|
75
|
+
|
|
73
76
|
const SvgLogo = (props)=>/*#__PURE__*/ (0,react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxDEV)("svg", _extends({
|
|
74
77
|
xmlns: "http://www.w3.org/2000/svg",
|
|
75
78
|
viewBox: "0 0 80.9 72.2",
|
|
@@ -536,6 +539,9 @@ exports[`server: images/logo.svg\\?react 1`] = `
|
|
|
536
539
|
/* harmony export */ });
|
|
537
540
|
/* harmony import */ var react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("webpack/sharing/consume/default/react/jsx-dev-runtime/react/jsx-dev-runtime");
|
|
538
541
|
/* harmony import */ var react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_0__);
|
|
542
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("react");
|
|
543
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);
|
|
544
|
+
|
|
539
545
|
|
|
540
546
|
const SvgLogo = (props)=>/*#__PURE__*/ (0,react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxDEV)("svg", {
|
|
541
547
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -59,28 +59,3 @@ export const createWorkerPoolTranspiler = (configManager: ConfigManager) => {
|
|
|
59
59
|
export const closeWorkerPoolTranspiler = (configManager: ConfigManager) => {
|
|
60
60
|
getPool(createTranspilerConfig(configManager))?.disposeWorkers();
|
|
61
61
|
};
|
|
62
|
-
|
|
63
|
-
const createStylesConfig = (configManager: ConfigManager) => {
|
|
64
|
-
return {
|
|
65
|
-
name: 'styles',
|
|
66
|
-
workerParallelJobs: 2,
|
|
67
|
-
workers: Math.max(getCpuNumber(), 2),
|
|
68
|
-
poolTimeout: configManager.env === 'development' ? Infinity : undefined,
|
|
69
|
-
...getCustomConfig(configManager),
|
|
70
|
-
};
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
export const createWorkerPoolStyles = (configManager: ConfigManager) => {
|
|
74
|
-
const config = createStylesConfig;
|
|
75
|
-
|
|
76
|
-
if (!(createWorkerPoolStyles as any).warmup) {
|
|
77
|
-
threadLoader.warmup(config, ['postcss-loader']);
|
|
78
|
-
(createWorkerPoolStyles as any).warmup = true;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
return config;
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
export const closeWorkerPoolStyles = (configManager: ConfigManager) => {
|
|
85
|
-
getPool(createStylesConfig(configManager))?.disposeWorkers();
|
|
86
|
-
};
|