fix(types): augment ref unwrap bail types in appropriate packages

Packages can now augment the ref unwrap bail types in their own `d.ts`.
Also updated the build script to auto concat any files in a package's
`types` directory to the final generated `d.ts`.

- `@vue/reactivity` should no longer require `libs: ["DOM"]` in tsconfig
- Properly bail on `VNode` and `ComponentPublicInstance` in runtime-core
This commit is contained in:
Evan You
2020-05-01 16:14:30 -04:00
parent 7f23555356
commit b40fcbc4c6
10 changed files with 86 additions and 12 deletions

View File

@@ -107,13 +107,15 @@ async function build(target) {
})
if (extractorResult.succeeded) {
// concat additional d.ts to rolled-up dts (mostly for JSX)
if (pkg.buildOptions && pkg.buildOptions.dts) {
// concat additional d.ts to rolled-up dts
const typesDir = path.resolve(pkgDir, 'types')
if (await fs.exists(typesDir)) {
const dtsPath = path.resolve(pkgDir, pkg.types)
const existing = await fs.readFile(dtsPath, 'utf-8')
const typeFiles = await fs.readdir(typesDir)
const toAdd = await Promise.all(
pkg.buildOptions.dts.map(file => {
return fs.readFile(path.resolve(pkgDir, file), 'utf-8')
typeFiles.map(file => {
return fs.readFile(path.resolve(typesDir, file), 'utf-8')
})
)
await fs.writeFile(dtsPath, existing + '\n' + toAdd.join('\n'))