Skip to content

Commit 06d9829

Browse files
committed
Merge pull request #1 from LeezQ/master
add query for react-router-proxy-loader,then you can use :
2 parents d33dfac + 167ab7b commit 06d9829

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

index.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@
22
* Taken and modified from react-proxy-loader to support react-router
33
* willTransitionTo hooks. See "BEGIN CHANGE" - "END CHANGE" below.
44
*/
5+
var loaderUtils = require("loader-utils");
6+
57
module.exports = function() {};
68
module.exports.pitch = function(remainingRequest) {
79
this.cacheable && this.cacheable();
10+
var query = loaderUtils.parseQuery(this.query);
11+
812
var moduleRequest = "!!" + remainingRequest;
913
return [
1014
'var React = require("react");',
@@ -25,7 +29,7 @@ module.exports.pitch = function(remainingRequest) {
2529
' else {',
2630
' callback();',
2731
' }',
28-
' });',
32+
' }' + (query.name ? ', ' + JSON.stringify(query.name) : '') + ');',
2933
' },',
3034
' willTransitionFrom: function(transition, component, callback) {',
3135
' if (component && component.willTransitionFrom) {',
@@ -46,7 +50,7 @@ module.exports.pitch = function(remainingRequest) {
4650
' require.ensure([], function() {',
4751
' component = require(' + JSON.stringify(moduleRequest) + ');',
4852
' if(callback) callback(component);',
49-
' });',
53+
' }' + (query.name ? ', ' + JSON.stringify(query.name) : '') + ');',
5054
' } else if(callback) callback(component);',
5155
' return component;',
5256
' }',

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
"bugs": {
2222
"url": "https://github.com/odysseyscience/react-router-proxy-loader/issues"
2323
},
24+
"dependencies": {
25+
"loader-utils": "~0.2.6"
26+
},
2427
"homepage": "https://github.com/odysseyscience/react-router-proxy-loader",
2528
"peerDependencies": {
2629
"react-router": "^0.12.0"

0 commit comments

Comments
 (0)