use : var accept = require('attr-accept'); accept() accept is not a function
use : var accept = require('attr-accept');
then: accept()
result: accept is not a function
solution: import accept from 'attr-accept' ????
I’m not sure what this is about.
perhaps he is talking about the README ? as it shows its use in CommonJS instead of a babel/webpack import?
Hmm 🤔
Do we need to update it?
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
Is the module available via CommonJS?
Yes, https://github.com/okonet/attr-accept/blob/master/webpack.config.js#L6
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/*')
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.