Suboptimal treeshaking on pure function calls
- Dominant language
- Go
- Stars
- 40.1k
- Forks
- 1.3k
- PR merge metrics
- No merged PRs in 30d
Description
It doesn't seem like esbuild is removing these pure function calls
```js
import { html, clone, first_child, append, define } from "@intrnl/velvet/internal";
let template0 = /*#__PURE__*/ html("
function setup($$root, $$host) {
let fragment0 = /*#__PURE__*/ clone(template0);
// these are deliberately commented out, though they are relevant
// let child0 = /*#__PURE__*/ first_child(fragment0);
// let child1 = /*#__PURE__*/ first_child(child0);
// append($$root, fragment0);
}
export default define("x-app", setup, {}, []);
```
Does it matter if the REPL has said import externalized?
[REPL link](https://esbuild.github.io/try/#YgAwLjE4LjE0AC0tYnVuZGxlIC0tbWluaWZ5IC0tZm9ybWF0PWVzbSAtLWV4dGVybmFsOkBpbnRybmwvdmVsdmV0L2ludGVybmFsAGUAZW50cnkuanMAaW1wb3J0IHsgaHRtbCwgY2xvbmUsIGZpcnN0X2NoaWxkLCBhcHBlbmQsIGRlZmluZSB9IGZyb20gIkBpbnRybmwvdmVsdmV0L2ludGVybmFsIjsKbGV0IHRlbXBsYXRlMCA9IC8qI19fUFVSRV9fKi8gaHRtbCgiPGRpdj5oZWxsbzwvZGl2PiIpOwoKZnVuY3Rpb24gc2V0dXAoJCRyb290LCAkJGhvc3QpIHsKCWxldCBmcmFnbWVudDAgPSAvKiNfX1BVUkVfXyovIGNsb25lKHRlbXBsYXRlMCk7CgkvLyBsZXQgY2hpbGQwID0gLyojX19QVVJFX18qLyBmaXJzdF9jaGlsZChmcmFnbWVudDApOwoJLy8gbGV0IGNoaWxkMSA9IC8qI19fUFVSRV9fKi8gZmlyc3RfY2hpbGQoY2hpbGQwKTsKCS8vIGFwcGVuZCgkJHJvb3QsIGZyYWdtZW50MCk7Cn0KCmV4cG9ydCBkZWZhdWx0IGRlZmluZSgieC1hcHAiLCBzZXR1cCwge30sIFtdKTs)
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the linked esbuild REPL reproduction and inspect the generated output for entry.js, comparing the behavior of the annotated pure calls with the commented-out calls. Determine whether the externalized import affects tree shaking; done means the reproducible pure calls are removed when their results are unused.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- build-system, compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100