Skip to content

Commit

Permalink
Webpack + minor dependencies upgrade (#845)
Browse files Browse the repository at this point in the history
* upgrade minor dependences

* webpack upgrade

* update webpack minimizer
  • Loading branch information
minotogna authored Jul 13, 2021
1 parent 48da195 commit 71e123c
Show file tree
Hide file tree
Showing 11 changed files with 1,396 additions and 2,705 deletions.
9 changes: 4 additions & 5 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@
}
},
"extends": [
"plugin:@typescript-eslint/recommended",
"prettier/@typescript-eslint",
"prettier",
"airbnb",
"plugin:prettier/recommended",
"prettier/react"
"plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended"
],
"env": {
"browser": true,
Expand All @@ -24,7 +23,7 @@
"plugins": ["prettier"],
"rules": {
"no-underscore-dangle": 0,
"prettier/prettier": "error",
"prettier/prettier": 1,
"react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx", ".ts", ".tsx"] }],
"react/forbid-prop-types": 0,
"react/prop-types": "off",
Expand Down
1 change: 0 additions & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npm test
yarn pre-commit
10 changes: 2 additions & 8 deletions common/assessmentSectionItems.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,18 +226,12 @@ export const convertToAssessmentSections = (assessments: any) =>
R.pipe(
R.toPairs,
R.map(([assessment, items]) => [assessment, sectionsFromItems(items)]),
// @ts-ignore
R.fromPairs
// @ts-ignore
)(assessments)

/**
* @deprecated
*/
export const assessmentSections = convertToAssessmentSections(assessments)

/**
* @deprecated
*/

/**
* @deprecated
*/
4 changes: 2 additions & 2 deletions common/countryRole.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as R from 'ramda'
import * as assert from 'assert'
// import * as assert from 'assert'
// The returned value is of the form:
// {role: <ROLE>, label: <LABEL>}

Expand Down Expand Up @@ -45,7 +45,7 @@ export const roleForCountry = (countryIso: any, userInfo: any) => {
if (!userInfo) return noRole
if (hasRole('ADMINISTRATOR', userInfo.roles)) return administrator
const rolesForCountry: any = getCountryRoles(countryIso, userInfo)
assert(rolesForCountry.length < 2, `Ambiguous roles found for user ${userInfo} and country ${countryIso}`)
// assert(rolesForCountry.length < 2, `Ambiguous roles found for user ${userInfo} and country ${countryIso}`)
if (rolesForCountry.length === 0) return noRole

const roleObj = roles[rolesForCountry[0].role]
Expand Down
131 changes: 64 additions & 67 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
"scripts": {
"build": "yarn build:client && yarn build:server && yarn build:copy",
"build:server": "yarn tsc --project tsconfig.server.json && yarn tscpaths -v -p tsconfig.server.paths.json -s ./server -o ./dist",
"build:client": "NODE_ENV=production webpack -p --config webpack.config.babel.js",
"build:client": "NODE_ENV=production webpack --config webpack.config.babel.js",
"build:copy": "cp -a server/db/migration/* dist/server/db/migration/. && cp -a web-resources dist/ && cp -a server/static dist/server/",
"build:watch": "NODE_ENV=development webpack --config webpack.config.babel.js --watch",
"build:dev-server": "NODE_ENV=development webpack-dev-server",
"build:dev-server": "NODE_ENV=development webpack serve --config webpack.config.babel.js --progress",
"build:prod:report": "cross-env NODE_ENV=production BUILD_REPORT=true webpack --display-error-details -p --config webpack.config.babel.js",
"build:prod": "cross-env NODE_ENV=production webpack --display-error-details -p --config webpack.config.babel.js",
"clean": "rm -rf dist/",
Expand All @@ -30,97 +30,96 @@
"devDependencies": {
"@babel/cli": "^7.14.5",
"@babel/core": "^7.14.6",
"@babel/plugin-proposal-object-rest-spread": "^7.14.5",
"@babel/eslint-parser": "^7.14.7",
"@babel/plugin-proposal-object-rest-spread": "^7.14.7",
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
"@babel/preset-env": "^7.14.5",
"@babel/preset-env": "^7.14.7",
"@babel/preset-react": "^7.14.5",
"@babel/preset-typescript": "^7.14.5",
"@babel/register": "^7.14.5",
"@babel/runtime-corejs3": "^7.14.6",
"@babel/runtime-corejs3": "^7.14.7",
"@pmmmwh/react-refresh-webpack-plugin": "^0.4.3",
"@types/axios": "^0.14.0",
"@types/bcrypt": "^5.0.0",
"@types/bluebird-global": "^3.5.12",
"@types/body-parser": "^1.19.0",
"@types/chai": "^4.2.18",
"@types/chartjs": "^0.0.31",
"@types/compression": "^1.7.0",
"@types/connect-pg-simple": "^4.2.2",
"@types/body-parser": "^1.19.1",
"@types/chai": "^4.2.21",
"@types/chart.js": "^2.9.34",
"@types/compression": "^1.7.1",
"@types/connect-pg-simple": "^4.2.4",
"@types/cookie-parser": "^1.4.2",
"@types/d3": "^6.7.0",
"@types/d3": "^7.0.0",
"@types/d3-interpolate-path": "^2.0.0",
"@types/d3-tip": "^3.5.5",
"@types/express": "^4.17.12",
"@types/express-fileupload": "^1.1.6",
"@types/jest": "^26.0.23",
"@types/json2csv": "^5.0.2",
"@types/marked": "^2.0.3",
"@types/mocha": "^8.2.2",
"@types/morgan": "^1.9.2",
"@types/node": "^15.0.3",
"@types/node-schedule": "^1.3.1",
"@types/nodemailer": "^6.4.2",
"@types/passport": "^1.0.6",
"@types/passport-google-oauth": "^1.0.41",
"@types/passport-local": "^1.0.33",
"@types/pg": "^8.6.0",
"@types/ramda": "^0.27.40",
"@types/react": "^17.0.11",
"@types/react-csv": "^1.1.1",
"@types/react-dom": "^17.0.7",
"@types/react-redux": "^7.1.15",
"@types/react-responsive": "^8.0.2",
"@types/react-router-dom": "^5.1.7",
"@types/express": "^4.17.13",
"@types/express-fileupload": "^1.1.7",
"@types/jest": "^26.0.24",
"@types/json2csv": "^5.0.3",
"@types/marked": "^2.0.4",
"@types/mocha": "^8.2.3",
"@types/morgan": "^1.9.3",
"@types/node": "^16.3.1",
"@types/node-schedule": "^1.3.2",
"@types/nodemailer": "^6.4.4",
"@types/passport": "^1.0.7",
"@types/passport-google-oauth": "^1.0.42",
"@types/passport-local": "^1.0.34",
"@types/pg": "^8.6.1",
"@types/ramda": "^0.27.44",
"@types/react": "^17.0.14",
"@types/react-csv": "^1.1.2",
"@types/react-dom": "^17.0.9",
"@types/react-redux": "^7.1.18",
"@types/react-responsive": "^8.0.3",
"@types/react-router-dom": "^5.1.8",
"@types/redux-debounced": "^0.2.19",
"@types/to-snake-case": "^1.0.0",
"@types/uuid": "^8.3.0",
"@typescript-eslint/eslint-plugin": "^4.23.0",
"@typescript-eslint/parser": "^4.23.0",
"babel-eslint": "^10.1.0",
"@types/uuid": "^8.3.1",
"@typescript-eslint/eslint-plugin": "^4.28.2",
"@typescript-eslint/parser": "^4.28.2",
"babel-loader": "^8.2.2",
"chai": "^4.3.4",
"clean-webpack-plugin": "^3.0.0",
"clean-webpack-plugin": "^4.0.0-alpha.0",
"cross-env": "^7.0.3",
"css-loader": "^5.2.6",
"css-minimizer-webpack-plugin": "^3.0.2",
"csv": "^5.5.0",
"eslint": "^7.28.0",
"eslint": "^7.30.0",
"eslint-config-airbnb": "^18.2.1",
"eslint-config-prettier": "^7.1.0",
"eslint-config-prettier": "^8.3.0",
"eslint-import-resolver-webpack": "^0.13.1",
"eslint-plugin-import": "^2.23.4",
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-prettier": "^3.4.0",
"eslint-plugin-react": "^7.24.0",
"extract-text-webpack-plugin": "^4.0.0-alpha.0",
"git-revision-webpack-plugin": "^3.0.6",
"google-fonts-plugin": "^5.0.2",
"html-webpack-plugin": "^4.5.1",
"git-revision-webpack-plugin": "^5.0.0",
"html-webpack-plugin": "^5.3.2",
"husky": "^6.0.0",
"jsondiffpatch": "^0.4.1",
"less": "^4.1.1",
"less-loader": "^7.2.1",
"less-loader": "^10.0.1",
"lint-staged": ">=10.5.3",
"mini-css-extract-plugin": "^1.6.0",
"mini-css-extract-plugin": "^2.1.0",
"mocha": "^8.4.0",
"mochapack": "^2.1.2",
"nodemon": "^2.0.7",
"nodemon": "^2.0.12",
"null-loader": "^4.0.0",
"pdfjs-dist": "^2.8.335",
"prettier": "^2.3.1",
"prettier": "^2.3.2",
"puppeteer": "^5.5.0",
"react-refresh": "^0.10.0",
"sass": "^1.35.1",
"sass-loader": "^10.2.0",
"source-map-loader": "^2.0.1",
"style-loader": "^2.0.0",
"ts-migrate": "^0.1.19",
"ts-node": "^10.0.0",
"ts-node-dev": "^1.1.6",
"sass": "^1.35.2",
"sass-loader": "^12.1.0",
"source-map-loader": "^3.0.0",
"style-loader": "^3.0.0",
"terser-webpack-plugin": "^5.1.4",
"ts-migrate": "^0.1.20",
"ts-node": "^10.1.0",
"ts-node-dev": "^1.1.8",
"tscpaths": "^0.0.9",
"typescript": "^4.3.2",
"webpack": "^4.44.2",
"webpack-bundle-analyzer": "^3.8.0",
"webpack-cli": "^3.3.11",
"typescript": "^4.3.5",
"webpack": "^5.44.0",
"webpack-bundle-analyzer": "^4.4.2",
"webpack-cli": "^4.7.2",
"webpack-dev-server": "^3.11.1"
},
"dependencies": {
Expand All @@ -138,7 +137,7 @@
"compression": "^1.6.2",
"connect-pg-simple": "^6.2.1",
"cookie-parser": "^1.4.5",
"core-js": "^3.14.0",
"core-js": "^3.15.2",
"d3": "^7.0.0",
"d3-interpolate-path": "^2.2.3",
"d3-tip": "^0.9.1",
Expand All @@ -150,14 +149,13 @@
"express": "^4.15.2",
"express-fileupload": "^1.2.1",
"express-session": "^1.17.2",
"i18next": "^20.3.1",
"i18next": "^20.3.2",
"json2csv": "^5.0.6",
"jszip": "^3.6.0",
"marked": "^2.1.0",
"marked": "^2.1.3",
"morgan": "^1.10.0",
"node-schedule": "^2.0.0",
"nodemailer": "^6.6.1",
"optimize-css-assets-webpack-plugin": "^5.0.4",
"nodemailer": "^6.6.2",
"passport": "^0.4.1",
"passport-google-oauth": "^2.0.0",
"passport-local": "^1.0.0",
Expand All @@ -177,10 +175,9 @@
"redux-promise": "^0.6.0",
"redux-thunk": "^2.2.0",
"to-snake-case": "^1.0.0",
"tsconfig-paths": "^3.9.0",
"uglifyjs-webpack-plugin": "^2.2.0",
"tsconfig-paths": "^3.10.1",
"uuid": "^8.3.2",
"webpack-node-externals": "^2.5.2"
"webpack-node-externals": "^3.0.0"
},
"browserslist": [
"last 2 versions"
Expand Down
1 change: 1 addition & 0 deletions server/assessment/assessmentEditAccessControl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export const assessmentForSection = (section: any) =>
// @ts-ignore
R.map(([assessment, sections]) => (R.contains(section, sections) ? assessment : null)),
R.head
// @ts-ignore
)(assessmentSections)

export const getAssessmentStatus = async (countryIso: any, section: any) => {
Expand Down
7 changes: 6 additions & 1 deletion server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { serverInit } from './serverInit'

import * as VersioningScheduler from './system/schedulers/versioningScheduler'

// @ts-ignore
if (cluster.isMaster) {
// check db migrations in master process
migrations()
Expand All @@ -16,17 +17,21 @@ if (cluster.isMaster) {

console.log(`Master cluster setting up ${numWorkers} workers...`)

for (let i = 0; i < numWorkers; i++) {
for (let i = 0; i < numWorkers; i += 1) {
// @ts-ignore
cluster.fork()
}

// @ts-ignore
cluster.on('online', function (worker: any) {
console.log(`Worker ${worker.process.pid} is online`)
})

// @ts-ignore
cluster.on('exit', function (worker: any, code: any, signal: any) {
console.log(`Worker ${worker.process.pid} died with code: ${code}, and signal: ${signal}`)
console.log('Starting a new worker')
// @ts-ignore
cluster.fork()
})

Expand Down
4 changes: 2 additions & 2 deletions webapp/components/AssessmentComponent/AssessmentComponent.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react'
import * as assert from 'assert'
// import * as assert from 'assert'

import FRA from '@common/assessment/fra'

Expand All @@ -19,7 +19,7 @@ const AssessmentComponent: React.FC<Props> = (props: Props) => {
const { components, defaultKey, ...otherProps } = props
const key = isAssessment ? assessmentType : defaultKey

assert.ok(key !== 'en', key)
// assert.ok(key !== 'en', key)

return React.createElement(components[key], otherProps)
}
Expand Down
2 changes: 1 addition & 1 deletion webapp/main/styles/style.less
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//===WARNING====
// DO NOT IMPORT SPECIFIC COMPONENT STYLES HERE,
// ONLY MORE GENERAL STUFF USED IN MANY PLACES
@import url('/woff2.css');
@import url('https://fonts.googleapis.com/css2?family=Open+Sans:ital,wght@0,300;0,400;0,600;0,700;1,300;1,400;1,600;1,700&display=swap');
@import 'webapp/main/styles/config';
//Import all common application styles
@import 'webapp/main/styles/cssVars';
Expand Down
Loading

0 comments on commit 71e123c

Please sign in to comment.