8000 Use esbuild · NodeGo/unifiedjs.github.io@3190976 · GitHub
[go: up one dir, main page]

Skip to content 8000

Commit 3190976

Browse files
committed
Use esbuild
1 parent b12a7ee commit 3190976

File tree

2 files changed

+16
-13
lines changed

2 files changed

+16
-13
lines changed

generate/asset.js

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ var mkdirp = require('vfile-mkdirp')
88
var trough = require('trough')
99
var vfile = require('to-vfile')
1010
var reporter = require('vfile-reporter')
11-
var browserify = require('browserify')
11+
var esbuild = require('esbuild')
1212
var postcss = require('postcss')
1313
var postcssPresetEnv = require('postcss-preset-env')
1414
var cssnano = require('cssnano')
@@ -98,7 +98,6 @@ function copy(file, next) {
9898

9999
function print(file) {
100100
file.stored = true
101-
102101
// Clear memory.
103102
file.contents = null
104103
console.error(reporter(file))
@@ -113,15 +112,20 @@ function transformCss(file) {
113112
}
114113

115114
function bundleJs(file, next) {
116-
browserify(file.path).plugin('tinyify').bundle(done)
117-
118-
function done(error, buf) {
119-
if (buf) {
120-
file.contents = String(buf)
121-
}
122-
123-
next(error)
124-
}
115+
esbuild
116+
.build({
117+
entryPoints: [file.path],
118+
bundle: true,
119+
minify: true,
120+
write: false
121+
})
122+
.then(function (result) {
123+
if (result.errors.length > 0) throw new Error('esbuild errors')
124+
if (result.warnings.length > 0) throw new Error('esbuild warnings')
125+
const output = result.outputFiles[0]
126+
file.contents = output.contents
127+
next()
128+
}, next)
125129
}
126130

127131
function transformPng(file, next) {

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
"Merlijn Vos <merlijn@soverin.net>"
1616
],
1717
"devDependencies": {
18-
"browserify": "^17.0.0",
1918
"budo": "^11.0.0",
2019
"bytes": "^3.0.0",
2120
"chalk": "^4.0.0",
@@ -26,6 +25,7 @@
2625
"deepmerge": "^4.0.0",
2726
"dictionary-en": "^3.0.0",
2827
"dotenv": "^10.0.0",
28+
"esbuild": "^0.12.0",
2929
"flexsearch": "^0.7.0",
3030
"glob": "^7.0.0",
3131
"hast-util-find-and-replace": "^3.0.0",
@@ -88,7 +88,6 @@
8888
"stylelint": "^13.0.0",
8989
"stylelint-config-prettier": "^8.0.0",
9090
"stylelint-config-standard": "^22.0.0",
91-
"tinyify": "^3.0.0",
9291
"to-vfile": "^6.0.0",
9392
"trough": "^1.0.0",
9493
"unified": "^9.0.0",

0 commit comments

Comments
 (0)
0