tleunen / babel-plugin-module-resolver

Custom module resolver plugin for Babel
MIT License
3.46k stars 205 forks source link

why no typescript support? #357

Closed stavalfi closed 5 years ago

stavalfi commented 5 years ago

not working example:

index.js: require('file1')

file1.ts: export default {x:1}

when parsing index.js with this plugin : require("file1")


working example

index.js: require('file1')

file1.js: export default {x:1}

when parsing index.js with this plugin : require("./file1")


{
  "plugins": [
    [
      "module-resolver",
      {
        "root": ["./src"]
      }
    ]
  ]
}

what is the problem with typescript files?

stavalfi commented 5 years ago

ok, I found the problem:

https://github.com/tleunen/babel-plugin-module-resolver/blob/c73bd9d823d2a5c9a0bd0273c56364cf68bdb17e/src/normalizeOptions.js#L13

Why not adding ts,tsx,d.ts files also?

tleunen commented 5 years ago

The initial idea was that typescript is not javascript. So you would have to set your own extensions in the plugin options.

stavalfi commented 5 years ago

https://github.com/tleunen/babel-plugin-module-resolver/blob/master/DOCS.md#extensions

Thanks!!!!!!!