Skip to content

Commit e5ba931

Browse files
committed
add note on gotchas to avoid common confusions with static stuff; also add note on brfs-babel for es2015 features
1 parent 7e55a89 commit e5ba931

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

readme.markdown

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,24 @@ npm install brfs
163163
then use `-t brfs` with the browserify command or use `.transform('brfs')` from
164164
the browserify api.
165165

166+
# gotchas
167+
168+
Since `brfs` evaluates your source code *statically*, you can't use dynamic expressions that need to be evaluated at run time. For example:
169+
170+
```js
171+
// WILL NOT WORK!
172+
var file = window.someFilePath;
173+
var str = require('fs').readFileSync(file, 'utf8');
174+
```
175+
176+
Instead, you must use simpler expressions that can be resolved at build-time:
177+
178+
```js
179+
var str = require('fs').readFileSync(__dirname + '/file.txt', 'utf8');
180+
```
181+
182+
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.
183+
166184
# license
167185

168186
MIT

0 commit comments

Comments
 (0)