jimmywarting / StreamSaver.js

StreamSaver writes stream to the filesystem directly asynchronous
https://jimmywarting.github.io/StreamSaver.js/example.html
MIT License
3.95k stars 413 forks source link

Document undefined issue #301

Open preetpreet opened 1 year ago

preetpreet commented 1 year ago

image (46)

could you please add the condition

jimmywarting commented 1 year ago

i think you should rather do a conditional import/require (parhaps some code splitting or dynamic import just when required) why do you load StreamSaver on a server?

preetpreet commented 1 year ago

if you can help, your lot thanks could you please more clearification

jimmywarting commented 1 year ago

something like:

if (condition) {
    import('something')
    .then((something) => {
       console.log(something.something);
    });
}
preetpreet commented 1 year ago

Is it working in react js ?? This condition ??

jimmywarting commented 1 year ago

maybe. haven't tried out react if its build process dose support code splitting.

preetpreet commented 1 year ago

could you please try, otherwise you can add the condition undefiend

hsoulier commented 1 year ago

You can write your function like this 🤝

const myDownloadFunction  = async () => {
    const streamSaver = await import("streamsaver")
    // OR 
    const streamSaver = await require("streamsaver")
    // Do your fetch or anything
}