Nexodus Archive: Fediverse


<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>