Skip to content

Instantly share code, notes, and snippets.

Last active December 5, 2021 22:04
What would you like to do?
DIY file watcher with Parcel
// make sure you have @parcel/core and @parcel/config-default
// installed as devDependencies
import {Parcel} from '@parcel/core';
import {spawn, ChildProcessWithoutNullStreams} from 'child_process';
let bundler = new Parcel({
entries: 'src/index.ts',
defaultConfig: '@parcel/config-default',
defaultTargetOptions: { distDir: `${process.cwd()}/dist` },
async function main() {
let cp: ChildProcessWithoutNullStreams;
await => {
cp = spawn("node",[`${process.cwd()}/dist/index.js`])
cp.stderr.on('data', (data) => {
console.log(`stderr: ${data}`);
cp.stdout.on('data', (data) => {
console.log(`stdout: ${data}`);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment