mirror of
https://github.com/element-plus/element-plus.git
synced 2025-01-18 10:59:10 +08:00
fix(build): fix types (#4254)
* fix: add devDependencies * fix(build): fix generate types definitions
This commit is contained in:
parent
3afcb91a14
commit
7f38d3942f
@ -6,10 +6,9 @@ import glob from 'fast-glob'
|
|||||||
import { bold } from 'chalk'
|
import { bold } from 'chalk'
|
||||||
|
|
||||||
import { green, red, yellow } from './utils/log'
|
import { green, red, yellow } from './utils/log'
|
||||||
import { buildOutput, pkgRoot, projRoot } from './utils/paths'
|
import { buildOutput, epRoot, pkgRoot, projRoot } from './utils/paths'
|
||||||
|
|
||||||
import { excludeFiles, pathRewriter } from './utils/pkg'
|
import { excludeFiles, pathRewriter } from './utils/pkg'
|
||||||
import { run } from './utils/process'
|
|
||||||
import type { SourceFile } from 'ts-morph'
|
import type { SourceFile } from 'ts-morph'
|
||||||
|
|
||||||
const TSCONFIG_PATH = path.resolve(projRoot, 'tsconfig.json')
|
const TSCONFIG_PATH = path.resolve(projRoot, 'tsconfig.json')
|
||||||
@ -37,16 +36,22 @@ export const generateTypesDefinitions = async () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const filePaths = excludeFiles(
|
const filePaths = excludeFiles(
|
||||||
await glob('**/*.{js,ts,vue}', {
|
await glob(['**/*.{js,ts,vue}', '!element-plus/**/*'], {
|
||||||
cwd: pkgRoot,
|
cwd: pkgRoot,
|
||||||
absolute: true,
|
absolute: true,
|
||||||
onlyFiles: true,
|
onlyFiles: true,
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
const epPaths = excludeFiles(
|
||||||
|
await glob('**/*.{js,ts,vue}', {
|
||||||
|
cwd: epRoot,
|
||||||
|
onlyFiles: true,
|
||||||
|
})
|
||||||
|
)
|
||||||
|
|
||||||
const sourceFiles: SourceFile[] = []
|
const sourceFiles: SourceFile[] = []
|
||||||
await Promise.all(
|
await Promise.all([
|
||||||
filePaths.map(async (file) => {
|
...filePaths.map(async (file) => {
|
||||||
if (file.endsWith('.vue')) {
|
if (file.endsWith('.vue')) {
|
||||||
const content = await fs.readFile(file, 'utf-8')
|
const content = await fs.readFile(file, 'utf-8')
|
||||||
const sfc = vueCompiler.parse(content)
|
const sfc = vueCompiler.parse(content)
|
||||||
@ -71,12 +76,18 @@ export const generateTypesDefinitions = async () => {
|
|||||||
)
|
)
|
||||||
sourceFiles.push(sourceFile)
|
sourceFiles.push(sourceFile)
|
||||||
}
|
}
|
||||||
} else if (file.endsWith('.ts')) {
|
} else {
|
||||||
const sourceFile = project.addSourceFileAtPath(file)
|
const sourceFile = project.addSourceFileAtPath(file)
|
||||||
sourceFiles.push(sourceFile)
|
sourceFiles.push(sourceFile)
|
||||||
}
|
}
|
||||||
})
|
}),
|
||||||
)
|
...epPaths.map(async (file) => {
|
||||||
|
const content = await fs.readFile(path.resolve(epRoot, file), 'utf-8')
|
||||||
|
sourceFiles.push(
|
||||||
|
project.createSourceFile(path.resolve(pkgRoot, file), content)
|
||||||
|
)
|
||||||
|
}),
|
||||||
|
])
|
||||||
|
|
||||||
const diagnostics = project.getPreEmitDiagnostics()
|
const diagnostics = project.getPreEmitDiagnostics()
|
||||||
console.log(project.formatDiagnosticsWithColorAndContext(diagnostics))
|
console.log(project.formatDiagnosticsWithColorAndContext(diagnostics))
|
||||||
@ -115,11 +126,4 @@ export const generateTypesDefinitions = async () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
await Promise.all(tasks)
|
await Promise.all(tasks)
|
||||||
|
|
||||||
const epFiles = await glob('**/*', {
|
|
||||||
cwd: path.resolve(outDir, 'element-plus'),
|
|
||||||
absolute: true,
|
|
||||||
})
|
|
||||||
await run(`mv ${epFiles.join(' ')} ${outDir}`)
|
|
||||||
await run(`rmdir ${path.resolve(outDir, 'element-plus')}`)
|
|
||||||
}
|
}
|
||||||
|
@ -55,6 +55,11 @@
|
|||||||
"memoize-one": "^6.0.0",
|
"memoize-one": "^6.0.0",
|
||||||
"normalize-wheel-es": "^1.1.0"
|
"normalize-wheel-es": "^1.1.0"
|
||||||
},
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@types/node": "*",
|
||||||
|
"csstype": "^2.6.0",
|
||||||
|
"vue-router": "^4.0.0"
|
||||||
|
},
|
||||||
"vetur": {
|
"vetur": {
|
||||||
"tags": "tags.json",
|
"tags": "tags.json",
|
||||||
"attributes": "attributes.json"
|
"attributes": "attributes.json"
|
||||||
|
@ -188,12 +188,15 @@ importers:
|
|||||||
specifiers:
|
specifiers:
|
||||||
'@element-plus/icons': ^0.0.11
|
'@element-plus/icons': ^0.0.11
|
||||||
'@popperjs/core': ^2.10.2
|
'@popperjs/core': ^2.10.2
|
||||||
|
'@types/node': '*'
|
||||||
'@vueuse/core': ^6.7.3
|
'@vueuse/core': ^6.7.3
|
||||||
async-validator: ^4.0.7
|
async-validator: ^4.0.7
|
||||||
|
csstype: ^2.6.0
|
||||||
dayjs: ^1.10.7
|
dayjs: ^1.10.7
|
||||||
lodash: ^4.17.21
|
lodash: ^4.17.21
|
||||||
memoize-one: ^6.0.0
|
memoize-one: ^6.0.0
|
||||||
normalize-wheel-es: ^1.1.0
|
normalize-wheel-es: ^1.1.0
|
||||||
|
vue-router: ^4.0.0
|
||||||
dependencies:
|
dependencies:
|
||||||
'@element-plus/icons': 0.0.11
|
'@element-plus/icons': 0.0.11
|
||||||
'@popperjs/core': 2.10.2
|
'@popperjs/core': 2.10.2
|
||||||
@ -203,6 +206,10 @@ importers:
|
|||||||
lodash: 4.17.21
|
lodash: 4.17.21
|
||||||
memoize-one: 6.0.0
|
memoize-one: 6.0.0
|
||||||
normalize-wheel-es: 1.1.0
|
normalize-wheel-es: 1.1.0
|
||||||
|
devDependencies:
|
||||||
|
'@types/node': 16.11.6
|
||||||
|
csstype: 2.6.18
|
||||||
|
vue-router: 4.0.12_vue@3.2.21
|
||||||
|
|
||||||
packages/hooks:
|
packages/hooks:
|
||||||
specifiers: {}
|
specifiers: {}
|
||||||
@ -1767,6 +1774,10 @@ packages:
|
|||||||
resolution: {integrity: sha512-TMgXmy0v2xWyuCSCJM6NCna2snndD8yvQF67J29ipdzMcsPa9u+o0tjF5+EQNdhcuZplYuouYqpc4zcd5I6amQ==}
|
resolution: {integrity: sha512-TMgXmy0v2xWyuCSCJM6NCna2snndD8yvQF67J29ipdzMcsPa9u+o0tjF5+EQNdhcuZplYuouYqpc4zcd5I6amQ==}
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
/@types/node/16.11.6:
|
||||||
|
resolution: {integrity: sha512-ua7PgUoeQFjmWPcoo9khiPum3Pd60k4/2ZGXt18sm2Slk0W0xZTqt5Y0Ny1NyBiN1EVQ/+FaF9NcY4Qe6rwk5w==}
|
||||||
|
dev: true
|
||||||
|
|
||||||
/@types/normalize-package-data/2.4.0:
|
/@types/normalize-package-data/2.4.0:
|
||||||
resolution: {integrity: sha512-f5j5b/Gf71L+dbqxIpQ4Z2WlmI/mPJ0fOkGGmFgtb6sAu97EPczzbS3/tJKxmcYDj55OX6ssqwDAWOHIYDRDGA==}
|
resolution: {integrity: sha512-f5j5b/Gf71L+dbqxIpQ4Z2WlmI/mPJ0fOkGGmFgtb6sAu97EPczzbS3/tJKxmcYDj55OX6ssqwDAWOHIYDRDGA==}
|
||||||
dev: true
|
dev: true
|
||||||
|
@ -5,5 +5,9 @@
|
|||||||
matchPaths: ['docs/package.json'],
|
matchPaths: ['docs/package.json'],
|
||||||
extends: ['config:js-app'],
|
extends: ['config:js-app'],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
matchPaths: ['packages/element-plus/package.json'],
|
||||||
|
extends: ['config:base', ':preserveSemverRanges'],
|
||||||
|
},
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user