-
Notifications
You must be signed in to change notification settings - Fork 31k
import.meta.dirname + import.meta.filename undefined in page #60879
Copy link
Copy link
Open
Labels
UpstreamRelated to using Next.js with a third-party dependency. (e.g., React, UI/icon libraries, etc.).Related to using Next.js with a third-party dependency. (e.g., React, UI/icon libraries, etc.).bugIssue was opened via the bug report template.Issue was opened via the bug report template.linear: turbopackConfirmed issue that is tracked by the Turbopack team.Confirmed issue that is tracked by the Turbopack team.
Metadata
Metadata
Assignees
Labels
UpstreamRelated to using Next.js with a third-party dependency. (e.g., React, UI/icon libraries, etc.).Related to using Next.js with a third-party dependency. (e.g., React, UI/icon libraries, etc.).bugIssue was opened via the bug report template.Issue was opened via the bug report template.linear: turbopackConfirmed issue that is tracked by the Turbopack team.Confirmed issue that is tracked by the Turbopack team.
Type
Fields
Give feedbackNo fields configured for issues without a type.
Link to the code that reproduces this issue
https://codesandbox.io/p/devbox/import-meta-dirname-reproduction-vj3gfq?file=%2Fapp%2Fpage.tsx%3A1%2C1
To Reproduce
import.meta.dirnameisundefinedin the webpack-compiledpage.tsx(but is a dir path in Node.js)Changes to repro template:
"type": "module"to enable running ESM with Node.js (and changemodule.exports =toexport defaultinnext.config.js)import-meta.dirname.jswithconsole.log()ofimport.meta.dirnameconsole.log()ofimport.meta.dirnametoapp/page.tsxCurrent vs. Expected behavior
I expected
import.meta.dirnameandimport.meta.filename, introduced in Node.js 20.11.0 to not beundefinedin Next.js pages in the App Router, but it isundefinedVerify canary release
Provide environment information
Operating System: Platform: linux Arch: x64 Version: #1 SMP PREEMPT_DYNAMIC Sun Aug 6 20:05:33 UTC 2023 Binaries: Node: 20.11.0 npm: 10.2.4 Yarn: 1.22.19 pnpm: 8.14.1 Relevant Packages: next: 14.1.1-canary.1 eslint-config-next: N/A react: 18.2.0 react-dom: 18.2.0 typescript: 5.1.3 Next.js Config: output: N/AWhich area(s) are affected? (Select all that apply)
Module resolution (CJS / ESM, module resolving)
Which stage(s) are affected? (Select all that apply)
next dev (local), next build (local)
Additional context
No response
PACK-2953