Skip to content
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

Add ambient-loader proposal #63

Merged
merged 6 commits into from
Mar 27, 2022
Merged
Changes from 1 commit
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
22 changes: 20 additions & 2 deletions doc/design/proposal-ambient-loaders.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,30 @@ If loaders cannot generally influence each other, we could have a subset of them

- Regular loaders would be defined via the `--loader <module>` flag. They would be loaded in parallel (at least conceptually). Because they’d only be loaded after the ambient loaders have finished evaluating, their resolution would be affected by ambient loaders.

## Example
## Simple Example

Let's imagine we have the following loaders:

- ts, which adds support for TS files
- my-custom-loader, which is written in TypeScript

Without the TS loader, we wouldn't be able to even load the following custom loader. But by marking it as an ambiant loader, Node will make sure it'll be taken into account when resolving (and loading) my-custom-loader.


The command line would end up like this:

```
node --ambient-loader ts
--loader my-custom-loader
./path/to/script.mjs
```
arcanis marked this conversation as resolved.
Show resolved Hide resolved

## More Contrived Example

Let’s imagine we have the following loaders:

- zip, which adds zip file support to the `fs` module
- pnp, which adds support for the Plug’n’Play resolution
- pnp, which adds support for the Plug’n’Play resolution ([more details](https://yarnpkg.com/features/pnp))
- yaml, which adds yaml file support to `import`
- coffeescript, which adds coffeescript file support to `import`

Expand Down