# brfs-babel

> like brfs, but built on top of babel for es2015

Latest version **2.0.0** (published 2019-07-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install brfs-babel
pnpm add brfs-babel
yarn add brfs-babel
bun add brfs-babel
```

## 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 | 2.0.0 |
| Published | 2019-07-20 |
| First published | 2016-01-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 4.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 18 |
| Author | Matt DesLauriers |
| Maintainers | mattdesl |
| Keywords | babel, brfs, es2015, commonjs, es6, babelify, browserify, bundle, static, file, inline, text |

## Links

- npm: https://www.npmjs.com/package/brfs-babel
- Repository: https://github.com/Jam3/brfs-babel
- Issues: https://github.com/Jam3/brfs-babel/issues
- npm.io page: https://npm.io/package/brfs-babel

## Dependencies (3)

- [through2](https://npm.io/package/through2.md) ^2.0.0
- [@babel/core](https://npm.io/package/@babel/core.md) ^7.5.5
- [babel-plugin-static-fs](https://npm.io/package/babel-plugin-static-fs.md) ^2.0.1

## Alternatives

- [unionfs](https://npm.io/package/unionfs.md) — 2.2M weekly downloads
- [path-starts-with](https://npm.io/package/path-starts-with.md) — 35.9K weekly downloads
- [redzip](https://npm.io/package/redzip.md) — 1.2K weekly downloads
- [vscode-anymatch](https://npm.io/package/vscode-anymatch.md) — 848 weekly downloads
- [@ledgerhq/coin-filecoin](https://npm.io/package/@ledgerhq/coin-filecoin.md) — 793 weekly downloads

## Recent versions

- 2.0.0 (latest) — 2019-07-20
- 1.0.0 — 2016-01-21

## README

# brfs-babel

[![experimental](http://badges.github.io/stability-badges/dist/experimental.svg)](http://github.com/badges/stability-badges)

This is like [brfs](http://npmjs.com/package/brfs), a browserify transform to inline static files, but built on top of Babel and its AST manipulations. This provides some new features, like ES2015 import support, various additional edge cases, cleaner code output, and source maps.

However, since this is a re-write and work in progress, this has [some limitations](#limitations) and currently only supports `fs.readFileSync` and `fs.readdirSync`.

## Install

```sh
npm install brfs-babel --save
```

## Usage

Once installed, you can use it as a replacement for `brfs` transform:

```sh
browserify index.js -t brfs-babel
```

It will handle ES2015 syntax, so it can be ordered before or after `babelify`. Or, you can choose to avoid `babelify` altogether, e.g. if you are targeting a new version of Node/Chrome/FF.

```js
import { readFileSync } from 'fs';
import { join } from 'path';
const src = readFileSync(join(__dirname, 'hello.txt'), 'utf8');
```

And `hello.txt` is a text file containing the string `"Hello, world!"`.

After transformation:

```js
import { join } from 'path';
const src = 'Hello, World!';
```

## Limitations

The following `fs` functions are supported:

- `fs.readFileSync(filepath, [enc])`
- `fs.readdirSync(filepath)`

The following `path` functions will be evaluated statically when they are found inside the arguments of the above calls:

- `path.join()`
- `path.resolve()`

Some test cases are failing from `brfs`. This includes dynamic variables like this:

```js
const path = '/foo.txt';
fs.readFileSync(__dirname + path, 'utf8');
```

As well as inline CommonJS usage, like this:

```js
require('fs').readFileSync(__dirname + '/foo.txt', 'utf8');
```

## License

MIT, see [LICENSE.md](http://github.com/Jam3/brfs-babel/blob/master/LICENSE.md) for details.

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