|
@ -545,22 +545,26 @@ export default class Module { |
|
|
// should be split up. Otherwise, we may end up including code we
|
|
|
// should be split up. Otherwise, we may end up including code we
|
|
|
// don't need, just because an unwanted declarator is included
|
|
|
// don't need, just because an unwanted declarator is included
|
|
|
if ( node.type === 'VariableDeclaration' && node.declarations.length > 1 ) { |
|
|
if ( node.type === 'VariableDeclaration' && node.declarations.length > 1 ) { |
|
|
throw new Error( 'TODO' ); |
|
|
|
|
|
// node.declarations.forEach( declarator => {
|
|
|
node.declarations.forEach( ( declarator, i ) => { |
|
|
//const magicString = this.magicString.snip( declarator.start, declarator.end ).trim();
|
|
|
//const magicString = this.magicString.snip( declarator.start, declarator.end ).trim();
|
|
|
// magicString.prepend( `${node.kind} ` ).append( ';' );
|
|
|
const nextDeclarator = node.declarations[ i + 1 ]; |
|
|
//
|
|
|
|
|
|
// const syntheticNode = {
|
|
|
if ( nextDeclarator ) { |
|
|
// type: 'VariableDeclaration',
|
|
|
this.magicString.overwrite( declarator.end, nextDeclarator.start, `;\n${node.kind} ` ); // TODO indentation
|
|
|
// kind: node.kind,
|
|
|
} |
|
|
// start: node.start,
|
|
|
|
|
|
// end: node.end,
|
|
|
const syntheticNode = { |
|
|
// declarations: [ declarator ]
|
|
|
type: 'VariableDeclaration', |
|
|
// };
|
|
|
kind: node.kind, |
|
|
//
|
|
|
start: node.start, |
|
|
// const statement = new Statement( syntheticNode, magicString, this, statements.length );
|
|
|
end: node.end, |
|
|
// statements.push( statement );
|
|
|
declarations: [ declarator ] |
|
|
// });
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
const statement = new Statement( syntheticNode, this, node.start, node.end ); // TODO this is almost certainly wrong...
|
|
|
|
|
|
statements.push( statement ); |
|
|
|
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
else { |
|
|
else { |
|
@ -707,7 +711,7 @@ export default class Module { |
|
|
// previousIndex = statement.index;
|
|
|
// previousIndex = statement.index;
|
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
return magicString; |
|
|
return magicString.trim(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
suggestName ( defaultOrBatch, suggestion ) { |
|
|
suggestName ( defaultOrBatch, suggestion ) { |
|
|