From 2dc2d062b1af826add087d832a3f68806e2ef2b1 Mon Sep 17 00:00:00 2001 From: Evan You Date: Wed, 16 Nov 2016 16:41:44 -0500 Subject: [PATCH] adjust build --- benchmarks/ssr/renderToStream.js | 2 +- benchmarks/ssr/renderToString.js | 2 +- build/build.js | 37 +++++++-------- build/config.js | 31 ++++++++----- dist/README.md | 39 ++++++++++++++++ flow/compiler.js | 1 - package.json | 19 ++++---- src/compiler/parser/index.js | 11 ++--- src/core/config.js | 8 +--- src/core/index.js | 6 +-- src/core/instance/render.js | 4 +- src/core/observer/index.js | 6 +-- src/core/util/env.js | 17 +++++++ src/entries/web-runtime.js | 4 +- src/entries/web-server-renderer.js | 2 + src/platforms/web/compiler/index.js | 2 - src/server/create-renderer.js | 10 +---- src/server/render.js | 21 +++++++++ test/ssr/fixtures/app.js | 2 +- test/ssr/fixtures/cache.js | 2 +- test/ssr/ssr-env.spec.js | 45 ------------------- test/ssr/ssr-stream.spec.js | 4 +- test/ssr/ssr-string.spec.js | 4 +- .../unit/features/instance/properties.spec.js | 8 ---- 24 files changed, 153 insertions(+), 134 deletions(-) create mode 100644 dist/README.md delete mode 100644 test/ssr/ssr-env.spec.js diff --git a/benchmarks/ssr/renderToStream.js b/benchmarks/ssr/renderToStream.js index 74b4d144b..e068d94c6 100644 --- a/benchmarks/ssr/renderToStream.js +++ b/benchmarks/ssr/renderToStream.js @@ -1,6 +1,6 @@ 'use strict' -const Vue = require('../../dist/vue.common.js') +const Vue = require('../../dist/vue.runtime.common.js') const createRenderer = require('../../packages/vue-server-renderer').createRenderer const renderToStream = createRenderer().renderToStream const gridComponent = require('./common.js') diff --git a/benchmarks/ssr/renderToString.js b/benchmarks/ssr/renderToString.js index 39a45ff1e..4f16e93a4 100644 --- a/benchmarks/ssr/renderToString.js +++ b/benchmarks/ssr/renderToString.js @@ -1,6 +1,6 @@ 'use strict' -const Vue = require('../../dist/vue.common.js') +const Vue = require('../../dist/vue.runtime.common.js') const createRenderer = require('../../packages/vue-server-renderer').createRenderer const renderToString = createRenderer().renderToString const gridComponent = require('./common.js') diff --git a/build/build.js b/build/build.js index 27f7978b5..5aee4484d 100644 --- a/build/build.js +++ b/build/build.js @@ -69,37 +69,34 @@ function buildEntry (config) { pure_funcs: ['makeMap'] } }).code - return write(config.dest, minified).then(zip(config.dest)) + return write(config.dest, minified, true) } else { return write(config.dest, code) } }) } -function write (dest, code) { - return new Promise(function (resolve, reject) { - fs.writeFile(dest, code, function (err) { - if (err) return reject(err) - console.log(blue(path.relative(process.cwd(), dest)) + ' ' + getSize(code)) +function write (dest, code, zip) { + return new Promise((resolve, reject) => { + function report (extra) { + console.log(blue(path.relative(process.cwd(), dest)) + ' ' + getSize(code) + (extra || '')) resolve() + } + + fs.writeFile(dest, code, err => { + if (err) return reject(err) + if (zip) { + zlib.gzip(code, (err, zipped) => { + if (err) return reject(err) + report(' (gzipped: ' + getSize(zipped) + ')') + }) + } else { + report() + } }) }) } -function zip (file) { - return function () { - return new Promise(function (resolve, reject) { - fs.readFile(file, function (err, buf) { - if (err) return reject(err) - zlib.gzip(buf, function (err, buf) { - if (err) return reject(err) - write(file + '.gz', buf).then(resolve) - }) - }) - }) - } -} - function getSize (code) { return (code.length / 1024).toFixed(2) + 'kb' } diff --git a/build/config.js b/build/config.js index 4472b2296..7aad223b3 100644 --- a/build/config.js +++ b/build/config.js @@ -14,30 +14,38 @@ const banner = const builds = { // Runtime only (CommonJS). Used by bundlers e.g. Webpack & Browserify - 'web-runtime-dev': { + 'web-runtime-cjs': { entry: path.resolve(__dirname, '../src/entries/web-runtime.js'), - dest: path.resolve(__dirname, '../dist/vue.common.js'), + dest: path.resolve(__dirname, '../dist/vue.runtime.common.js'), format: 'cjs', banner }, - // runtime-only build for CDN - 'web-runtime-cdn-dev': { + // Runtime+compiler CommonJS build (CommonJS) + 'web-full-cjs': { + entry: path.resolve(__dirname, '../src/entries/web-runtime-with-compiler.js'), + dest: path.resolve(__dirname, '../dist/vue.common.js'), + format: 'cjs', + alias: { he: './entity-decoder' }, + banner + }, + // runtime-only build (Browser) + 'web-runtime-dev': { entry: path.resolve(__dirname, '../src/entries/web-runtime.js'), dest: path.resolve(__dirname, '../dist/vue.runtime.js'), format: 'umd', env: 'development', banner }, - // runtime-only production build for CDN - 'web-runtime-cdn-prod': { + // runtime-only production build (Browser) + 'web-runtime-prod': { entry: path.resolve(__dirname, '../src/entries/web-runtime.js'), dest: path.resolve(__dirname, '../dist/vue.runtime.min.js'), format: 'umd', env: 'production', banner }, - // Runtime+compiler standalone development build. - 'web-standalone-dev': { + // Runtime+compiler development build (Browser) + 'web-full-dev': { entry: path.resolve(__dirname, '../src/entries/web-runtime-with-compiler.js'), dest: path.resolve(__dirname, '../dist/vue.js'), format: 'umd', @@ -45,8 +53,8 @@ const builds = { alias: { he: './entity-decoder' }, banner }, - // Runtime+compiler standalone production build. - 'web-standalone-prod': { + // Runtime+compiler production build (Browser) + 'web-full-prod': { entry: path.resolve(__dirname, '../src/entries/web-runtime-with-compiler.js'), dest: path.resolve(__dirname, '../dist/vue.min.js'), format: 'umd', @@ -100,8 +108,7 @@ function genConfig (opts) { if (opts.env) { config.plugins.push(replace({ - 'process.env.NODE_ENV': JSON.stringify(opts.env), - 'process.env.VUE_ENV': JSON.stringify('client') + 'process.env.NODE_ENV': JSON.stringify(opts.env) })) } diff --git a/dist/README.md b/dist/README.md new file mode 100644 index 000000000..2ae820b9e --- /dev/null +++ b/dist/README.md @@ -0,0 +1,39 @@ +## Explanation of Build Files + +- ### vue.js + + The full (compiler-included) browser build. This is the build you can just include with a script tag: + + ``` +