-
-
Notifications
You must be signed in to change notification settings - Fork 927
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
Add bundler scripts for stream #1832
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Beyond the two nits, make sure that the bundler doesn't update the README using the stream bundle's size - Mithril core is a bit larger than the ~1.5kb gzipped, but unminified stream core. This may require an extra flag.
@@ -21,7 +22,7 @@ | |||
"cover": "istanbul cover --print both ospec/bin/ospec", | |||
"release": "npm version -m 'v%s'", | |||
"preversion": "npm run test", | |||
"version": "npm run build && git add mithril.js mithril.min.js", | |||
"version": "npm run build && git add mithril.js mithril.min.js stream.js stream.min.js", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: use mithril-stream.js
and mithril-stream.min.js
instead, so it doesn't override mithril/stream
.
@@ -4,4 +4,6 @@ | |||
/examples | |||
/mithril.js | |||
/mithril.min.js | |||
/stream.js |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: use mithril-stream.js
and mithril-stream.min.js
instead, so it doesn't override mithril/stream
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
package.json main
points to mithril.js
. So when doing require/import we'd get mithril.js, not index.js, right? So would we not also want to get the bundled, top-level stream.js?
And when using unpkg.com in a jsbin I was thinking it'd be nice to be able to use unpkg.com/mithril/stream rather than unpkg.com/mithril/mithril-stream
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When you require("mithril/stream")
, it searches for the following files (source):
node_modules/mithril/stream.js
node_modules/mithril/stream.node
(and other registered extensions)node_modules/mithril/stream/{pkg.main}
(where"main"
is from thepackage.json
)node_modules/mithril/stream/index.js
node_modules/mithril/stream/index.node
(and other registered extensions)
This means when you save a file as stream.js
in the root, when it gets published, Node will find mithril/stream.js
rather than the intended mithril/stream/index.js
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@spacejack (quoting from your most recent reply)
Currently, using require/import you get the pre-bundled mithril.js. My attempt was to create a similar stream.js bundle.
Oh okay. That makes sense (although that begs the question of why it's still in a subdirectory - the main export is an unbundled UMD).
But for the purposes of this review, my nits are moot.
https://www.npmjs.com/package/mithril-stream is published from the I'd like to see those bundle steps broken out further so the command length stays short enough to be readable. This is starting to feel just creaky enough that it maybe should lead to some reworking of the bundling stuff in general. Especially in regards to |
This might get beyond the scope of what I can or should be doing, so feel free to re-do the PR. :) |
Or better, maybe factor this out into a Node script? We're getting to the point ShellJS is starting to seem attractive IMHO. Easier to maintain, and we can do more. Plus, it remains platform-independent, which shell scripts and npm scripts are not. |
An added bonus running for ShellJS is that it comes with this useful ultra-basic task runner in the form of |
Personally I don't mind lots of short, atomic npm scripts and then I use npm-run-all to combine them. In sequence or in parallel as needed. |
I prefer npm scripts where possible, with a smattering of custom build scripts where necessary. ShellJS is a great tool for those custom build scripts for sure. I don't really have the time for a big rework right now, so this sort of change is probably fine so long as it puts the files in the correct directory. |
To publish IMHO It would be easier to deprecate the
Would also need an answer for #1832 (comment) before I can proceed. |
I guess one other option would be to leave But this is a little different than how the top level package.json main points to |
@tivac @isiahmeadows Just bumping this PR thread. To review - I'm uncertain what the desired layout and what files should be consumed when a user bundles mithril & stream. Currently, using require/import you get the pre-bundled Was also hoping to provide nice paths for usage in jsbins via unpkg.com. If I have some clarity on the desired file layout I could get back on this. |
I approved as my concerns are now moot. |
I've updated the bundler cli script to only update the readme when building mithril.min.js (not stream.min.js.) That said, was doing some testing before that and noticed that the size wasn't being updated anyway. I think the regex isn't matching. |
@spacejack If you could fix the regexp problem (could be in either one) in this PR, that'd be great. @tivac Any other blockers to merging the PR itself? So far, I don't see any. (We can still continue discussion, though.) |
Ok, the regex now updates the reported gzip sizes in the readme. Minor edit so it could update both places. |
Sorry @spacejack, I stomped all over this with #1898. I think we should fix the stream stuff in a more holistic way (#1875), but I'll cut new |
will be fixed with #2753 |
Following up on #1831
Took a stab at adding bundler scripts for stream, so consider this a rough draft. :) I'm not sure this won't break anything... but the tests still run ok.
This removes the old top-level stub stream.js and replaces it with a bundled output (analogous to mithril.js and mithril.min.js.)
Note that I also changed the build script from:
to:
IMHO I would add the
npm-run-all
module so that the dev scripts could become: