Rust version of webpack/enhanced-resolve

Overview

OXC Logo

Crates.io Docs.rs

MIT licensed Build Status Code Coverage CodSpeed Badge Sponsors Discord chat

Oxc Resolver

Rust port of enhanced-resolve.

  • built-in tsconfig-paths-webpack-plugin
    • support extending tsconfig defined in tsconfig.extends
    • support paths alias defined in tsconfig.compilerOptions.paths
    • support project references defined tsconfig.references
  • supports in-memory file system via the FileSystem trait
  • contains tracing instrumentation

Options

The options are aligned with enhanced-resolve.

Field Default Description
alias [] A list of module alias configurations or an object which maps key to value
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 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

Unimplemented Options

Field Default Description
cachePredicate function() { return true }; A function which decides whether a request should be cached or not. An object is passed to the function with path and request properties.
cacheWithContext true If unsafe cache is enabled, includes request.context in the cache key
plugins [] A list of additional resolve plugins which should be applied
resolver undefined A prepared Resolver to which the plugins are attached
unsafeCache false Use this cache object to unsafely cache the successful requests

Debugging

Rspack

The following environment variable will emit tracing information.

RSPACK_PROFILE='TRACE=filter=oxc_resolver=trace&layer=logger' rspack build

Test

Tests are ported from

Test cases are located in ./src/tests, fixtures are located in ./tests

  • alias.test.js
  • browserField.test.js
  • dependencies.test.js
  • exportsField.test.js
  • extension-alias.test.js
  • extensions.test.js
  • fallback.test.js
  • fullSpecified.test.js
  • identifier.test.js (see unit test in crates/oxc_resolver/src/request.rs)
  • importsField.test.js
  • incorrect-description-file.test.js (need to add ctx.fileDependencies)
  • missing.test.js
  • path.test.js (see unit test in crates/oxc_resolver/src/path.rs)
  • plugins.test.js
  • pnp.test.js
  • resolve.test.js
  • restrictions.test.js (partially done, regex is not supported yet)
  • roots.test.js
  • scoped-packages.test.js
  • simple.test.js
  • symlink.test.js

Irrelevant tests

  • CachedInputFileSystem.test.js
  • SyncAsyncFileSystemDecorator.test.js
  • forEachBail.test.js
  • getPaths.test.js
  • pr-53.test.js
  • unsafe-cache.test.js
  • yield.test.js

πŸ“– License

oxc_resolver is free and open-source software licensed under the MIT License.

Oxc partially copies code from the following projects.

Project License
webpack/enhanced-resolve MIT
dividab/tsconfig-paths MIT
parcel-bundler/parcel MIT
tmccombs/json-comments-rs Apache 2.0
Comments
  • throw recursion error when resolving cursed browser fields

    throw recursion error when resolving cursed browser fields

    From webpack test suite: https://github.com/webpack/webpack/blob/87660921808566ef3b8796f8df61bd79fc026108/test/cases/resolving/browser-field/index.js#L40-L43

    Given node_modules/recursive-file/package.json:

    {
    	"browser": {
    		"a.js": "./a",
    		"./b.js": "./b",
    		"c.js": "./d.js",
    		"./d.js": "./c.js"
    	}
    }
    

    The following snippet should all throw recursion error.

    require("recursive-file/a");
    require("recursive-file/b");
    require("recursive-file/c");
    require("recursive-file/d");
    

    Caveat:

    require("module-c") should resolve to browser-module/node_modules/module-c.js given

    https://github.com/oxc-project/oxc_resolver/blob/2baf418ab6f8c4cc5073d71dc9a628c43f1a0165/fixtures/enhanced_resolve/test/fixtures/browser-module/package.json#L7

    opened by Boshen 3
  • feat: throw recursion error when resolving cursed browser fields

    feat: throw recursion error when resolving cursed browser fields

    From webpack test suite: https://github.com/webpack/webpack/blob/87660921808566ef3b8796f8df61bd79fc026108/test/cases/resolving/browser-field/index.js#L40-L43

    Given node_modules/recursive-file/package.json:

    {
    	"browser": {
    		"a.js": "./a",
    		"./b.js": "./b",
    		"c.js": "./d.js",
    		"./d.js": "./c.js"
    	}
    }
    

    The following snippet should all throw recursion error.

    require("recursive-file/a");
    require("recursive-file/b");
    require("recursive-file/c");
    require("recursive-file/d");
    
    opened by Boshen 3
  • chore(deps): update rust crate serde_json to 1.0.110 - autoclosed

    chore(deps): update rust crate serde_json to 1.0.110 - autoclosed

    Mend Renovate

    This PR contains the following updates:

    | Package | Type | Update | Change | |---|---|---|---| | serde_json | dependencies | patch | 1.0.109 -> 1.0.110 |


    Release Notes

    serde-rs/json (serde_json)

    v1.0.110

    Compare Source


    Configuration

    πŸ“… Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

    🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

    β™» Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    πŸ”• Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, check this box

    This PR has been generated by Mend Renovate. View repository job log here.

    opened by renovate[bot] 2
  • chore(deps): update rust crate serde to 1.0.194 - autoclosed

    chore(deps): update rust crate serde to 1.0.194 - autoclosed

    Mend Renovate

    This PR contains the following updates:

    | Package | Type | Update | Change | |---|---|---|---| | serde (source) | dependencies | patch | 1.0.193 -> 1.0.194 |


    Release Notes

    serde-rs/serde (serde)

    v1.0.194

    Compare Source

    • Update proc-macro2 to fix caching issue when using a rustc-wrapper such as sccache

    Configuration

    πŸ“… Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

    🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

    β™» Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    πŸ”• Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, check this box

    This PR has been generated by Mend Renovate. View repository job log here.

    opened by renovate[bot] 2
  • chore(deps): update rust crate thiserror to 1.0.56

    chore(deps): update rust crate thiserror to 1.0.56

    Mend Renovate

    This PR contains the following updates:

    | Package | Type | Update | Change | |---|---|---|---| | thiserror | dependencies | patch | 1.0.55 -> 1.0.56 |


    Release Notes

    dtolnay/thiserror (thiserror)

    v1.0.56

    Compare Source

    • Update proc-macro2 to fix caching issue when using a rustc-wrapper such as sccache

    Configuration

    πŸ“… Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

    🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

    β™» Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    πŸ”• Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, check this box

    This PR has been generated by Mend Renovate. View repository job log here.

    opened by renovate[bot] 2
  • chore(deps): update rust crate thiserror to 1.0.55

    chore(deps): update rust crate thiserror to 1.0.55

    Mend Renovate

    This PR contains the following updates:

    | Package | Type | Update | Change | |---|---|---|---| | thiserror | dependencies | patch | 1.0.53 -> 1.0.55 |


    Release Notes

    dtolnay/thiserror (thiserror)

    v1.0.55

    Compare Source

    v1.0.54

    Compare Source


    Configuration

    πŸ“… Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

    🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

    β™» Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    πŸ”• Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, check this box

    This PR has been generated by Mend Renovate. View repository job log here.

    opened by renovate[bot] 2
  • chore(deps): update rust crate serde_json to 1.0.109

    chore(deps): update rust crate serde_json to 1.0.109

    Mend Renovate

    This PR contains the following updates:

    | Package | Type | Update | Change | |---|---|---|---| | serde_json | dependencies | patch | 1.0.108 -> 1.0.109 |


    Release Notes

    serde-rs/json (serde_json)

    v1.0.109

    Compare Source

    • Documentation improvements

    Configuration

    πŸ“… Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

    🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

    β™» Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    πŸ”• Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, check this box

    This PR has been generated by Mend Renovate. View repository job log here.

    opened by renovate[bot] 2
  • chore(deps): update rust crate thiserror to 1.0.53

    chore(deps): update rust crate thiserror to 1.0.53

    Mend Renovate

    This PR contains the following updates:

    | Package | Type | Update | Change | |---|---|---|---| | thiserror | dependencies | patch | 1.0.51 -> 1.0.53 |


    Release Notes

    dtolnay/thiserror (thiserror)

    v1.0.53

    Compare Source

    • Reduce spurious rebuilds under RustRover IDE when using a nightly toolchain (#​270)

    v1.0.52

    Compare Source

    • Fix interaction with RUSTC_BOOTSTRAP (#​269)

    Configuration

    πŸ“… Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

    🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

    β™» Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    πŸ”• Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, check this box

    This PR has been generated by Mend Renovate. View repository job log here.

    opened by renovate[bot] 2
  • chore(deps): update rust crate thiserror to 1.0.51

    chore(deps): update rust crate thiserror to 1.0.51

    Mend Renovate

    This PR contains the following updates:

    | Package | Type | Update | Change | |---|---|---|---| | thiserror | dependencies | patch | 1.0.50 -> 1.0.51 |


    Release Notes

    dtolnay/thiserror (thiserror)

    v1.0.51

    Compare Source

    • Improve diagnostics when an invalid attribute previously caused thiserror to generate no Error impl (#​266)

    Configuration

    πŸ“… Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

    🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

    β™» Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    πŸ”• Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, check this box

    This PR has been generated by Mend Renovate. View repository job log here.

    opened by renovate[bot] 2
  • chore(deps): update rust crate once_cell to 1.19.0

    chore(deps): update rust crate once_cell to 1.19.0

    Mend Renovate

    This PR contains the following updates:

    | Package | Type | Update | Change | |---|---|---|---| | once_cell | dependencies | minor | 1.18.0 -> 1.19.0 |


    Release Notes

    matklad/once_cell (once_cell)

    v1.19.0

    Compare Source

    • Use portable-atomic instead of atomic-polyfill, #​251.

    Configuration

    πŸ“… Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

    🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

    β™» Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    πŸ”• Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, check this box

    This PR has been generated by Mend Renovate. View repository job log here.

    opened by renovate[bot] 2
  • chore(deps): update pnpm to v8.13.1

    chore(deps): update pnpm to v8.13.1

    Mend Renovate

    This PR contains the following updates:

    | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | pnpm (source) | 8.12.1 -> 8.13.1 | age | adoption | passing | confidence |


    Release Notes

    pnpm/pnpm (pnpm)

    v8.13.1

    Minor Changes

    • New commands added for inspecting the store:

      • pnpm cat-index: Prints the index file of a specific package in the store. The package is specified by its name and version: pnpm cat-index <pkg name>@&#8203;<pkg version>
      • pnpm cat-file: Prints the contents of a file based on the hash value stored in the index file. For example: pnpm cat-file sha512-mvavhfVcEREI7d8dfvfvIkuBLnx7+rrkHHnPi8mpEDUlNpY4CUY+CvJ5mrrLl18iQYo1odFwBV7z/cOypG7xxQ==
      • pnpm find-hash: Lists the packages that include the file with the specified hash. For example: pnpm find-hash sha512-mvavhfVcEREI7d8dfvfvIkuBLnx7+rrkHHnPi8mpEDUlNpY4CUY+CvJ5mrrLl18iQYo1odFwBV7z/cOypG7xxQ== This command is experimental. We might change how it behaves.

      Related issue: #​7413.

    • A new setting added for symlinking injected dependencies from the workspace, if their dependencies use the same peer dependencies as the dependent package. The setting is called dedupe-injected-deps #​7416.

    • Use --fail-if-no-match if you want the CLI fail if no packages were matched by the command #​7403.

    Patch Changes

    • pnpm list --parseable should not print the same dependency multiple times #​7429.
    • Fix error message texts in the pnpm env commands #​7456.
    • Better support for light themed terminals by the pnpm update --interactive command #​7439.
    • Fix EPERM error that occasionally happened on Windows during renames in the store #​7213.
    • Fix error as in update -i -r with Git specifiers #​7415.
    • Added support for boolean values in 'bundleDependencies' package.json fields when installing a dependency. Fix to properly handle 'bundledDependencies' alias #​7411.

    Our Gold Sponsors

    Our Silver Sponsors


    Configuration

    πŸ“… Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

    🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

    β™» Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    πŸ”• Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, check this box

    This PR has been generated by Mend Renovate. View repository job log here.

    opened by renovate[bot] 1
  • chore(deps): update pnpm to v8.14.0

    chore(deps): update pnpm to v8.14.0

    Mend Renovate

    This PR contains the following updates:

    | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | pnpm (source) | 8.13.1 -> 8.14.0 | age | adoption | passing | confidence |


    Release Notes

    pnpm/pnpm (pnpm)

    v8.14.0

    Compare Source

    Minor Changes
    • A new option added for hoisting packages from the workspace. When hoist-workspace-packages is set to true, packages from the workspace are symlinked to either <workspace_root>/node_modules/.pnpm/node_modules or to <workspace_root>/node_modules depending on other hoisting settings (hoist-pattern and public-hoist-pattern) #​7451.
    • The pnpm dedupe command now accepts more command line options that the pnpm install command also accepts. Example: pnpm dedupe --store-dir=local-store-dir
    Patch Changes
    • The package information output by cat-index should be sorted by key.
    • pnpm deploy should not touch the target directory if it already exists and isn't empty #​7351.
    • pnpm add a-module-already-in-dev-deps will show a message to notice the user that the package was not moved to "dependencies" #​926 and fix #​7319.
    • Don't install Node.js when use-node-version is set in a WebContainer #​7478.
    • Fix copy-on-write on Windows Dev Drives #​7468.
    Our Gold Sponsors
    Our Silver Sponsors

    Configuration

    πŸ“… Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

    🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

    β™» Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    πŸ”• Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, check this box

    This PR has been generated by Mend Renovate. View repository job log here.

    opened by renovate[bot] 1
Releases(1.0.0)
  • 1.0.0(Dec 20, 2023)

  • 0.6.2(Dec 18, 2023)

    What's Changed

    • fix: throw recursion error when resolving browser fields with recursion by @Boshen in https://github.com/oxc-project/oxc_resolver/pull/17
    • fix: browser field resolving relative to path to itself by @Boshen in https://github.com/oxc-project/oxc_resolver/pull/34
    • feat: return not found when recursing non-existent file by @Boshen in https://github.com/oxc-project/oxc_resolver/pull/36
    • perf(resolver): remove extra large fields from raw package json by @Boshen in https://github.com/oxc-project/oxc_resolver/pull/23
    • refactor: use FxHashMap instead of FxIndexMap for BrowserField by @Boshen in https://github.com/oxc-project/oxc_resolver/pull/33

    Full Changelog: https://github.com/oxc-project/oxc_resolver/compare/0.6.0...0.6.2

    Source code(tar.gz)
    Source code(zip)
  • 0.6.0(Dec 6, 2023)

    • remove unused impl<T> FileSystem for Arc<T> #5
    • feat(resolver): add a realpath to package.json

    Using the realpath for resolving browser field will lead to missing queries.

    This fixes a cases where browserField fails to read.


    styled-components is using a trick for loading browser modules:

    https://github.com/styled-components/styled-components/blob/7c065e0b6f890760d7a6759ec5e4a95775b6e688/packages/styled-components/package.json#L6C1-L12C5

      "main": "dist/styled-components.cjs.js",
      "module": "./dist/styled-components.esm.js",
      "browser": {
        "./dist/styled-components.esm.js": "./dist/styled-components.browser.esm.js",
        "./dist/styled-components.cjs.js": "./dist/styled-components.browser.cjs.js"
      },
    

    Module resolution has to go from "module": "./dist/styled-components.esm.js", then to browser's "./dist/styled-components.esm.js": "./dist/styled-components.browser.esm.js" part in order for things to get resolved correctly.

    Source code(tar.gz)
    Source code(zip)
Owner
oxc
βš“ A suite of high-performance tools for JavaScript and TypeScript written in Rust.
oxc
Resolve JavaScript/TypeScript module with Rust

ES Resolve JavaScript/TypeScript module resolution in Rust Installation cargo add es_resolve Get Started use std::path::{Path, PathBuf}; use es_resolv

wang chenyu 2 Oct 12, 2022
An enhanced history(1) for bash

history This is a replacement for the history builtin in bash. It has a couple of additional features that relative to the one included with bash: Con

Robert T. McGibbon 4 Aug 25, 2022
An enhanced search engine just for Lemmy/Fediverse

Please Read If anyone wants to help contribute to this, please feel free to reach out to me. You can obviously find me on Lemmy, mainly https://lemmy.

null 51 Jul 4, 2023
Create, reorder, group, and focus workspaces easily in i3. Fully configurable with enhanced polybar modules.

Create, reorder, group, and focus workspaces fast and easily in i3. Features Focus Mode: Eliminate Distractions Enable Focus Mode: Use groups and focu

i3-wsman 15 Sep 2, 2023
Using BDK from nodejs using WASM webpack πŸ¦€

BDK + nodejs = ❀️ This repository shows how to use the bdk library in nodejs. It's just a proof-of-concept, not a complete example, and as such, it's

Daniela Brozzoni 10 Feb 21, 2023
A more intuitive version of du in rust

A more intuitive version of du in rust

andy.boot 3k Sep 20, 2021
Vyper-Compiler Version Manager in Rust

Vyper Compiler Version Manager in Rust Install $ cargo install --git https://github.com/storming0x/vvm-rs --locked vvm-rs Install from source $ git c

Storming0x 26 Dec 15, 2022
A version control system implemented from scratch in Rust.

Version Control An experiment to write a version control system from scratch in Rust. CLI Usage Usage: revtool <COMMAND> Commands: init initia

Samuel Schlesinger 3 May 3, 2023
Rust parser/validator for Debian version strings

debian version handling in rust This simple crate provides a struct for parsing, validating, manipulating and comparing Debian version strings. It aim

Jelmer VernooΔ³ 2 Jul 8, 2023
A better rust version of pokeget.

pokeget-rs A better rust version of pokeget. Usage pokeget <pokemon> for more info, run pokeget --help Also, if you're using pokeget in your bashrc, t

Tal 11 Aug 14, 2023
Truly universal encoding detector in pure Rust - port of Python version

Charset Normalizer A library that helps you read text from an unknown charset encoding. Motivated by original Python version of charset-normalizer, I'

Nikolay Yarovoy 29 Oct 9, 2023
An over-simplified version control system written in Rust, similar to Git, for local files (Incomplete)

Vault Vault will be a command line tool (if successful) similar to git which would have multiple features like brances etc etc. __ __ _ _

Shubham 3 Nov 21, 2023
An experimental project for rust version of Hertz written by GPT4.

Ryze: An experimental Rust Web Framework Ryze is a minimal web framework for Rust inspired by Hertz and written by GPT4. Example Here is a simple exam

Wenju Gao 3 Nov 28, 2023
A simple Rust version of goctl

goctl-rs A simple Rust version of goctl Support type struct many type struct nest type struct service block API block Structure token.rs - Tokenize th

hanhotfox 5 Feb 9, 2024
IntelliJ version of the Afterglow Sublime Text theme

Afterglow IntelliJ This theme for IntelliJ is based on the the Afterglow Sublime Text theme, and replaces the default sidebar icons and colour of Inte

Sidney Just 81 Jun 29, 2022
Nvm - Node Version Manager - POSIX-compliant bash script to manage multiple active node.js versions

Node Version Manager Table of Contents Intro About Installing and Updating Install & Update Script Additional Notes Troubleshooting on Linux Troublesh

nvm.sh 63.8k Jan 7, 2023
Compiler for an "extended" version of the Mindustry logic language

Minblur Compiler Minblur is a compiler for a superset of "logic" programming language in the game Mindustry. It helps reduce code-duplication, making

Binder News 15 May 2, 2022
Python PEP-440 Version Parsing

PyVer (WIP) Python PEP-440 Version Parsing This package allows for parsing Python PEP-440 version numbers and comparisons between PEP-440 Versions Usa

Allstreamer 3 Sep 18, 2022
Python PEP-440 Version Parsing

PyVer Python PEP-440 Version Parser This package allows for parsing Python PEP-440 version numbers and for comparisons between PEP-440 version numbers

null 3 Sep 18, 2022