Closed davidmurdoch closed 4 months ago
Hello @davidmurdoch,
Thank you for the issue report and the solution!
The fixed version is 3.5.2
.
I have added the fields require, import, types into the exports
section of the package.json
.
This just works fine, but I got another error: TS1479 by import { Options as MinifyOptions } from 'html-minifier-terser';
To fix it you should use following TS options:
// tsconfig.json
{
"compilerOptions": {
"strict": true,
"module": "es2020",
//"module": "node16", /* ERROR TS1479 by import { Options as MinifyOptions } from 'html-minifier-terser'; */
"moduleResolution": "node",
"allowSyntheticDefaultImports": true,
"esModuleInterop": true
}
}
Current behaviour
importing
html-bundler-webpack-plugin
causes typescript error:Expected behaviour
Types should work in latest typescript with
"module": "node16"
and"strict": true
.Here is some information about how typescript resolves types fields: https://www.typescriptlang.org/docs/handbook/modules/reference.html#packagejson-typesversions
I think you need to add a "types" field to the "exports" in the
package.json
. Something like (but I'm not entirely sure this is 100% correct):Reproduction Example
Create the 3 files below then run
yarn && npx -y tsc
.Environment
Additional context
n/a