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.
npm install babel-plugin-transform-vite-meta-hotVerified import paths — ran on the pinned version, not inferred.
Shows setup, input with import.meta.hot, and transformed output using module.hot.
Use babel-plugin-transform-vite-meta-env or babel-plugin-transform-vite-meta-glob for those respectively.
Add a conditional check like if (typeof module.hot !== 'undefined') before using the transformed code.
Switch to babel-preset-vite which includes this plugin and others.
Add '@babel/plugin-syntax-import-meta' or use babel-preset-vite which includes it.