dropzone icon indicating copy to clipboard operation
dropzone copied to clipboard

Allow formData to be transformed async for each file

Open gugiserman opened this issue 4 years ago • 5 comments

gugiserman avatar Sep 20 '21 22:09 gugiserman

Hi @gugiserman . Thanks for you PR, but due to browser restrictions simply adding async is not as easy. I need to check whether webpack + babel properly transforms this and if it increases the bundle size considerably.

enyo avatar Sep 21 '21 13:09 enyo

Hi @gugiserman . Thanks for you PR, but due to browser restrictions simply adding async is not as easy. I need to check whether webpack + babel properly transforms this and if it increases the bundle size considerably.

Hey @enyo , I was expecting that answer already, no worries! I didn't have the time to properly test the async support but I needed this fork to hotfix a project I'm working on ASAP and it worked over there. Coincidence? Who knows. Then I decided to leave the PR here to discuss with all first.

I was going to leave it as draft, I don't know why I marked as ready for review. My bad 😃 (If you can revert it, please feel free to do so, or close it and I can come back later on).

As soon as I have the time I will push the unit tests I added and take a good in-depth look at the final bundle and bring you the results.

Thanks for the quick reply!

gugiserman avatar Sep 21 '21 15:09 gugiserman

The reason I haven't merged this yet, is because I'm hesitant in piling on feature after feature. Dropzone is pretty heavy as it is at the moment, and I want to avoid running the risk of making it even more unmaintainable.

I see the need for something like this however. I just don't like that now there are two ways to achieve the same thing: either listening to the event, or setting the transform function. That makes me wonder whether it's even necessary to have the event in the first place... 🤔

PS: if you don't mind removing the yarn.lock file from the PR that would make it easier for me to merge in the future.

enyo avatar Oct 26 '21 08:10 enyo

I see. If the transform works well we could deprecate the event, yeah.

I still didn't have the time to properly address your concerns about the code, I also feel I need to make the code more similar to the rest of the codebase as well as add the missing tests. I will try to do that next weekend.

About yarn.lock: no worries, I will get rid of it asap.

gugiserman avatar Oct 26 '21 18:10 gugiserman

Regarding the await/async code that's not an issue anymore. Dropzone 6 dropped IE support and it compiles to Promises properly for the browsers that are still needed.

enyo avatar Oct 27 '21 15:10 enyo