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

Build for UMD #617

Merged
merged 4 commits into from
May 23, 2018
Merged

Build for UMD #617

merged 4 commits into from
May 23, 2018

Conversation

bates64
Copy link
Contributor

@bates64 bates64 commented Jan 8, 2018

Via the --standalone browserify option.
Fixes #537. Note that the export is window.choo.

Only caveat is the choo/html is not exported -- the best way to do this would probably be to export choo.html, but that'd require changes to the source also - see heyitsmeuralex/nanochoo for a potential solution to this (evicting choo/html altogether as it is unused within the choo source).

8 characters. See choojs#537
@bcomnes
Copy link
Collaborator

bcomnes commented Jan 8, 2018

https://github.com/choojs/choo-umd existed to do this, but what is your use case? I'm more 👎 on UMDs than I ever have been.

EDIT: I've softened up on them since writing the above. People should till be bundling but we can still support this path.

@bates64
Copy link
Contributor Author

bates64 commented Jan 8, 2018

Via @arturi:

This functionality is actually useful for quick demos and taking a library for a spin, build step is good for production, but shouldn’t be required for starting out.

Here’s an example of someone wanting to use Choo without build-steps: https://twitter.com/louiscenter/status/950312739825647616.

I'd note that this has little-to-no impact on the build size and changes nothing other than allowing one to include choo in a script tag, which I'd argue is a great thing 🎉 There's no extra file generated, etc, etc.

@toddself
Copy link
Contributor

toddself commented Jan 8, 2018

We never actually use choo/html since choo isn't a dependency of most of our codebase -- rather we install and require bel directly.

This is something I'd love to do in the next release of choo -- xhr was already dropped; I don't feel there is a significant advantage gain to including bel.

@bates64
Copy link
Contributor Author

bates64 commented Jan 8, 2018

For reference, I saw significant gains (well, losses) evicting both nanorouter (which is easy enough to re-implement) and choo/html.

Copy link
Member

@goto-bus-stop goto-bus-stop left a comment

Choose a reason for hiding this comment

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

i think we should drop choo-umd and instead only have this

@YerkoPalma
Copy link
Member

Would this cause conflicts when using choo-devtools? Since both exports a choo object to window?

@yoshuawuyts
Copy link
Member

@YerkoPalma yeah, it would. Might need to alias choo before importing devtools. Maybe we should alias devtools if it already detects a globl choo instance. A PR for that would be very welcome!

@goto-bus-stop
Copy link
Member

I guess we could uppercase Choo here?

@YerkoPalma
Copy link
Member

I prefer uppercasing choo (Choo) instead of aliasing. Now I wonder how views would be built with umd, since bel is not expose and has no umd build, that's the only concern I have about it.

@bates64
Copy link
Contributor Author

bates64 commented Feb 14, 2018

@YerkoPalma I'm still advocating evicting bel from choo as in nanochoo. However, we could export:

window.Choo = { choo, html, devtools }

with devtools extending Choo if it already exists

package.json Outdated
@@ -13,7 +13,7 @@
"example"
],
"scripts": {
"build": "mkdir -p dist/ && browserify index -p bundle-collapser/plugin > dist/bundle.js && browserify index -p tinyify > dist/bundle.min.js && cat dist/bundle.min.js | gzip --best --stdout | wc -c | pretty-bytes",
"build": "mkdir -p dist/ && browserify index -s choo -p bundle-collapser/plugin > dist/bundle.js && browserify index -p tinyify > dist/bundle.min.js && cat dist/bundle.min.js | gzip --best --stdout | wc -c | pretty-bytes",
Copy link
Member

@YerkoPalma YerkoPalma Mar 14, 2018

Choose a reason for hiding this comment

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

Could this be uppercased to Choo to avoid issues with devtools?

@goto-bus-stop
Copy link
Member

@heyitsmeuralex do you have time to address @YerkoPalma's review soon? i can do it too if not.

index.js Outdated
@@ -13,6 +13,9 @@ var xtend = require('xtend')

module.exports = Choo

Choo.html = require('./html')
Choo.raw = require('./html/raw')
Copy link
Member

Choose a reason for hiding this comment

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

This will add choo/html to yo-yoified browserify bundles too, increasing bundle size by a few KB… I think people should probably use nanohtml directly instead for UMD, or we could have a separate UMD entry file that does something like

module.exports = require('./')
module.exports.html = require('./html')
module.exports.raw = require('./html/raw')

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point. Reverting.

@goto-bus-stop goto-bus-stop merged commit b0cdb6c into choojs:master May 23, 2018
tornqvist added a commit to tornqvist/choo that referenced this pull request Jun 21, 2018
…state

* upstream/master:
  6.12.1
  6.12.0
  typings: add app to app.use cb (choojs#665)
  update dependencies (choojs#663)
  ci: Node 7 → Node 10 (choojs#661)
  Update bel and yo-yoify references in docs to nanohtml. (choojs#660)
  Build for UMD (choojs#617)
  6.11.0
  Use nanoassert in the browser (choojs#651)
  Switch to nanohtml (choojs#644)
  v6.11.0-preview1
  choo components (choojs#639)
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.

6 participants