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.

This commit is contained in:
Ryan Mwangi 2024-11-20 13:58:35 +03:00
parent ad3ec6f7a6
commit 174a845c78
3 changed files with 5 additions and 2 deletions

View File

@ -15,8 +15,8 @@
},
"description": "calmerger",
"main": "server.js",
"type": "module",
"author": "Ryan",
"type": "module",
"license": "ISC",
"devDependencies": {
"@babel/preset-env": "^7.26.0",

View File

@ -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";