Skip to content

Commit 379d628

Browse files
committed
refactor: update repo
1 parent d40b97e commit 379d628

File tree

14 files changed

+3947
-3794
lines changed

14 files changed

+3947
-3794
lines changed

.eslintignore

Lines changed: 0 additions & 3 deletions
This file was deleted.

.eslintrc

Lines changed: 0 additions & 7 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
- run: corepack enable
1717
- uses: actions/setup-node@v4
1818
with:
19-
node-version: 18
19+
node-version: 20
2020
cache: "pnpm"
2121
- run: pnpm install
2222
- run: pnpm lint

README.md

Lines changed: 58 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
[![npm version][npm-version-src]][npm-version-href]
2-
[![npm downloads][npm-downloads-src]][npm-downloads-href]
3-
[![package phobia][package-phobia-src]][package-phobia-href]
4-
[![github actions][checks-src]][checks-href]
1+
<!-- automd:badges packagephobia -->
2+
3+
[![npm version](https://img.shields.io/npm/v/webpackbar)](https://npmjs.com/package/webpackbar)
4+
[![npm downloads](https://img.shields.io/npm/dm/webpackbar)](https://npm.chart.dev/webpackbar)
5+
6+
<!-- /automd -->
57

68
<div align="center">
79
<!-- replace with accurate logo e.g from https://worldvectorlogo.com/ -->
@@ -20,7 +22,7 @@
2022

2123
✔ Windows compatible
2224

23-
**Fully** customizable using reporters
25+
✔ Fully customizable using reporters
2426

2527
✔ Advanced build profiler
2628

@@ -42,35 +44,44 @@
4244

4345
To begin, you'll need to install `webpackbar`:
4446

45-
Using npm:
47+
<!-- automd:pm-i -->
4648

47-
```bash
48-
npm install webpackbar -D
49-
```
49+
```sh
50+
# ✨ Auto-detect
51+
npx nypm install webpackbar
52+
53+
# npm
54+
npm install webpackbar
55+
56+
# yarn
57+
yarn add webpackbar
5058

51-
Using yarn:
59+
# pnpm
60+
pnpm install webpackbar
5261

53-
```bash
54-
yarn add webpackbar -D
62+
# bun
63+
bun install webpackbar
64+
65+
# deno
66+
deno install webpackbar
5567
```
5668

69+
<!-- /automd -->
70+
5771
Then add the reporter as a plugin to your webpack config.
5872

59-
**webpack.config.js**
73+
**webpack.config.mjs**
6074

6175
```js
62-
const webpack = require("webpack");
63-
const WebpackBar = require("webpackbar");
64-
65-
module.exports = {
66-
context: path.resolve(__dirname),
67-
devtool: "source-map",
68-
entry: "./entry.js",
69-
output: {
70-
filename: "./output.js",
71-
path: path.resolve(__dirname),
72-
},
73-
plugins: [new WebpackBar()],
76+
import WebpackBar from "webpackbar";
77+
78+
export default {
79+
entry: "./src/entry.js",
80+
plugins: [
81+
new WebpackBar({
82+
/* options */
83+
}),
84+
],
7485
};
7586
```
7687

@@ -130,30 +141,28 @@ A reporter should be instance of a class or plain object and functions for speci
130141
**Simple logger:**
131142

132143
```js
133-
{
134-
start(context) {
135-
// Called when (re)compile is started
136-
},
137-
change(context) {
138-
// Called when a file changed on watch mode
139-
},
140-
update(context) {
141-
// Called after each progress update
142-
},
143-
done(context) {
144-
// Called when compile finished
145-
},
146-
progress(context) {
147-
// Called when build progress updated
148-
},
149-
allDone(context) {
150-
// Called when _all_ compiles finished
151-
},
152-
beforeAllDone(context) {
153-
},
154-
afterAllDone(context) {
155-
},
156-
}
144+
const logger = {
145+
start(context) {
146+
// Called when (re)compile is started
147+
},
148+
change(context) {
149+
// Called when a file changed on watch mode
150+
},
151+
update(context) {
152+
// Called after each progress update
153+
},
154+
done(context) {
155+
// Called when compile finished
156+
},
157+
progress(context) {
158+
// Called when build progress updated
159+
},
160+
allDone(context) {
161+
// Called when _all_ compiles finished
162+
},
163+
beforeAllDone(context) {},
164+
afterAllDone(context) {},
165+
};
157166
```
158167

159168
`context` is the reference to the plugin. You can use `context.state` to access status.

eslint.config.mjs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import unjs from "eslint-config-unjs";
2+
3+
// https://github.com/unjs/eslint-config
4+
export default unjs({
5+
ignores: ["/node_modules", "**/dist", "test/**/dist"],
6+
rules: {
7+
"unicorn/prevent-abbreviations": 0,
8+
"unicorn/no-null": 0,
9+
"@typescript-eslint/no-require-imports": 0,
10+
},
11+
});

package.json

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
"description": "Elegant ProgressBar and Profiler for Webpack",
55
"repository": "unjs/webpackbar",
66
"license": "MIT",
7-
"main": "./dist/index.cjs",
87
"type": "module",
98
"exports": {
109
"import": {
@@ -16,48 +15,52 @@
1615
"default": "./dist/index.cjs"
1716
}
1817
},
18+
"main": "./dist/index.cjs",
1919
"types": "./dist/index.d.ts",
2020
"files": [
2121
"dist"
2222
],
2323
"scripts": {
2424
"build": "unbuild",
25-
"dev": "webpack --config ./playground/webpack.config.cjs",
26-
"lint": "eslint --ext .ts,.mjs . && prettier -c .",
27-
"lint:fix": "eslint --fix --ext .ts,.mjs . && prettier -w .",
25+
"lint": "eslint . && prettier -c .",
26+
"lint:fix": "eslint --fix . && prettier -w .",
2827
"prepack": "unbuild",
28+
"play": "webpack --config ./playground/webpack.config.mjs",
2929
"release": "pnpm test && changelogen --release && npm publish && git push --follow-tags",
3030
"test": "pnpm lint && mocha ./test/*.test.*"
3131
},
3232
"dependencies": {
33-
"ansi-escapes": "^4.3.2",
34-
"chalk": "^4.1.2",
33+
"ansi-escapes": "^7.0.0",
3534
"consola": "^3.2.3",
36-
"figures": "^3.2.0",
37-
"markdown-table": "^2.0.0",
35+
"figures": "^6.1.0",
36+
"markdown-table": "^3.0.4",
3837
"pretty-time": "^1.1.0",
3938
"std-env": "^3.7.0",
40-
"wrap-ansi": "^7.0.0"
39+
"wrap-ansi": "^9.0.0"
4140
},
4241
"devDependencies": {
43-
"@types/mocha": "^10.0.6",
44-
"@types/node": "^20.11.16",
45-
"changelogen": "^0.5.5",
46-
"eslint": "^8.56.0",
47-
"eslint-config-unjs": "^0.2.1",
48-
"jiti": "^1.21.0",
42+
"@babel/standalone": "^7.26.2",
43+
"@types/mocha": "^10.0.9",
44+
"@types/node": "^22.9.0",
45+
"automd": "^0.3.12",
46+
"chalk": "^5.3.0",
47+
"changelogen": "^0.5.7",
48+
"eslint": "^9.14.0",
49+
"eslint-config-unjs": "^0.4.1",
50+
"jiti": "^2.4.0",
4951
"memory-fs": "^0.5.0",
50-
"mocha": "^10.2.0",
51-
"prettier": "^3.2.5",
52-
"typescript": "^5.3.3",
52+
"mocha": "^10.8.2",
53+
"prettier": "^3.3.3",
54+
"typescript": "^5.6.3",
5355
"unbuild": "^2.0.0",
54-
"webpack": "^5.90.1",
56+
"webpack": "^5.96.1",
5557
"webpack-cli": "^5.1.4"
5658
},
5759
"peerDependencies": {
5860
"webpack": "3 || 4 || 5"
5961
},
62+
"packageManager": "pnpm@9.12.3",
6063
"engines": {
6164
"node": ">=14.21.3"
6265
}
63-
}
66+
}

playground/babel.mjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import babel from "@babel/standalone";
2+
3+
console.log(babel.transform("const a = 1;"));

playground/chalk.mjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import chalk from "chalk";
2+
3+
console.log(chalk.blue("Hello world!"));

playground/index.mjs

Lines changed: 0 additions & 2 deletions
This file was deleted.

playground/webpack.config.cjs renamed to playground/webpack.config.mjs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,24 @@
1-
const path = require("node:path");
2-
const WebpackBar = require("webpackbar");
1+
import { dirname, join } from "node:path";
2+
import { fileURLToPath } from "node:url";
3+
import WebpackBar from "webpackbar";
34

45
// let lastProgress;
56

7+
const __dirname = dirname(fileURLToPath(import.meta.url));
8+
69
const config = (name, color) => ({
710
mode: "production",
811
context: __dirname,
912
devtool: false,
1013
target: "node",
11-
entry: "./index.mjs",
12-
stats: false,
14+
entry: `./${name}.mjs`,
15+
stats: true,
1316
output: {
1417
filename: "./output.cjs",
15-
path: path.join(__dirname, "/dist"),
18+
path: join(__dirname, "/dist"),
1619
},
1720
module: {
18-
rules: [{ test: /\.js$/, use: path.resolve(__dirname, "test-loader.cjs") }],
21+
rules: [{ test: /\.js$/, use: join(__dirname, "test-loader.cjs") }],
1922
},
2023
plugins: [
2124
new WebpackBar({
@@ -35,4 +38,4 @@ const config = (name, color) => ({
3538
],
3639
});
3740

38-
module.exports = [config("OrangeBar", "orange")];
41+
export default [config("chalk", "cyan"), config("babel", "yellow")];

0 commit comments

Comments
 (0)