Skip to content
Permalink
Browse files
build: build v2.5.18-beta.0
  • Loading branch information
yyx990803 committed Dec 2, 2018
1 parent 3078352 commit fe194dd5d812249bed5c15ad1d16551599b029dd

Large diffs are not rendered by default.

Large diffs are not rendered by default.

19,573 dist/vue.js

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

@@ -4,6 +4,8 @@

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;
@@ -12,8 +14,19 @@ 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 onEmit = function (compiler, name, hook) {
if (compiler.hooks) {
// Webpack >= 4.0.0
compiler.hooks.emit.tapAsync(name, hook);
} else {
// Webpack < 4.0.0
compiler.plugin('emit', hook);
}
};

var hash = require('hash-sum');
var uniq = require('lodash.uniq');

var VueSSRClientPlugin = function VueSSRClientPlugin (options) {
if ( options === void 0 ) options = {};

@@ -25,7 +38,7 @@ var VueSSRClientPlugin = function VueSSRClientPlugin (options) {
VueSSRClientPlugin.prototype.apply = function apply (compiler) {
var this$1 = this;

compiler.plugin('emit', function (compilation, cb) {
onEmit(compiler, 'vue-client-plugin', function (compilation, cb) {
var stats = compilation.getStats().toJson();

var allFiles = uniq(stats.assets
@@ -34,10 +47,10 @@ VueSSRClientPlugin.prototype.apply = function apply (compiler) {
var initialFiles = uniq(Object.keys(stats.entrypoints)
.map(function (name) { return stats.entrypoints[name].assets; })
.reduce(function (assets, all) { return all.concat(assets); }, [])
.filter(isJS));
.filter(function (file) { return isJS(file) || isCSS(file); }));

var asyncFiles = allFiles
.filter(isJS)
.filter(function (file) { return isJS(file) || isCSS(file); })
.filter(function (file) { return initialFiles.indexOf(file) < 0; });

var manifest = {
@@ -58,7 +71,8 @@ VueSSRClientPlugin.prototype.apply = function apply (compiler) {
if (!chunk || !chunk.files) {
return
}
var files = manifest.modules[hash(m.identifier)] = chunk.files.map(fileToIndex);
var id = m.identifier.replace(/\s\w+$/, ''); // remove appended hash
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; })) {
@@ -68,12 +82,6 @@ VueSSRClientPlugin.prototype.apply = function apply (compiler) {
}
});

// const debug = (file, obj) => {
// require('fs').writeFileSync(__dirname + '/' + file, JSON.stringify(obj, null, 2))
// }
// debug('stats.json', stats)
// debug('client-manifest.json', manifest)

var json = JSON.stringify(manifest, null, 2);
compilation.assets[this$1.options.filename] = {
source: function () { return json; },
@@ -1,6 +1,6 @@
{
"name": "vue-server-renderer",
"version": "2.5.17-beta.0",
"version": "2.5.18-beta.0",
"description": "server renderer for Vue 2.0",
"main": "index.js",
"types": "types/index.d.ts",
@@ -29,6 +29,16 @@ var validate = function (compiler) {
}
};

var onEmit = function (compiler, name, hook) {
if (compiler.hooks) {
// Webpack >= 4.0.0
compiler.hooks.emit.tapAsync(name, hook);
} else {
// Webpack < 4.0.0
compiler.plugin('emit', hook);
}
};

var VueSSRServerPlugin = function VueSSRServerPlugin (options) {
if ( options === void 0 ) options = {};

@@ -42,7 +52,7 @@ VueSSRServerPlugin.prototype.apply = function apply (compiler) {

validate(compiler);

compiler.plugin('emit', function (compilation, cb) {
onEmit(compiler, 'vue-server-plugin', function (compilation, cb) {
var stats = compilation.getStats().toJson();
var entryName = Object.keys(stats.entrypoints)[0];
var entryInfo = stats.entrypoints[entryName];
@@ -75,7 +85,7 @@ VueSSRServerPlugin.prototype.apply = function apply (compiler) {
};

stats.assets.forEach(function (asset) {
if (asset.name.match(/\.js$/)) {
if (isJS(asset.name)) {
bundle.files[asset.name] = compilation.assets[asset.name].source();
} else if (asset.name.match(/\.js\.map$/)) {
bundle.maps[asset.name.replace(/\.map$/, '')] = JSON.parse(compilation.assets[asset.name].source());

0 comments on commit fe194dd

Please sign in to comment.