Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vue-server-renderer

Package Overview
Dependencies
Maintainers
2
Versions
147
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue-server-renderer - npm Package Compare versions

Comparing version 2.6.14 to 2.7.0-alpha.1

LICENSE

6

client-plugin.d.ts

@@ -1,3 +0,3 @@

import { WebpackPlugin } from './types/plugin';
declare const Plugin: WebpackPlugin;
export = Plugin;
import { WebpackPlugin } from './types/plugin'
declare const Plugin: WebpackPlugin
export = Plugin
'use strict';
/* */
Object.freeze({});
/**
* Make a map and return a function for checking if a key
* is in that map.
*/
function makeMap(str, expectsLowerCase) {
var map = Object.create(null);
var list = str.split(',');
for (var i = 0; i < list.length; i++) {
map[list[i]] = true;
}
return expectsLowerCase ? function (val) { return map[val.toLowerCase()]; } : function (val) { return map[val]; };
}
/**
* Check if a tag is a built-in tag.
*/
makeMap('slot,component', true);
/**
* Check if an attribute is a reserved attribute.
*/
makeMap('key,ref,slot,slot-scope,is');
makeMap('accept,accept-charset,accesskey,action,align,alt,async,autocomplete,' +
'autofocus,autoplay,autosave,bgcolor,border,buffered,challenge,charset,' +
'checked,cite,class,code,codebase,color,cols,colspan,content,' +
'contenteditable,contextmenu,controls,coords,data,datetime,default,' +
'defer,dir,dirname,disabled,download,draggable,dropzone,enctype,for,' +
'form,formaction,headers,height,hidden,high,href,hreflang,http-equiv,' +
'icon,id,ismap,itemprop,keytype,kind,label,lang,language,list,loop,low,' +
'manifest,max,maxlength,media,method,GET,POST,min,multiple,email,file,' +
'muted,name,novalidate,open,optimum,pattern,ping,placeholder,poster,' +
'preload,radiogroup,readonly,rel,required,reversed,rows,rowspan,sandbox,' +
'scope,scoped,seamless,selected,shape,size,type,text,password,sizes,span,' +
'spellcheck,src,srcdoc,srclang,srcset,start,step,style,summary,tabindex,' +
'target,title,usemap,value,width,wrap');
var isJS = function (file) { return /\.js(\?[^.]+)?$/.test(file); };
var isCSS = function (file) { return /\.css(\?[^.]+)?$/.test(file); };
var ref = require('chalk');
var red = ref.red;
var yellow = ref.yellow;
var _a = require('chalk'), red = _a.red, yellow = _a.yellow;
var webpack = require('webpack');
var prefix = "[vue-server-renderer-webpack-plugin]";
var warn = exports.warn = function (msg) { return console.error(red((prefix + " " + msg + "\n"))); };
var tip = exports.tip = function (msg) { return console.log(yellow((prefix + " " + msg + "\n"))); };
(exports.warn = function (msg) { return console.error(red("".concat(prefix, " ").concat(msg, "\n"))); });
(exports.tip = function (msg) { return console.log(yellow("".concat(prefix, " ").concat(msg, "\n"))); });
var isWebpack5 = !!(webpack.version && webpack.version[0] > 4);
var onEmit = function (compiler, name, stageName, hook) {
if (isWebpack5) {
// Webpack >= 5.0.0
compiler.hooks.compilation.tap(name, function (compilation) {
if (compilation.compiler !== compiler) {
// Ignore child compilers
return
}
var stage = webpack.Compilation[stageName];
compilation.hooks.processAssets.tapAsync({ name: name, stage: stage }, function (assets, cb) {
hook(compilation, cb);
});
});
} else if (compiler.hooks) {
// Webpack >= 4.0.0
compiler.hooks.emit.tapAsync(name, hook);
} else {
// Webpack < 4.0.0
compiler.plugin('emit', hook);
}
if (isWebpack5) {
// Webpack >= 5.0.0
compiler.hooks.compilation.tap(name, function (compilation) {
if (compilation.compiler !== compiler) {
// Ignore child compilers
return;
}
var stage = webpack.Compilation[stageName];
compilation.hooks.processAssets.tapAsync({ name: name, stage: stage }, function (assets, cb) {
hook(compilation, cb);
});
});
}
else if (compiler.hooks) {
// Webpack >= 4.0.0
compiler.hooks.emit.tapAsync(name, hook);
}
else {
// Webpack < 4.0.0
compiler.plugin('emit', hook);
}
};
var stripModuleIdHash = function (id) {
if (isWebpack5) {
// Webpack >= 5.0.0
return id.replace(/\|\w+$/, '')
}
// Webpack < 5.0.0
return id.replace(/\s\w+$/, '')
if (isWebpack5) {
// Webpack >= 5.0.0
return id.replace(/\|\w+$/, '');
}
// Webpack < 5.0.0
return id.replace(/\s\w+$/, '');
};
var getAssetName = function (asset) {
if (typeof asset === 'string') {
return asset
}
return asset.name
if (typeof asset === 'string') {
return asset;
}
return asset.name;
};

@@ -60,69 +87,66 @@

var uniq = require('lodash.uniq');
var VueSSRClientPlugin = function VueSSRClientPlugin (options) {
if ( options === void 0 ) options = {};
this.options = Object.assign({
filename: 'vue-ssr-client-manifest.json'
}, options);
};
VueSSRClientPlugin.prototype.apply = function apply (compiler) {
var this$1 = this;
var stage = 'PROCESS_ASSETS_STAGE_ADDITIONAL';
onEmit(compiler, 'vue-client-plugin', stage, function (compilation, cb) {
var stats = compilation.getStats().toJson();
var allFiles = uniq(stats.assets
.map(function (a) { return a.name; }));
var initialFiles = uniq(Object.keys(stats.entrypoints)
.map(function (name) { return stats.entrypoints[name].assets; })
.reduce(function (assets, all) { return all.concat(assets); }, [])
.map(getAssetName)
.filter(function (file) { return isJS(file) || isCSS(file); }));
var asyncFiles = allFiles
.filter(function (file) { return isJS(file) || isCSS(file); })
.filter(function (file) { return initialFiles.indexOf(file) < 0; });
var manifest = {
publicPath: stats.publicPath,
all: allFiles,
initial: initialFiles,
async: asyncFiles,
modules: { /* [identifier: string]: Array<index: number> */ }
};
var assetModules = stats.modules.filter(function (m) { return m.assets.length; });
var fileToIndex = function (asset) { return manifest.all.indexOf(getAssetName(asset)); };
stats.modules.forEach(function (m) {
// ignore modules duplicated in multiple chunks
if (m.chunks.length === 1) {
var cid = m.chunks[0];
var chunk = stats.chunks.find(function (c) { return c.id === cid; });
if (!chunk || !chunk.files) {
return
}
var id = stripModuleIdHash(m.identifier);
var files = manifest.modules[hash(id)] = chunk.files.map(fileToIndex);
// find all asset modules associated with the same chunk
assetModules.forEach(function (m) {
if (m.chunks.some(function (id) { return id === cid; })) {
files.push.apply(files, m.assets.map(fileToIndex));
}
var VueSSRClientPlugin = /** @class */ (function () {
function VueSSRClientPlugin(options) {
if (options === void 0) { options = {}; }
//@ts-expect-error no type on options
this.options = Object.assign({
filename: 'vue-ssr-client-manifest.json'
}, options);
}
VueSSRClientPlugin.prototype.apply = function (compiler) {
var _this = this;
var stage = 'PROCESS_ASSETS_STAGE_ADDITIONAL';
onEmit(compiler, 'vue-client-plugin', stage, function (compilation, cb) {
var stats = compilation.getStats().toJson();
var allFiles = uniq(stats.assets.map(function (a) { return a.name; }));
var initialFiles = uniq(Object.keys(stats.entrypoints)
.map(function (name) { return stats.entrypoints[name].assets; })
.reduce(function (assets, all) { return all.concat(assets); }, [])
.map(getAssetName)
.filter(function (file) { return isJS(file) || isCSS(file); }));
var asyncFiles = allFiles
.filter(function (file) { return isJS(file) || isCSS(file); })
.filter(function (file) { return initialFiles.indexOf(file) < 0; });
var manifest = {
publicPath: stats.publicPath,
all: allFiles,
initial: initialFiles,
async: asyncFiles,
modules: {
/* [identifier: string]: Array<index: number> */
}
};
var assetModules = stats.modules.filter(function (m) { return m.assets.length; });
var fileToIndex = function (asset) { return manifest.all.indexOf(getAssetName(asset)); };
stats.modules.forEach(function (m) {
// ignore modules duplicated in multiple chunks
if (m.chunks.length === 1) {
var cid_1 = m.chunks[0];
var chunk = stats.chunks.find(function (c) { return c.id === cid_1; });
if (!chunk || !chunk.files) {
return;
}
var id = stripModuleIdHash(m.identifier);
var files_1 = (manifest.modules[hash(id)] =
chunk.files.map(fileToIndex));
// find all asset modules associated with the same chunk
assetModules.forEach(function (m) {
if (m.chunks.some(function (id) { return id === cid_1; })) {
files_1.push.apply(files_1, m.assets.map(fileToIndex));
}
});
}
});
var json = JSON.stringify(manifest, null, 2);
//@ts-expect-error no type on options
compilation.assets[_this.options.filename] = {
source: function () { return json; },
size: function () { return json.length; }
};
cb();
});
}
});
var json = JSON.stringify(manifest, null, 2);
compilation.assets[this$1.options.filename] = {
source: function () { return json; },
size: function () { return json.length; }
};
cb();
});
};
return VueSSRClientPlugin;
}());
module.exports = VueSSRClientPlugin;

@@ -10,5 +10,11 @@ try {

'\n\nVue packages version mismatch:\n\n' +
'- vue@' + vueVersion + '\n' +
'- ' + packageName + '@' + packageVersion + '\n\n' +
'This may cause things to work incorrectly. Make sure to use the same version for both.\n'
'- vue@' +
vueVersion +
'\n' +
'- ' +
packageName +
'@' +
packageVersion +
'\n\n' +
'This may cause things to work incorrectly. Make sure to use the same version for both.\n'
)

@@ -15,0 +21,0 @@ }

{
"name": "vue-server-renderer",
"version": "2.6.14",
"version": "2.7.0-alpha.1",
"description": "server renderer for Vue 2.0",

@@ -16,2 +16,7 @@ "main": "index.js",

],
"files": [
"types/*.d.ts",
"*.js",
"*.d.ts"
],
"author": "Evan You",

@@ -23,15 +28,18 @@ "license": "MIT",

"dependencies": {
"chalk": "^1.1.3",
"hash-sum": "^1.0.2",
"he": "^1.1.0",
"chalk": "^4.0.0",
"hash-sum": "^2.0.0",
"he": "^1.2.0",
"lodash.template": "^4.5.0",
"lodash.uniq": "^4.5.0",
"resolve": "^1.2.0",
"serialize-javascript": "^3.1.0",
"resolve": "^1.22.0",
"serialize-javascript": "^6.0.0",
"source-map": "0.5.6"
},
"devDependencies": {
"vue": "file:../.."
"memory-fs": "^0.5.0",
"vue": "file:../..",
"webpack": "^4.46.0",
"file-loader": "^3.0.1"
},
"homepage": "https://github.com/vuejs/vue/tree/dev/packages/vue-server-renderer#readme"
}
}

@@ -1,3 +0,3 @@

import { WebpackPlugin } from './types/plugin';
declare const Plugin: WebpackPlugin;
export = Plugin;
import { WebpackPlugin } from './types/plugin'
declare const Plugin: WebpackPlugin
export = Plugin
'use strict';
/* */
Object.freeze({});
/**
* Make a map and return a function for checking if a key
* is in that map.
*/
function makeMap(str, expectsLowerCase) {
var map = Object.create(null);
var list = str.split(',');
for (var i = 0; i < list.length; i++) {
map[list[i]] = true;
}
return expectsLowerCase ? function (val) { return map[val.toLowerCase()]; } : function (val) { return map[val]; };
}
/**
* Check if a tag is a built-in tag.
*/
makeMap('slot,component', true);
/**
* Check if an attribute is a reserved attribute.
*/
makeMap('key,ref,slot,slot-scope,is');
makeMap('accept,accept-charset,accesskey,action,align,alt,async,autocomplete,' +
'autofocus,autoplay,autosave,bgcolor,border,buffered,challenge,charset,' +
'checked,cite,class,code,codebase,color,cols,colspan,content,' +
'contenteditable,contextmenu,controls,coords,data,datetime,default,' +
'defer,dir,dirname,disabled,download,draggable,dropzone,enctype,for,' +
'form,formaction,headers,height,hidden,high,href,hreflang,http-equiv,' +
'icon,id,ismap,itemprop,keytype,kind,label,lang,language,list,loop,low,' +
'manifest,max,maxlength,media,method,GET,POST,min,multiple,email,file,' +
'muted,name,novalidate,open,optimum,pattern,ping,placeholder,poster,' +
'preload,radiogroup,readonly,rel,required,reversed,rows,rowspan,sandbox,' +
'scope,scoped,seamless,selected,shape,size,type,text,password,sizes,span,' +
'spellcheck,src,srcdoc,srclang,srcset,start,step,style,summary,tabindex,' +
'target,title,usemap,value,width,wrap');
var isJS = function (file) { return /\.js(\?[^.]+)?$/.test(file); };
var ref = require('chalk');
var red = ref.red;
var yellow = ref.yellow;
var _a = require('chalk'), red = _a.red, yellow = _a.yellow;
var webpack = require('webpack');
var prefix = "[vue-server-renderer-webpack-plugin]";
var warn = exports.warn = function (msg) { return console.error(red((prefix + " " + msg + "\n"))); };
var tip = exports.tip = function (msg) { return console.log(yellow((prefix + " " + msg + "\n"))); };
var warn = (exports.warn = function (msg) { return console.error(red("".concat(prefix, " ").concat(msg, "\n"))); });
var tip = (exports.tip = function (msg) { return console.log(yellow("".concat(prefix, " ").concat(msg, "\n"))); });
var isWebpack5 = !!(webpack.version && webpack.version[0] > 4);
var validate = function (compiler) {
if (compiler.options.target !== 'node') {
warn('webpack config `target` should be "node".');
}
if (compiler.options.output) {
if (compiler.options.output.library) {
// Webpack >= 5.0.0
if (compiler.options.output.library.type !== 'commonjs2') {
warn('webpack config `output.library.type` should be "commonjs2".');
}
} else if (compiler.options.output.libraryTarget !== 'commonjs2') {
// Webpack < 5.0.0
warn('webpack config `output.libraryTarget` should be "commonjs2".');
if (compiler.options.target !== 'node') {
warn('webpack config `target` should be "node".');
}
}
if (!compiler.options.externals) {
tip(
'It is recommended to externalize dependencies in the server build for ' +
'better build performance.'
);
}
if (compiler.options.output) {
if (compiler.options.output.library) {
// Webpack >= 5.0.0
if (compiler.options.output.library.type !== 'commonjs2') {
warn('webpack config `output.library.type` should be "commonjs2".');
}
}
else if (compiler.options.output.libraryTarget !== 'commonjs2') {
// Webpack < 5.0.0
warn('webpack config `output.libraryTarget` should be "commonjs2".');
}
}
if (!compiler.options.externals) {
tip('It is recommended to externalize dependencies in the server build for ' +
'better build performance.');
}
};
var onEmit = function (compiler, name, stageName, hook) {
if (isWebpack5) {
// Webpack >= 5.0.0
compiler.hooks.compilation.tap(name, function (compilation) {
if (compilation.compiler !== compiler) {
// Ignore child compilers
return
}
var stage = webpack.Compilation[stageName];
compilation.hooks.processAssets.tapAsync({ name: name, stage: stage }, function (assets, cb) {
hook(compilation, cb);
});
});
} else if (compiler.hooks) {
// Webpack >= 4.0.0
compiler.hooks.emit.tapAsync(name, hook);
} else {
// Webpack < 4.0.0
compiler.plugin('emit', hook);
}
if (isWebpack5) {
// Webpack >= 5.0.0
compiler.hooks.compilation.tap(name, function (compilation) {
if (compilation.compiler !== compiler) {
// Ignore child compilers
return;
}
var stage = webpack.Compilation[stageName];
compilation.hooks.processAssets.tapAsync({ name: name, stage: stage }, function (assets, cb) {
hook(compilation, cb);
});
});
}
else if (compiler.hooks) {
// Webpack >= 4.0.0
compiler.hooks.emit.tapAsync(name, hook);
}
else {
// Webpack < 4.0.0
compiler.plugin('emit', hook);
}
};
var getAssetName = function (asset) {
if (typeof asset === 'string') {
return asset
}
return asset.name
if (typeof asset === 'string') {
return asset;
}
return asset.name;
};
var VueSSRServerPlugin = function VueSSRServerPlugin (options) {
if ( options === void 0 ) options = {};
this.options = Object.assign({
filename: 'vue-ssr-server-bundle.json'
}, options);
};
VueSSRServerPlugin.prototype.apply = function apply (compiler) {
var this$1 = this;
validate(compiler);
var stage = 'PROCESS_ASSETS_STAGE_OPTIMIZE_TRANSFER';
onEmit(compiler, 'vue-server-plugin', stage, function (compilation, cb) {
var stats = compilation.getStats().toJson();
var entryName = Object.keys(stats.entrypoints)[0];
var entryInfo = stats.entrypoints[entryName];
if (!entryInfo) {
// #5553
return cb()
var VueSSRServerPlugin = /** @class */ (function () {
function VueSSRServerPlugin(options) {
if (options === void 0) { options = {}; }
//@ts-expect-error
this.options = Object.assign({
filename: 'vue-ssr-server-bundle.json'
}, options);
}
var entryAssets = entryInfo.assets
.map(getAssetName)
.filter(isJS);
if (entryAssets.length > 1) {
throw new Error(
"Server-side bundle should have one single entry file. " +
"Avoid using CommonsChunkPlugin in the server config."
)
}
var entry = entryAssets[0];
if (!entry || typeof entry !== 'string') {
throw new Error(
("Entry \"" + entryName + "\" not found. Did you specify the correct entry option?")
)
}
var bundle = {
entry: entry,
files: {},
maps: {}
VueSSRServerPlugin.prototype.apply = function (compiler) {
var _this = this;
validate(compiler);
var stage = 'PROCESS_ASSETS_STAGE_OPTIMIZE_TRANSFER';
onEmit(compiler, 'vue-server-plugin', stage, function (compilation, cb) {
var stats = compilation.getStats().toJson();
var entryName = Object.keys(stats.entrypoints)[0];
var entryInfo = stats.entrypoints[entryName];
if (!entryInfo) {
// #5553
return cb();
}
var entryAssets = entryInfo.assets.map(getAssetName).filter(isJS);
if (entryAssets.length > 1) {
throw new Error("Server-side bundle should have one single entry file. " +
"Avoid using CommonsChunkPlugin in the server config.");
}
var entry = entryAssets[0];
if (!entry || typeof entry !== 'string') {
throw new Error("Entry \"".concat(entryName, "\" not found. Did you specify the correct entry option?"));
}
var bundle = {
entry: entry,
files: {},
maps: {}
};
Object.keys(compilation.assets).forEach(function (name) {
if (isJS(name)) {
bundle.files[name] = compilation.assets[name].source();
}
else if (name.match(/\.js\.map$/)) {
bundle.maps[name.replace(/\.map$/, '')] = JSON.parse(compilation.assets[name].source());
}
// do not emit anything else for server
delete compilation.assets[name];
});
var json = JSON.stringify(bundle, null, 2);
//@ts-expect-error
var filename = _this.options.filename;
compilation.assets[filename] = {
source: function () { return json; },
size: function () { return json.length; }
};
cb();
});
};
return VueSSRServerPlugin;
}());
Object.keys(compilation.assets).forEach(function (name) {
if (isJS(name)) {
bundle.files[name] = compilation.assets[name].source();
} else if (name.match(/\.js\.map$/)) {
bundle.maps[name.replace(/\.map$/, '')] = JSON.parse(compilation.assets[name].source());
}
// do not emit anything else for server
delete compilation.assets[name];
});
var json = JSON.stringify(bundle, null, 2);
var filename = this$1.options.filename;
compilation.assets[filename] = {
source: function () { return json; },
size: function () { return json.length; }
};
cb();
});
};
module.exports = VueSSRServerPlugin;

@@ -1,50 +0,53 @@

import Vue, { VNode, VNodeDirective } from 'vue';
import { Readable } from 'stream';
import Vue, { VNode, VNodeDirective } from 'vue'
import { Readable } from 'stream'
export declare function createRenderer(options?: RendererOptions): Renderer;
export declare function createRenderer(options?: RendererOptions): Renderer
export declare function createBundleRenderer(bundle: string | object, options?: BundleRendererOptions): BundleRenderer;
export declare function createBundleRenderer(
bundle: string | object,
options?: BundleRendererOptions
): BundleRenderer
type RenderCallback = (err: Error | null, html: string) => void;
type RenderCallback = (err: Error | null, html: string) => void
interface Renderer {
renderToString(vm: Vue, callback: RenderCallback): void;
renderToString(vm: Vue, context: object, callback: RenderCallback): void;
renderToString(vm: Vue): Promise<string>;
renderToString(vm: Vue, context: object): Promise<string>;
renderToString(vm: Vue, callback: RenderCallback): void
renderToString(vm: Vue, context: object, callback: RenderCallback): void
renderToString(vm: Vue): Promise<string>
renderToString(vm: Vue, context: object): Promise<string>
renderToStream(vm: Vue, context?: object): Readable;
renderToStream(vm: Vue, context?: object): Readable
}
interface BundleRenderer {
renderToString(callback: RenderCallback): void;
renderToString(context: object, callback: RenderCallback): void;
renderToString(): Promise<string>;
renderToString(context: object): Promise<string>;
renderToString(callback: RenderCallback): void
renderToString(context: object, callback: RenderCallback): void
renderToString(): Promise<string>
renderToString(context: object): Promise<string>
renderToStream(context?: object): Readable;
renderToStream(context?: object): Readable
}
interface RendererOptions {
template?: string;
inject?: boolean;
shouldPreload?: (file: string, type: string) => boolean;
shouldPrefetch?: (file: string, type: string) => boolean;
cache?: RenderCache;
template?: string
inject?: boolean
shouldPreload?: (file: string, type: string) => boolean
shouldPrefetch?: (file: string, type: string) => boolean
cache?: RenderCache
directives?: {
[key: string]: (vnode: VNode, dir: VNodeDirective) => void
};
}
}
interface BundleRendererOptions extends RendererOptions {
clientManifest?: object;
serializer?: (state: object) => string;
runInNewContext?: boolean | 'once';
basedir?: string;
clientManifest?: object
serializer?: (state: object) => string
runInNewContext?: boolean | 'once'
basedir?: string
}
interface RenderCache {
get: (key: string, cb?: (res: string) => void) => string | void;
set: (key: string, val: string) => void;
has?: (key: string, cb?: (hit: boolean) => void) => boolean | void;
get: (key: string, cb?: (res: string) => void) => string | void
set: (key: string, val: string) => void
has?: (key: string, cb?: (hit: boolean) => void) => boolean | void
}

@@ -1,9 +0,11 @@

import { Plugin } from 'webpack';
import { DefinePlugin } from 'webpack'
interface WebpackPluginOptions {
filename?: string;
filename?: string
}
export interface WebpackPlugin {
new (options?: WebpackPluginOptions): Plugin;
// NOTE NOT SURE ABOUT THIS
// TODO DOUBLE CHECK HERE
new (options?: WebpackPluginOptions): DefinePlugin
}

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc