Skip to content

Commit 563b2f0

Browse files
committed
fix(compiler): use modelValueModifiers instead of modelModifiers
1 parent dd86742 commit 563b2f0

File tree

21 files changed

+679
-425
lines changed

21 files changed

+679
-425
lines changed

docs/introduction/getting-started.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,15 @@ We assume you are already familiar with the basic usages of Vue before you conti
88

99
- Node.js `>= v18.0.0`.
1010
- Vue `>= v3.6`.
11-
- VSCode extension [TS Macro](https://marketplace.visualstudio.com/items?itemName=zhiyuanzmj.vscode-ts-macro) and `@ts-macro/tsc`.
11+
- VSCode extension [TS Macro](https://marketplace.visualstudio.com/items?itemName=zhiyuanzmj.vscode-ts-macro) and install `@ts-macro/tsc` instead of `tsc` to typecheck.
12+
```json
13+
{
14+
"scripts": {
15+
"typecheck": "tsmc --noEmit"
16+
// ...
17+
}
18+
}
19+
```
1220

1321
### Install
1422

@@ -17,7 +25,7 @@ We assume you are already familiar with the basic usages of Vue before you conti
1725
pnpm add vue-jsx-vapor
1826

1927
# runtime
20-
pnpm add https://pkg.pr.new/vue@eeab9c4
28+
pnpm add https://pkg.pr.new/vue@3e7464f
2129
```
2230

2331
The Vue Vapor runtime is not release, so we use [pkg.pr.new](https://github.com/stackblitz-labs/pkg.pr.new) to install.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"@sxzz/eslint-config": "^6.0.2",
4242
"@ts-macro/tsc": "^0.1.24",
4343
"@types/node": "^22.13.10",
44-
"@vue-macros/reactivity-transform": "3.0.0-beta.4",
44+
"@vue-macros/reactivity-transform": "catalog:",
4545
"bumpp": "^10.0.3",
4646
"conventional-changelog-cli": "^5.0.0",
4747
"eslint": "^9.22.0",

packages/babel/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@
5757
"dependencies": {
5858
"@babel/core": "catalog:",
5959
"@babel/parser": "catalog:",
60-
"@babel/plugin-syntax-jsx": "^7.25.9",
61-
"@babel/traverse": "^7.26.9",
60+
"@babel/plugin-syntax-jsx": "catalog:",
61+
"@babel/traverse": "catalog:",
6262
"@babel/types": "catalog:",
6363
"@vue-jsx-vapor/compiler": "workspace:*",
6464
"source-map-js": "^1.2.1"

packages/compiler/src/transform.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
type OperationNode,
1818
type RootIRNode,
1919
type RootNode,
20+
type SetEventIRNode,
2021
} from './ir'
2122
import { newBlock, newDynamic } from './transforms/utils'
2223
import { findProp, getText, isConstantExpression, isTemplate } from './utils'
@@ -39,6 +40,7 @@ export interface DirectiveTransformResult {
3940
modifier?: '.' | '^'
4041
runtimeCamelize?: boolean
4142
handler?: boolean
43+
handlerModifiers?: SetEventIRNode['modifiers']
4244
model?: boolean
4345
modelModifiers?: string[]
4446
}

packages/compiler/test/transforms/__snapshots__/vModel.spec.ts.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
22

3-
exports[`compiler: vModel transform > component > v-model for component should generate modelModifiers 1`] = `
3+
exports[`compiler: vModel transform > component > v-model for component should generate modelValueModifiers 1`] = `
44
"
55
const n0 = _createComponent(Comp, { modelValue: () => (foo),
66
"onUpdate:modelValue": () => _value => (foo = _value),
7-
modelModifiers: () => ({ trim: true, "bar-baz": true }) })
7+
modelValueModifiers: () => ({ trim: true, "bar-baz": true }) })
88
return n0
99
"
1010
`;

packages/compiler/test/transforms/vModel.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,13 +244,13 @@ describe('compiler: vModel transform', () => {
244244
})
245245
})
246246

247-
test('v-model for component should generate modelModifiers', () => {
247+
test('v-model for component should generate modelValueModifiers', () => {
248248
const { code, ir } = compileWithVModel(
249249
'<Comp v-model_trim_bar-baz={foo} />',
250250
)
251251
expect(code).toMatchSnapshot()
252252
expect(code).contain(
253-
`modelModifiers: () => ({ trim: true, "bar-baz": true })`,
253+
`modelValueModifiers: () => ({ trim: true, "bar-baz": true })`,
254254
)
255255
expect(ir.block.dynamic.children[0].operation).toMatchObject({
256256
type: IRNodeTypes.CREATE_COMPONENT_NODE,

packages/macros/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@
172172
}
173173
},
174174
"dependencies": {
175-
"@vue-macros/common": "3.0.0-beta.4",
175+
"@vue-macros/common": "catalog:",
176176
"@vue/compiler-sfc": "catalog:",
177177
"@vue/language-core": "^2.2.8",
178178
"hash-sum": "^2.0.0",
@@ -184,7 +184,7 @@
184184
"@nuxt/kit": "catalog:",
185185
"@nuxt/schema": "catalog:",
186186
"@types/hash-sum": "^1.0.2",
187-
"@vue-macros/test-utils": "3.0.0-beta.4",
187+
"@vue-macros/test-utils": "catalog:",
188188
"vue": "catalog:"
189189
}
190190
}

packages/macros/src/core/define-component/await.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ function processAwait(
8686
s,
8787
0,
8888
`withAsyncContext`,
89-
'vue',
9089
)}(${containsNestedAwait ? `async ` : ``}() => `,
9190
)
9291
s.appendLeft(

packages/macros/src/core/define-component/index.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ export function transformDefineComponent(
1818
defineComponentName &&
1919
!['defineComponent', 'defineVaporComponent'].includes(defineComponentName)
2020
) {
21-
// @ts-expect-error should be removed after @vue-macros/common released.
22-
importHelperFn(s, 0, 'defineComponent', 'vue', false, defineComponentName)
21+
importHelperFn(s, 0, 'defineComponent', defineComponentName)
2322
}
2423

2524
let hasRestProp = false
@@ -32,7 +31,7 @@ export function transformDefineComponent(
3231
generateRestProps: (restPropsName, index, list) => {
3332
if (index === list.length - 1) {
3433
hasRestProp = true
35-
const useAttrs = importHelperFn(s, 0, 'useAttrs', 'vue')
34+
const useAttrs = importHelperFn(s, 0, 'useAttrs')
3635
return `const ${restPropsName} = ${useAttrs}()`
3736
}
3837
},

packages/macros/src/core/define-expose.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export function transformDefineExpose(
1010
s.appendRight(
1111
node.arguments[0]?.start || node.end! - 1,
1212
lib.includes('vapor')
13-
? `${importHelperFn(s, 0, 'currentInstance', 'vue')}.exposed = `
14-
: `${importHelperFn(s, 0, 'getCurrentInstance', 'vue')}().exposed = `,
13+
? `${importHelperFn(s, 0, 'currentInstance')}.exposed = `
14+
: `${importHelperFn(s, 0, 'getCurrentInstance')}().exposed = `,
1515
)
1616
}

0 commit comments

Comments
 (0)