mirror of https://github.com/sveltejs/svelte
parent
5441835d41
commit
7ac102a805
@ -1,19 +0,0 @@
|
||||
import { magic_string_bundle } from '../../helpers';
|
||||
|
||||
export const PREPEND = 'console.log("COUNTER_START")';
|
||||
export const APPEND = 'console.log("COUNTER_END")';
|
||||
|
||||
export default {
|
||||
js_map_sources: ['input.svelte', 'src/prepend.js', 'src/append.js'],
|
||||
preprocess: [
|
||||
{
|
||||
script: ({ content }) => {
|
||||
return magic_string_bundle([
|
||||
{ filename: 'src/prepend.js', code: PREPEND },
|
||||
{ filename: 'src/input.svelte', code: content },
|
||||
{ filename: 'src/append.js', code: APPEND }
|
||||
]);
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
@ -1,6 +0,0 @@
|
||||
<script lang="ts">
|
||||
let count = 3;
|
||||
</script>
|
||||
|
||||
<h1>Hello world!</h1>
|
||||
<div>Counter value: {count}</div>
|
@ -1,30 +0,0 @@
|
||||
import { getLocator } from 'locate-character';
|
||||
import { APPEND, PREPEND } from './_config';
|
||||
|
||||
export function test({ assert, input, preprocessed }) {
|
||||
|
||||
const assertMapped = (locateInput, code, filename) => {
|
||||
const sourceLoc = locateInput(code);
|
||||
const transformedLoc = preprocessed.locate_1(code);
|
||||
assert.deepEqual(
|
||||
preprocessed.mapConsumer.originalPositionFor(transformedLoc),
|
||||
{
|
||||
source: filename,
|
||||
name: null,
|
||||
line: sourceLoc.line + 1,
|
||||
column: sourceLoc.column
|
||||
},
|
||||
`failed to locate "${code}"`
|
||||
);
|
||||
};
|
||||
|
||||
// Transformed script, main file
|
||||
assertMapped(input.locate, 'let count = 3;', 'input.svelte');
|
||||
|
||||
// Untouched markup, main file
|
||||
assertMapped(input.locate, '<h1>Hello world!</h1>', 'input.svelte');
|
||||
|
||||
// External files
|
||||
assertMapped(getLocator(PREPEND), '"COUNTER_START"', 'src/prepend.js');
|
||||
assertMapped(getLocator(APPEND), '"COUNTER_END"', 'src/append.js');
|
||||
}
|
Loading…
Reference in new issue