In the bench, compared the the performance along esbuild, enhanced-resolve and this project base on ant-design
nodejs_resolver's Introduction
nodejs_resolver's People
nodejs_resolver's Issues
Refactor: use CanonicalPath for better readability
https://docs.rs/canonical-path/latest/canonical_path/
The current codebase does not distinguish canonical paths, which makes refactoring very tedious.
Feat: detect out of scope target
is able to use it in wasm, e.g. swc plugin?
Add parcel's node resolver to the benchmarks
Might be worth adding โ
to the resolver benchmarks โ this is implemented in rustland as well so the comparison is more apples to apples.
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 withRUST_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
enhanced-resolve used by webpack works:
Bug: Failed performing readlink on relative path
Perf: use `Cow<Path>` and `Arc<Path>` to reduce re-allocation
The current code bases does not utilize the fact that, a lot of the paths result unchanged after transformation, which should benefit from Cow<Path>
feat: support extensionAlias
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 ;-)
perf: `parse_identifier` can return `SmolStr` directly instead of allocating for a `String`
perf: heavy load on hashing Path
feat: resolve absolute path alias
From web-infra-dev/rspack#2914
[questionAbsolutePath]: path.resolve(__dirname, "./src/question.prod.js"),
`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?
perf: remove raw value of package.json and tsconfig.json
We currently save all raw values, they become quite large when we get 1000+ dependencies, it's best to remove the raw values and save what is necessary.
Why is the benchmark comment stuck on comparing to `Previous: 42e5d11` ?
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
Perf: reuse file size for `fs::read_to_string`
fs::read_to_string uses another path.metadata()
stat call which is not needed.
Perf: make `resolve_file_with_ext` faster
Feat: port DescriptionFilePlugin for package.json
Reading package.json is currently done inside load_entry
, it should be moved to a plugin.
And while we are at it, we should look into reducing stat
calls inside this plugin.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.