-
Notifications
You must be signed in to change notification settings - Fork 324
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Upgrade babel config * Update jest config * Improve test performance * Align babel config with create-react-app * Fix various config flows
- Loading branch information
Showing
26 changed files
with
630 additions
and
808 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
module.exports = (api) => { | ||
api.cache.using(() => process.env.NODE_ENV); | ||
|
||
const IS_PROD = api.env('production'); | ||
const IS_DEV = api.env('development'); | ||
const IS_TEST = api.env('test'); | ||
|
||
const presets = [ | ||
[ | ||
'@babel/preset-env', | ||
{ | ||
// eslint-disable-next-line global-require | ||
targets: IS_TEST ? { node: true } : { browsers: require('./package.json').browserslist }, | ||
modules: IS_TEST ? 'commonjs' : false, | ||
// Exclude transforms that make all code slower | ||
// See https://github.com/facebook/create-react-app/pull/5278 | ||
exclude: ['transform-typeof-symbol'], | ||
}, | ||
], | ||
['@babel/preset-react', { development: !IS_PROD }], | ||
'@babel/preset-flow', | ||
]; | ||
|
||
const plugins = [ | ||
'babel-plugin-lodash', | ||
'@babel/plugin-syntax-dynamic-import', | ||
// Deviate from spec, but Object.defineProperty is expensive | ||
// See https://github.com/facebook/create-react-app/issues/4263 | ||
['@babel/plugin-proposal-class-properties', { loose: true }], | ||
['@babel/plugin-proposal-optional-chaining', { loose: true }], | ||
]; | ||
|
||
if (IS_DEV || IS_PROD) { | ||
plugins.push(['@babel/plugin-proposal-object-rest-spread', { useBuiltIns: true }]); | ||
} | ||
if (IS_DEV) { | ||
plugins.push('react-hot-loader/babel'); | ||
} | ||
if (IS_PROD) { | ||
// React Optimize plugins | ||
plugins.push( | ||
'@babel/plugin-transform-react-inline-elements', | ||
'@babel/plugin-transform-react-constant-elements', | ||
'babel-plugin-transform-react-remove-prop-types', | ||
'babel-plugin-transform-react-class-to-function', | ||
); | ||
} | ||
if (IS_TEST) { | ||
plugins.push('babel-plugin-dynamic-import-node'); | ||
} | ||
|
||
return { | ||
presets, | ||
plugins, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,25 @@ | ||
module.exports = { | ||
roots: [ | ||
'<rootDir>/src', | ||
], | ||
moduleDirectories: [ | ||
'node_modules', | ||
'src/js', | ||
], | ||
modulePaths: [ | ||
'<rootDir>', | ||
], | ||
testPathIgnorePatterns: [ | ||
'<rootDir>/.eslintrc.js', | ||
], | ||
collectCoverageFrom: [ | ||
'src/**/*.{js|jsx}', | ||
], | ||
coveragePathIgnorePatterns: [ | ||
'src/js/test_utils', | ||
'src/js/e2e', | ||
// Code in this file triggers this bug - https://github.com/istanbuljs/babel-plugin-istanbul/issues/116 | ||
'src/js/views/modules/ModulePageContent.jsx', | ||
], | ||
roots: ['<rootDir>/src/js'], | ||
moduleDirectories: ['node_modules', '<rootDir>/src/js'], | ||
moduleFileExtensions: ['jsx', 'js'], | ||
testPathIgnorePatterns: [], | ||
testRegex: 'src/js/.+\\.test\\.jsx?$', | ||
setupFiles: ['<rootDir>/scripts/test.js'], | ||
moduleNameMapper: { | ||
// Mock non JS files as strings | ||
'\\.(jpg|jpeg|png|gif|eot|otf|webp|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': '<rootDir>/__mocks__/fileMock.js', | ||
'\\.(?:jpg|jpeg|png|gif|eot|otf|webp|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': | ||
'<rootDir>/src/js/__mocks__/fileMock.js', | ||
// Mock SVG as React component | ||
'\\.svg\\?url': '<rootDir>/__mocks__/fileMock.js', | ||
'\\.svg': '<rootDir>/__mocks__/svgMock.jsx', | ||
'\\.svg\\?url$': '<rootDir>/src/js/__mocks__/fileMock.js', | ||
'\\.svg$': '<rootDir>/src/js/__mocks__/svgMock.jsx', | ||
// Mock SCSS and CSS modules as objects | ||
'\\.(css|scss)$': 'identity-obj-proxy', | ||
'\\.(?:css|scss)$': 'identity-obj-proxy', | ||
}, | ||
// Allow us to directly use enzyme wrappers for snapshotting | ||
// Usage: expect(enzyme.shallow(<div/>)).toMatchSnapshot(); | ||
snapshotSerializers: [ | ||
'<rootDir>/node_modules/enzyme-to-json/serializer', | ||
], | ||
snapshotSerializers: ['<rootDir>/node_modules/enzyme-to-json/serializer'], | ||
collectCoverageFrom: ['**/*.{js,jsx}'], | ||
coveragePathIgnorePatterns: ['/node_modules/', '<rootDir>/src/js/(?:test-utils|e2e)'], | ||
// Only write lcov files in CIs | ||
coverageReporters: ['text'].concat(process.env.CI ? 'lcov' : []), | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import { configure } from 'enzyme'; | ||
import Adapter from 'enzyme-adapter-react-16'; | ||
const { configure } = require('enzyme'); | ||
const Adapter = require('enzyme-adapter-react-16'); | ||
|
||
configure({ adapter: new Adapter() }); |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.