-
Notifications
You must be signed in to change notification settings - Fork 28.9k
Description
Link to the code that reproduces this issue
https://shadcn-studio-internal-staging.vercel.app/blocks
To Reproduce
- Create a Next.js 15 app using App Router.
- Add some
.tsx
files insrc/registry/new-york/blocks/
. - In a route like
src/app/(blocks-inner-pages)/blocks/[category]/[section]/page.tsx
, call a function from thesrc/lib/registry.ts
file that callsfs.readFile(...)
pointing to the files mentioned in the second step. - Add
outputFileTracingIncludes
targeting that route innext.config.ts
like the following:
import path from 'path'
import type { NextConfig } from 'next'
const nextConfig: NextConfig = {
outputFileTracingIncludes: {
'./src/app/(blocks-inner-pages)/blocks/[category]/[section]/page.tsx': [
'./src/registry/new-york/blocks/**/*.tsx',
'./src/lib/registry.ts',
'./src/registry/registry-blocks.ts'
]
}
- Run
next build
and observe that files are not present in.next
.
Current vs. Expected behavior
Problem
Despite using outputFileTracingIncludes
correctly to include files used via dynamic fs.readFile()
calls in a server component route, the files are not being traced, copied, or included in the .next
build output - either locally or on Vercel.
Details
- I'm dynamically reading
.tsx
files at runtime using:
fs.readFile(path.join(process.cwd(), file.path), 'utf-8')
-
The files are stored in:
src/registry/new-york/blocks/**/*.tsx
-
The code that calls
fs.readFile
lives inside thesrc/lib/registry.ts
file and the function is being called from the following:
src/app/(blocks-inner-pages)/blocks/[category]/[section]/page.tsx
-
My
next.config.ts
includes:
import type { NextConfig } from 'next'
const nextConfig: NextConfig = {
outputFileTracingIncludes: {
'./src/app/(blocks-inner-pages)/blocks/[category]/[section]/page.tsx': ['./src/registry/new-york/blocks/**/*.tsx', './src/lib/registry.ts', './src/registry/registry-blocks.ts']
}
}
Actual Behavior
-
After running
next build
, no files fromregistry/new-york/blocks
appear in.next/
output. -
Confirmed with:
find .next -type f | grep new-york/blocks
-
This also causes
fs.readFile
to fail in the deployed app on Vercel because the files are missing.
Expected Behavior
All files in src/registry/new-york/blocks
should be included in the .next
build output and deployed to Vercel so they are available for runtime access via fs.readFile()
.
Provide environment information
Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 24.2.0: Fri Dec 6 18:40:14 PST 2024; root:xnu-11215.61.5~2/RELEASE_ARM64_T8103
Available memory (MB): 8192
Available CPU cores: 8
Binaries:
Node: 22.12.0
npm: 10.9.0
Yarn: 1.22.19
pnpm: 10.6.2
Relevant Packages:
next: 15.3.2 // There is a newer version (15.3.3) available, upgrade recommended!
eslint-config-next: 15.3.2
react: 19.1.0
react-dom: 19.1.0
typescript: 5.5.4
Next.js Config:
output: N/A
Which area(s) are affected? (Select all that apply)
Runtime
Which stage(s) are affected? (Select all that apply)
next build (local), Vercel (Deployed)
Additional context
No response