diff --git a/eslint.config.mjs b/eslint.config.mjs index 65bf540c5f..e143d5cd11 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -764,7 +764,7 @@ export default tsConfig( 'n/no-missing-import': [ 'error', { - allowModules: ['graphql', 'graphql-esm'], + allowModules: ['graphql'], }, ], 'n/no-missing-require': [ diff --git a/integrationTests/node/index.cjs b/integrationTests/node/index.js similarity index 78% rename from integrationTests/node/index.cjs rename to integrationTests/node/index.js index 8a7c1f5003..7c1262f798 100644 --- a/integrationTests/node/index.cjs +++ b/integrationTests/node/index.js @@ -1,15 +1,9 @@ -'use strict'; - -const assert = require('node:assert'); -const { readFileSync } = require('node:fs'); - -const { - experimentalExecuteIncrementally, - graphqlSync, - parse, -} = require('graphql'); -const { buildSchema } = require('graphql/utilities'); -const { version } = require('graphql/version'); +import assert from 'node:assert'; +import { readFileSync } from 'node:fs'; + +import { experimentalExecuteIncrementally, graphqlSync, parse } from 'graphql'; +import { buildSchema } from 'graphql/utilities'; +import { version } from 'graphql/version'; assert.deepStrictEqual( version, diff --git a/integrationTests/node/index.mjs b/integrationTests/node/index.mjs deleted file mode 100644 index e06bd19de6..0000000000 --- a/integrationTests/node/index.mjs +++ /dev/null @@ -1,54 +0,0 @@ -import assert from 'node:assert'; -import { readFileSync } from 'node:fs'; - -import { - experimentalExecuteIncrementally, - graphqlSync, - parse, -} from 'graphql-esm'; -import { buildSchema } from 'graphql-esm/utilities'; -import { version } from 'graphql-esm/version'; - -assert.deepStrictEqual( - version + '+esm', - JSON.parse(readFileSync('./node_modules/graphql-esm/package.json')).version, -); - -const schema = buildSchema('type Query { hello: String }'); - -let result = graphqlSync({ - schema, - source: '{ hello }', - rootValue: { hello: 'world' }, -}); - -assert.deepStrictEqual(result, { - data: { - __proto__: null, - hello: 'world', - }, -}); - -/** - * The below test triggers a call `invariant` method during execution (by - * passing a negative number to the `initialCount` parameter on the `@stream` - * directive). This ensures that the `inlineInvariant` method called by our - * build script works correctly. - **/ - -const experimentalSchema = buildSchema(` - directive @stream(initialCount: Int!) on FIELD - - type Query { - greetings: [String] - } -`); - -result = experimentalExecuteIncrementally({ - schema: experimentalSchema, - document: parse('{ greetings @stream(initialCount: -1) }'), - rootValue: { greetings: ['hi', 'hello'] }, -}); - -assert(result.errors?.[0] !== undefined); -assert(!result.errors[0].message.includes('is not defined')); diff --git a/integrationTests/node/package.json b/integrationTests/node/package.json index 8271998588..2d2665ed9a 100644 --- a/integrationTests/node/package.json +++ b/integrationTests/node/package.json @@ -6,7 +6,6 @@ "test": "node test.js" }, "dependencies": { - "graphql": "file:../graphql.tgz", - "graphql-esm": "file:../graphql-esm.tgz" + "graphql": "file:../graphql.tgz" } } diff --git a/integrationTests/node/test.js b/integrationTests/node/test.js index d7f77e51bf..0e6c35900d 100644 --- a/integrationTests/node/test.js +++ b/integrationTests/node/test.js @@ -15,12 +15,7 @@ for (const version of nodeVersions) { console.log(`Testing on node@${version} ...`); childProcess.execSync( - `docker run --rm --volume "$PWD":/usr/src/app -w /usr/src/app node:${version}-slim node ./index.cjs`, - { stdio: 'inherit' }, - ); - - childProcess.execSync( - `docker run --rm --volume "$PWD":/usr/src/app -w /usr/src/app node:${version}-slim node ./index.mjs`, + `docker run --rm --volume "$PWD":/usr/src/app -w /usr/src/app node:${version}-slim node ./index.js`, { stdio: 'inherit' }, ); } diff --git a/integrationTests/ts/esm.ts b/integrationTests/ts/esm.ts deleted file mode 100644 index 77d011e847..0000000000 --- a/integrationTests/ts/esm.ts +++ /dev/null @@ -1,38 +0,0 @@ -import type { ExecutionResult } from 'graphql-esm/execution'; - -import { graphqlSync } from 'graphql-esm'; -import { - GraphQLString, - GraphQLSchema, - GraphQLObjectType, -} from 'graphql-esm/type'; - -const queryType: GraphQLObjectType = new GraphQLObjectType({ - name: 'Query', - fields: () => ({ - sayHi: { - type: GraphQLString, - args: { - who: { - type: GraphQLString, - default: { value: 'World' }, - }, - }, - resolve(_root, args: { who: string }) { - return 'Hello ' + args.who; - }, - }, - }), -}); - -const schema: GraphQLSchema = new GraphQLSchema({ query: queryType }); - -const result: ExecutionResult = graphqlSync({ - schema, - source: ` - query helloWho($who: String){ - test(who: $who) - } - `, - variableValues: { who: 'Dolly' }, -}); diff --git a/integrationTests/ts/package.json b/integrationTests/ts/package.json index 6e5bfb367d..b3a3586b8a 100644 --- a/integrationTests/ts/package.json +++ b/integrationTests/ts/package.json @@ -7,7 +7,6 @@ }, "dependencies": { "graphql": "file:../graphql.tgz", - "graphql-esm": "file:../graphql-esm.tgz", "typescript-4.9": "npm:typescript@4.9.x", "typescript-5.0": "npm:typescript@5.0.x", "typescript-5.1": "npm:typescript@5.1.x", diff --git a/integrationTests/webpack/entry-esm.mjs b/integrationTests/webpack/entry-esm.mjs deleted file mode 100644 index 5a04dc1ada..0000000000 --- a/integrationTests/webpack/entry-esm.mjs +++ /dev/null @@ -1,10 +0,0 @@ -import { graphqlSync } from 'graphql-esm'; -import { buildSchema } from 'graphql-esm/utilities/buildASTSchema'; - -const schema = buildSchema('type Query { hello: String }'); - -export const result = graphqlSync({ - schema, - source: '{ hello }', - rootValue: { hello: 'world' }, -}); diff --git a/integrationTests/webpack/package.json b/integrationTests/webpack/package.json index 66dd836f1e..74a2502ff7 100644 --- a/integrationTests/webpack/package.json +++ b/integrationTests/webpack/package.json @@ -7,7 +7,6 @@ }, "dependencies": { "graphql": "file:../graphql.tgz", - "graphql-esm": "file:../graphql-esm.tgz", "webpack": "5.x.x", "webpack-cli": "4.x.x" } diff --git a/integrationTests/webpack/test.js b/integrationTests/webpack/test.js index db6ba9db84..7ee717c553 100644 --- a/integrationTests/webpack/test.js +++ b/integrationTests/webpack/test.js @@ -1,18 +1,10 @@ import assert from 'node:assert'; /* eslint-disable n/no-missing-import */ -import cjs from './dist/main-cjs.cjs'; -import mjs from './dist/main-mjs.cjs'; +import { result } from './dist/main-js.js'; /* eslint-enable n/no-missing-import */ -assert.deepStrictEqual(cjs.result, { - data: { - __proto__: null, - hello: 'world', - }, -}); - -assert.deepStrictEqual(mjs.result, { +assert.deepStrictEqual(result, { data: { __proto__: null, hello: 'world', diff --git a/integrationTests/webpack/webpack.config.json b/integrationTests/webpack/webpack.config.json index 8381df4cee..e931a59df2 100644 --- a/integrationTests/webpack/webpack.config.json +++ b/integrationTests/webpack/webpack.config.json @@ -1,13 +1,15 @@ { + "experiments": { + "outputModule": true + }, "mode": "production", "entry": { - "cjs": "./entry.js", - "mjs": "./entry-esm.mjs" + "js": "./entry.js" }, "output": { - "filename": "main-[name].cjs", + "filename": "main-[name].js", "library": { - "type": "commonjs2" + "type": "module" } } } diff --git a/package-lock.json b/package-lock.json index dd8bd3d485..7c094961c0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -30,7 +30,7 @@ "typescript-eslint": "^8.17.0" }, "engines": { - "node": "^16.19.0 || ^18.14.0 || >=19.7.0" + "node": ">=19.7.0 || >=20.0.0 || >=22.0.0" } }, "node_modules/@bcoe/v8-coverage": { diff --git a/package.json b/package.json index ee3e9d26d4..0d569e4f1d 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,7 @@ "graphql-js" ], "engines": { - "node": "^16.19.0 || ^18.14.0 || >=19.7.0" + "node": ">=19.7.0 || >=20.0.0 || >=22.0.0" }, "scripts": { "preversion": "bash -c '. ./resources/checkgit.sh && npm ci --ignore-scripts'", diff --git a/resources/build-npm.ts b/resources/build-npm.ts index c29747efb8..b7272f449c 100644 --- a/resources/build-npm.ts +++ b/resources/build-npm.ts @@ -15,14 +15,10 @@ import { } from './utils.js'; console.log('\n./npmDist'); -await buildPackage('./npmDist', false); +await buildPackage('./npmDist'); showDirStats('./npmDist'); -console.log('\n./npmEsmDist'); -await buildPackage('./npmEsmDist', true); -showDirStats('./npmEsmDist'); - -async function buildPackage(outDir: string, isESMOnly: boolean): Promise { +async function buildPackage(outDir: string): Promise { fs.rmSync(outDir, { recursive: true, force: true }); fs.mkdirSync(outDir); @@ -82,36 +78,25 @@ async function buildPackage(outDir: string, isESMOnly: boolean): Promise { ); } - if (isESMOnly) { - packageJSON.exports = {}; + packageJSON.exports = {}; - const { emittedTSFiles } = emitTSFiles({ - outDir, - module: 'es2020', - extension: '.js', - }); + const { emittedTSFiles } = emitTSFiles({ + outDir, + module: 'es2020', + extension: '.js', + }); - for (const filepath of emittedTSFiles) { - if (path.basename(filepath) === 'index.js') { - const relativePath = './' + path.relative('./npmEsmDist', filepath); - packageJSON.exports[path.dirname(relativePath)] = relativePath; - } + for (const filepath of emittedTSFiles) { + if (path.basename(filepath) === 'index.js') { + const relativePath = './' + path.relative('./npmDist', filepath); + packageJSON.exports[path.dirname(relativePath)] = relativePath; } - - // Temporary workaround to allow "internal" imports, no grantees provided - packageJSON.exports['./*.js'] = './*.js'; - packageJSON.exports['./*'] = './*.js'; - - packageJSON.publishConfig.tag += '-esm'; - packageJSON.version += '+esm'; - } else { - delete packageJSON.type; - packageJSON.main = 'index'; - packageJSON.module = 'index.mjs'; - emitTSFiles({ outDir, module: 'commonjs', extension: '.js' }); - emitTSFiles({ outDir, module: 'es2020', extension: '.mjs' }); } + // Temporary workaround to allow "internal" imports, no grantees provided + packageJSON.exports['./*.js'] = './*.js'; + packageJSON.exports['./*'] = './*.js'; + const packageJsonPath = `./${outDir}/package.json`; const prettified = await prettify( packageJsonPath, diff --git a/resources/integration-test.ts b/resources/integration-test.ts index 47afc844d6..471af0952c 100644 --- a/resources/integration-test.ts +++ b/resources/integration-test.ts @@ -16,12 +16,6 @@ describe('Integration Tests', () => { const archiveName = npm({ cwd: tmpDirPath(), quiet: true }).pack(distDir); fs.renameSync(tmpDirPath(archiveName), tmpDirPath('graphql.tgz')); - const esmDistDir = localRepoPath('npmEsmDist'); - const archiveEsmName = npm({ cwd: tmpDirPath(), quiet: true }).pack( - esmDistDir, - ); - fs.renameSync(tmpDirPath(archiveEsmName), tmpDirPath('graphql-esm.tgz')); - npm().run('build:deno'); function testOnNodeProject(projectName: string) {