Compare commits

...

2 Commits

Author SHA1 Message Date
5369e8d931 2.1.85 2024-10-27 13:35:55 +01:00
88444e835f fix(compiler): Improve path handling in compiler options 2024-10-27 13:35:54 +01:00
5 changed files with 24 additions and 14 deletions

View File

@ -1,5 +1,11 @@
# Changelog
## 2024-10-27 - 2.1.85 - fix(compiler)
Improve path handling in compiler options
- Refactored path import in tsbuild.classes.compiler.ts.
- Enhanced mergeCompilerOptions to read paths and baseUrl from tsconfig.json if present.
## 2024-07-22 - 2.1.84 - fix(cli)
Fixed transpilation order issue in tsfolders command

View File

@ -1,6 +1,6 @@
{
"name": "@git.zone/tsbuild",
"version": "2.1.84",
"version": "2.1.85",
"private": false,
"description": "TypeScript nightly to easily make use of latest features",
"main": "dist_ts/index.js",

View File

@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@git.zone/tsbuild',
version: '2.1.84',
version: '2.1.85',
description: 'TypeScript nightly to easily make use of latest features'
}

View File

@ -1,5 +1,6 @@
// import all the stuff we need
import * as plugins from './plugins.js';
import * as paths from './paths.js';
import type { CompilerOptions, ScriptTarget, ModuleKind } from './tsbuild.exports.js';
/**
@ -20,6 +21,7 @@ export const compilerOptionsDefault: CompilerOptions = {
esModuleInterop: true,
useDefineForClassFields: false,
verbatimModuleSyntax: true,
baseUrl: './',
};
/**
@ -49,6 +51,20 @@ export const mergeCompilerOptions = (
moduleResolution: plugins.typescript.ModuleResolutionKind.NodeJs,
}
: {}),
...(() => {
const returnObject: CompilerOptions = {};
console.log(`looking at tsconfig.json at ${paths.cwd}`);
const tsconfig = plugins.smartfile.fs.toObjectSync(plugins.path.join(paths.cwd, 'tsconfig.json'));
if (tsconfig && tsconfig.compilerOptions && tsconfig.compilerOptions.baseUrl) {
console.log('baseUrl found in tsconfig.json');
returnObject.baseUrl = tsconfig.compilerOptions.baseUrl;
}
if (tsconfig && tsconfig.compilerOptions && tsconfig.compilerOptions.paths) {
console.log('paths found in tsconfig.json');
returnObject.paths = tsconfig.compilerOptions.paths;
}
return returnObject;
})(),
};
console.log(mergedOptions);

View File

@ -60,17 +60,5 @@ export const runCli = async () => {
await tsbuild.compileGlobStringObject(compilationCommandObject, {}, process.cwd(), argvArg);
});
/**
* the custom command compiles any customDir to dist_customDir
*/
tsbuildCli.addCommand('interfaces').subscribe(async (argvArg) => {
const tsFolders = ['ts_interfaces'];
const compilationCommandObject: { [key: string]: string } = {};
for (const tsFolder of tsFolders) {
compilationCommandObject[`./${tsFolder}/**/*.ts`] = `./dist_${tsFolder}`;
}
await tsbuild.compileGlobStringObject(compilationCommandObject, {}, process.cwd(), argvArg);
});
tsbuildCli.startParse();
};