You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
exportdefaultfunctionmyPlugin(){constvirtualModuleId='virtual:my-module'constresolvedVirtualModuleId='\0'+virtualModuleIdreturn{name: 'my-plugin',// required, will show up in warnings and errorsresolveId(id){if(id===virtualModuleId){returnresolvedVirtualModuleId}},load(id){if(id===resolvedVirtualModuleId){// This Line, id isn't has '\0' prefixreturn`export const msg = "from virtual module"`}},}}
But in my plugin, I found that the behavior is inconsistent with the examples on the '\0' prefix.
Office example: The prefixed virtual module id is returned in resolveId hook. And then, the prefixed virtual module id is used in the load hook ( if (id === resolvedVirtualModuleId) { ...... ).
example: id: 'virtual:my-module', resolved return: '\0virtual:my-module', in load hook id param: '\0virtual:my-module'.
In my plugin development, I found that I return the '\0' prefixed virtual module id in resolveId hook,
but it isn't prefixed in load hook.
example: id: 'virtual:my-module', resolved return: '\0virtual:my-module', in load hook id param: 'virtual:my-module'.
In addition, in configureServer hook, the prefix is the same as in the official website example /@id/__x00__{id}
I suspect that the official website example is misleading, or there may be other reasons.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
env: vite 6.2.0
About the '\0' prefix. Link
Office example:
But in my plugin, I found that the behavior is inconsistent with the examples on the '\0' prefix.
Office example: The prefixed virtual module id is returned in
resolveId
hook. And then, the prefixed virtual module id is used in theload
hook (if (id === resolvedVirtualModuleId) { ......
).example: id:
'virtual:my-module'
, resolved return:'\0virtual:my-module'
, in load hook id param:'\0virtual:my-module'
.In my plugin development, I found that I return the '\0' prefixed virtual module id in resolveId hook,
but it isn't prefixed in load hook.
example: id:
'virtual:my-module'
, resolved return:'\0virtual:my-module'
, in load hook id param:'virtual:my-module'
.In addition, in configureServer hook, the prefix is the same as in the official website example
/@id/__x00__{id}
I suspect that the official website example is misleading, or there may be other reasons.
Beta Was this translation helpful? Give feedback.
All reactions