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

Publish as UMD bundle #62

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Publish as UMD bundle #62

wants to merge 2 commits into from

Conversation

jrop
Copy link

@jrop jrop commented Jan 2, 2018

Publishing as a UMD bundle allows for easy use in HTML pages via unpkg:

<script src="https://unpkg.com/hyperapp@1.0.1/dist/hyperapp.js"></script>
<script src="https://unpkg.com/hyperx@latest/dist/hyperx.min.js"></script>
<script>
  const {app, h} = hyperapp
  const hx = hyperx(h)
  const main = app(
    {}, // state
    {}, // actions
    () => hx`<div>Hello from HyperX!</div>`,
    document.getElementById('root')
  )
</script>

This change is completely backward-compatible and supports:

  • CommonJS (require('hyperx') still works)
  • AMD
  • library exported as window.hyperx when included via a <script> tag

This mirrors how React is publishing their module as well. See: https://unpkg.com/react@16.2.0/cjs/

@jrop
Copy link
Author

jrop commented Jan 2, 2018

@tsjnsn
Copy link

tsjnsn commented Feb 26, 2018

This would be really nice

@jrop
Copy link
Author

jrop commented Feb 26, 2018

@tsjnsn For the moment, I published a single version of a UMD build of this package here:

https://www.npmjs.com/package/@jrop/hyperx

I still would like to have this merged though :/

"scripts": {
"test": "tape test/*.js",
"coverage": "covert test/*.js"
"coverage": "covert test/*.js",
"prepack": "webpack"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

using browserify with tinyify seems simpler than placing a webpack config file in the root just for umd:

"scripts": {
  "prepublish": "browserify -s hyperx -p tinyify index.js -o dist/hyperx.js"
}

and a bit more in line with other choo-adjacent projects :)

@goto-bus-stop
Copy link
Member

personally i'm cool with publishing UMD builds. I know not everyone in the choojs org likes em tho. you can also use https://wzrd.in/standalone/hyperx which browserifies a UMD build on the fly.

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.

None yet

3 participants