decanTyme / chartjs-plugin-tailwindcss-colors

Use TailwindCSS to colorize your Chart.js components!
https://www.npmjs.com/package/chartjs-plugin-tailwindcss-colors
MIT License
3 stars 0 forks source link

UMD global exports #16

Closed decanTyme closed 9 months ago

decanTyme commented 1 year ago

As of now (02/2023), Parcel v2 doesn't support exporting as a UMD with an exposed global variable, which is strange given that they do support it in v1. Of course, there are some workarounds such as manually attaching to the window object. Unfortunately, Parcel has been slow to merge a PR looking to address exactly this (looking at you, https://github.com/parcel-bundler/parcel/pull/7240). Looking at similar packages, Rollup seems to do a better job at this with their config. ~While this does not really matter for now~ (or ever, given we are now moving towards native ESM), if this doesn't get resolved soon, I might be tempted to migrate to Rollup in the future.

Some resources:

decanTyme commented 1 year ago

Okay, one glaring problem is that while Parcel also supports global aliases for external dependencies, it does this for all targets. This means that doing:

"alias": {
  "tailwindcss/resolveConfig": {
    "global": "tailwind.resolveConfig"
  }
}

...which I intend for browser UMD exports only, frameworks/bundlers will complain that tailwind.resolveConfig is missing! I don't know of any way to just alias a single target, or at least they forgot to document that somehow.

Alternatively, building the UMD and Library targets separately can mitigate this, but I build/publish in CI and the only way is temporarily removing stuff in the package.json (there's no way to override this in the CLI, not that I'm aware of) so that's a no-go. A custom build script is also an unnecessary overhead just to publish stuff that can be dealt with by using other bundlers (and by other bundlers I mean Rollup, yes).

Again, Rollup does a much better job than this. ~Am I missing something here?~

decanTyme commented 1 year ago

Some kbs info for v0.2.0, built w/ Parcel:

image

decanTyme commented 1 year ago

Alrighty. I have dabbled way too much with tests lately and it looks like I'm gonna be making the move sooner than later. I figure this isn't really something I should be worrying too much about and just move on lol. I haven't really used Parcel that much either tbh but it was still a great run. Also, node-canvas is being just a little bit rough around the edges, I'd say.