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-script
Step 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.json
Tips:
- set entry file in your package.json
This tool will create a_export_all_in_one_index.js
inoutDir
, you should setmain
in package.json to that file. - you should also modify
types
ortypings
field 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.cjs
file, you should setexports
in 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.ts
and copy result file(s) back tooutDir
folder - Call
@microsoft/api-extractor
to parse_export_all_in_one_index.ts
and 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)