GithubHelp home page GithubHelp logo

Comments (5)

lukasoppermann avatar lukasoppermann commented on June 8, 2024 3

It seems to be working fine just by installing the babel module-resolver and adding the following to the .babelrc and leaving the tsconfig.json as is.

// babelrc
{
  "presets": ["next/babel"],
  "plugins": [
    "inline-react-svg",
    ["module-resolver", {
      "root": ["./"],
      "alias": {
        "@svgs": "./svgs"
      }
    }]
  ]
}
///

from babel-plugin-inline-react-svg.

ljharb avatar ljharb commented on June 8, 2024

The way is to get rid of all typescript (and webpack) aliases, and only do path aliasing with babel (and, to only do transpiling with babel). Unfortunately it’s likely not a small amount of effort.

from babel-plugin-inline-react-svg.

lukasoppermann avatar lukasoppermann commented on June 8, 2024

Hey @ljharb, thanks for the quick reply. I use nextjs (getting started) and have only 5 typescript aliases. Do you know if nextjs uses babel only?

I feel this should be easy to do for me, so I'll give it a spin, but does typescript recognize babel aliases in vs code?

from babel-plugin-inline-react-svg.

ljharb avatar ljharb commented on June 8, 2024

I’m not familiar with nextjs, you’d have to file an issue there.

That’s a good point; with this approach, even if you’re only using typescript for typechecking, it still needs a way to understand the specifiers to check types. I’m not sure the best solution here. Another option is to not use any aliases and use the actual filesystem/package paths for everything.

either way, this is far out of the scope of a babel plugin, so I’ll close this.

from babel-plugin-inline-react-svg.

ljharb avatar ljharb commented on June 8, 2024

Good call; as long as you're OK duplicating the config in both babel and TS configs, that should work fine.

from babel-plugin-inline-react-svg.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.