Provide a general summary of the bug here
In Vite, when importing iconv-lite, a warning will appear stating stream.Transform can't be accessed, linking to these Vite troubleshooting docs:
...If the module is imported from a third-party library (that's meant to be used in the browser), it's advised to report the issue to the respective library.
It seems that this is the affected code.
|
// Enable Streaming API automatically if 'stream' module is available and non-empty (the majority of environments). |
|
var streamModule |
|
try { |
|
streamModule = require("stream") |
|
} catch (e) {} |
Vite team member bluwy has said (vitejs/vite#9837 (comment))
Looks like the reason deps access them, even if there are browser friendly is because they are doing a "try import and test if exist" flow, which isn't a great technique for browser compatibility. They should not use the nodejs module at all via browsers and exports field.
Steps to Reproduce
Import iconv-lite in Vite while having a Buffer polyfill.
Module "stream" has been externalized for browser compatibility. Cannot access "stream.Transform" in client code. See https://vite.dev/guide/troubleshooting.html#module-externalized-for-browser
-compatibility for more details.
StackBlitz
Versions
iconv-lite@0.7.2
vite@8.0.14
Provide a general summary of the bug here
In Vite, when importing iconv-lite, a warning will appear stating stream.Transform can't be accessed, linking to these Vite troubleshooting docs:
It seems that this is the affected code.
iconv-lite/lib/index.js
Lines 163 to 167 in 6cf4f08
Vite team member bluwy has said (vitejs/vite#9837 (comment))
Steps to Reproduce
Import iconv-lite in Vite while having a Buffer polyfill.
StackBlitz
Versions
iconv-lite@0.7.2
vite@8.0.14