gajus / turbowatch

Extremely fast file change detector and task orchestrator for Node.js.
Other
938 stars 23 forks source link

Allow turbowatch to load its configuration from a package #51

Open AlexAegis opened 1 year ago

AlexAegis commented 1 year ago

Desired Behavior

turbowatch @myorg/turbowatch-config

It would be nice to just tell turbowatch to expect the default export of a package to be a config, or a function returning a promise of a config, and use that.

Motivation

I managed to make a pretty cool config that I'm gonna take with me with every single project I have.

That means I will have the same file in all of them:

import { turbowatchLocalNodeModules } from '@alexaegis/turbowatch';
import { watch } from 'turbowatch';

void (async () => {
    await watch(
        await turbowatchLocalNodeModules({
            buildDependenciesScript: 'build:dependencies',
            devScript: 'dev_',
        }),
    );
})();

Had to use an IIFE because top level awaits don't work currently with turbowatch

It would nice to not have to copy the same thing everywhere and just have the package installed.

This could be blocked by https://github.com/gajus/turbowatch/issues/16 if I can't import anything from turbowatch, or could be worked around if you export just the type of the configuration. (Currently I have extract it like this Parameters<typeof import('turbowatch').watch>[0])

This is really is just a nice-to-have, especially for me because I already have another project that automatically copies this file everywhere it's used.