]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
build: no need for alias in rollup config
authorEvan You <yyx990803@gmail.com>
Tue, 10 Dec 2019 22:50:16 +0000 (17:50 -0500)
committerEvan You <yyx990803@gmail.com>
Tue, 10 Dec 2019 22:50:16 +0000 (17:50 -0500)
package.json
rollup.config.js
yarn.lock

index 0e276fa5f017dfdc10e87cd5630b23645f2e9fb0..736e7a7e056bc7da75abaed95f3c3c03e71b1e9e 100644 (file)
@@ -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",
index fa8100f3f4ecd72acb1a97e66a4c9212397c9137..eb080150867c18dc8e121f6843f7022cf0ddceac 100644 (file)
@@ -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,
index e889a1ec731365345bfe7ab0a5b5876651786b73..7c7027c43453032a42a6d91b5669a7ca248d710c 100644 (file)
--- a/yarn.lock
+++ b/yarn.lock
     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"