FileSaver.js icon indicating copy to clipboard operation
FileSaver.js copied to clipboard

Version 2.0.0 cannot be used with rollup

Open davideicardi opened this issue 6 years ago • 4 comments

I'm trying to use file-saver version 2.0.0 with rollup, but I get the following error:

(!) Missing exports
https://rollupjs.org/guide/en#error-name-is-not-exported-by-module-
src/ExportCsv.js
saveAs is not exported by node_modules/file-saver/dist/FileSaver.min.js

I'm importing it using:

import * as FileSaver from 'file-saver';

tried also:

import { saveAs } from 'file-saver';

Version 1.3.8 works correctly. I don't understand exactly why.

Any idea?

davideicardi avatar Jan 16 '19 20:01 davideicardi

I don't know the cause, but now rollup.js will give you a hint. A solution that worked for me was: commonjs({ namedExports: { 'file-saver': [ 'saveAs' ] } })

remailednet avatar Aug 23 '19 13:08 remailednet

I have the same issue in a StencilJS/ Rollup project.

@davideicardi thanks for the 1.3.8 hint!

bitflower avatar Feb 11 '20 09:02 bitflower

I'm also experiencing this problem in a StencilJS v2 project which has deprecated support for the commonjs workaround by @remailednet.

Disappointing that this hasn't been addressed in almost 2-1/2 years. We will most likely have to roll back to v1.3.8.

gtranter avatar Jun 16 '22 17:06 gtranter

Adding @rollup/plugin-commonjs plugin to the rollup config should solve the problem.

https://rollupjs.org/troubleshooting/#error-name-is-not-exported-by-module

vskorohod avatar Feb 01 '24 10:02 vskorohod