UNPKG

knip

Version:

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

22 lines (21 loc) 767 B
import { toDependency, toProductionEntry } from '../../util/input.js'; import { hasDependency } from '../../util/plugin.js'; import { getMdxPlugins } from './resolveFromAST.js'; const title = 'Next.js MDX'; const enablers = ['@next/mdx']; const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers); const config = ['next.config.{js,ts,cjs,mjs}']; const production = ['{src/,}mdx-components.{js,jsx,ts,tsx}']; const resolveFromAST = sourceFile => { const mdxPlugins = getMdxPlugins(sourceFile); return [...production.map(id => toProductionEntry(id)), ...Array.from(mdxPlugins).map(id => toDependency(id))]; }; const plugin = { title, enablers, isEnabled, config, production, resolveFromAST, }; export default plugin;