copy package.json into dist directory for npm publish
This allows the library consumer to import required files instead of loading the whole library easily.
main
and types
are auto updated if index.js
and index.d.ts
exists.
Otherwise, the fields will be left blank.
import { aFunc } from 'a-lib/aModule'
import { aFunc } from 'a-lib/dist/aModule'
You can use mk-package in last step of build pipeline or in the postbuild
hook, then run npm publish
inside the dist
directory
package.json:
{
"scripts": {
"build": "tsc && mk-package",
"publish": "npm run build && cd dist && npm publish"
},
"devDependencies": {
"mk-package": "^1.0.0"
}
}
tsconfig.json
{
"compilerOptions": {
"outDir": "dist"
},
"include": [
"src/**/*.ts"
]
}
Details see ./example