Skip to content

Commit

Permalink
[micropack] 💄 Formating
Browse files Browse the repository at this point in the history
  • Loading branch information
smialy committed Feb 23, 2024
1 parent 497c491 commit d195b6f
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 17 deletions.
4 changes: 2 additions & 2 deletions packages/micropack/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@stool/micropack",
"version": "0.7.1",
"version": "0.8.1",
"description": "Simple bundler for tiny modules powered by rollup",
"type": "module",
"bin": {
Expand All @@ -14,7 +14,7 @@
"scripts": {
"format": "prettier --write ./src",
"lint": "eslint src/**/*.mjs",
"test": "mocha"
"test": "mocha --timeout 10000"
},
"repository": {
"type": "git",
Expand Down
12 changes: 5 additions & 7 deletions packages/micropack/src/cli.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ program
.option(
'-c, --config-file <config>',
'Add custom config file',
DEFAULT_OPTIONS.configFile
DEFAULT_OPTIONS.configFile,
)
.option('-f, --format <format>', 'Build only in specified format (es, cjs)')
.option('-w, --watch', 'Rebuild on change', DEFAULT_OPTIONS.watch)
Expand All @@ -28,30 +28,29 @@ program
.option(
'--dev',
'Developer mode (use quick SWC compiler)',
DEFAULT_OPTIONS.dev
DEFAULT_OPTIONS.dev,
)
.option(
'--no-modern',
'Specify your target environment (modern or old)',
DEFAULT_OPTIONS.modern
DEFAULT_OPTIONS.modern,
)
.option('--no-sourcemap', 'Generate sourcemap')
.option(
'-v, --verbose',
'verbosity that can be increased',
increaseVerbose,
0
0,
)
.option('--jsx <name>', 'JSX Runtime')
.option('--compress', 'Enable output compressing', DEFAULT_OPTIONS.compress)
.option(
'--css-module',
'Files .css will be parsed as modules (default: null)',
DEFAULT_OPTIONS.cssModule
DEFAULT_OPTIONS.cssModule,
)
.option('--no-timestamp', 'Add timestamp to beging of file', true)
.action(async (opts) => {
console.log(opts)
try {
await micropack(opts);
} catch (e) {
Expand All @@ -70,7 +69,6 @@ program.on('--help', function () {

export function run(argv) {
setupExceptionHandler();
console.log(argv)
program.parse(argv);
}
run(process.argv);
5 changes: 3 additions & 2 deletions packages/micropack/src/micropack.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class Tasks {
constructor(options) {
this.options = options;
this.tasks = options.entries.map(
({ input, outputs }) => new RollupTask(options, input, outputs)
({ input, outputs }) => new RollupTask(options, input, outputs),
);
}
async build() {
Expand Down Expand Up @@ -189,7 +189,8 @@ function* findExportsEntries(exports) {
if (input) {
const outputs = names
.filter(
(name) => exports[name] && typeof exports[name] === 'string'
(name) =>
exports[name] && typeof exports[name] === 'string',
)
.map((name) => exports[name]);
if (outputs.length) {
Expand Down
8 changes: 4 additions & 4 deletions packages/micropack/src/rollup.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export class RollupTask {
return !include.some((name) => {
if (name.endsWith('/*')) {
return id.startsWith(
name.substring(0, name.length - 2)
name.substring(0, name.length - 2),
);
}
return name === id;
Expand Down Expand Up @@ -127,8 +127,8 @@ export class RollupTask {
format: format
? format
: Path.extname(file) === '.mjs'
? 'es'
: 'cjs',
? 'es'
: 'cjs',
banner() {
if (cli) {
return '#!/usr/bin/env node\n';
Expand Down Expand Up @@ -177,7 +177,7 @@ export class RollupTask {
console.warn(e.error);
} else if (e.code === 'BUNDLE_END') {
const files = e.output.map((file) =>
Path.relative(cwd, file)
Path.relative(cwd, file),
);
listener('end', files);
}
Expand Down
4 changes: 2 additions & 2 deletions packages/micropack/src/utils/cmd.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const collectDict = (vals, acc) => ({
return acc;
}, {}),
});
export const collectList = (vals, acc=[]) => {
export const collectList = (vals, acc = []) => {
return [...acc, ...vals.split(',')];
}
};
export const increaseVerbose = (_, acc) => (acc += 1);

0 comments on commit d195b6f

Please sign in to comment.