https://github.com/morlay/babel-plugin-pure-calls-annotation
https://github.com/morlay/babel-plugin-pure-calls-annotation
babel babel-plugin tree-shaking
Last synced: 10 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/morlay/babel-plugin-pure-calls-annotation
- Owner: morlay
- License: wtfpl
- Created: 2017-08-03T13:32:15.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2023-03-06T08:02:28.000Z (over 3 years ago)
- Last Synced: 2025-08-09T02:02:05.870Z (10 months ago)
- Topics: babel, babel-plugin, tree-shaking
- Language: TypeScript
- Homepage:
- Size: 259 KB
- Stars: 20
- Watchers: 2
- Forks: 2
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## babel-plugin-pure-calls-annotation
[](https://github.com/morlay/babel-plugin-pure-calls-annotation/actions/workflows/test.yml)
[](https://codecov.io/gh/morlay/babel-plugin-pure-calls-annotation)
[](https://npmjs.org/package/babel-plugin-pure-calls-annotation)
[](https://libraries.io/github/morlay/babel-plugin-pure-calls-annotation)
Automated annotate **`/*#__PURE__*/`** to call expression which in **variable declarator**,
**assignment expression**, **arguments of call expression** and other expressions as values
### Purpose
help to annotate **`/*#__PURE__*/`** to drop dead code in [Webpack](https://github.com/webpack/webpack)
for uglyfiy and tree shaking
Will transform
```typescript
export const call = (s) => {
return "call" + s
}
export const stringA = call("a")
export const stringB = (() => call("b"))()
```
to
```typescript
export const call = (s) => {
return "call" + s
}
export const stringA = /*#__PURE__*/call("a")
export const stringB = /*#__PURE__*/(() => call("b"))()
```
Notice:
code like below will not be pure call
```typescript
const a = setInterval(() => {
console.log(a)
}, 1000)
```