I'm using the ics-to-json package. This imports / works fine on dev, but fails on an npm run build:
---
import EventCard from "../components/EventCard/EventCard.astro";
import Layout from "../layouts/Layout.astro";
import icsToJson from "ics-to-json";
// Get ICS text however you like, example below
// Make sure you have the right CORS settings if needed
const convert = async (fileLocation: string): Promise<MusicEvent[]> => {
const icsRes = await fetch(fileLocation);
const icsData = await icsRes.text();
// Convert
const data = icsToJson(icsData);
return data;
};
const allEvents = await convert("public/calendar/music-calendar.ics");
const events = allEvents.filter((musicEvent) => musicEvent.summary);
interface MusicEvent {
summary: string;
description: string;
startDate: string;
endDate: string;
}
---
<Layout>
<div class="bg-gray-50">
<div
class="mx-auto max-w-7xl py-16 px-4 sm:py-24 sm:px-6 lg:flex lg:justify-between lg:px-8"
>
<div class="w-full space-y-16">
<div class="max-w-xl">
<h2
class="text-4xl font-bold tracking-tight text-black sm:text-5xl lg:text-6xl"
>
Event Schedule
</h2>
<p class="mt-5 text-xl text-black">
Join us for live music performances by local artists, featuring a
mix of traditional Hawaiian and contemporary tunes. Enjoy great
food, drinks, and entertainment. We can't wait to see you at our
next live music event! Aloha!
</p>
</div>
<div class="event-block space-y-8">
{
events.map((event) => (
<EventCard artist={event.summary} startDate={event.startDate} />
))
}
</div>
</div>
</div>
</div>
</Layout>
The package is correctly included in my package.json as a dependency. Here's the error I get:
error icsToJson is not a function
File:
/Users/personalmac/projects/beastside-kitchen/node_modules/astro/dist/runtime/server/render/page.js:66:30
Code:
65 | }
> 66 | const factoryReturnValue = await componentFactory(result, props, children);
| ^
67 | if (isAstroComponent(factoryReturnValue)) {
68 | let iterable = renderAstroComponent(factoryReturnValue);
69 | let init = result.response;