build: adjust types build script

This commit is contained in:
Evan You 2018-10-16 17:41:59 -04:00
parent aac7805b3a
commit 6e04850d71
11 changed files with 35 additions and 23 deletions

View File

@ -4,7 +4,7 @@
"description": "@vue/compiler", "description": "@vue/compiler",
"main": "index.js", "main": "index.js",
"module": "dist/compiler.esm-bundler.js", "module": "dist/compiler.esm-bundler.js",
"typings": "dist/index.d.ts", "types": "dist/index.d.ts",
"sideEffects": false, "sideEffects": false,
"repository": { "repository": {
"type": "git", "type": "git",

View File

@ -4,7 +4,7 @@
"description": "@vue/core", "description": "@vue/core",
"main": "index.js", "main": "index.js",
"module": "dist/core.esm-bundler.js", "module": "dist/core.esm-bundler.js",
"typings": "dist/index.d.ts", "types": "dist/index.d.ts",
"sideEffects": false, "sideEffects": false,
"repository": { "repository": {
"type": "git", "type": "git",

View File

@ -4,7 +4,7 @@
"description": "@vue/observer", "description": "@vue/observer",
"main": "index.js", "main": "index.js",
"module": "dist/observer.esm-bundler.js", "module": "dist/observer.esm-bundler.js",
"typings": "dist/index.d.ts", "types": "dist/index.d.ts",
"unpkg": "dist/observer.global.js", "unpkg": "dist/observer.global.js",
"sideEffects": false, "sideEffects": false,
"repository": { "repository": {

View File

@ -4,7 +4,7 @@
"description": "@vue/renderer-dom", "description": "@vue/renderer-dom",
"main": "index.js", "main": "index.js",
"module": "dist/renderer-dom.esm-bundler.js", "module": "dist/renderer-dom.esm-bundler.js",
"typings": "dist/index.d.ts", "types": "dist/index.d.ts",
"unpkg": "dist/renderer-dom.global.js", "unpkg": "dist/renderer-dom.global.js",
"sideEffects": false, "sideEffects": false,
"buildOptions": { "buildOptions": {

View File

@ -3,7 +3,7 @@
"version": "3.0.0-alpha.1", "version": "3.0.0-alpha.1",
"description": "@vue/renderer-server", "description": "@vue/renderer-server",
"main": "index.js", "main": "index.js",
"typings": "dist/index.d.ts", "types": "dist/index.d.ts",
"buildOptions": { "buildOptions": {
"formats": ["cjs"] "formats": ["cjs"]
}, },

View File

@ -4,7 +4,7 @@
"description": "@vue/renderer-test", "description": "@vue/renderer-test",
"main": "index.js", "main": "index.js",
"module": "dist/renderer-test.esm-bundler.js", "module": "dist/renderer-test.esm-bundler.js",
"typings": "dist/index.d.ts", "types": "dist/index.d.ts",
"repository": { "repository": {
"type": "git", "type": "git",
"url": "git+https://github.com/vuejs/vue.git" "url": "git+https://github.com/vuejs/vue.git"

View File

@ -4,7 +4,7 @@
"description": "@vue/scheduler", "description": "@vue/scheduler",
"main": "index.js", "main": "index.js",
"module": "dist/scheduler.esm-bundler.js", "module": "dist/scheduler.esm-bundler.js",
"typings": "dist/index.d.ts", "types": "dist/index.d.ts",
"sideEffects": false, "sideEffects": false,
"repository": { "repository": {
"type": "git", "type": "git",

View File

@ -4,7 +4,6 @@
"description": "vue", "description": "vue",
"main": "index.js", "main": "index.js",
"module": "dist/vue.esm-bundler.js", "module": "dist/vue.esm-bundler.js",
"typings": "dist/index.d.ts",
"unpkg": "dist/vue.global.js", "unpkg": "dist/vue.global.js",
"sideEffects": false, "sideEffects": false,
"buildOptions": { "buildOptions": {

View File

@ -6,12 +6,13 @@ import {
createComponentClassFromOptions createComponentClassFromOptions
} from '@vue/renderer-dom' } from '@vue/renderer-dom'
class Vue { // Note: typing for this is intentionally loose, as it will be using 2.x types.
static h = h
static render = render class Vue {
static nextTick = nextTick static h: any = h
static render: any = render
static nextTick: any = nextTick
// Note: typing for this is intentionally loose, as it will be using 2.x types.
constructor(options: any) { constructor(options: any) {
// convert it to a class // convert it to a class
const Component = createComponentClassFromOptions(options || {}) const Component = createComponentClassFromOptions(options || {})

View File

@ -43,6 +43,7 @@ async function buildAll(targets) {
async function build(target) { async function build(target) {
const pkgDir = path.resolve(`packages/${target}`) const pkgDir = path.resolve(`packages/${target}`)
const pkg = require(`${pkgDir}/package.json`)
await fs.remove(`${pkgDir}/dist`) await fs.remove(`${pkgDir}/dist`)
@ -58,16 +59,20 @@ async function build(target) {
{ stdio: 'inherit' } { stdio: 'inherit' }
) )
const dtsOptions = { if (pkg.types) {
name: target === 'vue' ? target : `@vue/${target}`, const dtsOptions = {
main: `${pkgDir}/dist/packages/${target}/src/index.d.ts`, name: target === 'vue' ? target : `@vue/${target}`,
out: `${pkgDir}/dist/index.d.ts` main: `${pkgDir}/dist/packages/${target}/src/index.d.ts`,
} out: `${pkgDir}/${pkg.types}`
dts.bundle(dtsOptions) }
console.log() dts.bundle(dtsOptions)
console.log(chalk.blue(chalk.bold(`generated typings at ${dtsOptions.out}`))) console.log()
console.log(
chalk.blue(chalk.bold(`generated typings at ${dtsOptions.out}`))
)
await fs.remove(`${pkgDir}/dist/packages`) await fs.remove(`${pkgDir}/dist/packages`)
}
} }
function checkAllSizes(targets) { function checkAllSizes(targets) {

View File

@ -1,7 +1,14 @@
const fs = require('fs') const fs = require('fs')
const targets = (exports.targets = fs.readdirSync('packages').filter(f => { const targets = (exports.targets = fs.readdirSync('packages').filter(f => {
return f !== 'shared' && fs.statSync(`packages/${f}`).isDirectory() if (!fs.statSync(`packages/${f}`).isDirectory()) {
return false
}
const pkg = require(`../packages/${f}/package.json`)
if (pkg.private) {
return false
}
return true
})) }))
exports.fuzzyMatchTarget = partialTarget => { exports.fuzzyMatchTarget = partialTarget => {