[fix] handle preprocess with empty sourcemaps (#6757)

pull/6759/head
Bjorn Lu 3 years ago committed by GitHub
parent dad0284771
commit b845307698
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -79,12 +79,15 @@ function processed_content_to_code(processed: Processed, location: SourceLocatio
if (processed.map) {
decoded_map = decode_map(processed);
// decoded map may not have sources for empty maps like `{ mappings: '' }`
if (decoded_map.sources) {
// offset only segments pointing at original component source
const source_index = decoded_map.sources.indexOf(file_basename);
if (source_index !== -1) {
sourcemap_add_offset(decoded_map, location, source_index);
}
}
}
return MappedCode.from_processed(processed.code, decoded_map);
}

@ -0,0 +1,7 @@
export default {
preprocess: {
style: ({ content }) => {
return { code: content, map: { mappings: '' } };
}
}
};

@ -0,0 +1,7 @@
<div class="foo">bar</div>
<style>
.foo {
color: red;
}
</style>

@ -0,0 +1,7 @@
<div class="foo">bar</div>
<style>
.foo {
color: red;
}
</style>
Loading…
Cancel
Save