<p>Just encountered a *wild* JavaScript bug.</p><p>App code:<br />let myDate = DateTime.now();</p><p>Library code:<br />`myDate instanceof DateTime` was false, why??</p><p>First thought: multiple different versions of `DateTime` ("luxon") package installed via npm? Nope.</p><p>Actual culprit:</p><p>App code:<br />const { DateTime } = require("luxon");</p><p>Library code:<br />import { DateTime } from "luxon";</p><p>Luxon exports different versions of DateTime for CommonJS and ESM 😠I may never trust `instanceof` again 😬 Best friend .contructor.name now</p>
- Post #240
- Next March 4, 2025 at 5:13:00 PM UTC
- Previous March 3, 2025 at 8:59:29 PM UTC
- Tue, 04 Mar 2025 14:56:50 GMT — Zach Leatherman
- Original on Fediverse