Skip to content

Make simple-jscalendar usable as an ES module while preserving legacy #71

Description

@Kazio73

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch simple-jscalendar@1.4.5 for the project I'm working on.

Here is the diff that solved my problem:

diff --git a/node_modules/simple-jscalendar/source/jsCalendar.js b/node_modules/simple-jscalendar/source/jsCalendar.js
index de21fda..58df88c 100755
--- a/node_modules/simple-jscalendar/source/jsCalendar.js
+++ b/node_modules/simple-jscalendar/source/jsCalendar.js
@@ -1547,3 +1547,16 @@ var jsCalendar = (function(){
     // Return
     return JsCalendar;
 })();
+
+// expose for lang packs (they expect window.jsCalendar)
+if (typeof window !== 'undefined') {
+    window.jsCalendar = jsCalendar;
+
+    // consume queued languages (if lang loaded before core)
+    if (Array.isArray(window.jsCalendar_language2load)) {
+        window.jsCalendar_language2load.forEach((lang) => jsCalendar.addLanguage(lang));
+        window.jsCalendar_language2load.length = 0;
+    }
+}
+export { jsCalendar };
+

This issue body was partially generated by patch-package.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions