user-1
(User 1)
March 21, 2023, 6:18pm
1
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
user-1
(User 1)
March 21, 2023, 6:18pm
2
Could you share you entire code snippet so maybe we can help spot the issue?
user-1
(User 1)
March 21, 2023, 6:18pm
3
Hi Pierce, thanks for looking at this. This is how I’d expect the function to work:
user-1
(User 1)
March 21, 2023, 6:18pm
4
The library documentation uses the ‘require’ library function and then uses an ‘extend’ to reference the plugin:
user-1
(User 1)
March 21, 2023, 6:18pm
5
I’ve tried their example within the defineComponent:
user-1
(User 1)
March 21, 2023, 6:18pm
6
I tried ES6 import format:
user-1
(User 1)
March 21, 2023, 6:18pm
7
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)
user-1
(User 1)
March 21, 2023, 6:18pm
8
I wonder if something is missing from the library, Putting the extend just below the import throws an error:
user-1
(User 1)
March 21, 2023, 6:18pm
9
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.
user-1
(User 1)
March 21, 2023, 6:18pm
10
But never had any issues with date-fns in Pipedream if that helps.
user-1
(User 1)
March 21, 2023, 6:18pm
11
hey got it! added .js to the end
user-1
(User 1)
March 21, 2023, 6:18pm
14
Of course, have a good one