attr-accept icon indicating copy to clipboard operation
attr-accept copied to clipboard

use : var accept = require('attr-accept'); accept() accept is not a function

Open glntlq opened this issue 7 years ago • 7 comments

use : var accept = require('attr-accept');
then: accept()
result: accept is not a function

solution: import accept from 'attr-accept' ????

glntlq avatar Jul 15 '18 15:07 glntlq

I’m not sure what this is about.

okonet avatar Aug 29 '18 19:08 okonet

perhaps he is talking about the README ? as it shows its use in CommonJS instead of a babel/webpack import?

rxmarbles avatar Aug 29 '18 19:08 rxmarbles

Hmm 🤔

Do we need to update it?

okonet avatar Aug 29 '18 19:08 okonet

Is the module available via CommonJS? if so then it should be fine as is, but if not we should perhaps either fix the README or update the module so it is available via CommonJS

rxmarbles avatar Aug 29 '18 19:08 rxmarbles

Is the module available via CommonJS?

Yes, https://github.com/okonet/attr-accept/blob/master/webpack.config.js#L6

okonet avatar Sep 07 '18 08:09 okonet

Reproduction here: https://runkit.com/bsonntag/5c3362f019d6b0001713a107

Adding .default to the require() call fixes it. Like this:

var accept = require('attr-accept').default;
accept({
    name: 'my file.png',
    type: 'image/png'
}, 'image/*')

bsonntag avatar Jan 07 '19 14:01 bsonntag

attr-accept crashes Vite.js production builds because of this

When trying to upload and using react-dropzone with Vite (production build) I get accepts is not a function

if I change: import accepts from 'attr-accept'; to

import A from "attr-accept";
const accepts = A.default ? A.default : A;

react-dropzone works as it should.

fredrikbergqvist avatar Oct 18 '22 14:10 fredrikbergqvist