Skip to content

Commit 6b85561

Browse files
committed
Merge pull request #1 from victor-homyakov/patch-1
Add option to build parser with enabled cache
2 parents cff8863 + c7d0a3c commit 6b85561

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

index.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ var loaderUtils = require('loader-utils');
44
module.exports = function(source) {
55
this.cacheable && this.cacheable();
66
var query = loaderUtils.parseQuery(this.query);
7-
var pegOptions = { output: 'source' };
8-
var parser = 'module.exports = ' + pegjs.buildParser(source, pegOptions) + ';';
9-
this.callback(null, parser, null);
7+
var cacheParserResults = !!query.cache;
8+
// Description of PEG.js options: https://github.com/pegjs/pegjs#javascript-api
9+
var pegOptions = { output: 'source', cache: cacheParserResults };
10+
return 'module.exports = ' + pegjs.buildParser(source, pegOptions) + ';';
1011
};

0 commit comments

Comments
 (0)