babel-plugin-transform-vite-meta-glob 1.0.0
Install from the command line:
Learn more about npm packages
$ npm install @fond-of/babel-plugin-transform-vite-meta-glob@1.0.0
Install via package.json:
"@fond-of/babel-plugin-transform-vite-meta-glob": "1.0.0"
About this version
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.
In
const modules = import.meta.glob('./path/to/files/**/*')
// eager
const eagerModules = import.meta.glob('./path/to/files/**/*', { eager: true })
// deprecated eager
const deprecatedEagerModules = import.meta.globEager('./path/to/files/**/*')
Out
For the purposes of this example, assume there are 3 files,
files1.js
,files2.js
andfile3.js
at 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')
}
// eager
import * as __glob__0_0 from './path/to/files/file1.js'
import * as __glob__0_1 from './path/to/files/file2.js'
import * as __glob__0_2 from './path/to/files/file3.js'
const eagerModules = {
'./path/to/files/file1.js': __glob__0_1,
'./path/to/files/file2.js': __glob__0_2,
'./path/to/files/file3.js': __glob__0_3
}
// deprecated eager
const deprecatedEagerModules = {
'./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')
}
npm install --save-dev babel-plugin-transform-vite-meta-glob
{
"plugins": ["babel-plugin-transform-vite-meta-glob"]
}
babel --plugins babel-plugin-transform-vite-meta-glob script.js
require('@babel/core').transformSync('code', {
plugins: ['babel-plugin-transform-vite-meta-glob']
})
Details
- babel-plugin-transform-vite-meta-glob
-
fond-of
- 8 months ago
- MIT
- 9 dependencies
Assets
- babel-plugin-transform-vite-meta-glob-1.0.0.tgz
Download activity
- Total downloads 1,164
- Last 30 days 282
- Last week 55
- Today 5