-
-
Notifications
You must be signed in to change notification settings - Fork 33.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit a879ec0
Showing
35 changed files
with
3,671 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"env": { | ||
"development": { | ||
"presets": ["es2015", "stage-2"] | ||
}, | ||
"production": { | ||
"presets": ["es2015-rollup", "stage-2"] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.DS_Store | ||
node_modules | ||
npm-debug.log | ||
explorations | ||
TODOs.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
var fs = require('fs') | ||
var zlib = require('zlib') | ||
var rollup = require('rollup') | ||
var uglify = require('uglify-js') | ||
var babel = require('rollup-plugin-babel') | ||
var node = require('rollup-plugin-node-resolve') | ||
var commonjs = require('rollup-plugin-commonjs') | ||
var replace = require('rollup-plugin-replace') | ||
var version = process.env.VERSION || require('../package.json').version | ||
|
||
var banner = | ||
'/*!\n' + | ||
' * Vue.js v' + version + '\n' + | ||
' * (c) ' + new Date().getFullYear() + ' Evan You\n' + | ||
' * Released under the MIT License.\n' + | ||
' */' | ||
|
||
// update main file | ||
var main = fs | ||
.readFileSync('src/index.js', 'utf-8') | ||
.replace(/Vue\.version = '[\d\.]+'/, "Vue.version = '" + version + "'") | ||
fs.writeFileSync('src/index.js', main) | ||
|
||
var plugins = [ | ||
node(), | ||
commonjs({ | ||
include: 'node_modules/**' | ||
}), | ||
babel({ | ||
exclude: 'node_modules/**' | ||
}) | ||
] | ||
|
||
// CommonJS build. | ||
// this is used as the "main" field in package.json | ||
// and used by bundlers like Webpack and Browserify. | ||
rollup.rollup({ | ||
entry: 'src/index.js', | ||
plugins: plugins | ||
}) | ||
.then(function (bundle) { | ||
return write('dist/vue.common.js', bundle.generate({ | ||
format: 'cjs', | ||
banner: banner | ||
}).code) | ||
}) | ||
// Standalone Dev Build | ||
.then(function () { | ||
return rollup.rollup({ | ||
entry: 'src/index.js', | ||
plugins: [ | ||
replace({ | ||
'process.env.NODE_ENV': "'development'" | ||
}) | ||
].concat(plugins) | ||
}) | ||
.then(function (bundle) { | ||
return write('dist/vue.js', bundle.generate({ | ||
format: 'umd', | ||
banner: banner, | ||
moduleName: 'Vue' | ||
}).code) | ||
}) | ||
}) | ||
.then(function () { | ||
// Standalone Production Build | ||
return rollup.rollup({ | ||
entry: 'src/index.js', | ||
plugins: [ | ||
replace({ | ||
'process.env.NODE_ENV': "'production'" | ||
}) | ||
].concat(plugins) | ||
}) | ||
.then(function (bundle) { | ||
var code = bundle.generate({ | ||
format: 'umd', | ||
moduleName: 'Vue' | ||
}).code | ||
var minified = banner + '\n' + uglify.minify(code, { | ||
fromString: true, | ||
output: { | ||
ascii_only: true | ||
} | ||
}).code | ||
return write('dist/vue.min.js', minified) | ||
}) | ||
.then(zip) | ||
}) | ||
.catch(logError) | ||
|
||
function write (dest, code) { | ||
return new Promise(function (resolve, reject) { | ||
fs.writeFile(dest, code, function (err) { | ||
if (err) return reject(err) | ||
console.log(blue(dest) + ' ' + getSize(code)) | ||
resolve() | ||
}) | ||
}) | ||
} | ||
|
||
function zip () { | ||
return new Promise(function (resolve, reject) { | ||
fs.readFile('dist/vue.min.js', function (err, buf) { | ||
if (err) return reject(err) | ||
zlib.gzip(buf, function (err, buf) { | ||
if (err) return reject(err) | ||
write('dist/vue.min.js.gz', buf).then(resolve) | ||
}) | ||
}) | ||
}) | ||
} | ||
|
||
function getSize (code) { | ||
return (code.length / 1024).toFixed(2) + 'kb' | ||
} | ||
|
||
function logError (e) { | ||
console.log(e) | ||
} | ||
|
||
function blue (str) { | ||
return '\x1b[1m\x1b[34m' + str + '\x1b[39m\x1b[22m' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{ | ||
"name": "vue-lite", | ||
"version": "1.0.0", | ||
"description": "Lighter-weight Vue on virtual dom", | ||
"main": "index.js", | ||
"scripts": { | ||
"dev": "webpack --watch", | ||
"test": "mocha", | ||
"build": "NODE_ENV=production node build/build.js" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/vuejs/vue-lite.git" | ||
}, | ||
"keywords": [ | ||
"vue" | ||
], | ||
"author": "Evan You", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/vuejs/vue-lite/issues" | ||
}, | ||
"homepage": "https://github.com/vuejs/vue-lite#readme", | ||
"devDependencies": { | ||
"babel-core": "^6.0.0", | ||
"babel-loader": "^6.0.0", | ||
"babel-preset-es2015": "^6.0.0", | ||
"babel-preset-es2015-rollup": "^1.1.1", | ||
"babel-preset-stage-2": "^6.0.0", | ||
"rollup": "^0.25.8", | ||
"rollup-plugin-babel": "^2.4.0", | ||
"rollup-plugin-commonjs": "^2.2.1", | ||
"rollup-plugin-node-resolve": "^1.5.0", | ||
"rollup-plugin-replace": "^1.1.0", | ||
"uglify-js": "^2.6.2", | ||
"webpack": "^1.12.14" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
import { parseText } from './text-parser' | ||
|
||
const bindRE = /^:|^v-bind:/ | ||
const onRE = /^@|^v-on:/ | ||
const mustUsePropsRE = /^(value|selected|checked|muted)$/ | ||
|
||
export function generate (ast) { | ||
const code = genElement(ast) | ||
return new Function (`with (this) { return ${code}}`) | ||
} | ||
|
||
function genElement (el, key) { | ||
let exp | ||
if (exp = getAttr(el, 'v-for')) { | ||
return genFor(el, exp) | ||
} else if (exp = getAttr(el, 'v-if')) { | ||
return genIf(el, exp) | ||
} else if (el.tag === 'template') { | ||
return genChildren(el) | ||
} else { | ||
return `__h__('${ el.tag }', ${ genData(el, key) }, ${ genChildren(el) })` | ||
} | ||
} | ||
|
||
function genIf (el, exp) { | ||
return `(${ exp }) ? ${ genElement(el) } : ''` | ||
} | ||
|
||
function genFor (el, exp) { | ||
const inMatch = exp.match(/([a-zA-Z_][\w]*)\s+(?:in|of)\s+(.*)/) | ||
if (!inMatch) { | ||
throw new Error('Invalid v-for expression: '+ exp) | ||
} | ||
const alias = inMatch[1].trim() | ||
exp = inMatch[2].trim() | ||
const key = el.attrsMap['track-by'] || 'undefined' | ||
return `(${ exp }).map(function (${ alias }, $index) {return ${ genElement(el, key) }})` | ||
} | ||
|
||
function genData (el, key) { | ||
if (!el.attrs.length) { | ||
return '{}' | ||
} | ||
let data = key ? `{key:${ key },` : `{` | ||
if (el.attrsMap[':class'] || el.attrsMap['class']) { | ||
data += `class: _renderClass(${ el.attrsMap[':class'] }, "${ el.attrsMap['class'] || '' }"),` | ||
} | ||
let attrs = `attrs:{` | ||
let props = `props:{` | ||
let hasAttrs = false | ||
let hasProps = false | ||
for (let i = 0, l = el.attrs.length; i < l; i++) { | ||
let attr = el.attrs[i] | ||
let name = attr.name | ||
if (bindRE.test(name)) { | ||
name = name.replace(bindRE, '') | ||
if (name === 'class') { | ||
continue | ||
} else if (name === 'style') { | ||
data += `style: ${ attr.value },` | ||
} else if (mustUsePropsRE.test(name)) { | ||
hasProps = true | ||
props += `"${ name }": (${ attr.value }),` | ||
} else { | ||
hasAttrs = true | ||
attrs += `"${ name }": (${ attr.value }),` | ||
} | ||
} else if (onRE.test(name)) { | ||
name = name.replace(onRE, '') | ||
// TODO | ||
} else if (name !== 'class') { | ||
hasAttrs = true | ||
attrs += `"${ name }": (${ JSON.stringify(attr.value) }),` | ||
} | ||
} | ||
if (hasAttrs) { | ||
data += attrs.slice(0, -1) + '},' | ||
} | ||
if (hasProps) { | ||
data += props.slice(0, -1) + '},' | ||
} | ||
return data.replace(/,$/, '') + '}' | ||
} | ||
|
||
function genChildren (el) { | ||
if (!el.children.length) { | ||
return 'undefined' | ||
} | ||
return '__flatten__([' + el.children.map(genNode).join(',') + '])' | ||
} | ||
|
||
function genNode (node) { | ||
if (node.tag) { | ||
return genElement(node) | ||
} else { | ||
return genText(node) | ||
} | ||
} | ||
|
||
function genText (text) { | ||
if (text === ' ') { | ||
return '" "' | ||
} else { | ||
const exp = parseText(text) | ||
if (exp) { | ||
return 'String(' + escapeNewlines(exp) + ')' | ||
} else { | ||
return escapeNewlines(JSON.stringify(text)) | ||
} | ||
} | ||
} | ||
|
||
function escapeNewlines (str) { | ||
return str.replace(/\n/g, '\\n') | ||
} | ||
|
||
function getAttr (el, attr) { | ||
let val | ||
if (val = el.attrsMap[attr]) { | ||
el.attrsMap[attr] = null | ||
for (let i = 0, l = el.attrs.length; i < l; i++) { | ||
if (el.attrs[i].name === attr) { | ||
el.attrs.splice(i, 1) | ||
break | ||
} | ||
} | ||
} | ||
return val | ||
} |
Oops, something went wrong.
a879ec0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job!
a879ec0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice
a879ec0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
终于找到第一个commit
a879ec0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perfect!!
a879ec0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The beginning!
a879ec0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the first commit
a879ec0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tue Oct 08 2019 15:39:22
a879ec0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will start learn from this commit
a879ec0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
~
a879ec0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
在此膜拜前端大神尤雨溪
a879ec0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
从第一个commit开始学习😄
a879ec0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
观摩大神的第一个commit
a879ec0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is where it all started. The origin story of vue.js.
a879ec0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
来到这里彷佛穿越时空回到过去了
a879ec0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changing the commit number in the url navigate us to the start of everything.
a879ec0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
v3.0.0 One Piece
a879ec0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里其实不算是第一个Commit,branch 为 0.10 的才是。
a879ec0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good job
a879ec0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great job
a879ec0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like a migration. Where's the original repo?
a879ec0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ben kaldım kardeşş
a879ec0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello vue
a879ec0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Baby vue
a879ec0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Came here with FirstCommitter ❤️