fix(compiler): bail strigification on runtime constant expressions

This commit is contained in:
Evan You
2020-05-04 15:15:26 -04:00
parent 3c3fe88c64
commit f9a3766fd6
5 changed files with 80 additions and 3 deletions

View File

@@ -126,11 +126,14 @@ function getImportsExpressionExp(
}
const name = `_imports_${importsArray.length}`
const exp = createSimpleExpression(name, false, loc, true)
exp.isRuntimeConstant = true
context.imports.add({ exp, path })
if (hash && path) {
return context.hoist(
const ret = context.hoist(
createSimpleExpression(`${name} + '${hash}'`, false, loc, true)
)
ret.isRuntimeConstant = true
return ret
} else {
return exp
}

View File

@@ -86,11 +86,14 @@ export const transformSrcset: NodeTransform = (node, context) => {
}
})
const hoisted = context.hoist(compoundExpression)
hoisted.isRuntimeConstant = true
node.props[index] = {
type: NodeTypes.DIRECTIVE,
name: 'bind',
arg: createSimpleExpression('srcset', true, attr.loc),
exp: context.hoist(compoundExpression),
exp: hoisted,
modifiers: [],
loc: attr.loc
}