app.current, app.previous, cleanup Page classes #2156 @askvortsov1app.search: #2151 @askvortsov1app.cache.discussionList: #2150 @askvortsov1app.alerts #2163 @askvortsov1app.modal #2162 @askvortsov1app.composer #2161 @askvortsov1CommentPost stores PostUser #2184 @askvortsov1route patch, update core and bundled to use a Link component - https://github.com/flarum/core/pull/2315console.warn for BC layer - https://github.com/flarum/core/pull/2313See https://github.com/flarum/core/pull/1950.
@flarum/typesmoment with alternative such as dayjsjQuery with alternative such as zeptobootstrap, replace with component alternatives where necessarymicromodaltooltip.jstooltip.jshtml5sortable with dragulaImportant thing to note is to not change too much, we already had a big change with webpack.
Some work has been done on the ds/frontend-framework-rewrite branch.
Bootstrap's affix plugin, moment, jquery, jquery.hotkeys have all been replaced with alternatives.
moment has been replaced with dayjs, but kept globally so language packs require minimal to no changes to continue workingjquery replaced with zepto, some issues with compatibility and missing features (specially animations, hopefully tackling that right now)jquery.hotkeys replaced with mousetrap, popular + easy to useFinding alternatives for the rest of the bootstrap plugins has been a bit hard, so no progress has been made on any others yet. Mainly testing + failing. However, we might be able to use some of them with Zepto (some patches needed, but not hard).
Haven't touched Mithril v2 or TypeScript yet (excluding some testing done with both previously).
The built dist files have gone down to 268K (forum) and 188K (admin) from 356K and 276K respectively.
Why use some outdated libraries such as: zepto, jump.js, so the library has not been updated for a long time.
I'm not convinced about Zepto either. What's the reason behind that choice? Is it only for the reduced size of the library? I'm not seeing any other advantage, as it seems it hasn't been updated for 3 years, and others have dropped it for performance reasons. Plus I think it could create issues with extensions that rely on jQuery being available.
@yulei745 @matteocontrini
In a best case scenario, we wouldn't need jQuery at all to do what we want. However, as we probably don't want to reinvent the wheel, we use plugins that chose jQuery for easier coding instead of native implementations. By switching to Zepto, we can minimize the impact jQuery has on the bundle size and maintain compatibility with some jQuery plugins with some patches to Zepto (see js/src/common/utils/patchZepto.js).
I don't think performance is much of a concern here as jQuery is only used when necessary (and could probably be removed completely with some work). And we don't really take advantage of many of the features jQuery has to offer, most of which can be done better natively (http://youmightnotneedjquery.com/), apart from IE 11 support.
Extensions that rely on jQuery being available will still probably work, unless they use complex selectors not supported by Zepto. Besides, this is a rewrite, and while I am trying to make everything as backwards-compatible as possible, there will be breaking changes. We are on beta versions after all 馃し鈥嶁檪.
And a library doesn't necessarily have to be recent to work well. The issues that jump.js has in its repository really don't concern our use case, and mostly seem to be feature requests anyhow. I tested a few smooth scrolling methods before finding one that worked well for Flarum's use case.
Hopefully that answered some of your questions 馃檪.
I am looking forward to updating to mithril.js v2, but I don't know what I can do.
@yulei745
I don't know what I can do.
Do you mean to help out with the development, or in terms of extensions ? This isn't a priority, so if you do want to help with Flarum development, please do look at issues in the beta 10 milestone 馃檪.
Some more work has been done.
micromodaltooltip.jstooltip.js as it relies on popper.js, which is a very advanced library compared to our needs, meaning bigger bundle size (+20kb)Build dist files have gone up by 20K each, now 288K (forum) and 208K (admin).
I have started on Mithril v2 and Typescript. The best way to do this, after a few failures, is to start from scratch and bring in existing JS files one by one - i.e. convert files to typescript & mithril v2 as they are brought in. Thanks to @clarkwinkelmann for his help during this as well.
We'll probably want to make our Component class as close to Mithril's components, so those docs can be followed. However, we have introduced a few improvements such as:
this.props continues to existinitProps and prevent needing to pass vnode/vnode.attrs to every single functionComponent.component remainsvnode instead of simply the attributes/props<Component prop="value" />) or .component call (Component.component({ prop: 'value' }))m under the hood, but its prettier :)m.prop stays, setting it to mithril/stream to keep old functionalitym.withAttr manually added, as it was removed from mithril but is a useful helperSome different things that we've decided not to make backwards compatible / keep the old structure for:
init and config have now been replaced with mithril's new lifecycle hooks (oninit, oncreate, onbeforeupdate, onupdate, onbeforeremove, and onremove), see https://mithril.js.org/lifecycle-methods.html for more info on themm.route has changedOn the side of TypeScript, I've tried to make it so developers can prevent errors by making component props a type (optional). Sadly, it doesn't work with .component as that's a static method, but it works with this.props. It's not very pretty, but it is optional so 馃し鈥嶁檪. Feedback on this welcome.
The types & interfaces do not take up any compiled dist space (they appear as empty lines) so that's great 馃檪.
export type ComponentProps = {
children?: Mithril.Children,
className?: string;
}
export default class Component<T extends ComponentProps = any> {
protected props = <T> {};
}
export interface ButtonProps extends ComponentProps {
title?: string,
type?: string,
icon?: string,
loading?: boolean,
disabled?: boolean,
onclick?: Function
}
export default class Button<T extends ButtonProps = ButtonProps> extends Component<T> {}
I have pushed the code I have so far to ds/frontend-framework-rewrite-mithril and flarum-webpack-config@ds/frontend-framework-rewrite.
There's an old folder in js that just contains the plain JS files from the frontend framework rewrite (w/o mithril v2 & typescript). I just use it when moving files to TypeScript.
I have added a markdown file to the root of the branch that contains some of the changes that have been made to the class structures & methods (exlcluding mithril v2 and typescript).
Haven't set up typings yet for flarum/core (and definitely not extensions 馃檲), including thinking of how they will be generated, published, etc... and the global shims are a bit of a mess, at least with PhpStorm not liking them but recognizing them (???, I don't know TypeScript typings don't do this to me)
This is basically what I have right now.

I'll probably configure prettier at some point to fix the atrocious linting mistakes I'm committing when copy pasting coding.
Dist files are currently 196K (forum) and 132K (admin). Of course, it barely includes any of the classes necessary for Flarum to function like a forum. 馃榿
Progress on the Mithril rewrite, excluding components / utils / helpers that still have to be copied over.
Outdated checklist removed. See OP for recent updates. /Franz
As per today's kickoff meeting, here's the proposed roadmap for the remainder of this rewrite. The goal here is to have maximally modular PRs, so that history is as clean as possible. Plan is as follows:
Outdated checklist removed. See OP for recent updates. /Franz
A possible animation library replacement would be http://velocityjs.org/
And instead of Zepto, cash (or cash-dom in NPM) seems like a better, more updated alternative.
See https://github.com/flarum/core/pull/2255 for Mithril 2 updates
Consider replacing classList with https://www.npmjs.com/package/classnames?
Can someone distill every todo from this issue (and other issues) for the rewrite into the OP of this issue and include this checklist to signify rewriting bundled extension progress:
- [ ] akismet
- [ ] approval
- [ ] auth-facebook
- [ ] auth-github
- [ ] auth-twitter
- [ ] bbcode
- [ ] embed
- [ ] emoji
- [ ] flags
- [ ] likes
- [ ] lock
- [ ] markdown
- [ ] mentions
- [ ] pusher
- [ ] statistics
- [ ] sticky
- [ ] subscriptions
- [ ] suspend
- [ ] tags
What I did:
I've started ticking the boxes for the extensions where the Mithril 2.0 upgrades are ready to be merged. Note that we will only merge these once the upgrade in core has been merged.
Most helpful comment
Some work has been done on the ds/frontend-framework-rewrite branch.
Bootstrap's affix plugin,
moment,jquery,jquery.hotkeyshave all been replaced with alternatives.momenthas been replaced withdayjs, but kept globally so language packs require minimal to no changes to continue workingjqueryreplaced withzepto, some issues with compatibility and missing features (specially animations, hopefully tackling that right now)jquery.hotkeysreplaced withmousetrap, popular + easy to useFinding alternatives for the rest of the bootstrap plugins has been a bit hard, so no progress has been made on any others yet. Mainly testing + failing. However, we might be able to use some of them with Zepto (some patches needed, but not hard).
Haven't touched Mithril v2 or TypeScript yet (excluding some testing done with both previously).
The built dist files have gone down to 268K (forum) and 188K (admin) from 356K and 276K respectively.