Issue Description
@apollo/server provides different builds for ESM and CJS. It is great to see more ESM support, but the current approach means it suffers from the Dual package hazard described in the node documentation.
To sum up the hazard: this approach makes it extremely likely that both the ESM and CJS versions will be loaded at the same time. Here is a simple example of how this can happen:
- Your project is written in ESM.
- Your project uses
@nestjs/apollo. nestjs is written in commonJS and imports @apollo/server
- Your project includes a plugin for apollo, so you also import
@apollo/server
- Your project will load the ESM version of apollo, and nest will load the CJS version. Meaning the plugin cannot be compatible with nest.
I strongly recommend doing everything you can to only ship a single build to node users by either:
I've provided a minimalist example of what sort of errors this causes below
Link to Reproduction
https://codesandbox.io/p/sandbox/laughing-sun-85cmy8?file=%2Fsrc%2Findex.ts%3A1%2C1
Reproduction Steps
See above
Issue Description
@apollo/serverprovides different builds for ESM and CJS. It is great to see more ESM support, but the current approach means it suffers from the Dual package hazard described in the node documentation.To sum up the hazard: this approach makes it extremely likely that both the ESM and CJS versions will be loaded at the same time. Here is a simple example of how this can happen:
@nestjs/apollo. nestjs is written in commonJS and imports@apollo/server@apollo/serverI strongly recommend doing everything you can to only ship a single build to node users by either:
I've provided a minimalist example of what sort of errors this causes below
Link to Reproduction
https://codesandbox.io/p/sandbox/laughing-sun-85cmy8?file=%2Fsrc%2Findex.ts%3A1%2C1
Reproduction Steps
See above