JSPM

babel-plugin-transform-vite-meta-hot

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 79812
  • Score
    100M100P100Q183236F
  • License MIT

babel plugin that emulates vite's import.meta.hot functionality

Package Exports

  • babel-plugin-transform-vite-meta-hot
  • babel-plugin-transform-vite-meta-hot/lib/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (babel-plugin-transform-vite-meta-hot) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

babel-plugin-transform-vite-meta-hot

Build Status codecov version downloads MIT License

PRs Welcome Code of Conduct Discord

Watch on GitHub Star on GitHub Tweet

Please note: this plugin is intended to provide an approximation of some of Vite specific transformations when running the code in non-Vite environment, for example, running tests with a NodeJS based test runner.

The functionality within these transformations should not be relied upon in production.

Example

In

if (import.meta.hot) {
  import.meta.hot.accept(callback);
}

Out

if (module.hot) {
  module.hot.accept(callback);
}

Installation

npm install --save-dev babel-plugin-transform-vite-meta-hot

Usage

{
  "plugins": ["babel-plugin-transform-vite-meta-hot"]
}

Via CLI

babel --plugins babel-plugin-transform-vite-meta-hot script.js

Via Node API

require('@babel/core').transformSync('code', {
  plugins: ['babel-plugin-transform-vite-meta-hot']
})