Add TypeScript without build option for direct TS execution with JS-Controller 4+
This PR implements support for creating TypeScript adapters that run directly without transpilation, leveraging the native TypeScript execution feature added in JS-Controller 3.3 and now stable in JS-Controller 4.
Changes
New Adapter Type Option
Added "TypeScript (without build)" as a new language choice when creating adapters. This option is designed for installations running JS-Controller 4+ which support direct TypeScript execution.
Key Differences from Traditional TypeScript Adapters
Traditional TypeScript adapters:
- Require transpilation from
src/tobuild/ - Use
"main": "build/main.js"in package.json - Include
build,watch, andprebuildnpm scripts - Package the transpiled
build/directory - Generate both
tsconfig.jsonandtsconfig.build.json
TypeScript (without build) adapters:
- Execute TypeScript files directly without transpilation
- Use
"main": "src/main.ts"in package.json - Replace build scripts with
"check": "tsc --noEmit"for type validation - Package the source
src/directory directly - Generate only
tsconfig.json(no build configuration needed) - Smaller dependency footprint (no rimraf, no build-adapter)
Updated Templates
Modified all relevant template files to support the new mode:
- package.json: Conditional main entry point, files list, and npm scripts
- tsconfig.json: Updated comments and configuration for direct execution
- tsconfig.build.json: Not generated for TS-only adapters
-
Source files:
src/main.ts,src/main.test.ts, and type definitions generated correctly - Test configuration: Mocha configured for direct TS execution
- ESLint: Custom configuration supports TS-only mode
-
README: Documents the
checkscript appropriately - CI/CD: GitHub Actions workflow handles TS-only adapters
Template Generation & Testing
Added "TypeScriptWithoutBuild" to the automated template generation script with full linting and type-checking verification. All templates generate successfully and pass validation.
Example Generated Package.json
{
"main": "src/main.ts",
"files": ["src/", "admin{,/!(src)/**}/*.{html,css,png,svg,jpg,js}", ...],
"scripts": {
"check": "tsc --noEmit",
"test:ts": "mocha --config test/mocharc.custom.json src/**/*.test.ts",
"test": "npm run test:ts && npm run test:package",
"lint": "eslint -c eslint.config.mjs ."
}
}
Testing
- ✅ All existing tests pass (63 passing)
- ✅ New baseline test added for TS-only adapters
- ✅ Template generation verified with linting and type checking
- ✅ Generated adapters include correct file structure and configuration
Benefits
- Faster development: No build step during development
- Simpler setup: Fewer dependencies and build tools required
- Modern workflow: Leverages JS-Controller 4's native TS support
-
Type safety: Still maintains full TypeScript type checking via
tsc --noEmit
Closes #XXX
Original prompt
This section details on the original issue you should resolve
<issue_title>Add option to create a TS-only adapter (without transpilation)</issue_title> <issue_description>Now with JS-Controller 4 in stable, most installations should support this, which was added in TS 3.3.</issue_description>
<agent_instructions>This needs to be added to the "What type of adapter you want to generate". In this case no build step is needed and the package.json contains the "src/main.ts" directly. We the "build" npmjs script shall be replaced by a "check" script which executes tsc with -noEmit to just test all TS code. Also enhance the create_templates.ts/sh to also generate such an Adapter, test and lint it </agent_instructions>
Comments on the Issue (you are @copilot in this section)
Fixes ioBroker/create-adapter#889
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.