diff --git a/package.json b/package.json index 4d8e488..1bb984a 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ }, "dependencies": { "create-serve": "^1.0.1", - "esbuild": "^0.9.0" + "esbuild": "^0.14.49" }, "devDependencies": { "prettier": "^2.2.1" diff --git a/src/index.js b/src/index.js index f7ce1c7..f3ad297 100644 --- a/src/index.js +++ b/src/index.js @@ -1,24 +1,24 @@ -import esbuild from 'esbuild'; +import { build } from 'esbuild'; import serve, { error, log } from 'create-serve'; export const isWatch = process.argv.includes('-w'); const esbuildServe = async (options = {}, serveOptions = {}) => { - esbuild - .build({ - ...options, - watch: isWatch && { - onRebuild(err) { - serve.update(); - err ? error('× Failed') : log('✓ Updated'); - } + build({ + ...options, + watch: isWatch && { + onRebuild(err) { + serve.update(); + err ? error('× Failed') : log('✓ Updated'); } + } + }) + .then(() => { + if (isWatch) { + serve.start(serveOptions) + } }) .catch(() => process.exit(1)); - - if (isWatch) { - serve.start(serveOptions); - } }; export default esbuildServe;