-
Notifications
You must be signed in to change notification settings - Fork 19
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
What about Yarn PnP support? #176
Comments
It might be OK to embed resolvewithplus inside esmock. Maybe the prepublish script could copy resolvewithplus.js into the src folder then update esmock files to import './resolvewithplus.js' rather than 'resolvewithplus'. A new version could then be published with no dependencies. @tripodsan @aladdin-add it would be good to know what you think of this idea. |
@koshic does resolvewithplus need to be removed from package.json? If resolvewithplus is not removed from package.json, but if esmock does something like this, would this work for your situation? const resolver = typeof import.meta.resolve === 'function'
? import.meta.resolve
: (await import('resolvewithplus')).default |
@jakebailey I think the second one is the best solution, ps it should work :) |
"import.meta.resolve" does not resolve subpaths. The test creates a call like import.meta.resolve is experimental and, to my understanding based on browsing various discussions in nodejs upstream, incomplete. If esmock is updated to rely on current import.meta.resolve, things may get messy in the future. |
there will be less maintenance, if we wait for import.meta.resolve to be stable and complete before using it. |
a good idea BUT esmock tried exporting something like this a month or two ago and typescript does not support this sort of thing TypeStrong/ts-node#1877 even if typescript could (or can?) do this, the support is or will not be great and annoying complexity necessary to placate typescript |
|
thanks for making the demonstration. I'll try updating the PR later today and then respond afterward |
I think the problem at the PR is, "parent" is not in fileURL format that starts with "file:///" this can be fixed of course |
--experimantal-loaders is experimental too, so waiting can be looong ) |
@koshic if you approve this PR, let's merge and use follow-up PRs to specifically resolve the two issues,
I have not used optional dependencies myself so am interested to see how it works. If resolvewithplus is an optional dependency, will npm continue to download it by default for esmock? My research indicates resolvewithplus will continue to be downloaded in the default case, but I haven't used optional dependencies before so am not certain. @koshic if you still have test files you made for testing stub export, would you test if import.meta.resolve returns paths for moduleIds with extensions like "tsx" or "json"? If you're not interested to test this that's good and I can make a little test later this evening or tomorrow. |
@iambumblehead I will approve after few small fixes ) |
changes are published and deployed https://github.com/iambumblehead/esmock/releases/tag/v2.0.7 feel free to re-open if there is any issue :) |
Any loader used in PnP mode can't resolve/load any packages except Node builtins. Yep, we have discussion in Node community how to improve loaders, how to redesign API, etc.
But now only one way - to have bundled loader. It works perfectly for me (I use simple esdbuild-based transpiler for .ts, as an example), but I can't use esmock 'out of box' (proxy bundle is the way, but...) to try node native test runner instead of Jest.
Can we remove single external dependency, 'resolvewithplus' here? Or, mark it optional and use import.meta.resolve (by flag / different import path like esmock/native or so on).
The text was updated successfully, but these errors were encountered: