diff --git a/package.json b/package.json index d16672d..621d140 100644 --- a/package.json +++ b/package.json @@ -50,9 +50,10 @@ "@babel/traverse": "^7.16.3", "@babel/types": "^7.16.0", "@rollup/pluginutils": "^4.1.1", - "@vue/compiler-core": "^3.2.25", + "@vue/compiler-core": "^3.2.26", + "@vue/compiler-dom": "^3.2.26", "@vue/ref-transform": "^3.2.24", - "@vue/shared": "^3.2.24", + "@vue/shared": "^3.2.26", "defu": "^5.0.0", "htmlparser2": "5.0.1", "magic-string": "^0.25.7", @@ -63,7 +64,6 @@ "@antfu/ni": "^0.12.0", "@types/node": "^16.11.12", "@vue/composition-api": "^1.4.1", - "@vue/runtime-dom": "^3.2.25", "bumpp": "^7.1.1", "eslint": "^8.4.1", "esno": "^0.12.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 8bddbb2..2c231eb 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -14,11 +14,11 @@ importers: '@babel/types': ^7.16.0 '@rollup/pluginutils': ^4.1.1 '@types/node': ^16.11.12 - '@vue/compiler-core': ^3.2.25 + '@vue/compiler-core': ^3.2.26 + '@vue/compiler-dom': ^3.2.26 '@vue/composition-api': ^1.4.1 '@vue/ref-transform': ^3.2.24 - '@vue/runtime-dom': ^3.2.25 - '@vue/shared': ^3.2.24 + '@vue/shared': ^3.2.26 bumpp: ^7.1.1 defu: ^5.0.0 eslint: ^8.4.1 @@ -41,9 +41,10 @@ importers: '@babel/traverse': 7.16.3 '@babel/types': 7.16.0 '@rollup/pluginutils': 4.1.1 - '@vue/compiler-core': 3.2.25 + '@vue/compiler-core': 3.2.26 + '@vue/compiler-dom': 3.2.26 '@vue/ref-transform': 3.2.24 - '@vue/shared': 3.2.25 + '@vue/shared': 3.2.26 defu: 5.0.0 htmlparser2: 5.0.1 magic-string: 0.25.7 @@ -53,7 +54,6 @@ importers: '@antfu/ni': 0.12.0 '@types/node': 16.11.12 '@vue/composition-api': 1.4.1 - '@vue/runtime-dom': 3.2.25 bumpp: 7.1.1 eslint: 8.4.1 esno: 0.12.1_typescript@4.5.3 @@ -2946,11 +2946,11 @@ packages: source-map: 0.6.1 dev: false - /@vue/compiler-core/3.2.25: - resolution: {integrity: sha512-FlffKezIqztTCTyG0klkYRwhdyL6b1PTTCIerPb4p2R9qQaczccTX5g9ysi9w6tpLQ48a1WiXnFDJhWD7XoqwA==} + /@vue/compiler-core/3.2.26: + resolution: {integrity: sha512-N5XNBobZbaASdzY9Lga2D9Lul5vdCIOXvUMd6ThcN8zgqQhPKfCV+wfAJNNJKQkSHudnYRO2gEB+lp0iN3g2Tw==} dependencies: '@babel/parser': 7.16.4 - '@vue/shared': 3.2.25 + '@vue/shared': 3.2.26 estree-walker: 2.0.2 source-map: 0.6.1 dev: false @@ -2962,6 +2962,13 @@ packages: '@vue/shared': 3.2.21 dev: true + /@vue/compiler-dom/3.2.26: + resolution: {integrity: sha512-smBfaOW6mQDxcT3p9TKT6mE22vjxjJL50GFVJiI0chXYGU/xzC05QRGrW3HHVuJrmLTLx5zBhsZ2dIATERbarg==} + dependencies: + '@vue/compiler-core': 3.2.26 + '@vue/shared': 3.2.26 + dev: false + /@vue/component-compiler-utils/3.2.2: resolution: {integrity: sha512-rAYMLmgMuqJFWAOb3Awjqqv5X3Q3hVr4jH/kgrFJpiU0j3a90tnNBplqbj+snzrgZhC9W128z+dtgMifOiMfJg==} dependencies: @@ -3065,6 +3072,11 @@ packages: /@vue/shared/3.2.25: resolution: {integrity: sha512-DkHJFV2gw9WBRmUCa21eyG0WvlF0l1QFOgTkWj29O4mt2Tv3BSE5PQOKhUruZIym4bBYCqx9ZGtoD1WohDprow==} + dev: true + + /@vue/shared/3.2.26: + resolution: {integrity: sha512-vPV6Cq+NIWbH5pZu+V+2QHE9y1qfuTq49uNWw4f7FDEeZaDU2H2cx5jcUZOAKW7qTrUS4k6qZPbMy1x4N96nbA==} + dev: false /@vue/web-component-wrapper/1.3.0: resolution: {integrity: sha512-Iu8Tbg3f+emIIMmI2ycSI8QcEuAUgPTgHwesDU1eKMLE4YC/c/sFbGc70QgMq31ijRftV0R7vCm9co6rldCeOA==} diff --git a/src/core/parseSFC.ts b/src/core/parseSFC.ts index 0f6eb1f..41e85b5 100644 --- a/src/core/parseSFC.ts +++ b/src/core/parseSFC.ts @@ -10,6 +10,7 @@ import type { ExpressionNode, } from '@vue/compiler-core' import { baseParse } from '@vue/compiler-core' +import { parserOptions } from '@vue/compiler-dom' import { camelize } from '@vue/shared' import type { ParsedSFC, @@ -236,8 +237,7 @@ function getFreeVariablesForNode( } export function findReferencesForSFC(code: string) { - const rootNode = baseParse(code, { - }) + const rootNode = baseParse(code, parserOptions) const templateChildNodes = rootNode.children.flatMap(node => node.type === NodeTypes.ELEMENT && node.tagType === ElementTypes.ELEMENT ? [node] diff --git a/test/__snapshots__/transform.test.ts.snap b/test/__snapshots__/transform.test.ts.snap index 6cc64a5..9a0943a 100644 --- a/test/__snapshots__/transform.test.ts.snap +++ b/test/__snapshots__/transform.test.ts.snap @@ -209,6 +209,7 @@ exports[`transform > fixtures > test/fixtures/ComponentsDirectives.vue 1`] = ` + diff --git a/test/fixtures/ComponentsDirectives.vue b/test/fixtures/ComponentsDirectives.vue index c3d533f..3f2fcf6 100644 --- a/test/fixtures/ComponentsDirectives.vue +++ b/test/fixtures/ComponentsDirectives.vue @@ -26,6 +26,7 @@ +