From c81e4d9d03930f0211e39f65d3bed513dadb2836 Mon Sep 17 00:00:00 2001 From: VladimirTechMan Date: Sat, 20 Aug 2016 00:43:11 -0500 Subject: [PATCH] Updating pegjs-loader to work with pegjs 0.10.0 (allow back compatibility with prior versions) --- package.json | 2 +- src/index.js | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index c321daf..0101fd6 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ }, "homepage": "http://eploko.github.io/pegjs-loader", "peerDependencies": { - "pegjs": "^0.9.0", + "pegjs": "^0.10.0", "webpack": "^1.12.2" }, "dependencies": { diff --git a/src/index.js b/src/index.js index a451ef4..0433977 100644 --- a/src/index.js +++ b/src/index.js @@ -31,5 +31,6 @@ export default function loader(source) { pegOptions.allowedStartRules = allowedStartRules; } - return `module.exports = ${pegjs.buildParser(source, pegOptions)};`; + const methodName = (typeof pegjs.generate === 'function') ? 'generate' : 'buildParser'; + return `module.exports = ${pegjs[methodName](source, pegOptions)};`; }