Skip to content

Commit 8fff15a

Browse files
committed
Merge branch 'release/0.5.2'
2 parents 78eb66d + 2887712 commit 8fff15a

File tree

3 files changed

+67
-60
lines changed

3 files changed

+67
-60
lines changed

README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,19 @@ Then you only need to write: `require("./parser.pegjs")`.
4444

4545
You can pass options to PEG.js as [query parameters](http://webpack.github.io/docs/using-loaders.html#query-parameters). The following options are supported:
4646

47+
* `allowedStartRules` - The rules the built parser will be allowed to start
48+
parsing from (default: the first rule in the grammar).
49+
4750
* `cache` — If `true`, makes the parser cache results, avoiding exponential
4851
parsing time in pathological cases but making the parser slower (default:
4952
`false`).
5053

54+
* `dependencies` - Parser dependencies, the value is an object which maps variables used to access the
55+
dependencies in the parser to module IDs used to load them (default: `{}`).
56+
5157
* `optimize` - Whether to optimize the built parser either for `speed` or
5258
`size` (default: `speed`).
5359

54-
* `allowedStartRules` - The rules the built parser will be allowed to start
55-
parsing from (default: the first rule in the grammar).
56-
5760
* `trace` - If `true`, the tracing support in the built parser is enabled
5861
(default: `false`).
5962

@@ -82,6 +85,7 @@ Every release, along with the migration instructions, if any, is documented on t
8285
* [VladimirTechMan](https://github.com/VladimirTechMan) for the propagation of the `optimize` option and updating things to be compatible with PEG.js 0.10.0.
8386
* [ragtime](https://github.com/ragtime) for the propagation of the `allowedStartRules` and `trace` options.
8487
* [Jan Varwig](https://github.com/janv) for the Webpack 2 compatibility fix.
88+
* [retorquere](https://github.com/retorquere) for the propagation of the `dependencies` option.
8589

8690
## License
8791

package.json

Lines changed: 55 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,56 @@
11
{
2-
"name": "pegjs-loader",
3-
"version": "0.5.1",
4-
"description": "PEG.js loader for webpack",
5-
"authors": [
6-
"Andrey Subbotin <andrey@subbotin.me> (https://github.com/eploko)",
7-
"Victor Homyakov (https://github.com/victor-homyakov)"
8-
],
9-
"license": "MIT",
10-
"main": "lib/index.js",
11-
"jsnext:main": "src/index.js",
12-
"repository": {
13-
"type": "git",
14-
"url": "https://github.com/eploko/pegjs-loader"
15-
},
16-
"keywords": [
17-
"webpack",
18-
"pegjs",
19-
"peg.js",
20-
"peg",
21-
"loader"
22-
],
23-
"bugs": {
24-
"url": "https://github.com/eploko/pegjs-loader/issues"
25-
},
26-
"homepage": "http://eploko.github.io/pegjs-loader",
27-
"peerDependencies": {
28-
"pegjs": "^0.10.0",
29-
"webpack": "1 || 2 || ^2.1.0-beta || ^2.2.0-rc"
30-
},
31-
"dependencies": {
32-
"loader-utils": "^0.2.5"
33-
},
34-
"devDependencies": {
35-
"babel": "^5.5.8",
36-
"babel-core": "^5.6.18",
37-
"babel-eslint": "^4.1.0",
38-
"babel-loader": "^5.1.4",
39-
"eslint": "^1.7.1",
40-
"eslint-config-airbnb": "^0.1.0",
41-
"eslint-plugin-react": "^3.6.3",
42-
"rimraf": "^2.3.4",
43-
"webpack": "1.12.2"
44-
},
45-
"scripts": {
46-
"clean": "rimraf lib",
47-
"lint": "eslint src",
48-
"check": "npm run lint",
49-
"build:lib": "babel src --out-dir lib",
50-
"build": "npm run build:lib",
51-
"preversion": "npm run clean && npm run check",
52-
"version": "npm run build",
53-
"postversion": "git push && git push --tags && npm run clean",
54-
"prepublish": "npm run clean && npm run build"
55-
}
56-
}
2+
"name": "pegjs-loader",
3+
"version": "0.5.2",
4+
"description": "PEG.js loader for webpack",
5+
"authors": [
6+
"Andrey Subbotin <andrey@subbotin.me> (https://github.com/eploko)",
7+
"Victor Homyakov (https://github.com/victor-homyakov)"
8+
],
9+
"license": "MIT",
10+
"main": "lib/index.js",
11+
"jsnext:main": "src/index.js",
12+
"repository": {
13+
"type": "git",
14+
"url": "https://github.com/eploko/pegjs-loader"
15+
},
16+
"keywords": [
17+
"webpack",
18+
"pegjs",
19+
"peg.js",
20+
"peg",
21+
"loader"
22+
],
23+
"bugs": {
24+
"url": "https://github.com/eploko/pegjs-loader/issues"
25+
},
26+
"homepage": "http://eploko.github.io/pegjs-loader",
27+
"peerDependencies": {
28+
"pegjs": "^0.10.0",
29+
"webpack": "> 1"
30+
},
31+
"dependencies": {
32+
"loader-utils": "^0.2.5"
33+
},
34+
"devDependencies": {
35+
"babel": "^5.5.8",
36+
"babel-core": "^5.6.18",
37+
"babel-eslint": "^4.1.0",
38+
"babel-loader": "^5.1.4",
39+
"eslint": "^1.7.1",
40+
"eslint-config-airbnb": "^0.1.0",
41+
"eslint-plugin-react": "^3.6.3",
42+
"rimraf": "^2.3.4",
43+
"webpack": "1.12.2"
44+
},
45+
"scripts": {
46+
"clean": "rimraf lib",
47+
"lint": "eslint src",
48+
"check": "npm run lint",
49+
"build:lib": "babel src --out-dir lib",
50+
"build": "npm run build:lib",
51+
"preversion": "npm run clean && npm run check",
52+
"version": "npm run build",
53+
"postversion": "git push && git push --tags && npm run clean",
54+
"prepublish": "npm run clean && npm run build"
55+
}
56+
}

src/index.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export default function loader(source) {
1010
const cacheParserResults = !!query.cache;
1111
const optimizeParser = query.optimize || 'speed';
1212
const trace = !!query.trace;
13+
const dependencies = JSON.parse(query.dependencies || '{}');
1314

1415
let allowedStartRules;
1516
if (typeof query.allowedStartRules === 'string') {
@@ -22,15 +23,17 @@ export default function loader(source) {
2223

2324
// Description of PEG.js options: https://github.com/pegjs/pegjs#javascript-api
2425
const pegOptions = {
25-
output: 'source',
2626
cache: cacheParserResults,
27+
dependencies: dependencies,
28+
format: 'commonjs',
2729
optimize: optimizeParser,
30+
output: 'source',
2831
trace: trace,
2932
};
3033
if (allowedStartRules.length > 0) {
3134
pegOptions.allowedStartRules = allowedStartRules;
3235
}
3336

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

0 commit comments

Comments
 (0)