Can't import SVG components from external packages
Created by: stepankuzmin
Can you reproduce the problem with latest npm?
Yes, I can.
Description
Can't import react components that contain SVG elements like <svg>
, <g>
, etc from external packages.
Expected behavior
Files should be imported correctly.
Actual behavior
I'm getting
Module parse failed: /Users/stepan/projects/velobike/node_modules/@urbica/components/src/Chart/index.jsx Unexpected token (43:6)
You may need an appropriate loader to handle this file type.
|
| return (
| <svg height={this.props.height} width={this.props.width}>
| <g transform={transform}>
| {children}
Environment
-
npm ls react-scripts
(if you haven’t ejected):
velobike@0.3.0 /Users/stepan/projects/velobike
└── react-scripts@1.0.0
-
node -v
:7.10.0
-
npm -v
:4.6.1
-
Operating system: macOS 10.12.5
Reproducible Demo
To reproduce this issue you can try to import any component from @urbica/components.
Eg.
import { Axis, Area, Chart } from '@urbica/components';
FYI this library uses jsnext:main
param in package.json