-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Open
Labels
Description
What version of Bun is running?
1.3.3+274e01c73
What platform is your computer?
Linux
What steps can reproduce the bug?
Can be reproduced with:
echo -e "export function hello(name: string): void {\n\tconsole.log(\`Hello \${name}\`);\n}" > index.ts;
bun build index.ts --minify --keep-names;
bun build index.ts --minify;Output:
function l(o){console.log(`Hello ${o}`)}export{l as hello};
function l(o){console.log(`Hello ${o}`)}export{l as hello};I would expect --keep-names to have an effect, like preserving names internally:
function hello(o){console.log(`Hello ${o}`)}export{hello};
function l(o){console.log(`Hello ${o}`)}export{l as hello};The following demonstrates the "effect" --keep-names has, but not the intended effect anyone desires.
echo -e "function testFuncNames() {\n\tconst myFunc = function OriginalName() {};\n\tconsole.log(myFunc.name);\n}\n\nexport function entry() {\n\ttestFuncNames();\n}" > index.ts;
bun build index.ts --minify --keep-names;
bun build index.ts --minify;output
function n(){console.log(function o(){}.name)}function t(){n()}export{t as entry};
function n(){console.log(function(){}.name)}function t(){n()}export{t as entry};I would expect the following
function testFuncNames(){console.log(function OriginalName(){}.name)}function entry(){testFuncNames()}export{entry};
function n(){console.log(function(){}.name)}function t(){n()}export{t as entry};This is also more in line with the description of the flag - "Preserve original function and class names when minifying".