-
Notifications
You must be signed in to change notification settings - Fork 2k
Fix ESM/CJS and deep imports #6606
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,3 +32,5 @@ node_modules/ | |
|
|
||
| # Volta binaries (when using direnv/.envrc) | ||
| .volta | ||
|
|
||
| smoke-test/generated | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| { | ||
| "name": "@apollo/server/plugin/cacheControl", | ||
| "type": "module", | ||
| "main": "../dist/cjs/plugin/cacheControl/index.js", | ||
| "module": "../dist/esm/plugin/cacheControl/index.js", | ||
| "types": "../dist/esm/plugin/cacheControl/index.d.ts", | ||
| "sideEffects": false | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| { | ||
| "name": "@apollo/server/plugin/disabled", | ||
| "type": "module", | ||
| "main": "../dist/cjs/plugin/disabled/index.js", | ||
| "module": "../dist/esm/plugin/disabled/index.js", | ||
| "types": "../dist/esm/plugin/disabled/index.d.ts", | ||
| "sideEffects": false | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| { | ||
| "name": "@apollo/server/plugin/drainHttpServer", | ||
| "type": "module", | ||
| "main": "../dist/cjs/plugin/drainHttpServer/index.js", | ||
| "module": "../dist/esm/plugin/drainHttpServer/index.js", | ||
| "types": "../dist/esm/plugin/drainHttpServer/index.d.ts", | ||
| "sideEffects": false | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| { | ||
| "name": "@apollo/server/plugin/inlineTrace", | ||
| "type": "module", | ||
| "main": "../dist/cjs/plugin/inlineTrace/index.js", | ||
| "module": "../dist/esm/plugin/inlineTrace/index.js", | ||
| "types": "../dist/esm/plugin/inlineTrace/index.d.ts", | ||
| "sideEffects": false | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| { | ||
| "name": "@apollo/server/plugin/landingPage/default", | ||
| "type": "module", | ||
| "main": "../dist/cjs/plugin/landingPage/default/index.js", | ||
| "module": "../dist/esm/plugin/landingPage/default/index.js", | ||
| "types": "../dist/esm/plugin/landingPage/default/index.d.ts", | ||
| "sideEffects": false | ||
| } |
8 changes: 8 additions & 0 deletions
8
packages/server/plugin/landingPage/graphqlPlayground/package.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| { | ||
| "name": "@apollo/server/plugin/landingPage/graphqlPlayground", | ||
| "type": "module", | ||
| "main": "../dist/cjs/plugin/landingPage/graphqlPlayground/index.js", | ||
| "module": "../dist/esm/plugin/landingPage/graphqlPlayground/index.js", | ||
| "types": "../dist/esm/plugin/landingPage/graphqlPlayground/index.d.ts", | ||
| "sideEffects": false | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| { | ||
| "name": "@apollo/server/plugin/schemaReporting", | ||
| "type": "module", | ||
| "main": "../dist/cjs/plugin/schemaReporting/index.js", | ||
| "module": "../dist/esm/plugin/schemaReporting/index.js", | ||
| "types": "../dist/esm/plugin/schemaReporting/index.d.ts", | ||
| "sideEffects": false | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| { | ||
| "name": "@apollo/server/plugin/usageReporting", | ||
| "type": "module", | ||
| "main": "../dist/cjs/plugin/usageReporting/index.js", | ||
| "module": "../dist/esm/plugin/usageReporting/index.js", | ||
| "types": "../dist/esm/plugin/usageReporting/index.d.ts", | ||
| "sideEffects": false | ||
| } |
4 changes: 2 additions & 2 deletions
4
packages/server/src/plugin/disabled.ts → packages/server/src/plugin/disabled/index.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| { | ||
| "name": "@apollo/server/standalone", | ||
| "type": "module", | ||
| "main": "../dist/cjs/standalone/index.js", | ||
| "module": "../dist/esm/standalone/index.js", | ||
| "types": "../dist/esm/standalone/index.d.ts", | ||
| "sideEffects": false | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| import { ApolloServer } from '@apollo/server'; | ||
| import { startStandaloneServer } from '@apollo/server/standalone'; | ||
| import fetch from 'make-fetch-happen'; | ||
| import assert from 'assert'; | ||
|
|
||
| async function smokeTest() { | ||
| const s = new ApolloServer({ | ||
| typeDefs: 'type Query {hello:String}', | ||
| resolvers: { | ||
| Query: { | ||
| hello() { | ||
| return 'world'; | ||
| }, | ||
| }, | ||
| }, | ||
| }); | ||
| const { url } = await startStandaloneServer(s, { listen: { port: 0 } }); | ||
|
|
||
| const response = await fetch(url, { | ||
| method: 'POST', | ||
| headers: { 'content-type': 'application/json' }, | ||
| body: JSON.stringify({ query: '{hello}' }), | ||
| }); | ||
| const body = await response.json(); | ||
|
|
||
| assert.strictEqual(body.data.hello, 'world'); | ||
|
|
||
| await s.stop(); | ||
| } | ||
|
|
||
| smokeTest() | ||
| .then(() => { | ||
| console.log('TS-CJS smoke test passed!'); | ||
| process.exit(0); | ||
| }) | ||
| .catch((e) => { | ||
| console.error(e); | ||
| process.exit(1); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| import { ApolloServer } from '@apollo/server'; | ||
| import { startStandaloneServer } from '@apollo/server/standalone'; | ||
| import fetch from 'make-fetch-happen'; | ||
| import assert from 'assert'; | ||
|
|
||
| async function smokeTest() { | ||
| const s = new ApolloServer({ | ||
| typeDefs: 'type Query {hello:String}', | ||
| resolvers: { | ||
| Query: { | ||
| hello() { | ||
| return 'world'; | ||
| }, | ||
| }, | ||
| }, | ||
| }); | ||
| const { url } = await startStandaloneServer(s, { listen: { port: 0 } }); | ||
|
|
||
| const response = await fetch(url, { | ||
| method: 'POST', | ||
| headers: { 'content-type': 'application/json' }, | ||
| body: JSON.stringify({ query: '{hello}' }), | ||
| }); | ||
| const body = await response.json(); | ||
|
|
||
| assert.strictEqual(body.data.hello, 'world'); | ||
|
|
||
| await s.stop(); | ||
| } | ||
|
|
||
| smokeTest() | ||
| .then(() => { | ||
| console.log('TS-ESM smoke test passed!'); | ||
| process.exit(0); | ||
| }) | ||
| .catch((e) => { | ||
| console.error(e); | ||
| process.exit(1); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| { | ||
| "files": [ | ||
| "smoke-test.cts", | ||
| ], | ||
| "compilerOptions": { | ||
| "outDir": "generated/tsc", | ||
| "module": "commonjs", | ||
| "moduleResolution": "node", | ||
| "esModuleInterop": true, | ||
| "strict": true, | ||
| }, | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| { | ||
| "files": [ | ||
| "smoke-test.mts", | ||
| ], | ||
| "compilerOptions": { | ||
| "outDir": "generated/tsc", | ||
| "module": "esnext", | ||
| "moduleResolution": "node", | ||
| "esModuleInterop": true, | ||
| "strict": true, | ||
| }, | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wanna make the index change here for consistency?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh it looks like you did make that file move so I think this needs an update.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...and maybe we need to smoke test these paths since presumably this is in a broken state without CI knowing.