fgnass / spin.js

A spinning activity indicator
http://spin.js.org
MIT License
9.3k stars 1.02k forks source link

This library needs an UMD release #367

Closed andreynering closed 5 years ago

andreynering commented 5 years ago

Hey there,

I know Webpack and NPM/Yarn is the future, but for those of us that are still in transition to it and have some legacy code to maintain, the UMD release is still necessary.

The spin.js present on the site is not useful because:

  1. It isn't wrapped in an anonymous functions, i.e. it pollutes the global scope (window) with more than necessary (the Spinner object);
  2. It has modules keywords like export { Spinner } that won't work if you're using something like Gulp to concat libs.

I know this issue is duplicated, but I think you should reconsider.

theodorejb commented 5 years ago

I don't want to bloat the npm package with code for legacy module formats that not everyone needs.

If for some reason you aren't able to use ES6 modules yet, I'd recommend sticking with the 2.x release of spin.js, or creating a UMD file yourself using Rollup:

npm install spin.js
npm install rollup --save-dev
npx rollup node_modules/spin.js/spin.js --file spin.umd.js --format umd --name "Spin"

The spin.js file on the site actually does not pollute the global scope, since it is an ES6 module. This file is useful for anyone targeting modern browsers with support for <script type=module>.

andreynering commented 5 years ago

@theodorejb Saw that you added it now: http://spin.js.org/spin.umd.js

Thanks!

And yeah, it's definitely not needed to publish it on the NPM package.