Suppress Vite warnings about dynamic import?
Bluebie opened this issue · comments
Hey, I'm trying to use cbor-codec in a Vite bundle (inside SvelteKit project) and it's emitting a warning:
11:01:08 am [vite] warning:
/Users/phx/GitHub/find-sign-website/node_modules/.vite/deps/cbor-codec_esm_index_mjs.js
92 | return new TextEncoder("utf-8").encode(utf8);
93 | }
94 | typeof crypto !== "undefined" ? crypto.getRandomValues.bind(crypto) : import("node:crypto".trim()).then((m) => m.randomFillSync);
| ^
95 | function as_u8_buffer(u8) {
96 | if (u8 instanceof Uint8Array) {
The above dynamic import cannot be analyzed by vite.
See https://github.com/rollup/plugins/tree/master/packages/dynamic-import-vars#limitations for supported dynamic import formats. If this is intended to be left as-is, you can use the /* @vite-ignore */ comment inside the import() call to suppress this warning.
Adding a simple comment would suppress this in Vite to improve dev ux.
Thanks for opening the issue. With the fix, the dynamic import should be statically analyzable in cbor-codec@0.9.7
I just published.
I updated the dependency where that code resides and republished both packages. (see u8-utils:f5c11b22 for the fix)
LGTM! Thanks!