Skip to content

Commit 3297b99

Browse files
refactor: dropped webpack@4 (#339)
BREAKING CHANGE: minimum supported `webpack` version is `5`
1 parent b7b5dd2 commit 3297b99

File tree

13 files changed

+112
-99
lines changed

13 files changed

+112
-99
lines changed

.github/workflows/nodejs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ jobs:
5656
matrix:
5757
os: [ubuntu-latest, windows-latest, macos-latest]
5858
node-version: [10.x, 12.x, 14.x]
59-
webpack-version: [4, latest]
59+
webpack-version: [latest]
6060

6161
runs-on: ${{ matrix.os }}
6262

package-lock.json

Lines changed: 79 additions & 44 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -40,44 +40,43 @@
4040
"dist"
4141
],
4242
"peerDependencies": {
43-
"webpack": "^4.0.0 || ^5.0.0"
43+
"webpack": "^5.0.0"
4444
},
4545
"dependencies": {
4646
"html-minifier-terser": "^5.1.1",
4747
"loader-utils": "^2.0.0",
48-
"parse5-sax-parser": "^6.0.1",
49-
"schema-utils": "^3.0.0"
48+
"parse5-sax-parser": "^6.0.1"
5049
},
5150
"devDependencies": {
52-
"@babel/cli": "^7.12.1",
53-
"@babel/core": "^7.12.3",
54-
"@babel/preset-env": "^7.12.1",
51+
"@babel/cli": "^7.12.10",
52+
"@babel/core": "^7.12.10",
53+
"@babel/preset-env": "^7.12.11",
5554
"@commitlint/cli": "^11.0.0",
5655
"@commitlint/config-conventional": "^11.0.0",
5756
"@webpack-contrib/defaults": "^6.3.0",
5857
"@webpack-contrib/eslint-config-webpack": "^3.0.0",
5958
"babel-jest": "^26.6.3",
60-
"cross-env": "^7.0.2",
59+
"cross-env": "^7.0.3",
6160
"del": "^6.0.0",
6261
"del-cli": "^3.0.1",
63-
"es-check": "^5.1.2",
64-
"eslint": "^7.13.0",
65-
"eslint-config-prettier": "^6.15.0",
62+
"es-check": "^5.2.0",
63+
"eslint": "^7.19.0",
64+
"eslint-config-prettier": "^7.2.0",
6665
"eslint-plugin-import": "^2.22.1",
6766
"file-loader": "^6.2.0",
6867
"handlebars": "^4.7.6",
69-
"husky": "^4.3.0",
68+
"husky": "^4.3.8",
7069
"jest": "^26.6.3",
71-
"lint-staged": "^10.5.1",
70+
"lint-staged": "^10.5.3",
7271
"memfs": "^3.2.0",
7372
"npm-run-all": "^4.1.5",
74-
"posthtml": "^0.14.0",
73+
"posthtml": "^0.15.1",
7574
"posthtml-webp": "^2.1.0",
7675
"prettier": "^2.1.2",
7776
"standard-version": "^9.0.0",
7877
"unescape-unicode": "^0.2.0",
7978
"url-loader": "^4.1.1",
80-
"webpack": "^5.5.0"
79+
"webpack": "^5.19.0"
8180
},
8281
"keywords": [
8382
"webpack",

src/index.js

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { getOptions, stringifyRequest } from 'loader-utils';
2-
import { validate } from 'schema-utils';
1+
import { stringifyRequest } from 'loader-utils';
32

43
import { sourcePlugin, minimizerPlugin } from './plugins';
54
import {
@@ -13,13 +12,7 @@ import {
1312
import schema from './options.json';
1413

1514
export default async function loader(content) {
16-
const rawOptions = getOptions(this);
17-
18-
validate(schema, rawOptions, {
19-
name: 'HTML Loader',
20-
baseDataPath: 'options',
21-
});
22-
15+
const rawOptions = this.getOptions(schema);
2316
const options = normalizeOptions(rawOptions, this);
2417

2518
if (options.preprocessor) {

src/options.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"title": "HTML Loader options",
23
"type": "object",
34
"definitions": {
45
"Attribute": {

src/plugins/source-plugin.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ export default (options) =>
1919
const urlFilter = getFilter(maybeUrlFilter, (value) =>
2020
isUrlRequest(value, root)
2121
);
22-
const getAttribute = (tag, attribute, attributes, resourcePath) => {
23-
return list.find((element) => {
22+
const getAttribute = (tag, attribute, attributes, resourcePath) =>
23+
list.find((element) => {
2424
const foundTag =
2525
typeof element.tag === 'undefined' ||
2626
(typeof element.tag !== 'undefined' &&
@@ -47,7 +47,6 @@ export default (options) =>
4747
? element.filter(tag, attribute, adaptedAttributes, resourcePath)
4848
: true;
4949
});
50-
};
5150

5251
const { resourcePath } = options;
5352
const parser5 = new SAXParser({ sourceCodeLocationInfo: true });
@@ -141,9 +140,11 @@ export default (options) =>
141140
return;
142141
}
143142

144-
sourceSet = sourceSet.map((item) => ({
145-
source: c0ControlCodesExclude(item.source),
146-
}));
143+
sourceSet = sourceSet.map((item) => {
144+
return {
145+
source: c0ControlCodesExclude(item.source),
146+
};
147+
});
147148

148149
let searchFrom = name.length;
149150

@@ -213,7 +214,6 @@ export default (options) =>
213214
const request = requestify(normalizedUrl, root);
214215
const newUrl = prefix ? `${prefix}!${request}` : request;
215216
const importKey = newUrl;
216-
217217
let importName = imports.get(importKey);
218218

219219
if (!importName) {

test/attributes-option.test.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -246,9 +246,7 @@ describe("'attributes' option", () => {
246246
attribute: 'src',
247247
type: 'src',
248248
// eslint-disable-next-line no-unused-vars
249-
filter: (tag, attribute, attributes) => {
250-
return tag.toLowerCase() !== 'img';
251-
},
249+
filter: (tag, attribute, attributes) => tag.toLowerCase() !== 'img',
252250
},
253251
],
254252
},

0 commit comments

Comments
 (0)