3 ms·
> Don't do this: > module.exports = IPFSDropzone > Do this (and change documentation accordingly) > module.exports = {IPFSDropzone} Why? Exporting a
by allover 9y ago
> Don't do this:
> module.exports = IPFSDropzone
> Do this (and change documentation accordingly)
> module.exports = {IPFSDropzone}
Why? Exporting a single class for this kind of lib is preferable. I'd do:
export default IPFSDropzone;
See react-dropzone which does this [1]. (For that matter the author's questions around project setup would probably be answered by looking at react-dropzone's which looks pretty good).
Also with npm scripts, local deps that expose executables are added to your PATH so you can call them directly, e.g.
"prepublish": "babel *.js -d build/"
[1] https://github.com/react-dropzone/react-dropzone/blob/master/src/index.js#L415 https://github.com/react-dropzone/react-dropzone/blob/master...
- DiThi 9y agoBecause having a mix of libraries/modules which some export defaults and some don't makes it cumbersome to require them here and there: I have to remember which was exported as default and which had the class inside. Also it makes more obvious visually which variables are modules and which are classes/functions. For my projects I avoid default exports even when a module only has one class (which happens frequently). Additionally, ES6 default exports don't mix well with commonJS, sometimes I have to add require('foo').default for no apparent reason. > Also with npm scripts, local deps that expose executables are added to your PATH I think it didn't work reliably on windows or cygwin or something. I just tried and it works everywhere. Good to know! The only gotcha is that ";" and "&&" must have spaces around.