@gravity-ui/app-builder 0.13.1 → 0.13.2
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/commands/dev/index.js +5 -3
- package/dist/common/typescript/compile.js +10 -18
- package/dist/common/typescript/utils.d.ts +2 -1
- package/dist/common/typescript/utils.js +20 -2
- package/dist/common/typescript/watch.js +1 -1
- package/dist/common/webpack/config.js +1 -1
- package/dist/common/webpack/utils.d.ts +5 -2
- package/dist/common/webpack/utils.js +16 -19
- package/package.json +1 -1
|
@@ -49,6 +49,10 @@ async function default_1(config) {
|
|
|
49
49
|
const startNodemon = () => {
|
|
50
50
|
if (needToStartNodemon && serverCompiled && clientCompiled) {
|
|
51
51
|
logger_1.default.message('Starting application at', serverPath);
|
|
52
|
+
const nodeArgs = ['--enable-source-maps'];
|
|
53
|
+
if (inspect || inspectBrk) {
|
|
54
|
+
nodeArgs.push(`--${inspect ? 'inspect' : 'inspect-brk'}=:::${inspect || inspectBrk}`);
|
|
55
|
+
}
|
|
52
56
|
const serverWatch = config.server.watch ?? [];
|
|
53
57
|
const delay = config.server.watchThrottle;
|
|
54
58
|
const nodemonInstance = (0, nodemon_1.default)({
|
|
@@ -58,9 +62,7 @@ async function default_1(config) {
|
|
|
58
62
|
env: {
|
|
59
63
|
...(config.server.port ? { APP_PORT: config.server.port } : undefined),
|
|
60
64
|
},
|
|
61
|
-
nodeArgs
|
|
62
|
-
? [`--${inspect ? 'inspect' : 'inspect-brk'}=:::${inspect || inspectBrk}`]
|
|
63
|
-
: undefined,
|
|
65
|
+
nodeArgs,
|
|
64
66
|
watch: [serverPath, ...serverWatch],
|
|
65
67
|
delay,
|
|
66
68
|
});
|
|
@@ -10,24 +10,11 @@ function compile(ts, { projectPath, configFileName = 'tsconfig.json', optionsToE
|
|
|
10
10
|
logger.message('Start compilation');
|
|
11
11
|
logger.message(`Typescript v${ts.version}`);
|
|
12
12
|
logger.verbose(`Searching for the ${configFileName} in ${projectPath}`);
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
};
|
|
19
|
-
const parseConfigFileHost = {
|
|
20
|
-
getCurrentDirectory: ts.sys.getCurrentDirectory,
|
|
21
|
-
useCaseSensitiveFileNames: ts.sys.useCaseSensitiveFileNames,
|
|
22
|
-
readDirectory: ts.sys.readDirectory,
|
|
23
|
-
fileExists: ts.sys.fileExists,
|
|
24
|
-
readFile: ts.sys.readFile,
|
|
25
|
-
onUnRecoverableConfigFileDiagnostic: reportDiagnostic,
|
|
26
|
-
};
|
|
27
|
-
const parsedConfig = ts.getParsedCommandLineOfConfigFile(configPath, { noEmit: false, noEmitOnError: true, ...optionsToExtend }, parseConfigFileHost);
|
|
28
|
-
if (!parsedConfig) {
|
|
29
|
-
throw new Error(`Invalid '${configFileName}'`);
|
|
30
|
-
}
|
|
13
|
+
const parsedConfig = (0, utils_1.getTsProjectConfig)(ts, projectPath, configFileName, {
|
|
14
|
+
noEmit: false,
|
|
15
|
+
noEmitOnError: true,
|
|
16
|
+
...optionsToExtend,
|
|
17
|
+
});
|
|
31
18
|
logger.verbose('Config found and parsed');
|
|
32
19
|
logger.verbose("We're about to create the program");
|
|
33
20
|
const compilerHost = ts.createCompilerHost(parsedConfig.options);
|
|
@@ -57,6 +44,11 @@ function compile(ts, { projectPath, configFileName = 'tsconfig.json', optionsToE
|
|
|
57
44
|
else {
|
|
58
45
|
logger.success(`Compiled successfully in ${(0, pretty_time_1.elapsedTime)(start)}`);
|
|
59
46
|
}
|
|
47
|
+
const formatHost = {
|
|
48
|
+
getCanonicalFileName: (path) => path,
|
|
49
|
+
getCurrentDirectory: ts.sys.getCurrentDirectory,
|
|
50
|
+
getNewLine: () => ts.sys.newLine,
|
|
51
|
+
};
|
|
60
52
|
function reportDiagnostic(diagnostic) {
|
|
61
53
|
if (logger.isVerbose) {
|
|
62
54
|
logger.message(ts.formatDiagnosticsWithColorAndContext([diagnostic], formatHost));
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type Typescript from 'typescript';
|
|
2
2
|
import type { Logger } from '../logger';
|
|
3
|
-
export declare function
|
|
3
|
+
export declare function getTsProjectConfigPath(ts: typeof Typescript, projectPath: string, filename?: string): string;
|
|
4
|
+
export declare function getTsProjectConfig(ts: typeof Typescript, projectPath: string, filename?: string, optionsToExtend?: Typescript.CompilerOptions): Typescript.ParsedCommandLine;
|
|
4
5
|
export declare function displayFilename(originalFunc: (path: string, encoding?: string) => string | undefined, operationName: string, logger: Logger): {
|
|
5
6
|
(path: string, encoding?: string | undefined): string | undefined;
|
|
6
7
|
originalFunc: (path: string, encoding?: string) => string | undefined;
|
|
@@ -3,19 +3,37 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.getTsProjectConfigPath = getTsProjectConfigPath;
|
|
7
|
+
exports.getTsProjectConfig = getTsProjectConfig;
|
|
7
8
|
exports.displayFilename = displayFilename;
|
|
8
9
|
exports.onHostEvent = onHostEvent;
|
|
9
10
|
exports.resolveTypescript = resolveTypescript;
|
|
10
11
|
const node_path_1 = __importDefault(require("node:path"));
|
|
11
12
|
const paths_1 = __importDefault(require("../paths"));
|
|
12
|
-
function
|
|
13
|
+
function getTsProjectConfigPath(ts, projectPath, filename = 'tsconfig.json') {
|
|
13
14
|
const configPath = ts.findConfigFile(projectPath, ts.sys.fileExists, filename);
|
|
14
15
|
if (!configPath) {
|
|
15
16
|
throw new Error(`Could not find a valid '${filename}'.`);
|
|
16
17
|
}
|
|
17
18
|
return configPath;
|
|
18
19
|
}
|
|
20
|
+
function getTsProjectConfig(ts, projectPath, filename = 'tsconfig.json', optionsToExtend) {
|
|
21
|
+
const configPath = getTsProjectConfigPath(ts, projectPath, filename);
|
|
22
|
+
const parseConfigFileHost = {
|
|
23
|
+
getCurrentDirectory: ts.sys.getCurrentDirectory,
|
|
24
|
+
useCaseSensitiveFileNames: ts.sys.useCaseSensitiveFileNames,
|
|
25
|
+
readDirectory: ts.sys.readDirectory,
|
|
26
|
+
fileExists: ts.sys.fileExists,
|
|
27
|
+
readFile: ts.sys.readFile,
|
|
28
|
+
// this is required in types but not used
|
|
29
|
+
onUnRecoverableConfigFileDiagnostic: () => { },
|
|
30
|
+
};
|
|
31
|
+
const parsedConfig = ts.getParsedCommandLineOfConfigFile(configPath, optionsToExtend, parseConfigFileHost);
|
|
32
|
+
if (!parsedConfig) {
|
|
33
|
+
throw new Error(`Invalid config file '${configPath}'`);
|
|
34
|
+
}
|
|
35
|
+
return parsedConfig;
|
|
36
|
+
}
|
|
19
37
|
function displayFilename(originalFunc, operationName, logger) {
|
|
20
38
|
let displayEnabled = false;
|
|
21
39
|
let count = 0;
|
|
@@ -7,7 +7,7 @@ const diagnostic_1 = require("./diagnostic");
|
|
|
7
7
|
function watch(ts, projectPath, { logger, onAfterFilesEmitted, enableSourceMap, }) {
|
|
8
8
|
logger.message('Start compilation in watch mode');
|
|
9
9
|
logger.message(`Typescript v${ts.version}`);
|
|
10
|
-
const configPath = (0, utils_1.
|
|
10
|
+
const configPath = (0, utils_1.getTsProjectConfigPath)(ts, projectPath);
|
|
11
11
|
const createProgram = ts.createEmitAndSemanticDiagnosticsBuilderProgram;
|
|
12
12
|
const formatHost = {
|
|
13
13
|
getCanonicalFileName: (path) => path,
|
|
@@ -174,7 +174,7 @@ function configureResolve({ isEnvProduction, config }) {
|
|
|
174
174
|
alias['react-dom$'] = 'react-dom/profiling';
|
|
175
175
|
alias['scheduler/tracing'] = 'scheduler/tracing-profiling';
|
|
176
176
|
}
|
|
177
|
-
const { aliases, modules = [] } = (0, utils_1.
|
|
177
|
+
const { aliases, modules = [] } = (0, utils_1.resolveTsConfigPathsToAlias)(paths_1.default.appClient);
|
|
178
178
|
return {
|
|
179
179
|
alias: {
|
|
180
180
|
...aliases,
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import type webpack from 'webpack';
|
|
2
2
|
import type { Logger } from '../logger';
|
|
3
3
|
export declare function webpackCompilerHandlerFactory(logger: Logger, onCompilationEnd?: () => void): (err?: Error | null, stats?: webpack.Stats) => Promise<void>;
|
|
4
|
-
export declare function
|
|
4
|
+
export declare function resolveTsConfigPathsToAlias(projectPath: string, filename?: string): {
|
|
5
|
+
aliases?: undefined;
|
|
6
|
+
modules?: undefined;
|
|
7
|
+
} | {
|
|
5
8
|
aliases: Record<string, string[]>;
|
|
6
9
|
modules: string[];
|
|
7
|
-
}
|
|
10
|
+
};
|
|
@@ -24,10 +24,11 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.webpackCompilerHandlerFactory = webpackCompilerHandlerFactory;
|
|
27
|
-
exports.
|
|
27
|
+
exports.resolveTsConfigPathsToAlias = resolveTsConfigPathsToAlias;
|
|
28
28
|
const path = __importStar(require("node:path"));
|
|
29
|
-
const
|
|
29
|
+
const ts = __importStar(require("typescript"));
|
|
30
30
|
const pretty_time_1 = require("../logger/pretty-time");
|
|
31
|
+
const utils_1 = require("../typescript/utils");
|
|
31
32
|
function webpackCompilerHandlerFactory(logger, onCompilationEnd) {
|
|
32
33
|
return async (err, stats) => {
|
|
33
34
|
if (err) {
|
|
@@ -60,15 +61,22 @@ function webpackCompilerHandlerFactory(logger, onCompilationEnd) {
|
|
|
60
61
|
};
|
|
61
62
|
}
|
|
62
63
|
const endStarRe = /\/?\*$/;
|
|
63
|
-
function
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
function resolveTsConfigPathsToAlias(projectPath, filename = 'tsconfig.json') {
|
|
65
|
+
let parsed;
|
|
66
|
+
try {
|
|
67
|
+
parsed = (0, utils_1.getTsProjectConfig)(ts, projectPath, filename);
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
return {};
|
|
66
71
|
}
|
|
67
|
-
|
|
72
|
+
if (parsed.errors.length > 0) {
|
|
73
|
+
return {};
|
|
74
|
+
}
|
|
75
|
+
const { paths = {}, baseUrl } = parsed.options;
|
|
68
76
|
if (!baseUrl) {
|
|
69
|
-
return
|
|
77
|
+
return {};
|
|
70
78
|
}
|
|
71
|
-
const basePath = path.resolve(path.dirname(
|
|
79
|
+
const basePath = path.resolve(path.dirname(projectPath), baseUrl);
|
|
72
80
|
const aliases = {};
|
|
73
81
|
const modules = [basePath];
|
|
74
82
|
for (const [key, value] of Object.entries(paths)) {
|
|
@@ -84,14 +92,3 @@ function resolveTsconfigPathsToAlias(tsConfigPath) {
|
|
|
84
92
|
}
|
|
85
93
|
return { aliases, modules };
|
|
86
94
|
}
|
|
87
|
-
function readJsonConfig(pathname) {
|
|
88
|
-
try {
|
|
89
|
-
const json = fs.readFileSync(pathname, 'utf-8');
|
|
90
|
-
return {
|
|
91
|
-
...JSON.parse(json),
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
catch {
|
|
95
|
-
throw new Error(`Couldn't read config ${pathname}`);
|
|
96
|
-
}
|
|
97
|
-
}
|