Skip to content

Commit

Permalink
docs: intro to oxc-resolver
Browse files Browse the repository at this point in the history
  • Loading branch information
topheman committed Oct 25, 2024
1 parent 584c7c1 commit 0fb1cca
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 3 deletions.
3 changes: 3 additions & 0 deletions book.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@ edit-url-template = "https://github.com/topheman/toolchain-notes/edit/master/{pa
site-url = "/toolchain-notes/"
no-section-label = true
additional-css = ["custom.css"]

[output.html.redirect]
"/oxc-resolver/README.html" = "../oxc-resolver/index.html"
2 changes: 1 addition & 1 deletion src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

# oxc-resolver

- [oxc-resolver / Explore crate](./oxc-resolver/README.md)
- [oxc-resolver / Introduction](./oxc-resolver/README.md)

# napi

Expand Down
21 changes: 20 additions & 1 deletion src/oxc-resolver/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
# oxc-resolver / Explore crates
# oxc-resolver / Introduction

<https://github.com/oxc-project/oxc-resolver>

Rust version of [webpack/enhanced-resolve](https://github.com/webpack/enhanced-resolve).

The [tests](https://github.com/oxc-project/oxc-resolver/tree/main/src/tests) are ported from:

- [webpack/enhanced-resolve](https://github.com/webpack/enhanced-resolve/tree/main/test)
- [tsconfig-path](https://github.com/dividab/tsconfig-paths/blob/master/src/__tests__/data/match-path-data.ts) and [parcel-resolver](https://github.com/parcel-bundler/parcel/tree/v2/packages/utils/node-resolver-core/test/fixture/tsconfig) for tsconfig-paths

There is a Node.js API which allows to resolve requests according to the Node.js resolving rules ([esm](https://nodejs.org/api/esm.html#resolution-algorithm) / [cjs](https://nodejs.org/api/modules.html#all-together)).

Those resolving rules are applied, taking in account:

- module type:
- `esm`: `{ "conditionNames": ["node", "import"] }`
- `cjs`: `{ "conditionNames": ["node", "import"] }`
- `browserField`: `package.json#browser`
- `mainFields`:
- `package.json#main`
- `package.json#module`

And a lot of other things that can alter the resolution algorithm.
2 changes: 1 addition & 1 deletion src/rolldown/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ For the implementation, see [oxc-project/oxc-resolver](https://github.com/oxc-pr

This plugin relies on the traits `rolldown_fs::{FileSystem, OsFileSystem}` from [`rolldown_fs`](#rolldown_fs) which relies on `oxc_resolver::{FileMetadata, FileSystem}`.

This is the plugin in charge of resolving the paths of the imports, which is a very tricky thing in JavaScript. The resolving part is handled by the [`oxc_resolver`](https://github.com/oxc-project/oxc-resolver) crate (in order to be able to share).
This is the plugin in charge of resolving the paths of the imports, which is a very tricky thing in JavaScript. The resolving part is handled by the [`oxc_resolver`](../oxc-resolver/README.md) crate (in order to be able to share).

1. `rolldown_resolver::Resolver::new` creates an instance of the resolver
- based on
Expand Down

0 comments on commit 0fb1cca

Please sign in to comment.