Package Exports
- babel-plugin-transform-vite-meta-glob
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-glob) 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-glob
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
const modules = import.meta.glob('./path/to/files/**/*')
const eagerModules = import.meta.globEager('./path/to/files/**/*')Out
For the purposes of this example, assume there are 3 files,
files1.js,files2.jsandfile3.jsat the path of./path/to/files/relative the files being transformed.
const modules = {
'./path/to/files/file1.js': () => import('./path/to/files/file1.js'),
'./path/to/files/file2.js': () => import(('./path/to/files/file2.js'),
'./path/to/files/file3.js': () => import(('./path/to/files/file3.js')
}
const eagerModules = {
'./path/to/files/file1.js': require('./path/to/files/file1.js'),
'./path/to/files/file2.js': require('./path/to/files/file2.js'),
'./path/to/files/file3.js': require('./path/to/files/file3.js')
}Installation
npm install --save-dev babel-plugin-transform-vite-meta-globUsage
With a configuration file (Recommended)
{
"plugins": ["babel-plugin-transform-vite-meta-glob"]
}Via CLI
babel --plugins babel-plugin-transform-vite-meta-glob script.jsVia Node API
require('@babel/core').transformSync('code', {
plugins: ['babel-plugin-transform-vite-meta-glob']
})