Skip to content

Commit

Permalink
feat: bump dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
backflip committed Jan 3, 2022
1 parent aa127f1 commit 40d65ea
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 23 deletions.
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx --no-install pretty-quick --staged
4 changes: 4 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
trailingComma: "none",
arrowParens: "avoid"
};
21 changes: 18 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,25 @@
const fs = require("fs");
const path = require("path");
const { getOptions, parseQuery } = require("loader-utils");
const { Compiler } = require("@adobe/htlengine");

module.exports = async function(source) {
const options = getOptions(this);
// Basic loader query parser allowing for `?data=JSON_OBJECT`
function parseQuery(resourceQuery) {
const result = {};
const params = new URLSearchParams(resourceQuery.slice(1));

for (const [key, value] of params.entries()) {
if (key === "data") {
result[key] = JSON.parse(value);
} else {
result[key] = value;
}
}

return result;
}

module.exports = async function (source) {
const options = this.getOptions();
const query = this.resourceQuery ? parseQuery(this.resourceQuery) : null;
const settings = Object.assign(
{
Expand Down
32 changes: 13 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"test": "mocha test/*.test.js",
"example": "webpack --config example/webpack.config.js",
"format": "prettier --write \"**/*.js\"",
"release": "np"
"release": "np",
"prepare": "husky install"
},
"keywords": [
"htl",
Expand All @@ -17,25 +18,18 @@
"repository": "github:backflip/htl-loader",
"license": "MIT",
"devDependencies": {
"@adobe/htlengine": "^6.1.0",
"fs-extra": "^8.1.0",
"husky": "^4.2.3",
"mocha": "^7.0.1",
"np": "^6.4.0",
"prettier": "^1.19.1",
"pretty-quick": "^2.0.1",
"webpack": "^4.41.6",
"webpack-cli": "^3.3.11"
"@adobe/htlengine": "~6.3.0",
"fs-extra": "^10.0.0",
"husky": "^7.0.0",
"mocha": "^9.1.3",
"np": "^7.6.0",
"prettier": "^2.5.1",
"pretty-quick": "^3.1.3",
"webpack": "^5.65.0",
"webpack-cli": "^4.9.1"
},
"peerDependencies": {
"@adobe/htlengine": "^6.1.0"
},
"dependencies": {
"loader-utils": "^1.2.3"
},
"husky": {
"hooks": {
"pre-commit": "pretty-quick --staged"
}
"@adobe/htlengine": "~6.3.0",
"webpack": "^5"
}
}
2 changes: 1 addition & 1 deletion test/fixtures/simple_with_query/entry.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import html from './template.htl?{"data":{"title":"Hello, world."}}';
import html from './template.htl?data={"title":"Hello, world."}';

export default html;

0 comments on commit 40d65ea

Please sign in to comment.