danvk / source-map-explorer

Analyze and debug space usage through source maps
Apache License 2.0
3.83k stars 100 forks source link

coverageRanges without using the filesystem #196

Open FranckFreiburger opened 3 years ago

FranckFreiburger commented 3 years ago

Description

According to the types definition file : https://github.com/danvk/source-map-explorer/blob/e25947078be7e59ebed47459d988eadf0f4a5110/src/lib/types.d.ts#L37-L42 Bundle accepts code, map and coverageRanges. But it seems to not being taken in account in the output html file.

Steps to reproduce

        // page is a puppeteer page object
    const coverageData = await page.coverage.stopJSCoverage();
    const bundle = {
        code: await fetch('http://127.0.0.1:8182/vue3-sfc-loader.js').then(res => res.buffer()),
        map: await fetch('http://127.0.0.1:8182/vue3-sfc-loader.js.map').then(res => res.buffer()),
        coverageRanges: coverageData.find(e => e.url === 'http://127.0.0.1:8182/vue3-sfc-loader.js').ranges;
    }
    const result = await explore(bundle, {
        output: { format: 'html' },
    });
    fs.writeFileSync('exploreOutput.html', result.output);

Expected behavior coverage information to be included in exploreOutput.html

Environment

FranckFreiburger commented 3 years ago

oh, I missed convertRangesToLinesRanges() !

Can you consider exporting it?

nikolay-borzov commented 3 years ago

Exporting convertRangesToLinesRanges() won't help. We need to allow passing coverage data as an alternative to a coverage file path. And yes, the typing is kind of wrong