Skip to content

Commit 582d693

Browse files
authored
chore(deps): remove yargs and use native code via parseArgs() (#1992)
* chore(deps): remove `yargs` and use native code via `parseArgs()`
1 parent 9057e2c commit 582d693

4 files changed

Lines changed: 141 additions & 158 deletions

File tree

packages/vanilla-force-bundle/compress.mjs

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,25 @@
1-
21
import { strToU8, zip } from 'fflate';
32
import { existsSync, mkdirSync, readFileSync, statSync, writeFileSync } from 'node:fs';
3+
import { parseArgs } from 'node:util';
44
import normalizePath from 'normalize-path';
55
import { globSync } from 'tinyglobby';
6-
import { hideBin } from 'yargs/helpers';
7-
import yargs from 'yargs';
86

97
const inputFolder1 = './dist/bundle';
108
const inputFolder2 = '../common/dist/styles';
11-
const argv = yargs(hideBin(process.argv)).argv;
12-
const outputFilename = argv.outputFilename || 'bundle';
13-
const outputFolder = argv.outputFolder || './dist/';
9+
10+
const { values: args } = parseArgs({
11+
options: {
12+
outputFilename: { type: 'string' },
13+
outputFolder: { type: 'string' },
14+
'output-filename': { type: 'string' },
15+
'output-folder': { type: 'string' },
16+
},
17+
allowPositionals: true,
18+
});
19+
20+
// Prefer kebab-case if provided, otherwise camelCase, otherwise default
21+
const outputFilename = args['output-filename'] || args.outputFilename || 'bundle';
22+
const outputFolder = args['output-folder'] || args.outputFolder || './dist/';
1423

1524
if (!existsSync(outputFolder)) {
1625
mkdirSync(outputFolder);
@@ -25,7 +34,7 @@ const files = [
2534

2635
// get all files from `common/dist/styles`
2736
const styleFiles = globSync('../common/dist/styles/**/*.*');
28-
styleFiles.forEach(file => {
37+
styleFiles.forEach((file) => {
2938
const [styleName] = file.match(/(styles.*)/gi) || [];
3039
files.push({ name: normalizePath(styleName), path: normalizePath(file) });
3140
});
Binary file not shown.

packages/vanilla-force-bundle/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@
6565
"fflate": "^0.8.2",
6666
"normalize-path": "^3.0.0",
6767
"tinyglobby": "^0.2.13",
68-
"vite": "catalog:",
69-
"yargs": "^17.7.2"
68+
"vite": "catalog:"
7069
}
7170
}

0 commit comments

Comments
 (0)