Can Pipedream Use Library Plugins?

This topic was automatically generated from Slack. You can find the original thread here.

Good morning, is Pipedream capable of library plugins? I’m trying to use dayjs.extend(isBetween) but I keep getting ‘isBetween is not defined’. I’ve tried adding the extend snippet just below the import statement and inside the defineComponent step, not having much luck. (nodeJS workflow step) cheers

Could you share you entire code snippet so maybe we can help spot the issue?

Hi Pierce, thanks for looking at this. This is how I’d expect the function to work:

The library documentation uses the ‘require’ library function and then uses an ‘extend’ to reference the plugin:

I’ve tried their example within the defineComponent:

I tried ES6 import format:

require is not available in ESM which is what Node.js components use.

I think you’ll need to import both at the top of the file so that way you can import both the main library and the plugin:

import dayjs from 'dayjs'
import isBetween from 'dayjs/plugin/isBetween'
dayjs.extend(isBetween)

I wonder if something is missing from the library, Putting the extend just below the import throws an error:

They may have not published an ESM version, or it’s under a different path than the CommonJS version.

I would check their Github Issues to see if there’s an open issue about that.

But never had any issues with date-fns in Pipedream if that helps.

hey got it! added .js to the end

There you go :slightly_smiling_face: nice

Thanks for your help

Of course, have a good one