GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||
GeezerVison is showing github.com — unplugin's transform emits a line-only sourcemap (generateMap() with no options), silently collapsing code coverage · Issue #562 · unjs/unimport Closed DescriptionEnvironment
Describe the bugThe unplugin transform builds its sourcemap with a bare https://github.com/unjs/unimport/blob/main/src/unplugin.ts#L62-L65 return { code: s.toString(), map: s.generateMap(), } With no options, Auto-imports are injected at the top of the file, so line numbers still line up and most things look fine. But every column collapses to 0, which breaks anything that consumes columns. The concrete failure we hit is V8 code coverage ( Reproductionimport MagicString from 'magic-string' import { createUnimport } from 'unimport' const ctx = createUnimport({ presets: [{ from: 'my-lib', imports: ['helper'] }] }) await ctx.init() const code = [ 'export function classify(n) {', ' const h = helper();', ' if (n > 10) return h.big;', ' if (n > 0) return h.small;', ' return h.zero;', '}', '', ].join('\n') const run = async (opts) => { const s = new MagicString(code) await ctx.injectImports(s, '/src/a.ts') return s.generateMap(opts) } const segments = (m) => m.mappings.split(';').map((l) => (l ? l.split(',').length : 0)) const plain = await run(undefined) // what unplugin emits today const hires = await run({ hires: 'boundary', source: '/src/a.ts' }) console.log(plain.sources, segments(plain)) console.log(hires.sources, segments(hires)) Output: End-to-end effect, measured on a four-branch module using one auto-imported global with a test covering a single branch:
Expected behaviourThe transform emits a sourcemap with column-level mappings and a populated Suggested fix return {
code: s.toString(),
- map: s.generateMap(),
+ map: s.generateMap({ hires: 'boundary', source: id }),
}
If you'd rather not change the default, exposing the Happy to open a PR for whichever you prefer. Downstream contextwxt-dev/wxt#2604 — WXT is currently working around this by owning the transform so it can pass the options itself. Activity
MetadataMetadataAssigneesLabelsNo labels TypeProjectsMilestoneRelationshipsDevelopmentIssue actions | |||||||||
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |