breejs / bree

Bree is a Node.js and JavaScript job task scheduler with worker threads, cron, Date, and human syntax. Built for @ladjs, @forwardemail, @spamscanner, @cabinjs.
https://jobscheduler.net
MIT License
2.96k stars 80 forks source link

jobs/index.js as an ESM module #180

Closed maxpain closed 2 years ago

maxpain commented 2 years ago

Hello. Bree should use import instead of require for jobs/index.js as an ESM module.

jobs/index.js:

const jobs = ['job'];
export default jobs;

Error:

Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/maxpain/dev/fastcup/backend/cron/.build/jobs/index.js from /Users/maxpain/dev/fastcup/backend/cron/node_modules/bree/src/index.js not supported.
Instead change the require of /Users/maxpain/dev/fastcup/backend/cron/.build/jobs/index.js in /Users/maxpain/dev/fastcup/backend/cron/node_modules/bree/src/index.js to a dynamic import() which is available in all CommonJS modules.
    at Bree.init (/Users/maxpain/dev/fastcup/backend/cron/node_modules/bree/src/index.js:207:28)
    at new Bree (/Users/maxpain/dev/fastcup/backend/cron/node_modules/bree/src/index.js:172:10)
    at file:///Users/maxpain/dev/fastcup/backend/cron/.build/index.js:17:14
    at async Promise.all (index 0) {
  code: 'ERR_REQUIRE_ESM'
}
titanism commented 2 years ago

v9.0.0 released to npm and GitHub

NOTE: There are breaking changes! Please read https://github.com/breejs/bree/blob/master/UPGRADING.md#upgrading-from-v8-to-v9 for more insight how to upgrade from v8 to v9.

titanism commented 2 years ago

https://github.com/breejs/bree/releases/tag/v9.0.0

maxpain commented 2 years ago

Thanks!