export-all-in-one
Collect ALL export from your TypeScript project, export them in ONE entry file, so that others can import { Any, thing, they, want } from '@your/package'. No matter which file is Any/thing placed.
Usage:
Step 1: install
npm -g install build-scriptStep 2: update your tsconfig
outDir is required in tsconfig.json. Compile in place is not supported.
Step 3: do the magic
tsconfig.json can omit, order of the 2 commands is not important
export-all-in-one ./path/to/tsconfig.json
tsc -p ./path/to/tsconfig.jsonBOOM, everything exported.
Tips:
- set entry file in your package.json
This tool will create a_export_all_in_one_index.jsinoutDir, you should setmainin package.json to that file. - you should also modify
typesortypingsfield inpackage.json, value should be./docs/package-public.d.ts. - dual stack package: commonjs + esm
If dual package is detected, this tool will also create a_export_all_in_one_index.cjsfile, you should setexportsin package.json.
See:
Options:
If an expoted symbol has doc-comment (/** */):
- with
@extern: always export - with
@internal: never export - nothing: use default (see exportEverything)
non-export symbol will never be export.
Configure in package.json:
{
"exportAllInOne": {
"exportEverything": true
}
}| config | type | default | description |
|---|---|---|---|
| exportEverything | boolean | true | will all symbol exported by default |
It will do:
- Resolve all project files from given tsconfig.json
- Collect all exported thing from these files
- Join all of them into a single
_export_all_in_one_index.ts(in a temp folder) - Compile
_export_all_in_one_index.tsand copy result file(s) back tooutDirfolder - Call
@microsoft/api-extractorto parse_export_all_in_one_index.tsand copy results intoyour-package-root/docs/
Limits:
PS: Of course, all your file can not export two same named symbol....
But you have no reason to do that, except you want to fool your IDE.
PS2: default export will convert to named export, name is it's file name. (unstable)