Skip to content

Commit 2ec94c8

Browse files
committed
feat: migrate build system to TypeScript (v0.4.0)
1 parent 2e39f87 commit 2ec94c8

File tree

5 files changed

+94
-23
lines changed

5 files changed

+94
-23
lines changed

CHANGELOG.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,31 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [0.4.0] - 2025-09-30
11+
12+
### Changed
13+
14+
- **Build System**: Complete migration from JavaScript to TypeScript for build configuration
15+
- `esbuild.js``esbuild.ts`: Build configuration now fully typed with TypeScript interfaces
16+
- Added `tsx` dependency for direct TypeScript execution without compilation step
17+
- Updated npm scripts to use `tsx` for running TypeScript files directly
18+
- Cleaned up duplicate and legacy JavaScript build files
19+
20+
### Improved
21+
22+
- **Type Safety**: Enhanced type safety across build infrastructure with proper TypeScript interfaces
23+
- **Developer Experience**: Better IntelliSense and error detection in build configuration
24+
- **Code Quality**: Significantly reduced JavaScript percentage in source files
25+
- **Build Performance**: Streamlined build process with modern TypeScript tooling
26+
27+
### Technical Details
28+
29+
- Source code is now primarily TypeScript (11 TypeScript files vs 2 configuration files)
30+
- Only `eslint.config.mjs` and `.vscode-test.mjs` remain as JavaScript (tooling requirements)
31+
- All build and development workflows use native TypeScript execution via `tsx`
32+
- Enhanced type annotations for esbuild plugins and configuration objects
33+
- Maintained full backward compatibility with existing functionality
34+
1035
## [0.3.0] - 2025-09-30
1136

1237
### Updated

esbuild.js renamed to esbuild.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,34 +17,33 @@
1717
* along with this program. If not, see <https://www.gnu.org/licenses/>.
1818
*/
1919

20-
const esbuild = require("esbuild");
20+
import * as esbuild from 'esbuild';
2121

22-
const production = process.argv.includes('--production');
23-
const watch = process.argv.includes('--watch');
22+
const production: boolean = process.argv.includes('--production');
23+
const watch: boolean = process.argv.includes('--watch');
2424

25-
/**
26-
* @type {import('esbuild').Plugin}
27-
*/
28-
const esbuildProblemMatcherPlugin = {
25+
const esbuildProblemMatcherPlugin: esbuild.Plugin = {
2926
name: 'esbuild-problem-matcher',
3027

31-
setup(build) {
28+
setup(build: esbuild.PluginBuild): void {
3229
build.onStart(() => {
3330
console.log('[watch] build started');
3431
});
35-
build.onEnd((result) => {
32+
build.onEnd((result: esbuild.BuildResult) => {
3633
result.errors.forEach(({ text, location }) => {
3734
console.error(`✘ [ERROR] ${text}`);
38-
console.error(` ${location.file}:${location.line}:${location.column}:`);
35+
if (location) {
36+
console.error(` ${location.file}:${location.line}:${location.column}:`);
37+
}
3938
});
4039
console.log('[watch] build finished');
4140
});
4241
},
4342
};
4443

45-
async function main() {
44+
async function main(): Promise<void> {
4645
// Build extension
47-
const extensionCtx = await esbuild.context({
46+
const extensionCtx: esbuild.BuildContext = await esbuild.context({
4847
entryPoints: ['src/extension.ts'],
4948
bundle: true,
5049
format: 'cjs',
@@ -59,7 +58,7 @@ async function main() {
5958
});
6059

6160
// Build tests
62-
const testCtx = await esbuild.context({
61+
const testCtx: esbuild.BuildContext = await esbuild.context({
6362
entryPoints: ['src/test/*.test.ts'],
6463
bundle: true,
6564
format: 'cjs',
@@ -72,6 +71,7 @@ async function main() {
7271
logLevel: 'silent',
7372
plugins: [esbuildProblemMatcherPlugin],
7473
});
74+
7575
if (watch) {
7676
await Promise.all([
7777
extensionCtx.watch(),
@@ -85,7 +85,7 @@ async function main() {
8585
}
8686
}
8787

88-
main().catch(e => {
88+
main().catch((e: Error) => {
8989
console.error(e);
9090
process.exit(1);
9191
});

eslint.config.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import tsParser from "@typescript-eslint/parser";
2222

2323
export default [{
2424
files: ["**/*.ts"],
25+
ignores: ["esbuild.ts", "dist/**/*", "node_modules/**/*"],
2526
}, {
2627
plugins: {
2728
"@typescript-eslint": typescriptEslint,

package-lock.json

Lines changed: 46 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "vscode-ddev-phpstan",
33
"displayName": "DDEV PHPStan",
44
"description": "PHP static analysis with PHPStan in DDEV containers for VS Code",
5-
"version": "0.3.0",
5+
"version": "0.4.0",
66
"publisher": "OpenForgeProject",
77
"license": "GPL-3.0",
88
"engines": {
@@ -114,18 +114,18 @@
114114
"url": "https://github.com/OpenForgeProject/vscode-ddev-phpstan"
115115
},
116116
"scripts": {
117-
"compile": "esbuild src/extension.ts --bundle --outfile=dist/extension.js --external:vscode --format=cjs --platform=node",
118-
"compile-tests": "esbuild src/test/*.test.ts --bundle --outdir=dist/test --external:vscode --external:mocha --format=cjs --platform=node",
119-
"watch": "npm run compile -- --watch",
120-
"package": "npm run compile -- --minify",
117+
"compile": "tsx esbuild.ts",
118+
"compile-tests": "tsx esbuild.ts",
119+
"watch": "tsx esbuild.ts --watch",
120+
"package": "tsx esbuild.ts --production",
121121
"vscode:prepublish": "npm run package",
122122
"test": "npm run compile-tests && vscode-test",
123123
"lint": "eslint src --ext ts"
124124
},
125125
"devDependencies": {
126-
"@types/vscode": "^1.100.0",
127-
"@types/node": "^24.x",
128126
"@types/mocha": "^10.0.9",
127+
"@types/node": "^24.x",
128+
"@types/vscode": "^1.100.0",
129129
"@typescript-eslint/eslint-plugin": "^8.0.0",
130130
"@typescript-eslint/parser": "^8.0.0",
131131
"@vscode/test-cli": "^0.0.11",
@@ -136,6 +136,7 @@
136136
"mocha": "^11.7.3",
137137
"ovsx": "^0.9.0",
138138
"sinon": "^21.0.0",
139+
"tsx": "^4.20.6",
139140
"typescript": "^5.6.3"
140141
}
141142
}

0 commit comments

Comments
 (0)