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.7.0-alpha.7 to 2.7.0-alpha.8

105

client-plugin.js

@@ -9,8 +9,8 @@ 'use strict';

function makeMap(str, expectsLowerCase) {
var map = Object.create(null);
var list = str.split(',');
for (var i = 0; i < list.length; i++) {
const map = Object.create(null);
const list = str.split(',');
for (let i = 0; i < list.length; i++) {
map[list[i]] = true;
}
return expectsLowerCase ? function (val) { return map[val.toLowerCase()]; } : function (val) { return map[val]; };
return expectsLowerCase ? val => map[val.toLowerCase()] : val => map[val];
}

@@ -39,15 +39,15 @@ /**

'target,title,usemap,value,width,wrap');
var isJS = function (file) { return /\.js(\?[^.]+)?$/.test(file); };
var isCSS = function (file) { return /\.css(\?[^.]+)?$/.test(file); };
const isJS = (file) => /\.js(\?[^.]+)?$/.test(file);
const isCSS = (file) => /\.css(\?[^.]+)?$/.test(file);
var _a = require('chalk'), red = _a.red, yellow = _a.yellow;
var webpack = require('webpack');
var prefix = "[vue-server-renderer-webpack-plugin]";
(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) {
const { red, yellow } = require('chalk');
const webpack = require('webpack');
const prefix = `[vue-server-renderer-webpack-plugin]`;
(exports.warn = msg => console.error(red(`${prefix} ${msg}\n`)));
(exports.tip = msg => console.log(yellow(`${prefix} ${msg}\n`)));
const isWebpack5 = !!(webpack.version && webpack.version[0] > 4);
const onEmit = (compiler, name, stageName, hook) => {
if (isWebpack5) {
// Webpack >= 5.0.0
compiler.hooks.compilation.tap(name, function (compilation) {
compiler.hooks.compilation.tap(name, compilation => {
if (compilation.compiler !== compiler) {

@@ -57,4 +57,4 @@ // Ignore child compilers

}
var stage = webpack.Compilation[stageName];
compilation.hooks.processAssets.tapAsync({ name: name, stage: stage }, function (assets, cb) {
const stage = webpack.Compilation[stageName];
compilation.hooks.processAssets.tapAsync({ name, stage }, (assets, cb) => {
hook(compilation, cb);

@@ -73,3 +73,3 @@ });

};
var stripModuleIdHash = function (id) {
const stripModuleIdHash = id => {
if (isWebpack5) {

@@ -82,3 +82,3 @@ // Webpack >= 5.0.0

};
var getAssetName = function (asset) {
const getAssetName = asset => {
if (typeof asset === 'string') {

@@ -90,7 +90,6 @@ return asset;

var hash = require('hash-sum');
var uniq = require('lodash.uniq');
var VueSSRClientPlugin = /** @class */ (function () {
function VueSSRClientPlugin(options) {
if (options === void 0) { options = {}; }
const hash = require('hash-sum');
const uniq = require('lodash.uniq');
class VueSSRClientPlugin {
constructor(options = {}) {
//@ts-expect-error no type on options

@@ -101,17 +100,16 @@ this.options = Object.assign({

}
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); }, [])
apply(compiler) {
const stage = 'PROCESS_ASSETS_STAGE_ADDITIONAL';
onEmit(compiler, 'vue-client-plugin', stage, (compilation, cb) => {
const stats = compilation.getStats().toJson();
const allFiles = uniq(stats.assets.map(a => a.name));
const initialFiles = uniq(Object.keys(stats.entrypoints)
.map(name => stats.entrypoints[name].assets)
.reduce((assets, all) => 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 = {
.filter(file => isJS(file) || isCSS(file)));
const asyncFiles = allFiles
.filter(file => isJS(file) || isCSS(file))
.filter(file => initialFiles.indexOf(file) < 0);
const manifest = {
publicPath: stats.publicPath,

@@ -125,19 +123,19 @@ all: allFiles,

};
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) {
const assetModules = stats.modules.filter(m => m.assets.length);
const fileToIndex = asset => manifest.all.indexOf(getAssetName(asset));
stats.modules.forEach(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; });
const cid = m.chunks[0];
const chunk = stats.chunks.find(c => c.id === cid);
if (!chunk || !chunk.files) {
return;
}
var id = stripModuleIdHash(m.identifier);
var files_1 = (manifest.modules[hash(id)] =
const id = stripModuleIdHash(m.identifier);
const 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_1; })) {
files_1.push.apply(files_1, m.assets.map(fileToIndex));
assetModules.forEach(m => {
if (m.chunks.some(id => id === cid)) {
files.push.apply(files, m.assets.map(fileToIndex));
}

@@ -147,14 +145,13 @@ });

});
var json = JSON.stringify(manifest, null, 2);
const 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; }
compilation.assets[this.options.filename] = {
source: () => json,
size: () => json.length
};
cb();
});
};
return VueSSRClientPlugin;
}());
}
}
module.exports = VueSSRClientPlugin;
{
"name": "vue-server-renderer",
"version": "2.7.0-alpha.7",
"version": "2.7.0-alpha.8",
"description": "server renderer for Vue 2.0",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -9,8 +9,8 @@ 'use strict';

function makeMap(str, expectsLowerCase) {
var map = Object.create(null);
var list = str.split(',');
for (var i = 0; i < list.length; i++) {
const map = Object.create(null);
const list = str.split(',');
for (let i = 0; i < list.length; i++) {
map[list[i]] = true;
}
return expectsLowerCase ? function (val) { return map[val.toLowerCase()]; } : function (val) { return map[val]; };
return expectsLowerCase ? val => map[val.toLowerCase()] : val => map[val];
}

@@ -39,11 +39,11 @@ /**

'target,title,usemap,value,width,wrap');
var isJS = function (file) { return /\.js(\?[^.]+)?$/.test(file); };
const isJS = (file) => /\.js(\?[^.]+)?$/.test(file);
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("".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) {
const { red, yellow } = require('chalk');
const webpack = require('webpack');
const prefix = `[vue-server-renderer-webpack-plugin]`;
const warn = (exports.warn = msg => console.error(red(`${prefix} ${msg}\n`)));
const tip = (exports.tip = msg => console.log(yellow(`${prefix} ${msg}\n`)));
const isWebpack5 = !!(webpack.version && webpack.version[0] > 4);
const validate = compiler => {
if (compiler.options.target !== 'node') {

@@ -69,6 +69,6 @@ warn('webpack config `target` should be "node".');

};
var onEmit = function (compiler, name, stageName, hook) {
const onEmit = (compiler, name, stageName, hook) => {
if (isWebpack5) {
// Webpack >= 5.0.0
compiler.hooks.compilation.tap(name, function (compilation) {
compiler.hooks.compilation.tap(name, compilation => {
if (compilation.compiler !== compiler) {

@@ -78,4 +78,4 @@ // Ignore child compilers

}
var stage = webpack.Compilation[stageName];
compilation.hooks.processAssets.tapAsync({ name: name, stage: stage }, function (assets, cb) {
const stage = webpack.Compilation[stageName];
compilation.hooks.processAssets.tapAsync({ name, stage }, (assets, cb) => {
hook(compilation, cb);

@@ -94,3 +94,3 @@ });

};
var getAssetName = function (asset) {
const getAssetName = asset => {
if (typeof asset === 'string') {

@@ -102,5 +102,4 @@ return asset;

var VueSSRServerPlugin = /** @class */ (function () {
function VueSSRServerPlugin(options) {
if (options === void 0) { options = {}; }
class VueSSRServerPlugin {
constructor(options = {}) {
//@ts-expect-error

@@ -111,10 +110,9 @@ this.options = Object.assign({

}
VueSSRServerPlugin.prototype.apply = function (compiler) {
var _this = this;
apply(compiler) {
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];
const stage = 'PROCESS_ASSETS_STAGE_OPTIMIZE_TRANSFER';
onEmit(compiler, 'vue-server-plugin', stage, (compilation, cb) => {
const stats = compilation.getStats().toJson();
const entryName = Object.keys(stats.entrypoints)[0];
const entryInfo = stats.entrypoints[entryName];
if (!entryInfo) {

@@ -124,17 +122,17 @@ // #5553

}
var entryAssets = entryInfo.assets.map(getAssetName).filter(isJS);
const 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.");
throw new Error(`Server-side bundle should have one single entry file. ` +
`Avoid using CommonsChunkPlugin in the server config.`);
}
var entry = entryAssets[0];
const entry = entryAssets[0];
if (!entry || typeof entry !== 'string') {
throw new Error("Entry \"".concat(entryName, "\" not found. Did you specify the correct entry option?"));
throw new Error(`Entry "${entryName}" not found. Did you specify the correct entry option?`);
}
var bundle = {
entry: entry,
const bundle = {
entry,
files: {},
maps: {}
};
Object.keys(compilation.assets).forEach(function (name) {
Object.keys(compilation.assets).forEach(name => {
if (isJS(name)) {

@@ -149,15 +147,14 @@ bundle.files[name] = compilation.assets[name].source();

});
var json = JSON.stringify(bundle, null, 2);
const json = JSON.stringify(bundle, null, 2);
//@ts-expect-error
var filename = _this.options.filename;
const filename = this.options.filename;
compilation.assets[filename] = {
source: function () { return json; },
size: function () { return json.length; }
source: () => json,
size: () => json.length
};
cb();
});
};
return VueSSRServerPlugin;
}());
}
}
module.exports = VueSSRServerPlugin;

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