From 174a845c78be727e56bed6f9b69be8d1ac1d040f Mon Sep 17 00:00:00 2001 From: Ryan Mwangi Date: Wed, 20 Nov 2024 13:58:35 +0300 Subject: [PATCH] fix(import): enable compatibility between ES modules and CommonJS for ical.jsRenamed ical.js to ical.cjs to explicitly mark it as a CommonJS module and used `createRequire` to import it into the ES module project. This resolves module system conflicts and ensures seamless integration without modifying ical.js content. --- package.json | 2 +- src/lib/{ical.js => ical.cjs} | 0 src/lib/ical.timezones.js | 5 ++++- 3 files changed, 5 insertions(+), 2 deletions(-) rename src/lib/{ical.js => ical.cjs} (100%) diff --git a/package.json b/package.json index 65f6b82..93956f8 100644 --- a/package.json +++ b/package.json @@ -15,8 +15,8 @@ }, "description": "calmerger", "main": "server.js", - "type": "module", "author": "Ryan", + "type": "module", "license": "ISC", "devDependencies": { "@babel/preset-env": "^7.26.0", diff --git a/src/lib/ical.js b/src/lib/ical.cjs similarity index 100% rename from src/lib/ical.js rename to src/lib/ical.cjs diff --git a/src/lib/ical.timezones.js b/src/lib/ical.timezones.js index aebfa4a..3fcb1f7 100644 --- a/src/lib/ical.timezones.js +++ b/src/lib/ical.timezones.js @@ -1,4 +1,7 @@ -const ICAL = require('./ical.js'); +import { createRequire } from 'module'; +const require = createRequire(import.meta.url); + +const ICAL = require('./ical.cjs'); (function() { function register(tzdata) { ICAL.TimezoneService.register(ICAL.Component.fromString("BEGIN:VTIMEZONE\r\n" + tzdata + "\r\nEND:VTIMEZONE")) }; ICAL.TimezoneService.IANA_TZDB_VERSION = "2024b";