diff --git a/theme/package.json b/theme/package.json index 9dd17fbc..51293cde 100644 --- a/theme/package.json +++ b/theme/package.json @@ -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" diff --git a/theme/tsup.config.ts b/theme/tsup.config.ts index 56142148..4a6f6da7 100644 --- a/theme/tsup.config.ts +++ b/theme/tsup.config.ts @@ -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)[] = [ @@ -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, @@ -35,6 +43,7 @@ export default defineConfig((cli) => { outDir: './lib/node', external: sharedExternal, target: 'node18', + watch: false, }, // client/utils/index.js { @@ -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')}`), + ], + })), ] })