Mirror: The highly customizable and versatile GraphQL client with which you add on features like normalized caching as you grow.
at main 564 B view raw
1import { createFilter } from '@rollup/pluginutils'; 2 3function cleanup() { 4 const emptyImportRe = /import\s+(?:'[^']+'|"[^"]+")\s*;?/g; 5 const gqlImportRe = /(import\s+(?:[*\s{}\w\d]+)\s*from\s*'graphql';?)/g; 6 const dtsFilter = createFilter(/\.d\.ts(\.map)?$/, null, { resolve: false }); 7 8 return { 9 name: 'cleanup', 10 11 renderChunk(input, chunk) { 12 if (dtsFilter(chunk.fileName)) { 13 return input 14 .replace(emptyImportRe, '') 15 .replace(gqlImportRe, x => '/*@ts-ignore*/\n' + x); 16 } 17 }, 18 }; 19} 20 21export default cleanup;