Skip to content

React.Fragment Short Syntax fails to extract, SyntaxError unexpected token #59

@18steps

Description

@18steps
  • version: react-intl-cra@0.3.3
  • node version: v8.11.4
  • npm (or yarn) version: yarn 1.6.0

Do you want to request a feature or report a bug?:
Bug

What is the current behavior?:

Fragment short syntax breaks the parser.

yarn run v1.6.0
$ yarn run extract:messages && yarn run extract:pot-c
$ react-intl-cra ./src/**/*.js -o translations/generated-translations.json
C:\src\legacy-invoice-view-app\node_modules\babel-core\lib\transformation\file\index.js:558
      throw err;
      ^

SyntaxError: unknown: Unexpected token (19:5)
  17 | function App({ username, userToken, customerNumber }) {
  18 |   return (
> 19 |     <>
     |      ^
  20 |       <DoWhenAppMounts />
  21 |       <global-header
  22 |         consumer={'legacy-invoice-view'}
    at Parser.pp$5.raise (C:\src\legacy-invoice-view-app\node_modules\babylon\lib\index.js:4454:13)
    at Parser.pp.unexpected (C:\src\legacy-invoice-view-app\node_modules\babylon\lib\index.js:1761:8)
    at Parser.pp$9.jsxParseIdentifier (C:\src\legacy-invoice-view-app\node_modules\babylon\lib\index.js:7029:10)
    at Parser.pp$9.jsxParseNamespacedName (C:\src\legacy-invoice-view-app\node_modules\babylon\lib\index.js:7040:19)
    at Parser.pp$9.jsxParseElementName (C:\src\legacy-invoice-view-app\node_modules\babylon\lib\index.js:7055:19)
    at Parser.pp$9.jsxParseOpeningElementAt (C:\src\legacy-invoice-view-app\node_modules\babylon\lib\index.js:7145:20)
    at Parser.pp$9.jsxParseElementAt (C:\src\legacy-invoice-view-app\node_modules\babylon\lib\index.js:7169:29)
    at Parser.pp$9.jsxParseElement (C:\src\legacy-invoice-view-app\node_modules\babylon\lib\index.js:7224:15)
    at Parser.parseExprAtom (C:\src\legacy-invoice-view-app\node_modules\babylon\lib\index.js:7236:21)
    at Parser.pp$3.parseExprSubscripts (C:\src\legacy-invoice-view-app\node_modules\babylon\lib\index.js:3494:19)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

What is the expected behavior?:
Extract messages works even if the solution uses the shorthand syntax for React Fragments.

Suggested solution:
Update dependencies? No idea. Babylon package says it's now at "babel/babel as @babel/parser" -- don't know if that one works with the shorter syntax though.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions