Просмотр исходного кода

fix(build): avoid imports to @babel/types in client build of compiler-core

Evan You 4 лет назад
Родитель
Сommit
4c468eb30a
1 измененных файлов с 8 добавлено и 0 удалено
  1. 8 0
      packages/compiler-core/src/babelUtils.ts

+ 8 - 0
packages/compiler-core/src/babelUtils.ts

@@ -22,6 +22,10 @@ export function walkIdentifiers(
   parentStack: Node[] = [],
   parentStack: Node[] = [],
   knownIds: Record<string, number> = Object.create(null)
   knownIds: Record<string, number> = Object.create(null)
 ) {
 ) {
+  if (__BROWSER__) {
+    return
+  }
+
   const rootExp =
   const rootExp =
     root.type === 'Program' &&
     root.type === 'Program' &&
     root.body[0].type === 'ExpressionStatement' &&
     root.body[0].type === 'ExpressionStatement' &&
@@ -81,6 +85,10 @@ export function isReferencedIdentifier(
   parent: Node | null,
   parent: Node | null,
   parentStack: Node[]
   parentStack: Node[]
 ) {
 ) {
+  if (__BROWSER__) {
+    return false
+  }
+
   if (!parent) {
   if (!parent) {
     return true
     return true
   }
   }