build: no need for alias in rollup config
This commit is contained in:
parent
3e3188fa9f
commit
7aca27392f
@ -33,7 +33,6 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@microsoft/api-extractor": "^7.3.9",
|
"@microsoft/api-extractor": "^7.3.9",
|
||||||
"@rollup/plugin-alias": "^2.2.0",
|
|
||||||
"@rollup/plugin-json": "^4.0.0",
|
"@rollup/plugin-json": "^4.0.0",
|
||||||
"@rollup/plugin-replace": "^2.2.1",
|
"@rollup/plugin-replace": "^2.2.1",
|
||||||
"@types/jest": "^24.0.21",
|
"@types/jest": "^24.0.21",
|
||||||
|
@ -2,7 +2,6 @@ import fs from 'fs'
|
|||||||
import path from 'path'
|
import path from 'path'
|
||||||
import ts from 'rollup-plugin-typescript2'
|
import ts from 'rollup-plugin-typescript2'
|
||||||
import replace from '@rollup/plugin-replace'
|
import replace from '@rollup/plugin-replace'
|
||||||
import alias from '@rollup/plugin-alias'
|
|
||||||
import json from '@rollup/plugin-json'
|
import json from '@rollup/plugin-json'
|
||||||
import lernaJson from './lerna.json'
|
import lernaJson from './lerna.json'
|
||||||
|
|
||||||
@ -17,17 +16,9 @@ const resolve = p => path.resolve(packageDir, p)
|
|||||||
const pkg = require(resolve(`package.json`))
|
const pkg = require(resolve(`package.json`))
|
||||||
const packageOptions = pkg.buildOptions || {}
|
const packageOptions = pkg.buildOptions || {}
|
||||||
|
|
||||||
// build aliases dynamically
|
const knownExternals = fs.readdirSync(packagesDir).filter(p => {
|
||||||
const aliasOptions = { resolve: ['.ts'] }
|
return p !== '@vue/shared'
|
||||||
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 aliasPlugin = alias(aliasOptions)
|
|
||||||
|
|
||||||
// ensure TS checks only once for each build
|
// ensure TS checks only once for each build
|
||||||
let hasTSChecked = false
|
let hasTSChecked = false
|
||||||
@ -107,21 +98,19 @@ function createConfig(output, plugins = []) {
|
|||||||
// during a single build.
|
// during a single build.
|
||||||
hasTSChecked = true
|
hasTSChecked = true
|
||||||
|
|
||||||
const externals = Object.keys(aliasOptions)
|
|
||||||
.concat(Object.keys(pkg.dependencies || []))
|
|
||||||
.filter(p => p !== '@vue/shared')
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
input: resolve(`src/index.ts`),
|
input: resolve(`src/index.ts`),
|
||||||
// Global and Browser ESM builds inlines everything so that they can be
|
// Global and Browser ESM builds inlines everything so that they can be
|
||||||
// used alone.
|
// used alone.
|
||||||
external: isGlobalBuild || isBrowserESMBuild ? [] : externals,
|
external:
|
||||||
|
isGlobalBuild || isBrowserESMBuild
|
||||||
|
? []
|
||||||
|
: knownExternals.concat(Object.keys(pkg.dependencies || [])),
|
||||||
plugins: [
|
plugins: [
|
||||||
json({
|
json({
|
||||||
namedExports: false
|
namedExports: false
|
||||||
}),
|
}),
|
||||||
tsPlugin,
|
tsPlugin,
|
||||||
aliasPlugin,
|
|
||||||
createReplacePlugin(
|
createReplacePlugin(
|
||||||
isProductionBuild,
|
isProductionBuild,
|
||||||
isBundlerESMBuild,
|
isBundlerESMBuild,
|
||||||
|
@ -1162,13 +1162,6 @@
|
|||||||
universal-user-agent "^3.0.0"
|
universal-user-agent "^3.0.0"
|
||||||
url-template "^2.0.8"
|
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":
|
"@rollup/plugin-json@^4.0.0":
|
||||||
version "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"
|
resolved "https://registry.npm.taobao.org/@rollup/plugin-json/download/@rollup/plugin-json-4.0.0.tgz#4462e83c7ad5544bef4a601a6e8450daedc4b69b"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user