Skip to content

Commit

Permalink
Upgrade to Webpack2 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
Coen Warmer authored and pmendelski committed Mar 16, 2017
1 parent 575329f commit 2e34ab2
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
@@ -1,6 +1,6 @@
language: node_js
node_js:
- "0.10"
- "4.2.1"

script: npm run ci
after_success: npm run coveralls
Expand Down
15 changes: 11 additions & 4 deletions lib/swig-loader.js
@@ -1,6 +1,6 @@
'use strict';

var loaderUtils = require('loader-utils'),
var queryString = require('query-string'),
Swig = new require('swig').Swig,
defaultOpts = {},
noop = function() {},
Expand All @@ -10,10 +10,13 @@ var loaderUtils = require('loader-utils'),
resultCustomizer = noopr;

module.exports = function(content) {
var plugin = this;
var plugin = assign(
{},
this
);
plugin.cacheable && plugin.cacheable();
plugin.query = loaderUtils.parseQuery(this.query);
plugin.resourceQuery = loaderUtils.parseQuery(this.resourceQuery);
plugin.query = parseQuery(plugin.query);
plugin.resourceQuery = parseQuery(plugin.resourceQuery);
content = resolve(content, plugin);
return prepareResult(content, plugin.query);
};
Expand Down Expand Up @@ -63,6 +66,10 @@ function resolve(content, plugin) {
return result;
}

function parseQuery(query) {
return JSON.parse(JSON.stringify(queryString.parse(query, { arrayFormat: 'bracket' })));
}

function registerTemplateDependencies(swig, plugin) {
var loader = swig.options.loader,
_load = loader.load;
Expand Down
6 changes: 3 additions & 3 deletions package.json
Expand Up @@ -23,7 +23,7 @@
"webpack"
],
"dependencies": {
"loader-utils": "^0.2.11",
"query-string": "4.3.2",
"swig": "^1.4.2"
},
"devDependencies": {
Expand All @@ -43,10 +43,10 @@
"mkdirp": "^0.5.1",
"mocha": "2.2.5",
"mocha-jenkins-reporter": "~0.1.9",
"webpack": "^1.11.0"
"webpack": "2.2.1"
},
"engines": {
"node": ">=0.10"
"node": "4.2.1"
},
"analyze": "true"
}
2 changes: 1 addition & 1 deletion test/load.js
Expand Up @@ -17,7 +17,7 @@ module.exports = function(filepath, callback) {
libraryTarget: 'commonjs2'
},
module: {
loaders: [
rules: [
{ test: /\.html(\?.*)?$/, loader: __projectDir }
]
}
Expand Down

0 comments on commit 2e34ab2

Please sign in to comment.