11import fs from 'node:fs/promises'
2+ import { createRequire } from 'node:module'
23import { defineConfig } from 'tsdown'
34
5+ const require = createRequire ( import . meta. url )
6+
47export default defineConfig ( [ {
5- entry : './src/index .ts' ,
8+ entry : './src/module .ts' ,
69 // tsconfig: '../../tsconfig.base.json',
710 clean : true ,
811 dts : true ,
9- exports : true ,
12+ exports : false ,
1013 // Keep transitive Nuxt/Vite type graphs out of dts bundling. Consumers
1114 // resolve these via their own node_modules at install time.
1215 deps : {
@@ -39,7 +42,8 @@ export default defineConfig([{
3942 } ,
4043 hooks : {
4144 'build:done' : async ( ) => {
42- // copy types and generate plugin dts
45+ const { name, version, devDependencies } = require ( './package.json' )
46+ // copy types and generate plugin d.ts, module types.d.mts and module.json files
4347 await Promise . all ( [
4448 fs . cp ( 'src/runtime/types.d.ts' , 'dist/runtime/types.d.ts' ) ,
4549 fs . writeFile ( 'dist/runtime/plugin.client.d.ts' , `import type { Plugin } from '#app';
@@ -48,6 +52,19 @@ declare const plugin: Plugin<{
4852 rpc: DevToolsRpcClient;
4953}>;
5054export default plugin;
55+ ` , 'utf-8' ) ,
56+ fs . writeFile ( 'dist/types.d.mts' , `export { default } from './module.mjs';
57+
58+ export { type ModuleOptions, type DevframeNuxtModuleOptions } from './module.mjs';
59+ ` , 'utf-8' ) ,
60+ fs . writeFile ( 'dist/module.json' , `{
61+ "name": "${ name } ",
62+ "configKey": "devframe",
63+ "version": "${ version } ",
64+ "builder": {
65+ "tsdown": "${ devDependencies . tsdown } "
66+ }
67+ }
5168` , 'utf-8' ) ,
5269 ] )
5370 } ,
0 commit comments