Babel plugin that emulates Vite's import.meta.glob and import.meta.globEager functionality for use in non-Vite environments like Node.js test runners. Version 1.1.2 is current, released January 2024. Regularly updated with bug fixes and feature support, including eager imports via options. It provides an approximation of Vite's glob import transformation, not for production use. Differentiates from Vite itself by enabling these features in plain Babel pipelines, often used with Jest or Mocha.
npm install babel-plugin-transform-vite-meta-globVerified import paths — ran on the pinned version, not inferred.
Shows Babel config setup and glob import transformation output with dynamic imports.
Update to v1.1.2+ or manually replace backslashes in glob patterns.
Replace import.meta.globEager('./path') with import.meta.glob('./path', { eager: true })Use a static string literal for the glob pattern.
Install @babel/core@^7.0.0 and @babel/plugin-syntax-dynamic-import if needed.
Avoid using __glob__ prefixed variables in your code.
Run npm install --save-dev babel-plugin-transform-vite-meta-glob and ensure Babel's config resolves from your project root.
Use string reference in Babel config: plugins: ['babel-plugin-transform-vite-meta-glob'] instead of requiring directly.
Install @babel/plugin-syntax-dynamic-import and add it to your plugins array.
Use import.meta.glob with { eager: true } option, or update the plugin to v1.1.0+.Update to v1.1.2+ or use forward slashes in glob patterns.