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

Closed
wants to merge 2 commits into from
Closed

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/[email protected]/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/[email protected]/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

@goto-bus-stop goto-bus-stop Feb 26, 2018

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.

@mreinstein
Copy link
Contributor

the ecma world has chosen es modules for the module standard. closing this in favor of #85

@mreinstein mreinstein closed this Oct 17, 2024
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.

4 participants