zely-js / zely

Build Productive, Convenient, Fast Backend
https://zely.vercel.app
MIT License
9 stars 1 forks source link

support`type: "module"` #327

Closed werewrwere closed 2 months ago

werewrwere commented 2 months ago
{
  "private": true,
  "type": "module",
  "scripts": {
    "dev": "zely dev"
  },
  "dependencies": {
    "zely": "^3.0.2"
  },
}
> yarn dev
Error [ERR_REQUIRE_ESM]: require() of ES Module \zely-esm\.zely\cache\zely.config.js from \zely-esm\node_modules\@zely-js\loader\dist\index.js not supported.
zely.config.js is treated as an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which declares all .js files in that package scope as ES modules.      
Instead either rename zely.config.js to end in .cjs, change the requiring code to use dynamic import() which is available in all CommonJS modules, or change "type": "module" to "type": "commonjs" in \zely-esm\package.json to treat all .js files as CommonJS (using .mjs for all ES modules instead).