Skip to content

Commit 87d003d

Browse files
authored
deploy full ESM with "type": "module" in "latest-esm" npm tag (#3361)
1 parent 3e5239f commit 87d003d

File tree

16 files changed

+154
-38
lines changed

16 files changed

+154
-38
lines changed

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
/node_modules
66
/reports
77
/npmDist
8+
/npmEsmDist
89
/denoDist
910
/websiteDist
1011

.eslintrc.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,10 @@ rules:
473473
yield-star-spacing: off
474474

475475
overrides:
476+
- files:
477+
- 'integrationTests/node-esm/**/*.js'
478+
parserOptions:
479+
sourceType: module
476480
- files: '**/*.ts'
477481
parser: '@typescript-eslint/parser'
478482
parserOptions:

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@
1313
/node_modules
1414
/reports
1515
/npmDist
16+
/npmEsmDist
1617
/denoDist
1718
/websiteDist

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@
66
/node_modules
77
/reports
88
/npmDist
9+
/npmEsmDist
910
/denoDist
1011
/websiteDist

integrationTests/node/index.js renamed to integrationTests/node/index.mjs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
import assert from 'assert';
33
import { readFileSync } from 'fs';
44

5-
import { graphqlSync } from 'graphql';
6-
import { buildSchema } from 'graphql/utilities';
7-
import { version } from 'graphql/version';
5+
import { graphqlSync } from 'graphql-esm';
6+
import { buildSchema } from 'graphql-esm/utilities';
7+
import { version } from 'graphql-esm/version';
88

99
assert.deepStrictEqual(
10-
version,
11-
JSON.parse(readFileSync('./node_modules/graphql/package.json')).version,
10+
version + '+esm',
11+
JSON.parse(readFileSync('./node_modules/graphql-esm/package.json')).version,
1212
);
1313

1414
const schema = buildSchema('type Query { hello: String }');

integrationTests/node/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"test": "node test.js"
77
},
88
"dependencies": {
9-
"graphql": "file:../graphql.tgz"
9+
"graphql": "file:../graphql.tgz",
10+
"graphql-esm": "file:../graphql-esm.tgz"
1011
}
1112
}

integrationTests/node/test.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,12 @@ for (const version of nodeVersions) {
1414
console.log(`Testing on node@${version} ...`);
1515

1616
childProcess.execSync(
17-
`docker run --rm --volume "$PWD":/usr/src/app -w /usr/src/app node:${version}-slim node ./index.js`,
17+
`docker run --rm --volume "$PWD":/usr/src/app -w /usr/src/app node:${version}-slim node ./index.cjs`,
18+
{ stdio: 'inherit' },
19+
);
20+
21+
childProcess.execSync(
22+
`docker run --rm --volume "$PWD":/usr/src/app -w /usr/src/app node:${version}-slim node ./index.mjs`,
1823
{ stdio: 'inherit' },
1924
);
2025
}

integrationTests/ts/esm.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import type { ExecutionResult } from 'graphql-esm/execution';
2+
3+
import { graphqlSync } from 'graphql-esm';
4+
import {
5+
GraphQLString,
6+
GraphQLSchema,
7+
GraphQLObjectType,
8+
} from 'graphql-esm/type';
9+
10+
const queryType: GraphQLObjectType = new GraphQLObjectType({
11+
name: 'Query',
12+
fields: () => ({
13+
sayHi: {
14+
type: GraphQLString,
15+
args: {
16+
who: {
17+
type: GraphQLString,
18+
defaultValue: 'World',
19+
},
20+
},
21+
resolve(_root, args: { who: string }) {
22+
return 'Hello ' + args.who;
23+
},
24+
},
25+
}),
26+
});
27+
28+
const schema: GraphQLSchema = new GraphQLSchema({ query: queryType });
29+
30+
const result: ExecutionResult = graphqlSync({
31+
schema,
32+
source: `
33+
query helloWho($who: String){
34+
test(who: $who)
35+
}
36+
`,
37+
variableValues: { who: 'Dolly' },
38+
});

integrationTests/ts/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
},
88
"dependencies": {
99
"graphql": "file:../graphql.tgz",
10+
"graphql-esm": "file:../graphql-esm.tgz",
1011
"typescript-4.4": "npm:typescript@4.4.x",
1112
"typescript-4.5": "npm:typescript@4.5.x",
1213
"typescript-4.6": "npm:typescript@4.6.x",
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// eslint-disable-next-line node/no-missing-import, import/no-unresolved
2+
import { graphqlSync } from 'graphql-esm';
3+
4+
// eslint-disable-next-line node/no-missing-import, import/no-unresolved
5+
import { buildSchema } from 'graphql-esm/utilities/buildASTSchema';
6+
7+
const schema = buildSchema('type Query { hello: String }');
8+
9+
export const result = graphqlSync({
10+
schema,
11+
source: '{ hello }',
12+
rootValue: { hello: 'world' },
13+
});

0 commit comments

Comments
 (0)