FileSaver.js
FileSaver.js copied to clipboard
feat(module): export saveAs method and define module entrypoint
Fixes https://github.com/eligrey/FileSaver.js/issues/538
This enables code using es modules to do:
import {saveAs} from 'file-saver'
Legacy js code is not affected by this change.
So, I don't think this PR will be accepted because you're manipulating a dist output coming from babel transform. The underlying problem here is that the babel transform to UMD is messed up with respect to exports. This is discussed here: https://github.com/babel/babel/issues/10696.
You probably need to put pressure on the babel group to fix their library.
@chrisknoll the updated dist output is generated by babel, I did not edit it by hand (I might be wrong though... this PR is very old).
Understood, Thanks. I see it now, your addition of 'export saveAs' probably led to the change.
Angular 10 is putting pressure on moving from Common JS to ES modules, could we for example put this pr as separate version of filesaver.js just like with lodash-es?
Why this is not yet merged in? It is really helpful feature.
Why this is not yet merged in? It is really helpful feature.
+1
Migrating from Angular 8 to Angular 10.
Is there any intension for this to be merged, or even for the creation of a seperate version as mentioned by @criskrzysiu
Any update? Would be cool to eliminate the warning: CommonJS or AMD dependencies can cause optimization bailouts.
It's causing fail in my app, any updates?
Is this something that we just need to rely on a fork to resolve? Unfortunate, but what else can be done?
Any update? I have the same warning: CommonJS or AMD dependencies can cause optimization bailouts.
@cristinecula thanks for doing the legwork on this. Hopefully it gets merged soon.
In the meantime, I thought I'd share an easy way to install this PR in your node modules folder for us script kiddies out there:
npm i git+ssh://[email protected]/plumelo/FileSaver.js.git#master
then it should be easy to replace once this package gets updated.
[edit] linked the wrong package. sorry!
Our dependencies are loaded via package.json. Can I specify that information in the package dependencies? Making all our consumers of our library run that command manually for their local installs is not feasible.
Our dependencies are loaded via package.json. Can I specify that information in the package dependencies? Making all our consumers of our library run that command manually for their local installs is not feasible.
Sorry about that, I @'d the wrong person. To answer your question that line should add the fork to your package.json dependencies. But, if you have any more questions regarding installing packages from github I highly suggest using stack overflow so this thread can remain on topic :)
In all fairness, you brought it up....
I stumbled across https://www.npmjs.com/package/file-saver-es which seems to address this issue.
Not sure how "official" this package is however.
@eligrey As the sole owner of this repo, can you have a look at this PR. It will help the whole Angular community if this gets merged.
@eligrey Since you approved the PR, could you merge and publish a new version ? It has been 3 years since the PR has been opened and it's still an issue.
I get this in Nuxt 3 when I generate
for static hosting.
Named export 'saveAs' not found. The requested module 'file:///Users/sleblanc/Github/neobigben/node_modules/file-saver/dist/FileSaver.min.js' is a CommonJS module, which may not support all module.exports as named exports.
@eligrey @cristinecula could you give an update on this? Would be really cool if this PR lands soon in file-saver 👍🏽
@cristinecula can you please resolve the branch conflicts?
@eligrey is there any update on this?
it's been a while... :/