MDX: Make Next.js config ESM only

This commit is contained in:
Fuma Nama
2026-04-16 18:21:38 +08:00
parent 71c15fd778
commit fa9f6788f3
4 changed files with 47 additions and 74 deletions
+7
View File
@@ -0,0 +1,7 @@
---
'fumadocs-mdx': minor
---
**Make Next.js config ESM only**
Newer Next.js supported `.mts` extension for Next.js config files, see [Next.js docs](https://nextjs.org/docs/app/api-reference/config/typescript#using-nodejs-native-typescript-resolver-for-nextconfigts) for more info.
-6
View File
@@ -1,6 +0,0 @@
---
'@fumadocs/story': patch
'fumadocs-typescript': patch
---
Bump `ts-morph`
+18 -35
View File
@@ -17,44 +17,27 @@
"dist"
],
"type": "module",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"exports": {
".": "./dist/index.js",
"./bin": "./dist/bin.js",
"./bun": "./dist/bun/index.js",
"./config": "./dist/config/index.js",
"./next": "./dist/next/index.js",
"./node/loader": "./dist/node/loader.js",
"./plugins/index-file": "./dist/plugins/index-file.js",
"./plugins/json-schema": "./dist/plugins/json-schema.js",
"./plugins/last-modified": "./dist/plugins/last-modified.js",
"./runtime/browser": "./dist/runtime/browser.js",
"./runtime/dynamic": "./dist/runtime/dynamic.js",
"./runtime/server": "./dist/runtime/server.js",
"./runtime/types": "./dist/runtime/types.js",
"./vite": "./dist/vite/index.js",
"./webpack/mdx": "./dist/webpack/mdx.js",
"./webpack/meta": "./dist/webpack/meta.js",
"./package.json": "./package.json",
"./loader-mdx": "./loader-mdx.cjs",
"./loader-meta": "./loader-meta.cjs",
"./config": {
"types": "./dist/config/index.d.ts",
"import": "./dist/config/index.js"
},
"./next": {
"types": "./dist/next/index.d.ts",
"import": "./dist/next/index.js",
"require": "./dist/next/index.cjs"
},
"./vite": {
"types": "./dist/vite/index.d.ts",
"import": "./dist/vite/index.js"
},
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js"
},
"./runtime/*": {
"types": "./dist/runtime/*.d.ts",
"import": "./dist/runtime/*.js"
},
"./node/loader": {
"types": "./dist/node/loader.d.ts",
"import": "./dist/node/loader.js"
},
"./bun": {
"types": "./dist/bun/index.d.ts",
"import": "./dist/bun/index.js"
},
"./plugins/*": {
"types": "./dist/plugins/*.d.ts",
"import": "./dist/plugins/*.js"
}
"./loader-meta": "./loader-meta.cjs"
},
"publishConfig": {
"access": "public"
+22 -33
View File
@@ -9,39 +9,28 @@ const noExternal = [
'fumadocs-core/mdx-plugins/remark-llms',
];
export default defineConfig([
{
entry: [
'./src/{index,bin}.ts',
'./src/{config,next,vite,bun}/index.ts',
'./src/webpack/{mdx,meta}.ts',
'./src/node/loader.ts',
'./src/runtime/*.{ts,tsx}',
'./src/plugins/*.ts',
],
format: 'esm',
dts: true,
fixedExtension: false,
target: 'node22',
deps: {
onlyBundle: noExternal,
alwaysBundle: noExternal,
neverBundle: external,
export default defineConfig({
entry: [
'./src/{index,bin}.ts',
'./src/{config,next,vite,bun}/index.ts',
'./src/webpack/{mdx,meta}.ts',
'./src/node/loader.ts',
'./src/runtime/*.{ts,tsx}',
'./src/plugins/*.ts',
],
format: 'esm',
dts: true,
fixedExtension: false,
target: 'node22',
exports: {
customExports: {
'./loader-mdx': './loader-mdx.cjs',
'./loader-meta': './loader-meta.cjs',
},
},
{
outDir: 'dist/next',
// ensure Next.js CJS config compatibility
// because next.config.ts by default uses CJS
entry: ['./src/next/index.ts'],
format: 'cjs',
dts: false,
fixedExtension: false,
target: 'node22',
deps: {
onlyBundle: noExternal,
alwaysBundle: noExternal,
neverBundle: external,
},
deps: {
onlyBundle: noExternal,
alwaysBundle: noExternal,
neverBundle: external,
},
]);
});