Improving Browser Compatibility #960
Replies: 2 comments 3 replies
-
thanks for bringing this to our attention! browser support is a great goal and I'd be interested to see a PR about this. we already use Jest so extending Jest for testing browser environments would be best |
Beta Was this translation helpful? Give feedback.
-
I was sure I answered this but looks like my comment got lost ... so here it is again: I think we should think about removing Using it manually from the tick function is simple enough and gives users more control over it anyway, so I don't even think it is being widely used. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Originally posted by @sheerlox in #538
Currently, node-cron call child_process for executing system commands when a string or object is provided instead of a function.
https://github.com/kelektiv/node-cron/blob/main/src/job.ts#L175-L196
To improve browser compatibility, we could refactor the import of child_process so that it is only required when actually needed. Specifically, we can introduce a validation mechanism to ensure that system commands (string or object formats) are executed only in non-browser environments.
Proposed Solution
Modify the _fnWrap function to include a browser check before requiring child_process:
I’d like to submit a PR implementing this.
Additionally, we should decide on a suitable testing library for browser environments to ensure compatibility—perhaps using Jest with jsdom or a browser-focused framework like karma.
Beta Was this translation helpful? Give feedback.
All reactions