Skip to content

Can't import SVG components from external packages #2236

Closed
@stepankuzmin

Description

@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

  1. npm ls react-scripts (if you haven’t ejected):
velobike@0.3.0 /Users/stepan/projects/velobike
└── react-scripts@1.0.0 
  1. node -v: 7.10.0

  2. npm -v: 4.6.1

  3. 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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions