pull/3539/head
Richard Harris 6 years ago
parent 9e1bc908d3
commit 6616b17c7a

@ -44,16 +44,6 @@ childKeys.EachBlock = childKeys.IfBlock = ['children', 'else'];
childKeys.Attribute = ['value'];
childKeys.ExportNamedDeclaration = ['declaration', 'specifiers'];
function remove_node(
body: Node[],
node: Node
) {
const i = body.indexOf(node);
if (i === -1) throw new Error('node not in list');
body.splice(i, 1);
}
export default class Component {
stats: Stats;
warnings: Warning[];
@ -478,13 +468,15 @@ export default class Component {
}
extract_imports(content) {
content.body.forEach(node => {
let i = content.body.length;
while (i--) {
const node = content.body[i];
if (node.type === 'ImportDeclaration') {
// imports need to be hoisted out of the IIFE
remove_node(content.body, node);
content.body.splice(i, 1);
this.imports.push(node);
}
});
}
}
extract_exports(content) {

@ -15,9 +15,10 @@ export default class Let extends Node {
super(component, parent, scope, info);
this.name = { type: 'Identifier', name: info.name };
this.value = info.expression.node;
if (info.expression) {
this.value = info.expression;
walk(info.expression, {
enter: node => {
if (!applicable.has(node.type)) {
@ -30,6 +31,15 @@ export default class Let extends Node {
if (node.type === 'Identifier') {
this.names.push(node.name);
}
// slightly unfortunate hack
if (node.type === 'ArrayExpression') {
(node as any).type = 'ArrayPattern';
}
if (node.type === 'ObjectExpression') {
(node as any).type = 'ObjectPattern';
}
}
});
} else {

@ -4,8 +4,6 @@ import { x } from 'code-red';
export function get_context_merger(lets: Let[]) {
if (lets.length === 0) return null;
console.log(lets);
const input = {
type: 'ObjectPattern',
properties: lets.map(l => ({

Loading…
Cancel
Save