Rollup plugin (v1.0.8) for mocking ESM imports during bundling, using `__mocks__` directories (like Jest) or a custom `node_mockdules` folder. Designed for pre-compilation testing scenarios (e.g., Svelte components with JSDOM), it intercepts resolved module IDs before other Rollup plugins. Configuration options include `mockall`, `ignore`, and `mock` patterns. Requires Rollup ^0.66.6 as peer dependency. Ships TypeScript types. Release cadence: low (last updated 2019).
npm install rollup-plugin-mock-importsVerified import paths — ran on the pinned version, not inferred.
Shows basic Rollup config with mockImports placed before other plugins, enabling global mocking with exceptions.
Use Rollup ^0.66.6 or test compatibility with newer versions; consider forking or updating if needed.
Place mockImports() first in the plugins array.
Ensure imports are static ESM statements; convert dynamic imports to static or use alternative mocking.
Do not rename the folder; the path is hardcoded relative to node_modules. For custom paths, use nodePath option.
npm install --save-dev rollup@^0.66.6
Use import { mockImports } from 'rollup-plugin-mock-imports';