UNPKG

knip

Version:

Find and fix unused dependencies, exports and files in your TypeScript and JavaScript projects

12 lines (11 loc) 367 B
const directiveMatcher = /@(?:import|config|plugin)\s+['"]([^'"]+)['"][^;]*;/g; const compiler = (text) => { const imports = []; let match; let index = 0; while ((match = directiveMatcher.exec(text))) if (match[1]) imports.push(`import _$${index++} from '${match[1]}';`); return imports.join('\n'); }; export default compiler;