@gravity-ui/app-builder 0.41.0-beta.0 → 0.41.0-beta.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.
|
@@ -4,7 +4,6 @@ interface CompileOptions {
|
|
|
4
4
|
projectPath: string;
|
|
5
5
|
configFileName?: string;
|
|
6
6
|
logger: Logger;
|
|
7
|
-
optionsToExtend?: Typescript.CompilerOptions;
|
|
8
7
|
}
|
|
9
|
-
export declare function compile(ts: typeof Typescript, { projectPath, configFileName,
|
|
8
|
+
export declare function compile(ts: typeof Typescript, { projectPath, configFileName, logger }: CompileOptions): void;
|
|
10
9
|
export {};
|
|
@@ -5,50 +5,45 @@ const utils_1 = require("./utils");
|
|
|
5
5
|
const transformers_1 = require("./transformers");
|
|
6
6
|
const pretty_time_1 = require("../logger/pretty-time");
|
|
7
7
|
const diagnostic_1 = require("./diagnostic");
|
|
8
|
-
function compile(ts, { projectPath, configFileName = 'tsconfig.json',
|
|
8
|
+
function compile(ts, { projectPath, configFileName = 'tsconfig.json', logger }) {
|
|
9
9
|
const start = process.hrtime.bigint();
|
|
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 parsedConfig = (0, utils_1.getTsProjectConfig)(ts, projectPath, configFileName, {
|
|
14
|
-
noEmit: false,
|
|
15
|
-
noEmitOnError: true,
|
|
16
|
-
...optionsToExtend,
|
|
17
|
-
});
|
|
18
13
|
logger.verbose('Config found and parsed');
|
|
19
14
|
logger.verbose("We're about to create the program");
|
|
20
|
-
const compilerHost = ts.
|
|
15
|
+
const compilerHost = ts.createSolutionBuilderHost(ts.sys, ts.createEmitAndSemanticDiagnosticsBuilderProgram, reportDiagnostic, reportDiagnostic);
|
|
21
16
|
compilerHost.readFile = (0, utils_1.displayFilename)(compilerHost.readFile, 'Reading', logger);
|
|
22
|
-
// @ts-expect-error
|
|
17
|
+
// @ts-expect-error We invoke method from overrided function
|
|
23
18
|
compilerHost.readFile.enableDisplay();
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
options: parsedConfig.options,
|
|
27
|
-
projectReferences: parsedConfig.projectReferences,
|
|
28
|
-
host: compilerHost,
|
|
29
|
-
});
|
|
30
|
-
// @ts-expect-error
|
|
19
|
+
const solutionBuilder = ts.createSolutionBuilder(compilerHost, [(0, utils_1.getTsProjectConfigPath)(ts, projectPath, configFileName)], { noEmitOnError: true });
|
|
20
|
+
// @ts-expect-error We invoke method from overrided function
|
|
31
21
|
const filesCount = compilerHost.readFile.disableDisplay();
|
|
32
|
-
let allDiagnostics = ts.getPreEmitDiagnostics(program);
|
|
33
22
|
logger.verbose(`Program created, read ${filesCount} files`);
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
23
|
+
logger.verbose('We finished making the program! Emitting...');
|
|
24
|
+
const transformPathsToLocalModules = (0, transformers_1.createTransformPathsToLocalModules)(ts);
|
|
25
|
+
let project = solutionBuilder.getNextInvalidatedProject();
|
|
26
|
+
do {
|
|
27
|
+
if (project?.kind === ts.InvalidatedProjectKind.Build) {
|
|
28
|
+
const emitResult = project.emit(undefined, undefined, undefined, undefined, {
|
|
29
|
+
after: [transformPathsToLocalModules],
|
|
30
|
+
afterDeclarations: [transformPathsToLocalModules],
|
|
31
|
+
});
|
|
32
|
+
if (emitResult?.diagnostics) {
|
|
33
|
+
const diagnostics = ts.sortAndDeduplicateDiagnostics(emitResult?.diagnostics);
|
|
34
|
+
if (hasErrors(diagnostics)) {
|
|
35
|
+
logger.error(`Error compile, elapsed time ${(0, pretty_time_1.elapsedTime)(start)}`);
|
|
36
|
+
process.exit(1);
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
logger.success(`Compiled successfully in ${(0, pretty_time_1.elapsedTime)(start)}`);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
project?.done();
|
|
44
|
+
project = solutionBuilder.getNextInvalidatedProject();
|
|
45
|
+
} while (project);
|
|
46
|
+
logger.verbose('Emit complete!');
|
|
52
47
|
function reportDiagnostic(diagnostic) {
|
|
53
48
|
const formatHost = {
|
|
54
49
|
getCanonicalFileName: (path) => path,
|
package/package.json
CHANGED