Split up src/sweetalert2.js
See original GitHub issue1403 lines of code is wayyyy too much for one module. We have a module bundler set up in our build pipe-line, so lets take advantage of it! All the constant scrolling is killing me when I work on this code. If we split up the code into multiple modules, we can (a) find things faster, and (b) easily work in more than one area at a time.
I don’t really care how it’s split up, so long as it’s reasonable, and so long as it’s split up.
Like I mentioned here https://github.com/sweetalert2/sweetalert2/issues/865#issuecomment-369577660 it’s possible to move code into methods on a SwalContext
object. I think we should do that, and also extract more utility functions.
Is anyone opposed to this? Either in general, or at this specific time? Obviously there will be a lot of code change to review and it could result in merge conflicts, but we can try to get all done quickly and at once.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:3
- Comments:6 (6 by maintainers)
So, update: the former main module has been completely dissolved. Now the entry point is 4 lines of code including blank lines, the module containing the Swal class/function is 72, and there are many small modules in
src/utils
,src/staticMethods
andsrc/instanceMethods
. ThoughinstanceMethods/_main.js
is still pretty big at 548 LOC and should be broken down. I’m pretty sure that is by far the largest module.The issue was “Split up src/sweetalert2.js” so I think it’s fair to say this can be closed
Agreed, partly why #824 was taking so long. My new code is 95% contained in its own modules so won’t cause me too much pain when it is ready to merge.
Module at a time might make it easier to review and reason about, if that’s possible.