"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "packages/vue-server-renderer/server-plugin.js" between
vue-2.6.13.tar.gz and vue-2.6.14.tar.gz

About: Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

server-plugin.js  (vue-2.6.13):server-plugin.js  (vue-2.6.14)
'use strict'; 'use strict';
/* */ /* */
var isJS = function (file) { return /\.js(\?[^.]+)?$/.test(file); }; var isJS = function (file) { return /\.js(\?[^.]+)?$/.test(file); };
var ref = require('chalk'); var ref = require('chalk');
var red = ref.red; var red = ref.red;
var yellow = ref.yellow; var yellow = ref.yellow;
var webpack = require('webpack');
var prefix = "[vue-server-renderer-webpack-plugin]"; var prefix = "[vue-server-renderer-webpack-plugin]";
var warn = exports.warn = function (msg) { return console.error(red((prefix + " " + msg + "\n"))); }; 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 tip = exports.tip = function (msg) { return console.log(yellow((prefix + " " + msg + "\n"))); };
var isWebpack5 = !!(webpack.version && webpack.version[0] > 4);
var validate = function (compiler) { var validate = function (compiler) {
if (compiler.options.target !== 'node') { if (compiler.options.target !== 'node') {
warn('webpack config `target` should be "node".'); warn('webpack config `target` should be "node".');
} }
if (compiler.options.output && compiler.options.output.libraryTarget !== 'comm if (compiler.options.output) {
onjs2') { if (compiler.options.output.library) {
warn('webpack config `output.libraryTarget` should be "commonjs2".'); // 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) { if (!compiler.options.externals) {
tip( tip(
'It is recommended to externalize dependencies in the server build for ' + 'It is recommended to externalize dependencies in the server build for ' +
'better build performance.' 'better build performance.'
); );
} }
}; };
var onEmit = function (compiler, name, hook) { var onEmit = function (compiler, name, stageName, hook) {
if (compiler.hooks) { 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 }, fun
ction (assets, cb) {
hook(compilation, cb);
});
});
} else if (compiler.hooks) {
// Webpack >= 4.0.0 // Webpack >= 4.0.0
compiler.hooks.emit.tapAsync(name, hook); compiler.hooks.emit.tapAsync(name, hook);
} else { } else {
// Webpack < 4.0.0 // Webpack < 4.0.0
compiler.plugin('emit', hook); compiler.plugin('emit', hook);
} }
}; };
var getAssetName = function (asset) {
if (typeof asset === 'string') {
return asset
}
return asset.name
};
var VueSSRServerPlugin = function VueSSRServerPlugin (options) { var VueSSRServerPlugin = function VueSSRServerPlugin (options) {
if ( options === void 0 ) options = {}; if ( options === void 0 ) options = {};
this.options = Object.assign({ this.options = Object.assign({
filename: 'vue-ssr-server-bundle.json' filename: 'vue-ssr-server-bundle.json'
}, options); }, options);
}; };
VueSSRServerPlugin.prototype.apply = function apply (compiler) { VueSSRServerPlugin.prototype.apply = function apply (compiler) {
var this$1 = this; var this$1 = this;
validate(compiler); validate(compiler);
onEmit(compiler, 'vue-server-plugin', function (compilation, cb) { var stage = 'PROCESS_ASSETS_STAGE_OPTIMIZE_TRANSFER';
onEmit(compiler, 'vue-server-plugin', stage, function (compilation, cb) {
var stats = compilation.getStats().toJson(); var stats = compilation.getStats().toJson();
var entryName = Object.keys(stats.entrypoints)[0]; var entryName = Object.keys(stats.entrypoints)[0];
var entryInfo = stats.entrypoints[entryName]; var entryInfo = stats.entrypoints[entryName];
if (!entryInfo) { if (!entryInfo) {
// #5553 // #5553
return cb() return cb()
} }
var entryAssets = entryInfo.assets.filter(isJS); var entryAssets = entryInfo.assets
.map(getAssetName)
.filter(isJS);
if (entryAssets.length > 1) { if (entryAssets.length > 1) {
throw new Error( throw new Error(
"Server-side bundle should have one single entry file. " + "Server-side bundle should have one single entry file. " +
"Avoid using CommonsChunkPlugin in the server config." "Avoid using CommonsChunkPlugin in the server config."
) )
} }
var entry = entryAssets[0]; var entry = entryAssets[0];
if (!entry || typeof entry !== 'string') { if (!entry || typeof entry !== 'string') {
skipping to change at line 87 skipping to change at line 120
("Entry \"" + entryName + "\" not found. Did you specify the correct ent ry option?") ("Entry \"" + entryName + "\" not found. Did you specify the correct ent ry option?")
) )
} }
var bundle = { var bundle = {
entry: entry, entry: entry,
files: {}, files: {},
maps: {} maps: {}
}; };
stats.assets.forEach(function (asset) { Object.keys(compilation.assets).forEach(function (name) {
if (isJS(asset.name)) { if (isJS(name)) {
bundle.files[asset.name] = compilation.assets[asset.name].source(); bundle.files[name] = compilation.assets[name].source();
} else if (asset.name.match(/\.js\.map$/)) { } else if (name.match(/\.js\.map$/)) {
bundle.maps[asset.name.replace(/\.map$/, '')] = JSON.parse(compilation.a bundle.maps[name.replace(/\.map$/, '')] = JSON.parse(compilation.assets[
ssets[asset.name].source()); name].source());
} }
// do not emit anything else for server // do not emit anything else for server
delete compilation.assets[asset.name]; delete compilation.assets[name];
}); });
var json = JSON.stringify(bundle, null, 2); var json = JSON.stringify(bundle, null, 2);
var filename = this$1.options.filename; var filename = this$1.options.filename;
compilation.assets[filename] = { compilation.assets[filename] = {
source: function () { return json; }, source: function () { return json; },
size: function () { return json.length; } size: function () { return json.length; }
}; };
 End of changes. 9 change blocks. 
14 lines changed or deleted 47 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)