privatenumber / pkgroll

📦 Zero-config package bundler for Node.js + TypeScript
MIT License
1.01k stars 23 forks source link

support iife export format #57

Closed muratgozel closed 3 months ago

muratgozel commented 3 months ago

Feature request

Provide an option for an iife type of bundle.

Motivations

Libraries that target browser environments usually need an iife export to be injectible by html script tag.

Alternatives

The best thing to do right now, is to use rollup to have iife exports.

Additional context

I understand how this bundler works and loved it. I don't want it to be complicated by config files or more more dependencies. Still I'm curious what the developer would think about this.

Contributions

privatenumber commented 3 months ago

Browsers support ESM natively so you can use the module output type

muratgozel commented 3 months ago

yeah, i didn't mention but there is also private node environments such as google apps script or cloudflare workers which requires you to bundle everything without import or require statements. iife format also works well in those environments.

privatenumber commented 3 months ago

This tool is a bundler, so it removes import/requires.

Maybe you can spin up a demo where the output does not work for your needs.

muratgozel commented 3 months ago

yeah, fair enough, better i come with a tangible case. iife exports are generated as part of build phase in my libraries and it was the only missing thing in pkgroll, thats why i wanted to ask. i will see how this goes in the future, thanks anyway.