question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Split up src/sweetalert2.js

See original GitHub issue

1403 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:closed
  • Created 6 years ago
  • Reactions:3
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
zenflowcommented, Mar 27, 2018

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 and src/instanceMethods. Though instanceMethods/_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

1reaction
samturrellcommented, Mar 1, 2018

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

SweetAlert2 - a beautiful, responsive, customizable and ...
A beautiful, responsive, customizable and accessible (WAI-ARIA) replacement for JavaScript's popup boxes.
Read more >
sweet-alert display HTML code in text - Stack Overflow
I created SweetAlert2 with HTML support in modal and some other ... <script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>.
Read more >
Guides - SweetAlert
A beautiful replacement for JavaScript's 'alert'
Read more >
sweetalert2 | Yarn - Package Manager
A beautiful, responsive, customizable and accessible (WAI-ARIA) replacement for JavaScript's popup boxes, supported fork of sweetalert.
Read more >
Open Source — Sweet Alert 2 - codeburst
Sweet Alert 2 is a replacement for default JavaScript pop up boxes. It needs zero dependencies, and is customizable and responsive. It's ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found