From 59c7329be76a4a859c2c69530353fff197b8031d Mon Sep 17 00:00:00 2001 From: Rahul Kadyan Date: Sun, 29 Jan 2017 02:41:58 +0530 Subject: [PATCH 01/10] :memo: TODO: Add usage guidelines --- README.md | 2 +- docs/introduction.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e7aa291..78dae1e 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -
+
diff --git a/docs/introduction.md b/docs/introduction.md index e7aa291..78dae1e 100644 --- a/docs/introduction.md +++ b/docs/introduction.md @@ -1,4 +1,4 @@ -
+
From e13c492ab1c5ddda5c8d16b586cf632ef4251c56 Mon Sep 17 00:00:00 2001 From: Rahul Kadyan Date: Thu, 2 Feb 2017 12:03:46 +0530 Subject: [PATCH 02/10] Fix image position --- README.md | 2 +- docs/introduction.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 78dae1e..14b7164 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -
+
diff --git a/docs/introduction.md b/docs/introduction.md index 78dae1e..14b7164 100644 --- a/docs/introduction.md +++ b/docs/introduction.md @@ -1,4 +1,4 @@ -
+
From 7a9c7710fd0ec459b4e0a753730b5d7d3397ec47 Mon Sep 17 00:00:00 2001 From: Rahul Kadyan Date: Fri, 3 Feb 2017 09:17:44 +0530 Subject: [PATCH 03/10] :hankey: Add less support --- package.json | 3 ++- src/style/index.js | 7 +++++-- src/style/less.js | 18 ++++++++++++++++++ src/vueTransform.js | 2 +- test/expects/css-modules-static.css | 2 +- test/expects/css-modules.css | 2 +- test/expects/less.css | 3 +++ test/expects/less.js | 3 +++ test/fixtures/less.vue | 16 ++++++++++++++++ test/test.js | 2 +- yarn.lock | 2 +- 11 files changed, 52 insertions(+), 8 deletions(-) create mode 100644 src/style/less.js create mode 100644 test/expects/less.css create mode 100644 test/expects/less.js create mode 100644 test/fixtures/less.vue diff --git a/package.json b/package.json index b928f97..0c2d1da 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,8 @@ "rollup-pluginutils": "^2.0.1", "vue-template-compiler": "^2.1.10", "vue-template-es2015-compiler": "^1.5.0", - "vue-template-validator": "^1.1.5" + "vue-template-validator": "^1.1.5", + "less": "latest" }, "devDependencies": { "babel-eslint": "^7.1.1", diff --git a/src/style/index.js b/src/style/index.js index 6193d66..cd61f11 100644 --- a/src/style/index.js +++ b/src/style/index.js @@ -1,10 +1,12 @@ import { writeFile } from 'fs' import compileCSS from './css' import compileSCSS from './scss' +import compileLESS from './less' const compilers = { scss: compileSCSS, - sass: compileSCSS + sass: compileSCSS, + less: compileLESS } export async function compile (style, options) { @@ -30,7 +32,8 @@ export default function (files, options) { Object.keys(files).forEach((file) => { files[file].forEach((style) => { - css += style.code + '\n' + css += ('$compiled' in style) ? `${style.$compiled.code}\n` : `${style.code}\n` + allStyles.push(style) }) }) diff --git a/src/style/less.js b/src/style/less.js new file mode 100644 index 0000000..bf197c8 --- /dev/null +++ b/src/style/less.js @@ -0,0 +1,18 @@ +import less from 'less' + +export default async function (style, options) { + const { css, map } = await less.render(style.code, { + sourceMap: { + sourceMapFullFilename: style.id, + sourceMapFileInline: false + }, + ...options.less + }) + + style.$compiled = { + code: css.toString(), + map: map.toString() + } + + return style +} diff --git a/src/vueTransform.js b/src/vueTransform.js index 973d241..298bda2 100644 --- a/src/vueTransform.js +++ b/src/vueTransform.js @@ -109,7 +109,7 @@ function injectTemplate (script, template, lang, options, modules) { throw new Error('[rollup-plugin-vue] could not find place to inject template in script.') } -var validateTemplate = function (code, content, id) { +function validateTemplate (code, content, id) { const warnings = templateValidator(code, content) if (warnings) { const relativePath = relative(process.cwd(), id) diff --git a/test/expects/css-modules-static.css b/test/expects/css-modules-static.css index bee9afa..1abd677 100644 --- a/test/expects/css-modules-static.css +++ b/test/expects/css-modules-static.css @@ -1,3 +1,3 @@ -.test { +.css-modules-static__test { color: red; } \ No newline at end of file diff --git a/test/expects/css-modules.css b/test/expects/css-modules.css index bee9afa..9e35874 100644 --- a/test/expects/css-modules.css +++ b/test/expects/css-modules.css @@ -1,3 +1,3 @@ -.test { +.css-modules__test { color: red; } \ No newline at end of file diff --git a/test/expects/less.css b/test/expects/less.css new file mode 100644 index 0000000..92cfb71 --- /dev/null +++ b/test/expects/less.css @@ -0,0 +1,3 @@ +.less__test { + color: red; +} \ No newline at end of file diff --git a/test/expects/less.js b/test/expects/less.js new file mode 100644 index 0000000..ec5c631 --- /dev/null +++ b/test/expects/less.js @@ -0,0 +1,3 @@ +var less = { template: "
",cssModules: {"test":"less__test"},}; + +export default less; \ No newline at end of file diff --git a/test/fixtures/less.vue b/test/fixtures/less.vue new file mode 100644 index 0000000..fd3447d --- /dev/null +++ b/test/fixtures/less.vue @@ -0,0 +1,16 @@ + + + + + + diff --git a/test/test.js b/test/test.js index 992ad9e..a0f0e15 100644 --- a/test/test.js +++ b/test/test.js @@ -41,7 +41,7 @@ function test(name) { assert.equal(code.trim(), expected.trim(), 'should compile code correctly') // Check css output - if (['style', 'css-modules', 'css-modules-static', 'scss', 'pug'].indexOf(name) > -1) { + if (['style', 'css-modules', 'css-modules-static', 'scss', 'pug', 'less'].indexOf(name) > -1) { var css = read('expects/' + name + '.css') assert.equal(css.trim(), actualCss.trim(), 'should output style tag content') } else { diff --git a/yarn.lock b/yarn.lock index 81c3428..1b76861 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2689,7 +2689,7 @@ lcov-parse@0.0.10: version "0.0.10" resolved "https://registry.yarnpkg.com/lcov-parse/-/lcov-parse-0.0.10.tgz#1b0b8ff9ac9c7889250582b70b71315d9da6d9a3" -"less@2.6.x || ^2.7.1": +"less@2.6.x || ^2.7.1", less@latest: version "2.7.2" resolved "https://registry.yarnpkg.com/less/-/less-2.7.2.tgz#368d6cc73e1fb03981183280918743c5dcf9b3df" optionalDependencies: From 8f5a08bb78909bb98eaedf3df4ae877ec7a833d3 Mon Sep 17 00:00:00 2001 From: Rahul Kadyan Date: Sat, 4 Feb 2017 01:06:45 +0530 Subject: [PATCH 04/10] Refactoring --- package.json | 1 + src/index.js | 46 ++++++++++++++++----------------------------- src/options.js | 5 +++-- src/style/css.js | 43 +++++++++++++++++++++++++++++++++++------- src/style/scss.js | 2 ++ src/vueTransform.js | 18 ++++++++++-------- yarn.lock | 8 +++++++- 7 files changed, 75 insertions(+), 48 deletions(-) diff --git a/package.json b/package.json index 0c2d1da..6dc36c5 100644 --- a/package.json +++ b/package.json @@ -70,6 +70,7 @@ "gulp": "^3.9.1", "istanbul": "^0.4.5", "laravel-elixir": "^6.0.0-15", + "merge-options": "0.0.64", "mocha": "^3.2.0", "mocha-lcov-reporter": "^1.2.0", "rollup": "^0.41.4", diff --git a/src/index.js b/src/index.js index a8df0ca..8ca8e79 100644 --- a/src/index.js +++ b/src/index.js @@ -4,49 +4,33 @@ import vueTransform from './vueTransform' import DEFAULT_OPTIONS from './options' import compileStyle from './style/index' import debug from './debug' +import mergeOptions from 'merge-options' -function mergeOptions (options, defaults) { - Object.keys(defaults).forEach((key) => { - const val = defaults[key] - - if (key in options) { - if (typeof options[key] === 'object') { - mergeOptions(options[key], val) - } - } else { - options[key] = val - } - }) - - return options -} - -export default function vue (options = {}) { +export default function vue (opts = {}) { debug('Yo! rolling vue!') - const filter = createFilter(options.include, options.exclude) + const filter = createFilter(opts.include, opts.exclude) - delete options.include - delete options.exclude + delete opts.include + delete opts.exclude /* eslint-disable */ try { const vueVersion = require('vue').version; if (parseInt(vueVersion.split('.')[0], 10) >= 2) { - if (!('compileTemplate' in options)) { + if (!('compileTemplate' in config)) { debug('Vue 2.0 detected. Compiling template.'); - options.compileTemplate = true; + opts.compileTemplate = true; } } else { - if (options.compileTemplate === true) { + if (opts.compileTemplate === true) { console.warn('Vue version < 2.0.0 does not support compiled template.'); } - options.compileTemplate = false; + opts.compileTemplate = false; } } catch (e) {} /* eslint-enable */ - options = mergeOptions(options, DEFAULT_OPTIONS) - + const config = mergeOptions(DEFAULT_OPTIONS, opts) const styles = {} return { @@ -74,7 +58,9 @@ export default function vue (options = {}) { return null } - const { code, css, map } = await vueTransform(source, id, options) + debug(`Compile: ${id}`) + + const { code, css, map } = await vueTransform(source, id, config) styles[id] = css @@ -82,9 +68,9 @@ export default function vue (options = {}) { }, ongenerate () { - if (options.styleToImports !== true) { - if (options.css === undefined || options.css === null) options.css = DEFAULT_OPTIONS.css - compileStyle(styles, options) + if (config.styleToImports !== true) { + if (config.css === undefined || config.css === null) config.css = DEFAULT_OPTIONS.css + compileStyle(styles, config) } } } diff --git a/src/options.js b/src/options.js index 846fe2e..2aef589 100644 --- a/src/options.js +++ b/src/options.js @@ -37,8 +37,9 @@ export default { styleToImports: false, autoStyles: true, disableCssModuleStaticReplacement: false, - modules: { - generateScopedName: '[name]__[local]___[hash:base64:5]' + cssModules: { + generateScopedName: '[name]__[local]___[hash:base64:5]', + camelCase: true }, scss: {}, pug: {} diff --git a/src/style/css.js b/src/style/css.js index 2e150a8..55b038c 100644 --- a/src/style/css.js +++ b/src/style/css.js @@ -1,38 +1,67 @@ import postcss from 'postcss' import modules from 'postcss-modules' +import camelcase from 'camelcase' +// import MagicString from 'magic-string' +import debug from '../debug' function compileModule (code, map, source, options) { let style + debug(`CSS Modules: ${source.id}`) return postcss([ modules({ getJSON (filename, json) { style = json }, - ...options.modules + ...options.cssModules }) ]).process(code, { map: { inline: false, prev: map }, from: source.id, to: source.id }) - .then( - result => ({ code: result.css, map: result.map, module: style }), - error => { - throw error - }) + .then( + result => ({ code: result.css, map: result.map, module: style }), + error => { + throw error + } + ) } export default async function (promise, options) { const style = await promise + debug(`CSS: ${style.id}`) const { code, map } = ('$compiled' in style) ? style.$compiled : style if (style.module === true) { return compileModule(code, map, style, options).then(compiled => { if (style.$compiled) { compiled.$prev = style.$compiled + + const classes = Object.keys(compiled.module) + const cssModule = {} + + if (classes.length) { + // Apply CSS modules to actual source. + // TODO: Update source map. + // const original = style.code + + style.code = classes.reduce( + (result, name) => { + cssModule[camelcase(name)] = compiled.module[name] + + return result.replace(`.${name}`, `.${compiled.module[name]}`) + }, + style.code + ) + // style.map = (new MagicString(original)) + + compiled.module = ( + typeof (style.module) === 'string' && style.attrs.module.length + ) ? { [style.module]: cssModule } : cssModule + } } style.$compiled = compiled return style - }) + }).catch(error => debug(error)) } const output = { code, map, lang: 'css' } diff --git a/src/style/scss.js b/src/style/scss.js index 8efd5ca..aaff49f 100644 --- a/src/style/scss.js +++ b/src/style/scss.js @@ -1,6 +1,8 @@ import sass from 'node-sass' +import debug from '../debug' export default function (style, options) { + debug(`SASS: ${style.id}`) const { css, map } = sass.renderSync({ file: style.id, data: style.code, diff --git a/src/vueTransform.js b/src/vueTransform.js index 298bda2..7b48c38 100644 --- a/src/vueTransform.js +++ b/src/vueTransform.js @@ -124,6 +124,8 @@ function validateTemplate (code, content, id) { async function processTemplate (source, id, content, options, nodes, modules) { if (source === undefined) return undefined + debug(`Process template: ${id}`) + const extras = { modules, id, lang: source.attrs.lang } const { code } = source const template = deIndent( @@ -142,6 +144,8 @@ async function processTemplate (source, id, content, options, nodes, modules) { async function processScript (source, id, content, options, nodes, modules) { const template = await processTemplate(nodes.template[0], id, content, options, nodes, modules) + debug(`Process script: ${id}`) + const lang = source.attrs.lang || 'js' const script = deIndent(padContent(content.slice(0, content.indexOf(source.code))) + source.code) @@ -159,9 +163,10 @@ async function processScript (source, id, content, options, nodes, modules) { } } +// eslint-disable-next-line complexity async function processStyle (styles, id, content, options) { + debug(`Process styles: ${id}`) const outputs = [] - for (let i = 0; i < styles.length; i += 1) { const style = styles[i] @@ -176,21 +181,18 @@ async function processStyle (styles, id, content, options) { code: code, map: map, lang: style.attrs.lang || 'css', - module: 'module' in style.attrs, - scoped: 'scoped' in style.attrs + module: 'module' in style.attrs ? style.attrs.module || true : false, + scoped: 'scoped' in style.attrs ? style.attrs.scoped || true : false } - if (options.autoStyles) { - outputs.push(await compile(output, options)) - } else { - outputs.push(output) - } + outputs.push(options.autoStyles ? await compile(output, options) : output) } return outputs } function parseTemplate (code) { + debug('Parsing template....') const fragment = parse5.parseFragment(code, { locationInfo: true }) const nodes = { diff --git a/yarn.lock b/yarn.lock index 1b76861..1914948 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2449,7 +2449,7 @@ is-path-inside@^1.0.0: dependencies: path-is-inside "^1.0.1" -is-plain-obj@^1.0.0: +is-plain-obj@^1.0.0, is-plain-obj@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/is-plain-obj/-/is-plain-obj-1.1.0.tgz#71a50c8429dfca773c92a390a4a03b39fcd51d3e" @@ -3049,6 +3049,12 @@ meow@^3.7.0: redent "^1.0.0" trim-newlines "^1.0.0" +merge-options@0.0.64: + version "0.0.64" + resolved "https://registry.yarnpkg.com/merge-options/-/merge-options-0.0.64.tgz#cbe04f594a6985eaf27f7f8f0b2a3acf6f9d562d" + dependencies: + is-plain-obj "^1.1.0" + merge-stream@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/merge-stream/-/merge-stream-1.0.1.tgz#4041202d508a342ba00174008df0c251b8c135e1" From f1ad7a9d1bdf0e495b1421135ec5ac873e7143ef Mon Sep 17 00:00:00 2001 From: Rahul Kadyan Date: Sat, 4 Feb 2017 01:13:31 +0530 Subject: [PATCH 05/10] Choose minimal defaults --- src/options.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/options.js b/src/options.js index 2aef589..b8db4e8 100644 --- a/src/options.js +++ b/src/options.js @@ -38,8 +38,7 @@ export default { autoStyles: true, disableCssModuleStaticReplacement: false, cssModules: { - generateScopedName: '[name]__[local]___[hash:base64:5]', - camelCase: true + generateScopedName: '[name]__[local]' }, scss: {}, pug: {} From 7eccafa6bb0364548814db4989701174935c2cc5 Mon Sep 17 00:00:00 2001 From: Rahul Kadyan Date: Tue, 7 Feb 2017 05:46:11 +0530 Subject: [PATCH 06/10] Add missing dependency Fixes #59 --- package.json | 6 +- yarn.lock | 245 ++++++++++++++++++++++----------------------------- 2 files changed, 107 insertions(+), 144 deletions(-) diff --git a/package.json b/package.json index 6dc36c5..13b5c74 100644 --- a/package.json +++ b/package.json @@ -37,9 +37,11 @@ }, "homepage": "https://github.com/znck/rollup-plugin-vue#readme", "dependencies": { + "babel-runtime": "^6.22.0", "de-indent": "^1.0.2", "debug": "^2.6.0", "html-minifier": "^3.2.3", + "less": "^2.7.2", "magic-string": "^0.19.0", "node-sass": "^4.5.0", "parse5": "^3.0.1", @@ -51,8 +53,7 @@ "rollup-pluginutils": "^2.0.1", "vue-template-compiler": "^2.1.10", "vue-template-es2015-compiler": "^1.5.0", - "vue-template-validator": "^1.1.5", - "less": "latest" + "vue-template-validator": "^1.1.5" }, "devDependencies": { "babel-eslint": "^7.1.1", @@ -75,7 +76,6 @@ "mocha-lcov-reporter": "^1.2.0", "rollup": "^0.41.4", "rollup-plugin-babel": "^2.7.1", - "rollup-plugin-buble": "^0.15.0", "rollup-plugin-css-only": "^0.2.0", "rollup-plugin-replace": "^1.1.1", "uglify-js": "^2.7.5", diff --git a/yarn.lock b/yarn.lock index 1914948..b69fab5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3,8 +3,8 @@ "@types/node@^6.0.46": - version "6.0.61" - resolved "https://registry.yarnpkg.com/@types/node/-/node-6.0.61.tgz#eea1748ad99decaf319b571017018631974ac6f0" + version "6.0.62" + resolved "https://registry.yarnpkg.com/@types/node/-/node-6.0.62.tgz#85222c077b54f25b57417bb708b9f877bda37f89" abbrev@1, abbrev@1.0.x: version "1.0.9" @@ -35,23 +35,17 @@ acorn-globals@^3.0.0: dependencies: acorn "^4.0.4" -acorn-jsx@^3.0.0, acorn-jsx@^3.0.1: +acorn-jsx@^3.0.0: version "3.0.1" resolved "https://registry.yarnpkg.com/acorn-jsx/-/acorn-jsx-3.0.1.tgz#afdf9488fb1ecefc8348f6fb22f464e32a58b36b" dependencies: acorn "^3.0.4" -acorn-object-spread@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/acorn-object-spread/-/acorn-object-spread-1.0.0.tgz#48ead0f4a8eb16995a17a0db9ffc6acaada4ba68" - dependencies: - acorn "^3.1.0" - -acorn@4.X, acorn@^4.0.1, acorn@^4.0.4, acorn@~4.0.2: +acorn@4.0.4, acorn@4.X, acorn@^4.0.4, acorn@~4.0.2: version "4.0.4" resolved "https://registry.yarnpkg.com/acorn/-/acorn-4.0.4.tgz#17a8d6a7a6c4ef538b814ec9abac2779293bf30a" -acorn@^3.0.4, acorn@^3.1.0, acorn@^3.3.0, acorn@~3.3.0: +acorn@^3.0.4, acorn@^3.1.0, acorn@~3.3.0: version "3.3.0" resolved "https://registry.yarnpkg.com/acorn/-/acorn-3.3.0.tgz#45e37fb39e8da3f25baee3ff5369e2bb5f22017a" @@ -197,11 +191,11 @@ atob@~1.1.0: resolved "https://registry.yarnpkg.com/atob/-/atob-1.1.3.tgz#95f13629b12c3a51a5d215abdce2aa9f32f80773" autoprefixer@^6.0.0: - version "6.7.0" - resolved "https://registry.yarnpkg.com/autoprefixer/-/autoprefixer-6.7.0.tgz#88992cf04df141e7b8293550f2ee716c565d1cae" + version "6.7.2" + resolved "https://registry.yarnpkg.com/autoprefixer/-/autoprefixer-6.7.2.tgz#172ab07b998ae9b957530928a59a40be54a45023" dependencies: - browserslist "~1.6.0" - caniuse-db "^1.0.30000613" + browserslist "^1.7.1" + caniuse-db "^1.0.30000618" normalize-range "^0.1.2" num2fraction "^1.2.2" postcss "^5.2.11" @@ -777,8 +771,8 @@ balanced-match@^0.4.1: resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-0.4.2.tgz#cb3f3e3c732dc0f01ee70b403f302e61d7709838" bcrypt-pbkdf@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.0.tgz#3ca76b85241c7170bf7d9703e7b9aa74630040d4" + version "1.0.1" + resolved "https://registry.yarnpkg.com/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.1.tgz#63bc5dcb61331b92bc05fd528953c33462a06f8d" dependencies: tweetnacl "^0.14.3" @@ -790,11 +784,11 @@ big.js@^3.1.3: version "3.1.3" resolved "https://registry.yarnpkg.com/big.js/-/big.js-3.1.3.tgz#4cada2193652eb3ca9ec8e55c9015669c9806978" -bl@^1.0.0, bl@~1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/bl/-/bl-1.1.2.tgz#fdca871a99713aa00d19e3bbba41c44787a65398" +bl@^1.0.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/bl/-/bl-1.2.0.tgz#1397e7ec42c5f5dc387470c500e34a9f6be9ea98" dependencies: - readable-stream "~2.0.5" + readable-stream "^2.0.5" block-stream@*: version "0.0.9" @@ -827,24 +821,12 @@ browser-stdout@1.3.0: version "1.3.0" resolved "https://registry.yarnpkg.com/browser-stdout/-/browser-stdout-1.3.0.tgz#f351d32969d32fa5d7a5567154263d928ae3bd1f" -browserslist@~1.6.0: - version "1.6.0" - resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-1.6.0.tgz#85fb7c993540d3fda31c282baf7f5aee698ac9ee" - dependencies: - caniuse-db "^1.0.30000613" - electron-to-chromium "^1.2.0" - -buble@^0.15.0: - version "0.15.2" - resolved "https://registry.yarnpkg.com/buble/-/buble-0.15.2.tgz#547fc47483f8e5e8176d82aa5ebccb183b02d613" +browserslist@^1.7.1: + version "1.7.1" + resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-1.7.1.tgz#cc9bd193979a2a4b09fdb3df6003fefe48ccefe1" dependencies: - acorn "^3.3.0" - acorn-jsx "^3.0.1" - acorn-object-spread "^1.0.0" - chalk "^1.1.3" - magic-string "^0.14.0" - minimist "^1.2.0" - os-homedir "^1.0.1" + caniuse-db "^1.0.30000617" + electron-to-chromium "^1.2.1" buffer-shims@^1.0.0: version "1.0.0" @@ -890,9 +872,9 @@ camelcase@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-3.0.0.tgz#32fc4b9fcdaf845fcdf7e73bb97cac2261f0ab0a" -caniuse-db@^1.0.30000613: - version "1.0.30000613" - resolved "https://registry.yarnpkg.com/caniuse-db/-/caniuse-db-1.0.30000613.tgz#639133b7a5380c1416f9701d23d54d093dd68299" +caniuse-db@^1.0.30000617, caniuse-db@^1.0.30000618: + version "1.0.30000621" + resolved "https://registry.yarnpkg.com/caniuse-db/-/caniuse-db-1.0.30000621.tgz#be8726af1a39315618a0f364998cf9c9a0431177" cardinal@^1.0.0: version "1.0.0" @@ -932,7 +914,13 @@ circular-json@^0.3.1: version "0.3.1" resolved "https://registry.yarnpkg.com/circular-json/-/circular-json-0.3.1.tgz#be8b36aefccde8b3ca7aa2d6afc07a37242c0d2d" -clean-css@3.4.x, clean-css@^3.3.0, clean-css@^3.4.12, clean-css@^3.4.24: +clean-css@4.0.x: + version "4.0.4" + resolved "https://registry.yarnpkg.com/clean-css/-/clean-css-4.0.4.tgz#629896cc364f3c3d00b9908ee60dd18e4c6c6462" + dependencies: + source-map "0.5.x" + +clean-css@^3.3.0, clean-css@^3.4.12, clean-css@^3.4.24: version "3.4.24" resolved "https://registry.yarnpkg.com/clean-css/-/clean-css-3.4.24.tgz#89f5a5e9da37ae02394fe049a41388abbe72c3b5" dependencies: @@ -1082,14 +1070,14 @@ core-util-is@~1.0.0: resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7" coveralls@^2.11.15: - version "2.11.15" - resolved "https://registry.yarnpkg.com/coveralls/-/coveralls-2.11.15.tgz#37d3474369d66c14f33fa73a9d25cee6e099fca0" + version "2.11.16" + resolved "https://registry.yarnpkg.com/coveralls/-/coveralls-2.11.16.tgz#da9061265142ddee954f68379122be97be8ab4b1" dependencies: js-yaml "3.6.1" lcov-parse "0.0.10" log-driver "1.2.5" minimist "1.2.0" - request "2.75.0" + request "2.79.0" cross-spawn@^3.0.0: version "3.0.1" @@ -1304,9 +1292,9 @@ ecc-jsbn@~0.1.1: dependencies: jsbn "~0.1.0" -electron-to-chromium@^1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.2.0.tgz#3bd7761f85bd4163602259ae6c7ed338050b17e7" +electron-to-chromium@^1.2.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.2.1.tgz#63ac7579a1c5bedb296c8607621f2efc9a54b968" emojis-list@^2.0.0: version "2.1.0" @@ -1463,16 +1451,16 @@ eslint-plugin-import@^2.2.0: pkg-up "^1.0.0" eslint-plugin-promise@^3.4.0: - version "3.4.0" - resolved "https://registry.yarnpkg.com/eslint-plugin-promise/-/eslint-plugin-promise-3.4.0.tgz#6ba9048c2df57be77d036e0c68918bc9b4fc4195" + version "3.4.1" + resolved "https://registry.yarnpkg.com/eslint-plugin-promise/-/eslint-plugin-promise-3.4.1.tgz#6911a9010bf84e17d82e19e0ab0f80ab3ad6db4c" eslint-plugin-standard@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/eslint-plugin-standard/-/eslint-plugin-standard-2.0.1.tgz#3589699ff9c917f2c25f76a916687f641c369ff3" eslint@^3.14.0: - version "3.14.0" - resolved "https://registry.yarnpkg.com/eslint/-/eslint-3.14.0.tgz#2c617e5f782fda5cbee5bc8be7ef5053af8e63a3" + version "3.15.0" + resolved "https://registry.yarnpkg.com/eslint/-/eslint-3.15.0.tgz#bdcc6a6c5ffe08160e7b93c066695362a91e30f2" dependencies: babel-code-frame "^6.16.0" chalk "^1.1.3" @@ -1480,7 +1468,7 @@ eslint@^3.14.0: debug "^2.1.1" doctrine "^1.2.2" escope "^3.6.0" - espree "^3.3.1" + espree "^3.4.0" estraverse "^4.2.0" esutils "^2.0.2" file-entry-cache "^2.0.0" @@ -1509,11 +1497,11 @@ eslint@^3.14.0: text-table "~0.2.0" user-home "^2.0.0" -espree@^3.3.1: - version "3.3.2" - resolved "https://registry.yarnpkg.com/espree/-/espree-3.3.2.tgz#dbf3fadeb4ecb4d4778303e50103b3d36c88b89c" +espree@^3.4.0: + version "3.4.0" + resolved "https://registry.yarnpkg.com/espree/-/espree-3.4.0.tgz#41656fa5628e042878025ef467e78f125cb86e1d" dependencies: - acorn "^4.0.1" + acorn "4.0.4" acorn-jsx "^3.0.0" esprima@2.7.x, esprima@^2.6.0, esprima@^2.7.1: @@ -1708,13 +1696,13 @@ fork-stream@^0.0.4: version "0.0.4" resolved "https://registry.yarnpkg.com/fork-stream/-/fork-stream-0.0.4.tgz#db849fce77f6708a5f8f386ae533a0907b54ae70" -form-data@~2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/form-data/-/form-data-2.0.0.tgz#6f0aebadcc5da16c13e1ecc11137d85f9b883b25" +form-data@~2.1.1: + version "2.1.2" + resolved "https://registry.yarnpkg.com/form-data/-/form-data-2.1.2.tgz#89c3534008b97eada4cbb157d58f6f5df025eae4" dependencies: asynckit "^0.4.0" combined-stream "^1.0.5" - mime-types "^2.1.11" + mime-types "^2.1.12" fs-exists-sync@^0.1.0: version "0.1.0" @@ -2002,8 +1990,8 @@ gulp-less@^3.0.5: vinyl-sourcemaps-apply "^0.2.0" gulp-load-plugins@^1.2.2: - version "1.4.0" - resolved "https://registry.yarnpkg.com/gulp-load-plugins/-/gulp-load-plugins-1.4.0.tgz#82fab03715ecf1838a958ec643a4d74274ddfece" + version "1.5.0" + resolved "https://registry.yarnpkg.com/gulp-load-plugins/-/gulp-load-plugins-1.5.0.tgz#4c419f7e5764d9a0e33061bab9618f81b73d4171" dependencies: array-unique "^0.2.1" fancy-log "^1.2.0" @@ -2073,8 +2061,8 @@ gulp-shell@^0.5.2: through2 "^2.0.0" gulp-sourcemaps@^1.6.0: - version "1.11.0" - resolved "https://registry.yarnpkg.com/gulp-sourcemaps/-/gulp-sourcemaps-1.11.0.tgz#1b249bfe994361c370c168fe2508effc1f1523c9" + version "1.11.1" + resolved "https://registry.yarnpkg.com/gulp-sourcemaps/-/gulp-sourcemaps-1.11.1.tgz#b534376deab49387d406c3aebeb8beaf02ef3548" dependencies: acorn "4.X" convert-source-map "1.X" @@ -2202,8 +2190,8 @@ hawk@~3.1.3: sntp "1.x.x" he@1.1.x, he@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/he/-/he-1.1.0.tgz#29319d49beec13a9b1f3c4f9b2a6dde4859bb2a7" + version "1.1.1" + resolved "https://registry.yarnpkg.com/he/-/he-1.1.1.tgz#93410fd21b009735151f8868c2f271f3427e23fd" hoek@2.x.x: version "2.16.3" @@ -2223,15 +2211,15 @@ homedir-polyfill@^1.0.0: parse-passwd "^1.0.0" hosted-git-info@^2.1.4: - version "2.1.5" - resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.1.5.tgz#0ba81d90da2e25ab34a332e6ec77936e1598118b" + version "2.2.0" + resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.2.0.tgz#7a0d097863d886c0fabbdcd37bf1758d8becf8a5" html-minifier@^3.2.3: - version "3.2.3" - resolved "https://registry.yarnpkg.com/html-minifier/-/html-minifier-3.2.3.tgz#d2ff536e24d95726c332493d8f77d84dbed85372" + version "3.3.0" + resolved "https://registry.yarnpkg.com/html-minifier/-/html-minifier-3.3.0.tgz#a9b5b8eda501362d4c5699db02a8dc72013d1fab" dependencies: camel-case "3.0.x" - clean-css "3.4.x" + clean-css "4.0.x" commander "2.9.x" he "1.1.x" ncname "1.0.x" @@ -2263,8 +2251,8 @@ icss-replace-symbols@1.0.2, icss-replace-symbols@^1.0.2: resolved "https://registry.yarnpkg.com/icss-replace-symbols/-/icss-replace-symbols-1.0.2.tgz#cb0b6054eb3af6edc9ab1d62d01933e2d4c8bfa5" ignore@^3.2.0: - version "3.2.0" - resolved "https://registry.yarnpkg.com/ignore/-/ignore-3.2.0.tgz#8d88f03c3002a0ac52114db25d2c673b0bf1e435" + version "3.2.2" + resolved "https://registry.yarnpkg.com/ignore/-/ignore-3.2.2.tgz#1c51e1ef53bab6ddc15db4d9ac4ec139eceb3410" image-size@~0.5.0: version "0.5.1" @@ -2567,8 +2555,8 @@ js-stringify@^1.0.1: resolved "https://registry.yarnpkg.com/js-stringify/-/js-stringify-1.0.2.tgz#1736fddfd9724f28a3682adc6230ae7e4e9679db" js-tokens@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.0.tgz#a2f2a969caae142fb3cd56228358c89366957bd1" + version "3.0.1" + resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.1.tgz#08e9f132484a2c45a30907e9dc4d5567b7f114d7" js-yaml@3.6.1, js-yaml@3.x, js-yaml@^3.5.1: version "3.6.1" @@ -2689,7 +2677,7 @@ lcov-parse@0.0.10: version "0.0.10" resolved "https://registry.yarnpkg.com/lcov-parse/-/lcov-parse-0.0.10.tgz#1b0b8ff9ac9c7889250582b70b71315d9da6d9a3" -"less@2.6.x || ^2.7.1", less@latest: +"less@2.6.x || ^2.7.1", less@^2.7.2: version "2.7.2" resolved "https://registry.yarnpkg.com/less/-/less-2.7.2.tgz#368d6cc73e1fb03981183280918743c5dcf9b3df" optionalDependencies: @@ -2994,12 +2982,6 @@ lru-cache@^4.0.1: pseudomap "^1.0.1" yallist "^2.0.0" -magic-string@^0.14.0: - version "0.14.0" - resolved "https://registry.yarnpkg.com/magic-string/-/magic-string-0.14.0.tgz#57224aef1701caeed273b17a39a956e72b172462" - dependencies: - vlq "^0.2.1" - magic-string@^0.15.2: version "0.15.2" resolved "https://registry.yarnpkg.com/magic-string/-/magic-string-0.15.2.tgz#0681d7388741bbc3addaa65060992624c6c09e9c" @@ -3083,7 +3065,7 @@ mime-db@~1.26.0: version "1.26.0" resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.26.0.tgz#eaffcd0e4fc6935cf8134da246e2e6c35305adff" -mime-types@^2.1.11, mime-types@~2.1.7: +mime-types@^2.1.12, mime-types@~2.1.7: version "2.1.14" resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.14.tgz#f7ef7d97583fcaf3b7d282b6f8b5679dab1e94ee" dependencies: @@ -3116,7 +3098,7 @@ minimist@0.0.8, minimist@~0.0.1: version "0.0.8" resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.8.tgz#857fcabfc3397d2625b8228262e86aa7a011b05d" -minimist@1.2.0, minimist@^1.1.0, minimist@^1.1.1, minimist@^1.1.3, minimist@^1.2.0: +minimist@1.2.0, minimist@^1.1.0, minimist@^1.1.1, minimist@^1.1.3: version "1.2.0" resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284" @@ -3282,10 +3264,6 @@ node-sass@^4.5.0: sass-graph "^2.1.1" stdout-stream "^1.4.0" -node-uuid@~1.4.7: - version "1.4.7" - resolved "https://registry.yarnpkg.com/node-uuid/-/node-uuid-1.4.7.tgz#6da5a17668c4b3dd59623bda11cf7fa4c1f60a6f" - node.extend@^1.1.3: version "1.1.6" resolved "https://registry.yarnpkg.com/node.extend/-/node.extend-1.1.6.tgz#a7b882c82d6c93a4863a5504bd5de8ec86258b96" @@ -3579,8 +3557,8 @@ postcss@5.1.2: supports-color "^3.1.2" postcss@^5.0.14, postcss@^5.0.4, postcss@^5.2.11, postcss@^5.2.8: - version "5.2.11" - resolved "https://registry.yarnpkg.com/postcss/-/postcss-5.2.11.tgz#ff29bcd6d2efb98bfe08a022055ec599bbe7b761" + version "5.2.12" + resolved "https://registry.yarnpkg.com/postcss/-/postcss-5.2.12.tgz#6a2b15e35dd65634441bb0961fa796904c7890e0" dependencies: chalk "^1.1.3" js-base64 "^2.1.9" @@ -3624,8 +3602,8 @@ pretty-hrtime@^1.0.0: resolved "https://registry.yarnpkg.com/pretty-hrtime/-/pretty-hrtime-1.0.3.tgz#b7e3ea42435a4c9b2759d99e0f201eb195802ee1" private@^0.1.6: - version "0.1.6" - resolved "https://registry.yarnpkg.com/private/-/private-0.1.6.tgz#55c6a976d0f9bafb9924851350fe47b9b5fbb7c1" + version "0.1.7" + resolved "https://registry.yarnpkg.com/private/-/private-0.1.7.tgz#68ce5e8a1ef0a23bb570cc28537b5332aba63ef1" process-nextick-args@^1.0.6, process-nextick-args@~1.0.6: version "1.0.7" @@ -3679,18 +3657,18 @@ pug-error@^1.3.2: resolved "https://registry.yarnpkg.com/pug-error/-/pug-error-1.3.2.tgz#53ae7d9d29bb03cf564493a026109f54c47f5f26" pug-filters@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/pug-filters/-/pug-filters-2.1.0.tgz#4e1066df6271e70557baec3da56c686238150e40" + version "2.1.1" + resolved "https://registry.yarnpkg.com/pug-filters/-/pug-filters-2.1.1.tgz#10ab2b6d7e5aeec99cad28a1e4c8085f823fc754" dependencies: clean-css "^3.3.0" constantinople "^3.0.1" jstransformer "1.0.0" pug-error "^1.3.2" - pug-walk "^1.1.0" + pug-walk "^1.1.1" resolve "^1.1.6" uglify-js "^2.6.1" -pug-lexer@^2.3.2: +pug-lexer@^2.3.1: version "2.3.2" resolved "https://registry.yarnpkg.com/pug-lexer/-/pug-lexer-2.3.2.tgz#68b19d96ea5dc0e4a86148b01cb966c17815a614" dependencies: @@ -3699,18 +3677,18 @@ pug-lexer@^2.3.2: pug-error "^1.3.2" pug-linker@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/pug-linker/-/pug-linker-2.0.1.tgz#167096eeae722c02f0a718c9c12a0c57b6e2030d" + version "2.0.2" + resolved "https://registry.yarnpkg.com/pug-linker/-/pug-linker-2.0.2.tgz#1deca67d741fab46b028c1366f178fbaee620233" dependencies: pug-error "^1.3.2" - pug-walk "^1.1.0" + pug-walk "^1.1.1" pug-load@^2.0.4: - version "2.0.4" - resolved "https://registry.yarnpkg.com/pug-load/-/pug-load-2.0.4.tgz#51beb5c9af10269ea533d0a881223c3d8ccc0fd9" + version "2.0.5" + resolved "https://registry.yarnpkg.com/pug-load/-/pug-load-2.0.5.tgz#eaaf46ccace8aff7461e0fad1e2b67305514f2c6" dependencies: object-assign "^4.1.0" - pug-walk "^1.1.0" + pug-walk "^1.1.1" pug-parser@^2.0.2: version "2.0.2" @@ -3729,17 +3707,17 @@ pug-strip-comments@^1.0.2: dependencies: pug-error "^1.3.2" -pug-walk@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/pug-walk/-/pug-walk-1.1.0.tgz#f784cf94215d70ade49f1fc05c736dc741623051" +pug-walk@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/pug-walk/-/pug-walk-1.1.1.tgz#b9976240d213692e6993fbc13ae1205c54052efe" pug@^2.0.0-beta10: - version "2.0.0-beta10" - resolved "https://registry.yarnpkg.com/pug/-/pug-2.0.0-beta10.tgz#0afdc58af0e6b36500390ed05fd1fe4ba038d6d7" + version "2.0.0-beta9" + resolved "https://registry.yarnpkg.com/pug/-/pug-2.0.0-beta9.tgz#158ec6dbace5bb78f2b25e8825477d03ea6e14b0" dependencies: pug-code-gen "^1.1.1" pug-filters "^2.1.0" - pug-lexer "^2.3.2" + pug-lexer "^2.3.1" pug-linker "^2.0.1" pug-load "^2.0.4" pug-parser "^2.0.2" @@ -3754,9 +3732,9 @@ q@^1.4.1: version "1.4.1" resolved "https://registry.yarnpkg.com/q/-/q-1.4.1.tgz#55705bcd93c5f3673530c2c2cbc0c2b3addc286e" -qs@~6.2.0: - version "6.2.1" - resolved "https://registry.yarnpkg.com/qs/-/qs-6.2.1.tgz#ce03c5ff0935bc1d9d69a9f14cbd18e568d67625" +qs@~6.3.0: + version "6.3.0" + resolved "https://registry.yarnpkg.com/qs/-/qs-6.3.0.tgz#f403b264f23bc01228c74131b407f18d5ea5d442" randomatic@^1.1.3: version "1.1.6" @@ -3789,7 +3767,7 @@ read-pkg@^1.0.0: isarray "0.0.1" string_decoder "~0.10.x" -readable-stream@^2.0.0, "readable-stream@^2.0.0 || ^1.1.13", readable-stream@^2.0.1, readable-stream@^2.0.2, readable-stream@^2.1.5, readable-stream@^2.2.2: +readable-stream@^2.0.0, "readable-stream@^2.0.0 || ^1.1.13", readable-stream@^2.0.1, readable-stream@^2.0.2, readable-stream@^2.0.5, readable-stream@^2.1.5, readable-stream@^2.2.2: version "2.2.2" resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.2.2.tgz#a9e6fec3c7dda85f8bb1b3ba7028604556fc825e" dependencies: @@ -3810,17 +3788,6 @@ readable-stream@~1.1.8, readable-stream@~1.1.9: isarray "0.0.1" string_decoder "~0.10.x" -readable-stream@~2.0.5: - version "2.0.6" - resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.0.6.tgz#8f90341e68a53ccc928788dacfcd11b36eb9b78e" - dependencies: - core-util-is "~1.0.0" - inherits "~2.0.1" - isarray "~1.0.0" - process-nextick-args "~1.0.6" - string_decoder "~0.10.x" - util-deprecate "~1.0.1" - readable-stream@~2.1.0: version "2.1.5" resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.1.5.tgz#66fa8b720e1438b364681f2ad1a63c618448c9d0" @@ -3939,18 +3906,17 @@ replace-ext@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/replace-ext/-/replace-ext-1.0.0.tgz#de63128373fcbf7c3ccfa4de5a480c45a67958eb" -request@2, request@2.75.0, request@^2.61.0, request@^2.72.0: - version "2.75.0" - resolved "https://registry.yarnpkg.com/request/-/request-2.75.0.tgz#d2b8268a286da13eaa5d01adf5d18cc90f657d93" +request@2, request@2.79.0, request@^2.61.0, request@^2.72.0: + version "2.79.0" + resolved "https://registry.yarnpkg.com/request/-/request-2.79.0.tgz#4dfe5bf6be8b8cdc37fcf93e04b65577722710de" dependencies: aws-sign2 "~0.6.0" aws4 "^1.2.1" - bl "~1.1.2" caseless "~0.11.0" combined-stream "~1.0.5" extend "~3.0.0" forever-agent "~0.6.1" - form-data "~2.0.0" + form-data "~2.1.1" har-validator "~2.0.6" hawk "~3.1.3" http-signature "~1.1.0" @@ -3958,12 +3924,12 @@ request@2, request@2.75.0, request@^2.61.0, request@^2.72.0: isstream "~0.1.2" json-stringify-safe "~5.0.1" mime-types "~2.1.7" - node-uuid "~1.4.7" oauth-sign "~0.8.1" - qs "~6.2.0" + qs "~6.3.0" stringstream "~0.0.4" tough-cookie "~2.3.0" tunnel-agent "~0.4.1" + uuid "^3.0.0" require-dir@^0.3.0: version "0.3.1" @@ -4041,13 +4007,6 @@ rollup-plugin-babel@^2.7.1: object-assign "^4.1.0" rollup-pluginutils "^1.5.0" -rollup-plugin-buble@^0.15.0: - version "0.15.0" - resolved "https://registry.yarnpkg.com/rollup-plugin-buble/-/rollup-plugin-buble-0.15.0.tgz#83c3e89c7fd2266c7918f41ba3980313519c7fd0" - dependencies: - buble "^0.15.0" - rollup-pluginutils "^1.5.0" - rollup-plugin-css-only@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/rollup-plugin-css-only/-/rollup-plugin-css-only-0.2.0.tgz#e7c583b2726ff15c88e701ead5c9ad80e1cf4324" @@ -4173,8 +4132,8 @@ source-map-resolve@^0.3.0: urix "~0.1.0" source-map-support@^0.4.0, source-map-support@^0.4.2: - version "0.4.10" - resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.4.10.tgz#d7b19038040a14c0837a18e630a196453952b378" + version "0.4.11" + resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.4.11.tgz#647f939978b38535909530885303daf23279f322" dependencies: source-map "^0.5.3" @@ -4188,7 +4147,7 @@ source-map@0.4.x, source-map@^0.4.4: dependencies: amdefine ">=0.0.4" -source-map@0.X, source-map@^0.5.0, source-map@^0.5.1, source-map@^0.5.3, source-map@^0.5.6, source-map@~0.5.1: +source-map@0.5.x, source-map@0.X, source-map@^0.5.0, source-map@^0.5.1, source-map@^0.5.3, source-map@^0.5.6, source-map@~0.5.1: version "0.5.6" resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.6.tgz#75ce38f52bf0733c5a7f0c118d81334a2bb5f412" @@ -4522,6 +4481,10 @@ util@^0.10.3: dependencies: inherits "2.0.1" +uuid@^3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.0.1.tgz#6544bba2dfda8c1cf17e629a3a305e2bb1fee6c1" + v8flags@^2.0.2: version "2.0.11" resolved "https://registry.yarnpkg.com/v8flags/-/v8flags-2.0.11.tgz#bca8f30f0d6d60612cc2c00641e6962d42ae6881" From 43ac232a3d4f06978099ef76f8a8ec92aa81db40 Mon Sep 17 00:00:00 2001 From: Rahul Kadyan Date: Mon, 27 Feb 2017 09:35:56 +0530 Subject: [PATCH 07/10] CSS source maps --- src/style/css.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/style/css.js b/src/style/css.js index 55b038c..5492048 100644 --- a/src/style/css.js +++ b/src/style/css.js @@ -17,13 +17,17 @@ function compileModule (code, map, source, options) { }) ]).process(code, { map: { inline: false, prev: map }, from: source.id, to: source.id }) .then( - result => ({ code: result.css, map: result.map, module: style }), + result => ({ code: result.css, map: result.map.toString(), module: style }), error => { throw error } ) } +function escapeRegExp (str) { + return str.replace(/[-[\]/{}()*+?.\\^$|]/g, '\\$&') +} + export default async function (promise, options) { const style = await promise debug(`CSS: ${style.id}`) @@ -43,10 +47,12 @@ export default async function (promise, options) { // const original = style.code style.code = classes.reduce( - (result, name) => { - cssModule[camelcase(name)] = compiled.module[name] + (result, original) => { + const transformed = compiled.module[original] + cssModule[camelcase(original)] = transformed + cssModule[original] = transformed - return result.replace(`.${name}`, `.${compiled.module[name]}`) + return result.replace(new RegExp(escapeRegExp(`.${original}`), 'g'), `.${transformed}`) }, style.code ) From 91a80b39b2a2516ea60696ba555917da6d7db024 Mon Sep 17 00:00:00 2001 From: Rahul Kadyan Date: Mon, 27 Feb 2017 09:37:08 +0530 Subject: [PATCH 08/10] Add script in logs --- src/vueTransform.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/vueTransform.js b/src/vueTransform.js index 7b48c38..f60bfb7 100644 --- a/src/vueTransform.js +++ b/src/vueTransform.js @@ -43,11 +43,12 @@ function wrapRenderFunction (code) { function injectModule (script, lang, options, modules) { if (Object.keys(modules).length === 0) return script + debug('Inject css modules', modules) if (['js', 'babel'].indexOf(lang.toLowerCase()) > -1) { const matches = /(export default[^{]*\{)/g.exec(script) - if (matches) { + if (matches && matches.length) { const moduleScript = `${matches[1]}cssModules: ${JSON.stringify(modules)},` return script.split(matches[1]).join(moduleScript) @@ -56,7 +57,7 @@ function injectModule (script, lang, options, modules) { return options.injectModule(script, lang, options, modules) } - throw new Error('[rollup-plugin-vue] could not inject css module in script') + throw new Error('[rollup-plugin-vue] could not inject css module in script', script) } function injectRender (script, render, lang, options, modules) { From 11f42812c7c9263076e5d29ee199adeca60d2199 Mon Sep 17 00:00:00 2001 From: Rahul Kadyan Date: Mon, 27 Feb 2017 11:17:25 +0530 Subject: [PATCH 09/10] Allow custom injections & script processors --- package.json | 2 +- src/index.js | 21 ++++++---- src/injections.js | 89 +++++++++++++++++++++++++++++++++++++++++ src/options.js | 42 ++++++++++++++++++-- src/style/css.js | 4 +- src/vueTransform.js | 97 +++++++-------------------------------------- 6 files changed, 157 insertions(+), 98 deletions(-) create mode 100644 src/injections.js diff --git a/package.json b/package.json index 61b44f7..944639c 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "version": "2.3.0-beta.2", "description": "Roll .vue files", "main": "dist/rollup-plugin-vue.common.js", - "jsnext": "dist/rollup-plugin-vue.js", + "module": "dist/rollup-plugin-vue.js", "scripts": { "test": "npm run lint && npm run build && npm run unit", "build": "node config/build.js", diff --git a/src/index.js b/src/index.js index 8ca8e79..55e19d2 100644 --- a/src/index.js +++ b/src/index.js @@ -27,7 +27,8 @@ export default function vue (opts = {}) { } opts.compileTemplate = false; } - } catch (e) {} + } catch (e) { + } /* eslint-enable */ const config = mergeOptions(DEFAULT_OPTIONS, opts) @@ -44,14 +45,15 @@ export default function vue (opts = {}) { } }, load (id) { - if (id.indexOf('.vue.component.') > -1) { - const parts = id.split('.') - const component = parts.slice(0, parts.length - 4).join('.') - const index = parseInt(parts[parts.length - 4]) + if (id.indexOf('.vue.component.') < 0) return null - return styles[component][index] || '' - } + const parts = id.split('.') + const component = parts.slice(0, parts.length - 4).join('.') + const index = parseInt(parts[parts.length - 4]) + + if (index < styles[component].length) return styles[component][index] }, + async transform (source, id) { if (!filter(id) || !id.endsWith('.vue')) { debug(`Ignore: ${id}`) @@ -69,7 +71,10 @@ export default function vue (opts = {}) { ongenerate () { if (config.styleToImports !== true) { - if (config.css === undefined || config.css === null) config.css = DEFAULT_OPTIONS.css + if (config.css === undefined || config.css === null) { + config.css = DEFAULT_OPTIONS.css + } + compileStyle(styles, config) } } diff --git a/src/injections.js b/src/injections.js new file mode 100644 index 0000000..7b0d5d5 --- /dev/null +++ b/src/injections.js @@ -0,0 +1,89 @@ +import transpileVueTemplate from 'vue-template-es2015-compiler' + +export function templateJs (script, template, lang, id, options, modules) { + if (template === undefined) return script + + const matches = /(export default[^{]*\{)/g.exec(script) + + if (matches && matches.length) { + return script.split(matches[1]).join(`${matches[1]} template: ${JSON.stringify(template)},`) + } + + throw new Error( + `[rollup-plugin-vue] Template is injected in the default export of .vue file (lang: ${lang}). In ${id}, it cannot find 'export defaults'.` + ) +} + +/** + * Wrap code inside a with statement inside a function + * This is necessary for Vue 2 template compilation + */ +function wrapRenderFunction (code) { + return `function(){${code}}` +} + +export function renderJs (script, render, lang, id, options) { + const matches = /(export default[^{]*\{)/g.exec(script) + + if (matches && matches.length) { + let renderScript = 'module.exports={' + + `render: ${wrapRenderFunction(render.render)},` + + 'staticRenderFns: [' + + `${render.staticRenderFns.map(wrapRenderFunction).join(',')}],}` + + if (options.stripWith !== false) { + renderScript = transpileVueTemplate(renderScript, options.vue) + } + + return script.split(matches[1]).join(renderScript.replace('module.exports={', 'export default {').replace(/\}$/, '')) + } + + throw new Error( + `[rollup-plugin-vue] Generated render function is injected in the default export of .vue file (lang: ${lang}). In ${id}, it cannot find 'export defaults'.` + ) +} + +export function moduleJs (script, modules, lang, id, options) { + if (Object.keys(modules).length === 0) return script + + const matches = /(export default[^{]*\{)/g.exec(script) + + if (matches && matches.length) { + const moduleScript = `${matches[1]}cssModules: ${JSON.stringify(modules)},` + + return script.split(matches[1]).join(moduleScript) + } + + throw new Error( + `[rollup-plugin-vue] CSS modules are injected in the default export of .vue file (lang: ${lang}). In ${id}, it cannot find 'export defaults'.` + ) +} + +export function injectTemplate (script, template, lang, id, options) { + if (lang in options.inject.template) { + return options.inject.template[lang](script, template, lang, id, options) + } + throw new Error( + `[rollup-plugin-vue] Template is injected in the default export of .vue file. In ${id}, it cannot find 'export defaults'.` + ) +} + +export function injectRender (script, render, lang, id, options) { + if (lang in options.inject.render) { + return options.inject.render[lang](script, render, lang, id, options) + } + + throw new Error( + `[rollup-plugin-vue] Generated render function is injected in the default export of .vue file. In ${id}, it cannot find 'export defaults'.` + ) +} + +export function injectModule (script, modules, lang, id, options) { + if (lang in options.inject.module) { + return options.inject.module[lang](script, modules, lang, id, options) + } + + throw new Error( + `[rollup-plugin-vue] CSS modules are injected in the default export of .vue file. In ${id}, it cannot find 'export defaults'.` + ) +} diff --git a/src/options.js b/src/options.js index b8db4e8..8900434 100644 --- a/src/options.js +++ b/src/options.js @@ -1,9 +1,19 @@ +import { templateJs, moduleJs, renderJs } from './injections' + export default { + // Style compilation choices. + styleToImports: false, + autoStyles: true, + disableCssModuleStaticReplacement: false, + + // Config for html-minifier. htmlMinifier: { customAttrSurround: [[/@/, new RegExp('')], [/:/, new RegExp('')]], collapseWhitespace: true, removeComments: true }, + + // Handle with(this) vue: { // Remove all transforms added by vue since it's up to the user // to use whatever he wants @@ -34,12 +44,36 @@ export default { unicodeRegExp: false } }, - styleToImports: false, - autoStyles: true, - disableCssModuleStaticReplacement: false, + + // Config for postcss-modules. cssModules: { generateScopedName: '[name]__[local]' }, + + // Config for node-sass. scss: {}, - pug: {} + + // Config for pug compiler. + pug: {}, + + // Custom injectors. + inject: { + template: { + js: templateJs, + babel: templateJs + }, + + render: { + js: renderJs, + babel: renderJs + }, + + module: { + js: moduleJs, + babel: moduleJs + } + }, + + // script languages. + script: {} } diff --git a/src/style/css.js b/src/style/css.js index 31b5ec1..5492048 100644 --- a/src/style/css.js +++ b/src/style/css.js @@ -4,7 +4,7 @@ import camelcase from 'camelcase' // import MagicString from 'magic-string' import debug from '../debug' -function compileModule(code, map, source, options) { +function compileModule (code, map, source, options) { let style debug(`CSS Modules: ${source.id}`) @@ -24,7 +24,7 @@ function compileModule(code, map, source, options) { ) } -function escapeRegExp(str) { +function escapeRegExp (str) { return str.replace(/[-[\]/{}()*+?.\\^$|]/g, '\\$&') } diff --git a/src/vueTransform.js b/src/vueTransform.js index f60bfb7..d1d44d5 100644 --- a/src/vueTransform.js +++ b/src/vueTransform.js @@ -2,12 +2,12 @@ import deIndent from 'de-indent' import htmlMinifier from 'html-minifier' import parse5 from 'parse5' import templateValidator from 'vue-template-validator' -import transpileVueTemplate from 'vue-template-es2015-compiler' import { compile } from './style/index' import templateProcessor from './template/index' import { relative } from 'path' import MagicString from 'magic-string' import debug from './debug' +import { injectModule, injectTemplate, injectRender } from './injections' function getNodeAttrs (node) { if (node.attrs) { @@ -33,86 +33,9 @@ function padContent (content) { .join('\n') } -/** - * Wrap code inside a with statement inside a function - * This is necessary for Vue 2 template compilation - */ -function wrapRenderFunction (code) { - return `function(){${code}}` -} - -function injectModule (script, lang, options, modules) { - if (Object.keys(modules).length === 0) return script - debug('Inject css modules', modules) - - if (['js', 'babel'].indexOf(lang.toLowerCase()) > -1) { - const matches = /(export default[^{]*\{)/g.exec(script) - - if (matches && matches.length) { - const moduleScript = `${matches[1]}cssModules: ${JSON.stringify(modules)},` - - return script.split(matches[1]).join(moduleScript) - } - } else if (typeof (options.injectModule) === 'function') { - return options.injectModule(script, lang, options, modules) - } - - throw new Error('[rollup-plugin-vue] could not inject css module in script', script) -} - -function injectRender (script, render, lang, options, modules) { - if (['js', 'babel'].indexOf(lang.toLowerCase()) > -1) { - const matches = /(export default[^{]*\{)/g.exec(script) - if (matches) { - let renderScript = 'module.exports={' + - `render: ${wrapRenderFunction(render.render)},` + - 'staticRenderFns: [' + - `${render.staticRenderFns.map(wrapRenderFunction).join(',')}],}` - - if (options.stripWith !== false) { - renderScript = transpileVueTemplate(renderScript, options.vue) - } - - return script.split(matches[1]) - .join(renderScript.replace('module.exports={', 'export default {').replace(/\}$/, '')) - } - - debug(`No injection location found in: \n${script}\n`) - } else if (typeof (options.inject) === 'function') { - return options.inject(script, render, lang, options) - } - throw new Error('[rollup-plugin-vue] could not find place to inject template in script.') -} - -/** - * @param script - * @param template - * @param lang - * @param options - * @param modules - * @returns {string} - */ -function injectTemplate (script, template, lang, options, modules) { - if (template === undefined) return script - - if (['js', 'babel'].indexOf(lang.toLowerCase()) > -1) { - const matches = /(export default[^{]*\{)/g.exec(script) - if (matches) { - return script.split(matches[1]) - .join(`${matches[1]} template: ${JSON.stringify(template)},`) - } - - debug(`No injection location found in: \n${script}\n`) - } else if (typeof (options.inject) === 'function') { - return options.inject(script, template, lang, options) - } - - throw new Error('[rollup-plugin-vue] could not find place to inject template in script.') -} - function validateTemplate (code, content, id) { const warnings = templateValidator(code, content) - if (warnings) { + if (Array.isArray(warnings)) { const relativePath = relative(process.cwd(), id) warnings.forEach((msg) => { console.warn(`\n Warning in ${relativePath}:\n ${msg}`) @@ -149,16 +72,24 @@ async function processScript (source, id, content, options, nodes, modules) { const lang = source.attrs.lang || 'js' + if (['js', 'babel'].indexOf(lang) < 0) { + if (!(lang in options.script)) { + throw new Error(`[rollup-plugin-vue] ${lang} is not yet supported in .vue files.`) + } + + source = await options.script[lang](source, id, content, options, nodes) + } + const script = deIndent(padContent(content.slice(0, content.indexOf(source.code))) + source.code) const map = (new MagicString(script)).generateMap({ hires: true }) - const scriptWithModules = injectModule(script, lang, options, modules) + const scriptWithModules = injectModule(script, modules, lang, id, options) if (template && options.compileTemplate) { const render = require('vue-template-compiler').compile(template) - return { map, code: injectRender(scriptWithModules, render, lang, options, modules) } + return { map, code: await injectRender(scriptWithModules, render, lang, id, options) } } else if (template) { - return { map, code: injectTemplate(scriptWithModules, template, lang, options, modules) } + return { map, code: await injectTemplate(scriptWithModules, template, lang, id, options) } } else { return { map, code: scriptWithModules } } @@ -229,7 +160,7 @@ function parseTemplate (code) { return nodes } -var getModules = function (styles) { +const getModules = function (styles) { let all = {} for (let i = 0; i < styles.length; i += 1) { From 2d865e2a4fbe49c1e99df6e4c76ea03bef41a127 Mon Sep 17 00:00:00 2001 From: Rahul Kadyan Date: Mon, 27 Feb 2017 12:07:08 +0530 Subject: [PATCH 10/10] Add coffee support --- package.json | 4 ++++ src/injections.js | 21 +++++++++++++++++---- src/options.js | 6 +++++- src/script/coffee.js | 17 +++++++++++++++++ src/script/index.js | 1 + src/vueTransform.js | 11 +++++------ test/expects/coffee.js | 12 ++++++++++++ test/fixtures/coffee.vue | 9 +++++++++ yarn.lock | 8 ++++++++ 9 files changed, 78 insertions(+), 11 deletions(-) create mode 100644 src/script/coffee.js create mode 100644 src/script/index.js create mode 100644 test/expects/coffee.js create mode 100755 test/fixtures/coffee.vue diff --git a/package.json b/package.json index 944639c..c9b4887 100644 --- a/package.json +++ b/package.json @@ -81,5 +81,9 @@ "uglify-js": "^2.7.5", "vue-hot-reload-api": "^2.0.8", "yargs": "^6.6.0" + }, + "optionalDependencies": { + "coffee-script": "^1.12.4", + "coffeescript-compiler": "^0.1.1" } } diff --git a/src/injections.js b/src/injections.js index 7b0d5d5..18bfda3 100644 --- a/src/injections.js +++ b/src/injections.js @@ -1,9 +1,23 @@ import transpileVueTemplate from 'vue-template-es2015-compiler' +function findInjectionPosition (script) { + const hasDefaultExportObject = /(export default[^{]*\{)/g.exec(script) + + if (hasDefaultExportObject) return hasDefaultExportObject + + const hasDefaultExportReference = /(export default[\s]+((?!(?:do|if|in|for|let|new|try|var|case|else|enum|eval|false|null|this|true|void|with|break|catch|class|const|super|throw|while|yield|delete|export|import|public|return|static|switch|typeof|default|extends|finally|package|private|continue|debugger|function|arguments|interface|protected|implements|instanceof)$)[$A-Z_a-z\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376\u0377\u037a-\u037d\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05d0-\u05ea\u05f0-\u05f2\u0620-\u064a\u066e\u066f\u0671-\u06d3\u06d5\u06e5\u06e6\u06ee\u06ef\u06fa-\u06fc\u06ff\u0710\u0712-\u072f\u074d-\u07a5\u07b1\u07ca-\u07ea\u07f4\u07f5\u07fa\u0800-\u0815\u081a\u0824\u0828\u0840-\u0858\u08a0\u08a2-\u08ac\u0904-\u0939\u093d\u0950\u0958-\u0961\u0971-\u0977\u0979-\u097f\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bd\u09ce\u09dc\u09dd\u09df-\u09e1\u09f0\u09f1\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abd\u0ad0\u0ae0\u0ae1\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3d\u0b5c\u0b5d\u0b5f-\u0b61\u0b71\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bd0\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c33\u0c35-\u0c39\u0c3d\u0c58\u0c59\u0c60\u0c61\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cde\u0ce0\u0ce1\u0cf1\u0cf2\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d\u0d4e\u0d60\u0d61\u0d7a-\u0d7f\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0e01-\u0e30\u0e32\u0e33\u0e40-\u0e46\u0e81\u0e82\u0e84\u0e87\u0e88\u0e8a\u0e8d\u0e94-\u0e97\u0e99-\u0e9f\u0ea1-\u0ea3\u0ea5\u0ea7\u0eaa\u0eab\u0ead-\u0eb0\u0eb2\u0eb3\u0ebd\u0ec0-\u0ec4\u0ec6\u0edc-\u0edf\u0f00\u0f40-\u0f47\u0f49-\u0f6c\u0f88-\u0f8c\u1000-\u102a\u103f\u1050-\u1055\u105a-\u105d\u1061\u1065\u1066\u106e-\u1070\u1075-\u1081\u108e\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u1380-\u138f\u13a0-\u13f4\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f0\u1700-\u170c\u170e-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1780-\u17b3\u17d7\u17dc\u1820-\u1877\u1880-\u18a8\u18aa\u18b0-\u18f5\u1900-\u191c\u1950-\u196d\u1970-\u1974\u1980-\u19ab\u19c1-\u19c7\u1a00-\u1a16\u1a20-\u1a54\u1aa7\u1b05-\u1b33\u1b45-\u1b4b\u1b83-\u1ba0\u1bae\u1baf\u1bba-\u1be5\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c7d\u1ce9-\u1cec\u1cee-\u1cf1\u1cf5\u1cf6\u1d00-\u1dbf\u1e00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2071\u207f\u2090-\u209c\u2102\u2107\u210a-\u2113\u2115\u2119-\u211d\u2124\u2126\u2128\u212a-\u212d\u212f-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2c2e\u2c30-\u2c5e\u2c60-\u2ce4\u2ceb-\u2cee\u2cf2\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d80-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u2e2f\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303c\u3041-\u3096\u309d-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312d\u3131-\u318e\u31a0-\u31ba\u31f0-\u31ff\u3400-\u4db5\u4e00-\u9fcc\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua697\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua78e\ua790-\ua793\ua7a0-\ua7aa\ua7f8-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\ua840-\ua873\ua882-\ua8b3\ua8f2-\ua8f7\ua8fb\ua90a-\ua925\ua930-\ua946\ua960-\ua97c\ua984-\ua9b2\ua9cf\uaa00-\uaa28\uaa40-\uaa42\uaa44-\uaa4b\uaa60-\uaa76\uaa7a\uaa80-\uaaaf\uaab1\uaab5\uaab6\uaab9-\uaabd\uaac0\uaac2\uaadb-\uaadd\uaae0-\uaaea\uaaf2-\uaaf4\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uabc0-\uabe2\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d\ufb1f-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\uff21-\uff3a\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc][$A-Z_a-z\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376\u0377\u037a-\u037d\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05d0-\u05ea\u05f0-\u05f2\u0620-\u064a\u066e\u066f\u0671-\u06d3\u06d5\u06e5\u06e6\u06ee\u06ef\u06fa-\u06fc\u06ff\u0710\u0712-\u072f\u074d-\u07a5\u07b1\u07ca-\u07ea\u07f4\u07f5\u07fa\u0800-\u0815\u081a\u0824\u0828\u0840-\u0858\u08a0\u08a2-\u08ac\u0904-\u0939\u093d\u0950\u0958-\u0961\u0971-\u0977\u0979-\u097f\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bd\u09ce\u09dc\u09dd\u09df-\u09e1\u09f0\u09f1\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abd\u0ad0\u0ae0\u0ae1\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3d\u0b5c\u0b5d\u0b5f-\u0b61\u0b71\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bd0\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c33\u0c35-\u0c39\u0c3d\u0c58\u0c59\u0c60\u0c61\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cde\u0ce0\u0ce1\u0cf1\u0cf2\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d\u0d4e\u0d60\u0d61\u0d7a-\u0d7f\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0e01-\u0e30\u0e32\u0e33\u0e40-\u0e46\u0e81\u0e82\u0e84\u0e87\u0e88\u0e8a\u0e8d\u0e94-\u0e97\u0e99-\u0e9f\u0ea1-\u0ea3\u0ea5\u0ea7\u0eaa\u0eab\u0ead-\u0eb0\u0eb2\u0eb3\u0ebd\u0ec0-\u0ec4\u0ec6\u0edc-\u0edf\u0f00\u0f40-\u0f47\u0f49-\u0f6c\u0f88-\u0f8c\u1000-\u102a\u103f\u1050-\u1055\u105a-\u105d\u1061\u1065\u1066\u106e-\u1070\u1075-\u1081\u108e\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u1380-\u138f\u13a0-\u13f4\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f0\u1700-\u170c\u170e-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1780-\u17b3\u17d7\u17dc\u1820-\u1877\u1880-\u18a8\u18aa\u18b0-\u18f5\u1900-\u191c\u1950-\u196d\u1970-\u1974\u1980-\u19ab\u19c1-\u19c7\u1a00-\u1a16\u1a20-\u1a54\u1aa7\u1b05-\u1b33\u1b45-\u1b4b\u1b83-\u1ba0\u1bae\u1baf\u1bba-\u1be5\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c7d\u1ce9-\u1cec\u1cee-\u1cf1\u1cf5\u1cf6\u1d00-\u1dbf\u1e00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2071\u207f\u2090-\u209c\u2102\u2107\u210a-\u2113\u2115\u2119-\u211d\u2124\u2126\u2128\u212a-\u212d\u212f-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2c2e\u2c30-\u2c5e\u2c60-\u2ce4\u2ceb-\u2cee\u2cf2\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d80-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u2e2f\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303c\u3041-\u3096\u309d-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312d\u3131-\u318e\u31a0-\u31ba\u31f0-\u31ff\u3400-\u4db5\u4e00-\u9fcc\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua697\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua78e\ua790-\ua793\ua7a0-\ua7aa\ua7f8-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\ua840-\ua873\ua882-\ua8b3\ua8f2-\ua8f7\ua8fb\ua90a-\ua925\ua930-\ua946\ua960-\ua97c\ua984-\ua9b2\ua9cf\uaa00-\uaa28\uaa40-\uaa42\uaa44-\uaa4b\uaa60-\uaa76\uaa7a\uaa80-\uaaaf\uaab1\uaab5\uaab6\uaab9-\uaabd\uaac0\uaac2\uaadb-\uaadd\uaae0-\uaaea\uaaf2-\uaaf4\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uabc0-\uabe2\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d\ufb1f-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\uff21-\uff3a\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc0-9\u0300-\u036f\u0483-\u0487\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u0669\u0670\u06d6-\u06dc\u06df-\u06e4\u06e7\u06e8\u06ea-\u06ed\u06f0-\u06f9\u0711\u0730-\u074a\u07a6-\u07b0\u07c0-\u07c9\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0859-\u085b\u08e4-\u08fe\u0900-\u0903\u093a-\u093c\u093e-\u094f\u0951-\u0957\u0962\u0963\u0966-\u096f\u0981-\u0983\u09bc\u09be-\u09c4\u09c7\u09c8\u09cb-\u09cd\u09d7\u09e2\u09e3\u09e6-\u09ef\u0a01-\u0a03\u0a3c\u0a3e-\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a66-\u0a71\u0a75\u0a81-\u0a83\u0abc\u0abe-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ae2\u0ae3\u0ae6-\u0aef\u0b01-\u0b03\u0b3c\u0b3e-\u0b44\u0b47\u0b48\u0b4b-\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b66-\u0b6f\u0b82\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd7\u0be6-\u0bef\u0c01-\u0c03\u0c3e-\u0c44\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0c66-\u0c6f\u0c82\u0c83\u0cbc\u0cbe-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0ce6-\u0cef\u0d02\u0d03\u0d3e-\u0d44\u0d46-\u0d48\u0d4a-\u0d4d\u0d57\u0d62\u0d63\u0d66-\u0d6f\u0d82\u0d83\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0df2\u0df3\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0e50-\u0e59\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0ed0-\u0ed9\u0f18\u0f19\u0f20-\u0f29\u0f35\u0f37\u0f39\u0f3e\u0f3f\u0f71-\u0f84\u0f86\u0f87\u0f8d-\u0f97\u0f99-\u0fbc\u0fc6\u102b-\u103e\u1040-\u1049\u1056-\u1059\u105e-\u1060\u1062-\u1064\u1067-\u106d\u1071-\u1074\u1082-\u108d\u108f-\u109d\u135d-\u135f\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b4-\u17d3\u17dd\u17e0-\u17e9\u180b-\u180d\u1810-\u1819\u18a9\u1920-\u192b\u1930-\u193b\u1946-\u194f\u19b0-\u19c0\u19c8\u19c9\u19d0-\u19d9\u1a17-\u1a1b\u1a55-\u1a5e\u1a60-\u1a7c\u1a7f-\u1a89\u1a90-\u1a99\u1b00-\u1b04\u1b34-\u1b44\u1b50-\u1b59\u1b6b-\u1b73\u1b80-\u1b82\u1ba1-\u1bad\u1bb0-\u1bb9\u1be6-\u1bf3\u1c24-\u1c37\u1c40-\u1c49\u1c50-\u1c59\u1cd0-\u1cd2\u1cd4-\u1ce8\u1ced\u1cf2-\u1cf4\u1dc0-\u1de6\u1dfc-\u1dff\u200c\u200d\u203f\u2040\u2054\u20d0-\u20dc\u20e1\u20e5-\u20f0\u2cef-\u2cf1\u2d7f\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua620-\ua629\ua66f\ua674-\ua67d\ua69f\ua6f0\ua6f1\ua802\ua806\ua80b\ua823-\ua827\ua880\ua881\ua8b4-\ua8c4\ua8d0-\ua8d9\ua8e0-\ua8f1\ua900-\ua909\ua926-\ua92d\ua947-\ua953\ua980-\ua983\ua9b3-\ua9c0\ua9d0-\ua9d9\uaa29-\uaa36\uaa43\uaa4c\uaa4d\uaa50-\uaa59\uaa7b\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uaaeb-\uaaef\uaaf5\uaaf6\uabe3-\uabea\uabec\uabed\uabf0-\uabf9\ufb1e\ufe00-\ufe0f\ufe20-\ufe26\ufe33\ufe34\ufe4d-\ufe4f\uff10-\uff19\uff3f]*))/g.exec(script) + + if (!hasDefaultExportReference) return null + + const name = hasDefaultExportReference[2].replace('$', '\\$') + + return (new RegExp(`(${name}[\\s]=[^{]*\\{)`, 'g')).exec(script) +} + export function templateJs (script, template, lang, id, options, modules) { if (template === undefined) return script - const matches = /(export default[^{]*\{)/g.exec(script) + const matches = findInjectionPosition(script) if (matches && matches.length) { return script.split(matches[1]).join(`${matches[1]} template: ${JSON.stringify(template)},`) @@ -23,7 +37,7 @@ function wrapRenderFunction (code) { } export function renderJs (script, render, lang, id, options) { - const matches = /(export default[^{]*\{)/g.exec(script) + const matches = findInjectionPosition(script) if (matches && matches.length) { let renderScript = 'module.exports={' + @@ -42,11 +56,10 @@ export function renderJs (script, render, lang, id, options) { `[rollup-plugin-vue] Generated render function is injected in the default export of .vue file (lang: ${lang}). In ${id}, it cannot find 'export defaults'.` ) } - export function moduleJs (script, modules, lang, id, options) { if (Object.keys(modules).length === 0) return script - const matches = /(export default[^{]*\{)/g.exec(script) + const matches = findInjectionPosition(script) if (matches && matches.length) { const moduleScript = `${matches[1]}cssModules: ${JSON.stringify(modules)},` diff --git a/src/options.js b/src/options.js index 8900434..03b083f 100644 --- a/src/options.js +++ b/src/options.js @@ -1,4 +1,5 @@ import { templateJs, moduleJs, renderJs } from './injections' +import { coffee } from './script/index' export default { // Style compilation choices. @@ -75,5 +76,8 @@ export default { }, // script languages. - script: {} + script: { + coffee, + coffeescript: coffee + } } diff --git a/src/script/coffee.js b/src/script/coffee.js new file mode 100644 index 0000000..b4f0cb6 --- /dev/null +++ b/src/script/coffee.js @@ -0,0 +1,17 @@ +import Compiler from 'coffeescript-compiler' + +const coffee = new Compiler() + +export default function (script) { + return new Promise((resolve, reject) => { + coffee.compile(script.code, { bare: true }, (status, output) => { + if (status === 0) { + script.code = output + + resolve(script) + } else { + reject(`Coffee compiler exited with status code ${status}.`) + } + }) + }) +} diff --git a/src/script/index.js b/src/script/index.js new file mode 100644 index 0000000..998d218 --- /dev/null +++ b/src/script/index.js @@ -0,0 +1 @@ +export { default as coffee } from './coffee' diff --git a/src/vueTransform.js b/src/vueTransform.js index d1d44d5..88a5095 100644 --- a/src/vueTransform.js +++ b/src/vueTransform.js @@ -69,15 +69,14 @@ async function processScript (source, id, content, options, nodes, modules) { const template = await processTemplate(nodes.template[0], id, content, options, nodes, modules) debug(`Process script: ${id}`) + const lang = 'js' - const lang = source.attrs.lang || 'js' - - if (['js', 'babel'].indexOf(lang) < 0) { - if (!(lang in options.script)) { - throw new Error(`[rollup-plugin-vue] ${lang} is not yet supported in .vue files.`) + if (source.attrs.lang && ['js', 'babel'].indexOf(source.attrs.lang) < 0) { + if (!(source.attrs.lang in options.script)) { + throw new Error(`[rollup-plugin-vue] ${source.attrs.lang} is not yet supported in .vue files.`) } - source = await options.script[lang](source, id, content, options, nodes) + source = await options.script[source.attrs.lang](source, id, content, options, nodes) } const script = deIndent(padContent(content.slice(0, content.indexOf(source.code))) + source.code) diff --git a/test/expects/coffee.js b/test/expects/coffee.js new file mode 100644 index 0000000..ae5e3e3 --- /dev/null +++ b/test/expects/coffee.js @@ -0,0 +1,12 @@ +// Generated by CoffeeScript 1.12.4 +var component; + +component = { template: "

hello

", + data: function() { + return [2, 4, 6, 8]; + } +}; + +var component$1 = component; + +export default component$1; \ No newline at end of file diff --git a/test/fixtures/coffee.vue b/test/fixtures/coffee.vue new file mode 100755 index 0000000..ab5deb2 --- /dev/null +++ b/test/fixtures/coffee.vue @@ -0,0 +1,9 @@ + + + diff --git a/yarn.lock b/yarn.lock index b69fab5..b13e0bc 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1002,6 +1002,14 @@ code-point-at@^1.0.0: version "1.1.0" resolved "https://registry.yarnpkg.com/code-point-at/-/code-point-at-1.1.0.tgz#0d070b4d043a5bea33a2f1a40e2edb3d9a4ccf77" +coffee-script@^1.12.4: + version "1.12.4" + resolved "https://registry.yarnpkg.com/coffee-script/-/coffee-script-1.12.4.tgz#fe1bced97fe1fb3927b998f2b45616e0658be1ff" + +coffeescript-compiler@^0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/coffeescript-compiler/-/coffeescript-compiler-0.1.1.tgz#81a8bd44a78bda421f7e0b51f28d13c853beb805" + colors@1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/colors/-/colors-1.0.3.tgz#0433f44d809680fdeb60ed260f1b0c262e82a40b"