npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

vue-server

v0.8.1

Published

Vue.js server side version

Downloads

27

Readme

VueServer.js

Vue.js server-side version

Disclaimer

This is not an offical Vue.js version and it has no straight relation to it and its author.

The module is developed for specific needs of its authors and has some restrictions compared to Vue.js.

Getting started

var vueServer = require('vue-server');
var Vue = new vueServer.renderer();

// For $root instance you should pass 'template' option instead of 'el'.
var vm = new Vue({
    template: '<common-module></common-module>',
    components: {
        commonModule: {
            template: '<div>Hello world!</div>'
        }
    }
});

vm.$on('vueServer.htmlReady', function(html) {
    console.log(html); // '<div>Hello world!</div>'
});

Compatibility table

| VueServer.js | Vue.js | | :------------ |:--------------- | | 0.4.x-0.6.x | 1.0.0-migration |

Restrictions

VueServer.js is designed for static HTML rendering. It has no real reactivity.

Also, the module is not running original Vue.js on server. It has its own implementation.

It means VueServer.js is just trying to perfectly reproduce the same result as Vue.js does.

Because of the reasons listed above some of Vue.js functionality is not available.

Hooks difference

VueServer.js does not share hooks with Vue.js. It has its own ones, partially equal to Vue.js'

Note: readyBe is a bit experimental and its behaviour may be not correct.

| VueServer.js | Vue.js | | :------------ |:------------- | | createdBe | created | | -- | beforeCompile | | compiledBe | compiled | | activateBe | activate | | readyBe | ready | | -- | attached | | -- | detached | | -- | beforeDestroy | | -- | destroyed |

List of unsupported methods:

  • vm.$watch
  • vm.$delete
  • vm.$eval
  • vm.$interpolate
  • vm.$appendTo
  • vm.$before
  • vm.$after
  • vm.$remove
  • vm.$mount
  • vm.$destroy
  • vm.$addChild

List of unsupported directives:

  • v-on
  • v-el

Because of using an extra light DOM version it's not possible to use custom directives too.

What is supported, then?

Well, actually, everything else is (maybe I forgot something).

It means you can use v-if, filters, partials, async components, wait-for (or activate hook), events etc.

Overall, it is possible to use the beloved complex component building system like in orignal Vue.js

Templates precompilation

It is recommended to precompile templates for faster rendering

var vueServer = require('vue-server');
var VueCompile = new vueServer.compiler();

var serverTemplate = VueCompile('<div>Hello world!</div>');

We've got a gulp.js plugin for that purpose. Soon it will be published too.

Configuration

var vueServer = require('vue-server');
var Vue = new vueServer.renderer();

// Original Vue.js options. Can be used with VueServer.js too:
Vue.config.replace = false;
Vue.config.debug = true;
Vue.config.silent = false;
Vue.config.strict = false;

// VueServer.js options.
// On warnings and errors you can pass additional information about your VM;
Vue.config.onLogMessage = function (vm) {
    if (vm.name) {
        return vm.name;
    } else {
        return '';
    }
};

Custom options

  • renderServer - accepts compiled template (a function from require('vue-server').compiler();)