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
fix: support evaluating TypeScript files by default. fixes #27 #283
Conversation
db661f7
to
bf121b9
Compare
@@ -58,10 +59,35 @@ class Module { | |||
this.require.resolve = this.resolve.bind(this); | |||
this.require.ensure = NOOP; | |||
this.require.cache = cache; | |||
|
|||
// We support following extensions by default | |||
this.extensions = ['.json', '.js', '.ts', '.tsx']; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add .jsx
as well? I'm cool with not adding that and forcing others to just use .js
though :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
death to .jsx
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should kill .tsx
as well then XD
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@thymikee I would if I could. But due to syntax ambiguity with deprecated typecast syntax, TypeScript relies on the .tsx
extension to understand JSX!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What a shame. Flow doesn't have these issues :D Hopefully they can get rid of deprecations soon 🙂
src/babel/module.js
Outdated
@@ -86,15 +112,16 @@ class Module { | |||
// we would end up in infinite loop with cyclic dependencies | |||
cache[filename] = m; | |||
|
|||
if (/\.(js|json)$/.test(filename)) { | |||
// For JS/JSON files, we need to read the file first | |||
if (/\.(json|js|tsx?)$/.test(filename)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's safer to generate this regex based on this.extensions
, but that's not gonna change too often, so feel free to ignore this advice
bf121b9
to
449a816
Compare
No description provided.