Subscribe on changes!

script-setup ignores imports with a dollar $

avatar
Aug 8th 2021

Version

3.2.0-beta.8

Reproduction link

https://github.com/jods4/bug-vue-dollar

Steps to reproduce

import { v$Hello } from "./something" If you bind v$Hello in template it won't be there, Vue removed it as if it was unused.

This can't be seen in SFC playground because the build codegen is different, so look at the linked repository instead.

What is expected?

v$Hello is exported by setup and bound in template.

What is actually happening?

v$Hello is not exported by setup.


Renaming the import works, also demonstrated in linked repo: import { v$Hello as vHello } does work. Notice this isn't a directive, even though it starts with v. As vHello shows, this doesn't seem to be a problem for the compiler.

avatar
Aug 9th 2021

@jods4 Are you sure this is a problem with version 3.2.0-beta.8?

@lidlanca I noticed that your PR is checkout from the master branch, not v3.2. because v3.2 not contains this code

    let isUsedInTemplate = true
    if (isTS && sfc.template && !sfc.template.src) {
      isUsedInTemplate = new RegExp(`\\b${local}\\b`).test(
        resolveTemplateUsageCheckString(sfc)
      )
    }
avatar
Aug 9th 2021

@edison1105 you are correct, 3.2 does not have this but the v3.2.0-beta.8 tag and master does.

https://github.com/vuejs/vue-next/blob/v3.2.0-beta.8/packages/compiler-sfc/src/compileScript.ts#L333-L338

avatar
Aug 9th 2021

@edison1105 not sure where this was introduced. I know it happened to me with 3.2.0-beta.7, I upgraded to beta.8 and the bug was still there. Not sure about 3.1.