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-typescriptpreset 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.svgextension as typescript.A bug I've noticed that I haven't fixed is if you have a separate config file
.svgrrc.jstheoptionsobject 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 formaton the repo.Test plan
Added an additional test case to the webpack package's
index.test.jsto include{typescript: true}.I also tested that it fixes the SyntaxError in my NextJS project by doing an
npm packand installing the local tar package.