Skip to content

Commit 7a68e1e

Browse files
committed
fix: mark runtime/ directory as external
resolves #242
1 parent 3a54a33 commit 7a68e1e

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

example/src/module.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
import { defineNuxtModule, addPlugin, createResolver } from '@nuxt/kit'
22

3+
// https://github.com/nuxt/module-builder/issues/242
4+
import type { SharedTypeFromRuntime } from './runtime/plugins/plugin'
5+
36
// Module options TypeScript interface definition
47
export interface ModuleOptions {
58
apiKey: string
9+
shared?: SharedTypeFromRuntime
610
}
711

812
export interface ModuleHooks {
@@ -33,6 +37,9 @@ export default defineNuxtModule<ModuleOptions>({
3337
setup(_options, _nuxt) {
3438
const resolver = createResolver(import.meta.url)
3539

40+
// @ts-expect-error type should be resolved
41+
_options.shared = 'not-shared-type'
42+
3643
// Do not add the extension since the `.ts` will be transpiled to `.mjs` after `npm run prepack`
3744
addPlugin(resolver.resolve('./runtime/plugins/plugin'))
3845
},

example/src/runtime/plugins/plugin.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { defineNuxtPlugin } from '#app'
22

3+
export type SharedTypeFromRuntime = 'shared-type'
4+
35
export default defineNuxtPlugin(() => {
46
console.log('Plugin injected by my-module!')
57
return {

src/commands/build.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ export default defineCommand({
5858
cjsBridge: true,
5959
},
6060
externals: [
61+
/src\/runtime/,
6162
'@nuxt/schema',
6263
'@nuxt/schema-nightly',
6364
'@nuxt/schema-edge',

0 commit comments

Comments
 (0)