File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change
1
+ //@ts -check
2
+ import { ensureDir } from 'fs-extra'
3
+ import { build } from 'esbuild'
4
+ import { join , resolve } from 'path'
5
+ import { writePackageJsonFile } from 'typed-jsonfile'
6
+
7
+ export const buildTsPlugin = async ( /** @type {string } */ outDir , /** @type {string } */ name , /** @type {string } */ entrypoint ) => {
8
+ outDir = resolve ( outDir )
9
+ entrypoint = resolve ( entrypoint )
10
+ await ensureDir ( outDir )
11
+ await writePackageJsonFile (
12
+ { dir : outDir } ,
13
+ {
14
+ name,
15
+ // TODO
16
+ version : '0.0.0' ,
17
+ main : 'index.js' ,
18
+ } ,
19
+ )
20
+ await build ( {
21
+ bundle : true ,
22
+ platform : 'node' ,
23
+ treeShaking : true ,
24
+ format : 'cjs' ,
25
+ entryPoints : [ entrypoint ] ,
26
+ outfile : join ( outDir , 'index.js' ) ,
27
+ } )
28
+ }
29
+
30
+ const name = 'my-typescript-plugin-2'
31
+ buildTsPlugin ( `out/node_modules/${ name } ` , name , 'typescript-2/src/index.ts' )
You can’t perform that action at this time.
0 commit comments