Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(compiler-sfc): fix import usage check in template strings case sensitive #4363

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -206,15 +206,15 @@ return { x }

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, VAR, VAR2, VAR3, Last } from './x'
import { FooBar, FooBaz, fooQux, vMyDir, x, y, z, x$y, VAR, VAR2, VAR3, Last } from './x'

export default _defineComponent({
setup(__props, { expose }) {
expose()

const fooBar: FooBar = 1

return { fooBar, FooBaz, FooQux, vMyDir, x, z, x$y, VAR, VAR3, Last }
return { fooBar, FooBaz, fooQux, vMyDir, x, z, x$y, VAR, VAR3, Last }
}

})"
Expand Down
4 changes: 2 additions & 2 deletions packages/compiler-sfc/__tests__/compileScript.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ defineExpose({ foo: 123 })
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, VAR, VAR2, VAR3, Last } from './x'
import { FooBar, FooBaz, fooQux, vMyDir, x, y, z, x$y, VAR, VAR2, VAR3, Last } from './x'
const fooBar: FooBar = 1
</script>
<template>
Expand All @@ -233,7 +233,7 @@ defineExpose({ foo: 123 })
// x$y: #4274 should escape special chars when creating Regex
// VAR & VAR3: #4340 interpolations in tempalte strings
expect(content).toMatch(
`return { fooBar, FooBaz, FooQux, vMyDir, x, z, x$y, VAR, VAR3, Last }`
`return { fooBar, FooBaz, fooQux, vMyDir, x, z, x$y, VAR, VAR3, Last }`
)
assertCode(content)
})
Expand Down
2 changes: 1 addition & 1 deletion packages/compiler-sfc/src/compileScript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2212,7 +2212,7 @@ function resolveTemplateUsageCheckString(sfc: SFCDescriptor) {
!parserOptions.isNativeTag!(node.tag) &&
!parserOptions.isBuiltInComponent!(node.tag)
) {
code += `,${capitalize(camelize(node.tag))}`
code += `,${camelize(node.tag)}`
}
for (let i = 0; i < node.props.length; i++) {
const prop = node.props[i]
Expand Down