lix-website/themes/lix/assets/bootstrap/node_modules/rollup-plugin-istanbul/dist/rollup-plugin-istanbul.mjs

32 lines
804 B
JavaScript
Raw Normal View History

2024-04-27 03:39:10 +00:00
import { createFilter } from '@rollup/pluginutils';
import istanbul from 'istanbul-lib-instrument';
function index (options = {}) {
const filter = createFilter(options.include, options.exclude);
return {
name: 'istanbul',
transform (code, id) {
if (!filter(id)) return;
let instrumenter;
const instrumenterConfig = Object.assign({
esModules: true,
compact: true,
produceSourceMap: true,
autoWrap: true,
preserveComments: true
}, options.instrumenterConfig);
instrumenter = new (options.instrumenter || istanbul).createInstrumenter(instrumenterConfig);
code = instrumenter.instrumentSync(code, id);
const map = instrumenter.lastSourceMap();
return { code, map };
}
};
}
export default index;