Confused by __PURE__ behavior
- Dominant language
- Go
- Stars
- 40.1k
- Forks
- 1.3k
- PR merge metrics
- No merged PRs in 30d
Description
I'm using `@__PURE__` comments with and I'm getting some weird behavior, almost like ESBuild only applies one pass of tree shaking when I use `--minify --tree-shaking`.
If I have this code:
```js
import { Server } from "./server/index.js";
import { manifest } from "./server/manifest.js";
const server = /* @__PURE__ */ new Server(manifest);
/* @__PURE__ */ server.init({
env: process.env
});
```
Even though the equivalent of `server.init` isn't emitted, `server` is, in the form of `const n=new e(r);`.
I know that ESBuild understands that `server` is pure because if I remove the `server.init` call all traces of `server` are gone... wait, except for its imports?! A very similar thing happens again, where even though the equivalent of `server` has vanished from the bundle, you have to fully remove `server` from the input to turn `import{manifest as o}from"./server/manifest.js";` into `import"./server/manifest.js";` in the output.
Apologies if this is a duplicate issue, but I couldn't find anything similar with my keyword searching.
Workaround: you can use minify-syntax instead of minify and then run it as many times as needed.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.