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

Commit 1ad7aa1

Browse files
jonataswalkerznck
authored andcommitted
Update deps (#160)
* Update Rollup and other deps * Add keepClosingSlash to options * Tests
1 parent c7f25a9 commit 1ad7aa1

File tree

6 files changed

+114
-84
lines changed

6 files changed

+114
-84
lines changed

config/build.js

Lines changed: 59 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,66 @@
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 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')
1010

11-
let main = fs
11+
const main = fs
1212
.readFileSync('src/index.js', 'utf-8')
13-
.replace(/plugin\.version = '[\d\.]+'/, `plugin.version = '${pack.version}'`);
13+
.replace(/plugin\.version = '[\d\.]+'/, `plugin.version = '${pack.version}'`)
1414

15-
fs.writeFileSync('src/index.js', main);
15+
fs.writeFileSync('src/index.js', main)
1616

1717
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-
}
18+
input: 'src/index.js',
19+
plugins: [
20+
babel({ runtimeHelpers: true })
21+
],
22+
external (id) {
23+
if (/babel-runtime\/.*/i.test(id)) {
24+
return true
25+
}
2626

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-
});
65-
})
66-
.catch(function logError(e) {
67-
console.log(e)
68-
});
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) {
56+
bundle.write({
57+
format: 'cjs',
58+
file: 'dist/' + pack.name + '.common.js'
59+
})
60+
bundle.write({
61+
format: 'es',
62+
file: 'dist/' + pack.name + '.js'
63+
})
64+
}).catch(function logError (e) {
65+
console.log(e)
66+
})

package.json

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,21 +37,21 @@
3737
"babel-runtime": "^6.22.0",
3838
"camelcase": "^4.0.0",
3939
"de-indent": "^1.0.2",
40-
"debug": "^2.6.0",
40+
"debug": "^3.1.0",
4141
"hash-sum": "^1.0.2",
4242
"html-minifier": "^3.2.3",
43-
"magic-string": "^0.19.0",
44-
"merge-options": "0.0.64",
45-
"parse5": "^2.1.0",
43+
"magic-string": "^0.22.4",
44+
"merge-options": "^1.0.0",
45+
"parse5": "^3.0.3",
4646
"postcss": "^5.2.11",
4747
"postcss-load-config": "^1.2.0",
4848
"postcss-modules": "^0.6.4",
4949
"postcss-selector-parser": "^2.2.3",
50-
"posthtml": "^0.9.2",
50+
"posthtml": "^0.10.1",
5151
"posthtml-attrs-parser": "^0.1.1",
5252
"rollup-pluginutils": "^2.0.1",
5353
"typescript": "^2.4.1",
54-
"vue-template-es2015-compiler": "^1.5.0",
54+
"vue-template-es2015-compiler": "^1.6.0",
5555
"vue-template-validator": "^1.1.5"
5656
},
5757
"devDependencies": {
@@ -68,14 +68,14 @@
6868
"eslint-plugin-promise": "^3.4.0",
6969
"eslint-plugin-standard": "^2.0.1",
7070
"istanbul": "^0.4.5",
71-
"mocha": "^3.2.0",
72-
"rollup": "^0.41.4",
71+
"mocha": "^4.0.1",
72+
"rollup": "^0.52.0",
7373
"rollup-plugin-babel": "^2.7.1",
74-
"rollup-plugin-buble": "^0.15.0",
74+
"rollup-plugin-buble": "^0.18.0",
7575
"rollup-plugin-css-only": "^0.2.0",
76-
"rollup-plugin-replace": "^1.1.1",
76+
"rollup-plugin-replace": "^2.0.0",
7777
"uglify-js": "^2.7.5",
78-
"vue-template-compiler": "^2.4.4"
78+
"vue-template-compiler": "^2.5.9"
7979
},
8080
"optionalDependencies": {
8181
"coffee-script": "^1.12.4",

src/options.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export default {
1818
customAttrSurround: [[/@/, new RegExp('')], [/:/, new RegExp('')]],
1919
collapseWhitespace: true,
2020
conservativeCollapse: true,
21+
keepClosingSlash: true,
2122
removeComments: true
2223
},
2324

test/expects/selfClosingComponent.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
var evens = [2,4,6,8];
2+
var odds = evens.map(v => v + 1);
3+
var Basic = { template: "<h1 :id=\"id\" @click=\"hi\">hello</h1> <input type=\"text\">",
4+
data() {
5+
return odds
6+
}
7+
};
8+
9+
var selfClosingComponent = { template: "<main> <basic/> <h1>Hey</h1> </main>",
10+
components: {
11+
Basic
12+
}
13+
};
14+
15+
export default selfClosingComponent;
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<template>
2+
<main>
3+
<basic />
4+
<h1>Hey</h1>
5+
</main>
6+
</template>
7+
8+
<script>
9+
import Basic from './basic.vue'
10+
11+
export default {
12+
components: {
13+
Basic
14+
}
15+
}
16+
</script>

test/test.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,12 @@ var autoprefixer = require('autoprefixer')
99

1010
process.chdir(__dirname)
1111

12-
function read(file) {
12+
function read (file) {
1313
return fs.readFileSync(path.resolve(__dirname, file), 'utf-8')
1414
}
1515

16-
function test(name) {
16+
function test (name) {
1717
it('should rollup ' + name + '.vue', function () {
18-
1918
var entry = './fixtures/' + name + '.vue'
2019
var expected = read('expects/' + name + '.js').replace(/\r/g, '')
2120
var actualCss
@@ -28,7 +27,7 @@ function test(name) {
2827
}
2928

3029
return rollup.rollup({
31-
entry: entry,
30+
input: entry,
3231
plugins: [vuePlugin({
3332
css: ['no-css-extract'].indexOf(name) > -1 ? true : cssHandler,
3433
modules: {
@@ -45,7 +44,8 @@ function test(name) {
4544
autoStyles: ['scoped-css-with-no-auto-style'].indexOf(name) < 0
4645
})]
4746
}).then(function (bundle) {
48-
var result = bundle.generate({ format: 'es' })
47+
return bundle.generate({ format: 'es' })
48+
}).then(function (result) {
4949
var code = result.code
5050
assert.equal(code.trim(), expected.trim(), 'should compile code correctly')
5151

@@ -98,20 +98,20 @@ describe('styleToImports', function () {
9898

9999
return rollup.rollup({
100100
format: 'cjs',
101-
entry: entry,
101+
input: entry,
102102
plugins: [
103103
vuePlugin({
104-
styleToImports: true,
104+
styleToImports: true
105105
}),
106106
cssPlugin({
107107
output: function (css) {
108108
actualCss = css
109-
},
110-
}),
111-
],
109+
}
110+
})
111+
]
112112
}).then(function (bundle) {
113-
bundle.generate({ format: 'es' })
114-
113+
return bundle.generate({ format: 'es' })
114+
}).then(function () {
115115
assert.equal(expectedCss.trim(), actualCss.trim(), 'should import style')
116116
}).catch(function (error) {
117117
throw error

0 commit comments

Comments
 (0)