import { ref } from 'vue'
import Foo, { bar } from './Foo.vue'
import other from './util'
+ import * as tree from './tree'
export default {
setup(__props) {
]),
_: 1 /* STABLE */
}),
- _createElementVNode(\\"div\\", { onClick: fn }, _toDisplayString(count.value) + \\" \\" + _toDisplayString(constant) + \\" \\" + _toDisplayString(_unref(maybe)) + \\" \\" + _toDisplayString(_unref(lett)) + \\" \\" + _toDisplayString(_unref(other)), 1 /* TEXT */)
+ _createElementVNode(\\"div\\", { onClick: fn }, _toDisplayString(count.value) + \\" \\" + _toDisplayString(constant) + \\" \\" + _toDisplayString(_unref(maybe)) + \\" \\" + _toDisplayString(_unref(lett)) + \\" \\" + _toDisplayString(_unref(other)), 1 /* TEXT */),
+ _createTextVNode(\\" \\" + _toDisplayString(tree.foo()), 1 /* TEXT */)
], 64 /* STABLE_FRAGMENT */))
}
}
import { ref } from 'vue'
import Foo, { bar } from './Foo.vue'
import other from './util'
+ import * as tree from './tree'
const count = ref(0)
const constant = {}
const maybe = foo()
<template>
<Foo>{{ bar }}</Foo>
<div @click="fn">{{ count }} {{ constant }} {{ maybe }} {{ lett }} {{ other }}</div>
+ {{ tree.foo() }}
</template>
`,
{ inlineTemplate: true }
expect(content).toMatch(`unref(maybe)`)
// should unref() on let bindings
expect(content).toMatch(`unref(lett)`)
+ // no need to unref namespace import (this also preserves tree-shaking)
+ expect(content).toMatch(`tree.foo()`)
// no need to unref function declarations
expect(content).toMatch(`{ onClick: fn }`)
// no need to mark constant fns in patch flag
for (let i = 0; i < node.specifiers.length; i++) {
const specifier = node.specifiers[i]
const local = specifier.local.name
- const imported =
+ let imported =
specifier.type === 'ImportSpecifier' &&
specifier.imported.type === 'Identifier' &&
specifier.imported.name
+ if (specifier.type === 'ImportNamespaceSpecifier') {
+ imported = '*'
+ }
const source = node.source.value
const existing = userImports[local]
if (
)) {
if (isType) continue
bindingMetadata[key] =
- (imported === 'default' && source.endsWith('.vue')) || source === 'vue'
+ imported === '*' ||
+ (imported === 'default' && source.endsWith('.vue')) ||
+ source === 'vue'
? BindingTypes.SETUP_CONST
: BindingTypes.SETUP_MAYBE_REF
}