feat(config): add smartconfig metadata and update TypeScript build configuration docs

This commit is contained in:
2026-03-24 18:13:56 +00:00
parent cfe2eafe89
commit 724e5bf7ec
10 changed files with 1196 additions and 2042 deletions

View File

@@ -18,7 +18,6 @@ export const compilerOptionsDefault: CompilerOptions = {
noImplicitAny: false,
esModuleInterop: true,
verbatimModuleSyntax: true,
baseUrl: './',
};
/**
@@ -98,12 +97,13 @@ export class TsConfig {
// Apply path transformations (ts_ → dist_ts_)
if (tsconfig.compilerOptions.paths) {
returnObject.paths = { ...tsconfig.compilerOptions.paths };
for (const pathKey of Object.keys(returnObject.paths)) {
if (Array.isArray(returnObject.paths[pathKey]) && returnObject.paths[pathKey].length > 0) {
returnObject.paths[pathKey][0] = returnObject.paths[pathKey][0].replace('./ts_', './dist_ts_');
const paths: Record<string, string[]> = { ...tsconfig.compilerOptions.paths };
for (const pathKey of Object.keys(paths)) {
if (Array.isArray(paths[pathKey]) && paths[pathKey].length > 0) {
paths[pathKey][0] = paths[pathKey][0].replace('./ts_', './dist_ts_');
}
}
returnObject.paths = paths;
}
this.cachedTsConfig = returnObject;

View File

@@ -17,7 +17,8 @@ export interface ITsPublishJson {
*/
export class TsPublishConfig {
private folderPath: string;
private cachedConfig: ITsPublishJson | null | undefined = undefined;
private cachedConfig: ITsPublishJson | null = null;
private cacheLoaded = false;
constructor(folderPath: string) {
this.folderPath = folderPath;
@@ -35,7 +36,7 @@ export class TsPublishConfig {
* Returns null if file doesn't exist or is invalid
*/
public async load(): Promise<ITsPublishJson | null> {
if (this.cachedConfig !== undefined) {
if (this.cacheLoaded) {
return this.cachedConfig;
}
@@ -43,9 +44,11 @@ export class TsPublishConfig {
const configPath = path.join(this.folderPath, 'tspublish.json');
const content = await fs.promises.readFile(configPath, 'utf8');
this.cachedConfig = JSON.parse(content);
this.cacheLoaded = true;
return this.cachedConfig;
} catch {
this.cachedConfig = null;
this.cacheLoaded = true;
return null;
}
}
@@ -55,7 +58,7 @@ export class TsPublishConfig {
* Returns null if file doesn't exist or is invalid
*/
public loadSync(): ITsPublishJson | null {
if (this.cachedConfig !== undefined) {
if (this.cacheLoaded) {
return this.cachedConfig;
}
@@ -63,9 +66,11 @@ export class TsPublishConfig {
const configPath = path.join(this.folderPath, 'tspublish.json');
const content = fs.readFileSync(configPath, 'utf8');
this.cachedConfig = JSON.parse(content);
this.cacheLoaded = true;
return this.cachedConfig;
} catch {
this.cachedConfig = null;
this.cacheLoaded = true;
return null;
}
}
@@ -111,6 +116,7 @@ export class TsPublishConfig {
* Clear the cached config (useful for reloading)
*/
public clearCache(): void {
this.cachedConfig = undefined;
this.cachedConfig = null;
this.cacheLoaded = false;
}
}