swc-project / pkgs

node.js packages for SWC
49 stars 15 forks source link

Add callback functions to CLI #55

Closed lake2 closed 1 week ago

lake2 commented 1 week ago

I want to integrate @swc/cli in my project as follows:

    const swc: any = require('@swc/cli/lib/swc/dir').default;

    const swcOptions: Config = {
        jsc: {
            target: 'esnext',
            externalHelpers: true,
        },
        module: {
            type: 'commonjs',
        },
    };

    swc({
        cliOptions: {
            outDir: './dist2',
            watch: true,
            filenames: ['./src'],
            extensions: ['.ts'],
            onSuccess: () => {
                // restart an express project
                // run  typescript type check
            },
            onFail: () => {
                // log reason
            },
        },
        swcOptions,
    });

But now onSuccess and onFail callbacks are missing. Is this reasonable? I will make a pr if this is possible.

kdy1 commented 1 week ago

Yeah, I think it's acceptable