-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
是否支持 new URL('xxx.wasm',import.meta.url) 方法,目前测试是无效 #83
Comments
之前没有遇到过 new URL 的情况,我需要了解下 |
@chenli1989 new URL('xxx.wasm', import.meta.url) 形式的资源引用是由 Vite 内置插件处理的,lib-assets 也可以采用相同的方式获取到被引入的资源,然后将 Vite 生成的 base64 内容替换回资源的地址,但我还需要对这种形式使用 URL 进行一些调研,避免破坏已有的代码。 |
I would like to chime in here as well. I hope translation was correct and I didn't miss anything but using the following syntax is a good workaround: instead of new URL("./demo.wasm", import.meta.url).href use import demoURL from "./demo.wasm?url" This solved the base64 encoding issue but I get the following warning(s) during build
Not sure if this is something to worry about though. Any comments @coder-layne? |
@DenizUgur I'm not quite sure what the difference is between This warning occurs because the plugin emits assets to a specified directory and then marks them as external. If your output is in |
Thank you @coder-layne for your reply. I get these warnings for a |
@DenizUgur I am using the build configuration in the project playground, and I did not encounter the warning you mentioned when outputting the |
It was difficult to reproduce but here you go: codesandbox link. Run |
@DenizUgur The plugin will externalize files that meet the inclusion criteria, and Rollup will attempt to acquire the global variable names of external modules when outputting in the |
@DenizUgur Additionally, the plugin is used to handle asset files. It treats the content of files as strings, which may cause problems when dealing with scripts. |
No warnings, that was it. Thank you for pointing that out.
I'm using the syntax I've mentioned above to get the asset's public URL so I'm not interested with the content as well. |
@DenizUgur Glad that the plugin fits your scenario :) |
@coder-layne Does the plugin work for this syntax?
In my case I'm not getting it to work by configuring the plugin and I don't have the option to change the syntax to the suggested format
because it's in an npn package I'm using and don't have control over. |
@P422L Thank you for your feedback. It seems necessary to reconsider the initial plan.
|
It would be awesome having the plugin supporting those imports as they've become vites recommended way of dynamically importing. |
@P422L Just released v1.1.0 under the |
vite.config.ts 文件配置是以下:编译结果还是转为 base64 内联,是否支持wasm文件?还是哪里配置不正确?
代码是
编译结果还是 base64
The text was updated successfully, but these errors were encountered: