fix(compiler-sfc): make asset url imports stringifiable
This commit is contained in:
@@ -162,7 +162,12 @@ function getImportsExpressionExp(
|
||||
exp = context.imports[existingIndex].exp as SimpleExpressionNode
|
||||
} else {
|
||||
name = `_imports_${context.imports.length}`
|
||||
exp = createSimpleExpression(name, false, loc, ConstantTypes.CAN_HOIST)
|
||||
exp = createSimpleExpression(
|
||||
name,
|
||||
false,
|
||||
loc,
|
||||
ConstantTypes.CAN_STRINGIFY
|
||||
)
|
||||
context.imports.push({ exp, path })
|
||||
}
|
||||
|
||||
@@ -184,13 +189,13 @@ function getImportsExpressionExp(
|
||||
`_hoisted_${existingHoistIndex + 1}`,
|
||||
false,
|
||||
loc,
|
||||
ConstantTypes.CAN_HOIST
|
||||
ConstantTypes.CAN_STRINGIFY
|
||||
)
|
||||
}
|
||||
return context.hoist(
|
||||
createSimpleExpression(hashExp, false, loc, ConstantTypes.CAN_HOIST)
|
||||
createSimpleExpression(hashExp, false, loc, ConstantTypes.CAN_STRINGIFY)
|
||||
)
|
||||
} else {
|
||||
return createSimpleExpression(`''`, false, loc, ConstantTypes.CAN_HOIST)
|
||||
return createSimpleExpression(`''`, false, loc, ConstantTypes.CAN_STRINGIFY)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,14 +113,14 @@ export const transformSrcset: NodeTransform = (
|
||||
`_imports_${existingImportsIndex}`,
|
||||
false,
|
||||
attr.loc,
|
||||
ConstantTypes.CAN_HOIST
|
||||
ConstantTypes.CAN_STRINGIFY
|
||||
)
|
||||
} else {
|
||||
exp = createSimpleExpression(
|
||||
`_imports_${context.imports.length}`,
|
||||
false,
|
||||
attr.loc,
|
||||
ConstantTypes.CAN_HOIST
|
||||
ConstantTypes.CAN_STRINGIFY
|
||||
)
|
||||
context.imports.push({ exp, path })
|
||||
}
|
||||
@@ -131,7 +131,7 @@ export const transformSrcset: NodeTransform = (
|
||||
`"${url}"`,
|
||||
false,
|
||||
attr.loc,
|
||||
ConstantTypes.CAN_HOIST
|
||||
ConstantTypes.CAN_STRINGIFY
|
||||
)
|
||||
compoundExpression.children.push(exp)
|
||||
}
|
||||
@@ -146,7 +146,7 @@ export const transformSrcset: NodeTransform = (
|
||||
})
|
||||
|
||||
const hoisted = context.hoist(compoundExpression)
|
||||
hoisted.constType = ConstantTypes.CAN_HOIST
|
||||
hoisted.constType = ConstantTypes.CAN_STRINGIFY
|
||||
|
||||
node.props[index] = {
|
||||
type: NodeTypes.DIRECTIVE,
|
||||
|
||||
Reference in New Issue
Block a user