From 532acf7104cbb3ebb88440e0a08de18a64b81910 Mon Sep 17 00:00:00 2001 From: biodiscus Date: Tue, 17 Oct 2023 22:11:27 +0200 Subject: [PATCH] fix: correct the type of the `value` argument in the `filter()` function --- CHANGELOG.md | 4 ++++ README.md | 4 ++-- package.json | 2 +- .../loader-option-sources-attrs/webpack.config.js | 11 ++++++++++- types.d.ts | 2 +- 5 files changed, 18 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6daad5b1..83c157a1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Change log +## 2.14.5 (2023-10-17) + +- fix: correct the type of the `value` argument in the `filter()` function of the `sources` loader option + ## 2.14.4 (2023-10-12) - fix: correct attributes type in the `filter()` function of the `sources` loader option diff --git a/README.md b/README.md index c326f416..b2e077aa 100644 --- a/README.md +++ b/README.md @@ -2008,7 +2008,7 @@ type Sources = filter?: (props: { tag: string; attribute: string; - value: string; + value: string | Array; attributes: { [k: string]: string }; resourcePath: string; }) => boolean | undefined; @@ -2071,7 +2071,7 @@ The argument is an object containing the properties: - `tag: string` - a name of the HTML tag - `attribute: string` - a name of the HTML attribute -- `value: string` - a value of the HTML attribute +- `value: string | Array` - a value of the HTML attribute; for `srcset` the value is an array of parsed filenames - `attributes: string` - all attributes of the tag - `resourcePath: string` - a path of the HTML template diff --git a/package.json b/package.json index d2f54291..d10ee8b5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "html-bundler-webpack-plugin", - "version": "2.14.4", + "version": "2.14.5", "description": "HTML bundler plugin for webpack handles a template as an entry point, extracts CSS and JS from their sources referenced in HTML, supports template engines like Eta, EJS, Handlebars, Nunjucks.", "keywords": [ "html", diff --git a/test/cases/loader-option-sources-attrs/webpack.config.js b/test/cases/loader-option-sources-attrs/webpack.config.js index 0932f7fe..199de746 100644 --- a/test/cases/loader-option-sources-attrs/webpack.config.js +++ b/test/cases/loader-option-sources-attrs/webpack.config.js @@ -30,7 +30,16 @@ module.exports = { tag: 'img-ng', attributes: ['data-src-one', 'data-src-two'], }, - + // TODO: in next major version + // - change the value as original string + // - add the values argument containing array of parsed in srcset filenames + // { + // tag: 'img', + // attributes: ['srcset'], + // filter: ({ attribute, value, values }) => { + // console.log('\n### ATTR: ', { attribute, value, values }); + // }, + // }, { tag: 'link', attributes: ['data-source'], diff --git a/types.d.ts b/types.d.ts index 4cfd642e..37ddb8d9 100644 --- a/types.d.ts +++ b/types.d.ts @@ -211,7 +211,7 @@ type Sources = filter?: (props: { tag: string; attribute: string; - value: string; + value: string | Array; attributes: { [k: string]: string }; resourcePath: string; }) => boolean | undefined;