Skip to content

Commit

Permalink
fix: add default export for types.d.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Jan 17, 2022
1 parent 666a7e5 commit 885c02f
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/build.ts
Expand Up @@ -10,7 +10,7 @@ export interface BuildModuleOptions {
stub?: boolean
}

export async function buildModule (opts: BuildModuleOptions) {
export async function buildModule(opts: BuildModuleOptions) {
const { build } = await import('unbuild')

await build(opts.rootDir, false, {
Expand All @@ -31,7 +31,7 @@ export async function buildModule (opts: BuildModuleOptions) {
'@nuxt/kit-edge'
],
hooks: {
async 'rollup:done' (ctx) {
async 'rollup:done'(ctx) {
// Generate CommonJS stup
await writeCJSStub(ctx.options.outDir)

Expand Down Expand Up @@ -70,7 +70,7 @@ export async function buildModule (opts: BuildModuleOptions) {
})
}

async function writeTypes (distDir: string, meta: ModuleMeta) {
async function writeTypes(distDir: string, meta: ModuleMeta) {
const dtsFile = resolve(distDir, 'types.d.ts')
if (existsSync(dtsFile)) {
return
Expand Down Expand Up @@ -103,13 +103,13 @@ import { ${moduleImports.join(', ')} } from './module'
${schemaShims.length ? `declare module '@nuxt/schema' {\n${schemaShims.join('\n')}\n}\n` : ''}
export * from './module'
export { default } from './module'
`

await fsp.writeFile(dtsFile, dtsContents, 'utf8')
}

async function writeCJSStub (distDir: string) {
async function writeCJSStub(distDir: string) {
const cjsStubFile = resolve(distDir, 'module.cjs')
if (existsSync(cjsStubFile)) {
return
Expand Down

0 comments on commit 885c02f

Please sign in to comment.