Skip to content

Commit

Permalink
add note on gotchas to avoid common confusions with static stuff; als…
Browse files Browse the repository at this point in the history
…o add note on brfs-babel for es2015 features
  • Loading branch information
mattdesl committed Jan 18, 2016
1 parent 7e55a89 commit e5ba931
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions readme.markdown
Expand Up @@ -163,6 +163,24 @@ npm install brfs
then use `-t brfs` with the browserify command or use `.transform('brfs')` from
the browserify api.

# gotchas

Since `brfs` evaluates your source code *statically*, you can't use dynamic expressions that need to be evaluated at run time. For example:

```js
// WILL NOT WORK!
var file = window.someFilePath;
var str = require('fs').readFileSync(file, 'utf8');
```

Instead, you must use simpler expressions that can be resolved at build-time:

```js
var str = require('fs').readFileSync(__dirname + '/file.txt', 'utf8');
```

Another gotcha: `brfs` does not yet support ES2015 syntax like destructuring or `import` statements. See [brfs-babel](https://github.com/Jam3/brfs-babel) for an experimental replacement that supports this syntax.

# license

MIT

0 comments on commit e5ba931

Please sign in to comment.