terser / html-minifier-terser

actively maintained fork of html-minifier - minify HTML, CSS and JS code using terser - supports ES6 code
https://terser.org/html-minifier-terser
MIT License
376 stars 30 forks source link

Add the type definitions file - closes #20 #21

Closed DanielRuf closed 3 years ago

DanielRuf commented 4 years ago

This adds the type definitions file so that TypeScript projects can consume and use them.

jantimon commented 4 years ago

Looks good to me 👍

@types/html-minifier has 3 dependencies: https://www.npmjs.com/package/@types/html-minifier

Will adding them as devDependencies be enough to work properly?

DanielRuf commented 4 years ago

I think so. They are added in the package.json file in this PR. @types/uglify-js is not needed anymore as terser is used now and for that there is only a stub, see https://unpkg.com/browse/@types/terser@3.12.0/package.json and https://unpkg.com/browse/@types/terser@3.12.0/README.md

jantimon commented 4 years ago

According to https://stackoverflow.com/questions/45176661/how-do-i-decide-whether-types-goes-into-dependencies-or-devdependencies we should add types we rexeport to dependencies.

For example:

    minifyCSS?: boolean | CleanCSS.Options | ((text: string) => string);

If someone tries to consume this type they will not be able to access CleanCSS.Options as @types/clean-css would not be installed.

DanielRuf commented 4 years ago

I have read the same thread yesterday.

Normally I would say devDependencies because types and TypeScript are not directly used in production and only useful for development.`

jantimon commented 4 years ago

If dependents of html-minifier-terser will use it, it is a public dependency not a dev dependency.

If you don't want to add it to dependencies that is also fine but in that case we should not merge this pullrequest - as dependent builds will fail otherwise.

Maybe we can create @types/html-minifier-terser instead?

DanielRuf commented 4 years ago

Maybe we can create @types/html-minifier-terser instead?

Makes more sense. But I have amended the commit and moved them to dependencies so there should not be any issues now.

jantimon commented 4 years ago

Both ways will work fine for IDE support and build type checks.

jantimon commented 4 years ago

So pick the one you prefer :)

DanielRuf commented 4 years ago

I guess I can close this PR as there is now https://www.npmjs.com/package/@types/html-minifier-terser

DanielRuf commented 3 years ago

Closing as this might be obsolete now.