Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI Exceeding call stack #991

Open
justinhippo opened this issue Mar 28, 2024 · 4 comments
Open

CLI Exceeding call stack #991

justinhippo opened this issue Mar 28, 2024 · 4 comments

Comments

@justinhippo
Copy link

justinhippo commented Mar 28, 2024

🐛 Bug Report

After freshly installing i18next-parser with npm i -g i18next-parser and setting up a configuration file, running the CLI gives

i18next "src/**/*.{js, jsx, ts, tsx}"

  i18next Parser
  --------------
  Input:  src/**/*.{js, jsx, ts, tsx}
  Output: public/locales/$LOCALE/$NAMESPACE.json

/home/justin/.nvm/versions/node/v20.12.0/lib/node_modules/i18next-parser/node_modules/anymatch/index.js:94
    return (testString, ri = false) => {
           ^

RangeError: Maximum call stack size exceeded
    at /home/justin/.nvm/versions/node/v20.12.0/lib/node_modules/i18next-parser/node_modules/anymatch/index.js:94:12
    at EventEmitter.onPath (/home/justin/.nvm/versions/node/v20.12.0/lib/node_modules/i18next-parser/node_modules/glob-stream/index.js:270:20)
    at EventEmitter.emit (node:events:518:28)
    at processDirents (/home/justin/.nvm/versions/node/v20.12.0/lib/node_modules/i18next-parser/node_modules/glob-stream/index.js:88:10)
    at next (/home/justin/.nvm/versions/node/v20.12.0/lib/node_modules/i18next-parser/node_modules/now-and-later/lib/mapSeries.js:43:5)
    at handler (/home/justin/.nvm/versions/node/v20.12.0/lib/node_modules/i18next-parser/node_modules/now-and-later/lib/mapSeries.js:57:9)
    at f (/home/justin/.nvm/versions/node/v20.12.0/lib/node_modules/i18next-parser/node_modules/once/once.js:25:25)
    at processDirents (/home/justin/.nvm/versions/node/v20.12.0/lib/node_modules/i18next-parser/node_modules/glob-stream/index.js:113:7)
    at next (/home/justin/.nvm/versions/node/v20.12.0/lib/node_modules/i18next-parser/node_modules/now-and-later/lib/mapSeries.js:43:5)
    at handler (/home/justin/.nvm/versions/node/v20.12.0/lib/node_modules/i18next-parser/node_modules/now-and-later/lib/mapSeries.js:57:9)

Node.js v20.12.0

To Reproduce

A minimal reproducible example.
A codesandbox example or similar
or at least steps to reproduce the behavior:
i18next-parser.config.js

module.exports = {
  contextSeparator: '_',
  // Key separator used in your translation keys

  createOldCatalogs: true,
  // Save the \_old files

  defaultNamespace: 'translation',
  // Default namespace used in your i18next config

  defaultValue: (loc, ns, key) => (loc === 'en' ? key : '__NOT_TRANSLATED__'),
  // Default value to give to keys with no value
  // You may also specify a function accepting the locale, namespace, key, and value as arguments

  indentation: 2,
  // Indentation of the catalog files

  keepRemoved: true,
  // Keep keys from the catalog that are no longer in code
  // You may either specify a boolean to keep or discard all removed keys.
  // You may also specify an array of patterns: the keys from the catalog that are no long in the code but match one of the patterns will be kept.
  // The patterns are applied to the full key including the namespace, the parent keys and the separators.

  keySeparator: false,
  // Key separator used in your translation keys
  // If you want to use plain english keys, separators such as `.` and `:` will conflict. You might want to set `keySeparator: false` and `namespaceSeparator: false`. That way, `t('Status: Loading...')` will not think that there are a namespace and three separator dots for instance.

  // see below for more details
  lexers: {
    js: ['JavascriptLexer'], // if you're writing jsx inside .js files, change this to JsxLexer
    ts: ['JavascriptLexer'],
    jsx: ['JsxLexer'],
    tsx: ['JsxLexer'],

    default: ['JavascriptLexer'],
  },

  lineEnding: 'auto',
  // Control the line ending. See options at https://github.com/ryanve/eol

  locales: ['en'],
  // An array of the locales in your applications

  namespaceSeparator: false,
  // Namespace separator used in your translation keys
  // If you want to use plain english keys, separators such as `.` and `:` will conflict. You might want to set `keySeparator: false` and `namespaceSeparator: false`. That way, `t('Status: Loading...')` will not think that there are a namespace and three separator dots for instance.

  output: 'public/locales/$LOCALE/$NAMESPACE.json',
  // Supports $LOCALE and $NAMESPACE injection
  // Supports JSON (.json) and YAML (.yml) file formats
  // Where to write the locale files relative to process.cwd()

  pluralSeparator: '_',
  // Plural separator used in your translation keys
  // If you want to use plain english keys, separators such as `_` might conflict. You might want to set `pluralSeparator` to a different string that does not occur in your keys.
  // If you don't want to generate keys for plurals (for example, in case you are using ICU format), set `pluralSeparator: false`.

  input: ['src/**/*.{js, jsx, ts, tsx}'],
  // An array of globs that describe where to look for source files
  // relative to the location of the configuration file

  sort: false,
  // Whether or not to sort the catalog. Can also be a [compareFunction](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#parameters)

  verbose: true,
  // Display info about the parsing including some stats

  failOnWarnings: false,
  // Exit with an exit code of 1 on warnings

  failOnUpdate: false,
  // Exit with an exit code of 1 when translations are updated (for CI purpose)

  i18nextOptions: { compatibilityJSON: 'v3' },
  // If you wish to customize options in internally used i18next instance, you can define an object with any
  // configuration property supported by i18next (https://www.i18next.com/overview/configuration-options).
  // { compatibilityJSON: 'v3' } can be used to generate v3 compatible plurals.
};
npm i -g i18next-parser
i18next "src/**/*.{js, jsx, ts, tsx}" 

Expected behavior

i18next-parser runs

Your Environment

  • runtime version: node v20, v18, v16
  • i18next version: ^23.5.1
  • os: Linux
  • Folders go no further than 4 levels deep, so not sure what would be causing
@sun-rhythms
Copy link

Have same issue :(

@abutkeev
Copy link

npm i -D 'glob-stream@<8.0.1’ fix this problem for me

@megastep
Copy link

megastep commented Apr 1, 2024

Having the same issue, but yeah it appears a security fix update to the glob-stream package broke this.

@Porok12
Copy link

Porok12 commented Apr 7, 2024

I spend over hour debugging, and ended up installing i18next-parser in version 7.9.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants