Skip to content

Commit 985ce09

Browse files
committed
💥 Transform to ESM
1 parent 49cff2c commit 985ce09

File tree

8 files changed

+284
-209
lines changed

8 files changed

+284
-209
lines changed

npm-shrinkwrap.json

Lines changed: 254 additions & 192 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,17 @@
22
"name": "graphql-schema-diff",
33
"version": "2.5.0",
44
"description": "Returns the diff of two GraphQL schemas. Detects dangerous and breaking changes.",
5-
"main": "dist/index.js",
6-
"types": "dist/index.d.ts",
5+
"type": "module",
6+
"exports": "./dist/index.js",
7+
"types": "./dist/index.d.ts",
78
"scripts": {
89
"build": "tsc",
9-
"dev": "ts-node --files src/cli",
10+
"dev": "node --loader ts-node/esm ./src/cli.ts",
1011
"prepack": "npm run build",
1112
"test": "jest",
1213
"fmt": "prettier --write src/**"
1314
},
14-
"bin": "dist/cli.js",
15+
"bin": "./dist/cli.js",
1516
"files": [
1617
"dist/",
1718
"npm-shrinkwrap.json"
@@ -40,10 +41,9 @@
4041
"chalk": "^4.1.2",
4142
"diff2html": "^3.4.18",
4243
"disparity": "^3.2.0",
43-
"fs-extra": "^10.1.0",
44-
"graphql": "^15.6.1",
45-
"meow": "^9.0.0",
46-
"node-fetch": "^2.6.7"
44+
"fs-extra": "^10.0.0",
45+
"graphql": "^15.5.1",
46+
"meow": "^10.1.1"
4747
},
4848
"devDependencies": {
4949
"@types/fs-extra": "^9.0.13",
@@ -59,13 +59,21 @@
5959
"typescript": "^4.7.4"
6060
},
6161
"engines": {
62-
"node": ">= 12"
62+
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
6363
},
6464
"jest": {
6565
"roots": [
6666
"src"
6767
],
68-
"preset": "ts-jest",
68+
"preset": "ts-jest/presets/default-esm",
69+
"globals": {
70+
"ts-jest": {
71+
"useESM": true
72+
}
73+
},
74+
"moduleNameMapper": {
75+
"^(\\.{1,2}/.*)\\.js$": "$1"
76+
},
6977
"testEnvironment": "node",
7078
"collectCoverage": true
7179
}

src/__tests__/diff.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import nock from "nock";
22
import path from "path";
3-
import { getDiff } from "../diff";
3+
import { getDiff } from "../diff.js";
44
import { getIntrospectionQuery, parse, print } from "graphql";
55
import introspectionResponse from "./fixtures/introspectionResponse.json";
66

src/cli.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
import meow from "meow";
44
import chalk from "chalk";
5-
import { createHtmlOutput } from "./html";
6-
import { getDiff, Headers } from "./diff";
5+
import { createHtmlOutput } from "./html.js";
6+
import { getDiff, Headers } from "./diff.js";
77

88
const cli = meow(
99
`
@@ -27,6 +27,7 @@ const cli = meow(
2727
$ graphql-schema-diff https://example.com/graphql schema.graphql -H 'Authorization: Bearer 123'
2828
`,
2929
{
30+
importMeta: import.meta,
3031
flags: {
3132
failOnDangerousChanges: {
3233
type: "boolean",

src/diff.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
DangerousChange,
66
BreakingChange,
77
} from "graphql";
8-
import { lexicographicSortSchema } from "graphql/utilities";
8+
import { lexicographicSortSchema } from "graphql/utilities/index.js";
99
import disparity from "disparity";
1010
import { loadSchema } from "@graphql-tools/load";
1111
import { UrlLoader } from "@graphql-tools/url-loader";

src/html.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
import { createRequire } from "module";
12
import path from "path";
23
import fs from "fs-extra";
34

5+
const require = createRequire(import.meta.url);
6+
47
const htmlTemplate = (diff: string): string => `<html>
58
<head>
69
<title>GraphQL Schema Diff</title>

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export { getDiff } from "./diff";
1+
export { getDiff } from "./diff.js";

tsconfig.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
{
22
"compilerOptions": {
3-
"target": "ES2019",
4-
"module": "commonjs",
3+
"target": "ES2020",
4+
"module": "ESNext",
55
"rootDir": "./src",
66
"outDir": "./dist",
7+
"moduleResolution": "node",
78
"strict": true,
89
"esModuleInterop": true,
910
"resolveJsonModule": true,

0 commit comments

Comments
 (0)