Babel Plugin Shopware Vite Meta Glob
raw JSON → 0.0.5 verified Sat Apr 25 auth: no javascript
A Babel plugin (v0.0.5, latest stable) that transforms `import.meta.glob()` calls into dynamic module imports for Shopware and Vite-like environments. It supports eager and lazy loading, array patterns, and file path normalization. Notable differentiators: heavily inspired by OpenSourceRaidGuild/babel-vite but handles import meta statements differently; explicitly not recommended for production use due to performance, security, and unexpected behavior risks. Supports Node >=20 and ships TypeScript types. Last release at 0.0.5, release cadence is unknown but appears experimental.
Common errors
error Error: Cannot find module 'babel-plugin-shopware-vite-meta-glob' ↓
cause Plugin not installed or referenced incorrectly in Babel config.
fix
Run 'npm install babel-plugin-shopware-vite-meta-glob --save-dev' and ensure the string 'shopware-vite-meta-glob' is in plugins array.
error TypeError: glob.sync is not a function ↓
cause Outdated glob dependency (v8+) where sync returns a function with newer API.
fix
Downgrade glob to v7 or update plugin (if fix exists). Check package.json for glob version.
error The plugin may generate duplicate keys in module object ↓
cause File paths with different slashes on Windows vs Unix can produce duplicate entries.
fix
Normalize paths manually or ensure consistent slash direction in glob patterns.
Warnings
gotcha Not recommended for production use due to performance overhead, security risks, and unexpected behavior. ↓
fix Use the native Vite import.meta.glob if possible. Only use this plugin in development/experimental contexts.
gotcha Supports { import: 'default' } only in combination with eager: true; otherwise ignored. ↓
fix Ensure eager: true when using import: 'default'.
gotcha import.meta.glob with { eager: false } is not transformed; left as-is in output. ↓
fix Use eager: true or omit the eager option for transformation. eager: false is not supported.
gotcha The query option is ignored and not passed through. ↓
fix Do not use query: option as it will be dropped.
Install
npm install babel-plugin-shopware-vite-meta-glob yarn add babel-plugin-shopware-vite-meta-glob pnpm add babel-plugin-shopware-vite-meta-glob Imports
- default wrong
import plugin from 'babel-plugin-shopware-vite-meta-glob' (not needed, config-based)correctNo explicit import; add to .babelrc plugins: ['babel-plugin-shopware-vite-meta-glob'] - transform
Not exported; use programmatic API via @babel/core - viteMetaGlob wrong
import { viteMetaGlob } from 'babel-plugin-shopware-vite-meta-glob'correctNo such export; use the string name in Babel config
Quickstart
// Install and configure
npm install babel-plugin-shopware-vite-meta-glob --save-dev
// .babelrc or babel.config.json
{
"plugins": ["shopware-vite-meta-glob"]
}
// Input file (e.g., src/modules.js)
const modules = import.meta.glob('./components/*.vue', { eager: true });
// After Babel transformation, output will be:
const modules = (function () {
const __glob__0_0 = require('./components/Button.vue');
const __glob__0_1 = require('./components/Modal.vue');
const __glob__context__ = {
'./components/Button.vue': __glob__0_0,
'./components/Modal.vue': __glob__0_1,
};
return __glob__context__;
})();