Registry /
testing / babel-plugin-qunit-lazy-imports
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslnode 18–226 runs
build_error
glibcnode 18–226 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
default
✓ module.exports = {
plugins: [
['module:babel-plugin-qunit-lazy-imports', { startsWith: ['my-app/'] }]
]
};
✗ plugins: [['babel-plugin-qunit-lazy-imports', ...]]
Use 'module:' prefix when using babel.config.js in Node.js; not needed in .babelrc or when using require directly.
default
✓ const plugin = require('babel-plugin-qunit-lazy-imports');
CommonJS require works; no default import in ESM because the plugin does not export a named symbol.
plugin options
✓ [
'module:babel-plugin-qunit-lazy-imports',
{ startsWith: ['my-app/'], matches: [/.*\.lazy\..*/] }
]
✗ {
"plugins": [
["babel-plugin-qunit-lazy-imports", { startsWith: 'my-app/' }]
]
}
startsWith must be an array of strings; matches must be an array of RegExp. Both options are optional but at least one must be provided.
Shows basic setup with babel.config.js and example transformation of imports into lazy beforeEach imports.
// Install: npm add babel-plugin-qunit-lazy-imports --save-dev
// babel.config.js
module.exports = {
plugins: [
[
'module:babel-plugin-qunit-lazy-imports',
{
// Transform imports starting with 'my-app/' into lazy imports
startsWith: ['my-app/'],
// Also match any import matching regex (optional)
matches: [/.*\.lazy\..*/],
},
],
],
};
// Before transformation:
// import { foo } from 'my-app/foo';
// import { bar } from 'some-other-lib';
// import { baz } from './baz.lazy';
// After transformation:
// let foo, bar, baz;
// module('...', function(hooks) {
// hooks.beforeEach(async function() {
// const mod1 = await import('my-app/foo');
// foo = mod1.foo;
// const mod2 = await import('./baz.lazy');
// baz = mod2.baz;
// });
// });
// Note: only imports matching startsWith or matches are transformed
Errors
Common errors & fixes
Cannot find module 'babel-plugin-qunit-lazy-imports'
Package not installed or not in node_modules.
fixRun: npm add babel-plugin-qunit-lazy-imports --save-dev
Error: [BABEL] unknown: Plugin module:babel-plugin-qunit-lazy-imports requires @babel/core@^7.0.0 but was loaded with @babel/core@6.x.
Incompatible @babel/core version.
fixUpgrade @babel/core to ^7.0.0: npm upgrade @babel/core
TypeError: startsWith.filter is not a function
startsWith option is not an array.
fixChange startsWith to an array, e.g., startsWith: ['my-app/']
Audit
Dependencies
@babel/corerequiredRequired as a peer dependency for Babel plugin API