P4sca1 / cron-schedule

A zero-dependency cron parser and scheduler for Node.js, Deno and the browser.
MIT License
172 stars 14 forks source link

Type definitions can fail to load when loading in a 'esmodule-mode' project #284

Closed drfuzzyness closed 1 year ago

drfuzzyness commented 1 year ago

Using this library when Typescript is configured with moduleResolution: "NodeNext", type definitions can fail to load. This is resolved by including the type definitions in the exports map of package.json.

https://github.com/P4sca1/cron-schedule/blob/0bff6865580b452e4fa8ea508d1e8111e7c528d7/package.json#L32-L35

The following patch fixes it:


{
...
  "exports": {
    "require": "./dist/cron-schedule.cjs.min.js",
-   "import": "./dist/cron-schedule.min.mjs"
+   "import": "./dist/cron-schedule.min.mjs",
+   "types": "./dist/index.d.ts"
  },
...
}

Love your library!
P4sca1 commented 1 year ago

Hey @drfuzzyness. Could you try cron-schedule@4.0.0-next.2? The library is now ESM only and should support conditional exports with moduleResolution: "NodeNext". The only relevant breaking change for you should be that the schedulers are no longer exposed in the default export, but need to be manually imported from cron-schedule/schedulers/interval-based.js or cron-schedule/schedulers/timer-based.js.

drfuzzyness commented 1 year ago

Can confirm this is resolved in "cron-schedule": "^4.0.0", thank you!