Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
2fb8613
fix: resolve build errors in mdxdb and minimal example
devin-ai-integration[bot] May 16, 2025
19e26dc
fix: update date-fns version and include minimal example types
devin-ai-integration[bot] May 16, 2025
36513c5
fix: update lockfile with date-fns dependency
devin-ai-integration[bot] May 16, 2025
afe7c5b
fix: update mdxe to use app directory structure
devin-ai-integration[bot] May 16, 2025
6eb881b
fix: add ESLint config to minimal example
devin-ai-integration[bot] May 16, 2025
85ccbc7
fix: add Vercel configuration for minimal example
devin-ai-integration[bot] May 16, 2025
c6ba99e
fix: revert app directory changes and update Vercel configuration for…
devin-ai-integration[bot] May 16, 2025
73ac371
fix: remove app directory files from minimal example
devin-ai-integration[bot] May 16, 2025
42e4ab7
fix: add patch for @payloadcms/ui to fix date-fns transpose import error
devin-ai-integration[bot] May 16, 2025
3cf5d0b
fix: add app directory structure to minimal example
devin-ai-integration[bot] May 16, 2025
416079a
fix: copy .next folder to user directory after build completes
devin-ai-integration[bot] May 16, 2025
20eea12
fix: remove rewrites from vercel.json in minimal example
devin-ai-integration[bot] May 16, 2025
b027f76
fix: resolve merge conflicts in mdxe.js and tsconfig.json
devin-ai-integration[bot] May 16, 2025
337be5d
fix: update patch file format to fix hunk header integrity check
devin-ai-integration[bot] May 16, 2025
a81cc89
fix: remove problematic patch file
devin-ai-integration[bot] May 16, 2025
a807610
fix: remove patch references from package.json files
devin-ai-integration[bot] May 16, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions examples/minimal/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "next/core-web-vitals"
}
7 changes: 7 additions & 0 deletions examples/minimal/app/layout.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default function RootLayout({ children }) {
return (
<html lang="en">
<body>{children}</body>
</html>
)
}
3 changes: 3 additions & 0 deletions examples/minimal/app/page.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function Page() {
return <div>Welcome to your MDX app!</div>
}
6 changes: 6 additions & 0 deletions examples/minimal/vercel.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"buildCommand": "mdxe build",
"outputDirectory": ".next",
"framework": "nextjs",
"installCommand": "pnpm install"
}
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"build": "turbo run build",
"dev": "turbo run dev",
"lint": "turbo run lint",
"test": "turbo run test",
"format": "prettier --write \"**/*.{js,jsx,ts,tsx,md,mdx}\"",
"check-types": "turbo run check-types",
"test": "echo \"No tests specified yet\" && exit 0",
Expand All @@ -28,5 +29,9 @@
"printWidth": 160,
"tabWidth": 2,
"semi": false
},
"pnpm": {
"patchedDependencies": {
}
}
}
6 changes: 3 additions & 3 deletions packages/mdxdb/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"@payloadcms/next": "3.33.0",
"@payloadcms/payload-cloud": "3.33.0",
"@payloadcms/richtext-lexical": "3.33.0",
"date-fns": "^4.1.0",
"graphql": "^16.8.1",
"next": "15.3.0",
"payload": "3.33.0",
Expand All @@ -43,8 +44,7 @@
"pnpm": "^9 || ^10"
},
"pnpm": {
"onlyBuiltDependencies": [
"sharp"
]
"patchedDependencies": {
}
}
}
69 changes: 67 additions & 2 deletions packages/mdxe/bin/mdxe.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,32 @@ const runNextCommand = async (command, args = []) => {
const readmePath = resolve(userCwd, 'README.md')
const hasReadme = existsSync(readmePath)

const userAppDir = resolve(userCwd, 'app')
const userPagesDir = resolve(userCwd, 'pages')
const hasNextDirs = existsSync(userAppDir) || existsSync(userPagesDir)

if ((command === 'build' || command === 'start') && !hasNextDirs) {
console.log('No app or pages directory found. Creating minimal app directory structure...')

if (!existsSync(userAppDir)) {
await import('fs/promises').then(fs => fs.mkdir(userAppDir, { recursive: true }))

const pageContent = `export default function Page() {
return <div>Welcome to your MDX app!</div>
}`
await import('fs/promises').then(fs => fs.writeFile(resolve(userAppDir, 'page.js'), pageContent))

const layoutContent = `export default function RootLayout({ children }) {
return (
<html lang="en">
<body>{children}</body>
</html>
)
}`
await import('fs/promises').then(fs => fs.writeFile(resolve(userAppDir, 'layout.js'), layoutContent))
}
}

const localNextBin = resolve(userCwd, 'node_modules', '.bin', 'next')
const mdxeNextBin = resolve(mdxeRoot, 'node_modules', '.bin', 'next')

Expand All @@ -70,6 +96,8 @@ const runNextCommand = async (command, args = []) => {
console.log(`Running Next.js command: ${cmd} ${cmdArgs.join(' ')}`)

const isVercelDeployment = process.env.VERCEL === '1'
const cmdCwd = hasNextDirs ? userCwd : embeddedAppPath
console.log(`Using directory: ${cmdCwd}`)

let nextDistDir = resolve(userCwd, '.next')

Expand All @@ -78,11 +106,10 @@ const runNextCommand = async (command, args = []) => {
// Always use userCwd (the actual project root) instead of process.cwd()
nextDistDir = resolve(userCwd, '.next')
}

activeProcess = spawn(cmd, cmdArgs, {
stdio: 'inherit',
shell: true,
cwd: embeddedAppPath,
cwd: cmdCwd,
env: {
...process.env,
PAYLOAD_DB_PATH: resolve(userCwd, 'mdx.db'),
Expand All @@ -91,6 +118,44 @@ const runNextCommand = async (command, args = []) => {
README_PATH: hasReadme ? readmePath : ''
}
})

if (command === 'build') {
activeProcess.on('exit', async (code) => {
if (code === 0) {
console.log('Build completed successfully. Copying .next folder to user directory...')

const mdxeNextDir = resolve(cmdCwd, '.next')
const userNextDir = resolve(userCwd, '.next')

if (existsSync(mdxeNextDir) && cmdCwd !== userCwd) {
try {
await import('fs/promises').then(fs => fs.mkdir(userNextDir, { recursive: true }))

const copyDir = async (src, dest) => {
const entries = await import('fs/promises').then(fs => fs.readdir(src, { withFileTypes: true }))

for (const entry of entries) {
const srcPath = resolve(src, entry.name)
const destPath = resolve(dest, entry.name)

if (entry.isDirectory()) {
await import('fs/promises').then(fs => fs.mkdir(destPath, { recursive: true }))
await copyDir(srcPath, destPath)
} else {
await import('fs/promises').then(fs => fs.copyFile(srcPath, destPath))
}
}
}

await copyDir(mdxeNextDir, userNextDir)
console.log('Successfully copied .next folder to user directory.')
} catch (error) {
console.error(`Error copying .next folder: ${error.message}`)
}
}
}
})
}

activeProcess.on('error', (error) => {
console.error(`Error executing command: ${error.message}`)
Expand Down
1 change: 1 addition & 0 deletions packages/mdxe/src/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"**/*.ts",
"**/*.tsx",
".next/types/**/*.ts",
"../examples/minimal/.next/types/**/*.ts",
"next-env.d.ts"
],
"exclude": [
Expand Down
Loading
Loading