fix(ssr): should not hoist transformed asset urls in ssr compile
fix #3874
This commit is contained in:
@@ -176,6 +176,17 @@ function getImportsExpressionExp(
|
||||
}
|
||||
|
||||
const hashExp = `${name} + '${hash}'`
|
||||
const finalExp = createSimpleExpression(
|
||||
hashExp,
|
||||
false,
|
||||
loc,
|
||||
ConstantTypes.CAN_STRINGIFY
|
||||
)
|
||||
|
||||
if (!context.hoistStatic) {
|
||||
return finalExp
|
||||
}
|
||||
|
||||
const existingHoistIndex = context.hoists.findIndex(h => {
|
||||
return (
|
||||
h &&
|
||||
@@ -192,9 +203,7 @@ function getImportsExpressionExp(
|
||||
ConstantTypes.CAN_STRINGIFY
|
||||
)
|
||||
}
|
||||
return context.hoist(
|
||||
createSimpleExpression(hashExp, false, loc, ConstantTypes.CAN_STRINGIFY)
|
||||
)
|
||||
return context.hoist(finalExp)
|
||||
} else {
|
||||
return createSimpleExpression(`''`, false, loc, ConstantTypes.CAN_STRINGIFY)
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ import {
|
||||
ConstantTypes,
|
||||
createCompoundExpression,
|
||||
createSimpleExpression,
|
||||
ExpressionNode,
|
||||
NodeTransform,
|
||||
NodeTypes,
|
||||
SimpleExpressionNode
|
||||
@@ -145,14 +146,17 @@ export const transformSrcset: NodeTransform = (
|
||||
}
|
||||
})
|
||||
|
||||
const hoisted = context.hoist(compoundExpression)
|
||||
hoisted.constType = ConstantTypes.CAN_STRINGIFY
|
||||
let exp: ExpressionNode = compoundExpression
|
||||
if (context.hoistStatic) {
|
||||
exp = context.hoist(compoundExpression)
|
||||
exp.constType = ConstantTypes.CAN_STRINGIFY
|
||||
}
|
||||
|
||||
node.props[index] = {
|
||||
type: NodeTypes.DIRECTIVE,
|
||||
name: 'bind',
|
||||
arg: createSimpleExpression('srcset', true, attr.loc),
|
||||
exp: hoisted,
|
||||
exp,
|
||||
modifiers: [],
|
||||
loc: attr.loc
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user