https://github.com/yjhmelody/as-debug-transform
A debug decorator for AssemblyScript
https://github.com/yjhmelody/as-debug-transform
assemblyscript debug transform
Last synced: 5 days ago
JSON representation
A debug decorator for AssemblyScript
- Host: GitHub
- URL: https://github.com/yjhmelody/as-debug-transform
- Owner: yjhmelody
- License: mit
- Created: 2021-07-12T08:16:19.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2024-05-16T16:28:52.000Z (about 1 year ago)
- Last Synced: 2025-04-08T07:59:13.276Z (2 months ago)
- Topics: assemblyscript, debug, transform
- Language: JavaScript
- Homepage:
- Size: 262 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# as-debug-transform

> A simple conditional compilation library for testing or debugging.
## Usage
### install
```sh
npm install --save-dev as-debug-transform
```Update your asconfig to include the transform:
```json
{
"options": {
... // other options here
"transform": ["as-debug-transform"]
}
}
```### Syntax
`@debugMode` decorator is used to decorate functions/methods/static methods. Its usage is as simple as `@inline/@global`.
When a function is decorated, its body will be erased if you want to compile production code.You can use it in the following ways:
- Not set the env variable `DEBUG_MODE`. Transform will always erase function bodies.
- Set the env variable `DEBUG_MODE` to `false` or `0`. Transform will always keep function bodies.
- Set the env variable `DEBUG_MODE` to `debug`. Transform will keep function bodies when `optimizeLevel` < 2.### Note
Now, `debugMode` only support `MethodDeclaration` and `FunctionDeclaration`. Maybe support for classes/namespaces/fields and more features may be added in the future, but it is practical enough for now.