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

docs(Turborepo): package entry points customization #7903

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -238,3 +238,32 @@ This pattern is extremely powerful for creating pieces of code that can be easil

1. Ensure that you're [importing it correctly](/repo/docs/handbook/sharing-code/internal-packages#3-import-the-package)
2. Ensure that you've [configured your app to transpile it](/repo/docs/handbook/sharing-code/internal-packages#6-configuring-your-app)

#### Package entry points

In the case we want to customize the package entry points like this for instance.

```diff
+ import { add } from "math-helpers/add";

+ add(1, 2);
```

Go back to `packages/math-helpers/package.json` and modify field: `exports`:

```json filename="packages/math-helpers/package.json"
{
"name": "math-helpers",
"exports": {
"./add": "./src/add.ts"
},
"dependencies": {
"typescript": "latest"
}
}
```

Notice the difference than the previous where the `./add` in the `exports` key is mentioned now to export it to the subpath that we want.

More readings about [package entry points](https://nodejs.org/api/packages.html#package-entry-points) can be explored.