svobik7 / next-roots

Next.js utility to generate i18n routes in the new APP directory.
https://next-roots-svobik7.vercel.app/
MIT License
172 stars 11 forks source link

Support for Es module? #238

Closed BorghildSelle closed 1 week ago

BorghildSelle commented 1 month ago

We have a project where package json is set up with type module, and running next-roots then requires it to be .cjs, but then it throws this error:

node:internal/modules/cjs/loader:1080
  throw err;
  ^

Error: Cannot find module '.../roots.config.js'
Require stack:
- .../node_modules/.pnpm/next-roots@3.7.0/node_modules/next-roots/dist/cli.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1077:15)
    at Module._load (node:internal/modules/cjs/loader:922:27)
    at Module.require (node:internal/modules/cjs/loader:1143:19)
    at require (node:internal/modules/cjs/helpers:119:18)
    at Object.<anonymous> (.../node_modules/.pnpm/next-roots@3.7.0/node_modules/next-roots/dist/cli.js:144:4087)
    at Module._compile (node:internal/modules/cjs/loader:1256:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
    at Module.load (node:internal/modules/cjs/loader:1119:32)
    at Module._load (node:internal/modules/cjs/loader:960:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:86:12) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '.../node_modules/.pnpm/next-roots@3.7.0/node_modules/next-roots/dist/cli.js'
  ]
}

Can you support roots.config to have file extension .cjs?

svobik7 commented 4 weeks ago

Hi, that makes sense, will look into that 🙂

github-actions[bot] commented 1 week ago

:tada: This issue has been resolved in version 3.8.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

svobik7 commented 1 week ago

Hi @BorghildSelle,

the new version 3.8.0 was just published. Should support your requirement. Could you please check? You can find an example here https://github.com/svobik7/next-roots/tree/master/examples/basic-esm