{"id":19227,"library":"babel-plugin-transform-vite-meta-hot","title":"Babel Plugin Transform Vite Meta Hot","description":"A Babel plugin that emulates Vite's import.meta.hot API for non-Vite environments, primarily used in test runners like Jest or Mocha. Version 1.0.0 is the initial stable release (January 2023), with no subsequent updates. It transforms import.meta.hot calls into module.hot equivalents, enabling HMR-like code to run in Node.js. Unlike full Vite presets, this is a focused plugin for HMR simulation only. It ships TypeScript type definitions and is part of the babel-vite suite.","status":"active","version":"1.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/OpenSourceRaidGuild/babel-vite","tags":["javascript","babel","vite","plugin","import","meta","hot","typescript"],"install":[{"cmd":"npm install babel-plugin-transform-vite-meta-hot","lang":"bash","label":"npm"},{"cmd":"yarn add babel-plugin-transform-vite-meta-hot","lang":"bash","label":"yarn"},{"cmd":"pnpm add babel-plugin-transform-vite-meta-hot","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency for plugin transformation","package":"@babel/core","optional":false}],"imports":[{"note":"ESM works; CJS require is also supported due to dual package support.","wrong":"const plugin = require('babel-plugin-transform-vite-meta-hot')","symbol":"default export","correct":"import plugin from 'babel-plugin-transform-vite-meta-hot'"}],"quickstart":{"code":"// Install: npm install --save-dev babel-plugin-transform-vite-meta-hot\n// In .babelrc or babel.config.js:\n{\n  \"plugins\": [\"babel-plugin-transform-vite-meta-hot\"]\n}\n\n// Source code with Vite HMR:\nif (import.meta.hot) {\n  import.meta.hot.accept((newModule) => {\n    console.log('HMR update');\n  });\n}\n\n// After Babel transform:\nif (module.hot) {\n  module.hot.accept((newModule) => {\n    console.log('HMR update');\n  });\n}\n\n// Use with Jest: add to jest.config.js transformIgnorePatterns or babel config.","lang":"typescript","description":"Shows setup, input with import.meta.hot, and transformed output using module.hot."},"warnings":[{"fix":"Use babel-plugin-transform-vite-meta-env or babel-plugin-transform-vite-meta-glob for those respectively.","message":"Only transforms import.meta.hot, not other Vite meta properties like import.meta.env or import.meta.glob.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Add a conditional check like if (typeof module.hot !== 'undefined') before using the transformed code.","message":"The transformation is an approximation; module.hot may not be defined in all environments, causing runtime errors.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Switch to babel-preset-vite which includes this plugin and others.","message":"No active development; last release 1.0.0 over a year ago. Consider using babel-preset-vite for comprehensive Vite compatibility.","severity":"deprecated","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Add '@babel/plugin-syntax-import-meta' or use babel-preset-vite which includes it.","cause":"Babel parser doesn't recognize import.meta syntax; needs appropriate plugin or preset.","error":"SyntaxError: /path/to/file.js: Support for the experimental syntax 'importMeta' isn't currently enabled"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}