# gulp-transform-js-ast

> Gulp plugin to transform a javascript AST using recast visitors

Latest version **1.0.2** (published 2014-11-30) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install gulp-transform-js-ast
pnpm add gulp-transform-js-ast
yarn add gulp-transform-js-ast
bun add gulp-transform-js-ast
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2014-11-30 |
| First published | 2014-11-29 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 7 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Nicholas Daley |
| Maintainers | ntdaley |
| Keywords | gulp, plugin, recast, ast, visitor, visit, transform, javascript, js |

## Links

- npm: https://www.npmjs.com/package/gulp-transform-js-ast
- Repository: https://github.com/ntdaley/gulp-transform-js-ast
- Issues: https://github.com/ntdaley/gulp-transform-js-ast/issues
- npm.io page: https://npm.io/package/gulp-transform-js-ast

## Dependencies (7)

- [recast](https://npm.io/package/recast.md) ^0.9.6
- [through2](https://npm.io/package/through2.md) ^0.6.3
- [ast-types](https://npm.io/package/ast-types.md) ^0.6.6
- [gulp-util](https://npm.io/package/gulp-util.md) ^3.0.1
- [convert-source-map](https://npm.io/package/convert-source-map.md) ^0.4.1
- [multi-stage-sourcemap](https://npm.io/package/multi-stage-sourcemap.md) ^0.2.1
- [vinyl-sourcemaps-apply](https://npm.io/package/vinyl-sourcemaps-apply.md) ^0.1.4

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 1.0.2 (latest) — 2014-11-30
- 1.0.1 — 2014-11-29
- 1.0.0 — 2014-11-29

## README

gulp-transform-js-ast
=====================
Gulp plugin to transform javascript files by modifying AST nodes with a visitor

Makes use of [recast](https://www.npmjs.org/package/recast) to parse the javascript into an AST, to run a visitor over the AST to modify nodes, and serialise it back to text.

Install
=======
```npm install --save gulp-transform-js-ast```

Usage
=====
```
var transform = require('gulp-transform-js-ast');
gulp.task('strip-console', function() {
    return gulp.src(['./example.js'])
        .pipe(transform({
            //visit functions as used by recast.visit()
            visitCallExpression : function(path) {
                if( shouldRemove(path) ) {
                    //replace with a (void 0) expression.
                    return transform.voidExpression;
                } else {
                    //don't change it.
                    return path.value;
                }
            }
        }))
        .pipe(gulp.dest('build'));
});
```
or with creation of a sourcemap:
```
var transform = require('gulp-transform-js-ast');
var sourcemaps = require('gulp-sourcemaps');
gulp.task('strip-console', function() {
    return gulp.src(['./example.js'])
        .pipe(sourcemaps.init())
        .pipe(transform({
            //visit functions as used by recast.visit()
            visitCallExpression : function(path) {
                if( shouldRemove(path) ) {
                    //replace with a (void 0) expression.
                    return transform.voidExpression();
                } else {
                    //don't change it.
                    return path.value;
                }
            }
        }))
        .pipe(sourcemaps.write('.'))
        .pipe(gulp.dest('build'));
});
```

License
=======
Apache 2.0 License
&copy; Nicholas Daley

---
_Source: https://npm.io/package/gulp-transform-js-ast · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
