Compare commits
2 Commits
31834e0b3e
...
5d32ac85e0
Author | SHA1 | Date | |
---|---|---|---|
5d32ac85e0 | |||
4f2ac6922a |
@ -1,5 +1,12 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## 2025-03-17 - 2.2.7 - fix(compiler)
|
||||||
|
Improve diagnostic checking and error handling in the TypeScript compiler integration
|
||||||
|
|
||||||
|
- Added pre-emit diagnostics check to log errors before emitting
|
||||||
|
- Process exits on encountering pre-emit errors to ensure build correctness
|
||||||
|
- Enhanced logging for emit diagnostics to aid debugging
|
||||||
|
|
||||||
## 2025-03-04 - 2.2.6 - fix(package)
|
## 2025-03-04 - 2.2.6 - fix(package)
|
||||||
Fix repository URL in package.json
|
Fix repository URL in package.json
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@git.zone/tsbuild",
|
"name": "@git.zone/tsbuild",
|
||||||
"version": "2.2.6",
|
"version": "2.2.7",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "A tool for compiling TypeScript files using the latest nightly features, offering flexible APIs and a CLI for streamlined development.",
|
"description": "A tool for compiling TypeScript files using the latest nightly features, offering flexible APIs and a CLI for streamlined development.",
|
||||||
"main": "dist_ts/index.js",
|
"main": "dist_ts/index.js",
|
||||||
|
@ -3,6 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
export const commitinfo = {
|
export const commitinfo = {
|
||||||
name: '@git.zone/tsbuild',
|
name: '@git.zone/tsbuild',
|
||||||
version: '2.2.6',
|
version: '2.2.7',
|
||||||
description: 'A tool for compiling TypeScript files using the latest nightly features, offering flexible APIs and a CLI for streamlined development.'
|
description: 'A tool for compiling TypeScript files using the latest nightly features, offering flexible APIs and a CLI for streamlined development.'
|
||||||
}
|
}
|
||||||
|
@ -93,17 +93,15 @@ export const compiler = async (
|
|||||||
console.log(`Compiling ${fileNames.length} files...`);
|
console.log(`Compiling ${fileNames.length} files...`);
|
||||||
const done = plugins.smartpromise.defer<any[]>();
|
const done = plugins.smartpromise.defer<any[]>();
|
||||||
const program = plugins.typescript.createProgram(fileNames, options);
|
const program = plugins.typescript.createProgram(fileNames, options);
|
||||||
const emitResult = program.emit();
|
|
||||||
|
|
||||||
// implement check only
|
// Check for pre-emit diagnostics first
|
||||||
/*let emitResult = program.emit(undefined,(args) => {
|
const preEmitDiagnostics = plugins.typescript.getPreEmitDiagnostics(program);
|
||||||
console.log(args)
|
let hasErrors = false;
|
||||||
});*/
|
|
||||||
|
|
||||||
const allDiagnostics = plugins.typescript
|
// Log pre-emit diagnostics if any
|
||||||
.getPreEmitDiagnostics(program)
|
if (preEmitDiagnostics.length > 0) {
|
||||||
.concat(emitResult.diagnostics);
|
preEmitDiagnostics.forEach((diagnostic) => {
|
||||||
allDiagnostics.forEach((diagnostic) => {
|
hasErrors = true;
|
||||||
if (diagnostic.file) {
|
if (diagnostic.file) {
|
||||||
const { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start!);
|
const { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start!);
|
||||||
const message = plugins.typescript.flattenDiagnosticMessageText(diagnostic.messageText, '\n');
|
const message = plugins.typescript.flattenDiagnosticMessageText(diagnostic.messageText, '\n');
|
||||||
@ -114,6 +112,31 @@ export const compiler = async (
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Only continue to emit phase if no pre-emit errors
|
||||||
|
if (hasErrors) {
|
||||||
|
console.error('TypeScript pre-emit checks failed. Please fix the issues above.');
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// If no pre-emit errors, proceed with emit
|
||||||
|
const emitResult = program.emit();
|
||||||
|
|
||||||
|
// Check for emit diagnostics
|
||||||
|
if (emitResult.diagnostics.length > 0) {
|
||||||
|
emitResult.diagnostics.forEach((diagnostic) => {
|
||||||
|
if (diagnostic.file) {
|
||||||
|
const { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start!);
|
||||||
|
const message = plugins.typescript.flattenDiagnosticMessageText(diagnostic.messageText, '\n');
|
||||||
|
console.log(`${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`);
|
||||||
|
} else {
|
||||||
|
console.log(
|
||||||
|
`${plugins.typescript.flattenDiagnosticMessageText(diagnostic.messageText, '\n')}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
const exitCode = emitResult.emitSkipped ? 1 : 0;
|
const exitCode = emitResult.emitSkipped ? 1 : 0;
|
||||||
if (exitCode === 0) {
|
if (exitCode === 0) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user