diff --git a/.eslintrc.yml b/.eslintrc.yml index ba172c453e8..b0a97dd7f87 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -443,8 +443,7 @@ rules: overrides: - files: - - 'integrationTests/webpack-esm/*.js' - - 'integrationTests/node-esm/*.js' + - 'integrationTests/node-esm/**/*.js' parserOptions: sourceType: module - files: '**/*.ts' diff --git a/integrationTests/node-esm/index.js b/integrationTests/node-esm/index.js index 44f5afd921d..65b234d1d6e 100644 --- a/integrationTests/node-esm/index.js +++ b/integrationTests/node-esm/index.js @@ -1,13 +1,12 @@ -/* eslint-disable node/no-missing-import, import/no-unresolved */ +/* eslint-disable node/no-missing-import, import/no-unresolved, node/no-unsupported-features/es-syntax */ import { deepStrictEqual, strictEqual } from 'assert'; -// Regular import +import { version } from 'version'; +import { schema } from 'schema'; + import { graphqlSync } from 'graphql'; -// Import with explicit extension -import { version } from 'graphql/version.js'; -// _/index.js import -import { buildSchema } from 'graphql/utilities'; + // Import without explicit extension import { isPromise } from 'graphql/jsutils/isPromise'; @@ -16,8 +15,6 @@ import pkg from 'graphql/package.json'; deepStrictEqual(version, pkg.version); -const schema = buildSchema('type Query { hello: String }'); - const result = graphqlSync({ schema, source: '{ hello }', @@ -34,6 +31,6 @@ deepStrictEqual(result, { strictEqual(isPromise(Promise.resolve()), true); // The possible promise rejection is handled by "--unhandled-rejections=strict" -import('graphql/jsutils/isPromise').then(({ isPromise }) => { - strictEqual(isPromise(Promise.resolve()), true); +import('graphql/jsutils/isPromise').then((isPromisePkg) => { + strictEqual(isPromisePkg.isPromise(Promise.resolve()), true); }); diff --git a/integrationTests/node-esm/package.json b/integrationTests/node-esm/package.json index dc371e8b09d..a8f08b44648 100644 --- a/integrationTests/node-esm/package.json +++ b/integrationTests/node-esm/package.json @@ -8,6 +8,8 @@ "graphql": "file:../graphql-esm.tgz", "node-12": "npm:node@12.x.x", "node-14": "npm:node@14.x.x", - "node-16": "npm:node@16.x.x" + "node-16": "npm:node@16.x.x", + "schema": "file:./schema", + "version": "file:./version" } } diff --git a/integrationTests/node-esm/schema/package.json b/integrationTests/node-esm/schema/package.json new file mode 100644 index 00000000000..411883da200 --- /dev/null +++ b/integrationTests/node-esm/schema/package.json @@ -0,0 +1,11 @@ +{ + "name": "schema", + "exports": { + ".": { + "import": "./schema.mjs" + } + }, + "peerDependencies": { + "graphql": "*" + } +} diff --git a/integrationTests/node-esm/schema/schema.mjs b/integrationTests/node-esm/schema/schema.mjs new file mode 100644 index 00000000000..0249166b676 --- /dev/null +++ b/integrationTests/node-esm/schema/schema.mjs @@ -0,0 +1,3 @@ +import { buildSchema } from 'graphql/utilities'; + +export const schema = buildSchema('type Query { hello: String }'); diff --git a/integrationTests/node-esm/version/package.json b/integrationTests/node-esm/version/package.json new file mode 100644 index 00000000000..a163f20d9ef --- /dev/null +++ b/integrationTests/node-esm/version/package.json @@ -0,0 +1,8 @@ +{ + "name": "bar", + "type": "module", + "main": "./version.js", + "peerDependencies": { + "graphql": "*" + } +} diff --git a/integrationTests/node-esm/version/version.js b/integrationTests/node-esm/version/version.js new file mode 100644 index 00000000000..2f1ad8eae28 --- /dev/null +++ b/integrationTests/node-esm/version/version.js @@ -0,0 +1,5 @@ +/* eslint-disable import/no-unresolved, node/no-missing-import */ + +import { version } from 'graphql'; + +export { version };