从命令行运行parcel bundler 不会停止进程

Mir*_*nas 2 javascript bundler node.js async-await parceljs

我有一个运行包裹打包器的简单 JS 文件:

const Bundler = require('parcel-bundler');
(async () => {
  const bundler = new Bundler('./src/index.html', {}); // options omitted for simplicity
  await bundler.bundle();
})();

Run Code Online (Sandbox Code Playgroud)

我从 CLI 运行它:

node ./build.js
Run Code Online (Sandbox Code Playgroud)

虽然 bundler 工作正常并在dist文件夹中创建捆绑文件,但该过程永远不会退出,而是保留在异步循环中。

我尝试添加then回调或使用返回,但没有任何帮助。使用process.exit()当然会停止这个过程,但也会限制我在 CI 中链接这个命令,这是整个目的。

我究竟做错了什么?

Nar*_*igo 6

您需要watch: false在您的选项中进行设置,让 Parcel 知道它不应该监视而只构建一次。

默认选项是watch: true,因此每当您更改文件中的某些内容时,Parcel 都会识别更改并重建您的应用程序。