fix: fix build error (#119)

This commit is contained in:
Kagol 2023-04-08 16:41:25 +08:00 committed by GitHub
parent 8a941f3711
commit 442a6e9ff7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 41 additions and 14 deletions

View File

@ -51,7 +51,7 @@ export const getVuePlugins = (vueVersion: string) => {
export const ns = (ver) => ({ '2': '', '2.7': '2', '3': '3' }[ver] || '')
export const getBaseConfig = ({ vueVersion, dtsInclude, dts, buildTarget }) => {
export const getBaseConfig = ({ vueVersion, dtsInclude, dts, buildTarget, themeVersion }) => {
// 处理tsconfig中配置主要是处理paths映射确保dts可以找到正确的包
const compilerOptions = require(pathFromWorkspaceRoot(`tsconfig.vue${vueVersion}.json`)).compilerOptions
@ -95,7 +95,7 @@ export const getBaseConfig = ({ vueVersion, dtsInclude, dts, buildTarget }) => {
generatePackageJsonPlugin({
beforeWriteFile: (filePath, content) => {
const versionTarget = `${vueVersion}.${buildTarget}`
const themeAndRenderlessVersion = `3.${buildTarget}`
const themeAndRenderlessVersion = `3.${themeVersion || buildTarget}`
const isThemeOrRenderless = (key) =>
key.includes('@opentiny/vue-theme') || key.includes('@opentiny/vue-renderless')
@ -157,7 +157,7 @@ export const getBaseConfig = ({ vueVersion, dtsInclude, dts, buildTarget }) => {
})
}
async function batchBuildAll({ vueVersion, tasks, formats, message, emptyOutDir, dts, buildTarget }) {
async function batchBuildAll({ vueVersion, tasks, formats, message, emptyOutDir, dts, buildTarget, themeVersion }) {
const rootDir = pathFromPackages('')
const outDir = path.resolve(rootDir, `dist${vueVersion}/@opentiny`)
await batchBuild({
@ -192,7 +192,7 @@ async function batchBuildAll({ vueVersion, tasks, formats, message, emptyOutDir,
const dtsInclude = toTsInclude(tasks)
await build({
configFile: false,
...getBaseConfig({ vueVersion, dtsInclude, dts, buildTarget }),
...getBaseConfig({ vueVersion, dtsInclude, dts, buildTarget, themeVersion }),
build: {
emptyOutDir,
minify: false,
@ -255,6 +255,7 @@ export interface BuildUiOption {
dts: boolean // 是否生成TS类型声明文件
scope?: string // npm的组织名称
min?: boolean // 是否压缩产物
themeVersion: string // renderless/theme/theme-mobile版本
}
function getEntryTasks(): Module[] {
@ -295,7 +296,7 @@ function getTasks(names: string[]): Module[] {
export async function buildUi(
names: string[] = [],
{ vueVersions = ['2', '3'], buildTarget = '8.0', formats = ['es'], clean = false, dts = true }: BuildUiOption
{ vueVersions = ['2', '3'], buildTarget = '8.0', formats = ['es'], clean = false, dts = true, themeVersion }: BuildUiOption
) {
// 是否清空构建目录
let emptyOutDir = clean
@ -316,7 +317,7 @@ export async function buildUi(
// 要构建的vue框架版本
for (const vueVersion of vueVersions) {
const message = `TINY for vue${vueVersion}: ${JSON.stringify(names.length ? names : '全量')}`
await batchBuildAll({ vueVersion, tasks, formats, message, emptyOutDir, dts, buildTarget })
await batchBuildAll({ vueVersion, tasks, formats, message, emptyOutDir, dts, buildTarget, themeVersion })
// 确保只运行一次
emptyOutDir = false
}

View File

@ -22,6 +22,7 @@ program
.addOption(new Option('-v --vue-versions <vueVersions...>', '目标框架,默认所有').choices(['2', '2.7', '3']))
.addOption(new Option('-f --formats <formats...>', '目标格式,默认 ["es"]').choices(['es', 'cjs']))
.addOption(new Option('-t --build-target <buildTarget>', '组件的目标版本'))
.addOption(new Option('-tv --theme-version <themeVersion>', 'renderless/theme/theme-mobile的版本'))
.option('-s, --scope <scope>', 'npm scope默认是 opentiny会以 @opentiny 发布到 npm')
.option('-c, --clean', '清空构建目录')
.option('--no-dts', '不生成 dts')

View File

@ -1,6 +1,6 @@
{
"name": "opentiny-vue",
"version": "3.6.0",
"version": "3.6.1",
"private": true,
"packageManager": "pnpm@7.11.0",
"description": "An enterprise-class UI component library, support both Vue.js 2 and Vue.js 3, as well as PC and mobile.",

View File

@ -1,7 +1,7 @@
{
"name": "@opentiny/vue-renderless",
"private": true,
"version": "3.7.0",
"version": "3.6.1",
"description": "An enterprise-class UI component library, support both Vue.js 2 and Vue.js 3, as well as PC and mobile.",
"homepage": "https://opentiny.design/tiny-vue",
"keywords": [
@ -21,7 +21,7 @@
"scripts": {
"build": "tsup",
"postversion": "pnpm build",
"release": "esno ./scripts/postbuild.ts"
"release": "esno ./scripts/postbuild.ts && cp README.md dist"
},
"dependencies": {
"xss": "1.0.11"

View File

@ -0,0 +1,13 @@
const { resolve } = require('node:path')
const { promises: fsPromises } = require('node:fs')
const root = resolve('./')
async function run() {
const content = await fsPromises.readFile(resolve(root, 'package.json'), 'utf8')
const packageJson = JSON.parse(content)
delete packageJson.exports
delete packageJson.private
await fsPromises.writeFile(resolve(root, 'dist/package.json'), JSON.stringify(packageJson, null, 2))
}
run()

View File

@ -1,7 +1,6 @@
{
"name": "@opentiny/vue-theme-mobile",
"private": true,
"version": "3.7.0",
"version": "3.6.1",
"description": "An enterprise-class UI component library, support both Vue.js 2 and Vue.js 3, as well as PC and mobile.",
"homepage": "https://opentiny.design/tiny-vue",
"main": "index.css",
@ -27,7 +26,7 @@
"build": "npm run clean && npm run build:theme",
"build:fast": "npm run build && npm run release",
"publishTgz": "node .cloudbuild/publish-tgzs.js",
"release": "node build/release.js",
"release": "node build/release.js && node build/postbuild.js && cp README.md dist",
"postversion": "pnpm build"
},
"devDependencies": {

View File

@ -0,0 +1,13 @@
const { resolve } = require('node:path')
const { promises: fsPromises } = require('node:fs')
const root = resolve('./')
async function run() {
const content = await fsPromises.readFile(resolve(root, 'package.json'), 'utf8')
const packageJson = JSON.parse(content)
delete packageJson.exports
delete packageJson.private
await fsPromises.writeFile(resolve(root, 'dist/package.json'), JSON.stringify(packageJson, null, 2))
}
run()

View File

@ -1,6 +1,6 @@
{
"name": "@opentiny/vue-theme",
"version": "3.7.0",
"version": "3.6.1",
"description": "An enterprise-class UI component library, support both Vue.js 2 and Vue.js 3, as well as PC and mobile.",
"main": "index.css",
"homepage": "https://opentiny.design/tiny-vue",
@ -25,7 +25,7 @@
"build:theme": "gulp build --gulpfile build/gulp-dist.js",
"build": "npm run clean && npm run build:theme && node build/replace-img.js",
"build:fast": "npm run build && npm run release",
"release": "node build/release.js",
"release": "node build/release.js && node build/postbuild.js && cp README.md dist",
"build:copy-remote": "npm run build:theme && cp-cli dist ../aurora-vue/node_modules/@aurora/theme",
"publishTgz": "node .cloudbuild/publish-tgzs.js",
"postversion": "pnpm build"