diff --git a/docs/repo-docs/core-concepts/internal-packages.mdx b/docs/repo-docs/core-concepts/internal-packages.mdx
index 5c806ef708559..1387bf104cd6e 100644
--- a/docs/repo-docs/core-concepts/internal-packages.mdx
+++ b/docs/repo-docs/core-concepts/internal-packages.mdx
@@ -95,7 +95,7 @@ There are a few important things to notice in this `package.json`:
#### Limitations and tradeoffs
- **Only applicable when consumers do transpiling**: This strategy can only be used when the package is going to be used in tooling that uses a bundler or natively understands TypeScript. The consumer's bundler is responsible for transpiling the TypeScript packages to JavaScript. If your builds or other usages of the package are not able to consume TypeScript, you will need to move to the [Compiled Packages](#compiled-packages) strategy.
-- **No TypeScript `paths`**: A library that is being transpiled by its consumer cannot use the `compilerOptions.paths` configuration because TypeScript assumes that source code is being transpiled in the package where it is written. If you're using Typescript 5.4 or later, we recommend [using Node.js subpath imports](https://devblogs.microsoft.com/typescript/announcing-typescript-5-4/#auto-import-support-for-subpath-imports).
+- **No TypeScript `paths`**: A library that is being transpiled by its consumer cannot use the `compilerOptions.paths` configuration because TypeScript assumes that source code is being transpiled in the package where it is written. If you're using Typescript 5.4 or later, we recommend [using Node.js subpath imports](https://devblogs.microsoft.com/typescript/announcing-typescript-5-4/#auto-import-support-for-subpath-imports). To learn how, visit [our TypeScript page](/repo/docs/guides/tools/typescript#use-nodejs-subpath-imports-instead-of-typescript-compiler-paths).
- **Turborepo cannot cache a build for a Just-in-Time Package**: Because the package doesn't have its own `build` step, it can't be cached by Turborepo. This tradeoff may make sense for you if you want to keep configuration to a minimum and are okay with the build times for your applications.
### Compiled Packages
diff --git a/docs/repo-docs/crafting-your-repository/structuring-a-repository.mdx b/docs/repo-docs/crafting-your-repository/structuring-a-repository.mdx
index 2a6e4cd55f49f..798b4f3ed2fd6 100644
--- a/docs/repo-docs/crafting-your-repository/structuring-a-repository.mdx
+++ b/docs/repo-docs/crafting-your-repository/structuring-a-repository.mdx
@@ -315,40 +315,7 @@ Using exports this way provides three major benefits:
#### `imports` (optional)
-[The `imports` field](https://nodejs.org/api/packages.html#imports) gives you a way to create subpaths to other modules within your package. You can think of these like "shortcuts" to get to other modules within your package.
-
-
-
-```json title="./packages/ui/package.json"
-{
- "imports": {
- "#*": "./*"
- }
-}
-```
-
-
-```ts title="./packages/math/src/add.ts"
- export const add = (a: number, b: number) => a + b;
-```
-
-
-
-```ts title="./packages/math/src/multiply.ts"
-import { add } from "#add";
-
-export const multiply = (a: number, b: number) => {
- let result = 0;
- for (let i = 0; i < b; i++) {
- result = add(result, a);
- }
- return result;
-}
-```
-
-
-
-This can be useful for concisely importing other modules within the package and can make refactors easier to manage.
+[The `imports` field](https://nodejs.org/api/packages.html#imports) gives you a way to create subpaths to other modules within your package. You can think of these like "shortcuts" to write simpler import paths that are more resilient to refactors that move files. To learn how, visit [the TypeScript page](/repo/docs/guides/tools/typescript#use-nodejs-subpath-imports-instead-of-typescript-compiler-paths).
You may be more familiar with TypeScript's `compilerOptions#paths` option, which accomplishes a similar goal. As of Typescript 5.4, TypeScript can infer subpaths from `imports`, making it a better option since you'll be working with Node.js conventions. For more information, visit [our Typescript guide](/repo/docs/guides/tools/typescript#use-nodejs-subpath-imports-instead-of-typescript-compiler-paths).
diff --git a/docs/repo-docs/guides/tools/typescript.mdx b/docs/repo-docs/guides/tools/typescript.mdx
index 2aae88f6d0a2c..a7c3b4a972e1b 100644
--- a/docs/repo-docs/guides/tools/typescript.mdx
+++ b/docs/repo-docs/guides/tools/typescript.mdx
@@ -5,7 +5,7 @@ description: Learn how to use TypeScript in a monorepo.
import { Callout } from '#/components/callout';
import { File, Folder, Files } from '#/components/files';
-import { PackageManagerTabs, Tab } from '#/components/tabs';
+import { PackageManagerTabs, Tabs, Tab } from '#/components/tabs';
import { LinkToDocumentation } from '#/components/link-to-documentation';
TypeScript is an excellent tool in monorepos, allowing teams to safely add types to their JavaScript code. While there is some complexity to getting set up, this guide will walk you through the important parts of a TypeScript setup for most use cases.
@@ -221,11 +221,64 @@ For [Internal Packages](/repo/docs/core-concepts/internal-packages), we recommen
### Use Node.js subpath imports instead of TypeScript compiler `paths`
-It's possible to create absolute imports in your packages using [the TypeScript compiler's `paths` option](https://www.typescriptlang.org/tsconfig#paths). However, [as of TypeScript 5.4](https://devblogs.microsoft.com/typescript/announcing-typescript-5-4/#auto-import-support-for-subpath-imports), you can use [Node.js subpath imports](https://nodejs.org/api/packages.html#imports) instead.
+It's possible to create absolute imports in your packages using [the TypeScript compiler's `paths` option](https://www.typescriptlang.org/tsconfig#paths), but these paths can cause failed compilation when using [Just-in-Time Packages](https://turbo.build/repo/docs/core-concepts/internal-packages#just-in-time-packages). [As of TypeScript 5.4](https://devblogs.microsoft.com/typescript/announcing-typescript-5-4/#auto-import-support-for-subpath-imports), you can use [Node.js subpath imports](https://nodejs.org/api/packages.html#imports) instead for a more robust solution.
-Additionally, Node.js subpath imports are usable in [Just-in-Time Packages](/repo/docs/core-concepts/internal-packages#just-in-time-packages) while TypeScript's `compilerOptions#paths` are not.
+#### Just-in-Time packages
-This strategy brings your Node.js and TypeScript configurations closer together, making your project's configuration simpler.
+In [Just-in-Time packages](https://turbo.build/repo/docs/core-concepts/internal-packages#just-in-time-packages), `imports` must target the source code in the package, since build outputs like `dist` won't be created.
+
+
+
+```json title="./packages/ui/package.json"
+{
+ "imports": {
+ "#*": "./src/*"
+ }
+}
+```
+
+
+```tsx title="./packages/ui/button.tsx"
+import { MY_STRING } from "#utils.ts" // Uses .ts extension // [!code highlight]
+
+export const Button = () => {
+ return (
+
+ )
+}
+```
+
+
+
+
+#### Compiled packages
+
+In [Compiled packages](https://turbo.build/repo/docs/core-concepts/internal-packages#compiled-packages), `imports` target the built ouptuts for the package.
+
+
+
+```json title="./packages/ui/package.json"
+{
+ "imports": {
+ "#*": "./dist/*"
+ }
+}
+```
+
+
+
+```tsx title="./packages/ui/button.tsx"
+import { MY_STRING } from "#utils.js" // Uses .js extension // [!code highlight]
+
+export const Button = () => {
+ return (
+
+ )
+}
+```
+
+
+
### You likely don't need a `tsconfig.json` file in the root of your project