esbuild-runner icon indicating copy to clipboard operation
esbuild-runner copied to clipboard

feat: ✨ add `cwd` option

Open jfirebaugh opened this issue 2 years ago • 3 comments

I want to use esbuild-runner in contexts where the current directory is not the directory containing the package.json whose dependencies should be used to chose externals. This makes the location for package.json configurable. It's roughly equivalent to the cwd option from ts-node: https://github.com/TypeStrong/ts-node/blob/abc616ece2a8cdb066439a4e5c6fc7d493aa4612/src/index.ts#L191-L196.

jfirebaugh avatar Feb 16 '22 19:02 jfirebaugh

Why not just make use of process.chdir?

romanlamsal avatar Sep 29 '22 08:09 romanlamsal

It would change the execution environment of the code that the runner is running, which may be expecting the current directory to be the one where the command was executed.

jfirebaugh avatar Sep 30 '22 01:09 jfirebaugh

Yes, but is that not the intention of a --cwd flag? For example, running ts-node --cwd /some/where your-script.ts will try to execute /some/where/your-script.ts. I'm just saying, cwd as flag is confusing if the actual goal is to just tell esbuild-runner to read from another package.json.

romanlamsal avatar Sep 30 '22 10:09 romanlamsal