gilbarbara/react-inlinesvg

Using react-inlinesvg in an npm package

julianguyen opened this issue · 8 comments

When I use react-inlinesvg in an npm package and add it to another project, I get this error. Any ideas how to resolve?

🚨  ../node_modules/react-inlinesvg/es/index.js: [BABEL] .../node_modules/react-inlinesvg/es/index.js: Unknown option: base.sourceMapRelative. Check out http://babeljs.io/docs/usage/options/ for more information about options.

A common cause of this error is the presence of a configuration options object without the corresponding preset name. Example:

Invalid:
  `{ presets: [{option: value}] }`
Valid:
  `{ presets: [['presetName', {option: value}]] }`

I tried setting .babelrc to

{ "presets": ["react", "es2015"] }

Not really.
Are you using it as a dependency in the other module? Or peerDependency? Which version?

It might be something about babel usually not been used to transpile node_modules but the es version is pretty much compatible with node 6+. And there's no sourcemap.

Try to load the react-inlinesvg/lib instead.
Switch the preset to babel-preset-env

Let me know if found out why this is happening.

@gilbarbara It's a dependency (the most recent version) in another module. Where would you load react-inlinesvg/lib?

Thanks for your help!

I don't how you are using it, so I can't say where...

@gilbarbara I'm doing import SVG from 'react-inlinesvg/lib'; in my module. In my project where I'm using my module, my .babelrc looks like

{
  "presets": ["env"]
}

Where env refers to babel-preset-env

Still encountering that error. Any ideas?

Nope
I think you are missing some babel transforms. Try to load the react preset.
Since this is an implementation problem, not related to this module, I'm closing this issue.

@gilbarbara I put

{
  "presets": ["env", "react", "es2015"]
}

But it doesn't work :/

I can't know what's happening without seeing the whole thing.

Totally understand. Can't show it since it's private repo. Thanks for answering my questions!