Skip to content
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

Adds JSX extension support #563

Merged
merged 4 commits into from
Sep 3, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 3 additions & 3 deletions config/webpack.config.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ module.exports = {
// https://github.com/facebookincubator/create-react-app/issues/253
fallback: paths.nodePaths,
// These are the reasonable defaults supported by the Node ecosystem.
extensions: ['.js', '.json', ''],
extensions: ['.jsx', '.js', '.json', ''],
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's make it the last extension before "", not the first.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, how about after .js?

Copy link
Contributor

Choose a reason for hiding this comment

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

I would prefer Node resolution mechanism to be respected before falling back to JSX.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, ok makes sense.

alias: {
// Support React Native Web
// https://www.smashingmagazine.com/2016/08/a-glimpse-into-the-future-with-react-native-for-web/
Expand All @@ -93,15 +93,15 @@ module.exports = {
// It's important to do this before Babel processes the JS.
preLoaders: [
{
test: /\.js$/,
test: /\.jsx?$/,
Copy link
Contributor

Choose a reason for hiding this comment

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

People often don't understand what ? means here. Let's explicitly say js|jsx

loader: 'eslint',
include: paths.appSrc,
}
],
loaders: [
// Process JS with Babel.
{
test: /\.js$/,
test: /\.jsx?$/,
include: paths.appSrc,
loader: 'babel',
query: require('./babel.dev')
Expand Down
7 changes: 4 additions & 3 deletions config/webpack.config.prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ module.exports = {
// https://github.com/facebookincubator/create-react-app/issues/253
fallback: paths.nodePaths,
// These are the reasonable defaults supported by the Node ecosystem.
extensions: ['.js', '.json', ''],
// We also include JSX as a common component filename extension.
extensions: ['.jsx', '.js', '.json', ''],
alias: {
// Support React Native Web
// https://www.smashingmagazine.com/2016/08/a-glimpse-into-the-future-with-react-native-for-web/
Expand All @@ -88,15 +89,15 @@ module.exports = {
// It's important to do this before Babel processes the JS.
preLoaders: [
{
test: /\.js$/,
test: /\.jsx?$/,
loader: 'eslint',
include: paths.appSrc
}
],
loaders: [
// Process JS with Babel.
{
test: /\.js$/,
test: /\.jsx?$/,
include: paths.appSrc,
loader: 'babel',
query: require('./babel.prod')
Expand Down
1 change: 1 addition & 0 deletions scripts/utils/createJestConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ module.exports = (resolve, rootDir) => {
}

const config = {
moduleFileExtensions: ['jsx', 'js', 'json'],
moduleNameMapper: {
'^[./a-zA-Z0-9$_-]+\\.(jpg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm)$': resolve('config/jest/FileStub.js'),
'^[./a-zA-Z0-9$_-]+\\.css$': resolve('config/jest/CSSStub.js')
Expand Down