Experimental utility to automate reexporting TypeScript in index.ts
files. Primary target is TypeScript but it should work for any language with //
comments.
Insert comment instructions // @reexport glob/pattern/*.tsx
in place where you want to reexport such files and this utility will reexport all matching files.
Screen.Recording.2022-11-27.at.18.49.52.mov
Your index.ts
looking like this:
// @reexport ./*.{ts,tsx}
With directory like this:
./index.ts
./Alice.tsx
./Bob.ts
Running this:
npx reexport ./index.ts
Will generate this:
// @reexport ./*.{ts,tsx}
export * from './Alice'
export * from './Bob'
// @end-reexport
npm install reexport
npm i -g reexport
reexport "./src/**/index.{ts,tsx}"
npx reexport "./src/**/index.{ts,tsx}"
import { reexport } from 'reexport'
reexport({ files: ['./index.ts'], watch: true })
- watch mode
--watch
- glob matching
reexport "**/index.{ts,tsx},something.js"
- verbose mode
-v
| more verbose-vv
| even more verbose-vvv
Define outptu pattern after colon (:
) symbol.
path/to/File.suffix.tsx |
|||||
---|---|---|---|---|---|
$BASENAME | $PATH | $TS_PATH | $NAME | $SAFE_NAME | $EXT |
File.module.tsx | path/to/File.module.tsx | path/to/File.module | File.module | d | .tsx |
// @reexport ./*.{ts,tsx}:export * from './$TS_PATH'
export * from './Alice'
export * from './Bob'
// @end-reexport
const things = {
// @reexport ./*.{ts,tsx}: $SAFE_NAME: () => import('./$TS_PATH'),
Alice: () => import('./Alice'),
Bob: () => import('./Bob'),
// @end-reexport
}