build: update create package template

This commit is contained in:
pengzhanbo 2023-02-10 04:34:41 +08:00
parent 7b88251c7b
commit e1e845a470
10 changed files with 30 additions and 60 deletions

View File

@ -39,8 +39,8 @@ const generatorFile = async (config) => {
}
const include = [
!client && 'client',
!client && 'tsconfig.esm.json',
!shared && 'shared',
!shared && 'client/index.js'
]
.filter(Boolean)
.join('|')

View File

@ -18,10 +18,16 @@
},
"license": "MIT",
"author": "pengzhanbo <volodymyr@foxmail.com>",
"type": "module",
"exports": {
".": "./lib/node/index.js",
{{#if shared }}
"./client": "./lib/client/index.js",
{{/if}}
"./package.json": "./package.json"
},
"main": "lib/node/index.js",
"files": [
"lib"
],
"types": "./lib/node/index.d.ts",
"scripts": {
"build": "pnpm run clean && pnpm run copy && pnpm run ts",
"clean": "rimraf lib *.tsbuildinfo",

View File

@ -1,5 +0,0 @@
import { defineClientAppEnhance } from '@vuepress/client'
export default defineClientAppEnhance(({ router }) => {
// do something
})

View File

@ -0,0 +1,8 @@
import { defineClientConfig } from '@vuepress/client'
export default defineClientConfig({
setup() {
// do something
},
})

View File

@ -0,0 +1 @@
export * from '../shared/index.js'

View File

@ -1,8 +1,8 @@
import { {{ lowerName }}Plugin } from './plugin'
import { {{ lowerName }}Plugin } from './plugin.js'
export * from './plugin'
export * from './plugin.js'
{{#if shared }}
export * from '../shared'
export * from '../shared/index.js'
{{/if}}
export default {{ lowerName }}Plugin

View File

@ -3,7 +3,7 @@ import type { App, Plugin } from '@vuepress/core'
import { path } from '@vuepress/utils'
{{/if}}
{{#if shared}}
import type { {{ upperName }}Options } from '../shared'
import type { {{ upperName }}Options } from '../shared/index.js'
{{else}}
export interface {{ upperName }}Options {
@ -16,10 +16,7 @@ export const {{ lowerName }}Plugin = (options: {{ upperName }}Options): Plugin =
return {
name: '@vuepress-plume/vuepress-{{ pkgName }}',
{{#if client}}
clientAppEnhanceFiles: path.resolve(
__dirname,
'../client/clientAppEnhance.js'
),
clientConfigFile: path.resolve(__dirname, '../client/clientConfig.js'),
{{/if}}
}
}

View File

@ -1,14 +1,8 @@
{
"extends": "../../tsconfig.base.json",
"references": [
{{#if client}}
{
"path": "./tsconfig.esm.json"
},
{{/if}}
{
"path": "./tsconfig.cjs.json"
}
],
"files": []
"extends": "../tsconfig.build.json",
"compilerOptions": {
"rootDir": "./src",
"outDir": "./lib"
},
"include": ["./src"]
}

View File

@ -1,14 +0,0 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"module": "CommonJS",
"rootDir": "./src",
"outDir": "./lib"
},
"include": [
{{#if shared}}
"./src/shared",
{{/if}}
"./src/node"
]
}

View File

@ -1,17 +0,0 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"module": "ES2020",
"rootDir": "./src",
"outDir": "./lib",
"types": [
"@vuepress/client/types"
]
},
"include": [
{{#if shared}}
"./src/shared",
{{/if}}
"./src/client"
]
}