Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

feat(module): export saveAs method and define module entrypoint #602

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

cristinecula
Copy link

Fixes #538

This enables code using es modules to do:

import {saveAs} from 'file-saver'

Legacy js code is not affected by this change.

@chrisknoll
Copy link

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: babel/babel#10696.

You probably need to put pressure on the babel group to fix their library.

@cristinecula
Copy link
Author

cristinecula commented Jun 12, 2020

@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).

@chrisknoll
Copy link

Understood, Thanks. I see it now, your addition of 'export saveAs' probably led to the change.

@kbrilla
Copy link

kbrilla commented Jun 29, 2020

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?

@fidlip
Copy link

fidlip commented Sep 10, 2020

Why this is not yet merged in? It is really helpful feature.

@agarciacalvo
Copy link

Why this is not yet merged in? It is really helpful feature.

+1

Migrating from Angular 8 to Angular 10.

@ammaarpatel99
Copy link

Is there any intension for this to be merged, or even for the creation of a seperate version as mentioned by @criskrzysiu

@woteska
Copy link

woteska commented Oct 5, 2020

Any update? Would be cool to eliminate the warning: CommonJS or AMD dependencies can cause optimization bailouts.

@PredragCrnogorac
Copy link

It's causing fail in my app, any updates?

@chrisknoll
Copy link

Is this something that we just need to rely on a fork to resolve? Unfortunate, but what else can be done?

@grungert
Copy link

grungert commented Nov 3, 2020

Any update? I have the same warning: CommonJS or AMD dependencies can cause optimization bailouts.

@swordensen
Copy link

swordensen commented Nov 5, 2020

@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://git@github.com/plumelo/FileSaver.js.git#master

then it should be easy to replace once this package gets updated.

[edit] linked the wrong package. sorry!

@chrisknoll
Copy link

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.

@swordensen
Copy link

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 :)

@chrisknoll
Copy link

In all fairness, you brought it up....

@yglodt
Copy link

yglodt commented Jan 26, 2021

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.

@jerone
Copy link

jerone commented Oct 21, 2022

@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.

Copy link
Owner

@eligrey eligrey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs a version bump

Copy link
Owner

@eligrey eligrey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm after rebuilding to resolve conflicts 👍

@mrleblanc101
Copy link

@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.

@colinscz
Copy link

@eligrey @cristinecula could you give an update on this?
Would be really cool if this PR lands soon in file-saver 👍🏽

@acohenOT
Copy link

@cristinecula can you please resolve the branch conflicts?

@colinscz
Copy link

@eligrey is there any update on this?

it's been a while... :/

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ES Modules support