eligrey / eligrey/FileSaver.js
Cannot dynamic import FileSaver.js
- Dominant language
- JavaScript
- Stars
- 22k
- Forks
- 4.3k
- PR merge metrics
- No merged PRs in 30d
Description
## What's wrong?
It gets error when import `FileSaver` dynamically
```javascript
(async() => {
const FileSaverSrc = "./FileSaver.js";
const FileSaverLib = await import(FileSaverSrc);
var blob = new Blob(["Hello, world!"], { type: "text/plain;charset=utf-8" });
saveAs(blob, "hello world.txt");
})();
```

## Temporary solution
Just remove or make comment 11st line.
```javascript
(function (global, factory) {
if (typeof define === "function" && define.amd) {
define([], factory);
} else if (typeof exports !== "undefined") {
factory();
} else {
var mod = {
exports: {}
};
factory();
// global.FileSaver = mod.exports; <- remove this line !!
}
})(this, function () {
```
---
## Test repo
Here is my test repo.
https://github.com/mirusu400/FileSaver-Issue
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.