Hey <@UL1A5BA2X> :wave: Is there any way to use <N...
# javascript
n
Hey @Big Chungus 👋 Is there any way to use NPM’s `exports` with npm-publish plugin or to add a custom field? Thanks!
b
You can have any arbitrary json properties https://npm-publish.petuska.dev/latest/user-guide/configuration/package/#packagejson Although I should probably add new missing fields as proper typesafe dsl. Care to raise an issue for what's missing?
n
Sure thing, will rise it. Thanks!
Wanna me to open a PR for that?
b
That'd be much appreciated if you have the time
Just be sure to also add the new props to the docs
n
Cool! I think I'll find the time soon enough 👍
Hey man, this is more complex than I expected. Would the API be good enough like:
Copy code
packages {
   named("js") {
      packageJson {
        exports {
           "." by "./index.mjs"
           "./subpath" by {
              "types" by "./subpath/types.d.ts",
              "default" by "./subpath/index.mjs",
           }
        }
      }
   }
}
Or something more assisted in terms of each path would be required?
b
Hah, just having typed "exports" block is already better than current situation. I can take care of the rest later.
👍 1
n
Will try to improve it and if I’m not able I’ll let you handle that.
I have achieved something like this, but I dislike the
paths
thing. WDYT?
b
Hmm, the goal here is to make the dsl feel like you're just writing an actual package json file. I assume package json file does not have exports.paths object, does it?
Are you stuck because exports property is a union type? Type: <Object> | <string> | <string[]>
n
Nope, no
paths
object and yes, that's the problem 😊.
b
How about just providing 3 variants for the dsl, all of which just write different things to the underlying map property?
exports by "string" exports by arrayOf() exports by {}
Or just implement the one you're using yourself for now and I can do the others later.
n
Ah! That feels like a smart solution. Let me try 🙂 Thanks!
Hey mate, I just opened a PR. It’s a draft one because it’s not working. It’s the first time I’m working on a Gradle plugin and I’m unsure of what I’m doing. Maybe this can serve as a base of the real feature or maybe not. Feel free to discard everything.
b
Thanks, I'll review it tomorrow
👍 1
n
Ah, and the docs are just quick placeholders to bypass detekt!