-
-
Notifications
You must be signed in to change notification settings - Fork 425
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
Added webpack typescript preset configuration #573
Added webpack typescript preset configuration #573
Conversation
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/gregberge/svgr/D1tGEaXVuEttFu4vVG73u9ghFtvJ |
Codecov Report
@@ Coverage Diff @@
## main #573 +/- ##
==========================================
- Coverage 90.89% 87.23% -3.66%
==========================================
Files 31 31
Lines 1076 572 -504
Branches 325 161 -164
==========================================
- Hits 978 499 -479
+ Misses 92 58 -34
- Partials 6 15 +9
Continue to review full report at Codecov.
|
77045d5
to
e76205c
Compare
e76205c
to
87ca373
Compare
any example or doc of this ? i use this in my nextjs config and don't get eny type help
|
Summary
Should offer support for #354 and #473. I originally tried to use the webpack loader with NextJS and TypeScript. I consistently got a SyntaxError when I had
{typescript: true}
in the options. This PR adds the@babel/preset-typescript
preset if the typescript option is enabled. It also automatically sets the preset-typescript options to{ allowNamespaces: true, allExtensions: true, isTSX: true }
which enables processing the.svg
extension as typescript.A bug I've noticed that I haven't fixed is if you have a separate config file
.svgrrc.js
theoptions
object in the webpack loader will be empty. I'll take a look into that if I have enough time!The additional changes in other files are due to me running
yarn format
on the repo.Test plan
Added an additional test case to the webpack package's
index.test.js
to include{typescript: true}
.I also tested that it fixes the SyntaxError in my NextJS project by doing an
npm pack
and installing the local tar package.