Skip to content

Commit

Permalink
fix: allow .ts or .js extension in module package (#225)
Browse files Browse the repository at this point in the history
* fix: allow .ts or .js extension in module package

* Update module.ts to replace node:path with pathe package
  • Loading branch information
Tiarhai committed Dec 29, 2023
1 parent c75b402 commit 9d66d15
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/module/src/module.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { readdirSync } from 'node:fs'
import { join } from 'pathe'
import { addComponent, createResolver, defineNuxtModule } from '@nuxt/kit'
import { Project } from 'ts-morph'

Expand Down Expand Up @@ -29,7 +30,7 @@ export default defineNuxtModule<ModuleOptions>({
const COMPONENT_DIR_PATH = options.componentDir!
const ROOT_DIR_PATH = nuxt.options.rootDir

const { resolve } = createResolver(ROOT_DIR_PATH)
const { resolve, resolvePath } = createResolver(ROOT_DIR_PATH)

nuxt.options.ignore.push(IGNORE_DIR)
nuxt._ignore?.add(IGNORE_DIR)
Expand All @@ -38,7 +39,7 @@ export default defineNuxtModule<ModuleOptions>({
try {
readdirSync(resolve(COMPONENT_DIR_PATH))
.forEach(async (dir) => {
const filePath = resolve(COMPONENT_DIR_PATH, dir, 'index.ts')
const filePath = await resolvePath(join(COMPONENT_DIR_PATH, dir, 'index'), { extensions: ['.ts', '.js'] })

const project = new Project()
project.addSourceFileAtPath(filePath)
Expand Down

0 comments on commit 9d66d15

Please sign in to comment.