Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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: 22 days 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 (over 7 years ago)
- Default Branch: master
- Last Pushed: 2023-03-06T08:02:28.000Z (over 1 year ago)
- Last Synced: 2024-10-02T15:38:10.721Z (about 1 month ago)
- Topics: babel, babel-plugin, tree-shaking
- Language: TypeScript
- Homepage:
- Size: 259 KB
- Stars: 21
- Watchers: 3
- Forks: 2
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## babel-plugin-pure-calls-annotation
[![test](https://img.shields.io/github/workflow/status/morlay/babel-plugin-pure-calls-annotation/test?style=flat-square)](https://github.com/morlay/babel-plugin-pure-calls-annotation/actions/workflows/test.yml)
[![codecov](https://img.shields.io/codecov/c/github/morlay/babel-plugin-pure-calls-annotation?style=flat-square)](https://codecov.io/gh/morlay/babel-plugin-pure-calls-annotation)
[![npm](https://img.shields.io/npm/v/babel-plugin-pure-calls-annotation?style=flat-square)](https://npmjs.org/package/babel-plugin-pure-calls-annotation)
[![dep](https://img.shields.io/librariesio/release/npm/babel-plugin-pure-calls-annotation?style=flat-square)](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 shakingWill 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)
```