打包后,被defineAsyncComponent引入的插件,需要模块js相对路径,而不是url相对路径。
Version
3.0.11
Steps to reproduce
- 制作插件: pdf-autotable(vite vue3 ts)
- 打包
- 作为插件引入到webapp/plugins/pdf-autotable
- webapp/pdf-autotable-demo.html,type module 使用这个插件
- console报404错误,原因是找不到被defineAsyncComponent引入的插件
What is expected?
打包后,被defineAsyncComponent引入的插件,需要模块js相对路径,而不是url相对路径。
What is actually happening?
vite打包后似乎只能根目录启动,不能放到我的web其他目录使用,我想把vue app做成插件,这似乎不太好实现
打包后,异步组件编译成__vitePreload加载,需要模块js相对路径,而不是url相对路径。 编译后的源码: const HelloWorld = defineAsyncComponent(() => __vitePreload(() => import("./HelloWorld.699d1cd2.js"), true ? ["./assets/HelloWorld.699d1cd2.js","./assets/HelloWorld.fd7ce5b2.css"] : void 0)); 数组处的路径,最终被识别为url的相对路径,而不是该源码js的相对路径
Thank you for reporting this but please provide a runnable reproduction as instructed by our issue helper. If it cannot be reproduced with our SFC playground or CodeSandbox, please create a GitHub repo for it and make sure the reproduction you provide is minimal (without unnecessary code or dependencies). Read more here.