oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
73.01k stars 2.66k forks source link

--sourcemap external doesn't work without = (--sourcemap=external)? #12779

Open huseeiin opened 1 month ago

huseeiin commented 1 month ago

What version of Bun is running?

1.1.20+ae1948925

What platform is your computer?

Linux 6.5.0-18-generic x86_64 x86_64

What steps can reproduce the bug?

this doesn't work:

bun build test.js --target bun --outdir dist --sourcemap external

but this works:

bun build test.js --target bun --outdir dist --sourcemap=external

What is the expected behavior?

both should work

What do you see instead?

error: ModuleNotFound resolving "external" (entry point)

Additional information

No response

ippsav commented 1 month ago

The issue is not coming from bun, it's an issue of one of the dependencies that are responsible of cli argument parsing (clap)

clap.parseParam("--sourcemap <STR>?                Build with sourcemaps - 'inline', 'external', or 'none'") catch unreachable,

the ? is what's making it behave like that

Jarred-Sumner commented 1 month ago

Note that we have forked clap and have made many changes to it, I would consider this a bug in bun

ippsav commented 1 month ago

@Jarred-Sumner will take a look and fix it

ippsav commented 1 month ago

@Jarred-Sumner after looking at the issue closely, I think using = should be mandatory for flags that takes an optional value to differentiate between actually passing a value to the flag or just using the default value of the flag for certain situations like the following:

Optional case with no value:

bun-debug --inspect main.ts

In this case it knows that --inspect will get whatever the default value for the flag is, and not use main.ts as a value to --inspect

Optional case with value:

bun-debug --inspect=ws://localhost:6499/foo/bar main.ts

In this case it knows that --inspect expects a value and not use the default one because of =