You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
svelte/test/sourcemaps/helpers.ts

21 lines
601 B

import MagicString from 'magic-string';
export function magic_string_preprocessor_result(filename: string, src: MagicString) {
return {
code: src.toString(),
map: src.generateMap({
source: filename,
hires: true,
includeContent: false
})
};
}
export function magic_string_replace_all(src: MagicString, search: string, replace: string) {
let idx = src.original.indexOf(search);
if (idx == -1) throw new Error('search not found in src');
do {
src.overwrite(idx, idx + search.length, replace, { storeName: true });
} while ((idx = src.original.indexOf(search, idx + 1)) != -1);
}