From 68694e9d94f3537af243eb8bd30e878f4bd89114 Mon Sep 17 00:00:00 2001 From: Evan You Date: Thu, 30 Jun 2016 10:27:21 -0400 Subject: [PATCH 01/21] add a note about building for production --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index 66fa388..949599a 100644 --- a/README.md +++ b/README.md @@ -294,6 +294,14 @@ browserify('./main.js') This only works for vueify 9+. For Vue 1.x / vueify 8.x you can use [vueify-extract-css](https://github.com/rawcreative/vueify-extract-css). +## Building for Production + +When building for production, follow these steps to ensure smaller bundle size: + +1. Make sure `process.env.NODE_ENV === "production"`. This tells `vueify` to avoid including hot-reload related code. + +2. Apply a global [envify](https://github.com/hughsk/envify) transform to your bundle. This allows the minifier to strip out all the warnings in Vue's source code wrapped in env variable conditional blocks. + ## Compiler API The compiler API (originally `vue-component-compiler`) is also exposed: From 8550260612de4338714802fd014cc5f7dfc84dbf Mon Sep 17 00:00:00 2001 From: Evan You Date: Thu, 30 Jun 2016 10:33:53 -0400 Subject: [PATCH 02/21] skip css and hot-reload in server mode --- lib/compiler.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/compiler.js b/lib/compiler.js index 7fb0e2c..d743004 100644 --- a/lib/compiler.js +++ b/lib/compiler.js @@ -60,6 +60,10 @@ compiler.applyConfig = function (config) { } compiler.compile = function (content, filePath, cb) { + var isProduction = process.env.NODE_ENV === 'production' + var isServer = process.env.VUE_ENV === 'server' + var isTest = !!process.env.VUEIFY_TEST + // generate css scope id var id = 'data-v-' + genId(filePath) // parse the component into parts @@ -96,7 +100,7 @@ compiler.compile = function (content, filePath, cb) { var map = null // styles var style = resolvedParts.styles.join('\n') - if (style) { + if (style && !isServer) { // emit style compiler.emit('style', { file: filePath, @@ -126,7 +130,7 @@ compiler.compile = function (content, filePath, cb) { // template var template = resolvedParts.template if (template) { - if (process.env.NODE_ENV !== 'production') { + if (!isProduction && !isServer) { output += 'if (__vue__options__.functional) {console.error("' + '[vueify] functional components are not supported and ' + @@ -142,7 +146,7 @@ compiler.compile = function (content, filePath, cb) { output += '__vue__options__._scopeId = "' + id + '"\n' } // hot reload - if (process.env.NODE_ENV !== 'production' && !process.env.VUEIFY_TEST) { + if (!isProduction && !isTest && !isServer) { output += 'if (module.hot) {(function () {' + ' var hotAPI = require("' + hotReloadAPIPath + '")\n' + From b527242e57aaeda6a19f6a5ad0823eb11ccd2ae6 Mon Sep 17 00:00:00 2001 From: Evan You Date: Thu, 30 Jun 2016 10:33:59 -0400 Subject: [PATCH 03/21] 9.2.3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5be8f1a..d012e33 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vueify", - "version": "9.2.2", + "version": "9.2.3", "description": "Vue component transform for Browserify", "main": "index.js", "repository": { From bd6c09400b36741f3c7f05cc0156e4b9bd493bd5 Mon Sep 17 00:00:00 2001 From: Evan You Date: Fri, 15 Jul 2016 18:25:59 -0400 Subject: [PATCH 04/21] map all render errors to the template --- lib/compiler.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/lib/compiler.js b/lib/compiler.js index d743004..cde3d99 100644 --- a/lib/compiler.js +++ b/lib/compiler.js @@ -137,9 +137,16 @@ compiler.compile = function (content, filePath, cb) { 'should be defined in plain js files using render functions.' + '")}\n' } + var beforeLines + if (map) { + beforeLines = output.split(splitRE).length + } output += '__vue__options__.render = ' + template.render + '\n' + '__vue__options__.staticRenderFns = ' + template.staticRenderFns + '\n' + if (map) { + addTemplateMapping(content, parts, output, map, beforeLines) + } } // scoped CSS id if (hasScopedStyle) { @@ -205,10 +212,29 @@ compiler.compile = function (content, filePath, cb) { }) } }) + map._hashedFilename = hashedFilename return map } } +function addTemplateMapping (content, parts, output, map, beforeLines) { + var afterLines = output.split(splitRE).length + var templateLine = content.slice(0, parts.template.start).split(splitRE).length + for (; beforeLines < afterLines; beforeLines++) { + map.addMapping({ + source: map._hashedFilename, + generated: { + line: beforeLines, + column: 0 + }, + original: { + line: templateLine, + column: 0 + } + }) + } +} + function processTemplate (part, filePath, parts) { if (!part) return Promise.resolve() var template = getContent(part, filePath) From a3465bb9d6bc695b0f70ba8f096d4c95c033d3cb Mon Sep 17 00:00:00 2001 From: Evan You Date: Fri, 15 Jul 2016 18:26:03 -0400 Subject: [PATCH 05/21] 9.2.4 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d012e33..cc3bbde 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vueify", - "version": "9.2.3", + "version": "9.2.4", "description": "Vue component transform for Browserify", "main": "index.js", "repository": { From 62236436086e0d2fc76caf608b9c4f25540970ca Mon Sep 17 00:00:00 2001 From: Evan You Date: Wed, 28 Sep 2016 19:13:20 -0400 Subject: [PATCH 06/21] add version notice --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 949599a..809c89e 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,8 @@ > [Browserify](http://browserify.org/) transform for [Vue.js](http://vuejs.org/) components, with scoped CSS and component hot-reloading. +**NOTE: master branch now hosts version ^9.0, which only works with Vue ^2.0. Vueify 8.x which works with Vue 1.x is in the [8.x branch](https://github.com/vuejs/vueify/tree/8.x).** + This transform allows you to write your components in this format: ``` html From 9ce0fb10af26b108317c5913ee4549445cff7b0e Mon Sep 17 00:00:00 2001 From: Evan You Date: Wed, 28 Sep 2016 20:12:53 -0400 Subject: [PATCH 07/21] fix dep --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index cc3bbde..1d8e9a6 100644 --- a/package.json +++ b/package.json @@ -44,6 +44,7 @@ "coffee-script": "^1.10.0", "eslint": "^2.13.0", "eslint-config-vue": "^1.0.3", + "eslint-plugin-html": "^1.5.3", "jade": "^1.11.0", "jsdom": "^9.2.1", "less": "^2.5.1", From fa235bd345779e52d7697c476de9a4393bc394e1 Mon Sep 17 00:00:00 2001 From: Evan You Date: Sat, 12 Nov 2016 11:07:12 -0500 Subject: [PATCH 08/21] include vue-template-es2015-compiler --- lib/template-compiler.js | 3 ++- package.json | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/template-compiler.js b/lib/template-compiler.js index 3824c37..51314b9 100644 --- a/lib/template-compiler.js +++ b/lib/template-compiler.js @@ -1,5 +1,6 @@ var chalk = require('chalk') var vueCompiler = require('vue-template-compiler') +var transpile = require('vue-template-es2015-compiler') module.exports = function compileTemplate (template, compiler) { var compiled = vueCompiler.compile(template) @@ -17,5 +18,5 @@ module.exports = function compileTemplate (template, compiler) { } function toFunction (code) { - return 'function(){' + code + '}' + return transpile('function render () {' + code + '}') } diff --git a/package.json b/package.json index 1d8e9a6..db1dfae 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,8 @@ "source-map": "^0.5.6", "through": "^2.3.6", "vue-hot-reload-api": "^2.0.1", - "vue-template-compiler": "^2.0.0-alpha.8" + "vue-template-compiler": "^2.0.0-alpha.8", + "vue-template-es2015-compiler": "^1.2.2" }, "devDependencies": { "babel-core": "^6.0.0", From 97741fde0f6099ece99a07a6ef39d4283637642f Mon Sep 17 00:00:00 2001 From: Evan You Date: Sat, 12 Nov 2016 11:09:32 -0500 Subject: [PATCH 09/21] fix tests --- test/test.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/test.js b/test/test.js index 69d3e4b..dfcf92a 100644 --- a/test/test.js +++ b/test/test.js @@ -9,6 +9,7 @@ const browserify = require('browserify') const vueify = require('../index') const jsdom = require('jsdom') const vueCompiler = require('vue-template-compiler') +const transpile = require('vue-template-es2015-compiler') const genId = require('../lib/gen-id') const tempDir = path.resolve(__dirname, './temp') @@ -50,7 +51,7 @@ function testCssExtract (file, assert) { function assertRenderFn (options, template) { const compiled = vueCompiler.compile(template) - expect(options.render.toString()).to.equal('function (){' + compiled.render + '}') + expect(options.render.toString()).to.equal(transpile('function render() {' + compiled.render + '}')) } describe('vueify', () => { From 357f5818ccd968e98dfedfc6fb6b8a37726a0cdc Mon Sep 17 00:00:00 2001 From: Evan You Date: Sat, 12 Nov 2016 11:10:02 -0500 Subject: [PATCH 10/21] 9.3.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index db1dfae..4e0796a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vueify", - "version": "9.2.4", + "version": "9.3.0", "description": "Vue component transform for Browserify", "main": "index.js", "repository": { From 4e9eea85edd75dae080060ef7e9c693079c8b24c Mon Sep 17 00:00:00 2001 From: Adam Niederer Date: Thu, 8 Dec 2016 15:05:47 -0500 Subject: [PATCH 11/21] Load configuration from vue.config.js (#146) Resolves #116 and #145 --- index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/index.js b/index.js index 1bb2933..d789a83 100644 --- a/index.js +++ b/index.js @@ -6,6 +6,7 @@ module.exports = function vueify (file, options) { return through() } + compiler.loadConfig() compiler.applyConfig(options) compiler.applyConfig({ sourceMap: options._flags.debug From f77be6258c6fc47e8bd1af69c5724a179c8c1ab9 Mon Sep 17 00:00:00 2001 From: Mike Date: Thu, 8 Dec 2016 15:06:15 -0500 Subject: [PATCH 12/21] Fixed Node deprecated warning (#163) --- plugins/extract-css.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/extract-css.js b/plugins/extract-css.js index 740bb80..1b83eb6 100644 --- a/plugins/extract-css.js +++ b/plugins/extract-css.js @@ -18,7 +18,7 @@ module.exports = function (b, opts) { outPath.write(css) outPath.end() } else if (typeof outPath === 'string') { - fs.writeFile(outPath, css) + fs.writeFile(outPath, css, function () {}) } }) }) From 620e90e44ad779355fcd1150305fbcd3676e5567 Mon Sep 17 00:00:00 2001 From: Daniel Diekmeier Date: Thu, 8 Dec 2016 21:06:27 +0100 Subject: [PATCH 13/21] Fix link to browserify-simple (#155) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 809c89e..e55b78c 100644 --- a/README.md +++ b/README.md @@ -271,7 +271,7 @@ npm install browserify-hmr --save-dev watchify -p browserify-hmr index.js -o bundle.js ``` -You can scaffold a hot-reload enabled project easily using `vue-cli` and the [this template](https://github.com/vuejs-templates/browserify-simple-2.0). +You can scaffold a hot-reload enabled project easily using `vue-cli` and the [this template](https://github.com/vuejs-templates/browserify-simple). ## CSS Extraction From f25fb22856b762ca0eb0b82f49810fb55165dcae Mon Sep 17 00:00:00 2001 From: Daniel Diekmeier Date: Thu, 8 Dec 2016 21:08:49 +0100 Subject: [PATCH 14/21] Fix errors with scoped modules (#154) --- lib/style-rewriter.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/style-rewriter.js b/lib/style-rewriter.js index c631857..1195799 100644 --- a/lib/style-rewriter.js +++ b/lib/style-rewriter.js @@ -40,7 +40,7 @@ var addId = postcss.plugin('add-id', function () { */ module.exports = function (id, css, scoped, options) { - var key = id + '!!' + css + var key = id + '!!' + scoped + '!!' + css var val = cache.get(key) if (val) { return Promise.resolve(val) @@ -56,9 +56,16 @@ module.exports = function (id, css, scoped, options) { } // scoped css rewrite - if (scoped) { + // make sure the addId plugin is only pushed once + if (scoped && plugins.indexOf(addId) === -1) { plugins.push(addId) } + + // remove the addId plugin if the style block is not scoped + if (!scoped && plugins.indexOf(addId) !== -1) { + plugins.splice(plugins.indexOf(addId), 1) + } + // minification if (process.env.NODE_ENV === 'production') { plugins.push(require('cssnano')(assign({ From 1c2dce72248b36869b4144207f16da2e28f170bd Mon Sep 17 00:00:00 2001 From: Jason Date: Fri, 9 Dec 2016 04:10:25 +0800 Subject: [PATCH 15/21] use hash-sum for module id generation (#160) --- lib/gen-id.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/gen-id.js b/lib/gen-id.js index 25281ae..8c9621d 100644 --- a/lib/gen-id.js +++ b/lib/gen-id.js @@ -1,8 +1,8 @@ // utility for generating a uid for each component file // used in scoped CSS rewriting -var fileUid = 1 -var fileRegistry = Object.create(null) +var hash = require('hash-sum') +var cache = Object.create(null) module.exports = function genId (file) { - return fileRegistry[file] || (fileRegistry[file] = fileUid++) + return cache[file] || (cache[file] = hash(file)) } From 79793efcbc8a33af2162bfee784e7aac5141065a Mon Sep 17 00:00:00 2001 From: Jason Date: Fri, 9 Dec 2016 04:11:28 +0800 Subject: [PATCH 16/21] Parse babelrc with json5 (#161) * Parse babelrc with json5 * Include json5 in package.json --- lib/compilers/babel.js | 3 ++- package.json | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/compilers/babel.js b/lib/compilers/babel.js index d237ed6..323b23d 100644 --- a/lib/compilers/babel.js +++ b/lib/compilers/babel.js @@ -1,5 +1,6 @@ var fs = require('fs') var path = require('path') +var json = require('json5') var assign = require('object-assign') var ensureRequire = require('../ensure-require') @@ -16,7 +17,7 @@ var babelOptions = fs.existsSync(babelRcPath) function getBabelRc () { var rc try { - rc = JSON.parse(fs.readFileSync(babelRcPath, 'utf-8')) + rc = json.parse(fs.readFileSync(babelRcPath, 'utf-8')) } catch (e) { throw new Error('[vueify] Your .babelrc seems to be incorrectly formatted.') } diff --git a/package.json b/package.json index 4e0796a..8aaba5f 100644 --- a/package.json +++ b/package.json @@ -31,6 +31,7 @@ "postcss-selector-parser": "^2.0.0", "source-map": "^0.5.6", "through": "^2.3.6", + "json5": "^0.5.1", "vue-hot-reload-api": "^2.0.1", "vue-template-compiler": "^2.0.0-alpha.8", "vue-template-es2015-compiler": "^1.2.2" From 6c518d597385bab54d330482fd87835337626a85 Mon Sep 17 00:00:00 2001 From: Daniel Diekmeier Date: Thu, 8 Dec 2016 21:21:47 +0100 Subject: [PATCH 17/21] Remove listener leading to memory leak (#156) --- plugins/extract-css.js | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/plugins/extract-css.js b/plugins/extract-css.js index 1b83eb6..e3331e9 100644 --- a/plugins/extract-css.js +++ b/plugins/extract-css.js @@ -23,16 +23,11 @@ module.exports = function (b, opts) { }) }) - b.on('reset', listen) - listen() - - function listen () { - b.on('transform', function (tr, file) { - if (tr.vueify) { - tr.on('vueify-style', function (e) { - styles[e.file] = e.style - }) - } - }) - } + b.on('transform', function (tr, file) { + if (tr.vueify) { + tr.on('vueify-style', function (e) { + styles[e.file] = e.style + }) + } + }) } From 80e168ae34f9feee2eca5d76e386681442710753 Mon Sep 17 00:00:00 2001 From: Evan You Date: Thu, 8 Dec 2016 15:22:26 -0500 Subject: [PATCH 18/21] 9.4.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8aaba5f..c364b45 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vueify", - "version": "9.3.0", + "version": "9.4.0", "description": "Vue component transform for Browserify", "main": "index.js", "repository": { From 6992fc75de03b394d23b20983d08a6b81596a140 Mon Sep 17 00:00:00 2001 From: Toru Nagashima Date: Thu, 9 Mar 2017 11:42:31 +0900 Subject: [PATCH 19/21] Fix: invalid warning about babel (#183) --- lib/compilers/babel.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/compilers/babel.js b/lib/compilers/babel.js index 323b23d..be317b4 100644 --- a/lib/compilers/babel.js +++ b/lib/compilers/babel.js @@ -25,7 +25,7 @@ function getBabelRc () { } module.exports = function (raw, cb, compiler, filePath) { - if (babelOptions === defaultBabelOptions) { + if ((compiler.options.babel || babelOptions) === defaultBabelOptions) { try { ensureRequire('babel', ['babel-preset-es2015', 'babel-runtime', 'babel-plugin-transform-runtime']) } catch (e) { From 8d3159ff7d41bfaf1662056436a4252ea07219aa Mon Sep 17 00:00:00 2001 From: Evan You Date: Thu, 9 Mar 2017 10:42:56 +0800 Subject: [PATCH 20/21] 9.4.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c364b45..c1caee7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vueify", - "version": "9.4.0", + "version": "9.4.1", "description": "Vue component transform for Browserify", "main": "index.js", "repository": { From 0bcabf17b6c44cbe0e4c4ff85e3c79d22a853bd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorsten=20L=C3=BCnborg?= Date: Tue, 25 Dec 2018 23:58:40 +0100 Subject: [PATCH 21/21] Update README.md --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e55b78c..9a42c15 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,8 @@ -# vueify [![Build Status](https://circleci.com/gh/vuejs/vueify.svg?style=shield)](https://circleci.com/gh/vuejs/vueify) [![npm version](https://badge.fury.io/js/vueify.svg)](http://badge.fury.io/js/vueify) +# THIS REPOSITORY IS DEPRECATED + +> Note: We are concentrating our efforts on supporting webpack and rollup. + +## vueify [![Build Status](https://circleci.com/gh/vuejs/vueify.svg?style=shield)](https://circleci.com/gh/vuejs/vueify) [![npm version](https://badge.fury.io/js/vueify.svg)](http://badge.fury.io/js/vueify) > [Browserify](http://browserify.org/) transform for [Vue.js](http://vuejs.org/) components, with scoped CSS and component hot-reloading. pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy