airbnb / airbnb/babel-plugin-inline-react-svg

Module build failed: SyntaxError: Unexpected token (1:1)

Open
#38 17 comments 2 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
474
Forks
90
PR merge metrics
No merged PRs in 30d

Description

If I specify plugin config in `.babelrc` it throws the error.

```js
ERROR in ./src/pages/Application.js
Module build failed: SyntaxError: c:/dev/.../Application.js: Unexpected token (1:1)

> 1 | import React, { Component } from 'react'
| ^
```

```
{
"presets": ...,
"plugins": [
...,
["inline-react-svg", {
"svgo": false
}]
]
}
```

If I then use just `"inline-react-svg"` in `.babelrc` then it doesn't throw the error.
But in the default mode it discards half of attributes like `stroke-width="2.5"`.

Contributor guide

No contributing guide indexed for this repository

Research direction

The report names .babelrc and src/pages/Application.js; first reproduce the build with the plugin options object, then with the bare "inline-react-svg" setting. Compare both configurations and verify that the build no longer reports the import syntax error and that SVG attributes such as stroke-width="2.5" are preserved.

Written by the indexing model from the issue text.

Assessment

Tech stack
babel, javascript, react
Domain
frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.