Skip to content

Commit dc6045b

Browse files
committed
wip
1 parent b797aaf commit dc6045b

File tree

1 file changed

+31
-2
lines changed

1 file changed

+31
-2
lines changed

README.md

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,9 @@ Because [context switching is expensive](https://www.petrikainulainen.net/softwa
140140
# Plopfile API
141141
The plopfile api is the collection of methods that are exposed by the `plop` object. Most of the work is done by [`setGenerator`](#setgenerator) but this section documents the other methods that you may also find useful in your plopfile.
142142

143-
## TypeScript Declarations
143+
## TypeScript Support
144144

145-
`plop` bundles TypeScript declarations. Whether or not you write your plopfile in TypeScript, many editors will offer code assistance via these declarations.
145+
Plop bundles TypeScript declarations and supports TypeScript plopfiles via [NodeJS command line imports](https://nodejs.org/api/cli.html#--importmodule).
146146

147147
```javascript
148148
// plopfile.ts
@@ -153,6 +153,35 @@ export default function (plop: NodePlopAPI) {
153153
};
154154
```
155155

156+
Plop can use a native `polopfile.ts` without compiling it ahead of time by using [tsx loaders](https://github.com/privatenumber/tsx?tab=readme-ov-file#nodejs-loader):
157+
158+
```bash
159+
npm i -D tsx cross-env
160+
```
161+
162+
**Node.js v20.6 and above**
163+
164+
```json
165+
// package.json
166+
"scripts": {
167+
"cross-env NODE_OPTIONS='--import tsx' plop --plopfile=plopfile.ts"
168+
}
169+
```
170+
171+
**Node.js v20.5.1 and below**
172+
173+
```json
174+
// package.json
175+
"scripts": {
176+
"cross-env NODE_OPTIONS='--loader tsx' plop --plopfile=plopfile.ts"
177+
}
178+
```
179+
180+
181+
## JSDoc Support
182+
183+
Whether or not you write your plopfile in TypeScript, many editors will offer code assistance via JSDoc declarations.
184+
156185
```javascript
157186
// plopfile.js
158187
export default function (

0 commit comments

Comments
 (0)