Giter VIP home page Giter VIP logo

nodejs_resolver's Introduction

nodejs_resolver's People

Contributors

ahabhgk avatar boshen avatar bvanjoi avatar hardfist avatar iwanabethatguy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

nodejs_resolver's Issues

can't deal with priority correctlly

package.json:

{
    "name": "commonjs",
    "exports": {
        "./a/b/*": "./dist/hello.js",
        "./a/*/c": null
    }
}

output:

thread '' panicked at 'internal error: entered unreachable code', /Users/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/nodejs-resolver-0.0.34/src/map.rs:135:18
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace
fatal runtime error: failed to initiate panic, error 5
[1] 8437 abort node apps/commonjs-app/index.js

image

enhanced-resolve used by webpack works:

image

Perf: Better cache hit for `std::fs::canonicalize` and `std::fs::metadata`

Both std::fs::canonicalize and std::fs::metadata are slow syscalls as they need to follow and resolve symlinks.

We can probably avoid a lot of these calls by normalizing and caching as much as possible.

For example, std::fs::metadata is currently being called with such paths:

"/benchcases/three/src/copy1/./math/Color.js"
"/benchcases/three/src/copy1/core/../math/Color.js"
"/benchcases/three/src/copy1/extras/core/../../math/Color.js"
"/benchcases/three/src/copy1/helpers/../math/Color.js"
"/benchcases/three/src/copy1/lights/../math/Color.js"
"/benchcases/three/src/copy1/loaders/../math/Color.js"
"/benchcases/three/src/copy1/materials/../math/Color.js"
"/benchcases/three/src/copy1/renderers/shaders/../../math/Color.js"
"/benchcases/three/src/copy1/renderers/webgl/../../math/Color.js"
"/benchcases/three/src/copy1/scenes/../math/Color.js"

But only 1 call should exist because we can normalize and cache these paths prior to the call.

std::fs::canonicalize will be harder to cache and normalize, but should be doable ;-)

`Eq` for `PathBuf`

It return false for PathBuf::from("/a/b/c") == PathBuf::from("/a/b/../b/c"), we should ensure it return true.

Is there a way to resolve request without cache?

I am working on a bundler which is written using Rust and using nodejs_resolver to resolve dependencies. When running dev, all files will be resolved by nodejs_resolver. During dev, if there is a missing dependency, nodejs_resolver will cache that the dependency is None. When the missing dependency is added and using the original resolver to resolve this dependency, the cache None will return and cannot get the right result.

At first sight, I think there should be a method clear_entry which is single entry version of clear_entries:

    // src/entry.rs
    pub fn delete_cache_entry(&self, path: &Path) {
        self.cache.entries.remove(path);
    }

    // TODO: should put entries as a parament.
    pub fn clear_entries(&self) {
        self.cache.entries.clear();
    }

But, the param path should be a path which has been dealt with be ParsePlugin etc rather than the resolve param request, caller cannot the right path in a direct way.

There is a convenient way to resolve request without cache? If not, is there a proper method nodejs_resolver can provide to do that? If has, I can PR.

Get ready for v1.0.0

  • Turn on clippy pedantic and nursery - for better code quality
  • Fix the benchmark bot, it's still broken
  • Have a clear boundary / api between public and private structs, make all public fields private and add accessors and setters.
  • Especially for the return type Info, it should be replaced with a API struct
  • Add a NormalizedPath newtype for the return types of normalize.rs trait, to make the code super clear where normalized paths are
  • Make tracing an optional dependency?

Refactor: more idiomatic Rust codebase

The current codebase is pretty hard to navigate due to the mixed style of JavaScript + Rust, I'll refactor this codebase a bit to make it more idiomatic.

More privacy friendly error message

image
Currently, many errors happen during the resolve will yield the absolute path, this is pretty annoying when you want to copy the error message, the user needs to convert it to the relative path by hand.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.