Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrap library with UMD and add npm release task #587

Closed

Conversation

rossta
Copy link

@rossta rossta commented Jun 4, 2020

Builds on #454 which adds a package.json field.

This PR adds the following features:

  1. A release task rake release:npm that can be run to publish this library to NPM. The task will ensure that the NPM release version matches the info in VERSION.
  2. Wraps cocoon.js in Universal Module Definition (UMD). This is an immediately-invoked function expression (IIFE) that is compatible with browser and Node.js environments, i.e., applications that use Sprockets and applications that use Webpacker to bundle JavaScript.

I've also added to the description in package.json to clarify for end-users that this package is designed solely for use with the cocoon gem.

A note about the UMD expression: I used rollup locally to generate this wrapper, which is the only modification to the cocoon.js file. It might make more sense, typically, to add this wrapper as a build step and use a tool (like rollup or any module bundler) to develop locally against the "unwrapped" code, but I didn't want to dictate that change to the owner.

Generally, I believe this is these changes represent the path forward for "asset gems" to best accommodate both Sprockets and module-bundlers, like webpack for Rails applications. I hope you find this useful.

@rossta rossta closed this Feb 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants