Open Izhaki opened 1 year ago
We cannot recreate the issue with the provided information. Please add a reproduction in order for us to be able to investigate.
please add a complete reproduction
label?To be able to investigate, we need access to a reproduction to identify what triggered the issue. We prefer a link to a public GitHub repository (template), but you can also use a tool like CodeSandbox or StackBlitz.
To make sure the issue is resolved as quickly as possible, please make sure that the reproduction is as minimal as possible. This means that you should remove unnecessary code, files, and dependencies that do not contribute to the issue.
Please test your reproduction against the latest version of Next.js (next@canary
) to make sure your issue has not already been fixed.
Ensure the link is pointing to a codebase that is accessible (e.g. not a private repository). "example.com", "n/a", "will add later", etc. are not acceptable links -- we need to see a public codebase. See the above section for accepted links.
Issues with the please add a complete reproduction
label that receives no meaningful activity (e.g. new comments with a reproduction link) are automatically closed and locked after 30 days.
If your issue has not been resolved in that time and it has been closed/locked, please open a new issue with the required reproduction.
Anyone experiencing the same issue is welcome to provide a minimal reproduction following the above steps. Furthermore, you can upvote the issue using the :+1: reaction on the topmost comment (please do not comment "I have the same issue" without reproduction steps). Then, we can sort issues by votes to prioritize.
We look into every Next.js issue and constantly monitor open issues for new comments.
However, sometimes we might miss one or two due to the popularity/high traffic of the repository. We apologize, and kindly ask you to refrain from tagging core maintainers, as that will usually not result in increased priority.
Upvoting issues to show your interest will help us prioritize and address them as quickly as possible. That said, every issue is important to us, and if an issue gets closed by accident, we encourage you to open a new one linking to the old issue and we will look into it.
This is very much a revival of the now closed https://github.com/vercel/next.js/issues/41961. Also related: https://github.com/vercel/next.js/discussions/32239
Various packages are now esm-only, PlanetScale's edge-supporting JS driver is one example.
However, since NextJS still uses CJS file naming for relative imports, it is impossible to run tests in NodeJS (say with Cucumber) that consume project scripts that import such esm-only libraries.
Another way to look at it is that despite NextJS's increasing ESM support (and ultimately nobody is using CJS (
require
) in app code), NextJS relative imports are still written as an ESM/CJS hybrid:With Vercel shipping bleeding-edge technology, and esm seen as the de-facto future standard, support for ESM explicit file extension pattern appears to be a looming necessity.
As discussed in https://github.com/vercel/next.js/issues/41961,
experimental/fullySpecified
is incomplete.The following diagram depicts the issue (imports must have the
.js
extension in Node, but that causes NextJS builds to break):Provide environment information
Link to the code that reproduces this issue
https://github.com/Izhaki/nodenextjs-reproduction
To Reproduce
pnpm dev
Manual reproduction
src/test.js
:src/pages/index.tsx
:Describe the Bug
App fails to build:
Expected Behavior
With the
fullySpecified
flag enabled, both webpack and swc should handle module specifiers with file extensions.Typescript: As explained in the typescript documentation for ESM support, typescript import will have to be
.js
and not.ts
:However, seeing the required webpack configuration changes in https://github.com/vercel/next.js/issues/41961, possibly a
.ts
extension will work just fine.NEXT-783