fix(TsCompiler): Clear output directories before compilation to ensure clean builds and avoid stale files
This commit is contained in:
@@ -1,5 +1,14 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## 2025-12-14 - 4.0.2 - fix(TsCompiler)
|
||||||
|
Clear output directories before compilation to ensure clean builds and avoid stale files
|
||||||
|
|
||||||
|
- TsCompiler.compileGlob now clears the destination directory (if it exists) before compiling each glob pattern.
|
||||||
|
- Clearing is logged unless --quiet or --json flags are set (e.g. "🧹 Clearing output directory: <dest>").
|
||||||
|
- Uses FsHelpers.removeDirectory to remove previous output, preventing stale or duplicate emitted files.
|
||||||
|
- Documentation (readme.md) updated to advertise automatic output directory management / clean builds.
|
||||||
|
- Removed stale compiled test artifacts from test/assets/output to avoid interference with tests.
|
||||||
|
|
||||||
## 2025-12-13 - 3.1.3 - fix(npmextra)
|
## 2025-12-13 - 3.1.3 - fix(npmextra)
|
||||||
Align npmextra.json package name with package.json (@git.zone/tsbuild)
|
Align npmextra.json package name with package.json (@git.zone/tsbuild)
|
||||||
|
|
||||||
|
|||||||
1
test/assets/output/tocompile.d.ts
vendored
1
test/assets/output/tocompile.d.ts
vendored
@@ -1 +0,0 @@
|
|||||||
export {};
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
console.log('test');
|
|
||||||
console.log('test2');
|
|
||||||
import * as early from '@push.rocks/early';
|
|
||||||
early.start();
|
|
||||||
early.stop();
|
|
||||||
import { anExportedString } from './tocompile2.js';
|
|
||||||
console.log(anExportedString);
|
|
||||||
class test2 {
|
|
||||||
test = [];
|
|
||||||
constructor() {
|
|
||||||
console.log('hi');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const run = async () => {
|
|
||||||
return 'hi';
|
|
||||||
};
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidG9jb21waWxlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdG9jb21waWxlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sQ0FBQyxHQUFHLENBQUMsTUFBTSxDQUFDLENBQUM7QUFDcEIsT0FBTyxDQUFDLEdBQUcsQ0FBQyxPQUFPLENBQUMsQ0FBQztBQUVyQixPQUFPLEtBQUssS0FBSyxNQUFNLG1CQUFtQixDQUFDO0FBRTNDLEtBQUssQ0FBQyxLQUFLLEVBQUUsQ0FBQztBQUNkLEtBQUssQ0FBQyxJQUFJLEVBQUUsQ0FBQztBQUViLE9BQU8sRUFBRSxnQkFBZ0IsRUFBRSxNQUFNLGlCQUFpQixDQUFDO0FBQ25ELE9BQU8sQ0FBQyxHQUFHLENBQUMsZ0JBQWdCLENBQUMsQ0FBQztBQUU5QixNQUFNLEtBQUs7SUFDVCxJQUFJLEdBQWEsRUFBRSxDQUFDO0lBQ3BCO1FBQ0UsT0FBTyxDQUFDLEdBQUcsQ0FBQyxJQUFJLENBQUMsQ0FBQztJQUNwQixDQUFDO0NBQ0Y7QUFFRCxNQUFNLEdBQUcsR0FBRyxLQUFLLElBQXFCLEVBQUU7SUFDdEMsT0FBTyxJQUFJLENBQUM7QUFDZCxDQUFDLENBQUMifQ==
|
|
||||||
1
test/assets/output/tocompile2.d.ts
vendored
1
test/assets/output/tocompile2.d.ts
vendored
@@ -1 +0,0 @@
|
|||||||
export declare const anExportedString = "exported string";
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
console.log('hello');
|
|
||||||
export const anExportedString = 'exported string';
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidG9jb21waWxlMi5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RvY29tcGlsZTIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxDQUFDLEdBQUcsQ0FBQyxPQUFPLENBQUMsQ0FBQztBQUNyQixNQUFNLENBQUMsTUFBTSxnQkFBZ0IsR0FBRyxpQkFBaUIsQ0FBQyJ9
|
|
||||||
@@ -3,6 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
export const commitinfo = {
|
export const commitinfo = {
|
||||||
name: '@git.zone/tsbuild',
|
name: '@git.zone/tsbuild',
|
||||||
version: '3.1.3',
|
version: '4.0.2',
|
||||||
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.'
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -335,6 +335,14 @@ export class TsCompiler {
|
|||||||
// Get destination directory as absolute path
|
// Get destination directory as absolute path
|
||||||
const destDir = smartpath.transform.toAbsolute(destPath, this.cwd) as string;
|
const destDir = smartpath.transform.toAbsolute(destPath, this.cwd) as string;
|
||||||
|
|
||||||
|
// Clear the destination directory before compilation if it exists
|
||||||
|
if (await FsHelpers.directoryExists(destDir)) {
|
||||||
|
if (!isQuiet && !isJson) {
|
||||||
|
console.log(`🧹 Clearing output directory: ${destPath}`);
|
||||||
|
}
|
||||||
|
await FsHelpers.removeDirectory(destDir);
|
||||||
|
}
|
||||||
|
|
||||||
// Update compiler options with the output directory
|
// Update compiler options with the output directory
|
||||||
const options: CompilerOptions = {
|
const options: CompilerOptions = {
|
||||||
...customOptions,
|
...customOptions,
|
||||||
|
|||||||
Reference in New Issue
Block a user