- write some code as library
- split your code into many files
Then you can just write every file standalone, compile them all (to commonjs format), and others can use. perfect.
- manage imports using absolute path in your module (eg.
import xxx from "vs/code/workbench"
)- without requires user mock
require
call to handle absolute import path
- without requires user mock
- remove "src" or "out" from import path
- this can be done by place package.json in the dist folder
Then you must do some job, there's two ways:
- handle compile process, translate all import path to relative
- write a index.ts and export everything to user
If you want the fiest way, you can press Ctrl+W now.
Need to do:
- load a tsconfig to know what to include
- read every file, get exported symbols
- resolve file path to index.ts, (re)export symbols from that file
- have a way to only compile index.ts (tsconfig is used to find all files)
1,2 and 3 can be done with typescript api.
4 can be done by tsc
cli
just create a new tsconfig.index.json next to the tsconfig.json
, write:
{
"extends": "./tsconfig.json",
"files": ["_index.ts"]
}
But it's better to do with rollup. although it's harder to configure.