Replies: 18 comments
-
It would be possible if we altered the bundle to optionally emit an ES module and export it instead. Do note that it would most likely default-export the |
Beta Was this translation helpful? Give feedback.
-
I think I brought up this issue inside the chat room couple of months ago. I was advised to use syntax like this import m from "mithril/hyperscript";
import render from "mithril/render"; |
Beta Was this translation helpful? Give feedback.
-
I would personally just advise in the meantime using Rollup's |
Beta Was this translation helpful? Give feedback.
-
If we're gonna do this it should go all the way. I haven't tried converting everything to ES Modules + |
Beta Was this translation helpful? Give feedback.
-
Added to the |
Beta Was this translation helpful? Give feedback.
-
@tivac The current bundler still has the advantage that the |
Beta Was this translation helpful? Give feedback.
-
Long term I think we should focus on integration-testing via the public APIs instead of the more tightly-scoped tests we have now. They're sometimes harder to write up-front but we end up with better guarantees of API-correctness. That shift would mean all tests could use the bundle for testing instead of needing to support piecemeal usage. Investigating ES Modules is solely in the "experimental" phase right now, I added the milestone o try and ensure that I experiment w/ it again before too much longer. |
Beta Was this translation helpful? Give feedback.
-
A more complete port of mithril's internals to ES Modules would probably yield smaller overall app bundles when factoring in tree-shaking. It'd require a lot of refactoring & removing of the way current APIs work though. While I appreciate the way the framework has been broken up into discrete chunks, I do wonder if some of the files that enable piecemeal usage could be dropped entirely. This is anecdata at it's finest, but has anyone ever heard of someone actually using anything other than the default |
Beta Was this translation helpful? Give feedback.
-
Aren't there at least a few people on gitter (names escape me) that are using mainly the |
Beta Was this translation helpful? Give feedback.
-
@tivac Just out of curiosity, what's the Rollup bundle look like? Regarding improving the port:
* Of course, on a "you're on your own" basis, where it may change even across patch versions. |
Beta Was this translation helpful? Give feedback.
-
I agree with @orbitbot above. We also use just hyperscript and render from Mithril. |
Beta Was this translation helpful? Give feedback.
-
@gyandeeps the Promise polyfill is there to have Mithril work out of the box in IE9-11. IE 11 is still relevant, and not everyone uses Babel or polyfills. Being able to get started with Mithril without other deps is IMO an important feature |
Beta Was this translation helpful? Give feedback.
-
Which I dont disagree with. But today, people who use libraries like react and mithril in production tend to use polyfill libraries. That when we have repeated code. Thats why I suggested that their should be a way to ignore it. Most of the libraries today avoid carrying polyfills with them because then you are having duplicates. |
Beta Was this translation helpful? Give feedback.
-
I would like to exclude the full polyfill from the bundle, and instead have a small shim layer that can either return a reference to It increases friction a tiny bit for IE users, but it'd be part of a major version bump and then means that every other environment would be running less code. That'd improve both our download and parsing time, improving overall startup. |
Beta Was this translation helpful? Give feedback.
-
I'd love to use mithril with rollup to only include the code and functions I actually use. In particular, I often don't use routing, the request code or the polyfill. Consider hybrid apps or other apps that only support a small set of browser engines. |
Beta Was this translation helpful? Give feedback.
-
So our new plan is to revert our initial design (#2366) and instead expose the ES module source under Mirroring everything via |
Beta Was this translation helpful? Give feedback.
-
Here's a +1 so you guys are encouraged to treat this issue as more of a priority... |
Beta Was this translation helpful? Give feedback.
-
Here's the status: we're waiting for someone to file a PR for something like this. There's two reasons why this is low-priority currently:
Once I resolve the first, then I'll look into this. |
Beta Was this translation helpful? Give feedback.
-
ES Modules have landed under flags in all browsers, so it would be great if we could get a build of mithril that supports it.
Being able to
import { m, request, route, promise } from './mithril.js'
would be great.Beta Was this translation helpful? Give feedback.
All reactions