fix: import js index file with file extension (#2206)

This commit is contained in:
Alex Yang
2025-08-14 09:33:32 +08:00
committed by GitHub
parent 249d2055a9
commit b41ffc32bd
3 changed files with 3 additions and 3 deletions
+1 -1
View File
@@ -39,7 +39,7 @@ export type ImportPathConfig = { relativeTo: string } | { absolute: true };
export function toImportPath(file: string, config: ImportPathConfig): string {
const ext = path.extname(file);
const filename =
ext === '.ts' ? file.substring(0, file.length - ext.length) : file;
ext === '.ts' ? file.substring(0, file.length - ext.length) + '.js' : file;
let importPath;
if ('relativeTo' in config) {
+1 -1
View File
@@ -2,5 +2,5 @@
import { _runtimeAsync, buildConfig } from "fumadocs-mdx/runtime/async"
const _sourceConfig = buildConfig(_source)
import { _runtime } from "fumadocs-mdx"
import * as _source from "./config"
import * as _source from "./config.js"
export const docs = _runtimeAsync.doc<typeof _source.docs>([{"info":{"path":"index.mdx","absolutePath":"$cwd/packages/mdx/test/fixtures/index.mdx"},"data":{},"content":"# Hello World\n"}, {"info":{"path":"folder/test.mdx","absolutePath":"$cwd/packages/mdx/test/fixtures/folder/test.mdx"},"data":{},"content":""}], "docs", _sourceConfig)
+1 -1
View File
@@ -2,5 +2,5 @@
import * as docs_1 from "./folder/test.mdx?collection=docs&hash=hash"
import * as docs_0 from "./index.mdx?collection=docs&hash=hash"
import { _runtime } from "fumadocs-mdx"
import * as _source from "./config"
import * as _source from "./config.js"
export const docs = _runtime.doc<typeof _source.docs>([{ info: {"path":"index.mdx","absolutePath":"$cwd/packages/mdx/test/fixtures/index.mdx"}, data: docs_0 }, { info: {"path":"folder/test.mdx","absolutePath":"$cwd/packages/mdx/test/fixtures/folder/test.mdx"}, data: docs_1 }]);