Skip to content
This repository was archived by the owner on Jan 18, 2022. It is now read-only.

Commit 7f0a7d1

Browse files
committed
minimal impl using vue-component-compiler
1 parent 9e1b315 commit 7f0a7d1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+3261
-5214
lines changed

.babelrc

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
{
22
"presets": [
3-
[ "es2015", { "modules": false }],
4-
"stage-2"
5-
],
6-
"plugins": ["transform-runtime"],
7-
"retainLines": true,
8-
"comments": true
3+
["@babel/preset-env", {
4+
"modules": false,
5+
"targets": {
6+
"node": 6
7+
}
8+
}]
9+
]
910
}

.editorconfig

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# editorconfig.org
2+
3+
root = true
4+
5+
[*]
6+
charset = utf-8
7+
end_of_line = lf
8+
indent_size = 2
9+
indent_style = space
10+
insert_final_newline = true
11+
trim_trailing_whitespace = true
12+
13+
[*.md]
14+
trim_trailing_whitespace = false

.eslintrc.json

-27
This file was deleted.

.gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
dist/
22
/.github/sereno/public
33
/_cache
4-
test/style.css
4+
5+
test/target/
6+
57
# Logs
68
logs/
79
*.log

.npmignore

-9
This file was deleted.

config/banner.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
"use strict";
1+
'use strict'
22

3-
let pack = require('../package.json');
3+
const pack = require('../package.json')
44

5-
const VERSION = process.env.VERSION || pack.version;
6-
const YEAR = new Date().getFullYear();
5+
const VERSION = process.env.VERSION || pack.version
6+
const YEAR = new Date().getFullYear()
77

88
const BANNER = `/*!
99
* ${pack.name} v${VERSION}
1010
* (c) ${YEAR} ${pack.author}
1111
* Release under the ${pack.license} License.
12-
*/`;
12+
*/`
1313

14-
module.exports = BANNER;
14+
module.exports = BANNER

config/build.js

+35-52
Original file line numberDiff line numberDiff line change
@@ -2,65 +2,48 @@
22

33
const babel = require('rollup-plugin-babel')
44
const rollup = require('rollup')
5-
const replace = require('rollup-plugin-replace')
6-
const zlib = require('zlib')
75
const fs = require('fs')
86
const pack = require('../package.json')
9-
const banner = require('./banner')
107

11-
const main = fs
12-
.readFileSync('src/index.js', 'utf-8')
13-
.replace(/plugin\.version = '[\d\.]+'/, `plugin.version = '${pack.version}'`)
8+
const dependencies = Object.keys(pack.dependencies).concat('path')
149

15-
fs.writeFileSync('src/index.js', main)
16-
17-
rollup.rollup({
18-
input: 'src/index.js',
10+
rollup
11+
.rollup({
12+
entry: 'src/index.js',
13+
external(id) {
14+
return dependencies.some(it => it === id || id.startsWith(it))
15+
},
1916
plugins: [
20-
babel({ runtimeHelpers: true })
21-
],
22-
external (id) {
23-
if (/babel-runtime\/.*/i.test(id)) {
24-
return true
25-
}
26-
27-
return [
28-
'camelcase',
29-
'coffeescript-compiler',
30-
'de-indent',
31-
'debug',
32-
'fs',
33-
'hash-sum',
34-
'html-minifier',
35-
'less',
36-
'magic-string',
37-
'merge-options',
38-
'node-sass',
39-
'parse5',
40-
'path',
41-
'postcss',
42-
'postcss-load-config',
43-
'postcss-modules',
44-
'postcss-selector-parser',
45-
'posthtml',
46-
'posthtml-attrs-parser',
47-
'pug',
48-
'rollup-pluginutils',
49-
'stylus',
50-
'vue-template-es2015-compiler',
51-
'vue-template-validator',
52-
'typescript'
53-
].indexOf(id) > -1
54-
}
55-
}).then(function (bundle) {
17+
babel({
18+
exclude: 'node_modules/**',
19+
babelrc: false,
20+
presets: [
21+
[
22+
'@babel/preset-env',
23+
{
24+
modules: false,
25+
target: { node: 6 }
26+
}
27+
]
28+
],
29+
plugins: [
30+
'@babel/plugin-proposal-object-rest-spread',
31+
'@babel/plugin-transform-runtime'
32+
],
33+
runtimeHelpers: true
34+
})
35+
]
36+
})
37+
.then(function(bundle) {
5638
bundle.write({
57-
format: 'cjs',
58-
file: 'dist/' + pack.name + '.common.js'
39+
format: 'cjs',
40+
dest: 'dist/' + pack.name + '.common.js'
5941
})
6042
bundle.write({
61-
format: 'es',
62-
file: 'dist/' + pack.name + '.js'
43+
format: 'es',
44+
dest: 'dist/' + pack.name + '.js'
6345
})
64-
}).catch(function logError (e) {
46+
})
47+
.catch(function logError(e) {
6548
console.log(e)
66-
})
49+
})

docs/config.js

+43-36
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,58 @@
11
const languages = {
2-
title: 'Language',
3-
type: 'dropdown',
4-
exact: true,
5-
items: [
6-
{ title: 'English', path: '/en/', matchPath: /\/en\/.*/i }
7-
]
2+
title: 'Language',
3+
type: 'dropdown',
4+
exact: true,
5+
items: [{ title: 'English', path: '/en/', matchPath: /\/en\/.*/i }]
86
}
97

108
const home = { title: 'Home', path: '/' }
119

1210
const versions = [
13-
{ title: 'Version 2.2', path: '/2.2/', matchPath: /^\/([a-z-]+)\/2.2\/.*/i },
14-
{ title: 'Version 2.3', path: '/2.3/', matchPath: /^\/([a-z-]+)\/2.3\/.*/i },
11+
{ title: 'Version 2.2', path: '/2.2/', matchPath: /^\/([a-z-]+)\/2.2\/.*/i },
12+
{ title: 'Version 2.3', path: '/2.3/', matchPath: /^\/([a-z-]+)\/2.3\/.*/i }
1513
]
1614

1715
function lang_version(lang) {
18-
const version = {
19-
title: 'Version',
20-
type: 'dropdown',
21-
exact: true,
22-
}
23-
version.items = versions.map(function (v) {
24-
const ver = Object.assign({}, v)
25-
ver.path = '/' + lang + ver.path
26-
27-
return ver
28-
})
16+
const version = {
17+
title: 'Version',
18+
type: 'dropdown',
19+
exact: true
20+
}
21+
version.items = versions.map(function(v) {
22+
const ver = Object.assign({}, v)
23+
ver.path = '/' + lang + ver.path
2924

30-
return version
25+
return ver
26+
})
27+
28+
return version
3129
}
3230

3331
docute.init({
34-
repo: 'vuejs/rollup-plugin-vue',
35-
'edit-link': 'https://github.com/vuejs/rollup-plugin-vue/edit/master/docs',
36-
37-
nav: {
38-
default: [home, languages, lang_version('en')],
39-
'en2.3': [{ title: 'Home', path: '/en/2.3/' }, { title: 'Examples', path: '/en/2.3/examples' }, languages, lang_version('en')],
40-
'en2.2': [{ title: 'Home', path: '/en/2.2/' }, { title: 'Examples', path: '/en/2.2/examples' }, languages, lang_version('en')],
41-
},
42-
43-
plugins: [
44-
docsearch({
45-
apiKey: '7792597613e997afeb0b75a206ca0c5a',
46-
indexName: 'rollup-plugin-vue',
47-
url: 'https://vuejs.github.io/rollup-plugin-vue'
48-
})
32+
repo: 'vuejs/rollup-plugin-vue',
33+
'edit-link': 'https://github.com/vuejs/rollup-plugin-vue/edit/master/docs',
34+
35+
nav: {
36+
default: [home, languages, lang_version('en')],
37+
'en2.3': [
38+
{ title: 'Home', path: '/en/2.3/' },
39+
{ title: 'Examples', path: '/en/2.3/examples' },
40+
languages,
41+
lang_version('en')
42+
],
43+
'en2.2': [
44+
{ title: 'Home', path: '/en/2.2/' },
45+
{ title: 'Examples', path: '/en/2.2/examples' },
46+
languages,
47+
lang_version('en')
4948
]
50-
49+
},
50+
51+
plugins: [
52+
docsearch({
53+
apiKey: '7792597613e997afeb0b75a206ca0c5a',
54+
indexName: 'rollup-plugin-vue',
55+
url: 'https://vuejs.github.io/rollup-plugin-vue'
56+
})
57+
]
5158
})

example/Hello.vue

+2-12
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,13 @@
11
<template>
2-
<div class="hello">
3-
<h1 class="hello__title">{{ msg }}</h1>
4-
</div>
2+
<div class="hello"></div>
53
</template>
64

75
<script>
86
export default {
9-
data () {
7+
data() {
108
return {
119
msg: 'Hello World!'
1210
}
1311
}
1412
}
1513
</script>
16-
17-
<style lang="stylus">
18-
.hello {
19-
&__title {
20-
color: #42b983;
21-
}
22-
}
23-
</style>

example/Hello.vue.json

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"hello":"_hello_14kxd_18"}

example/build.js

+10-24
Original file line numberDiff line numberDiff line change
@@ -6,35 +6,21 @@ const CleanCSS = require('clean-css')
66
const fs = require('fs')
77
const stylus = require('stylus')
88

9-
109
rollup({
1110
entry: 'index.js',
12-
plugins: [
13-
vue({
14-
compileTemplate: true,
15-
css (styles, stylesNodes) {
16-
write('dist/papervue.styl', styles)
17-
stylus.render(styles, function (err, css) {
18-
if (err) throw err
19-
write('dist/papervue.css', css)
20-
write('dist/papervue.min.css', new CleanCSS().minify(css).styles)
21-
})
22-
}
23-
}),
24-
buble()
25-
]
11+
plugins: [vue(), buble()]
2612
})
27-
.then(function (bundle) {
13+
.then(function(bundle) {
2814
var code = bundle.generate({
2915
format: 'umd',
3016
moduleName: 'helloRollupVue',
3117
useStrict: false
3218
}).code
33-
return write('dist/papervue.js', code).then(function () {
19+
return write('dist/papervue.js', code).then(function() {
3420
return code
3521
})
3622
})
37-
.then(function (code) {
23+
.then(function(code) {
3824
var minified = uglify.minify(code, {
3925
fromString: true,
4026
output: {
@@ -45,24 +31,24 @@ rollup({
4531
})
4632
.catch(logError)
4733

48-
function write (dest, code) {
49-
return new Promise(function (resolve, reject) {
50-
fs.writeFile(dest, code, function (err) {
34+
function write(dest, code) {
35+
return new Promise(function(resolve, reject) {
36+
fs.writeFile(dest, code, function(err) {
5137
if (err) return reject(err)
5238
console.log(blue(dest) + ' ' + getSize(code))
5339
resolve()
5440
})
5541
})
5642
}
5743

58-
function getSize (code) {
44+
function getSize(code) {
5945
return (code.length / 1024).toFixed(2) + 'kb'
6046
}
6147

62-
function logError (e) {
48+
function logError(e) {
6349
console.log(e)
6450
}
6551

66-
function blue (str) {
52+
function blue(str) {
6753
return '\x1b[1m\x1b[34m' + str + '\x1b[39m\x1b[22m'
6854
}

0 commit comments

Comments
 (0)