mirror of
https://gitee.com/vuejs/vue.git
synced 2024-12-03 12:38:24 +08:00
[build] 2.3.0-beta.1
This commit is contained in:
parent
cb0531c4fb
commit
56b6f8aac6
1430
dist/vue.common.js
vendored
1430
dist/vue.common.js
vendored
File diff suppressed because it is too large
Load Diff
1430
dist/vue.esm.js
vendored
1430
dist/vue.esm.js
vendored
File diff suppressed because it is too large
Load Diff
1424
dist/vue.js
vendored
1424
dist/vue.js
vendored
File diff suppressed because it is too large
Load Diff
8
dist/vue.min.js
vendored
8
dist/vue.min.js
vendored
File diff suppressed because one or more lines are too long
1359
dist/vue.runtime.common.js
vendored
1359
dist/vue.runtime.common.js
vendored
File diff suppressed because it is too large
Load Diff
1359
dist/vue.runtime.esm.js
vendored
1359
dist/vue.runtime.esm.js
vendored
File diff suppressed because it is too large
Load Diff
1353
dist/vue.runtime.js
vendored
1353
dist/vue.runtime.js
vendored
File diff suppressed because it is too large
Load Diff
6
dist/vue.runtime.min.js
vendored
6
dist/vue.runtime.min.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
82
packages/vue-server-renderer/client-plugin.js
Normal file
82
packages/vue-server-renderer/client-plugin.js
Normal file
@ -0,0 +1,82 @@
|
||||
'use strict';
|
||||
|
||||
/* */
|
||||
|
||||
var isJS = function (file) { return /\.js(\?[^.]+)?$/.test(file); };
|
||||
|
||||
var ref = require('chalk');
|
||||
var red = ref.red;
|
||||
var yellow = ref.yellow;
|
||||
|
||||
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 hash = require('hash-sum');
|
||||
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;
|
||||
|
||||
compiler.plugin('emit', function (compilation, cb) {
|
||||
var stats = compilation.getStats().toJson();
|
||||
|
||||
var allFiles = stats.assets
|
||||
.map(function (a) { return a.name; });
|
||||
|
||||
var initialFiles = Object.keys(stats.entrypoints)
|
||||
.map(function (name) { return stats.entrypoints[name].assets; })
|
||||
.reduce(function (assets, all) { return all.concat(assets); }, [])
|
||||
.filter(isJS);
|
||||
|
||||
var asyncFiles = allFiles
|
||||
.filter(isJS)
|
||||
.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 (file) { return manifest.all.indexOf(file); };
|
||||
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; });
|
||||
var files = manifest.modules[hash(m.identifier)] = 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));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// 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; },
|
||||
size: function () { return json.length; }
|
||||
};
|
||||
cb();
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = VueSSRClientPlugin;
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "vue-server-renderer",
|
||||
"version": "2.2.6",
|
||||
"version": "2.3.0-beta.1",
|
||||
"description": "server renderer for Vue 2.0",
|
||||
"main": "index.js",
|
||||
"repository": {
|
||||
|
92
packages/vue-server-renderer/server-plugin.js
Normal file
92
packages/vue-server-renderer/server-plugin.js
Normal file
@ -0,0 +1,92 @@
|
||||
'use strict';
|
||||
|
||||
/* */
|
||||
|
||||
var isJS = function (file) { return /\.js(\?[^.]+)?$/.test(file); };
|
||||
|
||||
var ref = require('chalk');
|
||||
var red = ref.red;
|
||||
var yellow = ref.yellow;
|
||||
|
||||
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 validate = function (compiler) {
|
||||
if (compiler.options.target !== 'node') {
|
||||
warn('webpack config `target` should be "node".');
|
||||
}
|
||||
|
||||
if (compiler.options.output && compiler.options.output.libraryTarget !== 'commonjs2') {
|
||||
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 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);
|
||||
|
||||
compiler.plugin('emit', function (compilation, cb) {
|
||||
var stats = compilation.getStats().toJson();
|
||||
var entryName = Object.keys(stats.entrypoints)[0];
|
||||
var entryAssets = stats.entrypoints[entryName].assets.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: {}
|
||||
};
|
||||
|
||||
stats.assets.forEach(function (asset) {
|
||||
if (asset.name.match(/\.js$/)) {
|
||||
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());
|
||||
}
|
||||
// do not emit anything else for server
|
||||
delete compilation.assets[asset.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;
|
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "vue-template-compiler",
|
||||
"version": "2.2.6",
|
||||
"version": "2.3.0-beta.1",
|
||||
"description": "template compiler for Vue 2.0",
|
||||
"main": "index.js",
|
||||
"repository": {
|
||||
|
Loading…
Reference in New Issue
Block a user