Skip to content

Commit 53a2a0e

Browse files
committed
feat: bundle package
1 parent 791542b commit 53a2a0e

File tree

6 files changed

+2170
-32
lines changed

6 files changed

+2170
-32
lines changed

.babelrc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"env": {
3+
"test": {
4+
"presets": [
5+
["@babel/preset-env", {
6+
"targets": {
7+
"node": "current"
8+
}
9+
}]
10+
]
11+
}
12+
}
13+
}

package.json

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,35 @@
22
"name": "hable",
33
"version": "2.3.0",
44
"description": "Awaitable hooks for Node.js",
5+
"keywords": [
6+
"hook",
7+
"hookable",
8+
"plugin",
9+
"tapable",
10+
"tappable"
11+
],
12+
"repository": "jsless/hable",
513
"license": "MIT",
614
"contributors": [
715
"Sebastien Chopin (@Atinux)",
816
"Clark Du (@clarkdo)",
917
"Pooya Parsa (@pi0)"
1018
],
11-
"repository": "jsless/hable",
12-
"keywords": [
13-
"tapable",
14-
"tappable",
15-
"hook",
16-
"plugin",
17-
"hookable"
18-
],
19-
"main": "lib/hookable.js",
2019
"files": [
21-
"lib"
20+
"src",
21+
"dist"
2222
],
23+
"main": "dist/hable.js",
24+
"browser": "dist/hable.umd.js",
2325
"scripts": {
24-
"test": "yarn lint && yarn jest",
25-
"lint": "eslint lib",
26-
"prepublish": "yarn test",
27-
"release": "standard-version && git push --follow-tags && npm publish"
26+
"build": "bili --module-name hable --minify --format cjs,umd,es src/hable.js",
27+
"lint": "eslint src",
28+
"prepublish": "yarn build && yarn test",
29+
"release": "standard-version && git push --follow-tags && npm publish",
30+
"test": "yarn lint && yarn jest"
2831
},
2932
"devDependencies": {
33+
"bili": "^4.8.1",
3034
"codecov": "^3.0.0",
3135
"eslint": "^5.13.0",
3236
"eslint-config-standard": "^12.0.0",

lib/hookable.js renamed to src/hable.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
const { serial, flatHooks } = require('./utils')
1+
import { serial, flatHooks } from './utils'
22

3-
module.exports = class Hookable {
3+
export default class Hookable {
44
constructor (logger = console) {
55
this._logger = logger
66
this._hooks = {}

lib/utils.js renamed to src/utils.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
exports.flatHooks = function flatHooks (configHooks, hooks = {}, parentName) {
1+
export function flatHooks (configHooks, hooks = {}, parentName) {
22
for (const key in configHooks) {
33
const subHook = configHooks[key]
44
const name = parentName ? `${parentName}:${key}` : key
@@ -11,6 +11,6 @@ exports.flatHooks = function flatHooks (configHooks, hooks = {}, parentName) {
1111
return hooks
1212
}
1313

14-
exports.serial = function serial (tasks, fn) {
14+
export function serial (tasks, fn) {
1515
return tasks.reduce((promise, task) => promise.then(previous => fn(task, previous)), Promise.resolve(null))
1616
}

test/hookable.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const Hookable = require('..')
2-
const { flatHooks } = require('../lib/utils')
2+
const { flatHooks } = require('../src/utils')
33

44
describe('core: hookable', () => {
55
beforeEach(() => {

0 commit comments

Comments
 (0)