{"id":22853,"library":"vite-plugin-strip-comments","title":"vite-plugin-strip-comments","description":"Vite plugin to strip comments in production builds, with options to preserve legal comments or JSDoc. Current stable version is 0.0.10 (released 2025-03-17). Targets Node >=20, requires pnpm >=9.10.0 or Deno >=2.0.4. Compatible with Rollup, Rolldown, tsup, and tsdown. Differentiates from built-in minify by removing stubborn comments like istanbul ignore flags. Provides three stripping modes: all, keep-legal (default), and keep-jsdoc. Ships TypeScript types. Early stage (low version), use with caution. GitHub: https://github.com/thednp/vite-plugin-strip-comments.","status":"active","version":"0.0.10","language":"javascript","source_language":"en","source_url":"https://github.com/thednp/vite-plugin-strip-comments","tags":["javascript","vite","rollup","rolldown","tsup","tsdown","strip","comments","typescript"],"install":[{"cmd":"npm install vite-plugin-strip-comments","lang":"bash","label":"npm"},{"cmd":"yarn add vite-plugin-strip-comments","lang":"bash","label":"yarn"},{"cmd":"pnpm add vite-plugin-strip-comments","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"ESM-only package; dynamic import via import() works; named import not supported.","wrong":"const strip = require('vite-plugin-strip-comments')","symbol":"strip","correct":"import strip from 'vite-plugin-strip-comments'"},{"note":"Default export only; braces cause undefined.","wrong":"import { strip } from 'vite-plugin-strip-comments'","symbol":"strip","correct":"import strip from 'vite-plugin-strip-comments'"},{"note":"Unnecessary but works; simpler to use default import.","wrong":"import { default as strip } from 'vite-plugin-strip-comments'","symbol":"strip","correct":"import strip from 'vite-plugin-strip-comments'"}],"quickstart":{"code":"// vite.config.ts\nimport { defineConfig } from 'vite'\nimport strip from 'vite-plugin-strip-comments'\n\nexport default defineConfig({\n  plugins: [\n    strip({ type: 'keep-legal', enforce: 'pre' })\n  ]\n})","lang":"typescript","description":"Minimal Vite config using strip-comments plugin with keep-legal mode to preserve copyright/legal headers."},"warnings":[{"fix":"Enable only for production builds, disable other comment-stripping plugins to avoid double processing.","message":"Plugin is experimental; may strip important comments or cause build issues. Test thoroughly.","severity":"gotcha","affected_versions":"<=0.0.10"},{"fix":"Update to at least version 0.0.9.","message":"Does not respect /*! legal comment marker correctly before v0.0.9; use v0.0.9+.","severity":"gotcha","affected_versions":"<0.0.9"},{"fix":"Set enforce to 'pre' to strip before other transforms, or 'post' for after.","message":"Enforce option only accepts 'pre' (default) or 'post'; misconfiguration may cause unintended order.","severity":"gotcha","affected_versions":">=0.0.7"},{"fix":"Use exact string values as documented.","message":"Type option expects exact strings: 'none', 'keep-legal', or 'keep-jsdoc'; typos are silently ignored.","severity":"gotcha","affected_versions":">=0.0.7"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Install the package and ensure Node >=20.","cause":"Package not installed or version incompatible with Node <20.","error":"Error: Module not found: Error: Can't resolve 'vite-plugin-strip-comments'"},{"fix":"Use default import: import strip from 'vite-plugin-strip-comments'","cause":"Named import used instead of default import.","error":"TypeError: strip is not a function"},{"fix":"Call strip() without arguments or with a valid options object: strip({ type: 'keep-legal' })","cause":"Options object passed incorrectly as empty or invalid.","error":"TypeError: Cannot read properties of undefined (reading 'type')"},{"fix":"Use dynamic import(): const strip = await import('vite-plugin-strip-comments');","cause":"Using require() in a CommonJS context; package is ESM-only.","error":"Unexpected token 'export'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}