Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,8 @@ class ResolutionRequest {
file = potentialModulePath + '.native.js';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately this pull request doesn't implement with .ios.jsx. But, when/if it does, it raises more questions like what happens if you have both ios.js and ios.jsx?

Sorry to chime in super late but I actually think that this is harmful to support .jsx extension. We now live in a world where we have many transforms for es6, flow, jsx... Why would we add .jsx but not .flow or .es6. Supporting more extensions is only going to fragment tools even more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. Let's revert unless there's a stronger reason to keep this diff.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert here: #5296

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As much as I'd love to see .jsx files here you have a good point on supporting other extensions and the fragmentation it could lead too, I didn't see it that way. Thanks @vjeux

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another late late chime in: An argument for supporting .jsx is that up until recently (e.g. pre-flow), .js pretty consistently meant "a version of ES that either matches current or future ES specs". I'm assuming that JSX will never become part of ES proper?

Similarly, why not .flow? There is .ts after all. (aside from it being potentially too late to bring up)

File extensions help tools and infrastructure determine what to do w/ the source. Having to guess is error prone and added complication

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! There's so much drama around this subject that we're probably going to wait until it settles and gets shipped in node before taking any action on react native

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same is true for Jest and I'd say Facebook in general. Let's see how this goes for node and then learn from whatever they do :)

Copy link

@yordis yordis Jan 24, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vjeux your first comment makes sense if you wouldn't talk about React ecosystem. I am having a hard time trying to understand why would you use that argument.

.jsx was invented by React team from the beginning of the time where React appear on the market as long as I remember from 2014 (4 years ago).

So yeah, I wouldn't support any random extension that appear but this one do not makes sense at all, React Native is about React, so probably .jsx would be more important than .js itself, but because we started using Babel we forget where we come from.

Outside that airbnb code style requires it for a really good reason, you are explicit about which file requires JSX syntax and which one doesn't and IDE/Editors likes that extension.

SeemsGood

I can't understand your point.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

} else if (this._fastfs.fileExists(potentialModulePath + '.js')) {
file = potentialModulePath + '.js';
} else if (this._fastfs.fileExists(potentialModulePath + '.jsx')) {
file = potentialModulePath + '.jsx';
} else if (this._fastfs.fileExists(potentialModulePath + '.json')) {
file = potentialModulePath + '.json';
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class DependencyGraph {
platforms: platforms || [],
preferNativePlatform: preferNativePlatform || false,
cache,
extensions: extensions || ['js', 'json'],
extensions: extensions || ['js', 'jsx', 'json'],
mocksPattern,
extractRequires,
};
Expand Down
1 change: 1 addition & 0 deletions packager/react-packager/src/Server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ class Server {
dir: dir,
globs: [
'**/*.js',
'**/*.jsx',
'**/*.json',
].concat(assetGlobs),
};
Expand Down