Commit 49e4f646 authored by Jeremy Gayed's avatar Jeremy Gayed Committed by Dan Abramov
Browse files

Adds JSX extension support (#563)

* Adds JSX extension support

* PR changes

* Add testRegex

* Add note about not recommending JSX, link to issue
parent 6da29550
Showing with 15 additions and 7 deletions
+15 -7
......@@ -74,7 +74,10 @@ 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 to support
// some tools, although we do not recommend using it, see:
// https://github.com/facebookincubator/create-react-app/issues/290
extensions: ['.js', '.json', '.jsx', ''],
alias: {
// Support React Native Web
// https://www.smashingmagazine.com/2016/08/a-glimpse-into-the-future-with-react-native-for-web/
......@@ -93,7 +96,7 @@ module.exports = {
// It's important to do this before Babel processes the JS.
preLoaders: [
{
test: /\.js$/,
test: /\.(js|jsx)$/,
loader: 'eslint',
include: paths.appSrc,
}
......@@ -101,7 +104,7 @@ module.exports = {
loaders: [
// Process JS with Babel.
{
test: /\.js$/,
test: /\.(js|jsx)$/,
include: paths.appSrc,
loader: 'babel',
query: require('./babel.dev')
......
......@@ -69,7 +69,10 @@ 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 to support
// some tools, although we do not recommend using it, see:
// https://github.com/facebookincubator/create-react-app/issues/290
extensions: ['.js', '.json', '.jsx', ''],
alias: {
// Support React Native Web
// https://www.smashingmagazine.com/2016/08/a-glimpse-into-the-future-with-react-native-for-web/
......@@ -88,7 +91,7 @@ module.exports = {
// It's important to do this before Babel processes the JS.
preLoaders: [
{
test: /\.js$/,
test: /\.(js|jsx)$/,
loader: 'eslint',
include: paths.appSrc
}
......@@ -96,7 +99,7 @@ module.exports = {
loaders: [
// Process JS with Babel.
{
test: /\.js$/,
test: /\.(js|jsx)$/,
include: paths.appSrc,
loader: 'babel',
query: require('./babel.prod')
......
......@@ -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')
......@@ -26,7 +27,8 @@ module.exports = (resolve, rootDir) => {
scriptPreprocessor: resolve('config/jest/transform.js'),
setupFiles: setupFiles,
testPathIgnorePatterns: ['<rootDir>/(build|docs|node_modules)/'],
testEnvironment: 'node'
testEnvironment: 'node',
testRegex: '(/__tests__/.*|\\.(test|spec))\\.(js|jsx)$',
};
if (rootDir) {
config.rootDir = rootDir;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment