Skip to content

Commit a21ca81

Browse files
authored
pegjs can return commonjs modules by itself
1 parent 78eb66d commit a21ca81

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,12 @@ export default function loader(source) {
2626
cache: cacheParserResults,
2727
optimize: optimizeParser,
2828
trace: trace,
29+
format: 'commonjs',
2930
};
3031
if (allowedStartRules.length > 0) {
3132
pegOptions.allowedStartRules = allowedStartRules;
3233
}
3334

3435
const methodName = (typeof pegjs.generate === 'function') ? 'generate' : 'buildParser';
35-
return `module.exports = ${pegjs[methodName](source, pegOptions)};`;
36+
return pegjs[methodName](source, pegOptions);
3637
}

0 commit comments

Comments
 (0)