Skip to content

Commit

Permalink
fix: normalize virtual id
Browse files Browse the repository at this point in the history
closes #386
  • Loading branch information
sxzz committed Jun 1, 2023
1 parent 77833d4 commit abd3f06
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
6 changes: 6 additions & 0 deletions .changeset/honest-jokes-perform.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@vue-macros/reactivity-transform': patch
'@vue-macros/define-models': patch
---

normalize virtual file path
4 changes: 2 additions & 2 deletions packages/define-models/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ export default createUnplugin<Options | undefined, false>(
enforce: 'pre',

resolveId(id) {
if (id.startsWith(helperPrefix)) return id
if (normalizePath(id).startsWith(helperPrefix)) return id
},

loadInclude(id) {
return id.startsWith(helperPrefix)
return normalizePath(id).startsWith(helperPrefix)
},

load(_id) {
Expand Down
9 changes: 4 additions & 5 deletions packages/reactivity-transform/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,15 @@ export default createUnplugin<Options | undefined, false>(
enforce: 'pre',

resolveId(id) {
if (id === helperId) return id
if (id === normalizePath(helperId)) return id
},

loadInclude(id) {
return id === helperId
return normalizePath(id) === helperId
},

load(_id) {
const id = normalizePath(_id)
if (id === helperId) return helperCode
load(id) {
if (normalizePath(id) === helperId) return helperCode
},

transformInclude(id) {
Expand Down

0 comments on commit abd3f06

Please sign in to comment.