Skip to content

Commit 642a44f

Browse files
committed
chore: fix browser build treeshaking for transformExpression
1 parent 8490964 commit 642a44f

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

packages/compiler-core/src/index.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,22 @@ export function compile(
1717
template: string | RootNode,
1818
options: CompilerOptions = {}
1919
): CodegenResult {
20-
if (__BROWSER__ && options.prefixIdentifiers) {
20+
if (__BROWSER__ && options.prefixIdentifiers === false) {
2121
;(options.onError || defaultOnError)(
2222
createCompilerError(ErrorCodes.X_PREFIX_ID_NOT_SUPPORTED)
2323
)
2424
}
2525

2626
const ast = isString(template) ? parse(template, options) : template
2727

28+
const prefixIdentifiers = !__BROWSER__ && options.prefixIdentifiers === true
2829
transform(ast, {
2930
...options,
30-
prefixIdentifiers: !__BROWSER__ && options.prefixIdentifiers === true,
31+
prefixIdentifiers,
3132
nodeTransforms: [
3233
transformIf,
3334
transformFor,
34-
transformExpression,
35+
...(prefixIdentifiers ? [transformExpression] : []),
3536
transformElement,
3637
...(options.nodeTransforms || []) // user transforms
3738
],
@@ -41,6 +42,7 @@ export function compile(
4142
...(options.directiveTransforms || {}) // user transforms
4243
}
4344
})
45+
4446
return generate(ast, options)
4547
}
4648

0 commit comments

Comments
 (0)