diff --git a/.mocharc.yml b/.mocharc.yml index 923173c1c4..77b52383b4 100644 --- a/.mocharc.yml +++ b/.mocharc.yml @@ -4,4 +4,4 @@ check-leaks: true extension: - ts node-option: - - 'loader=ts-node/esm/transpile-only' + - 'import=./resources/register-ts-node.js' diff --git a/package-lock.json b/package-lock.json index 4346f4b0e7..f25278ec91 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,6 +9,7 @@ "version": "17.0.0-alpha.9", "license": "MIT", "devDependencies": { + "@swc/core": "^1.12.11", "@types/chai": "5.0.1", "@types/mocha": "10.0.10", "@types/node": "22.10.1", @@ -968,6 +969,232 @@ "dev": true, "license": "MIT" }, + "node_modules/@swc/core": { + "version": "1.12.11", + "resolved": "https://registry.npmjs.org/@swc/core/-/core-1.12.11.tgz", + "integrity": "sha512-P3GM+0lqjFctcp5HhR9mOcvLSX3SptI9L1aux0Fuvgt8oH4f92rCUrkodAa0U2ktmdjcyIiG37xg2mb/dSCYSA==", + "dev": true, + "hasInstallScript": true, + "license": "Apache-2.0", + "dependencies": { + "@swc/counter": "^0.1.3", + "@swc/types": "^0.1.23" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/swc" + }, + "optionalDependencies": { + "@swc/core-darwin-arm64": "1.12.11", + "@swc/core-darwin-x64": "1.12.11", + "@swc/core-linux-arm-gnueabihf": "1.12.11", + "@swc/core-linux-arm64-gnu": "1.12.11", + "@swc/core-linux-arm64-musl": "1.12.11", + "@swc/core-linux-x64-gnu": "1.12.11", + "@swc/core-linux-x64-musl": "1.12.11", + "@swc/core-win32-arm64-msvc": "1.12.11", + "@swc/core-win32-ia32-msvc": "1.12.11", + "@swc/core-win32-x64-msvc": "1.12.11" + }, + "peerDependencies": { + "@swc/helpers": ">=0.5.17" + }, + "peerDependenciesMeta": { + "@swc/helpers": { + "optional": true + } + } + }, + "node_modules/@swc/core-darwin-arm64": { + "version": "1.12.11", + "resolved": "https://registry.npmjs.org/@swc/core-darwin-arm64/-/core-darwin-arm64-1.12.11.tgz", + "integrity": "sha512-J19Jj9Y5x/N0loExH7W0OI9OwwoVyxutDdkyq1o/kgXyBqmmzV7Y/Q9QekI2Fm/qc5mNeAdP7aj4boY4AY/JPw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "Apache-2.0 AND MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-darwin-x64": { + "version": "1.12.11", + "resolved": "https://registry.npmjs.org/@swc/core-darwin-x64/-/core-darwin-x64-1.12.11.tgz", + "integrity": "sha512-PTuUQrfStQ6cjW+uprGO2lpQHy84/l0v+GqRqq8s/jdK55rFRjMfCeyf6FAR0l6saO5oNOQl+zWR1aNpj8pMQw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0 AND MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-linux-arm-gnueabihf": { + "version": "1.12.11", + "resolved": "https://registry.npmjs.org/@swc/core-linux-arm-gnueabihf/-/core-linux-arm-gnueabihf-1.12.11.tgz", + "integrity": "sha512-poxBq152HsupOtnZilenvHmxZ9a8SRj4LtfxUnkMDNOGrZR9oxbQNwEzNKfi3RXEcXz+P8c0Rai1ubBazXv8oQ==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-linux-arm64-gnu": { + "version": "1.12.11", + "resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-gnu/-/core-linux-arm64-gnu-1.12.11.tgz", + "integrity": "sha512-y1HNamR/D0Hc8xIE910ysyLe269UYiGaQPoLjQS0phzWFfWdMj9bHM++oydVXZ4RSWycO7KyJ3uvw4NilvyMKQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "Apache-2.0 AND MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-linux-arm64-musl": { + "version": "1.12.11", + "resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-musl/-/core-linux-arm64-musl-1.12.11.tgz", + "integrity": "sha512-LlBxPh/32pyQsu2emMEOFRm7poEFLsw12Y1mPY7FWZiZeptomKSOSHRzKDz9EolMiV4qhK1caP1lvW4vminYgQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "Apache-2.0 AND MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-linux-x64-gnu": { + "version": "1.12.11", + "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-gnu/-/core-linux-x64-gnu-1.12.11.tgz", + "integrity": "sha512-bOjiZB8O/1AzHkzjge1jqX62HGRIpOHqFUrGPfAln/NC6NR+Z2A78u3ixV7k5KesWZFhCV0YVGJL+qToL27myA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0 AND MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-linux-x64-musl": { + "version": "1.12.11", + "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-musl/-/core-linux-x64-musl-1.12.11.tgz", + "integrity": "sha512-4dzAtbT/m3/UjF045+33gLiHd8aSXJDoqof7gTtu4q0ZyAf7XJ3HHspz+/AvOJLVo4FHHdFcdXhmo/zi1nFn8A==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0 AND MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-win32-arm64-msvc": { + "version": "1.12.11", + "resolved": "https://registry.npmjs.org/@swc/core-win32-arm64-msvc/-/core-win32-arm64-msvc-1.12.11.tgz", + "integrity": "sha512-h8HiwBZErKvCAmjW92JvQp0iOqm6bncU4ac5jxBGkRApabpUenNJcj3h2g5O6GL5K6T9/WhnXE5gyq/s1fhPQg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "Apache-2.0 AND MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-win32-ia32-msvc": { + "version": "1.12.11", + "resolved": "https://registry.npmjs.org/@swc/core-win32-ia32-msvc/-/core-win32-ia32-msvc-1.12.11.tgz", + "integrity": "sha512-1pwr325mXRNUhxTtXmx1IokV5SiRL+6iDvnt3FRXj+X5UvXXKtg2zeyftk+03u8v8v8WUr5I32hIypVJPTNxNg==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "Apache-2.0 AND MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-win32-x64-msvc": { + "version": "1.12.11", + "resolved": "https://registry.npmjs.org/@swc/core-win32-x64-msvc/-/core-win32-x64-msvc-1.12.11.tgz", + "integrity": "sha512-5gggWo690Gvs7XiPxAmb5tHwzB9RTVXUV7AWoGb6bmyUd1OXYaebQF0HAOtade5jIoNhfQMQJ7QReRgt/d2jAA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0 AND MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/counter": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/@swc/counter/-/counter-0.1.3.tgz", + "integrity": "sha512-e2BR4lsJkkRlKZ/qCHPw9ZaSxc0MVUd7gtbtaB7aMvHeJVYe8sOB8DBZkP2DtISHGSku9sCK6T6cnY0CtXrOCQ==", + "dev": true, + "license": "Apache-2.0" + }, + "node_modules/@swc/types": { + "version": "0.1.23", + "resolved": "https://registry.npmjs.org/@swc/types/-/types-0.1.23.tgz", + "integrity": "sha512-u1iIVZV9Q0jxY+yM2vw/hZGDNudsN85bBpTqzAQ9rzkxW9D+e3aEM4Han+ow518gSewkXgjmEK0BD79ZcNVgPw==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@swc/counter": "^0.1.3" + } + }, "node_modules/@tsconfig/node10": { "version": "1.0.11", "resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.11.tgz", diff --git a/package.json b/package.json index 4f66c719d0..54a7d8ed18 100644 --- a/package.json +++ b/package.json @@ -30,10 +30,10 @@ }, "scripts": { "preversion": "bash -c '. ./resources/checkgit.sh && npm ci --ignore-scripts'", - "version": "node --loader ts-node/esm resources/gen-version.ts && npm test && git add src/version.ts", + "version": "node --import ./resources/register-ts-node.js resources/gen-version.ts && npm test && git add src/version.ts", "fuzzonly": "mocha --full-trace src/**/__tests__/**/*-fuzz.ts", - "changelog": "node --loader ts-node/esm resources/gen-changelog.ts", - "benchmark": "node --loader ts-node/esm resources/benchmark.ts", + "changelog": "node --import ./resources/register-ts-node.js resources/gen-changelog.ts", + "benchmark": "node --import ./resources/register-ts-node.js resources/benchmark.ts", "test": "npm run lint && npm run check && npm run testonly:cover && npm run prettier:check && npm run check:spelling && npm run check:integrations", "lint": "eslint --cache --max-warnings 0 .", "check": "tsc --pretty", @@ -45,14 +45,15 @@ "precommit": "lint-staged", "check:spelling": "cspell --cache --no-progress \"**/*\"", "check:integrations": "mocha --full-trace resources/integration-test.ts", - "build:npm": "node --loader ts-node/esm resources/build-npm.ts", - "build:deno": "node --loader ts-node/esm resources/build-deno.ts", - "diff:npm": "node --loader ts-node/esm resources/diff-npm-package.ts", + "build:npm": "node --import ./resources/register-ts-node.js resources/build-npm.ts", + "build:deno": "node --import ./resources/register-ts-node.js resources/build-deno.ts", + "diff:npm": "node --import ./resources/register-ts-node.js resources/diff-npm-package.ts", "gitpublish:npm": "bash ./resources/gitpublish.sh npm npmDist", "gitpublish:deno": "bash ./resources/gitpublish.sh deno denoDist", "prepare": "husky" }, "devDependencies": { + "@swc/core": "^1.12.11", "@types/chai": "5.0.1", "@types/mocha": "10.0.10", "@types/node": "22.10.1", diff --git a/resources/register-ts-node.js b/resources/register-ts-node.js new file mode 100644 index 0000000000..8faa0f132c --- /dev/null +++ b/resources/register-ts-node.js @@ -0,0 +1,6 @@ +// node.js recommends this instead of using `node --loader ts-node/esm` +// eslint-disable-next-line n/no-unsupported-features/node-builtins +import { register } from 'node:module'; +import { pathToFileURL } from 'node:url'; + +register('ts-node/esm', pathToFileURL('./')); diff --git a/src/execution/execute.ts b/src/execution/execute.ts index bcf21e9737..49e98b9541 100644 --- a/src/execution/execute.ts +++ b/src/execution/execute.ts @@ -1125,8 +1125,10 @@ function completeValue( incrementalContext, deferMap, ); + // c8 control statement technically placed a line early secondary to + // slight swc source mapping error (at least as compared to ts-node without swc) + /* c8 ignore next 7 */ } - /* c8 ignore next 6 */ // Not reachable, all possible output types have been considered. invariant( false, diff --git a/src/type/introspection.ts b/src/type/introspection.ts index e9181f53ca..fceb49b9f9 100644 --- a/src/type/introspection.ts +++ b/src/type/introspection.ts @@ -240,8 +240,10 @@ export const __Type: GraphQLObjectType = new GraphQLObjectType({ } if (isNonNullType(type)) { return TypeKind.NON_NULL; + // c8 control statement technically placed a line early secondary to + // slight swc source mapping error (at least as compared to ts-node without swc) + /* c8 ignore next 4 */ } - /* c8 ignore next 3 */ // Not reachable, all possible types have been considered) invariant(false, `Unexpected type: "${inspect(type)}".`); }, diff --git a/src/utilities/astFromValue.ts b/src/utilities/astFromValue.ts index 3ace598d91..72fc70c427 100644 --- a/src/utilities/astFromValue.ts +++ b/src/utilities/astFromValue.ts @@ -137,8 +137,10 @@ export function astFromValue( } throw new TypeError(`Cannot convert value to AST: ${inspect(coerced)}.`); + // c8 control statement technically placed a line early secondary to + // slight swc source mapping error (at least as compared to ts-node without swc) + /* c8 ignore next 4 */ } - /* c8 ignore next 3 */ // Not reachable, all possible types have been considered. invariant(false, 'Unexpected input type: ' + inspect(type)); } diff --git a/src/utilities/findSchemaChanges.ts b/src/utilities/findSchemaChanges.ts index 4599ae489b..3000c676a3 100644 --- a/src/utilities/findSchemaChanges.ts +++ b/src/utilities/findSchemaChanges.ts @@ -715,8 +715,10 @@ function typeKindName(type: GraphQLNamedType): string { } if (isInputObjectType(type)) { return 'an Input type'; + // c8 control statement technically placed a line early secondary to + // slight swc source mapping error (at least as compared to ts-node without swc) + /* c8 ignore next 4 */ } - /* c8 ignore next 3 */ // Not reachable, all possible types have been considered. invariant(false, 'Unexpected type: ' + inspect(type)); } diff --git a/src/utilities/mapSchemaConfig.ts b/src/utilities/mapSchemaConfig.ts index dbcce21746..ac2ae9c1ed 100644 --- a/src/utilities/mapSchemaConfig.ts +++ b/src/utilities/mapSchemaConfig.ts @@ -280,8 +280,10 @@ export function mapSchemaConfig( } if (isInputObjectType(type)) { return mapInputObjectType(type); + // c8 control statement technically placed a line early secondary to + // slight swc source mapping error (at least as compared to ts-node without swc) + /* c8 ignore next 4 */ } - /* c8 ignore next 3 */ // Not reachable, all possible type definition nodes have been considered. invariant(false, 'Unexpected type: ' + inspect(type)); } diff --git a/src/utilities/printSchema.ts b/src/utilities/printSchema.ts index be5238ae3a..5287c6d957 100644 --- a/src/utilities/printSchema.ts +++ b/src/utilities/printSchema.ts @@ -141,8 +141,10 @@ export function printType(type: GraphQLNamedType): string { } if (isInputObjectType(type)) { return printInputObject(type); + // c8 control statement technically placed a line early secondary to + // slight swc source mapping error (at least as compared to ts-node without swc) + /* c8 ignore next 4 */ } - /* c8 ignore next 3 */ // Not reachable, all possible types have been considered. invariant(false, 'Unexpected type: ' + inspect(type)); } diff --git a/src/utilities/valueFromAST.ts b/src/utilities/valueFromAST.ts index add9153680..539d09b535 100644 --- a/src/utilities/valueFromAST.ts +++ b/src/utilities/valueFromAST.ts @@ -156,8 +156,10 @@ export function valueFromAST( return; // Invalid: intentionally return no value. } return result; + // c8 control statement technically placed a line early secondary to + // slight swc source mapping error (at least as compared to ts-node without swc) + /* c8 ignore next 4 */ } - /* c8 ignore next 3 */ // Not reachable, all possible input types have been considered. invariant(false, 'Unexpected input type: ' + inspect(type)); } diff --git a/src/validation/rules/PossibleTypeExtensionsRule.ts b/src/validation/rules/PossibleTypeExtensionsRule.ts index 57f2b5541b..c1aa119276 100644 --- a/src/validation/rules/PossibleTypeExtensionsRule.ts +++ b/src/validation/rules/PossibleTypeExtensionsRule.ts @@ -116,8 +116,10 @@ function typeToExtKind(type: GraphQLNamedType): Kind { } if (isInputObjectType(type)) { return Kind.INPUT_OBJECT_TYPE_EXTENSION; + // c8 control statement technically placed a line early secondary to + // slight swc source mapping error (at least as compared to ts-node without swc) + /* c8 ignore next 4 */ } - /* c8 ignore next 3 */ // Not reachable. All possible types have been considered invariant(false, 'Unexpected type: ' + inspect(type)); } diff --git a/tsconfig.json b/tsconfig.json index 1bd54781c0..bc9a92ce34 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -19,7 +19,6 @@ "isolatedModules": true, "verbatimModuleSyntax": true, "forceConsistentCasingInFileNames": true, - // Type Checking // https://www.typescriptlang.org/tsconfig#Type_Checking_6248 "strict": true, @@ -38,6 +37,6 @@ "allowSyntheticDefaultImports": true }, "ts-node": { - "esm": true + "swc": true } }