Skip to content

Commit

Permalink
Format d.ts output
Browse files Browse the repository at this point in the history
  • Loading branch information
kitten committed Jan 10, 2024
1 parent c8c60eb commit 51c46d7
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion scripts/rollup.config.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { readFileSync } from 'node:fs';

import * as prettier from 'prettier';
import commonjs from '@rollup/plugin-commonjs';
import resolve from '@rollup/plugin-node-resolve';
import babel from '@rollup/plugin-babel';
Expand Down Expand Up @@ -149,7 +150,18 @@ const dtsConfig = {
renderChunk(code, chunk) {
if (chunk.fileName.endsWith('d.ts')) {
const gqlImportRe = /(import\s+(?:[*\s{}\w\d]+)\s*from\s*'graphql';?)/g;
return code.replace(gqlImportRe, x => '/*!@ts-ignore*/\n' + x);
code = code.replace(gqlImportRe, x => '/*!@ts-ignore*/\n' + x);

code = prettier.format(code, {
filepath: chunk.fileName,
parser: 'typescript',
singleQuote: true,
tabWidth: 2,
printWidth: 100,
trailingComma: 'es5',
});

return code;
}
},
},
Expand Down

0 comments on commit 51c46d7

Please sign in to comment.