Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WEB-995] Support tsconfig nodenext #4807

Closed
padmaia opened this issue May 3, 2023 · 10 comments
Closed

[WEB-995] Support tsconfig nodenext #4807

padmaia opened this issue May 3, 2023 · 10 comments

Comments

@padmaia
Copy link
Member

padmaia commented May 3, 2023

From SyncLinear.com | WEB-995

PACK-3031

@wojtekmaj
Copy link

wojtekmaj commented Apr 4, 2024

It looks like we're nearing Turbo release with 99.7% tests passing, and yet, Turbo is STILL unable to resolve any modules with extensions. I'm getting hundreds and hundreds of errors like:


./packages/site-structure/index.ts:1:0
Module not found: Can't resolve './src/siteStructure.js'
> 1 | import { getSiteStructure } from './src/siteStructure.js';
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  2 |
  3 | import type {
  4 |   IPageEntryCollectionPartial,

https://nextjs.org/docs/messages/module-not-found

This is easily resolved with a hack on Webpack's side:

  webpack: (config) => {
    config.resolve.extensionAlias = {
      '.js': ['.js', '.ts', '.tsx'],
    };
    return config;
  },

which is also ridiculous, but at least it works.

@Jack-Works
Copy link

this blocks me trying --turbo in nextjs. we use this feature a lot

@AlessioGr
Copy link

AlessioGr commented May 29, 2024

Would be great if this could be added soon! Can't wait to cut my compile times in half.

At payload we LOVE supporting the latest and greatest next features. And while turbo works, the lack of nodenext support prevents us from running our test suites against turbo, thus we cannot guarantee turbo will work smoothly.

We are using moduleResolution: NodeNext across our entire monorepo, as well as fully-specified imports (that way we can ensure that our packages work outside of bundlers as well). Turbo just errors when it encounters those.

@wojtekmaj
Copy link

*Sigh* fine, I'll bite.

Introducing next-turbopack-nodenext - a package that patches your Next.js config so that Turbopack could resolve fully specified .js extensions leading to TypeScript files in your src directory.

/~https://github.com/wojtekmaj/next-turbopack-nodenext

  • Install by executing npm install next-turbopack-nodenext or yarn add next-turbopack-nodenext --dev.
  • Import by adding import withNodeNext from 'next-turbopack-nodenext'.
  • Use it by wrapping your config export default withNodeNext(nextConfig).

@macrozone
Copy link

Sigh fine, I'll bite.

Introducing next-turbopack-nodenext - a package that patches your Next.js config so that Turbopack could resolve fully specified .js extensions leading to TypeScript files in your src directory.

/~https://github.com/wojtekmaj/next-turbopack-nodenext

  • Install by executing npm install next-turbopack-nodenext or yarn add next-turbopack-nodenext --dev.
  • Import by adding import withNodeNext from 'next-turbopack-nodenext'.
  • Use it by wrapping your config export default withNodeNext(nextConfig).

thanks for the effort!
however I cannot make it run, is there something in need to add to the next-config (Besides wrapping it with withNodeNext)

i added

experimental: {
extensionAlias: [".js"],
},

but it did not fix the issue

@wojtekmaj
Copy link

@macrozone Not even that should be necessary, unless you're unhappy with the default order the plugin looks for files. If you provide a minimum reproduction I'll be happy to look into this. Also, when you have it, please rather raise an issue against my repo, we don't want to clutter this thread any more than necessary.

@macrozone
Copy link

@macrozone Not even that should be necessary, unless you're unhappy with the default order the plugin looks for files. If you provide a minimum reproduction I'll be happy to look into this. Also, when you have it, please rather raise an issue against my repo, we don't want to clutter this thread any more than necessary.

fair point. So far i settled with not using turbo pack in nextjs, until this is officially supported with ESM.

@timneutkens
Copy link
Member

timneutkens commented Oct 21, 2024

This PR landed a while back for Turbopack. Will ask Niklas to take a look at the reproduction repo as well.

@mischnic
Copy link
Contributor

This should be working now with Next.js 15 (or 15.0.1 for mjs/cjs imports).

@chris-olszewski
Copy link
Member

Closing as Turbopack as moved homes

@chris-olszewski chris-olszewski closed this as not planned Won't fix, can't repro, duplicate, stale Nov 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants