A Vite plugin that automatically adds `/* @vite-ignore */` comments to dynamic import statements, suppressing warnings from Vite's import analysis. Version 1.0.2 supports Vite 6 and 7. Unlike manual commenting, it automates the process across specified files, useful for external packages or generated code. Ships TypeScript types and uses `unplugin-ast` for AST transformation. Released under MIT, with a focus on developer convenience.
npm install vite-plugin-ignore-dynamic-importsNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to configure the plugin in vite.config.ts, including the include option, and the effect on a dynamic import statement.
Provide a glob array in the include option to specify files to transform.
Upgrade to Vite 6+ or use an alternative if pinned to an older version.
Add appropriate globs (e.g., 'node_modules/**/*.js') if you need to process external packages.
Test plugin order; place this plugin after other AST plugins that may affect dynamic imports.
Run 'npm install vite-plugin-ignore-dynamic-imports' or the equivalent for your package manager.
Use 'import ignoreDynamicImports from ...' (default import) rather than '{ ignoreDynamicImports }'.Pass an object with an 'include' array, e.g., 'ignoreDynamicImports({ include: ['**/*.js'] })'.