New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@magicmock/unplugin

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@magicmock/unplugin

Universal plugin for Magic Mock - works with Vite, Webpack, Rollup, and esbuild

latest
Source
npmnpm
Version
0.7.0
Version published
Maintainers
1
Created
Source

@magicmock/unplugin

Universal bundler plugin for Magic Mock

Works with Vite, Webpack, Rollup, and esbuild.

Installation

pnpm add -D @magicmock/unplugin

Usage

Vite

// vite.config.ts
import { defineConfig } from 'vite'
import MagicMock from '@magicmock/unplugin/vite'

export default defineConfig({
  plugins: [MagicMock()],
})

Webpack

// webpack.config.js
const MagicMock = require('@magicmock/unplugin/webpack')

module.exports = {
  plugins: [MagicMock()],
}

Rollup

// rollup.config.js
import MagicMock from '@magicmock/unplugin/rollup'

export default {
  plugins: [MagicMock()],
}

esbuild

// esbuild.config.js
import MagicMock from '@magicmock/unplugin/esbuild'

require('esbuild').build({
  plugins: [MagicMock()],
})

Options

interface MagicMockOptions {
  /**
   * Cache directory path
   * @default '.request-cache'
   */
  cacheDir?: string

  /**
   * Enable/disable the plugin
   * @default true
   */
  enabled?: boolean
}

How It Works

  • Injects client script into your HTML
  • Sets up dev server endpoints for caching (/api/__record, /api/__get-cache)
  • Intercepts fetch and XMLHttpRequest calls for recording and mocking
  • Provides UI controls for toggling record/mock modes
  • Supports GET, POST, PUT, DELETE methods with request body recording

License

MIT © Charley

Keywords

unplugin

FAQs

Package last updated on 13 Dec 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts