Hey <@UL1A5BA2X>, is there a way to express in a `...
# npm-publish
m
Hey @Big Chungus, is there a way to express in a
package.json
that some files within the package are "optional" and able to be excluded (or is that even something that needs to be done)? Looking to achieve the same sort of functionality that Java/Android app's have with the ability to exclude resources (such as android's
packagingOptions
gradle dsl). Is this something I need to define in the npm publication's
package.json
? e.g. I publish https://www.npmjs.com/package/kmp-tor-binary-resources?activeTab=code It contains pre-built native binaries for many platforms and architectures. But want to be able to selectively
exclude
files within the
io/matthewnelson/kmp/tor/binary/native
directory for platforms that my node application won't be running on.
b
Hmm, I don't think that's something npm supports. Most bin packages published there usually just have the executables for all the platforms bundled together.
That being said, you could hack it in npm-publish plugin itself and create 3 publication, each modified to filter out the files you don't want from the same package sources
Might need to spawn multiple assemble tasks with filtering yourself though and it certainly won't be pretty
Also this assumes 3 distinct packages on npm in the end
m
Hmm, I don't think that's something npm supports. Most bin packages published there usually just have the executables for all the platforms bundled together.
Yeah, even though I've gzipped all the files individually, it's still a 40mb package. Tor is not small.
b
What's the reason behind you publishing the package to the npm? Do you expect to have any real js/ts consumers?
m
So that I can extract the resources from the module to the filesystem
The only one depending on that npm package is my kotlin multiplatform library, then using
js("require.resolve({module-name}/io/matthewnelson/kmp/tor/binary/{platform}/{arch}/tor.gz") as String
and writing it to the filesystem