optimizePackageImports' caches index.ts files (dev and build) when they resolve to source files outside node_modules. #65630
Labels
bug
Issue was opened via the bug report template.
Developer Experience
Issues related to Next.js logs, Error overlay, etc.
SWC
Related to minification/transpilation in Next.js.
Link to the code that reproduces this issue
https://github.com/threehams/next-optimize-caching
To Reproduce
Dev caching:
npm run dev
ui/index.ts
Build caching:
npm run build
ui/Button.tsx
toui/CounterButton.tsx
, and update imports inui/index.ts
npm run build
againCurrent vs. Expected behavior
Current:
Dev caching: The syntax error is not reported. The dev server caches the contents of
index.ts
file until server restart.Build caching:
The build caches the
index.ts
file permanently, and will fail until the.next
directory is deleted.Expected:
The Next.js 14.2 release notes encourage using
optimizePackageImports: ['package-name']
to optimize barrel files. When these files are outsidenode_modules
, the imports should be re-evaluated when thoseindex.ts
files have changed on disk, in both dev and production builds.Provide environment information
Operating System: Platform: darwin Arch: arm64 Version: Darwin Kernel Version 23.4.0: Fri Mar 15 00:10:42 PDT 2024; root:xnu-10063.101.17~1/RELEASE_ARM64_T6000 Available memory (MB): 32768 Available CPU cores: 10 Binaries: Node: 20.10.0 npm: 10.2.5 Yarn: 1.22.19 pnpm: 9.1.0 Relevant Packages: next: 14.2.3 // Latest available version is detected (14.2.3). eslint-config-next: 14.2.3 react: 18.3.1 react-dom: 18.3.1 typescript: 5.4.5 Next.js Config: output: N/A
Which area(s) are affected? (Select all that apply)
Developer Experience, SWC
Which stage(s) are affected? (Select all that apply)
next dev (local), next build (local)
Additional context
No response
The text was updated successfully, but these errors were encountered: