Permalink
Browse files

feat: use @vue/component-compiler

  • Loading branch information...
znck committed May 1, 2018
1 parent 31a8c57 commit e110aa087403ca0c0e60d4dcee0efb94e964b872
Showing with 12,885 additions and 3,943 deletions.
  1. +13 −2 README.md
  2. +6 −6 config/banner.js
  3. +35 −53 config/build.js
  4. +43 −36 docs/config.js
  5. +6 −13 example/Hello.vue
  6. +10 −24 example/build.js
  7. +16 −0 example/package.json
  8. +13 −16 example/rollup.config.js
  9. +972 −0 example/yarn.lock
  10. +7,569 −0 package-lock.json
  11. +30 −58 package.json
  12. +10 −0 src/.babelrc
  13. +0 −3 src/debug.js
  14. +174 −0 src/delegate.js
  15. +0 −15 src/gen-scope-id.js
  16. +4 −79 src/index.js
  17. +0 −143 src/injections.js
  18. +0 −109 src/options.js
  19. +0 −15 src/script/coffee.js
  20. +0 −2 src/script/index.js
  21. +0 −14 src/script/typescript.js
  22. +52 −0 src/simple.js
  23. +0 −168 src/style/css.js
  24. +0 −78 src/style/index.js
  25. +0 −27 src/style/less/index.js
  26. +0 −27 src/style/postcss.js
  27. +0 −22 src/style/scss.js
  28. +0 −18 src/style/stylus.js
  29. +0 −30 src/template/html.js
  30. +0 −12 src/template/index.js
  31. +0 −6 src/template/pug.js
  32. +56 −0 src/utils.js
  33. +0 −268 src/vueTransform.js
  34. +43 −0 test/baseline.spec.js
  35. +0 −9 test/expects/basic.js
  36. +0 −11 test/expects/coffee.js
  37. +0 −19 test/expects/compileTemplate.js
  38. +0 −9 test/expects/compileTemplateLocalComponent.js
  39. +0 −3 test/expects/css-modules-static.css
  40. +0 −3 test/expects/css-modules-static.js
  41. +0 −3 test/expects/css-modules.css
  42. +0 −3 test/expects/css-modules.js
  43. +0 −3 test/expects/empty-less.css
  44. +0 −3 test/expects/empty-less.js
  45. +0 −10 test/expects/expression.js
  46. +0 −3 test/expects/external-script.css
  47. +0 −14 test/expects/external-script.js
  48. +0 −3 test/expects/import-less.js
  49. +0 −2 test/expects/import-scss.css
  50. +0 −3 test/expects/import-scss.js
  51. +0 −15 test/expects/imports.js
  52. +0 −3 test/expects/less.css
  53. +0 −3 test/expects/less.js
  54. +0 −8 test/expects/no-css-extract.js
  55. +0 −4 test/expects/noScript.js
  56. +0 −10 test/expects/noTemplate.js
  57. +0 −6 test/expects/postcss.css
  58. +0 −3 test/expects/postcss.js
  59. +0 −2 test/expects/pug.css
  60. +0 −3 test/expects/pug.js
  61. +0 −2 test/expects/sass.css
  62. +0 −3 test/expects/sass.js
  63. +0 −35 test/expects/scoped-css-with-deep-tag.css
  64. +0 −3 test/expects/scoped-css-with-deep-tag.js
  65. +0 −16 test/expects/scoped-css-with-no-auto-style.css
  66. +0 −3 test/expects/scoped-css-with-no-auto-style.js
  67. +0 −3 test/expects/scoped-css.css
  68. +0 −3 test/expects/scoped-css.js
  69. +0 −2 test/expects/scss.css
  70. +0 −3 test/expects/scss.js
  71. +0 −15 test/expects/selfClosingComponent.js
  72. +0 −7 test/expects/slot.js
  73. +0 −3 test/expects/style.css
  74. +0 −9 test/expects/style.js
  75. +0 −3 test/expects/stylus.css
  76. +0 −3 test/expects/stylus.js
  77. +0 −3 test/expects/table-n-slot.js
  78. +0 −3 test/expects/table.js
  79. +0 −7 test/expects/typescript-export-obj.js
  80. +0 −12 test/expects/typescript.js
  81. +0 −2 test/fixtures/app.ts
  82. +3 −6 test/fixtures/basic.vue
  83. +0 −8 test/fixtures/coffee.vue
  84. +0 −25 test/fixtures/compileTemplate.vue
  85. +0 −15 test/fixtures/compileTemplateLocalComponent.vue
  86. +0 −13 test/fixtures/css-modules-static.vue
  87. +0 −13 test/fixtures/css-modules.vue
  88. +0 −14 test/fixtures/empty-less.vue
  89. +0 −14 test/fixtures/expression.vue
  90. +0 −9 test/fixtures/external-script.js
  91. +0 −11 test/fixtures/external-script.vue
  92. +0 −11 test/fixtures/import-less.vue
  93. +0 −11 test/fixtures/import-scss.vue
  94. +0 −15 test/fixtures/imports.vue
  95. +0 −16 test/fixtures/less.vue
  96. BIN test/fixtures/logo.png
  97. +0 −28 test/fixtures/no-css-extract.vue
  98. +0 −3 test/fixtures/noScript.vue
  99. +0 −10 test/fixtures/noTemplate.vue
  100. +7 −0 test/fixtures/only-script.vue
  101. +3 −0 test/fixtures/only-template.vue
  102. +0 −8 test/fixtures/postcss.vue
  103. +0 −24 test/fixtures/pug.vue
  104. +0 −15 test/fixtures/sass.vue
  105. +0 −31 test/fixtures/scoped-css-with-deep-tag.vue
  106. +0 −19 test/fixtures/scoped-css-with-no-auto-style.vue
  107. +0 −13 test/fixtures/scoped-css.vue
  108. +5 −0 test/fixtures/script.js
  109. +0 −16 test/fixtures/scss.vue
  110. +0 −16 test/fixtures/selfClosingComponent.vue
  111. +0 −13 test/fixtures/slot.vue
  112. +0 −5 test/fixtures/some.less
  113. +0 −5 test/fixtures/some.scss
  114. +2 −2 test/{expects/import-less.css → fixtures/style.css}
  115. +0 −20 test/fixtures/style.vue
  116. +0 −14 test/fixtures/stylus.vue
  117. +0 −11 test/fixtures/table-n-slot.vue
  118. +0 −13 test/fixtures/table.vue
  119. +1 −0 test/fixtures/template.html
  120. +0 −10 test/fixtures/typescript-export-obj.vue
  121. +0 −24 test/fixtures/typescript.vue
  122. +19 −0 test/fixtures/with-custom-block.vue
  123. +5 −0 test/fixtures/with-import-script.vue
  124. +13 −0 test/fixtures/with-import-style.vue
  125. +9 −0 test/fixtures/with-import-template.vue
  126. +19 −0 test/fixtures/with-langs.vue
  127. +8 −0 test/fixtures/with-render-functional-style.vue
  128. +17 −0 test/fixtures/with-style-css-modules.vue
  129. +23 −0 test/fixtures/with-style-named-css-module.vue
  130. +57 −0 test/fixtures/with-style-scoped.vue
  131. +17 −0 test/fixtures/with-style.vue
  132. +22 −0 test/fixtures/with-template-comment.vue
  133. +18 −0 test/fixtures/with-template-functional-root.vue
  134. +22 −0 test/fixtures/with-template-functional.vue
  135. +25 −0 test/fixtures/with-template-require-transform.vue
  136. +109 −0 test/setup/index.js
  137. +0 −120 test/test.js
  138. +3,429 −1,800 yarn.lock
@@ -7,8 +7,6 @@ As vue-loader is for webpack and vueify is for browserify, similarly its for rol

With rollup you can break your application into reusable modules.

> See [docs](http://vuejs.github.io/rollup-plugin-vue) for installing, using and contributing.
<p align="center">
<a href="https://circleci.com/gh/vuejs/rollup-plugin-vue">
<img src="https://circleci.com/gh/vuejs/rollup-plugin-vue.svg?style=svg" alt="Build Status" />
@@ -37,6 +35,19 @@ With rollup you can break your application into reusable modules.
</a>
</p>

## Usage

```js
import vue from 'rollup-plugin-vue'
export default {
entry: 'main.js',
plugins: [
vue(/* options */)
]
}
```

## Security

If you discover any security related issues, please email hi@znck.me instead of using the issue tracker.
@@ -1,14 +1,14 @@
"use strict";
'use strict'

let pack = require('../package.json');
const pack = require('../package.json')

const VERSION = process.env.VERSION || pack.version;
const YEAR = new Date().getFullYear();
const VERSION = process.env.VERSION || pack.version
const YEAR = new Date().getFullYear()

const BANNER = `/*!
* ${pack.name} v${VERSION}
* (c) ${YEAR} ${pack.author}
* Release under the ${pack.license} License.
*/`;
*/`

module.exports = BANNER;
module.exports = BANNER
@@ -2,65 +2,47 @@

const babel = require('rollup-plugin-babel')
const rollup = require('rollup')
const replace = require('rollup-plugin-replace')
const zlib = require('zlib')
const fs = require('fs')
const pack = require('../package.json')
const banner = require('./banner')

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

fs.writeFileSync('src/index.js', main)

rollup.rollup({
rollup
.rollup({
input: 'src/index.js',
external(id) {
return dependencies.some(it => it === id || id.startsWith(it))
},
plugins: [
babel({ runtimeHelpers: true })
],
external (id) {
if (/babel-runtime\/.*/i.test(id)) {
return true
}

return [
'camelcase',
'coffeescript-compiler',
'de-indent',
'debug',
'fs',
'hash-sum',
'html-minifier',
'less',
'magic-string',
'merge-options',
'node-sass',
'parse5',
'path',
'postcss',
'postcss-load-config',
'postcss-modules',
'postcss-selector-parser',
'posthtml',
'posthtml-attrs-parser',
'pug',
'rollup-pluginutils',
'stylus',
'vue-template-es2015-compiler',
'vue-template-validator',
'typescript'
].indexOf(id) > -1
}
}).then(function (bundle) {
babel({
exclude: 'node_modules/**',
babelrc: false,
presets: [
[
'@babel/preset-env',
{
modules: false,
target: { node: 6 }
}
]
],
plugins: [
'@babel/plugin-proposal-object-rest-spread',
'@babel/plugin-transform-runtime'
],
runtimeHelpers: true
})
]
})
.then(bundle => {
bundle.write({
format: 'cjs',
file: 'dist/' + pack.name + '.common.js'
format: 'cjs',
file: 'dist/' + pack.name + '.common.js',
sourcemap: true
})
bundle.write({
format: 'es',
file: 'dist/' + pack.name + '.js'
format: 'es',
file: 'dist/' + pack.name + '.js',
sourcemap: true
})
}).catch(function logError (e) {
console.log(e)
})
})
.catch(console.error)
@@ -1,51 +1,58 @@
const languages = {
title: 'Language',
type: 'dropdown',
exact: true,
items: [
{ title: 'English', path: '/en/', matchPath: /\/en\/.*/i }
]
title: 'Language',
type: 'dropdown',
exact: true,
items: [{ title: 'English', path: '/en/', matchPath: /\/en\/.*/i }]
}

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

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

function lang_version(lang) {
const version = {
title: 'Version',
type: 'dropdown',
exact: true,
}
version.items = versions.map(function (v) {
const ver = Object.assign({}, v)
ver.path = '/' + lang + ver.path

return ver
})
const version = {
title: 'Version',
type: 'dropdown',
exact: true
}
version.items = versions.map(function(v) {
const ver = Object.assign({}, v)
ver.path = '/' + lang + ver.path

return version
return ver
})

return version
}

docute.init({
repo: 'vuejs/rollup-plugin-vue',
'edit-link': 'https://github.com/vuejs/rollup-plugin-vue/edit/master/docs',

nav: {
default: [home, languages, lang_version('en')],
'en2.3': [{ title: 'Home', path: '/en/2.3/' }, { title: 'Examples', path: '/en/2.3/examples' }, languages, lang_version('en')],
'en2.2': [{ title: 'Home', path: '/en/2.2/' }, { title: 'Examples', path: '/en/2.2/examples' }, languages, lang_version('en')],
},

plugins: [
docsearch({
apiKey: '7792597613e997afeb0b75a206ca0c5a',
indexName: 'rollup-plugin-vue',
url: 'https://vuejs.github.io/rollup-plugin-vue'
})
repo: 'vuejs/rollup-plugin-vue',
'edit-link': 'https://github.com/vuejs/rollup-plugin-vue/edit/master/docs',

nav: {
default: [home, languages, lang_version('en')],
'en2.3': [
{ title: 'Home', path: '/en/2.3/' },
{ title: 'Examples', path: '/en/2.3/examples' },
languages,
lang_version('en')
],
'en2.2': [
{ title: 'Home', path: '/en/2.2/' },
{ title: 'Examples', path: '/en/2.2/examples' },
languages,
lang_version('en')
]

},

plugins: [
docsearch({
apiKey: '7792597613e997afeb0b75a206ca0c5a',
indexName: 'rollup-plugin-vue',
url: 'https://vuejs.github.io/rollup-plugin-vue'
})
]
})
@@ -1,23 +1,16 @@
<template>
<div class="hello">
<h1 class="hello__title">{{ msg }}</h1>
</div>
<template functional>
<div class="hello">{{ props.message }}</div>
</template>

<script>
export default {
data () {
return {
msg: 'Hello World!'
}
}
props: ['message']
}
</script>

<style lang="stylus">

<style scoped>
.hello {
&__title {
color: #42b983;
}
color: red;
}
</style>
@@ -6,35 +6,21 @@ const CleanCSS = require('clean-css')
const fs = require('fs')
const stylus = require('stylus')


rollup({
entry: 'index.js',
plugins: [
vue({
compileTemplate: true,
css (styles, stylesNodes) {
write('dist/papervue.styl', styles)
stylus.render(styles, function (err, css) {
if (err) throw err
write('dist/papervue.css', css)
write('dist/papervue.min.css', new CleanCSS().minify(css).styles)
})
}
}),
buble()
]
plugins: [vue(), buble()]
})
.then(function (bundle) {
.then(function(bundle) {
var code = bundle.generate({
format: 'umd',
moduleName: 'helloRollupVue',
useStrict: false
}).code
return write('dist/papervue.js', code).then(function () {
return write('dist/papervue.js', code).then(function() {
return code
})
})
.then(function (code) {
.then(function(code) {
var minified = uglify.minify(code, {
fromString: true,
output: {
@@ -45,24 +31,24 @@ rollup({
})
.catch(logError)

function write (dest, code) {
return new Promise(function (resolve, reject) {
fs.writeFile(dest, code, function (err) {
function write(dest, code) {
return new Promise(function(resolve, reject) {
fs.writeFile(dest, code, function(err) {
if (err) return reject(err)
console.log(blue(dest) + ' ' + getSize(code))
resolve()
})
})
}

function getSize (code) {
function getSize(code) {
return (code.length / 1024).toFixed(2) + 'kb'
}

function logError (e) {
function logError(e) {
console.log(e)
}

function blue (str) {
function blue(str) {
return '\x1b[1m\x1b[34m' + str + '\x1b[39m\x1b[22m'
}
@@ -0,0 +1,16 @@
{
"private": true,
"devDependencies": {
"rollup-plugin-closure-compiler-js": "^1.0.5",
"rollup-plugin-commonjs": "^8.2.1",
"rollup-plugin-node-resolve": "^3.0.0",
"rollup-plugin-prepack": "^1.0.0",
"vue-style-loader": "^3.0.3"
},
"dependencies": {
"@vue/component-compiler-utils": "^1.2.1",
"resolve": "^1.4.0",
"rollup-plugin-buble": "^0.19.2",
"vue-runtime-helpers": "^0.1.0"
}
}
@@ -1,20 +1,17 @@
// Simple rollup config file.

const vue = require('../dist/rollup-plugin-vue.common.js');
const buble = require('rollup-plugin-buble');
const vue = require('../dist/rollup-plugin-vue.common.js')
const buble = require('rollup-plugin-buble')
// const prepack = require('rollup-plugin-prepack')
// const closure = require('rollup-plugin-closure-compiler-js')
const node = require('rollup-plugin-node-resolve')
// const commonjs = require('rollup-plugin-commonjs')

process.env.NODE_ENV = 'production'

export default {
name: 'helloRollupVue',
input: './index.js',
output: {
file: 'dist/bundle.js',
format: 'umd'
},
plugins: [
vue({
compileTemplate: true,
css: 'dist/bundle.css'
}),
buble()
]
};
name: 'ff',
input: 'index.js',
format: 'es',
plugins: [vue(), buble()]
}
Oops, something went wrong.

0 comments on commit e110aa0

Please sign in to comment.