Skip to content

Commit 56b6f8a

Browse files
committed
[build] 2.3.0-beta.1
1 parent cb0531c commit 56b6f8a

File tree

14 files changed

+11964
-14065
lines changed

14 files changed

+11964
-14065
lines changed

dist/vue.common.js

Lines changed: 883 additions & 589 deletions
Large diffs are not rendered by default.

dist/vue.esm.js

Lines changed: 883 additions & 589 deletions
Large diffs are not rendered by default.

dist/vue.js

Lines changed: 860 additions & 568 deletions
Large diffs are not rendered by default.

dist/vue.min.js

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/vue.runtime.common.js

Lines changed: 846 additions & 593 deletions
Large diffs are not rendered by default.

dist/vue.runtime.esm.js

Lines changed: 846 additions & 593 deletions
Large diffs are not rendered by default.

dist/vue.runtime.js

Lines changed: 843 additions & 592 deletions
Large diffs are not rendered by default.

dist/vue.runtime.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/vue-server-renderer/build.js

Lines changed: 4331 additions & 5629 deletions
Large diffs are not rendered by default.
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
'use strict';
2+
3+
/* */
4+
5+
var isJS = function (file) { return /\.js(\?[^.]+)?$/.test(file); };
6+
7+
var ref = require('chalk');
8+
var red = ref.red;
9+
var yellow = ref.yellow;
10+
11+
var prefix = "[vue-server-renderer-webpack-plugin]";
12+
var warn = exports.warn = function (msg) { return console.error(red((prefix + " " + msg + "\n"))); };
13+
var tip = exports.tip = function (msg) { return console.log(yellow((prefix + " " + msg + "\n"))); };
14+
15+
var hash = require('hash-sum');
16+
var VueSSRClientPlugin = function VueSSRClientPlugin (options) {
17+
if ( options === void 0 ) options = {};
18+
19+
this.options = Object.assign({
20+
filename: 'vue-ssr-client-manifest.json'
21+
}, options);
22+
};
23+
24+
VueSSRClientPlugin.prototype.apply = function apply (compiler) {
25+
var this$1 = this;
26+
27+
compiler.plugin('emit', function (compilation, cb) {
28+
var stats = compilation.getStats().toJson();
29+
30+
var allFiles = stats.assets
31+
.map(function (a) { return a.name; });
32+
33+
var initialFiles = Object.keys(stats.entrypoints)
34+
.map(function (name) { return stats.entrypoints[name].assets; })
35+
.reduce(function (assets, all) { return all.concat(assets); }, [])
36+
.filter(isJS);
37+
38+
var asyncFiles = allFiles
39+
.filter(isJS)
40+
.filter(function (file) { return initialFiles.indexOf(file) < 0; });
41+
42+
var manifest = {
43+
publicPath: stats.publicPath,
44+
all: allFiles,
45+
initial: initialFiles,
46+
async: asyncFiles,
47+
modules: { /* [identifier: string]: Array<index: number> */ }
48+
};
49+
50+
var assetModules = stats.modules.filter(function (m) { return m.assets.length; });
51+
var fileToIndex = function (file) { return manifest.all.indexOf(file); };
52+
stats.modules.forEach(function (m) {
53+
// ignore modules duplicated in multiple chunks
54+
if (m.chunks.length === 1) {
55+
var cid = m.chunks[0];
56+
var chunk = stats.chunks.find(function (c) { return c.id === cid; });
57+
var files = manifest.modules[hash(m.identifier)] = chunk.files.map(fileToIndex);
58+
// find all asset modules associated with the same chunk
59+
assetModules.forEach(function (m) {
60+
if (m.chunks.some(function (id) { return id === cid; })) {
61+
files.push.apply(files, m.assets.map(fileToIndex));
62+
}
63+
});
64+
}
65+
});
66+
67+
// const debug = (file, obj) => {
68+
// require('fs').writeFileSync(__dirname + '/' + file, JSON.stringify(obj, null, 2))
69+
// }
70+
// debug('stats.json', stats)
71+
// debug('client-manifest.json', manifest)
72+
73+
var json = JSON.stringify(manifest, null, 2);
74+
compilation.assets[this$1.options.filename] = {
75+
source: function () { return json; },
76+
size: function () { return json.length; }
77+
};
78+
cb();
79+
});
80+
};
81+
82+
module.exports = VueSSRClientPlugin;

packages/vue-server-renderer/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue-server-renderer",
3-
"version": "2.2.6",
3+
"version": "2.3.0-beta.1",
44
"description": "server renderer for Vue 2.0",
55
"main": "index.js",
66
"repository": {
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
'use strict';
2+
3+
/* */
4+
5+
var isJS = function (file) { return /\.js(\?[^.]+)?$/.test(file); };
6+
7+
var ref = require('chalk');
8+
var red = ref.red;
9+
var yellow = ref.yellow;
10+
11+
var prefix = "[vue-server-renderer-webpack-plugin]";
12+
var warn = exports.warn = function (msg) { return console.error(red((prefix + " " + msg + "\n"))); };
13+
var tip = exports.tip = function (msg) { return console.log(yellow((prefix + " " + msg + "\n"))); };
14+
15+
var validate = function (compiler) {
16+
if (compiler.options.target !== 'node') {
17+
warn('webpack config `target` should be "node".');
18+
}
19+
20+
if (compiler.options.output && compiler.options.output.libraryTarget !== 'commonjs2') {
21+
warn('webpack config `output.libraryTarget` should be "commonjs2".');
22+
}
23+
24+
if (!compiler.options.externals) {
25+
tip(
26+
'It is recommended to externalize dependencies in the server build for ' +
27+
'better build performance.'
28+
);
29+
}
30+
};
31+
32+
var VueSSRServerPlugin = function VueSSRServerPlugin (options) {
33+
if ( options === void 0 ) options = {};
34+
35+
this.options = Object.assign({
36+
filename: 'vue-ssr-server-bundle.json'
37+
}, options);
38+
};
39+
40+
VueSSRServerPlugin.prototype.apply = function apply (compiler) {
41+
var this$1 = this;
42+
43+
validate(compiler);
44+
45+
compiler.plugin('emit', function (compilation, cb) {
46+
var stats = compilation.getStats().toJson();
47+
var entryName = Object.keys(stats.entrypoints)[0];
48+
var entryAssets = stats.entrypoints[entryName].assets.filter(isJS);
49+
50+
if (entryAssets.length > 1) {
51+
throw new Error(
52+
"Server-side bundle should have one single entry file. " +
53+
"Avoid using CommonsChunkPlugin in the server config."
54+
)
55+
}
56+
57+
var entry = entryAssets[0];
58+
if (!entry || typeof entry !== 'string') {
59+
throw new Error(
60+
("Entry \"" + entryName + "\" not found. Did you specify the correct entry option?")
61+
)
62+
}
63+
64+
var bundle = {
65+
entry: entry,
66+
files: {},
67+
maps: {}
68+
};
69+
70+
stats.assets.forEach(function (asset) {
71+
if (asset.name.match(/\.js$/)) {
72+
bundle.files[asset.name] = compilation.assets[asset.name].source();
73+
} else if (asset.name.match(/\.js\.map$/)) {
74+
bundle.maps[asset.name.replace(/\.map$/, '')] = JSON.parse(compilation.assets[asset.name].source());
75+
}
76+
// do not emit anything else for server
77+
delete compilation.assets[asset.name];
78+
});
79+
80+
var json = JSON.stringify(bundle, null, 2);
81+
var filename = this$1.options.filename;
82+
83+
compilation.assets[filename] = {
84+
source: function () { return json; },
85+
size: function () { return json.length; }
86+
};
87+
88+
cb();
89+
});
90+
};
91+
92+
module.exports = VueSSRServerPlugin;

0 commit comments

Comments
 (0)