Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ext/node): fix unable to resolve fraction.js #18544

Merged
merged 5 commits into from
Apr 6, 2023

Conversation

marvinhagemeister
Copy link
Contributor

@marvinhagemeister marvinhagemeister commented Apr 1, 2023

Turns out autoprefixer is a better reproduction case then microbundle.

Fixes #18535
Fixes #18600

ext/node/ops.rs Outdated
Comment on lines 473 to 479
let orignal = modules_path.clone();
let mod_dir = path_resolve(vec![modules_path, name]);
if Path::new(&mod_dir).is_dir() {
mod_dir
} else {
orignal
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the fix here. I'm not too happy about it because it adds a file system check, but it does solve the issue.

The reason I'm not happy about it is that the resolution code expects node_module paths everywhere like /my-project/node_modules. But in this branch here we ignore that assumption and push a module directory to the list of paths instead (/my-project/node_modules/my-module). Then we reach this section here where we'd incorrectly append the package name to the path again resulting in /my-project/node_modules/my-module/my-module which doesn't exist and therefore panics.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. IIRC this was done to support CJS in situation where we use "global cache" (ie. not creating local node_modules directory), but appears that it's wrong. I'm happy to completely reorganize this bit of code so we don't have to do is_dir() check.

@marvinhagemeister marvinhagemeister marked this pull request as ready for review April 1, 2023 06:31
ext/node/ops.rs Outdated Show resolved Hide resolved
bartlomieju added a commit that referenced this pull request Apr 6, 2023
Added more methods to `ext/node/clippy.toml` that are not allowed
to be used in the crate.

Prerequisite for #18544
Copy link
Member

@bartlomieju bartlomieju left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you Marvin! We can clean it up further down the line, but it immediately unblocks us on using a lot more packages, so I'm going to merge it.

@bartlomieju bartlomieju merged commit e51985c into denoland:main Apr 6, 2023
@marvinhagemeister marvinhagemeister deleted the resolve-autoprefixer branch April 6, 2023 21:20
@marvinhagemeister
Copy link
Contributor Author

@bartlomieju Thanks for bringing this PR over the finish line 💯

levex pushed a commit that referenced this pull request Apr 12, 2023
Added more methods to `ext/node/clippy.toml` that are not allowed
to be used in the crate.

Prerequisite for #18544
levex pushed a commit that referenced this pull request Apr 12, 2023
Turns out `autoprefixer` is a better reproduction case then
`microbundle`.

Fixes #18535 
Fixes #18600

---------

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error loading package.json importing @google-cloud/storage Error loading package.json with fraction.js
3 participants