Skip to content

Commit 1353f61

Browse files
author
Ndifreke
committed
Upgrade webpack 5
1 parent c6dc15a commit 1353f61

File tree

4 files changed

+2295
-2771
lines changed

4 files changed

+2295
-2771
lines changed

.eslintrc

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,12 @@
2929
},
3030

3131
"plugins": [
32-
"prettier",
33-
"no-unused-vars-rest"
32+
"prettier"
33+
],
34+
"extends": [
35+
"plugin:@typescript-eslint/recommended",
36+
// "plugin:@typescript-eslint/recommended-requiring-type-checking"
3437
],
35-
3638
"rules": {
3739
"prettier/prettier": "error"
3840
},
@@ -46,10 +48,11 @@
4648
"jsx-a11y",
4749
"@typescript-eslint"
4850
],
49-
"parser": "@typescript-eslint/parser",
51+
"parser": "@babel/eslint-parser",
5052
"rules": {
51-
"no-unused-vars": "off",
52-
"@typescript-eslint/no-unused-vars": "error"
53+
"no-unused-vars": ["error", { "vars": "all", "args": "after-used", "ignoreRestSiblings": false }]
54+
// "no-unused-vars": "off",
55+
// "@typescript-eslint/no-unused-vars": "error"
5356
}
5457
}
5558
]

package.json

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
"main": "lib/server/platform-api.js",
77
"types": "types/index.d.ts",
88
"scripts": {
9-
"build": "rm -rf ./types && rm -rf ./lib && webpack --env.mode=build && mv types/src/* types/ && rm -r types/src",
10-
"dev": "webpack --progress --colors --watch --env.mode=dev",
9+
"build": "rm -rf ./types && rm -rf ./lib && webpack --env MODE=build && mv types/src/* types/ && rm -r types/src",
10+
"dev": "webpack --progress --watch --env MODE=dev",
1111
"test": "npm run test-web && npm run test-node",
1212
"test-web": "mocha -r mock-local-storage ./test/.setup.js ./test/**/*.spec.js",
1313
"test-node": "mocha -r ./test/.setup-node.js ./test/**/*.spec.js",
@@ -18,6 +18,7 @@
1818
"devDependencies": {
1919
"@babel/cli": "^7.8.4",
2020
"@babel/core": "^7.9.0",
21+
"@babel/eslint-parser": "^7.21.3",
2122
"@babel/plugin-transform-runtime": "^7.9.0",
2223
"@babel/preset-env": "^7.9.5",
2324
"@babel/preset-typescript": "^7.16.7",
@@ -27,15 +28,13 @@
2728
"@types/is-url": "^1.2.30",
2829
"@types/node": "^17.0.10",
2930
"@types/object.pick": "^1.3.1",
30-
"@typescript-eslint/eslint-plugin": "^5.9.1",
31-
"@typescript-eslint/parser": "^5.9.1",
31+
"@typescript-eslint/eslint-plugin": "^5.55.0",
3232
"babel-eslint": "10.1.0",
33-
"babel-loader": "8.1.0",
33+
"babel-loader": "9.1.2",
3434
"chai": "3.5.0",
35-
"eslint": "^4.18.2",
36-
"eslint-loader": "1.6.3",
37-
"eslint-plugin-no-unused-vars-rest": "^1.0.4",
35+
"eslint": "^8.36.0",
3836
"eslint-plugin-prettier": "^2.7.0",
37+
"eslint-webpack-plugin": "^4.0.0",
3938
"fake-fetch": "^1.0.0",
4039
"fetch-mock": "^5.9.4",
4140
"husky": "^0.14.3",
@@ -45,11 +44,10 @@
4544
"mock-local-storage": "^1.1.8",
4645
"prettier": "1.13.4",
4746
"sinon": "^1.17.6",
48-
"terser-webpack-plugin": "^2.3.6",
47+
"terser-webpack-plugin": "^5.3.7",
4948
"ts-node": "^10.4.0",
5049
"typescript": "^4.5.4",
51-
"webpack": "^4.43.0",
52-
"webpack-cli": "^3.3.11",
50+
"webpack-cli": "^5.0.1",
5351
"webpack-merge": "^4.2.2",
5452
"yargs": "6.6.0"
5553
},
@@ -63,20 +61,27 @@
6361
"author": "",
6462
"license": "MIT",
6563
"dependencies": {
64+
"@typescript-eslint/parser": "^5.55.0",
6665
"atob": "^2.1.2",
6766
"basename": "^0.1.2",
67+
"circular-dependency-plugin": "^5.2.2",
6868
"detect-node": "^2.0.4",
6969
"email-validator": "^1.0.7",
7070
"es6-promise": "4.2.6",
71+
"eslint-plugin-jsx-a11y": "^6.7.1",
72+
"eslint-plugin-react": "^7.32.2",
73+
"eslint-plugin-react-hooks": "^4.6.0",
7174
"is-scalar": "^1.0.2",
7275
"is-url": "^1.2.2",
7376
"isomorphic-fetch": "^3.0.0",
7477
"oauth2-popup-flow": "^1.1.0",
7578
"object.pick": "^1.3.0",
7679
"parse_url": "^0.1.1",
80+
"path-browserify": "^1.0.1",
7781
"slugify": "^1.3.4",
7882
"to-querystring": "^1.1.3",
79-
"ts-loader": "~8.2.0",
80-
"url-pattern": "^1.0.3"
83+
"ts-loader": "~9.4.2",
84+
"url-pattern": "^1.0.3",
85+
"webpack": "^5.76.1"
8186
}
8287
}

webpack.config.js

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,24 @@ const TerserPlugin = require("terser-webpack-plugin");
33
var path = require("path");
44
var env = require("yargs").argv.env;
55
var merge = require("webpack-merge");
6-
6+
const CircularDependencyPlugin = require("circular-dependency-plugin");
77
var libraryName = "platform-api";
88

9-
var plugins = [],
9+
var plugins = [
10+
new CircularDependencyPlugin({
11+
// exclude detection of files based on a RegExp
12+
exclude: /a\.js|node_modules/,
13+
// include specific files based on a RegExp
14+
include: /src/,
15+
// add errors to webpack instead of warnings
16+
failOnError: true,
17+
// allow import cycles that include an asyncronous import,
18+
// e.g. via import(/* webpackMode: "weak" */ './file.js')
19+
allowAsyncCycles: false,
20+
// set the current working directory for displaying module paths
21+
cwd: process.cwd()
22+
})
23+
],
1024
outputFile;
1125
let additionalSettings = {};
1226

@@ -29,7 +43,7 @@ var config = {
2943
filename: outputFile
3044
},
3145
watchOptions: {
32-
ignored: [/node_modules/, /types/]
46+
ignored: /(node_modules|types)/
3347
},
3448
module: {
3549
rules: [
@@ -47,7 +61,10 @@ var config = {
4761
},
4862
resolve: {
4963
modules: [path.resolve("./src"), "node_modules"],
50-
extensions: [".js", ".ts"]
64+
extensions: [".js", ".ts"],
65+
fallback: {
66+
path: require.resolve("path-browserify")
67+
}
5168
},
5269
plugins: plugins,
5370
...additionalSettings

0 commit comments

Comments
 (0)