fix(compiler): Improve path handling in compiler options
This commit is contained in:
parent
4892c8f7ae
commit
88444e835f
@ -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
|
||||
|
||||
|
@ -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'
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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();
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user