Skip to content

[moduleResolution bundler] List restrictions from initial PR in documentation #2976

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

Merged
merged 1 commit into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/documentation/scripts/types/AllFilenames.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ export type AllDocsPages =
| "modules-reference/Reference.md"
| "modules-reference/Theory.md"
| "modules-reference/appendices/ESM-CJS-Interop.md"
| "modules-reference/diagrams/README"
| "modules-reference/diagrams/declaration-files.svg"
| "modules-reference/diagrams/esm-cjs-interop.md"
| "modules-reference/diagrams/esm-cjs-interop.mmd-1.svg"
| "modules-reference/diagrams/esm-cjs-interop.mmd-2.svg"
| "modules-reference/diagrams/README"
| "modules-reference/diagrams/theory.md"
| "modules-reference/diagrams/theory.md-1.svg"
| "modules-reference/diagrams/theory.md-2.svg"
Expand Down Expand Up @@ -124,8 +124,8 @@ export type AllDocsPages =
| "release-notes/TypeScript 5.0.md"
| "release-notes/TypeScript 5.1.md"
| "release-notes/TypeScript 5.2.md"
| "tutorials/Angular.md"
| "tutorials/ASP.NET Core.md"
| "tutorials/Angular.md"
| "tutorials/Babel with TypeScript.md"
| "tutorials/DOM Manipulation.md"
| "tutorials/Gulp.md"
Expand Down
74 changes: 37 additions & 37 deletions packages/ts-twoslasher/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,43 @@ Turns to:
> }
> ```

#### `import_files.ts`

```ts
// @filename: file-with-export.ts
export const helloWorld = "Example string"

// @filename: index.ts
import { helloWorld } from "./file-with-export"
console.log(helloWorld)
```

Turns to:

> ```ts
> // @filename: file-with-export.ts
> export const helloWorld = "Example string"
>
> // @filename: index.ts
> import { helloWorld } from "./file-with-export"
> console.log(helloWorld)
> ```

> With:

> ```json
> {
> "code": "See above",
> "extension": "ts",
> "highlights": [],
> "queries": [],
> "staticQuickInfos": "[ 5 items ]",
> "errors": [],
> "playgroundURL": "https://www.typescriptlang.org/play/#code/PTAEAEDMEsBsFMB2BDAtvAXKGCC0B3aAFwAtd4APABwHsAnIgOiIGcAoS2h0AYxsRZFQJeLFg0A6vVgATUAF5QAIgCiFNFQShBdaIgDmSgNxs2ICDiRpMoPTMrN20VFyEBvEWMnSZAX2x0NKjKjMCWBMRknPRESmx8AjQIjOL6ABSe4lJ0sgCUbEA",
> "tags": []
> }
> ```

#### `importsModules.ts`

```ts
Expand Down Expand Up @@ -636,43 +673,6 @@ Turns to:
> }
> ```

#### `import_files.ts`

```ts
// @filename: file-with-export.ts
export const helloWorld = "Example string"

// @filename: index.ts
import { helloWorld } from "./file-with-export"
console.log(helloWorld)
```

Turns to:

> ```ts
> // @filename: file-with-export.ts
> export const helloWorld = "Example string"
>
> // @filename: index.ts
> import { helloWorld } from "./file-with-export"
> console.log(helloWorld)
> ```

> With:

> ```json
> {
> "code": "See above",
> "extension": "ts",
> "highlights": [],
> "queries": [],
> "staticQuickInfos": "[ 5 items ]",
> "errors": [],
> "playgroundURL": "https://www.typescriptlang.org/play/#code/PTAEAEDMEsBsFMB2BDAtvAXKGCC0B3aAFwAtd4APABwHsAnIgOiIGcAoS2h0AYxsRZFQJeLFg0A6vVgATUAF5QAIgCiFNFQShBdaIgDmSgNxs2ICDiRpMoPTMrN20VFyEBvEWMnSZAX2x0NKjKjMCWBMRknPRESmx8AjQIjOL6ABSe4lJ0sgCUbEA",
> "tags": []
> }
> ```

#### `multiFileErrors.ts`

```ts
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ Specify the module resolution strategy:
- `'node16'` or `'nodenext'` for modern versions of Node.js. Node.js v12 and later supports both ECMAScript imports and CommonJS `require`, which resolve using different algorithms. These `moduleResolution` values, when combined with the corresponding [`module`](#module) values, picks the right algorithm for each resolution based on whether Node.js will see an `import` or `require` in the output JavaScript code.
- `'node10'` (previously called `'node'`) for Node.js versions older than v10, which only support CommonJS `require`. You probably won't need to use `node10` in modern code.
- `'bundler'` for use with bundlers. Like `node16` and `nodenext`, this mode supports package.json `"imports"` and `"exports"`, but unlike the Node.js resolution modes, `bundler` never requires file extensions on relative paths in imports.

`bundler` does not support resolution of `require` calls. In TypeScript files, this means the `import mod = require("foo")` syntax is forbidden; in JavaScript files, `require` calls are not errors but only ever return the type `any` (or whatever an ambient declaration of a global require function is declared to `return`).

- `'classic'` was used in TypeScript before the release of 1.6. `classic` should not be used.

There is a handbook reference page on [Module Resolution](/docs/handbook/module-resolution.html)