unplugin-vue-components icon indicating copy to clipboard operation
unplugin-vue-components copied to clipboard

Vite tries to read source map from vite-specific path

Open shadow-light opened this issue 4 years ago • 7 comments

First raised in vite repo https://github.com/vitejs/vite/issues/4687, but I'm fairly sure it is caused by this plugin.

Describe the bug

While running vite in serve mode (but not build mode), the following error occurs for every component:

Sourcemap for "/redacted/app/src/components/global/AppBtn.vue" points to missing source files
  vite:sourcemap Missing sources:
  vite:sourcemap   /redacted/app/src/components/global/AppBtn.vue?vue&type=style&index=0&scoped=true&lang.sass

Obviously trying to read a file at a path ending with a query is going to fail. Which is what vite seems to be doing. https://github.com/vitejs/vite/blob/8048f900908009757bd20d13ee4af90ce15cd32c/packages/vite/src/node/server/sourcemap.ts#L38-L39

The path without the query is correct though. I assume vite is supposed to intercept the URL and return the source map, but instead seems to use the URL as a path and load from the file system.

Just don't know why it would do this?

System Info

System:
    OS: Linux 5.3 Debian GNU/Linux 11 (bullseye) 11 (bullseye)
    CPU: (8) x64 Intel(R) Core(TM) i7-1065G7 CPU @ 1.30GHz
    Memory: 6.56 GB / 15.41 GB
    Container: Yes
    Shell: 5.1.4 - /bin/bash
  Binaries:
    Node: 14.17.5 - /usr/bin/node
    Yarn: 1.22.11 - /usr/bin/yarn
    npm: 6.14.14 - /usr/bin/npm
  Browsers:
    Chrome: 94.0.4603.0
  npmPackages:
    vite: ^2.4.4 => 2.4.4

Used Package Manager

npm

shadow-light avatar Aug 23 '21 09:08 shadow-light

Can you share a minimal reproduction? Thanks.

antfu avatar Aug 23 '21 09:08 antfu

Ok, have created a very simple one: https://github.com/shadow-light/test_vite_components_bug

Seems to be a clash with this plugin, enabling source maps during build, and adding additionalData for sass.

shadow-light avatar Aug 23 '21 11:08 shadow-light

Did you solve that problem? That happened to me, too

weijie-code avatar Nov 01 '21 11:11 weijie-code

Had to stop using additionalData for sass. I think this bug still needs fixing.

shadow-light avatar Nov 01 '21 11:11 shadow-light

I didn't do anything but download the template and get an error

weijie-code avatar Nov 01 '21 12:11 weijie-code

After a little trial and error, I discovered this issue was introduced after version 0.17.11. Downgrading to this version has fixed the issue for me!

danielwaltz avatar Jan 25 '22 23:01 danielwaltz

Same error here. Downgrading to 0.17.11 fixes the issue.

enodr avatar Feb 11 '22 18:02 enodr