Browse Source

type

master
npmrun 3 years ago
parent
commit
da995a8031
  1. 17
      packages/all.ts
  2. 21
      packages/build/build.ts
  3. 18
      packages/build/buildAll.ts
  4. 3
      packages/build/package.json
  5. 1
      packages/build/tsconfig.json
  6. 2
      packages/components/captcha/captcha.vue
  7. 16
      packages/components/index.ts
  8. 5
      packages/components/package.json
  9. 1
      packages/hooks/index.ts
  10. 2067
      pnpm-lock.yaml

17
packages/all.ts

@ -0,0 +1,17 @@
import * as componets from '@princess-ui/components'
import type { App } from 'vue'
export * from '@princess-ui/components'
export * from '@princess-ui/hooks'
function install(app: App) {
for (const key in componets) {
const component = componets[key]
app.component(component.name || 'ps-' + key, component)
}
}
export { install }
export default {
install,
}

21
packages/build/build.ts

@ -7,9 +7,15 @@ import buildComponent from "./buildComponent"
import buildAll from "./buildAll"
import { getOutput, getPath, getPkgs } from "@princess-ui/share"
import * as dts from "dts-bundle"
import pkg from "../princess-ui/package.json"
console.log(chalk.yellow(`当前工作目录:${process.cwd()}`))
const oldCwdFn = process.cwd
process.cwd = ()=>{
return getPkgs()
}
console.log(chalk.yellow(`修改后工作目录:${process.cwd()}`))
console.log(chalk.yellow("正在清除lib文件夹"))
rimraf(getOutput("lib"), async err => {
if (err) throw err
@ -29,7 +35,18 @@ rimraf(getOutput("lib"), async err => {
console.log(chalk.yellow("构建全量包"))
await buildAll("ps")
console.log(chalk.green(`构建全量包完成, 其耗时:${(new Date().getTime() - beginDate) / 1000}s`))
process.cwd = ()=>{
return getPath()
console.log(chalk.red("构建完成,开始生成d.ts"))
const dtsOptions = {
name: pkg.name,
main: `princess-ui/lib/packages/all.d.ts`,
out: `../index.d.ts`,
outputAsModuleFolder: true
}
dts.bundle(dtsOptions)
console.log(chalk.red("生成完毕,开始清理残余"))
rimraf.sync(getOutput('lib/packages'))
console.log(chalk.green("残余清理完毕"))
process.cwd = oldCwdFn
console.log(chalk.yellow(`工作目录重置为:${process.cwd()}`))
})

18
packages/build/buildAll.ts

@ -9,13 +9,18 @@ import { getOutput, getPath, getPkgs } from "@princess-ui/share";
export default function (name: string) {
return build({
logLevel: "error",
resolve: {
alias: {
"@princess-ui": getPkgs(),
}
},
plugins: [
replaceCodePlugin({
replacements: [
{
from: "@princess-ui/components",
to: "../",
},
// {
// from: "@princess-ui/components",
// to: "../",
// },
// {
// from: /\@princess\-ui\/theme-chalk\/src\/(.*?)\.scss/i,
// to: "princess-ui/theme-chalk/$1.css"
@ -25,11 +30,10 @@ export default function (name: string) {
vue({ isProduction: true }),
vueJsx(),
dts({
entryRoot: `components`,
tsConfigFilePath: getPath("tsconfig.json"),
outputDir: getOutput("lib"),
cleanVueFileName: true,
include: ['components/index.ts', 'components/components.ts'],
include: ['all.ts', "hooks", "components"],
staticImport: true,
}),
],
@ -37,7 +41,7 @@ export default function (name: string) {
outDir: getOutput("lib"),
emptyOutDir: false,
lib: {
entry: path.resolve(__dirname, `../components/index.ts`),
entry: getPkgs(`all.ts`),
name: name,
formats: ["es", "umd"],
fileName: format => `index${format=='es'?'':'.umd'}.js`,

3
packages/build/package.json

@ -22,5 +22,8 @@
"vite-plugin-dts": "^1.1.1",
"vite-plugin-replace": "^0.1.1",
"vue": "^3.2.36"
},
"dependencies": {
"dts-bundle": "^0.7.3"
}
}

1
packages/build/tsconfig.json

@ -2,6 +2,7 @@
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"resolveJsonModule": true,
"module": "commonjs",
"lib": ["ES6", "DOM"],
"declaration": false,

2
packages/components/captcha/captcha.vue

@ -6,10 +6,12 @@
:loading="isLoading" type="button" size="small">
{{ text }}
</div>
<Abutton>asd</Abutton>
</template>
<script lang="ts" setup>
import { onBeforeUnmount, ref } from "vue"
import Abutton from "@princess-ui/components/button"
const props = withDefaults(
defineProps<{
duration?: number

16
packages/components/index.ts

@ -1,15 +1 @@
import * as componets from "./components"
export * from "./components"
function install(app) {
for (const key in componets) {
const component = componets[key]
app.component(component.name || "ps-" + key, component)
}
}
export { install }
export default {
install
}
export * from "./components"

5
packages/components/package.json

@ -4,10 +4,7 @@
"description": "",
"main": "index.ts",
"module": "index.ts",
"scripts": {
"start": "ts-node index.ts",
"dev": "ts-node ../../scripts/index.ts"
},
"scripts": {},
"keywords": [],
"author": "",
"license": "ISC"

1
packages/hooks/index.ts

@ -0,0 +1 @@
export * from './useNamespace'

2067
pnpm-lock.yaml

File diff suppressed because it is too large
Loading…
Cancel
Save