Open kravetsone opened 3 months ago
We should replace zx
with something else
because it used only for non first-class feature
import envPaths from 'env-paths';
import { mkdirSync } from 'fs';
import { access, readFile } from 'fs/promises';
import { join } from 'path';
import { $ } from 'zx';
const p = envPaths('drizzle-studio', {
suffix: '',
});
$.verbose = false;
$.cwd = p.data;
mkdirSync(p.data, { recursive: true });
export const certs = async () => {
const res = await $`mkcert --help`.nothrow();
// ~/.local/share/drizzle-studio
const keyPath = join(p.data, 'localhost-key.pem');
const certPath = join(p.data, 'localhost.pem');
if (res.exitCode === 0) {
try {
await Promise.all([access(keyPath), access(certPath)]);
} catch (e) {
await $`mkcert localhost`.nothrow();
}
const [key, cert] = await Promise.all([
readFile(keyPath, { encoding: 'utf-8' }),
readFile(certPath, { encoding: 'utf-8' }),
]);
return key && cert ? { key, cert } : null;
}
return null;
};
certs();
https://bundlephobia.com/package/zx@8.1.4
https://npmgraph.js.org/?q=zx#deps=devDependencies
A lot of dependencies in bundle come from it
zx 7.2.2 └── yaml 2.4.2
zx 7.2.2 └─┬ node-fetch 3.3.1 ├─┬ fetch-blob 3.2.0 │ └── web-streams-polyfill 3.2.1 └─┬ formdata-polyfill 4.0.10 └─┬ fetch-blob 3.2.0 └── web-streams-polyfill 3.2.1
But node-fetch
also depends on it
zx 7.2.2 └─┬ globby 13.2.2 └── fast-glob 3.3.2
So we have two glob packages
And etc
https://npmgraph.js.org/?q=drizzle-kit#zoom=h&deps=devDependencies
for now unpacked size is too much - 8.41 MB
By reducing dependencies and their weight, we will put ourselves on the path to the future of JS, as well as increase the performance of the CLI
Continuation of this issue https://github.com/drizzle-team/drizzle-kit-mirror/issues/485
bin.cjs
size analyzeHow to use metafile and analyze
Optimization list