|
|
@ -1,5 +1,5 @@
|
|
|
|
import remapper from '@ampproject/remapping';
|
|
|
|
import remapper from '@ampproject/remapping';
|
|
|
|
import { decode } from 'sourcemap-codec';
|
|
|
|
import { decode as sourcemap_decode } from 'sourcemap-codec';
|
|
|
|
import { getLocator } from 'locate-character';
|
|
|
|
import { getLocator } from 'locate-character';
|
|
|
|
import { StringWithSourcemap, sourcemap_add_offset } from '../utils/string_with_sourcemap';
|
|
|
|
import { StringWithSourcemap, sourcemap_add_offset } from '../utils/string_with_sourcemap';
|
|
|
|
|
|
|
|
|
|
|
@ -80,7 +80,7 @@ export default async function preprocess(
|
|
|
|
let generated;
|
|
|
|
let generated;
|
|
|
|
if (processed.map) {
|
|
|
|
if (processed.map) {
|
|
|
|
const full_map = typeof processed.map === "string" ? JSON.parse(processed.map) : processed.map;
|
|
|
|
const full_map = typeof processed.map === "string" ? JSON.parse(processed.map) : processed.map;
|
|
|
|
const decoded_map = { ...full_map, mappings: decode(full_map.mappings) };
|
|
|
|
const decoded_map = { ...full_map, mappings: sourcemap_decode(full_map.mappings) };
|
|
|
|
const processed_offset = get_location(offset + prefix.length);
|
|
|
|
const processed_offset = get_location(offset + prefix.length);
|
|
|
|
generated = StringWithSourcemap.from_generated(processed.code, sourcemap_add_offset(processed_offset, decoded_map));
|
|
|
|
generated = StringWithSourcemap.from_generated(processed.code, sourcemap_add_offset(processed_offset, decoded_map));
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
@ -185,7 +185,7 @@ export default async function preprocess(
|
|
|
|
get_location = getLocator(source);
|
|
|
|
get_location = getLocator(source);
|
|
|
|
const res = await replace_async(
|
|
|
|
const res = await replace_async(
|
|
|
|
source,
|
|
|
|
source,
|
|
|
|
/<!--[^]*?-->|<style(\s[^]*?)?>([^]*?)<\/style>/gi,
|
|
|
|
/<!--[^]*?-->|<style(\s[^]*?)?(?:>([^]*?)<\/style>|\/>)/gi,
|
|
|
|
async (match, attributes = '', content, offset) => {
|
|
|
|
async (match, attributes = '', content, offset) => {
|
|
|
|
const no_change = () => StringWithSourcemap.from_source(
|
|
|
|
const no_change = () => StringWithSourcemap.from_source(
|
|
|
|
filename, match, get_location(offset));
|
|
|
|
filename, match, get_location(offset));
|
|
|
|