fix(bridge): emit types for module (#660)

This commit is contained in:
Daniel Roe 2021-10-05 22:47:58 +02:00 committed by GitHub
parent ae0dbda2ce
commit 0213adcd20
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 31 additions and 3 deletions

View File

@ -1,10 +1,11 @@
import { defineBuildConfig } from 'unbuild'
export default defineBuildConfig({
declaration: true,
emitCJS: false,
entries: [
'src/module',
{ input: 'src/runtime/', outDir: 'dist/runtime', format: 'esm' }
{ input: 'src/runtime/', outDir: 'dist/runtime', format: 'esm', declaration: true }
],
externals: [
'webpack'

View File

@ -4,7 +4,8 @@
"repository": "nuxt/framework",
"license": "MIT",
"type": "module",
"exports": "./module.cjs",
"main": "./module.cjs",
"types": "./dist/module.d.ts",
"files": [
"module.cjs",
"dist"

View File

@ -7,6 +7,19 @@ import { setupBetterResolve } from './resolve'
import { setupGlobalImports } from './global-imports'
import { setupTypescript } from './typescript'
export interface BridgeConfig {
nitro: boolean
vite: boolean
app: boolean | {}
capi: boolean | {}
globalImports: boolean
constraints: boolean
postcss8: boolean
swc: boolean
resolve: boolean
typescript: boolean
}
export default defineNuxtModule({
name: 'nuxt-bridge',
configKey: 'bridge',
@ -21,7 +34,7 @@ export default defineNuxtModule({
postcss8: true,
typescript: true,
resolve: true
},
} as BridgeConfig,
async setup (opts, nuxt) {
const _require = createRequire(import.meta.url)
@ -67,3 +80,16 @@ export default defineNuxtModule({
}
}
})
declare module '@nuxt/kit' {
interface NuxtConfig {
bridge?: Partial<BridgeConfig>
}
}
// @ts-ignore
declare module '@nuxt/types' {
interface NuxtConfig {
bridge?: Partial<BridgeConfig>
}
}