Unverified Commit 589f4684 authored by Tim Neutkens's avatar Tim Neutkens Committed by GitHub

Docs: Mention npm link with Turbopack root (#86075)

## What?

Mention `npm link` case for the Turbopack root for when the package is
outside of the project directory.

Based on feedback here:
https://x.com/stevenaharrison/status/1988781488738070962.

---------
Co-authored-by: 's avatarJoseph <joseph.chamochumbi@vercel.com>
parent 67ec3ad9
...@@ -98,6 +98,8 @@ If you have a loader that is critically dependent upon one of these features ple ...@@ -98,6 +98,8 @@ If you have a loader that is critically dependent upon one of these features ple
Turbopack uses the root directory to resolve modules. Files outside of the project root are not resolved. Turbopack uses the root directory to resolve modules. Files outside of the project root are not resolved.
The reason files are not resolved outside of the project root is to improve cache validation, reduce filesystem watching overhead, and reduce the number of resolving steps needed.
Next.js automatically detects the root directory of your project. It does so by looking for one of these files: Next.js automatically detects the root directory of your project. It does so by looking for one of these files:
- `pnpm-lock.yaml` - `pnpm-lock.yaml`
...@@ -117,6 +119,10 @@ module.exports = { ...@@ -117,6 +119,10 @@ module.exports = {
} }
``` ```
To resolve files from linked dependencies outside the project root (via `npm link`, `yarn link`, `pnpm link`, etc.), you must configure the `turbopack.root` to the parent directory of both the project and the linked dependencies.
While this expands the scope of filesystem watching, it's typically only necessary during development when actively working on linked packages.
### Configuring webpack loaders ### Configuring webpack loaders
If you need loader support beyond what's built in, many webpack loaders already work with Turbopack. There are currently some limitations: If you need loader support beyond what's built in, many webpack loaders already work with Turbopack. There are currently some limitations:
......
...@@ -110,6 +110,14 @@ Turbopack in Next.js has **zero-configuration** for the common use cases. Below ...@@ -110,6 +110,14 @@ Turbopack in Next.js has **zero-configuration** for the common use cases. Below
There are a number of non-trivial behavior differences between webpack and Turbopack that are important to be aware of when migrating an application. Generally, these are less of a concern for new applications. There are a number of non-trivial behavior differences between webpack and Turbopack that are important to be aware of when migrating an application. Generally, these are less of a concern for new applications.
### Filesystem Root
Turbopack uses the root directory to resolve modules. Files outside of the project root are not resolved.
For example, when linking dependencies outside the project root (via `npm link`, `yarn link`, `pnpm link`, etc.), those linked files will not be resolved by default. To resolve these files, you must configure the root option to the parent directory of both the project and the linked dependencies.
You can configure the filesystem root using [turbopack.root](/docs/app/api-reference/config/next-config-js/turbopack#root-directory) option in `next.config.js`.
### CSS Module Ordering ### CSS Module Ordering
Turbopack will follow JS import order to order [CSS modules](/docs/app/getting-started/css#css-modules) which are not otherwise ordered. For example: Turbopack will follow JS import order to order [CSS modules](/docs/app/getting-started/css#css-modules) which are not otherwise ordered. For example:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment