From 7aca27392f1f3f43091f9a6092dbb56a15ecc9ea Mon Sep 17 00:00:00 2001 From: Evan You Date: Tue, 10 Dec 2019 17:50:16 -0500 Subject: [PATCH] build: no need for alias in rollup config --- package.json | 1 - rollup.config.js | 23 ++++++----------------- yarn.lock | 7 ------- 3 files changed, 6 insertions(+), 25 deletions(-) diff --git a/package.json b/package.json index 0e276fa5f..736e7a7e0 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,6 @@ }, "devDependencies": { "@microsoft/api-extractor": "^7.3.9", - "@rollup/plugin-alias": "^2.2.0", "@rollup/plugin-json": "^4.0.0", "@rollup/plugin-replace": "^2.2.1", "@types/jest": "^24.0.21", diff --git a/rollup.config.js b/rollup.config.js index fa8100f3f..eb0801508 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -2,7 +2,6 @@ import fs from 'fs' import path from 'path' import ts from 'rollup-plugin-typescript2' import replace from '@rollup/plugin-replace' -import alias from '@rollup/plugin-alias' import json from '@rollup/plugin-json' import lernaJson from './lerna.json' @@ -17,17 +16,9 @@ const resolve = p => path.resolve(packageDir, p) const pkg = require(resolve(`package.json`)) const packageOptions = pkg.buildOptions || {} -// build aliases dynamically -const aliasOptions = { resolve: ['.ts'] } -fs.readdirSync(packagesDir).forEach(dir => { - if (dir === 'vue') { - return - } - if (fs.statSync(path.resolve(packagesDir, dir)).isDirectory()) { - aliasOptions[`@vue/${dir}`] = path.resolve(packagesDir, `${dir}/src/index`) - } +const knownExternals = fs.readdirSync(packagesDir).filter(p => { + return p !== '@vue/shared' }) -const aliasPlugin = alias(aliasOptions) // ensure TS checks only once for each build let hasTSChecked = false @@ -107,21 +98,19 @@ function createConfig(output, plugins = []) { // during a single build. hasTSChecked = true - const externals = Object.keys(aliasOptions) - .concat(Object.keys(pkg.dependencies || [])) - .filter(p => p !== '@vue/shared') - return { input: resolve(`src/index.ts`), // Global and Browser ESM builds inlines everything so that they can be // used alone. - external: isGlobalBuild || isBrowserESMBuild ? [] : externals, + external: + isGlobalBuild || isBrowserESMBuild + ? [] + : knownExternals.concat(Object.keys(pkg.dependencies || [])), plugins: [ json({ namedExports: false }), tsPlugin, - aliasPlugin, createReplacePlugin( isProductionBuild, isBundlerESMBuild, diff --git a/yarn.lock b/yarn.lock index e889a1ec7..7c7027c43 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1162,13 +1162,6 @@ universal-user-agent "^3.0.0" url-template "^2.0.8" -"@rollup/plugin-alias@^2.2.0": - version "2.2.0" - resolved "https://registry.npm.taobao.org/@rollup/plugin-alias/download/@rollup/plugin-alias-2.2.0.tgz#3ac52ece8b39583249884adb90fb316484389fe5" - integrity sha1-OsUuzos5WDJJiErbkPsxZIQ4n+U= - dependencies: - slash "^3.0.0" - "@rollup/plugin-json@^4.0.0": version "4.0.0" resolved "https://registry.npm.taobao.org/@rollup/plugin-json/download/@rollup/plugin-json-4.0.0.tgz#4462e83c7ad5544bef4a601a6e8450daedc4b69b"