jass-vue 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +21 -0
- data/README.md +43 -0
- data/lib/jass/vue.rb +12 -0
- data/lib/jass/vue/version.rb +5 -0
- data/vendor/node_modules/arr-diff/index.js +58 -0
- data/vendor/node_modules/arr-diff/package.json +49 -0
- data/vendor/node_modules/arr-flatten/index.js +22 -0
- data/vendor/node_modules/arr-flatten/package.json +76 -0
- data/vendor/node_modules/array-unique/index.js +28 -0
- data/vendor/node_modules/array-unique/package.json +37 -0
- data/vendor/node_modules/braces/index.js +399 -0
- data/vendor/node_modules/braces/package.json +83 -0
- data/vendor/node_modules/de-indent/index.js +45 -0
- data/vendor/node_modules/de-indent/package.json +25 -0
- data/vendor/node_modules/de-indent/test.js +30 -0
- data/vendor/node_modules/estree-walker/dist/estree-walker.es.js +55 -0
- data/vendor/node_modules/estree-walker/dist/estree-walker.es6.js +59 -0
- data/vendor/node_modules/estree-walker/dist/estree-walker.umd.js +65 -0
- data/vendor/node_modules/estree-walker/package.json +33 -0
- data/vendor/node_modules/estree-walker/src/estree-walker.js +49 -0
- data/vendor/node_modules/expand-brackets/index.js +163 -0
- data/vendor/node_modules/expand-brackets/package.json +62 -0
- data/vendor/node_modules/expand-range/index.js +43 -0
- data/vendor/node_modules/expand-range/package.json +73 -0
- data/vendor/node_modules/extglob/index.js +178 -0
- data/vendor/node_modules/extglob/package.json +60 -0
- data/vendor/node_modules/filename-regex/index.js +10 -0
- data/vendor/node_modules/filename-regex/package.json +50 -0
- data/vendor/node_modules/fill-range/index.js +408 -0
- data/vendor/node_modules/fill-range/package.json +61 -0
- data/vendor/node_modules/for-in/index.js +16 -0
- data/vendor/node_modules/for-in/package.json +68 -0
- data/vendor/node_modules/for-own/index.js +19 -0
- data/vendor/node_modules/for-own/package.json +70 -0
- data/vendor/node_modules/glob-base/index.js +51 -0
- data/vendor/node_modules/glob-base/package.json +52 -0
- data/vendor/node_modules/glob-parent/index.js +10 -0
- data/vendor/node_modules/glob-parent/package.json +35 -0
- data/vendor/node_modules/glob-parent/test.js +28 -0
- data/vendor/node_modules/he/bin/he +148 -0
- data/vendor/node_modules/he/he.js +342 -0
- data/vendor/node_modules/he/man/he.1 +78 -0
- data/vendor/node_modules/he/package.json +56 -0
- data/vendor/node_modules/is-buffer/index.js +21 -0
- data/vendor/node_modules/is-buffer/package.json +51 -0
- data/vendor/node_modules/is-dotfile/index.js +14 -0
- data/vendor/node_modules/is-dotfile/package.json +69 -0
- data/vendor/node_modules/is-equal-shallow/index.js +27 -0
- data/vendor/node_modules/is-equal-shallow/package.json +54 -0
- data/vendor/node_modules/is-extendable/index.js +13 -0
- data/vendor/node_modules/is-extendable/package.json +51 -0
- data/vendor/node_modules/is-extglob/index.js +11 -0
- data/vendor/node_modules/is-extglob/package.json +48 -0
- data/vendor/node_modules/is-glob/index.js +14 -0
- data/vendor/node_modules/is-glob/package.json +60 -0
- data/vendor/node_modules/is-number/index.js +19 -0
- data/vendor/node_modules/is-number/package.json +59 -0
- data/vendor/node_modules/is-posix-bracket/index.js +10 -0
- data/vendor/node_modules/is-posix-bracket/package.json +64 -0
- data/vendor/node_modules/is-primitive/index.js +13 -0
- data/vendor/node_modules/is-primitive/package.json +46 -0
- data/vendor/node_modules/isarray/index.js +5 -0
- data/vendor/node_modules/isarray/package.json +45 -0
- data/vendor/node_modules/isarray/test.js +20 -0
- data/vendor/node_modules/isobject/index.js +14 -0
- data/vendor/node_modules/isobject/package.json +67 -0
- data/vendor/node_modules/kind-of/index.js +116 -0
- data/vendor/node_modules/kind-of/package.json +90 -0
- data/vendor/node_modules/magic-string/dist/magic-string.cjs.js +1287 -0
- data/vendor/node_modules/magic-string/dist/magic-string.es.js +1283 -0
- data/vendor/node_modules/magic-string/dist/magic-string.umd.js +1339 -0
- data/vendor/node_modules/magic-string/package.json +60 -0
- data/vendor/node_modules/magic-string/src/Bundle.js +263 -0
- data/vendor/node_modules/magic-string/src/Chunk.js +154 -0
- data/vendor/node_modules/magic-string/src/MagicString.js +618 -0
- data/vendor/node_modules/magic-string/src/index-legacy.js +6 -0
- data/vendor/node_modules/magic-string/src/index.js +4 -0
- data/vendor/node_modules/magic-string/src/utils/Mappings.js +117 -0
- data/vendor/node_modules/magic-string/src/utils/SourceMap.js +21 -0
- data/vendor/node_modules/magic-string/src/utils/Stats.js +18 -0
- data/vendor/node_modules/magic-string/src/utils/btoa.js +13 -0
- data/vendor/node_modules/magic-string/src/utils/getLocator.js +35 -0
- data/vendor/node_modules/magic-string/src/utils/getRelativePath.js +18 -0
- data/vendor/node_modules/magic-string/src/utils/guessIndent.js +25 -0
- data/vendor/node_modules/magic-string/src/utils/hasOwnProp.js +1 -0
- data/vendor/node_modules/magic-string/src/utils/isObject.js +5 -0
- data/vendor/node_modules/micromatch/index.js +431 -0
- data/vendor/node_modules/micromatch/lib/chars.js +67 -0
- data/vendor/node_modules/micromatch/lib/expand.js +304 -0
- data/vendor/node_modules/micromatch/lib/glob.js +193 -0
- data/vendor/node_modules/micromatch/lib/utils.js +149 -0
- data/vendor/node_modules/micromatch/package.json +114 -0
- data/vendor/node_modules/normalize-path/index.js +19 -0
- data/vendor/node_modules/normalize-path/package.json +78 -0
- data/vendor/node_modules/object.omit/index.js +40 -0
- data/vendor/node_modules/object.omit/package.json +67 -0
- data/vendor/node_modules/parse-glob/index.js +156 -0
- data/vendor/node_modules/parse-glob/package.json +62 -0
- data/vendor/node_modules/preserve/index.js +54 -0
- data/vendor/node_modules/preserve/package.json +48 -0
- data/vendor/node_modules/preserve/test.js +48 -0
- data/vendor/node_modules/randomatic/index.js +82 -0
- data/vendor/node_modules/randomatic/node_modules/is-number/index.js +22 -0
- data/vendor/node_modules/randomatic/node_modules/is-number/node_modules/kind-of/index.js +116 -0
- data/vendor/node_modules/randomatic/node_modules/is-number/node_modules/kind-of/package.json +90 -0
- data/vendor/node_modules/randomatic/node_modules/is-number/package.json +83 -0
- data/vendor/node_modules/randomatic/node_modules/kind-of/index.js +119 -0
- data/vendor/node_modules/randomatic/node_modules/kind-of/package.json +90 -0
- data/vendor/node_modules/randomatic/package.json +78 -0
- data/vendor/node_modules/regex-cache/index.js +68 -0
- data/vendor/node_modules/regex-cache/package.json +64 -0
- data/vendor/node_modules/remove-trailing-separator/index.js +17 -0
- data/vendor/node_modules/remove-trailing-separator/package.json +37 -0
- data/vendor/node_modules/repeat-element/index.js +18 -0
- data/vendor/node_modules/repeat-element/package.json +44 -0
- data/vendor/node_modules/repeat-string/index.js +70 -0
- data/vendor/node_modules/repeat-string/package.json +77 -0
- data/vendor/node_modules/rollup-plugin-vue2/dist/rollup-plugin-vue2.common.js +164 -0
- data/vendor/node_modules/rollup-plugin-vue2/dist/rollup-plugin-vue2.es.js +160 -0
- data/vendor/node_modules/rollup-plugin-vue2/package.json +50 -0
- data/vendor/node_modules/rollup-pluginutils/dist/pluginutils.cjs.js +223 -0
- data/vendor/node_modules/rollup-pluginutils/dist/pluginutils.es.js +214 -0
- data/vendor/node_modules/rollup-pluginutils/dist/pluginutils.es6.js +217 -0
- data/vendor/node_modules/rollup-pluginutils/package.json +40 -0
- data/vendor/node_modules/rollup-pluginutils/src/addExtension.js +6 -0
- data/vendor/node_modules/rollup-pluginutils/src/attachScopes.js +147 -0
- data/vendor/node_modules/rollup-pluginutils/src/createFilter.js +33 -0
- data/vendor/node_modules/rollup-pluginutils/src/index.js +4 -0
- data/vendor/node_modules/rollup-pluginutils/src/makeLegalIdentifier.js +15 -0
- data/vendor/node_modules/rollup-pluginutils/src/utils/ensureArray.js +5 -0
- data/vendor/node_modules/vlq/dist/vlq.js +91 -0
- data/vendor/node_modules/vlq/package.json +27 -0
- data/vendor/node_modules/vlq/src/vlq.js +78 -0
- data/vendor/node_modules/vue-template-compiler/browser.js +5237 -0
- data/vendor/node_modules/vue-template-compiler/build.js +4835 -0
- data/vendor/node_modules/vue-template-compiler/index.js +18 -0
- data/vendor/node_modules/vue-template-compiler/package.json +27 -0
- data/vendor/node_modules/vue-template-es2015-compiler/buble.js +14112 -0
- data/vendor/node_modules/vue-template-es2015-compiler/index.js +24 -0
- data/vendor/node_modules/vue-template-es2015-compiler/package.json +28 -0
- data/vendor/package.json +9 -0
- data/vendor/yarn.lock +268 -0
- metadata +242 -0
@@ -0,0 +1,164 @@
|
|
1
|
+
/*!
|
2
|
+
* rollup-plugin-vue2 v0.8.0
|
3
|
+
* (c) 2017 Thomas Ghysels <info@thomasg.be>
|
4
|
+
* Release under the MIT License.
|
5
|
+
*/
|
6
|
+
'use strict';
|
7
|
+
|
8
|
+
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
9
|
+
|
10
|
+
var rollupPluginutils = require('rollup-pluginutils');
|
11
|
+
var compiler = _interopDefault(require('vue-template-compiler'));
|
12
|
+
var transpile = _interopDefault(require('vue-template-es2015-compiler'));
|
13
|
+
var MagicString = _interopDefault(require('magic-string'));
|
14
|
+
var path = require('path');
|
15
|
+
var fs = require('fs');
|
16
|
+
|
17
|
+
function vue2 (options) {
|
18
|
+
if ( options === void 0 ) options = {};
|
19
|
+
|
20
|
+
var filter = rollupPluginutils.createFilter(options.include || '**/*.vue', options.exclude);
|
21
|
+
var styles = {};
|
22
|
+
var scripts = {}; // catch Vue render functions
|
23
|
+
|
24
|
+
return {
|
25
|
+
name: 'vue2',
|
26
|
+
resolveId: function resolveId (id) {
|
27
|
+
if (id.indexOf('.vue.component.') !== -1) {
|
28
|
+
return id
|
29
|
+
}
|
30
|
+
},
|
31
|
+
load: function load (id) {
|
32
|
+
if (id.indexOf('.vue.component.') !== -1) {
|
33
|
+
id = id.slice(0, id.lastIndexOf('.vue.component.') + 4);
|
34
|
+
return styles[id] || ''
|
35
|
+
}
|
36
|
+
},
|
37
|
+
transform: function transform (code, id) {
|
38
|
+
if (id.endsWith('vue.common.js') || id.endsWith('vue.runtime.common.js')) {
|
39
|
+
return vueCommon(code)
|
40
|
+
}
|
41
|
+
if (!filter(id)) {
|
42
|
+
return
|
43
|
+
}
|
44
|
+
|
45
|
+
code = vueTransform(code, id, scripts);
|
46
|
+
|
47
|
+
// Map of every stylesheet
|
48
|
+
styles[id] = code.css;
|
49
|
+
|
50
|
+
return code
|
51
|
+
}
|
52
|
+
}
|
53
|
+
}
|
54
|
+
|
55
|
+
function vueCommon (code) {
|
56
|
+
code = code
|
57
|
+
.replace(/process\.env\.VUE_ENV/g, JSON.stringify(process.env.VUE_ENV || ''))
|
58
|
+
.replace(/process\.env\.NODE_ENV/g, JSON.stringify(process.env.NODE_ENV || ''));
|
59
|
+
|
60
|
+
return {
|
61
|
+
code: code,
|
62
|
+
map: { mappings: '' }
|
63
|
+
}
|
64
|
+
}
|
65
|
+
|
66
|
+
function vueTransform (code, id, scripts) {
|
67
|
+
var nodes = compiler.parseComponent(code);
|
68
|
+
var s = new MagicString(code);
|
69
|
+
var exportOffset = 0;
|
70
|
+
if (nodes.script) {
|
71
|
+
if (nodes.script.src) {
|
72
|
+
var script = readSrc(id, nodes.script.src);
|
73
|
+
exportOffset = indexOfExport(script, 0);
|
74
|
+
if (exportOffset) {
|
75
|
+
s.overwrite(0, exportOffset, script.slice(0, exportOffset));
|
76
|
+
s.overwrite(exportOffset, code.length, script.slice(exportOffset));
|
77
|
+
}
|
78
|
+
} else {
|
79
|
+
s.remove(nodes.script.end, s.original.length);
|
80
|
+
s.remove(0, nodes.script.start);
|
81
|
+
exportOffset = indexOfExport(s.toString(), nodes.script.start);
|
82
|
+
}
|
83
|
+
}
|
84
|
+
|
85
|
+
// The script cannot be valid so let's overwrite it
|
86
|
+
if (exportOffset < 15) {
|
87
|
+
exportOffset = 16;
|
88
|
+
s.overwrite(0, 16, 'export default {');
|
89
|
+
s.overwrite(16, code.length, '\nstub: 1\n}');
|
90
|
+
}
|
91
|
+
|
92
|
+
// Precompile and inject Vue template
|
93
|
+
if (nodes.template) {
|
94
|
+
scripts[id] = injectTemplate(s, nodes.template, exportOffset, id);
|
95
|
+
}
|
96
|
+
|
97
|
+
// Import css as a module
|
98
|
+
// Example: import "./src/App.vue.component.css"
|
99
|
+
var css;
|
100
|
+
if (nodes.styles) {
|
101
|
+
nodes.styles.forEach(function (style) {
|
102
|
+
if (style.src) {
|
103
|
+
s.prepend('import ' + JSON.stringify(style.src) + '\n');
|
104
|
+
} else {
|
105
|
+
var lang = style.lang || 'css';
|
106
|
+
s.prepend('import ' + JSON.stringify(id + '.component.' + lang) + '\n');
|
107
|
+
css = (css || '') + style.content;
|
108
|
+
}
|
109
|
+
});
|
110
|
+
}
|
111
|
+
|
112
|
+
return {
|
113
|
+
code: s.toString(),
|
114
|
+
map: s.generateMap({ hires: true }),
|
115
|
+
css: css
|
116
|
+
}
|
117
|
+
}
|
118
|
+
|
119
|
+
function readSrc (id, src) {
|
120
|
+
if (src.startsWith('./') || src.startsWith('/') || src.startsWith('../')) {
|
121
|
+
src = path.resolve(id, '..', src);
|
122
|
+
} else {
|
123
|
+
src = require.resolve(src);
|
124
|
+
}
|
125
|
+
return fs.readFileSync(src, 'utf8')
|
126
|
+
}
|
127
|
+
|
128
|
+
function indexOfExport (code, start) {
|
129
|
+
var match = /export\s+default\s+\{/.exec(code);
|
130
|
+
if (match && match[0]) {
|
131
|
+
return match.index + match[0].length + start
|
132
|
+
}
|
133
|
+
return 0
|
134
|
+
}
|
135
|
+
|
136
|
+
/**
|
137
|
+
* Only support for es5 modules
|
138
|
+
*
|
139
|
+
* @param script
|
140
|
+
* @param template
|
141
|
+
* @returns {string}
|
142
|
+
*/
|
143
|
+
function injectTemplate (s, node, offset, id) {
|
144
|
+
var t = node.src ? readSrc(id, node.src) : node.content;
|
145
|
+
|
146
|
+
// Compile template
|
147
|
+
var compiled = compiler.compile(t);
|
148
|
+
var renderFuncs = '\nrender: ' + toFunction(compiled.render) + ',' +
|
149
|
+
'\nstaticRenderFns: [' + compiled.staticRenderFns.map(toFunction).join(',') + '],';
|
150
|
+
s.appendLeft(offset, renderFuncs);
|
151
|
+
return renderFuncs
|
152
|
+
}
|
153
|
+
|
154
|
+
/**
|
155
|
+
* Wrap a piece of code in a function
|
156
|
+
*
|
157
|
+
* @param {String} code
|
158
|
+
* @return {String}
|
159
|
+
*/
|
160
|
+
function toFunction (code) {
|
161
|
+
return transpile('(function(){' + code + '})').slice(1, -1)
|
162
|
+
}
|
163
|
+
|
164
|
+
module.exports = vue2;
|
@@ -0,0 +1,160 @@
|
|
1
|
+
/*!
|
2
|
+
* rollup-plugin-vue2 v0.8.0
|
3
|
+
* (c) 2017 Thomas Ghysels <info@thomasg.be>
|
4
|
+
* Release under the MIT License.
|
5
|
+
*/
|
6
|
+
import { createFilter } from 'rollup-pluginutils';
|
7
|
+
import compiler from 'vue-template-compiler';
|
8
|
+
import transpile from 'vue-template-es2015-compiler';
|
9
|
+
import MagicString from 'magic-string';
|
10
|
+
import { resolve } from 'path';
|
11
|
+
import { readFileSync } from 'fs';
|
12
|
+
|
13
|
+
function vue2 (options) {
|
14
|
+
if ( options === void 0 ) options = {};
|
15
|
+
|
16
|
+
var filter = createFilter(options.include || '**/*.vue', options.exclude);
|
17
|
+
var styles = {};
|
18
|
+
var scripts = {}; // catch Vue render functions
|
19
|
+
|
20
|
+
return {
|
21
|
+
name: 'vue2',
|
22
|
+
resolveId: function resolveId (id) {
|
23
|
+
if (id.indexOf('.vue.component.') !== -1) {
|
24
|
+
return id
|
25
|
+
}
|
26
|
+
},
|
27
|
+
load: function load (id) {
|
28
|
+
if (id.indexOf('.vue.component.') !== -1) {
|
29
|
+
id = id.slice(0, id.lastIndexOf('.vue.component.') + 4);
|
30
|
+
return styles[id] || ''
|
31
|
+
}
|
32
|
+
},
|
33
|
+
transform: function transform (code, id) {
|
34
|
+
if (id.endsWith('vue.common.js') || id.endsWith('vue.runtime.common.js')) {
|
35
|
+
return vueCommon(code)
|
36
|
+
}
|
37
|
+
if (!filter(id)) {
|
38
|
+
return
|
39
|
+
}
|
40
|
+
|
41
|
+
code = vueTransform(code, id, scripts);
|
42
|
+
|
43
|
+
// Map of every stylesheet
|
44
|
+
styles[id] = code.css;
|
45
|
+
|
46
|
+
return code
|
47
|
+
}
|
48
|
+
}
|
49
|
+
}
|
50
|
+
|
51
|
+
function vueCommon (code) {
|
52
|
+
code = code
|
53
|
+
.replace(/process\.env\.VUE_ENV/g, JSON.stringify(process.env.VUE_ENV || ''))
|
54
|
+
.replace(/process\.env\.NODE_ENV/g, JSON.stringify(process.env.NODE_ENV || ''));
|
55
|
+
|
56
|
+
return {
|
57
|
+
code: code,
|
58
|
+
map: { mappings: '' }
|
59
|
+
}
|
60
|
+
}
|
61
|
+
|
62
|
+
function vueTransform (code, id, scripts) {
|
63
|
+
var nodes = compiler.parseComponent(code);
|
64
|
+
var s = new MagicString(code);
|
65
|
+
var exportOffset = 0;
|
66
|
+
if (nodes.script) {
|
67
|
+
if (nodes.script.src) {
|
68
|
+
var script = readSrc(id, nodes.script.src);
|
69
|
+
exportOffset = indexOfExport(script, 0);
|
70
|
+
if (exportOffset) {
|
71
|
+
s.overwrite(0, exportOffset, script.slice(0, exportOffset));
|
72
|
+
s.overwrite(exportOffset, code.length, script.slice(exportOffset));
|
73
|
+
}
|
74
|
+
} else {
|
75
|
+
s.remove(nodes.script.end, s.original.length);
|
76
|
+
s.remove(0, nodes.script.start);
|
77
|
+
exportOffset = indexOfExport(s.toString(), nodes.script.start);
|
78
|
+
}
|
79
|
+
}
|
80
|
+
|
81
|
+
// The script cannot be valid so let's overwrite it
|
82
|
+
if (exportOffset < 15) {
|
83
|
+
exportOffset = 16;
|
84
|
+
s.overwrite(0, 16, 'export default {');
|
85
|
+
s.overwrite(16, code.length, '\nstub: 1\n}');
|
86
|
+
}
|
87
|
+
|
88
|
+
// Precompile and inject Vue template
|
89
|
+
if (nodes.template) {
|
90
|
+
scripts[id] = injectTemplate(s, nodes.template, exportOffset, id);
|
91
|
+
}
|
92
|
+
|
93
|
+
// Import css as a module
|
94
|
+
// Example: import "./src/App.vue.component.css"
|
95
|
+
var css;
|
96
|
+
if (nodes.styles) {
|
97
|
+
nodes.styles.forEach(function (style) {
|
98
|
+
if (style.src) {
|
99
|
+
s.prepend('import ' + JSON.stringify(style.src) + '\n');
|
100
|
+
} else {
|
101
|
+
var lang = style.lang || 'css';
|
102
|
+
s.prepend('import ' + JSON.stringify(id + '.component.' + lang) + '\n');
|
103
|
+
css = (css || '') + style.content;
|
104
|
+
}
|
105
|
+
});
|
106
|
+
}
|
107
|
+
|
108
|
+
return {
|
109
|
+
code: s.toString(),
|
110
|
+
map: s.generateMap({ hires: true }),
|
111
|
+
css: css
|
112
|
+
}
|
113
|
+
}
|
114
|
+
|
115
|
+
function readSrc (id, src) {
|
116
|
+
if (src.startsWith('./') || src.startsWith('/') || src.startsWith('../')) {
|
117
|
+
src = resolve(id, '..', src);
|
118
|
+
} else {
|
119
|
+
src = require.resolve(src);
|
120
|
+
}
|
121
|
+
return readFileSync(src, 'utf8')
|
122
|
+
}
|
123
|
+
|
124
|
+
function indexOfExport (code, start) {
|
125
|
+
var match = /export\s+default\s+\{/.exec(code);
|
126
|
+
if (match && match[0]) {
|
127
|
+
return match.index + match[0].length + start
|
128
|
+
}
|
129
|
+
return 0
|
130
|
+
}
|
131
|
+
|
132
|
+
/**
|
133
|
+
* Only support for es5 modules
|
134
|
+
*
|
135
|
+
* @param script
|
136
|
+
* @param template
|
137
|
+
* @returns {string}
|
138
|
+
*/
|
139
|
+
function injectTemplate (s, node, offset, id) {
|
140
|
+
var t = node.src ? readSrc(id, node.src) : node.content;
|
141
|
+
|
142
|
+
// Compile template
|
143
|
+
var compiled = compiler.compile(t);
|
144
|
+
var renderFuncs = '\nrender: ' + toFunction(compiled.render) + ',' +
|
145
|
+
'\nstaticRenderFns: [' + compiled.staticRenderFns.map(toFunction).join(',') + '],';
|
146
|
+
s.appendLeft(offset, renderFuncs);
|
147
|
+
return renderFuncs
|
148
|
+
}
|
149
|
+
|
150
|
+
/**
|
151
|
+
* Wrap a piece of code in a function
|
152
|
+
*
|
153
|
+
* @param {String} code
|
154
|
+
* @return {String}
|
155
|
+
*/
|
156
|
+
function toFunction (code) {
|
157
|
+
return transpile('(function(){' + code + '})').slice(1, -1)
|
158
|
+
}
|
159
|
+
|
160
|
+
export default vue2;
|
@@ -0,0 +1,50 @@
|
|
1
|
+
{
|
2
|
+
"name": "rollup-plugin-vue2",
|
3
|
+
"version": "0.8.0",
|
4
|
+
"description": "Rollup plugin for Vue 2.0 components",
|
5
|
+
"main": "dist/rollup-plugin-vue2.common.js",
|
6
|
+
"jsnext": "dist/rollup-plugin-vue2.es.js",
|
7
|
+
"scripts": {
|
8
|
+
"build": "rollup -c -f cjs -o dist/rollup-plugin-vue2.common.js && rollup -c -o dist/rollup-plugin-vue2.es.js",
|
9
|
+
"dev": "rollup -cw -f cjs -o dist/rollup-plugin-vue2.common.js",
|
10
|
+
"test": "yarn lint && yarn build && yarn unit",
|
11
|
+
"lint": "standard rollup.config.js test/test.js src/**",
|
12
|
+
"unit": "cross-env NODE_ENV=production mocha test/test.js",
|
13
|
+
"prepublish": "npm run build"
|
14
|
+
},
|
15
|
+
"files": [
|
16
|
+
"dist"
|
17
|
+
],
|
18
|
+
"repository": {
|
19
|
+
"type": "git",
|
20
|
+
"url": "git+https://github.com/thgh/rollup-plugin-vue2.git"
|
21
|
+
},
|
22
|
+
"keywords": [
|
23
|
+
"rollup-plugin",
|
24
|
+
"vue",
|
25
|
+
"vue2",
|
26
|
+
"template-compiler"
|
27
|
+
],
|
28
|
+
"author": "Thomas Ghysels <info@thomasg.be>",
|
29
|
+
"license": "MIT",
|
30
|
+
"bugs": {
|
31
|
+
"url": "https://github.com/thgh/rollup-plugin-vue2/issues"
|
32
|
+
},
|
33
|
+
"homepage": "https://github.com/thgh/rollup-plugin-vue2#readme",
|
34
|
+
"dependencies": {
|
35
|
+
"magic-string": "^0.19.0",
|
36
|
+
"rollup-pluginutils": "^1.5.2||2.x",
|
37
|
+
"vue-template-compiler": "^2.1.3",
|
38
|
+
"vue-template-es2015-compiler": "^1.5.0"
|
39
|
+
},
|
40
|
+
"devDependencies": {
|
41
|
+
"cross-env": "^3.1.4",
|
42
|
+
"eslint-plugin-promise": "^3.4.0",
|
43
|
+
"eslint-plugin-standard": "^2.0.1",
|
44
|
+
"mocha": "^3.2.0",
|
45
|
+
"rollup": "^0.41.4",
|
46
|
+
"rollup-plugin-buble": "^0.15.0",
|
47
|
+
"rollup-plugin-css-only": "0.2.0",
|
48
|
+
"standard": "^8.6.0"
|
49
|
+
}
|
50
|
+
}
|
@@ -0,0 +1,223 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
4
|
+
|
5
|
+
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
6
|
+
|
7
|
+
var path = require('path');
|
8
|
+
var estreeWalker = require('estree-walker');
|
9
|
+
var mm = _interopDefault(require('micromatch'));
|
10
|
+
|
11
|
+
function addExtension ( filename, ext ) {
|
12
|
+
if ( ext === void 0 ) ext = '.js';
|
13
|
+
|
14
|
+
if ( !path.extname( filename ) ) { filename += ext; }
|
15
|
+
return filename;
|
16
|
+
}
|
17
|
+
|
18
|
+
var blockDeclarations = {
|
19
|
+
'const': true,
|
20
|
+
'let': true
|
21
|
+
};
|
22
|
+
|
23
|
+
var extractors = {
|
24
|
+
Identifier: function Identifier ( names, param ) {
|
25
|
+
names.push( param.name );
|
26
|
+
},
|
27
|
+
|
28
|
+
ObjectPattern: function ObjectPattern ( names, param ) {
|
29
|
+
param.properties.forEach( function (prop) {
|
30
|
+
extractors[ prop.key.type ]( names, prop.key );
|
31
|
+
});
|
32
|
+
},
|
33
|
+
|
34
|
+
ArrayPattern: function ArrayPattern ( names, param ) {
|
35
|
+
param.elements.forEach( function (element) {
|
36
|
+
if ( element ) { extractors[ element.type ]( names, element ); }
|
37
|
+
});
|
38
|
+
},
|
39
|
+
|
40
|
+
RestElement: function RestElement ( names, param ) {
|
41
|
+
extractors[ param.argument.type ]( names, param.argument );
|
42
|
+
},
|
43
|
+
|
44
|
+
AssignmentPattern: function AssignmentPattern ( names, param ) {
|
45
|
+
return extractors[ param.left.type ]( names, param.left );
|
46
|
+
}
|
47
|
+
};
|
48
|
+
|
49
|
+
function extractNames ( param ) {
|
50
|
+
var names = [];
|
51
|
+
|
52
|
+
extractors[ param.type ]( names, param );
|
53
|
+
return names;
|
54
|
+
}
|
55
|
+
|
56
|
+
var Scope = function Scope ( options ) {
|
57
|
+
var this$1 = this;
|
58
|
+
|
59
|
+
options = options || {};
|
60
|
+
|
61
|
+
this.parent = options.parent;
|
62
|
+
this.isBlockScope = !!options.block;
|
63
|
+
|
64
|
+
this.declarations = Object.create( null );
|
65
|
+
|
66
|
+
if ( options.params ) {
|
67
|
+
options.params.forEach( function (param) {
|
68
|
+
extractNames( param ).forEach( function (name) {
|
69
|
+
this$1.declarations[ name ] = true;
|
70
|
+
});
|
71
|
+
});
|
72
|
+
}
|
73
|
+
};
|
74
|
+
|
75
|
+
Scope.prototype.addDeclaration = function addDeclaration ( node, isBlockDeclaration, isVar ) {
|
76
|
+
var this$1 = this;
|
77
|
+
|
78
|
+
if ( !isBlockDeclaration && this.isBlockScope ) {
|
79
|
+
// it's a `var` or function node, and this
|
80
|
+
// is a block scope, so we need to go up
|
81
|
+
this.parent.addDeclaration( node, isBlockDeclaration, isVar );
|
82
|
+
} else {
|
83
|
+
extractNames( node.id ).forEach( function (name) {
|
84
|
+
this$1.declarations[ name ] = true;
|
85
|
+
});
|
86
|
+
}
|
87
|
+
};
|
88
|
+
|
89
|
+
Scope.prototype.contains = function contains ( name ) {
|
90
|
+
return this.declarations[ name ] ||
|
91
|
+
( this.parent ? this.parent.contains( name ) : false );
|
92
|
+
};
|
93
|
+
|
94
|
+
|
95
|
+
function attachScopes ( ast, propertyName ) {
|
96
|
+
if ( propertyName === void 0 ) propertyName = 'scope';
|
97
|
+
|
98
|
+
var scope = new Scope();
|
99
|
+
|
100
|
+
estreeWalker.walk( ast, {
|
101
|
+
enter: function enter ( node, parent ) {
|
102
|
+
// function foo () {...}
|
103
|
+
// class Foo {...}
|
104
|
+
if ( /(Function|Class)Declaration/.test( node.type ) ) {
|
105
|
+
scope.addDeclaration( node, false, false );
|
106
|
+
}
|
107
|
+
|
108
|
+
// var foo = 1
|
109
|
+
if ( node.type === 'VariableDeclaration' ) {
|
110
|
+
var isBlockDeclaration = blockDeclarations[ node.kind ];
|
111
|
+
|
112
|
+
node.declarations.forEach( function (declaration) {
|
113
|
+
scope.addDeclaration( declaration, isBlockDeclaration, true );
|
114
|
+
});
|
115
|
+
}
|
116
|
+
|
117
|
+
var newScope;
|
118
|
+
|
119
|
+
// create new function scope
|
120
|
+
if ( /Function/.test( node.type ) ) {
|
121
|
+
newScope = new Scope({
|
122
|
+
parent: scope,
|
123
|
+
block: false,
|
124
|
+
params: node.params
|
125
|
+
});
|
126
|
+
|
127
|
+
// named function expressions - the name is considered
|
128
|
+
// part of the function's scope
|
129
|
+
if ( node.type === 'FunctionExpression' && node.id ) {
|
130
|
+
newScope.addDeclaration( node, false, false );
|
131
|
+
}
|
132
|
+
}
|
133
|
+
|
134
|
+
// create new block scope
|
135
|
+
if ( node.type === 'BlockStatement' && !/Function/.test( parent.type ) ) {
|
136
|
+
newScope = new Scope({
|
137
|
+
parent: scope,
|
138
|
+
block: true
|
139
|
+
});
|
140
|
+
}
|
141
|
+
|
142
|
+
// catch clause has its own block scope
|
143
|
+
if ( node.type === 'CatchClause' ) {
|
144
|
+
newScope = new Scope({
|
145
|
+
parent: scope,
|
146
|
+
params: [ node.param ],
|
147
|
+
block: true
|
148
|
+
});
|
149
|
+
}
|
150
|
+
|
151
|
+
if ( newScope ) {
|
152
|
+
Object.defineProperty( node, propertyName, {
|
153
|
+
value: newScope,
|
154
|
+
configurable: true
|
155
|
+
});
|
156
|
+
|
157
|
+
scope = newScope;
|
158
|
+
}
|
159
|
+
},
|
160
|
+
leave: function leave ( node ) {
|
161
|
+
if ( node[ propertyName ] ) { scope = scope.parent; }
|
162
|
+
}
|
163
|
+
});
|
164
|
+
|
165
|
+
return scope;
|
166
|
+
}
|
167
|
+
|
168
|
+
function ensureArray ( thing ) {
|
169
|
+
if ( Array.isArray( thing ) ) { return thing; }
|
170
|
+
if ( thing == undefined ) { return []; }
|
171
|
+
return [ thing ];
|
172
|
+
}
|
173
|
+
|
174
|
+
function createFilter ( include, exclude ) {
|
175
|
+
var getMatcher = function (id) { return ( isRegexp( id ) ? id : { test: mm.matcher( path.resolve( id ) ) } ); };
|
176
|
+
include = ensureArray( include ).map( getMatcher );
|
177
|
+
exclude = ensureArray( exclude ).map( getMatcher );
|
178
|
+
|
179
|
+
return function ( id ) {
|
180
|
+
|
181
|
+
if ( typeof id !== 'string' ) { return false; }
|
182
|
+
if ( /\0/.test( id ) ) { return false; }
|
183
|
+
|
184
|
+
id = id.split( path.sep ).join( '/' );
|
185
|
+
|
186
|
+
for ( var i = 0; i < exclude.length; ++i ) {
|
187
|
+
var matcher = exclude[i];
|
188
|
+
if ( matcher.test( id ) ) { return false; }
|
189
|
+
}
|
190
|
+
|
191
|
+
for ( var i$1 = 0; i$1 < include.length; ++i$1 ) {
|
192
|
+
var matcher$1 = include[i$1];
|
193
|
+
if ( matcher$1.test( id ) ) { return true; }
|
194
|
+
}
|
195
|
+
|
196
|
+
return !include.length;
|
197
|
+
};
|
198
|
+
}
|
199
|
+
|
200
|
+
function isRegexp ( val ) {
|
201
|
+
return val instanceof RegExp;
|
202
|
+
}
|
203
|
+
|
204
|
+
var reservedWords = 'break case class catch const continue debugger default delete do else export extends finally for function if import in instanceof let new return super switch this throw try typeof var void while with yield enum await implements package protected static interface private public'.split( ' ' );
|
205
|
+
var builtins = 'arguments Infinity NaN undefined null true false eval uneval isFinite isNaN parseFloat parseInt decodeURI decodeURIComponent encodeURI encodeURIComponent escape unescape Object Function Boolean Symbol Error EvalError InternalError RangeError ReferenceError SyntaxError TypeError URIError Number Math Date String RegExp Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array Map Set WeakMap WeakSet SIMD ArrayBuffer DataView JSON Promise Generator GeneratorFunction Reflect Proxy Intl'.split( ' ' );
|
206
|
+
|
207
|
+
var blacklisted = Object.create( null );
|
208
|
+
reservedWords.concat( builtins ).forEach( function (word) { return blacklisted[ word ] = true; } );
|
209
|
+
|
210
|
+
function makeLegalIdentifier ( str ) {
|
211
|
+
str = str
|
212
|
+
.replace( /-(\w)/g, function ( _, letter ) { return letter.toUpperCase(); } )
|
213
|
+
.replace( /[^$_a-zA-Z0-9]/g, '_' );
|
214
|
+
|
215
|
+
if ( /\d/.test( str[0] ) || blacklisted[ str ] ) { str = "_" + str; }
|
216
|
+
|
217
|
+
return str;
|
218
|
+
}
|
219
|
+
|
220
|
+
exports.addExtension = addExtension;
|
221
|
+
exports.attachScopes = attachScopes;
|
222
|
+
exports.createFilter = createFilter;
|
223
|
+
exports.makeLegalIdentifier = makeLegalIdentifier;
|