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.

Ical.js under CommonJS (Node.js) leaks global ICAL variable

See original GitHub issue

Hey,

Noticed some of my tests failing because they spot a global variable leakage. Turns out https://github.com/mozilla-comm/ical.js/blob/f3b8c7dc24a66424feb1735fe7ff38191e46ab99/lib/ical/helpers.js#L11 sets a global ICAL that is entirely unnecessary when running under CommonJS modules like when ran under Node.js. That ICAL variable should be scoped somehow to not set undesired globals. 😉

Cheers

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
kewischcommented, Feb 14, 2022

#470 should fix most of this, the rest via es6 modules which is work in progress

1reaction
mediaessenzcommented, May 20, 2021

I have exacly the same problem in conjuction with fullcalender.io’s icalendar plugin, which uses this lib as well. It took me hours to find the reason and using the same workaround than @pscs now, which i find quite ugly as well.

To help other people who have the same problem, here is the exact error, i got in the js console: “Uncaught ReferenceError: assignment to undeclared variable ICAL”

To fix it, i changed line 11 of node_modules/ical.js/build/ical.js from

ICAL = module.exports;

to

var ICAL = module.exports;
Read more comments on GitHub >

github_iconTop Results From Across the Web

Ical.js under CommonJS (Node.js) leaks global ICAL variable
Hey, Noticed some of my tests failing because they spot a global variable leakage.
Read more >
node-ical - npm
NodeJS class for parsing iCalendar/ICS files. Latest version: 0.15.3, last published: 16 days ago. Start using node-ical in your project by ...
Read more >
Understanding Memory Leaks in Nodejs | by Chidume Nnamdi
Global Variable. We learned that in JS's GC MArk-and-Sweep algorithm that global variables are never collected as they are always marked as ...
Read more >
@fullcalendar/core | Yarn - Package Manager
FIX: Remove global js 'default' from export maps (#7047) ... #6106); fix: removed accidental ical.js dependency in common's package.json (#6171) ...
Read more >
CommonJS modules | Node.js v19.3.0 Documentation
In this example, the variable PI is private to circle.js . The module.exports property can be assigned a new value (such as a...
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