Compare commits

...

16 Commits

8 changed files with 1989 additions and 511 deletions

193
changelog.md Normal file
View File

@ -0,0 +1,193 @@
# Changelog
## 2024-11-05 - 2.2.0 - feat(cli)
Enhance CLI for TypeScript folder compilation ordering based on rank and predefined rules.
- CLI now supports automatic ordering of TypeScript folders for compilation using tspublish.json based ranking.
- Ensures 'ts_interfaces' and 'ts_shared' are always transpiled first if certain conditions are met.
- Updated TypeScript compilerOptions to support additional path transformations.
- Updated dependencies versions and added '@git.zone/tspublish' in ts/plugins.ts.
## 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
- Corrected the transpilation order so 'ts_shared' is processed before other folders in the 'tsfolders' CLI command.
## 2024-07-21 - 2.1.83 - fix(cli)
Ensure 'ts_shared' folder is compiled first if present
- Added logic to make sure the 'ts_shared' folder is compiled first when running 'tsfolders' command.
## 2024-06-24 - 2.1.82 - fix(core)
Minor improvements and optimizations in core TypeScript compiler integration.
- Updated TypeScript dependency to latest version 5.5.2.
- Enhanced logging in compiler process.
- Improved handling of CLI commands for better flexibility.
- Compiled output directories are now more structured.
- Refactored internal compiler options merge function.
## 2024-06-24 - 2.1.81 - fix(dependencies)
Update dependencies to latest versions
- Upgraded @push.rocks/smartcli from ^4.0.10 to ^4.0.11
- Upgraded @push.rocks/smartfile from ^11.0.14 to ^11.0.21
- Upgraded @push.rocks/smartlog from ^3.0.3 to ^3.0.7
- Upgraded @push.rocks/smartpromise from ^4.0.3 to ^4.0.4
- Upgraded typescript from 5.4.5 to 5.5.2
- Upgraded @git.zone/tsrun from ^1.2.46 to ^1.2.47
- Upgraded @types/node from ^20.12.11 to ^20.14.8
## 2024-05-17 - 2.1.80 - core
Fix multiple core issues.
- Various small fixes and updates to the core functionality.
## 2024-05-17 - 2.1.76 to 2.1.79 - core
Routine core updates and fixes.
- Several minor enhancements and bug fixes.
## 2024-05-14 - 2.1.74 to 2.1.75 - core
General core maintenance updates.
- Core updated to fix minor bugs.
## 2024-05-10 - 2.1.72 to 2.1.73 - core
Minor core updates.
- Improvements and fixes to core components.
## 2024-01-08 - 2.1.70 to 2.1.71 - core
Core functionality enhancements.
- Small fixes and updates in the core.
## 2023-08-26 - 2.1.66 to 2.1.69 - core
Regular core updates and fixes.
- Various updates to improve core functionality.
## 2023-06-03 - 2.1.65 - core
Core maintenance update.
- Fixed issues in core functionality.
## 2022-08-03 - 2.1.63 to 2.1.64 - core
Minor core updates and fixes.
- Updated core functionality with minor fixes.
## 2022-05-25 - 2.1.61 to 2.1.62 - core
Routine core updates.
- Fixed minor bugs in the core.
## 2022-03-24 - 2.1.60 - core
Core functionality update.
- Fixed various minor issues in core.
## 2022-03-18 - 2.1.57 to 2.1.59 - core
Minor core updates and enhancements.
- Updated core components with small fixes.
## 2022-03-15 - 2.1.50 to 2.1.56 - core
Several core bug fixes.
- Fixed various minor issues in the core functionality.
## 2022-03-14 - 2.1.49 - core
Core update.
- Fixed minor bugs in the core.
## 2022-03-12 - 2.1.43 to 2.1.48 - core
General core maintenance updates.
- Core updated to fix minor bugs and improve functionality.
## 2022-03-11 - 2.1.33 to 2.1.42 - core
Core functionality enhancements and fixes.
- Multiple updates to improve core functionality and fix bugs.
## 2022-03-11 - 2.1.29 to 2.1.32 - core
Routine core updates.
- Minor bug fixes and improvements in core functionality.
## 2022-01-19 - 2.1.28 to 2.1.29 - core
Core bug fixes.
- Updated core to address minor issues.
## 2021-10-06 - 2.1.27 - core
Minor core update.
- Fixed core bugs.
## 2021-09-08 - 2.1.26 - core
Core update.
- Fixed minor bugs in the core.
## 2021-08-17 - 2.1.25 - core
Core bug fixes.
- Small updates to improve core functionality.
## 2020-08-11 - 2.1.24 - core
Routine core update.
- Fixed minor bugs in the core.
## 2020-05-14 - 2.1.23 - core
General core updates.
- Fixes to improve core stability.
## 2020-03-13 - 2.1.20 to 2.1.22 - core
Minor core updates.
- Enhancements and fixes for core functionality.
## 2020-03-09 - 2.1.19 - core
Maintenance core update.
- Fixes addressing minor issues in core functionality.
## 2019-08-26 - 2.1.16 to 2.1.17 - core
Routine minor core updates.
- Improvement and fixes within the core functionality.
## 2019-01-27 - 2.1.6 - custom directory compilation
Now picking up TypeScript files correctly.
- Resolved compilation issues with custom directories.
## 2018-12-05 - 2.1.0 to 2.1.1 - core
Minor core updates.
- Small enhancements and fixes applied to core functionality.
## 2018-12-05 - 2.0.22 - cli options
Now support --web for web compilations targeting Google Chrome.
- Added new CLI option for web compilation.
## 2018-07-25 - 2.0.15 to 2.0.19 - various
Multiple fixes across core, dependency, and compiler modules.
- Packagename fix in core.
- Dependency updates.
- Compiler options fixed.
- Initial core updates.

View File

@ -1,6 +1,6 @@
{
"name": "@git.zone/tsbuild",
"version": "2.1.78",
"version": "2.2.0",
"private": false,
"description": "TypeScript nightly to easily make use of latest features",
"main": "dist_ts/index.js",
@ -28,19 +28,20 @@
},
"homepage": "https://gitlab.com/pushrocks/tsn#README",
"dependencies": {
"@git.zone/tspublish": "^1.7.5",
"@push.rocks/early": "^4.0.4",
"@push.rocks/smartcli": "^4.0.10",
"@push.rocks/smartcli": "^4.0.11",
"@push.rocks/smartdelay": "^3.0.5",
"@push.rocks/smartfile": "^11.0.14",
"@push.rocks/smartlog": "^3.0.3",
"@push.rocks/smartfile": "^11.0.21",
"@push.rocks/smartlog": "^3.0.7",
"@push.rocks/smartpath": "^5.0.18",
"@push.rocks/smartpromise": "^4.0.3",
"typescript": "5.4.5"
"@push.rocks/smartpromise": "^4.0.4",
"typescript": "5.6.3"
},
"devDependencies": {
"@git.zone/tsrun": "^1.2.46",
"@git.zone/tsrun": "^1.2.47",
"@push.rocks/tapbundle": "^5.0.23",
"@types/node": "^20.12.11"
"@types/node": "^22.8.7"
},
"files": [
"ts/**/*",

2197
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

0
readme.hints.md Normal file
View File

View File

@ -1,8 +1,8 @@
/**
* autocreated commitinfo by @pushrocks/commitinfo
* autocreated commitinfo by @push.rocks/commitinfo
*/
export const commitinfo = {
name: '@git.zone/tsbuild',
version: '2.1.78',
version: '2.2.0',
description: 'TypeScript nightly to easily make use of latest features'
}

View File

@ -5,6 +5,13 @@ export {
path
}
// @git.zone scope
import * as tspublish from '@git.zone/tspublish';
export {
tspublish
}
// @push.rocks scope
import * as smartcli from '@push.rocks/smartcli';
import * as smartdelay from '@push.rocks/smartdelay';

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';
/**
@ -15,11 +16,12 @@ export const compilerOptionsDefault: CompilerOptions = {
module: plugins.typescript.ModuleKind.NodeNext,
target: plugins.typescript.ScriptTarget.ESNext,
moduleResolution: plugins.typescript.ModuleResolutionKind.NodeNext,
lib: ['lib.dom.d.ts', 'es2021'],
lib: ['lib.dom.d.ts', 'lib.es2022.d.ts'],
noImplicitAny: true,
esModuleInterop: true,
useDefineForClassFields: false,
verbatimModuleSyntax: true,
baseUrl: './',
};
/**
@ -49,6 +51,23 @@ 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;
for (const path of Object.keys(tsconfig.compilerOptions.paths)) {
returnObject.paths[path][0] = returnObject.paths[path][0].replace('./ts_', './dist_ts_');
}
}
return returnObject;
})(),
};
console.log(mergedOptions);

View File

@ -38,26 +38,51 @@ export const runCli = async () => {
tsbuildCli.addCommand('tsfolders').subscribe(async (argvArg) => {
const tsFolders = await plugins.smartfile.fs.listFolders(paths.cwd, /^ts/);
// lets make sure interfaces are always transpiled first
const index = tsFolders.indexOf('ts_interfaces');
if (index > -1) {
tsFolders.splice(index, 1);
tsFolders.unshift('ts_interfaces');
}
const compilationCommandObject: { [key: string]: string } = {};
for (const tsFolder of tsFolders) {
compilationCommandObject[`./${tsFolder}/**/*.ts`] = `./dist_${tsFolder}`;
}
await tsbuild.compileGlobStringObject(compilationCommandObject, {}, process.cwd(), argvArg);
});
// Now tsFolders contains all other folders except 'ts_shared' and 'ts_interfaces'
// We've established a base order. Now let's look at tspublish.json based ranking.
const tsPublishInstance = new plugins.tspublish.TsPublish();
const tsPublishModules = await tsPublishInstance.getModuleSubDirs(paths.cwd);
// tsPublishModules is an object: { [folderName]: tspublishJsonData }
// Create an array with folder names and their ranks
const foldersWithOrder = [];
for (const folder of tsFolders) {
let rank = Infinity; // Default rank if not specified
if (tsPublishModules[folder] && tsPublishModules[folder].order !== undefined) {
rank = tsPublishModules[folder].order;
}
foldersWithOrder.push({ folder, rank });
}
// Sort the folders based on rank
foldersWithOrder.sort((a, b) => a.rank - b.rank);
// Construct the sorted list of folders
const sortedTsFolders = [];
// Add the rest of the folders in sorted order
for (const item of foldersWithOrder) {
sortedTsFolders.push(item.folder);
}
// Let's make sure 'ts_shared' is always transpiled first
const ensurePosition = (folderNameArg: string, ensuredPosition: number) => {
if (tsFolders.indexOf(folderNameArg) > -1 && Object.keys(tsPublishModules).indexOf(folderNameArg) === -1) {
sortedTsFolders.splice(tsFolders.indexOf(folderNameArg), 1);
sortedTsFolders.splice(ensuredPosition, 0, folderNameArg);
}
}
ensurePosition('ts_interfaces', 0);
ensurePosition('ts_shared', 1);
/**
* 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) {
console.log(`compiling in this order:`);
console.log(sortedTsFolders);
for (const tsFolder of sortedTsFolders) {
compilationCommandObject[`./${tsFolder}/**/*.ts`] = `./dist_${tsFolder}`;
}
await tsbuild.compileGlobStringObject(compilationCommandObject, {}, process.cwd(), argvArg);