turbo icon indicating copy to clipboard operation
turbo copied to clipboard

Documentation: transpiling step seems not necessary with the pre-installed Next.js application

Open atharvadeosthale opened this issue 2 years ago • 1 comments

Verify canary release

  • [x] I verified that the issue exists in the latest Turborepo canary release.

Link to code that reproduces this issue

https://github.com/atharva-youtube/turborepo-tutorial

What package manager are you using / does the bug impact?

pnpm

What operating system are you using?

Mac

Which canary version will you have in your reproduction?

turbo 1.11.4-canary.1

Describe the Bug

The documentation mentions here that the package needs to be added under transpilePackages under next.config.js file. However, while filming the tutorial, when I tried to demonstrate the error without adding the package to transpilePackages, everything worked just fine.

It seems that the documentation targetted an older version of Next.js, and the newer Next.js version does the transpiling automatically (an assumption). I would love to know if I need to do something differently or if this is a problem. I would love to fix the documentation if an issue is assigned to me.

Expected Behavior

That part of the documentation should be removed.

To Reproduce

Clone the repository, install the packages using pnpm install, run pnpm dev and see the code working on http://localhost:3000. I have not added the shared-utils in transpilePackages under apps/web/next.config.js, but I'm still able to use it to add a button that performs addition using add() in the shared-utils package.

Additional context

No response

TURBO-2131

atharvadeosthale avatar Jan 21 '24 23:01 atharvadeosthale

Interesting. I'll check with the Next.js team to see if this is known/unexpected behavior.

anthonyshew avatar Jan 22 '24 14:01 anthonyshew

Sorry for being "that" guy who asks for update. It's been a while. Would love to contribute if the behaviour is not expected.

atharvadeosthale avatar Mar 04 '24 15:03 atharvadeosthale

Apologies! I forgot to come back. 😄

We do need to keep it as this is unexpected behavior in Next.js (for now, as this is likely to be implemented in the future). Let's leave this here so that if the Next.js team decides to do a bug fix, we won't need to chase that.

Thank you for reporting this!

anthonyshew avatar Mar 05 '24 22:03 anthonyshew

I just got an update on why those differences are being seen:

  • The App Router bundles everything it needs, without the need for transpilePackages.
  • The Pages Router only bundles what it sees in transpilePackages.

Additionally, there will be updates to this behavior in the near future.

anthonyshew avatar May 09 '24 18:05 anthonyshew