egoist / tsup

The simplest and fastest way to bundle your TypeScript libraries.
https://tsup.egoist.dev
MIT License
9.01k stars 217 forks source link

add tsup run command? #995

Open i5ting opened 1 year ago

i5ting commented 1 year ago

use tsx

$ tsx --inpect-brk a.ts

may we can add tsup run command

$ tsup run --inpect-brk your.ts

implements from tsx

npm

main file is run.ts

import type { StdioOptions } from 'child_process';
import { pathToFileURL } from 'url';
import spawn from 'cross-spawn';

export function run(
    argv: string[],
    options?: {
        noCache?: boolean;
        tsconfigPath?: string;
        ipc?: boolean;
    },
) {
    const environment = { ...process.env };
    const stdio: StdioOptions = [
        'inherit', // stdin
        'inherit', // stdout
        'inherit', // stderr
        'ipc', // parent-child communication
    ];

    if (options) {
        if (options.noCache) {
            environment.ESBK_DISABLE_CACHE = '1';
        }

        if (options.tsconfigPath) {
            environment.ESBK_TSCONFIG_PATH = options.tsconfigPath;
        }
    }

    return spawn(
        process.execPath,
        [
            '--require',
            require.resolve('./preflight.cjs'),

            '--loader',
            pathToFileURL(require.resolve('./loader.js')).toString(),

            ...argv,
        ],
        {
            stdio,
            env: environment,
        },
    );
}

Upvote & Fund

Fund with Polar

i5ting commented 1 year ago

we don't need tsup && tsx, example https://github.com/sxzz/monorepo-starter/blob/main/package.json

yairopro commented 9 months ago

tsup-node ? https://tsup.egoist.dev/#excluding-all-packages

joealden commented 9 months ago

@yairopro you can see here that this command does what is says in the docs (it doesn't execute the built file):

https://github.com/egoist/tsup/blob/8c26e63c92711d60c05aedd3cdc358530ba266c5/src/cli-node.ts#L1-L7