build: no need for alias in rollup config
This commit is contained in:
parent
3e3188fa9f
commit
7aca27392f
@ -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",
|
||||
|
@ -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,
|
||||
|
@ -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"
|
||||
|
Loading…
Reference in New Issue
Block a user