From c1959fa64dd9fa575a91c19376fbc6eb785b3755 Mon Sep 17 00:00:00 2001 From: Evan You Date: Tue, 17 Dec 2019 21:51:41 -0500 Subject: [PATCH] build: set compiler-sfc peerDep on vue --- packages/compiler-sfc/package.json | 3 +++ scripts/release.js | 24 ++++++++++++++---------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/packages/compiler-sfc/package.json b/packages/compiler-sfc/package.json index e6762b4b..c9bf001d 100644 --- a/packages/compiler-sfc/package.json +++ b/packages/compiler-sfc/package.json @@ -26,6 +26,9 @@ "url": "https://github.com/vuejs/vue/issues" }, "homepage": "https://github.com/vuejs/vue/tree/dev/packages/compiler-sfc#readme", + "peerDependencies": { + "vue": "3.0.0-alpha.0" + }, "dependencies": { "@vue/compiler-core": "3.0.0-alpha.0", "@vue/compiler-dom": "3.0.0-alpha.0", diff --git a/scripts/release.js b/scripts/release.js index a8b9b7c8..1275a7b7 100644 --- a/scripts/release.js +++ b/scripts/release.js @@ -119,19 +119,23 @@ function updateVersions(version) { function updatePackage(pkgRoot, version) { const pkg = readPkg(pkgRoot) pkg.version = version - if (pkg.dependencies) { - Object.keys(pkg.dependencies).forEach(dep => { - if ( - dep.startsWith('@vue') && - packages.includes(dep.replace(/^@vue\//, '')) - ) { - pkg.dependencies[dep] = version - } - }) - } + updateDeps(pkg.dependencies) + updateDeps(pkg.peerDependencies) fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + '\n') } +function updateDeps(deps, version) { + if (!deps) return + Object.keys(deps).forEach(dep => { + if ( + dep === 'vue' || + (dep.startsWith('@vue') && packages.includes(dep.replace(/^@vue\//, ''))) + ) { + deps[dep] = version + } + }) +} + function readPkg(pkgRoot) { const pkgPath = path.resolve(pkgRoot, 'package.json') return JSON.parse(fs.readFileSync(pkgPath, 'utf-8'))