fix(compiler-sfc): should not remove import statements with no specifier when compiling script setup
This commit is contained in:
parent
a76e58e5fd
commit
43eab923ea
@ -181,10 +181,13 @@ return { a, b }
|
|||||||
|
|
||||||
exports[`SFC compile <script setup> imports should hoist and expose imports 1`] = `
|
exports[`SFC compile <script setup> imports should hoist and expose imports 1`] = `
|
||||||
"import { ref } from 'vue'
|
"import { ref } from 'vue'
|
||||||
|
import 'foo/css'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
expose: [],
|
expose: [],
|
||||||
setup(__props) {
|
setup(__props) {
|
||||||
|
|
||||||
|
|
||||||
return { ref }
|
return { ref }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,7 +123,10 @@ const myEmit = defineEmit(['foo', 'bar'])
|
|||||||
describe('imports', () => {
|
describe('imports', () => {
|
||||||
test('should hoist and expose imports', () => {
|
test('should hoist and expose imports', () => {
|
||||||
assertCode(
|
assertCode(
|
||||||
compile(`<script setup>import { ref } from 'vue'</script>`).content
|
compile(`<script setup>
|
||||||
|
import { ref } from 'vue'
|
||||||
|
import 'foo/css'
|
||||||
|
</script>`).content
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -638,7 +638,7 @@ export function compileScript(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (removed === node.specifiers.length) {
|
if (node.specifiers.length && removed === node.specifiers.length) {
|
||||||
s.remove(node.start! + startOffset, node.end! + startOffset)
|
s.remove(node.start! + startOffset, node.end! + startOffset)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user