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

Commit 53805bd

Browse files
committed
borrow vueify tests :p
1 parent 44b7ad5 commit 53805bd

40 files changed

+414
-17
lines changed

.babelrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
{
3+
"presets": ["es2015-rollup"],
4+
"ignore": ["dist/**", "node_modules/**"]
5+
}

.travis.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
language: node_js
2+
node_js:
3+
- "4.1"
4+
- "4.0"
5+
- "0.12"
6+
- "0.11"
7+
- "0.10"
8+
- "0.8"
9+
- "0.6"
10+
- "iojs"

dist/rollup-plugin-vue.common.js

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,39 @@
66
'use strict';
77

88
var rollupPluginutils = require('rollup-pluginutils');
9-
10-
var _require = require('vueify');
11-
12-
var compiler = _require.compiler;
9+
var vueify = require('vueify');
1310

1411
function plugin() {
1512
var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
1613

17-
var filter = rollupPluginutils.createFilter(options['include'], options['exclude']);
14+
var filter = rollupPluginutils.createFilter(options.include || '**/*.vue', options.exclude || 'node_modules/**');
1815

1916
return {
2017
transform: function transform(code, id) {
21-
if (!filter(id)) return;
18+
if (!filter(id)) {
19+
return null;
20+
}
2221

2322
return new Promise(function (resolve, reject) {
24-
compiler['compile'](code, id, function (error, compiled) {
25-
if (error) reject(compiled);
26-
27-
resolve(compiled);
23+
vueify.compiler['compile'](code, id, function (error, compiled) {
24+
var temp = {
25+
code: compiled,
26+
map: { mappings: '' }
27+
};
28+
29+
if (error) {
30+
temp.error = error;
31+
reject(temp);
32+
}
33+
34+
resolve(temp);
2835
});
2936
});
3037
}
3138
};
3239
}
3340

41+
plugin.compiler = vueify.compiler;
3442
plugin.version = '1.0.1';
3543

3644
module.exports = plugin;

package.json

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"description": "Roll .vue files",
55
"main": "dist/rollup-plugin-vue.common.js",
66
"scripts": {
7-
"build": "node --harmony config/build.js"
7+
"build": "NODE_ENV=production node --harmony config/build.js",
8+
"test": "NODE_ENV=production mocha --compilers js:babel-register test/test.js --slow=5000 --timeout=10000"
89
},
910
"repository": {
1011
"type": "git",
@@ -25,9 +26,27 @@
2526
"vueify": "latest"
2627
},
2728
"devDependencies": {
29+
"babel-plugin-transform-runtime": "^6.4.3",
30+
"babel-preset-es2015": "^6.3.13",
2831
"babel-preset-es2015-rollup": "^1.1.1",
32+
"babel-register": "^6.4.3",
33+
"coffee-script": "^1.10.0",
34+
"diff": "^2.2.1",
35+
"hash-sum": "latest",
36+
"html-minifier": "^1.1.1",
37+
"less": "^2.5.3",
38+
"minify": "^2.0.3",
39+
"mocha": "^2.3.4",
40+
"node-sass": "^3.4.2",
2941
"rollup": "^0.25.1",
3042
"rollup-plugin-babel": "^2.3.9",
31-
"rollup-plugin-replace": "^1.1.0"
43+
"rollup-plugin-commonjs": "^2.2.0",
44+
"rollup-plugin-replace": "^1.1.0",
45+
"stylus": "^0.53.0",
46+
"vue-hot-reload-api": "^1.2.2",
47+
"vueify-insert-css": "^1.0.0",
48+
"jade": "^1.11.0",
49+
"babel-core": "^6.1.2",
50+
"babel-runtime": "^5.8.0"
3251
}
3352
}

src/index.js

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,39 @@
11
import {createFilter} from 'rollup-pluginutils';
2-
const {compiler} = require('vueify');
2+
import {compiler} from 'vueify';
33

44
export default plugin;
55

6+
67
function plugin(options = {}) {
7-
let filter = createFilter(options['include'], options['exclude']);
8+
let filter = createFilter(options.include || '**/*.vue', options.exclude || 'node_modules/**');
89

910
return {
1011
transform(code, id) {
11-
if (!filter(id)) return;
12+
if (!filter(id)) {
13+
return null;
14+
}
1215

1316
return new Promise(
1417
function (resolve, reject) {
1518
compiler['compile'](code, id, function (error, compiled) {
16-
if (error) reject(compiled);
19+
let temp = {
20+
code: compiled,
21+
map: {mappings: ''}
22+
};
23+
24+
if (error) {
25+
temp.error = error;
26+
reject(temp);
27+
}
1728

18-
resolve(compiled);
29+
resolve(temp);
1930
});
2031
}
2132
);
2233
}
2334
};
2435
}
2536

37+
plugin.compiler = compiler;
2638
plugin.version = '1.0.1';
2739

test/expects/autoprefix.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/expects/basic.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
var __vueify_style__ = require("vueify-insert-css").insert("html{font-size:20px}")
2+
"use strict";
3+
4+
Object.defineProperty(exports, "__esModule", {
5+
value: true
6+
});
7+
8+
var _classCallCheck2 = require("babel-runtime/helpers/classCallCheck");
9+
10+
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
11+
12+
var _createClass2 = require("babel-runtime/helpers/createClass");
13+
14+
var _createClass3 = _interopRequireDefault(_createClass2);
15+
16+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17+
18+
var Test = (function () {
19+
function Test() {
20+
(0, _classCallCheck3.default)(this, Test);
21+
}
22+
23+
(0, _createClass3.default)(Test, [{
24+
key: "ok",
25+
value: function ok() {}
26+
}]);
27+
return Test;
28+
})();
29+
30+
var evens = [2, 4, 6, 8];
31+
var odds = evens.map(function (v) {
32+
return v + 1;
33+
});
34+
exports.default = {
35+
data: function data() {
36+
return odds;
37+
}
38+
};
39+
if (module.exports.__esModule) module.exports = module.exports.default
40+
;(typeof module.exports === "function"? module.exports.options: module.exports).template = "<h1 :id=id @click=hi>hello</h1><input type=text>"

test/expects/custom.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
console.log('ok')
2+
3+
if (module.exports.__esModule) module.exports = module.exports.default

test/expects/empty.js

Whitespace-only changes.

test/expects/jade.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)