5. `node --loader=import-in-the-middle/hook.mjs index.mjs` **This fails**
However, doing the same with `import-in-the-middle@1.7.1` works as expected:
7. `npm install --save-exact import-in-the-middle@1.7.1`
8. `node --loader=import-in-the-middle/hook.mjs index.mjs` **This succeeds**
## Additional info
I'm not certain that this is safe, but adding this to the generated code in `hook.js` after [L312](https://github.com/DataDog/import-in-the-middle/blob/c3c2c52c1915b47994af59d507c59029c1f1fae9/hook.js#L312) includes the property from the primary namespace and seems to fix the issue.
for (const k of Object.getOwnPropertySymbols(primary)) {
_[k] = primary[k]
}
Expected Behavior
Using
Hook
, the module passed tohookFn
includes@@toStringTag
property as was the case up untilimport-in-the-middle@1.7.1
Actual Behavior
Using
Hook
, the module passed tohookFn
does not include the@@toStringTag
property.Steps to Reproduce the Problem
npm init
npm install --save-exact koa@2.15.0
(used as an example)npm install --save-exact import-in-the-middle@1.7.3
index.mjs
Hook(['koa'], (exported, name, baseDir) => { // Expect "Module" if(exported[Symbol.toStringTag] !== "Module"){ throw new Error('Expected module') } })
console.log('Everything as expected');
for (const k of Object.getOwnPropertySymbols(primary)) { _[k] = primary[k] }