i18next / i18next-parser

Parse your code to extract translation keys/values and manage your catalog files
MIT License
486 stars 198 forks source link

@babel/runtime needed to be added as a dependency #975

Closed skyuplam closed 9 months ago

skyuplam commented 9 months ago

🐛 Bug Report

Missing dependency @babel/runtime from the package.json file.

To Reproduce

  1. Create a new project and init with Yarn v4 as yarn init -2
  2. Install the i18next-parser package as yarn add -D i18next-parser
  3. Run i18next cli command as yarn i18next, and check the output.
~/dev/babelruntime
❯ yarn init -2
➤ YN0000: Retrieving https://repo.yarnpkg.com/4.1.0/packages/yarnpkg-cli/bin/yarn.js
➤ YN0000: Saving the new release in .yarn/releases/yarn-4.1.0.cjs
➤ YN0000: Done in 0s 228ms
➤ YN0000: · Yarn 4.1.0
➤ YN0000: ┌ Resolution step
➤ YN0000: └ Completed
➤ YN0000: ┌ Fetch step
➤ YN0000: └ Completed
➤ YN0000: ┌ Link step
➤ YN0000: └ Completed
➤ YN0000: · Done in 0s 38ms

~/d/babelruntime on  main [?] via  v18.19.1 took 12s
❯ ll
.rw-r--r-- terrencelam staff  63 B Mon Feb 26 09:10:20 2024  package.json
.rw-r--r-- terrencelam staff  15 B Mon Feb 26 09:10:20 2024  README.md
.rw-r--r-- terrencelam staff 308 B Mon Feb 26 09:10:21 2024  yarn.lock

~/d/babelruntime on  main [?] via  v18.19.1
❯ yarn add -D i18next-parser
➤ YN0000: · Yarn 4.1.0
➤ YN0000: ┌ Resolution step
➤ YN0085: │ + i18next-parser@npm:8.12.0, @babel/runtime@npm:7.23.9, @esbuild/aix-ppc64@npm:0.19.12, @esbuild/android-arm64@npm:0.19.12, @esbuild/android-arm@npm:0.19.12, @esbuild/android-x64@npm:0.19.12, @esbuild/darwin-arm64@npm:0.19.12, @esbuild/darwin-x64@npm:0.19.12, @esbuild/freebsd-arm64@npm:0.19.12, @esbuild/freebsd-x64@npm:0.19.12, and 142 more.
➤ YN0000: └ Completed in 3s 819ms
➤ YN0000: ┌ Fetch step
➤ YN0013: │ 130 packages were added to the project (+ 79.45 MiB).
➤ YN0000: └ Completed in 1s 5ms
➤ YN0000: ┌ Link step
➤ YN0000: │ ESM support for PnP uses the experimental loader API and is therefore experimental
➤ YN0007: │ esbuild@npm:0.19.12 must be built because it never has been before or the last one failed
➤ YN0000: └ Completed in 0s 283ms
➤ YN0000: · Done with warnings in 5s 132ms

~/d/babelruntime on  main [!?] via  v18.19.1 took 8s
❯ yarn i18next

node:internal/process/esm_loader:40
      internalBinding('errors').triggerUncaughtException(
                                ^
Error: i18next-parser tried to access @babel/runtime, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.

Required package: @babel/runtime (via "@babel/runtime/helpers/toConsumableArray")
Required by: i18next-parser@npm:8.12.0 (via /Users/terrencelam/.local/share/yarn/berry/cache/i18next-parser-npm-8.12.0-3de426d15c-10c0.zip/node_modules/i18next-parser/dist/helpers.js)

    at makeError (/Users/terrencelam/dev/babelruntime/.pnp.cjs:6898:34)
    at resolveToUnqualified (/Users/terrencelam/dev/babelruntime/.pnp.cjs:8546:21)
    at resolveRequest (/Users/terrencelam/dev/babelruntime/.pnp.cjs:8673:31)
    at Object.resolveRequest (/Users/terrencelam/dev/babelruntime/.pnp.cjs:8736:26)
    at resolve$1 (file:///Users/terrencelam/dev/babelruntime/.pnp.loader.mjs:2005:21)
    at nextResolve (node:internal/modules/esm/hooks:864:28)
    at Hooks.resolve (node:internal/modules/esm/hooks:302:30)
    at handleMessage (node:internal/modules/esm/worker:196:24)
    at Immediate.checkForMessages (node:internal/modules/esm/worker:138:28)
    at process.processImmediate (node:internal/timers:476:21)

Node.js v18.19.1

Expected behavior

According to the doc from Babel (https://babeljs.io/docs/babel-plugin-transform-runtime):

and @babel/runtime as a production dependency (since it's for the "runtime").

npm install --save @babel/runtime

Your Environment

karellm commented 9 months ago

Can you describe how you got that error and what you are trying to do? I don't see why we would need babel as a dependency, it is only used as a development tool afaik.

skyuplam commented 9 months ago

It is described from Babel’s doc. If have Yarn with PnP, it will error out as well.

On Sun, Feb 25, 2024 at 19:19 Karel Ledru @.***> wrote:

Can you describe how you got that error and what you are trying to do? I don't see why we would need babel as a dependency, it is only used as a development tool afaik.

— Reply to this email directly, view it on GitHub https://github.com/i18next/i18next-parser/issues/975#issuecomment-1963019832, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABYSBILSHFXM4CEIHVIZJTYVN6DZAVCNFSM6AAAAABDQYAYHKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNRTGAYTSOBTGI . You are receiving this because you authored the thread.Message ID: @.***>

skyuplam commented 9 months ago

So I have just added the step to reproduce the issue.

However, as I have already mentioned that the @babel/runtime dependency is required as stated from the Babel-plugin-transform-runtime Installation doc:

Install it as development dependency. yarn add --dev @babel/plugin-transform-runtime and @babel/runtime as a production dependency (since it's for the "runtime"). yarn add @babel/runtime 👈🏻 👀

You can read further to the Why section if you were wondering why it needs it.