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

providing filename when running babel.parse in icu.macro #1133

Merged
merged 1 commit into from
Jun 12, 2020

Conversation

joeycozza
Copy link
Contributor

We've been using icu.macro just fine at our organization for a while now.
Very recently, we started implementing typescript support for our org, and this brought to light a little issue with the macro.

  ● Test suite failed to run
    /Users/joeycozza/fs/zion/packages/locale/src/PluralsAndGenders.stories.js: react-i18next/icu.macro: [BABEL] unknown: Preset /* your preset */ requires a filename to be set when babel is called directly,
    ```
    babel.transform(code, { filename: 'file.ts', presets: [/* your preset */] });
    ```
    See https://babeljs.io/docs/en/options#filename for more information. Learn more: https://www.npmjs.com/package/react-i18next
      at validateIfOptionNeedsFilename (node_modules/@babel/core/lib/config/full.js:274:11)
      at node_modules/@babel/core/lib/config/full.js:286:52
          at Array.forEach (<anonymous>)
      at validatePreset (node_modules/@babel/core/lib/config/full.js:286:25)
      at loadPresetDescriptor (node_modules/@babel/core/lib/config/full.js:293:3)
          at loadPresetDescriptor.next (<anonymous>)
      at recurseDescriptors (node_modules/@babel/core/lib/config/full.js:107:30)
          at recurseDescriptors.next (<anonymous>)
      at loadFullConfig (node_modules/@babel/core/lib/config/full.js:142:6)
          at loadFullConfig.next (<anonymous>)

It is a fairly simple fix, we just need to provide the filename to babel.parse when it is called explicitly.

Checklist

  • only relevant code is changed (make a diff before you submit the PR)
  • run tests npm run test
  • tests are included
  • documentation is changed or added

@coveralls
Copy link

Coverage Status

Coverage remained the same at 95.775% when pulling 75aa722 on joeycozza:master into 825ff82 on i18next:master.

@jamuhl jamuhl merged commit dae4eba into i18next:master Jun 12, 2020
@jamuhl
Copy link
Member

jamuhl commented Jun 12, 2020

published in react-i18next@11.5.1

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

Successfully merging this pull request may close these issues.

3 participants