@gravity-ui/app-builder 0.30.0 → 0.30.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/dist/cli.js +20 -15
- package/dist/commands/build/build-lib.js +8 -5
- package/dist/commands/build/build-service/client.js +6 -3
- package/dist/commands/build/build-service/index.js +7 -4
- package/dist/commands/build/build-service/server.js +17 -11
- package/dist/commands/build/index.js +6 -3
- package/dist/commands/dev/client.js +63 -34
- package/dist/commands/dev/index.js +50 -21
- package/dist/commands/dev/server.js +42 -13
- package/dist/common/babel/index.js +4 -1
- package/dist/common/babel/ui-preset.d.ts +1 -1
- package/dist/common/babel/ui-preset.js +1 -0
- package/dist/common/child-process/controllable-script.js +32 -5
- package/dist/common/child-process/utils.js +30 -4
- package/dist/common/command.js +2 -1
- package/dist/common/config.js +49 -19
- package/dist/common/env.js +5 -3
- package/dist/common/library/babel-plugin-replace-paths.js +4 -2
- package/dist/common/library/index.js +95 -66
- package/dist/common/logger/colors.js +8 -2
- package/dist/common/logger/index.js +24 -17
- package/dist/common/logger/log-config.js +6 -3
- package/dist/common/logger/pretty-time.js +6 -2
- package/dist/common/models/index.d.ts +1 -1
- package/dist/common/models/index.js +8 -3
- package/dist/common/paths.js +28 -3
- package/dist/common/s3-upload/compress.js +12 -8
- package/dist/common/s3-upload/create-plugin.js +30 -4
- package/dist/common/s3-upload/index.js +9 -3
- package/dist/common/s3-upload/s3-client.js +37 -11
- package/dist/common/s3-upload/upload.js +38 -9
- package/dist/common/s3-upload/webpack-plugin.js +9 -5
- package/dist/common/swc/compile.js +12 -9
- package/dist/common/swc/index.js +7 -2
- package/dist/common/swc/utils.js +13 -6
- package/dist/common/swc/watch.js +9 -6
- package/dist/common/typescript/compile.js +14 -11
- package/dist/common/typescript/diagnostic.js +37 -11
- package/dist/common/typescript/transformers.js +29 -3
- package/dist/common/typescript/utils.js +18 -8
- package/dist/common/typescript/watch.js +13 -10
- package/dist/common/utils.js +25 -14
- package/dist/common/webpack/compile.js +22 -16
- package/dist/common/webpack/config.js +113 -80
- package/dist/common/webpack/node-externals.js +34 -5
- package/dist/common/webpack/progress-plugin.js +6 -3
- package/dist/common/webpack/public-path.d.ts +1 -0
- package/dist/common/webpack/public-path.js +1 -0
- package/dist/common/webpack/rspack.js +5 -1
- package/dist/common/webpack/runtime-versioning-plugin.js +3 -1
- package/dist/common/webpack/storybook.js +51 -21
- package/dist/common/webpack/utils.js +36 -9
- package/dist/common/webpack/worker/public-path.worker.d.ts +1 -0
- package/dist/common/webpack/worker/public-path.worker.js +1 -0
- package/dist/common/webpack/worker/worker-loader.js +34 -4
- package/dist/create-cli.js +48 -19
- package/dist/index.js +27 -5
- package/package.json +1 -2
|
@@ -1,6 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.createTransformPathsToLocalModules = createTransformPathsToLocalModules;
|
|
27
|
+
const path = __importStar(require("node:path"));
|
|
28
|
+
const semver = __importStar(require("semver"));
|
|
29
|
+
function createTransformPathsToLocalModules(ts) {
|
|
4
30
|
function resolveModule(module, sourceFileName, options) {
|
|
5
31
|
if (module.startsWith('.')) {
|
|
6
32
|
return undefined;
|
|
@@ -1,13 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getTsProjectConfigPath = getTsProjectConfigPath;
|
|
7
|
+
exports.getTsProjectConfig = getTsProjectConfig;
|
|
8
|
+
exports.displayFilename = displayFilename;
|
|
9
|
+
exports.onHostEvent = onHostEvent;
|
|
10
|
+
exports.resolveTypescript = resolveTypescript;
|
|
11
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
12
|
+
const paths_1 = __importDefault(require("../paths"));
|
|
13
|
+
function getTsProjectConfigPath(ts, projectPath, filename = 'tsconfig.json') {
|
|
4
14
|
const configPath = ts.findConfigFile(projectPath, ts.sys.fileExists, filename);
|
|
5
15
|
if (!configPath) {
|
|
6
16
|
throw new Error(`Could not find a valid '${filename}'.`);
|
|
7
17
|
}
|
|
8
18
|
return configPath;
|
|
9
19
|
}
|
|
10
|
-
|
|
20
|
+
function getTsProjectConfig(ts, projectPath, filename = 'tsconfig.json', optionsToExtend) {
|
|
11
21
|
const configPath = getTsProjectConfigPath(ts, projectPath, filename);
|
|
12
22
|
const parseConfigFileHost = {
|
|
13
23
|
getCurrentDirectory: ts.sys.getCurrentDirectory,
|
|
@@ -24,7 +34,7 @@ export function getTsProjectConfig(ts, projectPath, filename = 'tsconfig.json',
|
|
|
24
34
|
}
|
|
25
35
|
return parsedConfig;
|
|
26
36
|
}
|
|
27
|
-
|
|
37
|
+
function displayFilename(originalFunc, operationName, logger) {
|
|
28
38
|
let displayEnabled = false;
|
|
29
39
|
let count = 0;
|
|
30
40
|
function displayFunction(...args) {
|
|
@@ -52,7 +62,7 @@ export function displayFilename(originalFunc, operationName, logger) {
|
|
|
52
62
|
return displayFunction;
|
|
53
63
|
}
|
|
54
64
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
55
|
-
|
|
65
|
+
function onHostEvent(host, functionName, before, after) {
|
|
56
66
|
const originalFunction = host[functionName];
|
|
57
67
|
// eslint-disable-next-line no-param-reassign
|
|
58
68
|
host[functionName] = ((...args) => {
|
|
@@ -69,9 +79,9 @@ export function onHostEvent(host, functionName, before, after) {
|
|
|
69
79
|
return result;
|
|
70
80
|
});
|
|
71
81
|
}
|
|
72
|
-
|
|
82
|
+
function resolveTypescript() {
|
|
73
83
|
try {
|
|
74
|
-
return require.resolve(
|
|
84
|
+
return require.resolve(node_path_1.default.resolve(paths_1.default.appNodeModules, 'typescript'));
|
|
75
85
|
}
|
|
76
86
|
catch (err) {
|
|
77
87
|
if (!err ||
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.watch = watch;
|
|
4
|
+
const transformers_1 = require("./transformers");
|
|
5
|
+
const utils_1 = require("./utils");
|
|
6
|
+
const diagnostic_1 = require("./diagnostic");
|
|
7
|
+
function watch(ts, projectPath, { logger, onAfterFilesEmitted, enableSourceMap, }) {
|
|
5
8
|
logger.message('Start compilation in watch mode');
|
|
6
9
|
logger.message(`Typescript v${ts.version}`);
|
|
7
|
-
const configPath = getTsProjectConfigPath(ts, projectPath);
|
|
10
|
+
const configPath = (0, utils_1.getTsProjectConfigPath)(ts, projectPath);
|
|
8
11
|
const createProgram = ts.createEmitAndSemanticDiagnosticsBuilderProgram;
|
|
9
12
|
const host = ts.createWatchCompilerHost(configPath, {
|
|
10
13
|
noEmit: false,
|
|
@@ -13,8 +16,8 @@ export function watch(ts, projectPath, { logger, onAfterFilesEmitted, enableSour
|
|
|
13
16
|
inlineSources: enableSourceMap,
|
|
14
17
|
...(enableSourceMap ? { sourceMap: false } : undefined),
|
|
15
18
|
}, ts.sys, createProgram, reportDiagnostic, reportWatchStatusChanged);
|
|
16
|
-
host.readFile = displayFilename(host.readFile, 'Reading', logger);
|
|
17
|
-
onHostEvent(host, 'createProgram', () => {
|
|
19
|
+
host.readFile = (0, utils_1.displayFilename)(host.readFile, 'Reading', logger);
|
|
20
|
+
(0, utils_1.onHostEvent)(host, 'createProgram', () => {
|
|
18
21
|
logger.verbose("We're about to create the program");
|
|
19
22
|
// @ts-expect-error
|
|
20
23
|
host.readFile.enableDisplay();
|
|
@@ -23,9 +26,9 @@ export function watch(ts, projectPath, { logger, onAfterFilesEmitted, enableSour
|
|
|
23
26
|
const count = host.readFile.disableDisplay();
|
|
24
27
|
logger.verbose(`Program created, read ${count} files`);
|
|
25
28
|
});
|
|
26
|
-
onHostEvent(host, 'afterProgramCreate', (program) => {
|
|
29
|
+
(0, utils_1.onHostEvent)(host, 'afterProgramCreate', (program) => {
|
|
27
30
|
logger.verbose('We finished making the program! Emitting...');
|
|
28
|
-
const transformPathsToLocalModules = createTransformPathsToLocalModules(ts);
|
|
31
|
+
const transformPathsToLocalModules = (0, transformers_1.createTransformPathsToLocalModules)(ts);
|
|
29
32
|
program.emit(undefined, undefined, undefined, undefined, {
|
|
30
33
|
after: [transformPathsToLocalModules],
|
|
31
34
|
afterDeclarations: [transformPathsToLocalModules],
|
|
@@ -47,7 +50,7 @@ export function watch(ts, projectPath, { logger, onAfterFilesEmitted, enableSour
|
|
|
47
50
|
logger.message(ts.formatDiagnosticsWithColorAndContext([diagnostic], formatHost));
|
|
48
51
|
}
|
|
49
52
|
else {
|
|
50
|
-
logger.message(formatDiagnosticBrief(ts, diagnostic, formatHost));
|
|
53
|
+
logger.message((0, diagnostic_1.formatDiagnosticBrief)(ts, diagnostic, formatHost));
|
|
51
54
|
}
|
|
52
55
|
}
|
|
53
56
|
/*
|
package/dist/common/utils.js
CHANGED
|
@@ -1,28 +1,39 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getAppRunPath = getAppRunPath;
|
|
7
|
+
exports.createRunFolder = createRunFolder;
|
|
8
|
+
exports.shouldCompileTarget = shouldCompileTarget;
|
|
9
|
+
exports.getCacheDir = getCacheDir;
|
|
10
|
+
exports.getPort = getPort;
|
|
11
|
+
exports.deferredPromise = deferredPromise;
|
|
12
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
13
|
+
const node_os_1 = __importDefault(require("node:os"));
|
|
14
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
15
|
+
const paths_1 = __importDefault(require("./paths"));
|
|
16
|
+
function getAppRunPath(config) {
|
|
17
|
+
return node_path_1.default.resolve(paths_1.default.appRun, config.client.moduleFederation?.name || '');
|
|
7
18
|
}
|
|
8
|
-
|
|
19
|
+
function createRunFolder(config) {
|
|
9
20
|
const appRunPath = getAppRunPath(config);
|
|
10
|
-
if (!
|
|
11
|
-
|
|
21
|
+
if (!node_fs_1.default.existsSync(appRunPath)) {
|
|
22
|
+
node_fs_1.default.mkdirSync(appRunPath, { recursive: true });
|
|
12
23
|
}
|
|
13
24
|
}
|
|
14
|
-
|
|
25
|
+
function shouldCompileTarget(target, targetName) {
|
|
15
26
|
return target === undefined || target === targetName;
|
|
16
27
|
}
|
|
17
|
-
|
|
28
|
+
async function getCacheDir() {
|
|
18
29
|
const { default: findCacheDirectory } = await import('find-cache-dir');
|
|
19
|
-
return findCacheDirectory({ name: '@gravity-ui/app-builder', create: true }) ||
|
|
30
|
+
return findCacheDirectory({ name: '@gravity-ui/app-builder', create: true }) || node_os_1.default.tmpdir();
|
|
20
31
|
}
|
|
21
|
-
|
|
32
|
+
async function getPort({ port }) {
|
|
22
33
|
const { default: getPortDefault, portNumbers } = await import('get-port');
|
|
23
34
|
return getPortDefault({ port: portNumbers(port, port + 100) });
|
|
24
35
|
}
|
|
25
|
-
|
|
36
|
+
function deferredPromise() {
|
|
26
37
|
let resolve;
|
|
27
38
|
let reject;
|
|
28
39
|
const promise = new Promise((res, rej) => {
|
|
@@ -1,23 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.clientCompile = clientCompile;
|
|
7
|
+
const webpack_1 = __importDefault(require("webpack"));
|
|
8
|
+
const core_1 = require("@rspack/core");
|
|
9
|
+
const logger_1 = require("../logger");
|
|
10
|
+
const config_1 = require("./config");
|
|
11
|
+
const utils_1 = require("./utils");
|
|
12
|
+
async function clientCompile(config, configPath) {
|
|
13
|
+
const logger = new logger_1.Logger('client', config.verbose);
|
|
8
14
|
const webpackConfigs = [];
|
|
9
15
|
const rspackConfigs = [];
|
|
10
16
|
const isSsr = Boolean(config.ssr);
|
|
11
17
|
if (config.bundler === 'rspack') {
|
|
12
|
-
rspackConfigs.push(await rspackConfigFactory({
|
|
18
|
+
rspackConfigs.push(await (0, config_1.rspackConfigFactory)({
|
|
13
19
|
webpackMode: "production" /* WebpackMode.Prod */,
|
|
14
20
|
config,
|
|
15
21
|
configPath,
|
|
16
22
|
logger,
|
|
17
23
|
}));
|
|
18
24
|
if (isSsr) {
|
|
19
|
-
const ssrLogger = new Logger('client(SSR)', config.verbose);
|
|
20
|
-
rspackConfigs.push(await rspackConfigFactory({
|
|
25
|
+
const ssrLogger = new logger_1.Logger('client(SSR)', config.verbose);
|
|
26
|
+
rspackConfigs.push(await (0, config_1.rspackConfigFactory)({
|
|
21
27
|
webpackMode: "production" /* WebpackMode.Prod */,
|
|
22
28
|
config,
|
|
23
29
|
configPath,
|
|
@@ -27,15 +33,15 @@ export async function clientCompile(config, configPath) {
|
|
|
27
33
|
}
|
|
28
34
|
}
|
|
29
35
|
else {
|
|
30
|
-
webpackConfigs.push(await webpackConfigFactory({
|
|
36
|
+
webpackConfigs.push(await (0, config_1.webpackConfigFactory)({
|
|
31
37
|
webpackMode: "production" /* WebpackMode.Prod */,
|
|
32
38
|
config,
|
|
33
39
|
configPath,
|
|
34
40
|
logger,
|
|
35
41
|
}));
|
|
36
42
|
if (isSsr) {
|
|
37
|
-
const ssrLogger = new Logger('client(SSR)', config.verbose);
|
|
38
|
-
webpackConfigs.push(await webpackConfigFactory({
|
|
43
|
+
const ssrLogger = new logger_1.Logger('client(SSR)', config.verbose);
|
|
44
|
+
webpackConfigs.push(await (0, config_1.webpackConfigFactory)({
|
|
39
45
|
webpackMode: "production" /* WebpackMode.Prod */,
|
|
40
46
|
config,
|
|
41
47
|
configPath,
|
|
@@ -46,12 +52,12 @@ export async function clientCompile(config, configPath) {
|
|
|
46
52
|
}
|
|
47
53
|
logger.verbose('Config created');
|
|
48
54
|
return new Promise((resolve) => {
|
|
49
|
-
const compilerHandler = compilerHandlerFactory(logger, async () => {
|
|
55
|
+
const compilerHandler = (0, utils_1.compilerHandlerFactory)(logger, async () => {
|
|
50
56
|
resolve();
|
|
51
57
|
});
|
|
52
58
|
const compiler = config.bundler === 'rspack'
|
|
53
|
-
? rspack(rspackConfigs, compilerHandler)
|
|
54
|
-
:
|
|
59
|
+
? (0, core_1.rspack)(rspackConfigs, compilerHandler)
|
|
60
|
+
: (0, webpack_1.default)(webpackConfigs, compilerHandler);
|
|
55
61
|
process.on('SIGINT', async () => {
|
|
56
62
|
compiler?.close(() => {
|
|
57
63
|
process.exit(1);
|