vitejs / vite-plugin-vue

Vite Vue Plugins
MIT License
501 stars 154 forks source link

The value of compiler is differenet with vue playground #427

Closed s3xysteak closed 4 months ago

s3xysteak commented 4 months ago

Related plugins

Describe the bug

vite playground vue playground

Code is :

<template>
  <img src="assets:~/logo.svg" one="1" >
</template>

In vite playground, the value of compiler is:

// ...
import _imports_0 from '/logo.svg'

const _hoisted_1 = {
  src: _imports_0,
  one: "1"
}

function _sfc_render(_ctx, _cache) {
  return (_openBlock(), _createElementBlock("img", _hoisted_1))
}
// ...

With same code in vue playground, the value is:

// ...
const _hoisted_1 = {
  src: "assets:~/logo.svg",
  one: "1"
}
function render(_ctx, _cache) {
  return (_openBlock(), _createElementBlock("img", _hoisted_1))
}

Reproduction

https://stackblitz.com/edit/vitejs-vite-fvy9gv?file=src%2FApp.vue

Steps to reproduce

Run and see the console and error reported, it will show the code different with what in vue playground.

System Info

System:
    OS: Windows 10 10.0.19045
    CPU: (8) x64 Intel(R) Core(TM) i3-10100 CPU @ 3.60GHz
    Memory: 5.62 GB / 15.90 GB
  Binaries:
    Node: 20.10.0 - ~\AppData\Local\fnm_multishells\17064_1721032557973\node.EXE
    npm: 10.2.3 - ~\AppData\Local\fnm_multishells\17064_1721032557973\npm.CMD
    pnpm: 9.4.0 - ~\AppData\Local\pnpm\pnpm.CMD
  Browsers:
    Edge: Chromium (126.0.2592.102)
    Internet Explorer: 11.0.19041.4355

Used Package Manager

pnpm

Logs

No response

Validations

s3xysteak commented 4 months ago

It is because the plugin try to handle the asserts in template.