mpetuska/npm-publish

npm.publish.publication.<name>.types value ignored

Closed this issue ยท 2 comments

First and foremost many thanks for a great plugin, it saves an enormous amount of work! ๐Ÿ‘

The documentation mentions that it's possible to set custom types (*.d.ts) file for the final package.json as npm.publish.publication.<name>.types value and the gradle configuration allows it to be set.

In our case, the configuration looks as follows

npmPublishing {
    organization = "com.example"
    publications {
        js {
            moduleName = "my-test"
            types = "./CustomTypes.d.ts"
        }
    }
}

But after running the task the final package.json types attribute value fallbacks to the default my-test.d.ts value. A possible workaround is to create and set the packageJsonTemplateFile file with the types attribute being set to the expected value.

From the code, it seems that the NpmPublication.types value is never accessed. I would assume that here
https://github.com/mpetuska/npm-publish/blob/master/src/main/kotlin/task/NpmPackageAssembleTask.kt#L139 should be resolveTypes() function called only if NpmPublication.types is not set (or invalid).

Ah, you're right. Resolving defaults, templates and gradle configs is a bit tricky, so this slipped through the cracks. An easy fix though, so I should be able to release a new version for this tomorrow. Thanks for the report!

v2.1.0 should solve your issue