Skip to content

Commit 85de461

Browse files
authored
feat: Extend local AST types with graphql’s types (#10)
* Build AST types that are always extending graphql’s types * Replace entire type when possible * Apply lint * Add optional graphql peer dependency
1 parent cf62ab9 commit 85de461

File tree

6 files changed

+582
-393
lines changed

6 files changed

+582
-393
lines changed

package.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"main": "./dist/graphql.web",
88
"module": "./dist/graphql.web.mjs",
99
"types": "./dist/graphql.web.d.ts",
10+
"sideEffects": false,
1011
"files": [
1112
"LICENSE",
1213
"README.md",
@@ -21,7 +22,14 @@
2122
},
2223
"./package.json": "./package.json"
2324
},
24-
"sideEffects": false,
25+
"peerDependencies": {
26+
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0"
27+
},
28+
"peerDependenciesMeta": {
29+
"graphql": {
30+
"optional": true
31+
}
32+
},
2533
"public": true,
2634
"keywords": [
2735
"graphql",

scripts/rollup.config.mjs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,17 @@ const dtsConfig = {
150150
output: {
151151
dir: './dist',
152152
entryFileNames: '[name].d.ts',
153-
format: 'es'
153+
format: 'es',
154+
plugins: [
155+
{
156+
renderChunk(code, chunk) {
157+
if (chunk.fileName.endsWith('d.ts')) {
158+
const gqlImportRe = /(import\s+(?:[*\s{}\w\d]+)\s*from\s*'graphql';?)/g;
159+
return code.replace(gqlImportRe, x => '/*!@ts-ignore*/\n' + x);
160+
}
161+
},
162+
},
163+
],
154164
},
155165
};
156166

0 commit comments

Comments
 (0)