Closed barryhagan closed 11 months ago
Likely related to this: https://github.com/DataDog/dd-trace-js/issues/3595
It appears the issue is in Node 20 the exports are obtained via AST parsing. Export is not a valid export it just exports all data from the file it's importing so wrapping `` causes the syntax error. I'm not sure of the best way to fix this because pre Node 20 this was a stateful wrap. @Qard and @bengl any thoughts on the best way to fix? It looks like this was discussed here. The test for this isn't as complete as it needs to be to expose the issue @barryhagan has logged
Likely related to this: DataDog/dd-trace-js#3595
This does appear to be related in pre Node 20. However in Node 20 the proxying of exports outputs invalid syntax.
This should be resolved by #43.
Expected Behavior
Using import-in-the-middle/hook.mjs as a loader in an ESM project works when @apollo/server is used by the project.
Actual Behavior
The node application failed to start. The behavior varies based on the version of node in use.
Node v18: exit code 13 Node v20: exit code 1 with
SyntaxError: Unexpected token '*'
Steps to Reproduce the Problem