exports[`SFC compile <script setup> imports imports not used in <template> should not be exposed 1`] = `
"import { defineComponent as _defineComponent } from 'vue'
-import { FooBar, FooBaz, FooQux, vMyDir, x, y, z, x$y } from './x'
+import { FooBar, FooBaz, FooQux, vMyDir, x, y, z, x$y, Last } from './x'
export default _defineComponent({
setup(__props, { expose }) {
const fooBar: FooBar = 1
-return { fooBar, FooBaz, FooQux, vMyDir, x, z, x$y }
+return { fooBar, FooBaz, FooQux, vMyDir, x, z, x$y, Last }
}
})"
test('imports not used in <template> should not be exposed', () => {
const { content } = compile(`
<script setup lang="ts">
- import { FooBar, FooBaz, FooQux, vMyDir, x, y, z, x$y } from './x'
+ import { FooBar, FooBaz, FooQux, vMyDir, x, y, z, x$y, Last } from './x'
const fooBar: FooBar = 1
</script>
<template>
<FooBaz v-my-dir>{{ x }} {{ yy }} {{ x$y }}</FooBaz>
<foo-qux/>
<div :id="z + 'y'">FooBar</div>
+ <Last/>
</template>
`)
assertCode(content)
// y: should not be matched by {{ yy }} or 'y' in binding exps
// x$y: #4274 should escape special chars when creating Regex
expect(content).toMatch(
- `return { fooBar, FooBaz, FooQux, vMyDir, x, z, x$y }`
+ `return { fooBar, FooBaz, FooQux, vMyDir, x, z, x$y, Last }`
)
})
})