Skip to content

[Bug] Update to v2.36, not recognizing function in config.js #4146

@dathbe

Description

@dathbe

Environment

MagicMirror² version: 2.36.0
Node version: 24.14.1
npm version: 11.11.0
Platform: Raspbian

I updated to v2.36.0 this morning, and it broke one of my modules. Specifically, I have an MMM-CalendarExt2 module specified in my config.js, which calls a custom function within the config.js file to programatically set special icons for calendar entries. The module was working fine before the upgrade, but now it is reporting [ERROR] [MMM-LogExt] [ERROR] [:4:26] Uncaught ReferenceError: checkForCustomIcon is not defined (the function name is checkForCustomIcon; I have confirmed that the function exists and is named correctly. There are many other modules I use that also rely on functions inside the config.js file, and none of those seem to be affected. I don't know what's different about this.

Which start option are you using?

node --run start:wayland

Are you using PM2?

Yes

Module

None

Have you tried disabling other modules?

  • Yes
  • No

Have you searched if someone else has already reported the issue on the forum or in the issues?

  • Yes

What did you do?

Configuration

Here is the relevant part of my module definition:

{
  module: 'MMM-CalendarExt2',
  config: {
  calendars : [
    {
    name: "Family Calendar",
    url: "https://calendar.google.com/calendar/ical/<redacted>",
    icon: "ion:calendar-outline",
    className: "calmain",
    },
    {
    name: "US Holidays",
    url: "https://calendar.google.com/calendar/ical/<redacted>",
    icon: "mingcute:firework-line",
    className: "calholiday",
    },
    
    {
    name: "Birthdays",
    url: "https://calendar.google.com/calendar/ical/<redacted>",
    icon: "wpf:birthday",  
    className: "calbirthdays",
    },
    {
    name: "Anniversaries",
    url: "https://calendar.google.com/calendar/ical/<redacted>",
    icon: "game-icons:diamond-ring",
    className: "calanniversaries",
    },
  ],
  views: [
  {
    name: "week",
    mode: "daily",
    position: "lower_third",
    slotCount: 7,
    filterPassedEvent: true,
    timeFormat:"h:mm A",
    hideOverflow: false,
    slotMaxHeight: "auto",
    transform: (event) => {
      const iconChoice = checkForCustomIcon (event)
      if (iconChoice !== '') {
        event.icon = iconChoice
      }
      if (event.title === "a") {
        event.className = "calholiday"
        event.icon = "mingcute:a"
      }
      return event;
    },
  },
  ],
  scenes: [
    {
    name: "DEFAULT",
    views: [],
    },
	],
  },
},

And at the bottom of the config.js file, I have this function defined:

function checkForCustomIcon (event) {
  if (event.title.search("a") > -1 || event.title.search("b") > -1 || event.title.search("c") > -1 || event.title.search("d") > -1 || event.title.search("e") > -1 || event.title.search("e") > -1) {
    return "icon-park-outline:a"
  }
  else if (event.title.search("f") > -1 || event.title.search("g") > -1) {
    return "game-icons:b"
  }
  else if (event.title.search("h") > -1 || event.title.search("i") > -1 || event.title.search("j") > -1) {
    return "hugeicons:c"
  }
  else if (event.title.search("k") > -1) {
    return "iconoir:d"
  }
  else if (event.title.search("l") > -1) {
    return "ri:e"
  }
  else if (event.title.search("m") > -1) {
    return "ph:f"
  }
  return ''
}

Did something change with how functions need to be formatted with the latest release?

Steps to reproduce the issue:
Include specific functions (no idea what the specific issue is) in your config.js
Upgrade to 2.36

What did you expect to happen?

MM picks up the function and properly parses the module definition.

What actually happened?

MM complains that the function is missing.

Additional comments

No response

Participation

  • I am willing to submit a pull request for this change.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions