lingui / js-lingui

🌍 📖 A readable, automated, and optimized (3 kb) internationalization for JavaScript
https://lingui.dev
MIT License
4.64k stars 383 forks source link

Update @lingui/cli to use ora > 6 #2076

Closed elonzh closed 3 weeks ago

elonzh commented 3 weeks ago

Describe the bug

@lingui/cli requires "ora": "^5.1.0" as dependency, which is too old and is a commonjs moudule. That may conflict with other dependency like eslint-config-next.

To Reproduce Install eslint-config-next and @lingui/cli, run lingui extract command.

$ lingui extract
/home/elonzh/workspace/xxx/node_modules/ora/index.js:7
const stripAnsi = require('strip-ansi');
                  ^

Error [ERR_REQUIRE_ESM]: require() of ES Module /home/elonzh/workspace/xxx/node_modules/strip-ansi/index.js from /home/elonzh/workspace/xxx/node_modules/ora/index.js not supported.
Instead change the require of /home/elonzh/workspace/xxx/node_modules/strip-ansi/index.js in /home/elonzh/workspace/xxx/node_modules/ora/index.js to a dynamic import() which is available in all CommonJS modules.
    at Object.<anonymous> (/home/elonzh/workspace/xxx/node_modules/ora/index.js:7:19) {
  code: 'ERR_REQUIRE_ESM'
}

Node.js v20.16.0
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Additional context Add any other context about the problem here.


> yarn why strip-ansi       
yarn why v1.22.21
[1/4] Why do we have the module "strip-ansi"...?
[2/4] Initialising dependency graph...
[3/4] Finding dependency...
[4/4] Calculating file sizes...
=> Found "strip-ansi@7.1.0"
info Reasons this module exists
   - "eslint-config-next#@next#eslint-plugin-next#glob#jackspeak#@isaacs#cliui" depends on it
   - Hoisted from "eslint-config-next#@next#eslint-plugin-next#glob#jackspeak#@isaacs#cliui#strip-ansi"
   - Hoisted from "eslint-config-next#@next#eslint-plugin-next#glob#jackspeak#@isaacs#cliui#string-width#strip-ansi"
   - Hoisted from "eslint-config-next#@next#eslint-plugin-next#glob#jackspeak#@isaacs#cliui#wrap-ansi#strip-ansi"
info Disk size without dependencies: "48KB"
info Disk size with unique dependencies: "68KB"
info Disk size with transitive dependencies: "68KB"
info Number of shared dependencies: 1
Done in 0.28s.
timofei-iatsenko commented 3 weeks ago

lingui is also commonjs and could not use pure ESM modules.

Your issues are not related to the lingui itself, but to how package manager resolved the packages. It should not use newer version of ora for the lingui because it is explicitly stated in the dependencies to use "ora": "^5.1.0"

I use Yarn for my day 2 day work, and this never happened to me. Most likely, you have something wrong with your node_modules folder, lock file, or explicit resolutions overrides in package.json

timofei-iatsenko commented 3 weeks ago

I'm closing this, because there is nothing to do from lingui side