patriksimek / vm2

Advanced vm/sandbox for Node.js
MIT License
3.86k stars 293 forks source link

Support conditional export resolution with custom resolver #505

Closed nick-klaviyo closed 1 year ago

nick-klaviyo commented 1 year ago

Support resolution of conditional export packages with customer resolver. This change implements the solution described in https://github.com/patriksimek/vm2/issues/504

XmiliaH commented 1 year ago

Thank you for the PR. Could you check that npm test is succeeding. Seems like eslint wants some changes. Furthermore, it would be nice to edit the resolve method in index.d.ts to also allow to return the object.

nick-klaviyo commented 1 year ago

Thank you for the PR. Could you check that npm test is succeeding. Seems like eslint wants some changes. Furthermore, it would be nice to edit the resolve method in index.d.ts to also allow to return the object.

Thanks - I've added the missing comma that was failing eslint and updated index.d.ts - let me know if that additional return type is what you were thinking.

Also: is there additional configuration I need to do locally in order to run eslint? If I run the pretest npm script locally I get thousands of errors across all the project files. Something must be off with my settings 🤔 NVM. I had some additional files eslint was catching

XmiliaH commented 1 year ago

let me know if that additional return type is what you were thinking.

I was thinking of { path: string, module?: string } as you can optionally also return a new module name that should be used for lookup.

And maybe add /test/additional-modules/my-es-module/index.js to the .eslintignore to make eslint happy.

XmiliaH commented 1 year ago

Seems good to me now. Thank you.

nick-klaviyo commented 1 year ago

Thank you!

nick-klaviyo commented 1 year ago

@XmiliaH Do you know when this will be released?

XmiliaH commented 1 year ago

I am busy over the weekend. Will try to do it on Monday.

XmiliaH commented 1 year ago

The new version is released

nick-klaviyo commented 1 year ago

The new version is released

Thanks!