lix-website/themes/lix/assets/bootstrap/node_modules/rollup-plugin-istanbul/dist/rollup-plugin-istanbul.mjs
2024-04-26 22:49:34 -06:00

32 lines
804 B
JavaScript

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;