From ccfcf20c647adfc78e8645bca4e3cef376dcebc9 Mon Sep 17 00:00:00 2001 From: phk422 <1769476785@qq.com> Date: Fri, 1 Mar 2024 14:14:45 +0800 Subject: [PATCH 1/3] fix: fixed an error in the vue component editor(https://github.com/withastro/language-tools/issues/758) --- packages/integrations/vue/src/editor.cts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/integrations/vue/src/editor.cts b/packages/integrations/vue/src/editor.cts index 0c9642d671d7..d4f10aab6661 100644 --- a/packages/integrations/vue/src/editor.cts +++ b/packages/integrations/vue/src/editor.cts @@ -23,7 +23,8 @@ export function toTSX(code: string, className: string): string { const { scriptSetup } = parsedResult.descriptor; if (scriptSetup) { - const definePropsType = scriptSetup.content.match(/defineProps<([\s\S]+?)>\s?\(\)/); + const codeWithoutComments = scriptSetup.content.replace(/\/\/.*|\/\*[\s\S]*?\*\//g, ''); + const definePropsType = codeWithoutComments.match(/defineProps<([\s\S]+?)>\s?\(\)/); const propsGeneric = scriptSetup.attrs.generic; const propsGenericType = propsGeneric ? `<${propsGeneric}>` : ''; @@ -40,11 +41,10 @@ export function toTSX(code: string, className: string): string { // TODO. Find a way to support generics when using defineProps without passing explicit types. // Right now something like this `defineProps({ prop: { type: Array as PropType } })` // won't be correctly typed in Astro. - const defineProps = scriptSetup.content.match(/defineProps\([\s\S]+\)/); - + const defineProps = codeWithoutComments.match(/defineProps\([\s\S]+?\)/); if (defineProps) { result = ` - import { defineProps } from '@vue/runtime-core'; + import { defineProps } from 'vue'; ${regularScriptBlockContent} From 69111d0f87abb836bf349cc72560d79c45fdc486 Mon Sep 17 00:00:00 2001 From: phk422 <1769476785@qq.com> Date: Fri, 1 Mar 2024 16:34:10 +0800 Subject: [PATCH 2/3] test: add test `toTsx` --- packages/integrations/vue/package.json | 1 + packages/integrations/vue/test/toTsx.test.cts | 47 +++++ pnpm-lock.yaml | 160 ++++++++++++++---- 3 files changed, 172 insertions(+), 36 deletions(-) create mode 100644 packages/integrations/vue/test/toTsx.test.cts diff --git a/packages/integrations/vue/package.json b/packages/integrations/vue/package.json index 60943076cd5d..0f4e8e11c151 100644 --- a/packages/integrations/vue/package.json +++ b/packages/integrations/vue/package.json @@ -49,6 +49,7 @@ "@types/chai": "^4.3.10", "astro": "workspace:*", "astro-scripts": "workspace:*", + "chai": "^4.3.10", "cheerio": "1.0.0-rc.12", "linkedom": "^0.16.4", "vite": "^5.1.4", diff --git a/packages/integrations/vue/test/toTsx.test.cts b/packages/integrations/vue/test/toTsx.test.cts new file mode 100644 index 000000000000..16c369138b95 --- /dev/null +++ b/packages/integrations/vue/test/toTsx.test.cts @@ -0,0 +1,47 @@ +import { toTSX } from '../src/editor.cts'; +import { describe, it} from 'node:test'; +import { expect } from 'chai'; + +describe('toTSX function', () => { + it('should correctly transform Vue code to TSX with comments', () => { + const vueCode = ` + + + + `; + + const className = 'MyComponent'; + const result = toTSX(vueCode, className); + + // Replace the expectations below with the expected result based on your logic + expect(result).to.equal(`export default function ${className}__AstroComponent_(_props: Record): any {}`); + }); + it('should correctly transform Vue code to TSX', () => { + const vueCode = ` + + + + `; + + const className = 'MyComponent'; + const result = toTSX(vueCode, className); + + expect(result.replace(/\s/g, '')). + to.equal(`import{defineProps}from'vue';constProps=defineProps({msg:String})exportdefaultfunction${className}__AstroComponent_(_props:typeofProps):any{
}`); + }); +}); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index f0eb28d9453b..e39a03c2fdcc 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -5107,6 +5107,9 @@ importers: astro-scripts: specifier: workspace:* version: link:../../../scripts + chai: + specifier: ^4.3.10 + version: 4.4.1 cheerio: specifier: 1.0.0-rc.12 version: 1.0.0-rc.12 @@ -6023,6 +6026,7 @@ packages: engines: {node: '>=14.*'} cpu: [arm64] os: [linux] + libc: [musl] requiresBuild: true dev: false optional: true @@ -6032,6 +6036,7 @@ packages: engines: {node: '>=14.*'} cpu: [arm64] os: [linux] + libc: [glibc] requiresBuild: true dev: false optional: true @@ -6041,6 +6046,7 @@ packages: engines: {node: '>=14.*'} cpu: [x64] os: [linux] + libc: [musl] requiresBuild: true dev: false optional: true @@ -6050,6 +6056,7 @@ packages: engines: {node: '>=14.*'} cpu: [x64] os: [linux] + libc: [glibc] requiresBuild: true dev: false optional: true @@ -6963,11 +6970,11 @@ packages: engines: {node: '>=12'} dependencies: string-width: 5.1.2 - string-width-cjs: /string-width@4.2.3 + string-width-cjs: r2.cnpmjs.org/string-width@4.2.3 strip-ansi: 7.1.0 - strip-ansi-cjs: /strip-ansi@6.0.1 + strip-ansi-cjs: r2.cnpmjs.org/strip-ansi@6.0.1 wrap-ansi: 8.1.0 - wrap-ansi-cjs: /wrap-ansi@7.0.0 + wrap-ansi-cjs: r2.cnpmjs.org/wrap-ansi@7.0.0 /@jest/schemas@29.6.3: resolution: {integrity: sha512-mo5j5X+jIZmJQveBKeS/clAueipV7KgiX1vMgCxam1RNYiqE1w62n0/tJJnHtjW8ZHcQco5gY85jA3mi0L+nSA==} @@ -7212,7 +7219,7 @@ packages: react: optional: true optionalDependencies: - '@types/markdown-it': 12.2.3 + '@types/markdown-it': r2.cnpmjs.org/@types/markdown-it@12.2.3 dev: false /@mdx-js/mdx@3.0.0: @@ -7532,6 +7539,7 @@ packages: resolution: {integrity: sha512-pL6QtV26W52aCWTG1IuFV3FMPL1m4wbsRG+qijIvgFO/VBsiXJjDPE/uiMdHBAO6YcpV4KvpKtd0v3WFbaxBtg==} cpu: [arm64] os: [linux] + libc: [glibc] requiresBuild: true optional: true @@ -7539,6 +7547,7 @@ packages: resolution: {integrity: sha512-On+cc5EpOaTwPSNetHXBuqylDW+765G/oqB9xGmWU3npEhCh8xu0xqHGUA+4xwZLqBbIZNcBlKSIYfkBm6ko7g==} cpu: [arm64] os: [linux] + libc: [musl] requiresBuild: true optional: true @@ -7546,6 +7555,7 @@ packages: resolution: {integrity: sha512-Wnx/IVMSZ31D/cO9HSsU46FjrPWHqtdF8+0eyZ1zIB5a6hXaZXghUKpRrC4D5DcRTZOjml2oBhXoqfGYyXKipw==} cpu: [riscv64] os: [linux] + libc: [glibc] requiresBuild: true optional: true @@ -7553,6 +7563,7 @@ packages: resolution: {integrity: sha512-ym5x1cj4mUAMBummxxRkI4pG5Vht1QMsJexwGP8547TZ0sox9fCLDHw9KCH9c1FO5d9GopvkaJsBIOkTKxksdw==} cpu: [x64] os: [linux] + libc: [glibc] requiresBuild: true optional: true @@ -7560,6 +7571,7 @@ packages: resolution: {integrity: sha512-m0hYELHGXdYx64D6IDDg/1vOJEaiV8f1G/iO+tejvRCJNSwK4jJ15e38JQy5Q6dGkn1M/9KcyEOwqmlZ2kqaZg==} cpu: [x64] os: [linux] + libc: [musl] requiresBuild: true optional: true @@ -7810,15 +7822,6 @@ packages: /@types/linkify-it@3.0.5: resolution: {integrity: sha512-yg6E+u0/+Zjva+buc3EIb+29XEg4wltq7cSmd4Uc2EE/1nUVmxyzpX6gUXD0V8jIrG0r7YeOGVIbYRkxeooCtw==} - /@types/markdown-it@12.2.3: - resolution: {integrity: sha512-GKMHFfv3458yYy+v/N8gjufHO6MSZKCOXpZc5GXIWWy8uldwfmPn98vp81gZ5f9SVw8YYBctgfJ22a2d7AOMeQ==} - requiresBuild: true - dependencies: - '@types/linkify-it': 3.0.5 - '@types/mdurl': 1.0.5 - dev: false - optional: true - /@types/markdown-it@13.0.7: resolution: {integrity: sha512-U/CBi2YUUcTHBt5tjO2r5QV/x0Po6nsYwQU4Y04fBS6vfoImaiZ6f8bi3CjTCxBPQSO1LMyUqkByzi8AidyxfA==} dependencies: @@ -8770,9 +8773,6 @@ packages: engines: {node: '>=0.10.0'} dev: true - /assertion-error@1.1.0: - resolution: {integrity: sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==} - /astring@1.8.6: resolution: {integrity: sha512-ISvCdHdlTDlH5IpxQJIex7BWBywFWgjJSVdwst+/iQCoEYnyOaQ95+X1JGshuBjGp6nxKUy1jMgE3zPqN7fQdg==} hasBin: true @@ -9162,13 +9162,13 @@ packages: resolution: {integrity: sha512-13sOfMv2+DWduEU+/xbun3LScLoqN17nBeTLUsmDfKdoiC1fr0n9PU4guu4AhRcOVFk/sW8LyZWHuhWtQZiF+g==} engines: {node: '>=4'} dependencies: - assertion-error: 1.1.0 + assertion-error: r2.cnpmjs.org/assertion-error@1.1.0 check-error: 1.0.3 deep-eql: 4.1.3 get-func-name: 2.0.2 loupe: 2.3.7 - pathval: 1.1.1 - type-detect: 4.0.8 + pathval: r2.cnpmjs.org/pathval@1.1.1 + type-detect: r2.cnpmjs.org/type-detect@4.0.8 /chalk@2.4.2: resolution: {integrity: sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==} @@ -9730,7 +9730,7 @@ packages: resolution: {integrity: sha512-WaEtAOpRA1MQ0eohqZjpGD8zdI0Ovsm8mmFhaDN8dvDZzyoUMcYDnf5Y6iu7HTXxf8JDS23qWa4a+hKCDyOPzw==} engines: {node: '>=6'} dependencies: - type-detect: 4.0.8 + type-detect: r2.cnpmjs.org/type-detect@4.0.8 /deep-extend@0.6.0: resolution: {integrity: sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA==} @@ -10726,14 +10726,6 @@ packages: /fs.realpath@1.0.0: resolution: {integrity: sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==} - /fsevents@2.3.2: - resolution: {integrity: sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==} - engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0} - os: [darwin] - requiresBuild: true - dev: true - optional: true - /fsevents@2.3.3: resolution: {integrity: sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==} engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0} @@ -13624,9 +13616,6 @@ packages: resolution: {integrity: sha512-whLdWMYL2TwI08hn8/ZqAbrVemu0LNaNNJZX73O6qaIdCTfXutsLhMkjdENX0qhsQ9uIimo4/aQOmXkoon2nDQ==} dev: false - /pathval@1.1.1: - resolution: {integrity: sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ==} - /periscopic@3.1.0: resolution: {integrity: sha512-vKiQ8RRtkl9P+r/+oefh25C3fhybptkHKCZSPlcXiJux2tJF55GnEj3BVn4A5gKfq9NWWXXrxkHBwVPUfH0opw==} dependencies: @@ -13691,7 +13680,7 @@ packages: dependencies: playwright-core: 1.40.0 optionalDependencies: - fsevents: 2.3.2 + fsevents: r2.cnpmjs.org/fsevents@2.3.2 dev: true /port-authority@2.0.1: @@ -15865,10 +15854,6 @@ packages: prelude-ls: 1.2.1 dev: true - /type-detect@4.0.8: - resolution: {integrity: sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==} - engines: {node: '>=4'} - /type-fest@0.13.1: resolution: {integrity: sha512-34R7HTnG0XIJcBSn5XhDd7nNFPRcXYRZrBB2O2jdKqYODldSzBAqzsWoZYYvduky73toYS/ESqxPvkDf/F0XMg==} engines: {node: '>=10'} @@ -17052,3 +17037,106 @@ packages: dependencies: solid-js: 1.8.7 dev: false + + r2.cnpmjs.org/@types/markdown-it@12.2.3: + resolution: {integrity: sha512-GKMHFfv3458yYy+v/N8gjufHO6MSZKCOXpZc5GXIWWy8uldwfmPn98vp81gZ5f9SVw8YYBctgfJ22a2d7AOMeQ==, registry: http://r.cnpmjs.org/, tarball: https://r2.cnpmjs.org/@types/markdown-it/-/markdown-it-12.2.3.tgz} + name: '@types/markdown-it' + version: 12.2.3 + requiresBuild: true + dependencies: + '@types/linkify-it': 3.0.5 + '@types/mdurl': 1.0.5 + dev: false + optional: true + + r2.cnpmjs.org/ansi-regex@5.0.1: + resolution: {integrity: sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==, registry: http://r.cnpmjs.org/, tarball: https://r2.cnpmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz} + name: ansi-regex + version: 5.0.1 + engines: {node: '>=8'} + + r2.cnpmjs.org/ansi-styles@4.3.0: + resolution: {integrity: sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==, registry: http://r.cnpmjs.org/, tarball: https://r2.cnpmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz} + name: ansi-styles + version: 4.3.0 + engines: {node: '>=8'} + dependencies: + color-convert: r2.cnpmjs.org/color-convert@2.0.1 + + r2.cnpmjs.org/assertion-error@1.1.0: + resolution: {integrity: sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==, registry: http://r.cnpmjs.org/, tarball: https://r2.cnpmjs.org/assertion-error/-/assertion-error-1.1.0.tgz} + name: assertion-error + version: 1.1.0 + + r2.cnpmjs.org/color-convert@2.0.1: + resolution: {integrity: sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==, registry: http://r.cnpmjs.org/, tarball: https://r2.cnpmjs.org/color-convert/-/color-convert-2.0.1.tgz} + name: color-convert + version: 2.0.1 + engines: {node: '>=7.0.0'} + dependencies: + color-name: r2.cnpmjs.org/color-name@1.1.4 + + r2.cnpmjs.org/color-name@1.1.4: + resolution: {integrity: sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==, registry: http://r.cnpmjs.org/, tarball: https://r2.cnpmjs.org/color-name/-/color-name-1.1.4.tgz} + name: color-name + version: 1.1.4 + + r2.cnpmjs.org/emoji-regex@8.0.0: + resolution: {integrity: sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==, registry: http://r.cnpmjs.org/, tarball: https://r2.cnpmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz} + name: emoji-regex + version: 8.0.0 + + r2.cnpmjs.org/fsevents@2.3.2: + resolution: {integrity: sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==, registry: http://r.cnpmjs.org/, tarball: https://r2.cnpmjs.org/fsevents/-/fsevents-2.3.2.tgz} + name: fsevents + version: 2.3.2 + engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0} + os: [darwin] + requiresBuild: true + dev: true + optional: true + + r2.cnpmjs.org/is-fullwidth-code-point@3.0.0: + resolution: {integrity: sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==, registry: http://r.cnpmjs.org/, tarball: https://r2.cnpmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz} + name: is-fullwidth-code-point + version: 3.0.0 + engines: {node: '>=8'} + + r2.cnpmjs.org/pathval@1.1.1: + resolution: {integrity: sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ==, registry: http://r.cnpmjs.org/, tarball: https://r2.cnpmjs.org/pathval/-/pathval-1.1.1.tgz} + name: pathval + version: 1.1.1 + + r2.cnpmjs.org/string-width@4.2.3: + resolution: {integrity: sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==, registry: http://r.cnpmjs.org/, tarball: https://r2.cnpmjs.org/string-width/-/string-width-4.2.3.tgz} + name: string-width + version: 4.2.3 + engines: {node: '>=8'} + dependencies: + emoji-regex: r2.cnpmjs.org/emoji-regex@8.0.0 + is-fullwidth-code-point: r2.cnpmjs.org/is-fullwidth-code-point@3.0.0 + strip-ansi: r2.cnpmjs.org/strip-ansi@6.0.1 + + r2.cnpmjs.org/strip-ansi@6.0.1: + resolution: {integrity: sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==, registry: http://r.cnpmjs.org/, tarball: https://r2.cnpmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz} + name: strip-ansi + version: 6.0.1 + engines: {node: '>=8'} + dependencies: + ansi-regex: r2.cnpmjs.org/ansi-regex@5.0.1 + + r2.cnpmjs.org/type-detect@4.0.8: + resolution: {integrity: sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==, registry: http://r.cnpmjs.org/, tarball: https://r2.cnpmjs.org/type-detect/-/type-detect-4.0.8.tgz} + name: type-detect + version: 4.0.8 + engines: {node: '>=4'} + + r2.cnpmjs.org/wrap-ansi@7.0.0: + resolution: {integrity: sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==, registry: http://r.cnpmjs.org/, tarball: https://r2.cnpmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz} + name: wrap-ansi + version: 7.0.0 + engines: {node: '>=10'} + dependencies: + ansi-styles: r2.cnpmjs.org/ansi-styles@4.3.0 + string-width: r2.cnpmjs.org/string-width@4.2.3 + strip-ansi: r2.cnpmjs.org/strip-ansi@6.0.1 From 4c31d3db83a0761908748267075d2c056391b1da Mon Sep 17 00:00:00 2001 From: phk422 <1769476785@qq.com> Date: Fri, 1 Mar 2024 21:38:13 +0800 Subject: [PATCH 3/3] use `node:assert/strict`, remove `chai` --- packages/integrations/vue/package.json | 1 - packages/integrations/vue/test/toTsx.test.cts | 10 +-- pnpm-lock.yaml | 82 ++++++++++++++++--- 3 files changed, 74 insertions(+), 19 deletions(-) diff --git a/packages/integrations/vue/package.json b/packages/integrations/vue/package.json index 0f4e8e11c151..60943076cd5d 100644 --- a/packages/integrations/vue/package.json +++ b/packages/integrations/vue/package.json @@ -49,7 +49,6 @@ "@types/chai": "^4.3.10", "astro": "workspace:*", "astro-scripts": "workspace:*", - "chai": "^4.3.10", "cheerio": "1.0.0-rc.12", "linkedom": "^0.16.4", "vite": "^5.1.4", diff --git a/packages/integrations/vue/test/toTsx.test.cts b/packages/integrations/vue/test/toTsx.test.cts index 16c369138b95..28f100feac87 100644 --- a/packages/integrations/vue/test/toTsx.test.cts +++ b/packages/integrations/vue/test/toTsx.test.cts @@ -1,6 +1,6 @@ import { toTSX } from '../src/editor.cts'; -import { describe, it} from 'node:test'; -import { expect } from 'chai'; +import { describe, it } from 'node:test'; +import { strictEqual } from 'node:assert' describe('toTSX function', () => { it('should correctly transform Vue code to TSX with comments', () => { @@ -20,7 +20,7 @@ describe('toTSX function', () => { const result = toTSX(vueCode, className); // Replace the expectations below with the expected result based on your logic - expect(result).to.equal(`export default function ${className}__AstroComponent_(_props: Record): any {}`); + strictEqual(result, `export default function ${className}__AstroComponent_(_props: Record): any {}`) }); it('should correctly transform Vue code to TSX', () => { const vueCode = ` @@ -40,8 +40,6 @@ describe('toTSX function', () => { const className = 'MyComponent'; const result = toTSX(vueCode, className); - - expect(result.replace(/\s/g, '')). - to.equal(`import{defineProps}from'vue';constProps=defineProps({msg:String})exportdefaultfunction${className}__AstroComponent_(_props:typeofProps):any{
}`); + strictEqual(result.replace(/\s/g, ''), `import{defineProps}from'vue';constProps=defineProps({msg:String})exportdefaultfunction${className}__AstroComponent_(_props:typeofProps):any{
}`) }); }); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e39a03c2fdcc..1b327aa38234 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -5107,9 +5107,6 @@ importers: astro-scripts: specifier: workspace:* version: link:../../../scripts - chai: - specifier: ^4.3.10 - version: 4.4.1 cheerio: specifier: 1.0.0-rc.12 version: 1.0.0-rc.12 @@ -5118,10 +5115,10 @@ importers: version: 0.16.6 vite: specifier: ^5.1.4 - version: 5.1.4(@types/node@18.19.4)(sass@1.69.6) + version: 5.1.4 vue: specifier: ^3.3.8 - version: 3.4.3(typescript@5.2.2) + version: 3.4.3 packages/integrations/vue/test/fixtures/app-entrypoint: dependencies: @@ -5614,7 +5611,7 @@ packages: '@babel/traverse': 7.23.7 '@babel/types': 7.23.6 convert-source-map: 2.0.0 - debug: 4.3.4(supports-color@8.1.1) + debug: 4.3.4 gensync: 1.0.0-beta.2 json5: 2.2.3 semver: 6.3.1 @@ -5973,7 +5970,7 @@ packages: '@babel/helper-split-export-declaration': 7.22.6 '@babel/parser': 7.23.6 '@babel/types': 7.23.6 - debug: 4.3.4(supports-color@8.1.1) + debug: 4.3.4 globals: 11.12.0 transitivePeerDependencies: - supports-color @@ -8262,8 +8259,8 @@ packages: '@babel/core': 7.23.7 '@babel/plugin-transform-typescript': 7.23.6(@babel/core@7.23.7) '@vue/babel-plugin-jsx': 1.1.5(@babel/core@7.23.7) - vite: 5.1.4(@types/node@18.19.4)(sass@1.69.6) - vue: 3.4.3(typescript@5.2.2) + vite: 5.1.4 + vue: 3.4.3 transitivePeerDependencies: - supports-color dev: false @@ -8278,8 +8275,8 @@ packages: vite: optional: true dependencies: - vite: 5.1.4(@types/node@18.19.4)(sass@1.69.6) - vue: 3.4.3(typescript@5.2.2) + vite: 5.1.4 + vue: 3.4.3 dev: false /@vitest/expect@1.3.1: @@ -8548,7 +8545,7 @@ packages: dependencies: '@vue/compiler-ssr': 3.4.3 '@vue/shared': 3.4.3 - vue: 3.4.3(typescript@5.2.2) + vue: 3.4.3 /@vue/shared@3.1.5: resolution: {integrity: sha512-oJ4F3TnvpXaQwZJNF3ZK+kLPHKarDmJjJ6jyzVNDKH9md1dptjC7lWR//jrGuLdek/U6iltWxqAnYOu8gCiOvA==} @@ -9671,6 +9668,18 @@ packages: dependencies: ms: 2.0.0 + /debug@4.3.4: + resolution: {integrity: sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==} + engines: {node: '>=6.0'} + peerDependencies: + supports-color: '*' + peerDependenciesMeta: + supports-color: + optional: true + dependencies: + ms: 2.1.2 + dev: false + /debug@4.3.4(supports-color@8.1.1): resolution: {integrity: sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==} engines: {node: '>=6.0'} @@ -16337,6 +16346,40 @@ packages: svgo: 3.2.0 dev: false + /vite@5.1.4: + resolution: {integrity: sha512-n+MPqzq+d9nMVTKyewqw6kSt+R3CkvF9QAKY8obiQn8g1fwTscKxyfaYnC632HtBXAQGc1Yjomphwn1dtwGAHg==} + engines: {node: ^18.0.0 || >=20.0.0} + hasBin: true + peerDependencies: + '@types/node': ^18.0.0 || >=20.0.0 + less: '*' + lightningcss: ^1.21.0 + sass: '*' + stylus: '*' + sugarss: '*' + terser: ^5.4.0 + peerDependenciesMeta: + '@types/node': + optional: true + less: + optional: true + lightningcss: + optional: true + sass: + optional: true + stylus: + optional: true + sugarss: + optional: true + terser: + optional: true + dependencies: + esbuild: 0.19.11 + postcss: 8.4.35 + rollup: 4.9.2 + optionalDependencies: + fsevents: 2.3.3 + /vite@5.1.4(@types/node@18.19.4)(sass@1.69.6): resolution: {integrity: sha512-n+MPqzq+d9nMVTKyewqw6kSt+R3CkvF9QAKY8obiQn8g1fwTscKxyfaYnC632HtBXAQGc1Yjomphwn1dtwGAHg==} engines: {node: ^18.0.0 || >=20.0.0} @@ -16674,6 +16717,20 @@ packages: /vscode-uri@3.0.8: resolution: {integrity: sha512-AyFQ0EVmsOZOlAnxoFOGOq1SQDWAB7C6aqMGS23svWAllfOaxbuFvcT8D1i8z3Gyn8fraVeZNNmN6e9bxxXkKw==} + /vue@3.4.3: + resolution: {integrity: sha512-GjN+culMAGv/mUbkIv8zMKItno8npcj5gWlXkSxf1SPTQf8eJ4A+YfHIvQFyL1IfuJcMl3soA7SmN1fRxbf/wA==} + peerDependencies: + typescript: '*' + peerDependenciesMeta: + typescript: + optional: true + dependencies: + '@vue/compiler-dom': 3.4.3 + '@vue/compiler-sfc': 3.4.3 + '@vue/runtime-dom': 3.4.3 + '@vue/server-renderer': 3.4.3(vue@3.4.3) + '@vue/shared': 3.4.3 + /vue@3.4.3(typescript@5.2.2): resolution: {integrity: sha512-GjN+culMAGv/mUbkIv8zMKItno8npcj5gWlXkSxf1SPTQf8eJ4A+YfHIvQFyL1IfuJcMl3soA7SmN1fRxbf/wA==} peerDependencies: @@ -16688,6 +16745,7 @@ packages: '@vue/server-renderer': 3.4.3(vue@3.4.3) '@vue/shared': 3.4.3 typescript: 5.2.2 + dev: false /w3c-xmlserializer@4.0.0: resolution: {integrity: sha512-d+BFHzbiCx6zGfz0HyQ6Rg69w9k19nviJspaj4yNscGjrHu94sVP+aRm75yEbCh+r2/yR+7q6hux9LVtbuTGBw==}