nodejs / import-in-the-middle

Like `require-in-the-middle`, but for ESM import
https://www.npmjs.com/package/import-in-the-middle
Apache License 2.0
52 stars 20 forks source link

fix: Fallback to `parentLoad` if parsing fails #104

Closed timfish closed 3 weeks ago

timfish commented 3 weeks ago

Closes #101

timfish commented 3 weeks ago

I added a test that shows how this works around #105 but this PR should help with a lot of scenarios and edge cases and makes import-in-the-middle less likely to completely break setups.

timfish commented 3 weeks ago

The tests ran on my own fork but show this failing on node v16 due to the expected rejection in import-executable.mjs.

Looking at that test, I would expect this to fail on every Node version with my changes.

I guess it's only failing on that version due to how assert.rejects works with top-level-await across different node versions?