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

Add @next/vendored #64938

Draft
wants to merge 16 commits into
base: canary
Choose a base branch
from
Draft

Add @next/vendored #64938

wants to merge 16 commits into from

Conversation

lfades
Copy link
Member

@lfades lfades commented Apr 23, 2024

This PR aims to replace the use of next/dist/compiled/* with @next/vendored/*.

Motivation

  • Remove next/src/compiled from source. Currently Next.js clones its contents into next/dist/compiled but we can run the tasks that generate the modules fast enough with caching.
  • The imports to next/dist/compiled/* will now to go @next/vendored/*, a separate package that has all the third party modules that were compiled by ncc. This allows Next.js to have exports inside package.json in a future update, which is currently highly difficult due to it having inner node packages (i.e nested modules that are resolved after reading a package.json).
  • Move all of the related ncc tasks and compiled code out of the next repo.

Status

Some things that have been done so far:

  • A custom task runner is being used instead of taskr. The reason is taskr doesn't work very well with ESM (The @taskr/esnext package is a hack and it's still commonjs), because of this resolving a package always sends its commonjs distribution to ncc. There are also some differences in how the tasks are declared, particularly I wanted to have a way to generate multiple tasks with a loop for the most common cases.
  • The custom task runner is quite simple and it can also be made into its own package.

Todo

Testing locally

After running pnpm install, build @next/vendored with:

cd packages/next-vendored && pnpm dev

and then run the ncc tasks in @next/vendored:

pnpm task-runner ncc

Run pnpm dev at the root and the Next.js build should work. I'm testing it locally in an app from create-next-app and with pnpm next-with-deps

@eps1lon
Copy link
Member

eps1lon commented Apr 23, 2024

FYI we've replaced taskr is being replaced with using Turborepo: #64825

@lfades
Copy link
Member Author

lfades commented Apr 23, 2024

FYI we've replaced taskr is being replaced with using Turborepo: #64825

Thanks for sharing it. taskr is still being used there but it's being cached by Turborepo. I'll add that to this PR.

Note that I replaced taskr to resolve modules for ncc in a ESM environment. It's also a considerably old library that hasn't received an update in the last 7 years.

@ijjk ijjk added Font (next/font) Related to Next.js Font Optimization. tests labels May 1, 2024
@ijjk ijjk added the Turbopack Related to Turbopack with Next.js. label May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Font (next/font) Related to Next.js Font Optimization. tests Turbopack Related to Turbopack with Next.js. type: next
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants