Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
7ec7392
docs: update `alias` and `fallback` options type and description (#557)
JounQin Jun 14, 2025
238cd34
chore(deps): update github-actions (#558)
renovate[bot] Jun 15, 2025
5333ced
chore(deps): lock file maintenance npm packages (#560)
renovate[bot] Jun 15, 2025
02ab742
chore(deps): update dependency @types/node to v24 (#559)
renovate[bot] Jun 15, 2025
f321b7c
chore(deps): lock file maintenance (#562)
renovate[bot] Jun 15, 2025
6a92459
chore(deps): lock file maintenance rust crates (#563)
renovate[bot] Jun 15, 2025
d442282
chore(deps): update github-actions (#566)
renovate[bot] Jun 22, 2025
3c09232
chore(deps): lock file maintenance npm packages (#567)
renovate[bot] Jun 22, 2025
97a0723
chore(deps): lock file maintenance rust crates (#568)
renovate[bot] Jun 22, 2025
3cda38d
fix: avoid crash when encountering tsconfig circular extends (#570)
sapphi-red Jun 23, 2025
c6b4cca
docs: add ts config
Boshen Jun 23, 2025
644fb96
chore(cliff.toml): update changelog format
Boshen Jun 23, 2025
2d6973d
chore: release v11.2.1 (#569)
oxc-bot Jun 25, 2025
9b112b4
ci: only git tag and git release the main package
Boshen Jun 25, 2025
05d6b5d
feat(resolver): allow `exports` field in `require('../directory')` (#…
Boshen Jun 26, 2025
77ea974
chore: run `node --run test` in `just test`
Boshen Jun 26, 2025
8ca8ff8
feat(napi): add `ResolveResult::builtin` information (#575)
Boshen Jun 26, 2025
70a58c0
feat: align yarn pnp implementation (#576)
Boshen Jun 26, 2025
21fac29
ci: cancel in-progress release-plz PRs
Boshen Jun 26, 2025
83405a2
chore(cliff): set `breaking_always_bump_major = false`
Boshen Jun 26, 2025
0252b23
docs: document `allowPackageExportsInDirectoryResolve`
Boshen Jun 26, 2025
77abbd1
chore(cliff): update changelog
Boshen Jun 26, 2025
acb3d4e
ci: do not fail fast test
Boshen Jun 26, 2025
091ab70
chore: update release-plz.toml
Boshen Jun 26, 2025
78d8e12
chore: release v11.3.0 (#574)
oxc-bot Jun 26, 2025
90c5cdd
chore(deps): update dependency rust to v1.88.0 (#579)
renovate[bot] Jun 26, 2025
526e9b8
chore(deps): update github-actions (#580)
renovate[bot] Jun 29, 2025
b05d83e
chore(deps): lock file maintenance npm packages (#581)
renovate[bot] Jun 29, 2025
6fdd689
chore(deps): lock file maintenance (#583)
renovate[bot] Jun 29, 2025
d2ed69a
chore(deps): lock file maintenance rust crates (#582)
renovate[bot] Jun 30, 2025
969b07e
chore(deps): update crate-ci/typos action to v1.34.0 (#584)
renovate[bot] Jun 30, 2025
d730421
feat: bump `pnp` to 0.11.0 (#577)
Boshen Jul 1, 2025
5271786
chore: release v11.4.0 (#585)
oxc-bot Jul 2, 2025
eb50ecd
Merge remote-tracking branch 'upstream/main' into chore/merge_upstream
JounQin Jul 2, 2025
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
target/
/npm
/node_modules
/napi/node_modules
/fixtures/pnpm/node_modules
fuzz/Cargo.lock
84 changes: 16 additions & 68 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,6 @@ name = "resolver"

[dependencies]
cfg-if = "1.0"
dashmap = "7.0.0-rc2"
dunce = "1.0.5" # Normalize Windows paths to the most compatible format, avoiding UNC where possible
indexmap = { version = "2.10.0", features = ["serde"] }
json-strip-comments = "1.0.4"
once_cell = "1.21.3" # Use `std::sync::OnceLock::get_or_try_init` when it is stable.
Expand All @@ -93,7 +91,7 @@ simdutf8 = { version = "0.1.5", features = ["aarch64_neon"] }
thiserror = "2.0.12"
tracing = "0.1.41"
url = "2.5.4"
windows-sys = { version = "0.60", features = ["Win32_Foundation", "Win32_Storage_FileSystem"] }
windows-sys = { version = "0.60.2", features = ["Win32_Foundation", "Win32_Storage_FileSystem"] }

pnp = { version = "0.11.0", optional = true }

Expand Down
52 changes: 30 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,28 +189,36 @@ The following options are aligned with [enhanced-resolve], and is implemented fo

See [index.d.ts](https://github.com/unrs/unrs-resolver/blob/main/napi/index.d.ts) for Node.js usage.

| Field | Default | Description |
| ---------------- | ------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- |
| alias | {} | A hash map of module alias configurations |
| aliasFields | [] | A list of alias fields in description files |
| extensionAlias | {} | An object which maps extension to extension aliases |
| conditionNames | [] | A list of exports field condition names |
| descriptionFiles | ["package.json"] | A list of description files to read from |
| enforceExtension | false | Enforce that an extension from extensions must be used |
| exportsFields | ["exports"] | A list of exports fields in description files |
| extensions | [".js", ".json", ".node"] | A list of extensions which should be tried for files |
| fallback | {} | Same as `alias`, but only used if default resolving fails |
| fileSystem | | The file system which should be used |
| fullySpecified | false | Request passed to resolve is already fully specified and extensions or main files are not resolved for it (they are still resolved for internal requests) |
| mainFields | ["main"] | A list of main fields in description files |
| mainFiles | ["index"] | A list of main files in directories |
| modules | ["node_modules"] | A list of directories to resolve modules from, can be absolute path or folder name |
| resolveToContext | false | Resolve to a context instead of a file |
| preferRelative | false | Prefer to resolve module requests as relative request and fallback to resolving as module |
| preferAbsolute | false | Prefer to resolve server-relative urls as absolute paths before falling back to resolve in roots |
| restrictions | [] | A list of resolve restrictions |
| roots | [] | A list of root paths |
| symlinks | true | Whether to resolve symlinks to their symlinked location, [if possible](https://github.com/unrs/unrs-resolver/blob/main/src/options.rs#L157-L170). |
| Field | Default | Description |
| ------------------------------------- | ------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- |
| alias | {} | A hash map of module alias configurations |
| aliasFields | [] | A list of alias fields in description files |
| extensionAlias | {} | An object which maps extension to extension aliases |
| conditionNames | [] | A list of exports field condition names |
| enforceExtension | false | Enforce that a extension from extensions must be used |
| exportsFields | ["exports"] | A list of exports fields in description files |
| extensions | [".js", ".json", ".node"] | A list of extensions which should be tried for files |
| fallback | {} | Same as `alias`, but only used if default resolving fails |
| fileSystem | | The file system which should be used |
| fullySpecified | false | Request passed to resolve is already fully specified and extensions or main files are not resolved for it (they are still resolved for internal requests) |
| mainFields | ["main"] | A list of main fields in description files |
| mainFiles | ["index"] | A list of main files in directories |
| modules | ["node_modules"] | A list of directories to resolve modules from, can be absolute path or folder name |
| resolveToContext | false | Resolve to a context instead of a file |
| preferRelative | false | Prefer to resolve module requests as relative request and fallback to resolving as module |
| preferAbsolute | false | Prefer to resolve server-relative urls as absolute paths before falling back to resolve in roots |
| restrictions | [] | A list of resolve restrictions |
| roots | [] | A list of root paths |
| symlinks | true | Whether to resolve symlinks to their symlinked location |
| allowPackageExportsInDirectoryResolve | false | Allow `exports` field in `require('../directory')`. Not part of `enhanced-resolve`. |

### TypeScript Configuration

| Field | Default | Description |
| ------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| tsconfig | None | TypeScript related config for resolver |
| tsconfig.configFile | | A relative path to the tsconfig file based on `cwd`, or an absolute path of tsconfig file. |
| tsconfig.references | `[]` | - 'auto': inherits from TypeScript config <br/> - `string []`: relative path (based on directory of the referencing tsconfig file) or absolute path of referenced project's tsconfig |

### Unimplemented Options

Expand Down
2 changes: 1 addition & 1 deletion fixtures/pnp/shared/lib.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = function(){
return 42;
}
}
4 changes: 3 additions & 1 deletion justfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ install:
# When ready, run the same CI commands
ready:
git diff --exit-code --quiet
just install
typos
cargo fmt
just check
Expand Down Expand Up @@ -54,7 +55,8 @@ check:
# Run all the tests
test:
cargo test --all-features
pnpm test
node --run build
node --run test

# Lint the whole project
lint:
Expand Down
30 changes: 30 additions & 0 deletions napi/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,22 @@ export declare class ResolverFactory {
async(directory: string, request: string): Promise<ResolveResult>
}

/** Node.js builtin module when `Options::builtin_modules` is enabled. */
export interface Builtin {
/**
* Resolved module.
*
* Always prefixed with "node:" in compliance with the ESM specification.
*/
resolved: string
/**
* Whether the request was prefixed with `node:` or not.
* `fs` -> `false`.
* `node:fs` returns `true`.
*/
isRuntimeModule: boolean
}

export declare const enum EnforceExtension {
Auto = 0,
Enabled = 1,
Expand Down Expand Up @@ -41,6 +57,8 @@ export interface NapiResolveOptions {
* Default `None`
*/
tsconfig?: TsconfigOptions
/** Enable Yarn Plug'n'Play */
yarnPnp?: boolean
/**
* Alias for [ResolveOptions::alias] and [ResolveOptions::fallback].
*
Expand Down Expand Up @@ -198,11 +216,23 @@ export interface NapiResolveOptions {
* Default `false`
*/
moduleType?: boolean
/**
* Allow `exports` field in `require('../directory')`.
*
* This is not part of the spec but some vite projects rely on this behavior.
* See
* * <https://github.com/vitejs/vite/pull/20252>
* * <https://github.com/nodejs/node/issues/58827>
*
* Default: `false`
*/
allowPackageExportsInDirectoryResolve?: boolean
}

export interface ResolveResult {
path?: string
error?: string
builtin?: Builtin
/**
* Module type for this path.
*
Expand Down
Loading
Loading