better sourcemaps

pull/31/head
Rich-Harris 8 years ago
parent 48fb01cf7e
commit d7dc941ae8

@ -177,6 +177,8 @@ export default function generate ( parsed, template ) {
if ( chunk.type === 'Text' ) { if ( chunk.type === 'Text' ) {
return JSON.stringify( chunk.data ); return JSON.stringify( chunk.data );
} else { } else {
addSourcemapLocations( chunk.expression );
contextualise( code, chunk.expression, current.contexts, current.indexes, helpers ); contextualise( code, chunk.expression, current.contexts, current.indexes, helpers );
return `( [✂${chunk.expression.start}-${chunk.expression.end}✂] )`; return `( [✂${chunk.expression.start}-${chunk.expression.end}✂] )`;
} }
@ -318,6 +320,8 @@ export default function generate ( parsed, template ) {
${current.target}.appendChild( ${name} ); ${current.target}.appendChild( ${name} );
` ); ` );
addSourcemapLocations( node.expression );
const usedContexts = contextualise( code, node.expression, current.contexts, current.indexes, helpers ); const usedContexts = contextualise( code, node.expression, current.contexts, current.indexes, helpers );
const snippet = `[✂${node.expression.start}-${node.expression.end}✂]`; const snippet = `[✂${node.expression.start}-${node.expression.end}✂]`;
@ -357,6 +361,8 @@ export default function generate ( parsed, template ) {
var ${name} = null; var ${name} = null;
` ); ` );
addSourcemapLocations( node.expression );
const usedContexts = contextualise( code, node.expression, current.contexts, current.indexes, helpers ); const usedContexts = contextualise( code, node.expression, current.contexts, current.indexes, helpers );
const snippet = `[✂${node.expression.start}-${node.expression.end}✂]`; const snippet = `[✂${node.expression.start}-${node.expression.end}✂]`;
@ -399,14 +405,11 @@ export default function generate ( parsed, template ) {
${name}_anchor.parentNode.removeChild( ${name}_anchor ); ${name}_anchor.parentNode.removeChild( ${name}_anchor );
` ); ` );
current = { current = Object.assign( {}, current, {
useAnchor: true, useAnchor: true,
name: renderer, name: renderer,
target: 'target', target: 'target',
contexts: current.contexts,
contextChain: current.contextChain,
initStatements: [], initStatements: [],
updateStatements: [], updateStatements: [],
teardownStatements: [], teardownStatements: [],
@ -414,7 +417,7 @@ export default function generate ( parsed, template ) {
counter: counter(), counter: counter(),
parent: current parent: current
}; });
}, },
leave () { leave () {
@ -438,6 +441,8 @@ export default function generate ( parsed, template ) {
const ${name}_fragment = document.createDocumentFragment(); const ${name}_fragment = document.createDocumentFragment();
` ); ` );
addSourcemapLocations( node.expression );
contextualise( code, node.expression, current.contexts, current.indexes, helpers ); contextualise( code, node.expression, current.contexts, current.indexes, helpers );
const snippet = `[✂${node.expression.start}-${node.expression.end}✂]`; const snippet = `[✂${node.expression.start}-${node.expression.end}✂]`;

Loading…
Cancel
Save