-
Notifications
You must be signed in to change notification settings - Fork 625
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: support browser environment #629
base: main
Are you sure you want to change the base?
Conversation
lib/cron.js
Outdated
@@ -2,7 +2,7 @@ | |||
if (typeof define === 'function' && define.amd) { | |||
define(['luxon'], factory); | |||
} else if (typeof exports === 'object') { | |||
module.exports = factory(require('luxon'), require('child_process')); | |||
module.exports = factory(require('luxon'), (typeof window === 'undefined' ? require('child_process') : {})); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in browsers, typeof exports
is undefined
not object
, so would the execution even get as far as your logic?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure but this was required for me. My guess it's because im running vue with vite.
Support cron format testing, next execution calculation, etc. usage in browsers by not requiring child_process.
TODO
shared-node-browser
(see refactor!: migrate to TypeScript #694 (review))