{"id":19226,"library":"babel-plugin-transform-vite-meta-glob","title":"babel-plugin-transform-vite-meta-glob","description":"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.","status":"active","version":"1.1.2","language":"javascript","source_language":"en","source_url":"https://github.com/OpenSourceRaidGuild/babel-vite","tags":["javascript","babel","vite","plugin","import","meta","glob","globEager","typescript"],"install":[{"cmd":"npm install babel-plugin-transform-vite-meta-glob","lang":"bash","label":"npm"},{"cmd":"yarn add babel-plugin-transform-vite-meta-glob","lang":"bash","label":"yarn"},{"cmd":"pnpm add babel-plugin-transform-vite-meta-glob","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"often used together in babel-preset-vite; not required standalone","package":"babel-plugin-transform-vite-meta-env","optional":true}],"imports":[{"note":"ESM default export since v1. For CJS, use default import via babel.config.js or dynamic require()","wrong":"const plugin = require('babel-plugin-transform-vite-meta-glob')","symbol":"default","correct":"import plugin from 'babel-plugin-transform-vite-meta-glob'"},{"note":"String syntax in Babel config is preferred; direct require works but may cause issues with module resolution","wrong":"plugins: [require('babel-plugin-transform-vite-meta-glob')]","symbol":"plugin as function","correct":"plugins: ['babel-plugin-transform-vite-meta-glob']"},{"note":"This package includes TypeScript definitions; import plugin as shown above and assign to variable with type PluginObj","symbol":"TypeScript types","correct":"import type { PluginObj } from '@babel/core'"}],"quickstart":{"code":"// babel.config.js\nmodule.exports = {\n  plugins: [\n    'babel-plugin-transform-vite-meta-glob'\n  ]\n};\n\n// src/modules.js\nconst modules = import.meta.glob('./fixtures/*.js');\n\n// After transformation, modules becomes:\n// {\n//   './fixtures/a.js': () => import('./fixtures/a.js'),\n//   './fixtures/b.js': () => import('./fixtures/b.js')\n// }\n\nexport default modules;","lang":"javascript","description":"Shows Babel config setup and glob import transformation output with dynamic imports."},"warnings":[{"fix":"Update to v1.1.2+ or manually replace backslashes in glob patterns.","message":"On Windows, generated paths use backslashes, causing issues. Fixed in 1.1.2, but ensure you have at least that version.","severity":"gotcha","affected_versions":"<1.1.2"},{"fix":"Replace import.meta.globEager('./path') with import.meta.glob('./path', { eager: true })","message":"import.meta.globEager is deprecated; use import.meta.glob with '{ eager: true }' instead.","severity":"deprecated","affected_versions":">=1.1.0"},{"fix":"Use a static string literal for the glob pattern.","message":"The plugin only transforms static glob patterns; dynamic expressions like import.meta.glob(someVar) are left untouched.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Install @babel/core@^7.0.0 and @babel/plugin-syntax-dynamic-import if needed.","message":"Eager imports with { eager: true } require a supporting Babel version that understands import() statements; ensure @babel/core is up to date.","severity":"gotcha","affected_versions":">=1.1.0"},{"fix":"Avoid using __glob__ prefixed variables in your code.","message":"The plugin uses __glob__* variable naming, which may conflict with user code. No change planned.","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":"Run npm install --save-dev babel-plugin-transform-vite-meta-glob and ensure Babel's config resolves from your project root.","cause":"Plugin not installed or Babel is looking in wrong node_modules.","error":"Error: Cannot find module 'babel-plugin-transform-vite-meta-glob'"},{"fix":"Use string reference in Babel config: plugins: ['babel-plugin-transform-vite-meta-glob'] instead of requiring directly.","cause":"Using CJS require() to import the ESM default export incorrectly.","error":"TypeError: (0 , _default.default) is not a function"},{"fix":"Install @babel/plugin-syntax-dynamic-import and add it to your plugins array.","cause":"Babel is not configured to handle dynamic import() syntax.","error":"SyntaxError: Unexpected token 'import'"},{"fix":"Use import.meta.glob with { eager: true } option, or update the plugin to v1.1.0+.","cause":"Using deprecated import.meta.globEager with a plugin version that doesn't support it yet.","error":"Error: .globEager is not a function"},{"fix":"Update to v1.1.2+ or use forward slashes in glob patterns.","cause":"Windows backslashes in glob pattern not normalized; affected versions <1.1.2.","error":"Error: Could not resolve glob pattern 'C:\\path'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}