I have a simple JS file that runs parcel bundler:
const Bundler = require('parcel-bundler');
(async () => {
const bundler = new Bundler('./src/index.html', {}); // options omitted for simplicity
await bundler.bundle();
})();
I run it from CLI with:
node ./build.js
While bundler works fine and creates bundled files in the dist
folder, the process never exits, but rather remains in the async loop.
I tried adding then
callback or using return but none of it helped.
Using process.exit()
would of course stop the process but would also limit me from chaining this command in the CI, which is the whole purpose.
What am I doing wrong?
You need to set watch: false
in your options to let Parcel know it should not watch but just build it once.
The default option is watch: true
, so whenever you change something in your files, Parcel will recognize the change and rebuild your application.