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

Commit b0895db

Browse files
committed
minimal impl using vue-component-compiler
1 parent 73bb8a0 commit b0895db

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

+3267
-5196
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

+45-64
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,49 @@
1-
"use strict";
1+
'use strict'
22

3-
const babel = require('rollup-plugin-babel');
4-
const rollup = require('rollup');
5-
const replace = require('rollup-plugin-replace');
6-
const zlib = require('zlib');
7-
const fs = require('fs');
8-
const pack = require('../package.json');
9-
const banner = require('./banner');
3+
const babel = require('rollup-plugin-babel')
4+
const rollup = require('rollup')
5+
const fs = require('fs')
6+
const pack = require('../package.json')
107

11-
let 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-
entry: 'src/index.js',
19-
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-
})
56-
.then(function (bundle) {
57-
bundle.write({
58-
format: 'cjs',
59-
dest: 'dist/' + pack.name + '.common.js',
60-
});
61-
bundle.write({
62-
format: 'es',
63-
dest: 'dist/' + pack.name + '.js',
64-
});
10+
rollup
11+
.rollup({
12+
entry: 'src/index.js',
13+
external(id) {
14+
return dependencies.some(it => it === id || id.startsWith(it))
15+
},
16+
plugins: [
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
6534
})
66-
.catch(function logError(e) {
67-
console.log(e)
68-
});
35+
]
36+
})
37+
.then(function(bundle) {
38+
bundle.write({
39+
format: 'cjs',
40+
dest: 'dist/' + pack.name + '.common.js'
41+
})
42+
bundle.write({
43+
format: 'es',
44+
dest: 'dist/' + pack.name + '.js'
45+
})
46+
})
47+
.catch(function logError(e) {
48+
console.log(e)
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"}

0 commit comments

Comments
 (0)