这是indexloc提供的服务,不要输入任何密码
Skip to content

add tsup run command? #995

@i5ting

Description

@i5ting

use tsx

$ tsx --inpect-brk a.ts

may we can add tsup run command

$ tsup run --inpect-brk your.ts

implements from tsx

npm

  • cross-spaw
  • @esbuild-kit/cjs-loader
  • @esbuild-kit/esm-loader
  • @esbuild-kit/core-utils

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,
		},
	);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions