-
Notifications
You must be signed in to change notification settings - Fork 2k
internal: use swc with ts-node #4457
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
Conversation
this currently requires a few changes to c8 control statements to ensure complete code coverage presumably secondary to a bug/difference between how tsc and swc handle source mapping
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.
Pull Request Overview
This PR switches the project to use SWC with ts-node by adjusting coverage ignore directives for source-mapping differences and replacing --loader ts-node/esm
with a --import
registration script.
- Update
c8
ignore annotations (+comments and ignore counts) across multiple GraphQL source files to account for SWC source mapping. - Introduce
resources/register-ts-node.js
and update all npm & Mocha scripts to usenode --import
instead of--loader
. - Add
@swc/core
to devDependencies to enable SWC compilation.
Reviewed Changes
Copilot reviewed 11 out of 13 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
src/validation/rules/PossibleTypeExtensionsRule.ts | Adjusted c8 ignore comments/lines around unreachable invariant . |
src/utilities/valueFromAST.ts | Updated c8 ignore annotations for SWC mapping in valueFromAST . |
src/utilities/printSchema.ts | Updated c8 ignore annotations in printType for input object. |
src/utilities/mapSchemaConfig.ts | Updated c8 ignore annotations in mapSchemaConfig on input types. |
src/utilities/findSchemaChanges.ts | Updated c8 ignore annotations in typeKindName . |
src/utilities/astFromValue.ts | Updated c8 ignore annotations in astFromValue . |
src/type/introspection.ts | Updated c8 ignore annotations in introspection __Type resolver. |
src/execution/execute.ts | Updated c8 ignore annotations in completeValue . |
resources/register-ts-node.js | Added ESM registration script for ts-node import-based loader. |
package.json | Switched npm script flags from --loader to --import and added @swc/core . |
.mocharc.yml | Replaced Mocha loader=ts-node/esm option with import=./resources/register-ts-node.js . |
Comments suppressed due to low confidence (3)
.mocharc.yml:7
- The indentation under
node-option
may be incorrect, which can cause Mocha to ignore this setting. Verify YAML spacing so that each option is a direct child ofnode-option
.
- 'import=./resources/register-ts-node.js'
src/validation/rules/PossibleTypeExtensionsRule.ts:119
- [nitpick] This coverage-ignore comment and directive is duplicated across many files. Consider centralizing SWC-related coverage ignore in the project’s c8 configuration or as a shared helper, reducing repetitive boilerplate and future maintenance.
// c8 control statement technically placed a line early secondary to
src/utilities/printSchema.ts:146
- [nitpick] Ignoring the next four lines may hide coverage gaps beyond the invariant check. If possible, target only the unreachable
invariant
call or use/* c8 ignore next */
without a count to limit the ignored scope.
/* c8 ignore next 4 */
swc = observably faster on my machine, seems like a win. I tries tsx which uses esbuild under the hood, but there is a complication with tsx use of keepNames options for esbuild that messes up code coverage: |
Long term we should move to native node type stripping. |
once we drop v20 |
this currently requires a few changes to c8 control statements to ensure complete code coverage presumably secondary to a bug/difference between how tsc and swc handle source mapping also: use --import with register script instead of --loader to silence node.js warning regarding --loader
this currently requires a few changes to c8 control statements to ensure complete code coverage presumably secondary to a bug/difference between how tsc and swc handle source mapping
also: use --import with register script instead of --loader to silence node.js warning regarding --loader