Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to use iitm ESM loader with @apollo/server #31

Closed
barryhagan opened this issue Sep 2, 2023 · 4 comments
Closed

Unable to use iitm ESM loader with @apollo/server #31

barryhagan opened this issue Sep 2, 2023 · 4 comments

Comments

@barryhagan
Copy link

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

  1. clone https://github.com/barryhagan/iitm-apollo-server-repro
  2. npm i
  3. npm build
  4. npm run start
@barryhagan
Copy link
Author

Likely related to this: DataDog/dd-trace-js#3595

@bizob2828
Copy link

bizob2828 commented Sep 11, 2023

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

@bizob2828
Copy link

bizob2828 commented Sep 11, 2023

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.

jsumners-nr added a commit to jsumners-nr/import-in-the-middle that referenced this issue Dec 7, 2023
This change adds support for modules that export entities through
the `export * from 'module'` ESM syntax. This resolves issue nodejs#31.
jsumners-nr added a commit to jsumners-nr/import-in-the-middle that referenced this issue Dec 7, 2023
This change adds support for modules that export entities through the
`export * from 'module'` ESM syntax. This resolves issue nodejs#31.
jsumners-nr added a commit to jsumners-nr/import-in-the-middle that referenced this issue Dec 11, 2023
This change adds support for modules that export entities through the
`export * from 'module'` ESM syntax. This resolves issue nodejs#31.
bengl pushed a commit that referenced this issue Dec 13, 2023
This change adds support for modules that export entities through the
`export * from 'module'` ESM syntax. This resolves issue #31.
@jsumners-nr
Copy link
Contributor

This should be resolved by #43.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants