Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

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

Open
glntlq opened this issue Jul 15, 2018 · 7 comments

Comments

@glntlq
Copy link

glntlq commented Jul 15, 2018

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

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

@okonet
Copy link
Collaborator

okonet commented Aug 29, 2018

I’m not sure what this is about.

@rxmarbles
Copy link
Collaborator

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

@okonet
Copy link
Collaborator

okonet commented Aug 29, 2018

Hmm 🤔

Do we need to update it?

@rxmarbles
Copy link
Collaborator

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

@okonet
Copy link
Collaborator

okonet commented Sep 7, 2018

Is the module available via CommonJS?

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

@bsonntag
Copy link

bsonntag commented Jan 7, 2019

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/*')

@fredrikbergqvist
Copy link

fredrikbergqvist commented Oct 18, 2022

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.

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

No branches or pull requests

5 participants