r/javascript • u/ngDev • Jul 02 '17
help Want to build an SPA without using the framework (Angular, React, Vue). Please help to compose a stack
Hey folks,
I want to build a Single Page Application without using heavy frameworks, like Angular, React, Vue.
First of all, I would like to mention, that I want to make an SPA, not single page website, so routing is required. I will need contexts (for filtering and passing data) and so far Page.js seems like the best option: http://smalljs.org/client-side-routing/page/
Second of all, I am not opinionated about templating, as long as it has If, Elif, Repeats and such. Even LoDash/Underscore 's _.template() seems to work as for me.
For control flow I am thinking of async.js.
The last, but not the least, the data binding and states. I have bad experience with Redux and Flux since both involve a lot of template code copy-pasting, and to be honest, are confusing. I have much better experience with two-way data binding and MobX. I am also very keen for RxJS and Bacon.js, so if you know solutions working tightly with them, please note that fact.
Finally, as for the build system. I have experience with both Gulp and Webpack. With Webpack, I managed to setup it to work with ESLint, which helped a lot during development. Gulp, however is easier for understanding and seems to be much more lightweight (but again, I might be opinionated because I used webpack for Angular 2 and React bundling).
As for the front-end framework, it's best to use Bootstrap if any needed. It's easy to make a grid system and other components from zero, but sometimes rapid prototyping is needed.
jQuery is neither a problem.
Here are the requirements:
E2E tests
IE9+ support, so ES6 has to be transformed with Babel into ES5
HTML partials, since I plan to inline SVGs a lot.
2
u/lunfaii Jul 02 '17
Backbone is perfect! You can choose to use Marionette on top of it but I feel like Backbone, jQuery and Underscore/Lodash will be a fine combo for you.
1
u/ngDev Jul 03 '17
Yeah, I have checked it out recently and I like that it is tightly coupled with LoDash.
Also, the architecture looks good for me.
But I haven't checked the source code yet
6
Jul 02 '17
I would suggest trying hyperapp or preact, both are really lightweight frameworks with great support. Unless you want to build your SPA just to learn how to do it. To be honest, if you plan on using this for production, the implementation built by a single person is not going to beat any framework built by a community (unless it's a really good one, like hyperapp).
2
u/leeoniya Jul 02 '17 edited Jul 02 '17
2
u/ngDev Jul 02 '17
I seem to like DomVM and ReDom.
However, I was thinking about Riverts (http://rivetsjs.com/docs/guide/) or something like that + jQuery in EventEmitter - Listener pattern in functional programming flavour for refactoring simplicity.
5
u/leeoniya Jul 02 '17 edited Jul 02 '17
judging by your original post, it seems you're quite capable of evaluating what works best for you, so good luck!
15
u/carrot_gg Jul 02 '17
How on earth is Vue a "heavy" framework? A full-featured Vue project with Vuex + vue-router weights 30KB gzipped.
1
u/subvertallchris Jul 02 '17
Having worked in a place where the person in charge suffered terribly from NIHS, this sounds like you are headed down a frustrating path.
1
u/ngDev Jul 02 '17
Using jQuery instead of Angular or React or {{ insert_shiny_new_framework_name }} and some library to do the routing is NIHS.
6
u/digdic Jul 02 '17
this is a really bad idea, there's no reason to not use a framework on a production SPA
2
u/ccb621 Jul 02 '17
Naming semantics aside, you want to build your own frontend framework. Rather than tell you this is a bad idea, I would encourage you to research existing libraries and frameworks. Focus on what they get "right" and what they get "wrong" (according to whatever metric you decide). Can you build something that meets all of your needs cheaper—in terms of time spent developing now and debugging later—than it would take to use an existing framework and work around the things it got "wrong"? If so, go forth and build your own. If not, pick something that exists and build atop that foundation.
If you just want to learn how it all works, this exercise applies, but you'll want to dig deeper into the source code to see how the existing solutions work.
1
0
u/dragni Jul 02 '17
You should give Polymer a try, it's a lightweight library build on top of the webcomponent specifications. It has everything you need and relies heavily on the web platform as it is instead of custom framework code (https://www.polymer-project.org)
-1
u/ngDev Jul 02 '17
My colleague has had bad experience with it. Things get wild when more components are thrown in. Plus, polymer incorporates material design, meanwhile in my case, I get very specific design requirements :)
1
u/dragni Jul 02 '17
I think it depends on the way you build your component architecture. Polymer is used in production by some big companies for big projects (Google is using it for both Google Earth and the new YouTube for example). It just requires some more thought then a framework which often pushes you towards a specific architecture. Regarding the Material Design, that is indeed embedded in the paper elements created by the Polymer team. Polymer itself however has nothing to do with material design, there are loads of elements which are not using material design you could use (take a look at webcomponents.org)
1
u/ngDev Jul 02 '17
To be honest my post was not about going for exotics.
I wanted just to dich architecture-oriented frameworks, and try to build a stack from a couple of libraries. Going for polymer in my case is not going to be a good idea, since I am doing transition from well tested Angular, React, Vue to lesser-known framework, with less community support.
23
u/dbbk Jul 02 '17
Why would you want to do this? You'd be making your life really hard for no real reason.