update build system

polyfill new js features before executing tests
move jest config to file, update transformation exclusion to be okay with axios module
rename enzyme.config.js to jest.setup.js
remove currently unused redux deps
update babel to 7, use env preset as opposed to deprecated stage preset
move .babelrc to newer, favored babel.config.js preset
update all babel preset and plugin packages to those name spaced under @babel
This commit is contained in:
John Mitchell 2018-10-30 17:25:29 -04:00
parent 3ccfc5905e
commit fed7f51476
No known key found for this signature in database
GPG Key ID: FE6A9B5BD4EB5C94
7 changed files with 1108 additions and 554 deletions

View File

@ -1,7 +0,0 @@
{
"presets": [
"env",
"react",
"stage-2"
]
}

16
babel.config.js Normal file
View File

@ -0,0 +1,16 @@
module.exports = api => {
api.cache(false);
return {
plugins: [
'@babel/plugin-proposal-class-properties'
],
presets: [
['@babel/preset-env', {
targets: {
node: '8.11'
}
}],
'@babel/preset-react'
]
};
};

20
jest.config.js Normal file
View File

@ -0,0 +1,20 @@
module.exports = {
collectCoverageFrom: [
'src/**/*.{js,jsx}'
],
moduleNameMapper: {
'^[./a-zA-Z0-9$_-]+\\.svg$': '<rootDir>/__tests__/stubs/svgStub.js'
},
setupTestFrameworkScriptFile: '<rootDir>/jest.setup.js',
testMatch: [
'<rootDir>/__tests__/tests/**/*.{js,jsx}'
],
testEnvironment: 'jsdom',
testURL: 'http://127.0.0.1:3001',
transform: {
'^.+\\.(js|jsx)$': 'babel-jest'
},
transformIgnorePatterns: [
'[/\\\\]node_modules[/\\\\].+\\.(?!(axios)/)(js|jsx)$'
]
};

View File

@ -1,3 +1,5 @@
require('@babel/polyfill');
const enzyme = require('enzyme');
const Adapter = require('enzyme-adapter-react-16');

1517
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -12,12 +12,15 @@
"author": "",
"license": "Apache",
"devDependencies": {
"babel-core": "^6.26.3",
"babel-eslint": "^10.0.0",
"@babel/core": "^7.1.2",
"@babel/plugin-proposal-class-properties": "^7.1.0",
"@babel/polyfill": "^7.0.0",
"@babel/preset-env": "^7.1.0",
"@babel/preset-react": "^7.0.0",
"babel-core": "^7.0.0-bridge.0",
"babel-eslint": "^10.0.1",
"babel-jest": "^23.6.0",
"babel-loader": "^7.1.5",
"babel-preset-react": "^6.24.1",
"babel-preset-stage-2": "^6.24.1",
"babel-loader": "^8.0.4",
"css-loader": "^1.0.0",
"enzyme": "^3.7.0",
"enzyme-adapter-react-16": "^1.6.0",
@ -32,7 +35,7 @@
"react-hot-loader": "^4.3.3",
"sass-loader": "^7.1.0",
"style-loader": "^0.23.0",
"webpack": "^4.15.1",
"webpack": "^4.23.1",
"webpack-cli": "^3.0.8",
"webpack-dev-server": "^3.1.4"
},
@ -43,31 +46,8 @@
"@patternfly/react-styles": "^2.3.0",
"@patternfly/react-tokens": "^1.6.0",
"axios": "^0.18.0",
"babel-preset-env": "^1.7.0",
"react": "^16.4.1",
"react-dom": "^16.4.1",
"react-redux": "^5.0.7",
"react-router-dom": "^4.3.1",
"redux": "^4.0.0"
},
"jest": {
"collectCoverageFrom": [
"src/**/*.{js,jsx}"
],
"moduleNameMapper": {
"^[./a-zA-Z0-9$_-]+\\.svg$": "<rootDir>/__tests__/stubs/svgStub.js"
},
"setupTestFrameworkScriptFile": "<rootDir>/enzyme.config.js",
"testMatch": [
"<rootDir>/__tests__/tests/**/*.{js,jsx}"
],
"testEnvironment": "jsdom",
"testURL": "http://127.0.0.1:3001",
"transform": {
"^.+\\.(js|jsx)$": "<rootDir>/node_modules/babel-jest"
},
"transformIgnorePatterns": [
"[/\\\\]node_modules[/\\\\].+\\.(js|jsx)$"
]
"react-router-dom": "^4.3.1"
}
}

View File

@ -1,3 +1,4 @@
const path = require('path');
const webpack = require('webpack');
const TARGET_PORT = 8043;
@ -10,7 +11,7 @@ module.exports = {
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
use: ['babel-loader']
loader: 'babel-loader'
},
{
test: /\.s?[ac]ss$/,
@ -23,29 +24,29 @@ module.exports = {
{
test: /\.(woff(2)?|ttf|eot)(\?v=\d+\.\d+\.\d+)?$/,
use: [{
loader: 'file-loader',
options: {
name: '[name].[ext]',
outputPath: 'assets/fonts/',
publicPatH: '../',
includePaths: [
'node_modules/@patternfly/patternfly-next/assets/fonts',
]
}
loader: 'file-loader',
options: {
name: '[name].[ext]',
outputPath: 'assets/fonts/',
publicPatH: '../',
includePaths: [
'node_modules/@patternfly/patternfly-next/assets/fonts',
]
}
}]
},
{
test: /\.(jpg|png|gif|svg)(\?v=\d+\.\d+\.\d+)?$/,
use: [{
loader: 'file-loader',
options: {
name: '[name].[ext]',
outputPath: 'assets/images/',
publicPatH: '../',
includePaths: [
'node_modules/@patternfly/patternfly-next/assets/images',
]
}
loader: 'file-loader',
options: {
name: '[name].[ext]',
outputPath: 'assets/images/',
publicPatH: '../',
includePaths: [
'node_modules/@patternfly/patternfly-next/assets/images',
]
}
}]
}
]
@ -54,7 +55,7 @@ module.exports = {
extensions: ['*', '.js', '.jsx', '.css']
},
output: {
path: __dirname + '/dist',
path: path.resolve(__dirname, '/dist'),
publicPath: '/',
filename: 'bundle.js'
},
@ -71,29 +72,30 @@ module.exports = {
port: 3001,
clientLogLevel: 'none',
proxy: [
{
{
context: '/api/login/',
target: TARGET,
secure: false,
ws: false,
headers: {
Host: `localhost:${TARGET_PORT}`,
Origin: TARGET,
Referer: `${TARGET}/`
Host: `localhost:${TARGET_PORT}`,
Origin: TARGET,
Referer: `${TARGET}/`
}
},
{
},
{
context: '/api',
target: TARGET,
secure: false,
ws: false,
bypass: req => (req.originalUrl.includes('hot-update.json') || req.originalUrl.includes('login')),
},
{
},
{
context: '/websocket',
target: TARGET,
secure: false,
ws: true
}]
}
]
}
};