diff --git a/packages/reactivity-transform/__tests__/__snapshots__/reactivityTransform.spec.ts.snap b/packages/reactivity-transform/__tests__/__snapshots__/reactivityTransform.spec.ts.snap index f61e41b4498..3c3f85244cc 100644 --- a/packages/reactivity-transform/__tests__/__snapshots__/reactivityTransform.spec.ts.snap +++ b/packages/reactivity-transform/__tests__/__snapshots__/reactivityTransform.spec.ts.snap @@ -280,15 +280,6 @@ const props = defineProps<{msg: string; ids?: string[]}>() let ids = _ref([])" `; -exports[`should support module string names syntax 1`] = ` -" - - - let a = (ref(0)); - console.log((a)) - " -`; - exports[`using ref binding in property shorthand 1`] = ` "import { ref as _ref } from 'vue' diff --git a/packages/reactivity-transform/__tests__/reactivityTransform.spec.ts b/packages/reactivity-transform/__tests__/reactivityTransform.spec.ts index 344f0b4a77d..5255be6ba8b 100644 --- a/packages/reactivity-transform/__tests__/reactivityTransform.spec.ts +++ b/packages/reactivity-transform/__tests__/reactivityTransform.spec.ts @@ -460,22 +460,6 @@ test('macro import alias and removal', () => { assertCode(code) }) -test('should support module string names syntax', () => { - const { code } = transform( - ` - import { "$" as fromRefs, "$$" as escapeRefs } from 'vue/macros' - - let a = fromRefs(ref(0)); - console.log(escapeRefs(a)) - ` - ) - // should remove imports - expect(code).not.toMatch(`from 'vue/macros'`) - expect(code).toMatch(`let a = (ref(0))`) - expect(code).toMatch(`console.log((a))`) - assertCode(code) -}) - // #6838 test('should not overwrite importing', () => { const { code } = transform( diff --git a/packages/reactivity-transform/src/reactivityTransform.ts b/packages/reactivity-transform/src/reactivityTransform.ts index 8d64b3f8a65..16cf88e5ac8 100644 --- a/packages/reactivity-transform/src/reactivityTransform.ts +++ b/packages/reactivity-transform/src/reactivityTransform.ts @@ -18,7 +18,6 @@ import MagicString, { SourceMap } from 'magic-string' import { walk } from 'estree-walker' import { extractIdentifiers, - getImportedName, isFunctionType, isInDestructureAssignment, isReferencedIdentifier, @@ -199,7 +198,11 @@ export function transformAST( for (const specifier of node.specifiers) { const local = specifier.local.name - const imported = getImportedName(specifier) + const imported = + (specifier.type === 'ImportSpecifier' && + specifier.imported.type === 'Identifier' && + specifier.imported.name) || + 'default' userImports[local] = { source, local,