Skip to content

Commit 2e74ad4

Browse files
committed
refactor: revert reactivity transform
1 parent b70fa18 commit 2e74ad4

File tree

3 files changed

+5
-27
lines changed

3 files changed

+5
-27
lines changed

packages/reactivity-transform/__tests__/__snapshots__/reactivityTransform.spec.ts.snap

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -280,15 +280,6 @@ const props = defineProps<{msg: string; ids?: string[]}>()
280280
let ids = _ref([])"
281281
`;
282282
283-
exports[`should support module string names syntax 1`] = `
284-
"
285-
286-
287-
let a = (ref(0));
288-
console.log((a))
289-
"
290-
`;
291-
292283
exports[`using ref binding in property shorthand 1`] = `
293284
"import { ref as _ref } from 'vue'
294285

packages/reactivity-transform/__tests__/reactivityTransform.spec.ts

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -460,22 +460,6 @@ test('macro import alias and removal', () => {
460460
assertCode(code)
461461
})
462462

463-
test('should support module string names syntax', () => {
464-
const { code } = transform(
465-
`
466-
import { "$" as fromRefs, "$$" as escapeRefs } from 'vue/macros'
467-
468-
let a = fromRefs(ref(0));
469-
console.log(escapeRefs(a))
470-
`
471-
)
472-
// should remove imports
473-
expect(code).not.toMatch(`from 'vue/macros'`)
474-
expect(code).toMatch(`let a = (ref(0))`)
475-
expect(code).toMatch(`console.log((a))`)
476-
assertCode(code)
477-
})
478-
479463
// #6838
480464
test('should not overwrite importing', () => {
481465
const { code } = transform(

packages/reactivity-transform/src/reactivityTransform.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import MagicString, { SourceMap } from 'magic-string'
1818
import { walk } from 'estree-walker'
1919
import {
2020
extractIdentifiers,
21-
getImportedName,
2221
isFunctionType,
2322
isInDestructureAssignment,
2423
isReferencedIdentifier,
@@ -199,7 +198,11 @@ export function transformAST(
199198

200199
for (const specifier of node.specifiers) {
201200
const local = specifier.local.name
202-
const imported = getImportedName(specifier)
201+
const imported =
202+
(specifier.type === 'ImportSpecifier' &&
203+
specifier.imported.type === 'Identifier' &&
204+
specifier.imported.name) ||
205+
'default'
203206
userImports[local] = {
204207
source,
205208
local,

0 commit comments

Comments
 (0)