add special workarounds for typescript(?)

master
Drake 2 years ago
parent 0fccb8cf9b
commit e46410235b

@ -26,16 +26,19 @@ export default function preprocess(opts) {
delete parent[prop]
}
return //ignore childs of objects ie console.log
} else if (node.type === "Identifier") {
} else if (node.type === "Identifier" && !parent.type.startsWith("TS")) {
if (parent.type === "VariableDeclarator") {
return
}
if (opts.values) {
for (const i in opts.values) {
if (i === node.name) {
console.log(`Found comp-time var ${i} with value ${opts.values[i]}`)
const res = eval(`(${opts.values[i]})`)
if (typeof res === "string") {
parent[prop] = [ parse(`('${res}')`).body[0].expression ]
parent[prop] = [ rollupThis.parse(`('${res}')`).body[0].expression ]
} else {
parent[prop] = [ parse(`(${res})`).body[0].expression ]
parent[prop] = [ rollupThis.parse(`(${res})`).body[0].expression ]
}
return
}

Loading…
Cancel
Save