Compare commits

...

8 Commits

4 changed files with 71 additions and 25 deletions

View File

@ -1,5 +1,28 @@
# 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)
Fix repository URL in package.json
- Updated repository URL in package.json to point to the correct Git repository.
## 2025-03-04 - 2.2.5 - fix(package.json)
Update repository URLs in package metadata.
- Corrected the 'bugs.url' and 'homepage' fields with the accurate URLs.
## 2025-03-04 - 2.2.4 - fix(core)
Fix compiler logic to remove duplicate compiled files and improve glob pattern handling.
- Resolved an issue causing duplicate file compilations when using compileGlobStringObject.
- Improved handling of glob patterns to ensure accurate compilation paths.
## 2025-03-04 - 2.2.3 - fix(exports)
Fixed duplicate file compilation in compileGlobStringObject

View File

@ -1,6 +1,6 @@
{
"name": "@git.zone/tsbuild",
"version": "2.2.3",
"version": "2.2.7",
"private": false,
"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",
@ -16,7 +16,7 @@
},
"repository": {
"type": "git",
"url": "git+ssh://git@gitlab.com/pushrocks/tsn.git"
"url": "https://code.foss.global/git.zone/tsbuild.git"
},
"keywords": [
"TypeScript",
@ -32,9 +32,9 @@
"author": "Lossless GmbH",
"license": "MIT",
"bugs": {
"url": "https://gitlab.com/pushrocks/tsn/issues"
"url": "https://code.foss.global/git.zone/tsbuild/issues"
},
"homepage": "https://gitlab.com/pushrocks/tsn#README",
"homepage": "https://code.foss.global/git.zone/tsbuild#README",
"dependencies": {
"@git.zone/tspublish": "^1.9.1",
"@push.rocks/early": "^4.0.4",

View File

@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@git.zone/tsbuild',
version: '2.2.3',
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.'
}

View File

@ -93,27 +93,50 @@ export const compiler = async (
console.log(`Compiling ${fileNames.length} files...`);
const done = plugins.smartpromise.defer<any[]>();
const program = plugins.typescript.createProgram(fileNames, options);
// Check for pre-emit diagnostics first
const preEmitDiagnostics = plugins.typescript.getPreEmitDiagnostics(program);
let hasErrors = false;
// Log pre-emit diagnostics if any
if (preEmitDiagnostics.length > 0) {
preEmitDiagnostics.forEach((diagnostic) => {
hasErrors = true;
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')}`
);
}
});
}
// 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();
// implement check only
/*let emitResult = program.emit(undefined,(args) => {
console.log(args)
});*/
const allDiagnostics = plugins.typescript
.getPreEmitDiagnostics(program)
.concat(emitResult.diagnostics);
allDiagnostics.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')}`
);
}
});
// 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;
if (exitCode === 0) {