Skip to content

Commit 6529346

Browse files
authored
New modules docs (#2946)
1 parent 9150ed6 commit 6529346

File tree

31 files changed

+2353
-1667
lines changed

31 files changed

+2353
-1667
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
title: Modules - Introduction
3+
short: Introduction
4+
layout: docs
5+
permalink: /docs/handbook/modules/introduction.html
6+
oneline: How TypeScript models JavaScript modules
7+
translatable: true
8+
---
9+
10+
This document is divided into four sections:
11+
12+
1. The first section develops the [**theory**](/docs/handbook/modules/theory.html) behind how TypeScript approaches modules. If you want to be able to write the correct module-related compiler options for any situation, reason about how to integrate TypeScript with other tools, or understand how TypeScript processes dependency packages, this is the place to start. While there are guides and reference pages on these topics, building an understanding of these fundamentals will make reading the guides easier, and give you a mental framework for dealing with real-world problems not specifically covered here.
13+
2. The [**guides**](/docs/handbook/modules/guides/choosing-compiler-options.html) show how to accomplish specific real-world tasks, starting with picking the right compilation settings for a new project. The guides are a good place to start both for beginners who want to get up and running as quickly as possible and for experts who already have a good grasp of the theory but want concrete guidance on a complicated task.
14+
3. The [**reference**](/docs/handbook/modules/reference.html) section provides a more detailed look at the syntaxes and configurations presented in previous sections.
15+
4. The [**appendices**](/docs/handbook/modules/appendices/esm-cjs-interop.html) cover complicated topics that deserve additional explanation in more detail than the theory or reference sections allow.

packages/documentation/copy/en/modules-reference/Reference.md

Lines changed: 1147 additions & 0 deletions
Large diffs are not rendered by default.

packages/documentation/copy/en/modules-reference/Theory.md

Lines changed: 367 additions & 0 deletions
Large diffs are not rendered by default.

packages/documentation/copy/en/modules-reference/appendices/ESM-CJS-Interop.md

Lines changed: 351 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Some of this content uses mermaid diagrams. We could render them as part of the website build with gatsby-remark-mermaid, but that requires puppeteer/Chromium, which has historically caused a lot of cross-platform build issues. These diagrams should not change often, so I’m just going to store the source here and generate the SVGs manually.
2+
3+
Example:
4+
5+
```sh
6+
npm install -g @mermaid-js/mermaid-cli
7+
mmdc -i packages/documentation/copy/en/modules-reference/diagrams/esm-cjs-interop.md
8+
```
9+
10+
declaration-files.svg is a non-Mermaid replacement for theory.md-4.svg. I made it for a talk one time and it’s better than what Mermaid can do with a flowchart.

packages/documentation/copy/en/modules-reference/diagrams/declaration-files.svg

Lines changed: 17 additions & 0 deletions
Loading
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
```mermaid
2+
graph TB
3+
subgraph Transpiled[ESM transpiled to CJS]
4+
direction TB
5+
C[Importing module] -- designed based on spec --> D[Imported module]
6+
end
7+
subgraph ESM
8+
direction TB
9+
A[Importing module] -- specified behavior --> B[Imported module]
10+
end
11+
```
12+
13+
```mermaid
14+
graph TD
15+
subgraph Transpiled[ESM transpiled to CJS]
16+
C[Importing module] -- designed based on spec --> D[Imported module]
17+
end
18+
subgraph CJS[True CJS]
19+
E[Imported module]
20+
end
21+
subgraph ESM
22+
A[Importing module] -- specified behavior --> B[Imported module]
23+
end
24+
A -. unspecified behavior .-> E
25+
C .->|"<span style='font-size: 3em'>❓🤷🏻‍♂️❓</span>"| E
26+
```
Lines changed: 1 addition & 0 deletions
Loading

0 commit comments

Comments
 (0)