Skip to content

Commit

Permalink
feat(theme): add support for optional features
Browse files Browse the repository at this point in the history
  • Loading branch information
pengzhanbo committed Jul 26, 2024
1 parent ce544d2 commit 5e9d2d0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
3 changes: 3 additions & 0 deletions theme/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
"types": "./lib/client/composables/index.d.ts",
"import": "./lib/client/composables/index.js"
},
"./features/*": {
"import": "./lib/client/features/components/*"
},
"./shared": {
"types": "./lib/shared/index.d.ts",
"import": "./lib/shared/index.js"
Expand Down
20 changes: 20 additions & 0 deletions theme/tsup.config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import process from 'node:process'
import fs from 'node:fs'
import path from 'node:path'
import { type Options, defineConfig } from 'tsup'

const sharedExternal: (string | RegExp)[] = [
Expand All @@ -12,6 +15,11 @@ const clientExternal: (string | RegExp)[] = [
/.*\.css$/,
]

const featuresComposables = fs.readdirSync(
path.join(process.cwd(), 'src/client/features/composables'),
{ recursive: true, encoding: 'utf-8' },
)

export default defineConfig((cli) => {
const DEFAULT_OPTIONS: Options = {
dts: !cli.watch,
Expand All @@ -35,6 +43,7 @@ export default defineConfig((cli) => {
outDir: './lib/node',
external: sharedExternal,
target: 'node18',
watch: false,
},
// client/utils/index.js
{
Expand Down Expand Up @@ -77,5 +86,16 @@ export default defineConfig((cli) => {
'./config.js',
],
},
...featuresComposables.map(file => ({
...DEFAULT_OPTIONS,
entry: [`./src/client/features/composables/${file}`],
outDir: `./lib/client/features/composables/`,
external: [
...clientExternal,
'../../composables/index.js',
'../../utils/index.js',
...featuresComposables.map(file => `./${file.replace('.ts', '.js')}`),
],
})),
]
})

0 comments on commit 5e9d2d0

Please sign in to comment.