Skip to content

Commit ac01251

Browse files
Reduce extra deps more (#699)
* chore: reduce deps more * chore: reduce deps more * test: refactor no lodash at all
1 parent 3017bb6 commit ac01251

File tree

6 files changed

+95
-187
lines changed

6 files changed

+95
-187
lines changed

client/components/Sidebar.css

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
@value toggleTime: 200ms;
2-
31
.container {
42
background: var(--bg-primary);
53
border: none;
@@ -21,7 +19,7 @@
2119
bottom: 0;
2220
position: absolute;
2321
top: 0;
24-
transition: transform toggleTime ease;
22+
transition: transform 200ms ease;
2523
}
2624

2725
.container.pinned {

package-lock.json

Lines changed: 50 additions & 158 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@
6969
"autoprefixer": "10.2.5",
7070
"babel-eslint": "10.1.0",
7171
"babel-loader": "9.2.1",
72-
"babel-plugin-lodash": "3.3.4",
7372
"classnames": "2.3.1",
7473
"core-js": "3.12.1",
7574
"css-loader": "5.2.5",
@@ -81,21 +80,17 @@
8180
"eslint-config-th0r-react": "2.0.1",
8281
"eslint-plugin-react": "7.23.2",
8382
"filesize": "^6.3.0",
84-
"globby": "11.0.3",
8583
"jest": "^30.2.0",
86-
"lodash.memoize": "^4.1.2",
87-
"lodash.merge": "^4.6.2",
88-
"lodash.partial": "^4.2.1",
8984
"mobx": "5.15.7",
9085
"mobx-react": "6.3.1",
9186
"postcss": "8.3.0",
92-
"postcss-icss-values": "2.0.2",
9387
"postcss-loader": "5.3.0",
9488
"preact": "10.5.13",
9589
"prettier": "^3.8.0",
9690
"puppeteer": "^24.30.0",
9791
"style-loader": "2.0.0",
9892
"terser-webpack-plugin": "5.1.2",
93+
"tinyglobby": "^0.2.15",
9994
"webpack": "5.98.0",
10095
"webpack-cli": "6.0.1",
10196
"webpack-dev-server": "5.2.0"

test/helpers.js

Lines changed: 41 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,41 @@
11
const { readdirSync } = require("fs");
22
const webpack = require("webpack");
3-
const memoize = require("lodash.memoize");
4-
const partial = require("lodash.partial");
5-
const merge = require("lodash.merge");
63

74
global.webpackCompile = webpackCompile;
85
global.makeWebpackConfig = makeWebpackConfig;
96
global.forEachWebpackVersion = forEachWebpackVersion;
107

118
const BundleAnalyzerPlugin = require("../lib/BundleAnalyzerPlugin");
129

10+
/**
11+
* @template T
12+
* @typedef {() => T} FunctionReturning
13+
*/
14+
15+
/**
16+
* @template T
17+
* @param {FunctionReturning<T>} fn memorized function
18+
* @returns {FunctionReturning<T>} new function
19+
*/
20+
const memoize = (fn) => {
21+
let cache = false;
22+
/** @type {T | undefined} */
23+
let result;
24+
return () => {
25+
if (cache) {
26+
return /** @type {T} */ (result);
27+
}
28+
29+
result = fn();
30+
cache = true;
31+
// Allow to clean up memory for fn
32+
// and all dependent resources
33+
/** @type {FunctionReturning<T> | undefined} */
34+
(fn) = undefined;
35+
return /** @type {T} */ (result);
36+
};
37+
};
38+
1339
const getAvailableWebpackVersions = memoize(() =>
1440
readdirSync(`${__dirname}/webpack-versions`, { withFileTypes: true })
1541
.filter((entry) => entry.isDirectory())
@@ -51,7 +77,7 @@ function forEachWebpackVersion(versions, cb) {
5177
cb({
5278
it: itFn,
5379
version,
54-
webpackCompile: partial(webpackCompile, partial.placeholder, version),
80+
webpackCompile: (config) => webpackCompile(config, version),
5581
});
5682
}
5783
}
@@ -95,19 +121,18 @@ async function webpackCompile(config, version) {
95121
await wait(1);
96122
}
97123

98-
function makeWebpackConfig(opts) {
99-
opts = merge(
100-
{
101-
analyzerOpts: {
102-
analyzerMode: "static",
103-
openAnalyzer: false,
104-
logLevel: "error",
105-
},
106-
minify: false,
107-
multipleChunks: false,
124+
function makeWebpackConfig(opts = {}) {
125+
opts = {
126+
...opts,
127+
minify: false,
128+
multipleChunks: false,
129+
analyzerOpts: {
130+
analyzerMode: "static",
131+
openAnalyzer: false,
132+
logLevel: "error",
133+
...(opts.analyzerOpts || {}),
108134
},
109-
opts,
110-
);
135+
};
111136

112137
return {
113138
context: __dirname,

0 commit comments

Comments
 (0)