-
Notifications
You must be signed in to change notification settings - Fork 93
Plugin likely needs filename
when used with babel's transform
#52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I think both changes would be reasonable. A PR is most welcome. |
Do you know happen to know what the recommended |
It seems like, altho you can use the API programmatically, the I think the test case is great, but i think handling this properly might need a bit of refactoring. I'll open a PR with your test case once I've got a solution. |
ahhh - ok so, the filename is whatever the relative SVG file import should be computed against - so "unknown" won't really work either. |
Yeah, it happens to work in my case but I think that's more of an accident. |
Fixed in #53. |
Hi, I've been working to upgrade Thumbtack's design system to Babel 7. Got stuck at
babel-plugin-inline-react-svg
with the error "Path must be a string. Received undefined." It failed becauseiconPath
was undefined:babel-plugin-inline-react-svg/src/index.js
Lines 47 to 48 in 7ba334c
This happened because I use
babel.transform(code, opts)
. Previously, Babel would setfilename: "unknown"
in opts. This seems to have changed in Babel 7.Here's a commit with a failing test case: https://github.com/danoc/babel-plugin-inline-react-svg/commit/82d475926fc6d5866f255e0b306295a84ab5c2e9. Adding
filename: test/fixtures/test-import-read-file.jsx
toopts
(the second argument) fixes the test case.I don't think this is a bug in
babel-plugin-inline-react-svg
, but these changes may be helpful:iconPath
isundefined
(beforedirname(iconPath)
).filename
.The text was updated successfully, but these errors were encountered: