Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.

Add module resolution documentation - #181

Merged
Mohamed Hegazy (mhegazy) merged 26 commits into
masterfrom
moduleResolution
Mar 22, 2016
Merged

Mohamed Hegazy (mhegazy) merged 26 commits into
masterfrom
moduleResolution

Conversation

@mhegazy

Copy link
Copy Markdown
Contributor

Add documentation for module resolution.

Comment thread pages/Module Resolution.md Outdated
{
"compilerOptions": {
"paths": {
"jquery": ["node_modules\jquery\dist\jquery.slim.min.js"]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

escape backslashes in json

Comment thread pages/Module Resolution.md Outdated

### Node

This resolution strategy attempts to *mimic* the [nodejs](https://nodejs.org/) module resolution mechanism at runtime.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on the node module documentation, the prose spelling of Node is "Node.js" not nodejs. I think it's easier to read in the middle of a sentence anyway.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done,

Comment thread pages/Module Resolution.md Outdated
A non-relative import can be resolved relative to `baseUrl`, or through path mapping, which we'll cover below.
They can also resolve to ambient module declarations.
They can also resolve to [ambient module declarations](./Modules.md#ambient-modules).
Use non-relative paths when importing any of your external dependnecies.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: dependencies

@sandersn

Copy link
Copy Markdown
Member

👍

@mhegazy

Copy link
Copy Markdown
Contributor Author

Comment thread pages/Module Resolution.md Outdated

To understand what the steps the TS compiler will follow, it is important to shed some light on Node.js modules.
Node.js supports multiple ways to resolve the target of a call to `require`.
A relative module name in Node.js can resolve to:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of the last two lines, I'd suggest:

Traditionally, imports in Node.js are performed as calls to a function called `require`.
Node will resolve the path given to `require` to one of three things:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should mention that it's a relative path

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

@DanielRosenwasser

Copy link
Copy Markdown
Member

I'll send out a quick PR for my suggestions

@DanielRosenwasser

Copy link
Copy Markdown
Member

I had a fix ready to go out and when the page didn't submit correctly, I lost all my work. 😱

Comment thread pages/Module Resolution.md Outdated

#### How Node.js resolves modules

To understand what the steps the TS compiler will follow, it is important to shed some light on Node.js modules.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to understand what steps (delete 'the')

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

Mohamed Hegazy (mhegazy) added a commit that referenced this pull request Mar 22, 2016
Add module resolution documentation
@mhegazy
Mohamed Hegazy (mhegazy) merged commit 532632b into master Mar 22, 2016
@mhegazy
Mohamed Hegazy (mhegazy) deleted the moduleResolution branch March 22, 2016 17:54
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants