Skip to content

Commit eaefa79

Browse files
docs: add name field mention to migration page (#10823)
### Description A user mentioned that this page didn't make mention of how you need a `main` field in package.json ### Testing Instructions 👀 --------- Co-authored-by: Cursor Agent <[email protected]>
1 parent d72f94f commit eaefa79

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

docs/site/content/docs/crafting-your-repository/creating-an-internal-package.mdx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,11 @@ You'll need a directory to put the package in. Let's create one at `./packages/m
4242
<Step>
4343
### Add a package.json
4444

45-
Next, create the `package.json` for the package. By adding this file, you'll fulfill [the two requirements for an Internal Package](/docs/crafting-your-repository/structuring-a-repository#specifying-packages-in-a-monorepo), making it discoverable to Turborepo and the rest of your Workspace:
45+
Next, create the `package.json` for the package. By adding this file, you'll fulfill [the two requirements for an Internal Package](/docs/crafting-your-repository/structuring-a-repository#specifying-packages-in-a-monorepo), making it discoverable to Turborepo and the rest of your Workspace.
46+
47+
<Callout type="warn">
48+
The `name` field in your `package.json` determines how your package can be imported throughout your workspace. The name you choose here (e.g. `@repo/math`) is exactly how other packages will import it (e.g. `import { add } from '@repo/math/add'`).
49+
</Callout>
4650

4751
<PackageManagerTabs>
4852

@@ -159,9 +163,10 @@ Next, create the `package.json` for the package. By adding this file, you'll ful
159163

160164
Let's break down this `package.json` piece-by-piece:
161165

166+
- **`name`**: This is the most critical field for package discoverability. The value `@repo/math` becomes the exact identifier used in import statements throughout your workspace. If you change this name, you must update all import statements accordingly.
162167
- **`scripts`**: The `dev` and `build` script compile the package using [the TypeScript compiler](https://www.typescriptlang.org/docs/handbook/compiler-options.html). The `dev` script will watch for changes to source code and automatically recompile the package.
163168
- **`devDependencies`**: `typescript` and `@repo/typescript-config` are `devDependencies` so you can use those packages in the `@repo/math` package. In a real-world package, you will likely have more `devDependencies` and `dependencies` - but we can keep it simple for now.
164-
- **`exports`**: Defines multiple entrypoints for the package so it can be used in other packages (`import { add } from '@repo/math'`).
169+
- **`exports`**: Defines multiple entrypoints for the package so it can be used in other packages (`import { add } from '@repo/math/add'`).
165170

166171
Notably, this `package.json` declares an Internal Package, `@repo/typescript-config`, as a dependency. Turborepo will recognize `@repo/math` as a dependent of `@repo/typescript-config` for ordering your tasks.
167172

0 commit comments

Comments
 (0)