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

Explicitly named exports should be exported over `export *` exports #102

Closed timfish closed 3 weeks ago

timfish commented 3 weeks ago

@mohd-akram and I incorrectly deduced that duplicate named exports resulted in those exports being excluded.

However, this is not always the case!

With the following code: a.mjs

export function foo() { return 'a' }

b.mjs

export function foo() { return 'b' }

dupe.mjs

// the order here doesn't matter!
export * from './a.mjs'
export { foo } from './b.mjs'

test.mjs

import { foo } from './dupe.mjs'
console.log('out:', foo())
> node test.mjs
out: b

dupe.mjs should export foo from b.mjs. This is because explicitly named exports DO override export * exports.

jsumners-nr commented 3 weeks ago

Nice.

It continues ![image](https://github.com/DataDog/import-in-the-middle/assets/150050532/0b101fd6-67b9-461e-b076-5ebe692b10bb)
timfish commented 3 weeks ago

It continues

Will it ever end!

jsumners-nr commented 3 weeks ago

Will it ever end!

No. https://github.com/tc39/proposal-defer-import-eval