@build-script/export-all-in-one

3.1.7 • Public • Published

中 文

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

💥BOOM, everything exported.

Tips:

  1. set entry file in your package.json
    This tool will create a _export_all_in_one_index.js in outDir, you should set main in package.json to that file.
  2. you should also modify types or typings field in package.json, value should be./docs/package-public.d.ts.
  3. 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 set exports 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:

  1. Resolve all project files from given tsconfig.json
  2. Collect all exported thing from these files
  3. Join all of them into a single _export_all_in_one_index.ts (in a temp folder)
  4. Compile _export_all_in_one_index.ts and copy result file(s) back to outDir folder
  5. Call @microsoft/api-extractor to parse _export_all_in_one_index.ts and copy results into your-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)

Package Sidebar

Install

npm i @build-script/export-all-in-one

Weekly Downloads

4

Version

3.1.7

License

MIT

Unpacked Size

90.4 kB

Total Files

94

Last publish

Collaborators

  • gongt