CabalDAOC
Convex Community15mo ago
22 replies
CabalDAO

Errors importing dayjs plugins

Hi, I have a file in convex/utils/dateToMs that I need to parse incoming dates in different formats. It requires the use of dayjs and some of it's plugins. The code seems to push successfully when just importing dayjs but the plugins are throwing an error:

import dayjs from "dayjs";
import customParseFormat from "dayjs/plugin/customParseFormat";
import utc from "dayjs/plugin/utc";
import timezone from "dayjs/plugin/timezone";

// Extend dayjs with needed plugins
dayjs.extend(customParseFormat);
dayjs.extend(utc);
dayjs.extend(timezone);

...


Error:
Loading the pushed modules encountered the following
    error:
Uncaught Failed to analyze actions/profility.js: Cannot find module '/tmp/source/943f1a24-5f23-4e42-bd13-bb41e56fdfe8/node_modules/dayjs/plugin/customParseFormat' imported from /tmp/source/943f1a24-5f23-4e42-bd13-bb41e56fdfe8/modules/actions/profility.js
Did you mean to import dayjs/plugin/customParseFormat.js?


I've also tried in convex.json to explicitly specify these packages instead of just externalPackages: [*] like so:

{
  "node": {
    "externalPackages": [
      "*",
      "dayjs",
      "dayjs/plugin/customParseFormat",
      "dayjs/plugin/utc",
      "dayjs/plugin/timezone"
    ]
  }
}


But to no avail.
Was this page helpful?