Skip to content

Commit

Permalink
fix(module): invalid resolved path in npm package (#161)
Browse files Browse the repository at this point in the history
  • Loading branch information
farnabaz authored Jun 12, 2024
1 parent 389a633 commit 712952a
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
26 changes: 13 additions & 13 deletions src/utils/features.ts → src/features.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { joinURL } from 'ufo'
import { join } from 'pathe'
import { defu } from 'defu'
import { $fetch } from 'ofetch'
import { addDevtoolsCustomTabs } from './devtools'
import { addDevtoolsCustomTabs } from './utils/devtools'

const log = logger.withTag('nuxt:hub')

Expand Down Expand Up @@ -37,8 +37,8 @@ export function setupBase(nuxt: Nuxt, hub: HubConfig) {
const { resolve } = createResolver(import.meta.url)

// Add Server scanning
addServerScanDir(resolve('../runtime/base/server'))
addServerImportsDir(resolve('../runtime/base/server/utils'))
addServerScanDir(resolve('./runtime/base/server'))
addServerImportsDir(resolve('./runtime/base/server/utils'))

// Add custom tabs to Nuxt Devtools
if (nuxt.options.dev) {
Expand All @@ -50,11 +50,11 @@ export function setupBlob(_nuxt: Nuxt) {
const { resolve } = createResolver(import.meta.url)

// Add Server scanning
addServerScanDir(resolve('../runtime/blob/server'))
addServerImportsDir(resolve('../runtime/blob/server/utils'))
addServerScanDir(resolve('./runtime/blob/server'))
addServerImportsDir(resolve('./runtime/blob/server/utils'))

// Add Composables
addImportsDir(resolve('../runtime/blob/app/composables'))
addImportsDir(resolve('./runtime/blob/app/composables'))
}

export function setupCache(nuxt: Nuxt) {
Expand All @@ -78,23 +78,23 @@ export function setupCache(nuxt: Nuxt) {
})

// Add Server scanning
addServerScanDir(resolve('../runtime/cache/server'))
addServerScanDir(resolve('./runtime/cache/server'))
}

export function setupDatabase(_nuxt: Nuxt) {
const { resolve } = createResolver(import.meta.url)

// Add Server scanning
addServerScanDir(resolve('../runtime/database/server'))
addServerImportsDir(resolve('../runtime/database/server/utils'))
addServerScanDir(resolve('./runtime/database/server'))
addServerImportsDir(resolve('./runtime/database/server/utils'))
}

export function setupKV(_nuxt: Nuxt) {
const { resolve } = createResolver(import.meta.url)

// Add Server scanning
addServerScanDir(resolve('../runtime/kv/server'))
addServerImportsDir(resolve('../runtime/kv/server/utils'))
addServerScanDir(resolve('./runtime/kv/server'))
addServerImportsDir(resolve('./runtime/kv/server/utils'))
}

export function setupOpenAPI(nuxt: Nuxt) {
Expand All @@ -103,9 +103,9 @@ export function setupOpenAPI(nuxt: Nuxt) {
// Fallback to custom placeholder when openAPI is disabled
nuxt.options.alias['#hub/openapi'] = nuxt.options.nitro?.experimental?.openAPI === true
? '#internal/nitro/routes/openapi'
: resolve('../runtime/openapi/templates/openapi')
: resolve('./runtime/openapi/templates/openapi')

addServerScanDir(resolve('../runtime/openapi/server'))
addServerScanDir(resolve('./runtime/openapi/server'))
}

export async function setupRemote(_nuxt: Nuxt, hub: HubConfig) {
Expand Down
2 changes: 1 addition & 1 deletion src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { findWorkspaceDir } from 'pkg-types'
import { parseArgs } from 'citty'
import { version } from '../package.json'
import { generateWrangler } from './utils/wrangler'
import { setupCache, setupBlob, setupOpenAPI, setupDatabase, setupKV, setupBase, setupRemote } from './utils/features'
import { setupCache, setupBlob, setupOpenAPI, setupDatabase, setupKV, setupBase, setupRemote } from './features'
import type { ModuleOptions } from './types/module'

export * from './types'
Expand Down
2 changes: 1 addition & 1 deletion src/utils/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { logger } from '@nuxt/kit'
import { join } from 'pathe'
import { $fetch } from 'ofetch'
import type { Nuxt } from '@nuxt/schema'
import type { HubConfig } from './features'
import type { HubConfig } from '../features'

const log = logger.withTag('nuxt:hub')

Expand Down
2 changes: 1 addition & 1 deletion src/utils/devtools.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { addCustomTab } from '@nuxt/devtools-kit'
import type { Nuxt } from 'nuxt/schema'
import type { HubConfig } from './features'
import type { HubConfig } from '../features'

export function addDevtoolsCustomTabs(nuxt: Nuxt, hub: HubConfig) {
nuxt.hook('listen', (_, { url }) => {
Expand Down

0 comments on commit 712952a

Please sign in to comment.