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

Detection of optimization libraries incorrect with yarn berry + workspaces #227

Open
osdiab opened this issue Jan 14, 2021 · 6 comments
Open

Comments

@osdiab
Copy link

osdiab commented Jan 14, 2021

Thanks for the great project!

With v2, I was using it in one nextJS project but then I made a new one where my NextJS project is part of a yarn workspaces monorepo, but when I start it up I get the error that image compression libraries aren't present.

so I moved the imagemin package deps to the root package.json of the yarn workspace, and now next-optimized-images is happy. It seems that next-optimized-images isn't looking at the actually installed packages for the monorepo subpackage, but I haven't looked into the code to see why that is.

@osdiab osdiab changed the title Detection of optimization libraries incorrect with yarn workspaces Detection of optimization libraries incorrect with yarn berry + workspaces Jan 14, 2021
@osdiab
Copy link
Author

osdiab commented Jan 14, 2021

Seems that require.resolve() isn't a reliable way to determine if a package is installed for pnp packages, and that this library uses it for that purpose.

So the trick is probably to use a pnp-compatible package resolver like one referenced in the yarn article above.

@osdiab
Copy link
Author

osdiab commented Jan 14, 2021

I don't know what are the pros and cons of libraries out there but Webpack has one. https://github.com/webpack/enhanced-resolve

@osdiab
Copy link
Author

osdiab commented Jan 14, 2021

Perhaps the real move is to just use version 3 though.

@merceyz
Copy link

merceyz commented Jan 30, 2021

Seems that require.resolve() isn't a reliable way to determine if a package is installed for pnp packages, and that this library uses it for that purpose.

It is perfectly fine to use it for that, but only if you require from a location that declares them, i'm guessing the resolvePath is pointing to the wrong place

@simPod
Copy link

simPod commented Dec 4, 2022

@osdiab how did you solve it? I tried to require imagemin but still getting error.

@osdiab
Copy link
Author

osdiab commented Dec 5, 2022

Lol I just gave up on using it with pnp

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

No branches or pull requests

3 participants