From 02f9454b660d526958e71768b1c51face88b75e3 Mon Sep 17 00:00:00 2001 From: patmood Date: Sat, 26 Aug 2017 18:16:30 -0700 Subject: [PATCH 001/316] rename progress class to prevent conflicts --- lib/app/components/nuxt-loading.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/app/components/nuxt-loading.vue b/lib/app/components/nuxt-loading.vue index f7d0e91cae..6ccc666b59 100644 --- a/lib/app/components/nuxt-loading.vue +++ b/lib/app/components/nuxt-loading.vue @@ -1,5 +1,5 @@ + + \ No newline at end of file From 699b3f6230d60618662284d382e95e83a1fdb55a Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Wed, 30 Aug 2017 19:36:16 +0430 Subject: [PATCH 020/316] disable ModuleConcatenationPlugin --- lib/builder/webpack/client.config.js | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/lib/builder/webpack/client.config.js b/lib/builder/webpack/client.config.js index bef3a7b08c..4e04e63df0 100644 --- a/lib/builder/webpack/client.config.js +++ b/lib/builder/webpack/client.config.js @@ -5,7 +5,6 @@ import HTMLPlugin from 'html-webpack-plugin' import FriendlyErrorsWebpackPlugin from 'friendly-errors-webpack-plugin' import ProgressBarPlugin from 'progress-bar-webpack-plugin' import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer' -// import MinifyPlugin from 'babel-minify-webpack-plugin' import { resolve } from 'path' import { existsSync } from 'fs' import Debug from 'debug' @@ -191,17 +190,13 @@ export default function webpackClientConfig () { if (!this.options.dev) { // Scope Hoisting config.plugins.push( - new webpack.optimize.ModuleConcatenationPlugin() + // new webpack.optimize.ModuleConcatenationPlugin() ) // https://webpack.js.org/plugins/hashed-module-ids-plugin config.plugins.push(new webpack.HashedModuleIdsPlugin()) // Minify JS - - // https://github.com/webpack-contrib/babel-minify-webpack-plugin - // config.plugins.push(new MinifyPlugin()) - // https://github.com/webpack-contrib/uglifyjs-webpack-plugin config.plugins.push( new webpack.optimize.UglifyJsPlugin({ From 2dc84add7d32a72e0d41043c14f6b3bc2d2b5aea Mon Sep 17 00:00:00 2001 From: Sebastien Chopin Date: Wed, 30 Aug 2017 18:33:27 +0200 Subject: [PATCH 021/316] Use css-loader module --- package.json | 2 +- yarn.lock | 24 ++++++++++-------------- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/package.json b/package.json index edd80effb2..a8cd8b14bf 100644 --- a/package.json +++ b/package.json @@ -76,7 +76,7 @@ "clone": "^2.1.1", "compression": "^1.7.0", "connect": "^3.6.3", - "css-loader": "https://github.com/nuxt/css-loader.git", + "css-loader": "^0.28.6", "debug": "^3.0.1", "es6-promise": "^4.1.1", "etag": "^1.8.0", diff --git a/yarn.lock b/yarn.lock index 3f1dd839ca..2687749834 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1304,12 +1304,12 @@ caniuse-api@^2.0.0: lodash.uniq "^4.5.0" caniuse-db@^1.0.30000529, caniuse-db@^1.0.30000634, caniuse-db@^1.0.30000639: - version "1.0.30000718" - resolved "https://registry.yarnpkg.com/caniuse-db/-/caniuse-db-1.0.30000718.tgz#86cdd97987302554934c61e106f4e470f16f993c" + version "1.0.30000721" + resolved "https://registry.yarnpkg.com/caniuse-db/-/caniuse-db-1.0.30000721.tgz#cdc52efe8f82dd13916615b78e86f704ece61802" caniuse-lite@^1.0.0, caniuse-lite@^1.0.30000718: - version "1.0.30000718" - resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30000718.tgz#0dd24290beb11310b2d80f6b70a823c2a65a6fad" + version "1.0.30000721" + resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30000721.tgz#931a21a7bd85016300328d21f126d84b73437d35" capture-stack-trace@^1.0.0: version "1.0.0" @@ -1811,9 +1811,9 @@ css-color-names@0.0.4: version "0.0.4" resolved "https://registry.yarnpkg.com/css-color-names/-/css-color-names-0.0.4.tgz#808adc2e79cf84738069b646cb20ec27beb629e0" -"css-loader@https://github.com/nuxt/css-loader.git": - version "0.28.5" - resolved "https://github.com/nuxt/css-loader.git#43674428e42dd208f6192cfc0b1679935a0bae4b" +css-loader@^0.28.6: + version "0.28.6" + resolved "https://registry.yarnpkg.com/css-loader/-/css-loader-0.28.6.tgz#9cc15eeee3f8d2f4eeb4c37556581ac84f39bad1" dependencies: babel-code-frame "^6.11.0" css-selector-tokenizer "^0.7.0" @@ -4103,8 +4103,8 @@ mute-stream@0.0.7: resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.7.tgz#3075ce93bc21b8fab43e1bc4da7e8115ed1e7bab" nan@^2.3.0: - version "2.6.2" - resolved "https://registry.yarnpkg.com/nan/-/nan-2.6.2.tgz#e4ff34e6c95fdfb5aecc08de6596f43605a7db45" + version "2.7.0" + resolved "https://registry.yarnpkg.com/nan/-/nan-2.7.0.tgz#d95bf721ec877e08db276ed3fc6eb78f9083ad46" natural-compare@^1.4.0: version "1.4.0" @@ -6688,14 +6688,10 @@ window-size@0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/window-size/-/window-size-0.1.0.tgz#5438cd2ea93b202efa3a19fe8887aee7c94f9c9d" -wordwrap@0.0.2: +wordwrap@0.0.2, wordwrap@~0.0.2: version "0.0.2" resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-0.0.2.tgz#b79669bb42ecb409f83d583cad52ca17eaa1643f" -wordwrap@~0.0.2: - version "0.0.3" - resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-0.0.3.tgz#a3d5da6cd5c0bc0008d37234bbaf1bed63059107" - wordwrap@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-1.0.0.tgz#27584810891456a4171c8d0226441ade90cbcaeb" From 6852f9e7a63c1555777e5064a5829c61577e80b3 Mon Sep 17 00:00:00 2001 From: Sebastien Chopin Date: Wed, 30 Aug 2017 18:36:12 +0200 Subject: [PATCH 022/316] Bump to rc8 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a8cd8b14bf..17f7485b45 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nuxt", - "version": "1.0.0-rc7", + "version": "1.0.0-rc8", "description": "A minimalistic framework for server-rendered Vue.js applications (inspired by Next.js)", "contributors": [ { From 63bc512d73660986546bd2428649d0299a6a0abd Mon Sep 17 00:00:00 2001 From: Sebastien Chopin Date: Wed, 30 Aug 2017 18:36:41 +0200 Subject: [PATCH 023/316] Bump to rc8 --- start/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/start/package.json b/start/package.json index 8f2b656b6e..040335a6e9 100644 --- a/start/package.json +++ b/start/package.json @@ -1,6 +1,6 @@ { "name": "nuxt-start", - "version": "1.0.0-rc7", + "version": "1.0.0-rc8", "description": "runtime-only build for nuxt", "contributors": [ { From e2a18d76da6bc81c6cd946b8bafe6501679796c1 Mon Sep 17 00:00:00 2001 From: Wu Haotian Date: Thu, 31 Aug 2017 14:27:52 +0800 Subject: [PATCH 024/316] Fix typo in lib/app/index.js (#1539) --- lib/app/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/app/index.js b/lib/app/index.js index d3dc52750a..19ba1ad2b2 100644 --- a/lib/app/index.js +++ b/lib/app/index.js @@ -144,7 +144,7 @@ async function createApp (ssrContext) { <% if (store) { %> if (process.browser) { - // Replace store state before calling plugins + // Replace store state after calling plugins if (window.__NUXT__ && window.__NUXT__.state) { store.replaceState(window.__NUXT__.state) } From 7da8785d729985dca829fc2a2d614b859e3ca871 Mon Sep 17 00:00:00 2001 From: Sebastien Chopin Date: Thu, 31 Aug 2017 14:46:06 +0200 Subject: [PATCH 025/316] Add context.serverStoreState --- lib/app/utils.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/app/utils.js b/lib/app/utils.js index 4d65a8e187..e2d444796e 100644 --- a/lib/app/utils.js +++ b/lib/app/utils.js @@ -108,6 +108,11 @@ export function getContext (context, app) { if (ctx.isServer && context.beforeRenderFns) { ctx.beforeNuxtRender = (fn) => context.beforeRenderFns.push(fn) } + <% if (store) { %> + if (ctx.isClient && window.__NUXT__ && window.__NUXT__.state) { + ctx.serverStoreState = window.__NUXT__.state + } + <% } %> return ctx } From f4c68e95e240842c50701ea75a7834fdf07616f2 Mon Sep 17 00:00:00 2001 From: Sebastien Chopin Date: Fri, 1 Sep 2017 10:29:06 +0200 Subject: [PATCH 026/316] Add serverState --- lib/app/utils.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/app/utils.js b/lib/app/utils.js index e2d444796e..8cebeba6c3 100644 --- a/lib/app/utils.js +++ b/lib/app/utils.js @@ -108,11 +108,12 @@ export function getContext (context, app) { if (ctx.isServer && context.beforeRenderFns) { ctx.beforeNuxtRender = (fn) => context.beforeRenderFns.push(fn) } - <% if (store) { %> - if (ctx.isClient && window.__NUXT__ && window.__NUXT__.state) { - ctx.serverStoreState = window.__NUXT__.state + if (ctx.isClient && window.__NUXT__) { + ctx.serverState = window.__NUXT__ + <% if (store) { %> + ctx.serverStoreState = ctx.serverState.state + <% } %> } - <% } %> return ctx } From 9d43db475b86218db1b68515200a0ec887bb43a9 Mon Sep 17 00:00:00 2001 From: Sebastien Chopin Date: Fri, 1 Sep 2017 17:38:16 +0200 Subject: [PATCH 027/316] Fix example --- examples/i18n/package.json | 2 +- examples/i18n/plugins/i18n.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/i18n/package.json b/examples/i18n/package.json index 5ca4f709ba..6c75b31cb7 100644 --- a/examples/i18n/package.json +++ b/examples/i18n/package.json @@ -1,7 +1,7 @@ { "name": "nuxt-i18n", "dependencies": { - "nuxt": "latest", + "nuxt": "^1.0.0-rc9", "vue-i18n": "^7.0.5" }, "scripts": { diff --git a/examples/i18n/plugins/i18n.js b/examples/i18n/plugins/i18n.js index e4859aadc9..c767fd7f3e 100644 --- a/examples/i18n/plugins/i18n.js +++ b/examples/i18n/plugins/i18n.js @@ -3,11 +3,11 @@ import VueI18n from 'vue-i18n' Vue.use(VueI18n) -export default ({ app, store }) => { +export default ({ app, isClient, store, serverStore }) => { // Set i18n instance on app // This way we can use it in middleware and pages asyncData/fetch app.i18n = new VueI18n({ - locale: store.state.locale, + locale: (isClient ? serverStore.locale : store.state.locale), fallbackLocale: 'en', messages: { 'en': require('~/locales/en.json'), From a6a36b1d2fe0ae0f33a1a01a4aa4863790d84abb Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Fri, 1 Sep 2017 20:29:20 +0430 Subject: [PATCH 028/316] simplify error pages No dependencies and more mobile friendly --- lib/app/components/nuxt-error.vue | 99 +++++++++++++++++-------------- lib/app/views/error.html | 71 ++++------------------ 2 files changed, 65 insertions(+), 105 deletions(-) diff --git a/lib/app/components/nuxt-error.vue b/lib/app/components/nuxt-error.vue index 68b05a43be..4a12242201 100644 --- a/lib/app/components/nuxt-error.vue +++ b/lib/app/components/nuxt-error.vue @@ -1,32 +1,23 @@ diff --git a/examples/layout-transitions/pages/index.vue b/examples/layout-transitions/pages/index.vue new file mode 100644 index 0000000000..fe5ce74005 --- /dev/null +++ b/examples/layout-transitions/pages/index.vue @@ -0,0 +1,7 @@ + diff --git a/examples/layout-transitions/pages/users.vue b/examples/layout-transitions/pages/users.vue new file mode 100644 index 0000000000..ce5c065ba4 --- /dev/null +++ b/examples/layout-transitions/pages/users.vue @@ -0,0 +1,71 @@ + + + + + diff --git a/lib/app/App.vue b/lib/app/App.vue index 37e6d69b37..53806cd92e 100644 --- a/lib/app/App.vue +++ b/lib/app/App.vue @@ -1,7 +1,9 @@ diff --git a/lib/app/components/nuxt-child.js b/lib/app/components/nuxt-child.js index 39b8e3c4e7..5e17edbea1 100644 --- a/lib/app/components/nuxt-child.js +++ b/lib/app/components/nuxt-child.js @@ -37,6 +37,19 @@ export default { name: 'nuxt-child', functional: true, render (h, { parent, data }) { + const nuxt = parent.$root.nuxt + const component = parent.$route.matched[0].components.default + + const layoutUid = parent._uid + const layoutName = component.options ? component.options.layout : null + + // If we're changing layout return the stored vnode + if (nuxt._layoutUid === layoutUid && + nuxt._layoutName !== layoutName) return nuxt._layoutVnode + + nuxt._layoutUid = layoutUid + nuxt._layoutName = layoutName + data.nuxtChild = true const _parent = parent const transitions = parent.$nuxt.nuxt.transitions @@ -62,11 +75,14 @@ export default { listeners[key] = transition[key].bind(_parent) } }) - return h('transition', { + + nuxt._layoutVnode = h('transition', { props: transitionProps, on: listeners }, [ h('router-view', data) ]) + + return nuxt._layoutVnode } } diff --git a/lib/builder/builder.js b/lib/builder/builder.js index cf1de02253..ec84c59138 100644 --- a/lib/builder/builder.js +++ b/lib/builder/builder.js @@ -219,6 +219,7 @@ export default class Builder extends Tapable { layouts: Object.assign({}, this.options.layouts), loading: typeof this.options.loading === 'string' ? this.relativeToBuild(this.options.srcDir, this.options.loading) : this.options.loading, transition: this.options.transition, + layoutTransition: this.options.layoutTransition, components: { ErrorPage: this.options.ErrorPage ? this.relativeToBuild(this.options.ErrorPage) : null } diff --git a/lib/common/options.js b/lib/common/options.js index 8c6f099314..7f0e5b8d32 100755 --- a/lib/common/options.js +++ b/lib/common/options.js @@ -24,6 +24,9 @@ Options.from = function (_options) { if (typeof options.transition === 'string') { options.transition = { name: options.transition } } + if (typeof options.layoutTransition === 'string') { + options.layoutTransition = { name: options.layoutTransition } + } // Apply defaults _.defaultsDeep(options, Options.defaults) @@ -243,6 +246,10 @@ Options.defaults = { appearActiveClass: 'appear-active', appearToClass: 'appear-to' }, + layoutTransition: { + name: 'layout', + mode: 'out-in' + }, router: { mode: 'history', base: '/', From 2bf02731f2b0b948cefc97560cb73b8b9d03ac67 Mon Sep 17 00:00:00 2001 From: James Homer Date: Sat, 9 Sep 2017 12:12:07 +0100 Subject: [PATCH 065/316] fix page transitions --- lib/app/App.vue | 2 +- lib/app/components/nuxt-child.js | 8 ++++---- lib/app/components/nuxt.vue | 6 ++++-- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/app/App.vue b/lib/app/App.vue index 53806cd92e..771bd613f7 100644 --- a/lib/app/App.vue +++ b/lib/app/App.vue @@ -2,7 +2,7 @@
<% if (loading) { %><% } %> <% if (layoutTransition) { %><% } %> - + <% if (layoutTransition) { %><% } %>
diff --git a/lib/app/components/nuxt-child.js b/lib/app/components/nuxt-child.js index 5e17edbea1..8df1feb71d 100644 --- a/lib/app/components/nuxt-child.js +++ b/lib/app/components/nuxt-child.js @@ -43,9 +43,9 @@ export default { const layoutUid = parent._uid const layoutName = component.options ? component.options.layout : null - // If we're changing layout return the stored vnode + // If we're changing layout render the stored vnode if (nuxt._layoutUid === layoutUid && - nuxt._layoutName !== layoutName) return nuxt._layoutVnode + nuxt._layoutName !== layoutName) return nuxt._childVnode nuxt._layoutUid = layoutUid nuxt._layoutName = layoutName @@ -76,13 +76,13 @@ export default { } }) - nuxt._layoutVnode = h('transition', { + nuxt._childVnode = h('transition', { props: transitionProps, on: listeners }, [ h('router-view', data) ]) - return nuxt._layoutVnode + return nuxt._childVnode } } diff --git a/lib/app/components/nuxt.vue b/lib/app/components/nuxt.vue index 2817b3af9a..2bdd096dd8 100644 --- a/lib/app/components/nuxt.vue +++ b/lib/app/components/nuxt.vue @@ -1,6 +1,8 @@ + + \ No newline at end of file From 107f245dcf34143d9ead4948a93566fbe4927275 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Chopin?= Date: Thu, 21 Sep 2017 22:28:06 +0200 Subject: [PATCH 076/316] Add generate script --- examples/dynamic-components/package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/dynamic-components/package.json b/examples/dynamic-components/package.json index 8764932b44..300c9256e4 100644 --- a/examples/dynamic-components/package.json +++ b/examples/dynamic-components/package.json @@ -8,6 +8,7 @@ "scripts": { "dev": "nuxt", "build": "nuxt build", - "start": "nuxt start" + "start": "nuxt start", + "generate": "nuxt generate" } } From 04c8d423d48d5fe77ba1b7294ed1c86c1d41eeb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Chopin?= Date: Thu, 21 Sep 2017 22:36:50 +0200 Subject: [PATCH 077/316] Update README.md --- examples/dynamic-components/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/dynamic-components/README.md b/examples/dynamic-components/README.md index 06b42c7783..8b7290300f 100644 --- a/examples/dynamic-components/README.md +++ b/examples/dynamic-components/README.md @@ -1,5 +1,5 @@ # Dynamic Components with Nuxt.js -Demo: https://nuxt-chat.now.sh +Demo: https://dynamic-components.nuxtjs.org/ Video: https://www.youtube.com/watch?v=HzDea5-PFaw From 6fd67b68dd4e36b846fadb9e6210933958173b06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Chopin?= Date: Thu, 21 Sep 2017 22:42:28 +0200 Subject: [PATCH 078/316] fix: Wait for fn to end before pushing next message --- examples/dynamic-components/js/messages.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/dynamic-components/js/messages.js b/examples/dynamic-components/js/messages.js index 3caa0f77b1..aac4333f6a 100644 --- a/examples/dynamic-components/js/messages.js +++ b/examples/dynamic-components/js/messages.js @@ -18,10 +18,10 @@ export const messages = [ { component: 'vText', data: 'End of demo 🎉' }, ] -function streamMessages (fn, i = 0) { +async function streamMessages (fn, i = 0) { if (i >= messages.length) return - fn(messages[i]) - setTimeout(() => streamMessages(fn, i + 1), 2000) + await fn(messages[i]) + setTimeout(() => streamMessages(fn, i + 1), 1500) } export default streamMessages \ No newline at end of file From a3e5edd04af7634466f9328ec504d07618f5cc56 Mon Sep 17 00:00:00 2001 From: Sebastien Chopin Date: Fri, 22 Sep 2017 15:21:34 +0200 Subject: [PATCH 079/316] Upgrade dependencies --- package.json | 8 +- start/package.json | 5 +- yarn.lock | 207 +++++++++++++++++++++++++++------------------ 3 files changed, 134 insertions(+), 86 deletions(-) diff --git a/package.json b/package.json index 60e6ee9495..598d5389cd 100644 --- a/package.json +++ b/package.json @@ -97,7 +97,7 @@ "pify": "^3.0.0", "postcss": "^6.0.10", "postcss-cssnext": "^3.0.2", - "postcss-import": "^10.0.0", + "postcss-import": "^11.0.0", "postcss-loader": "^2.0.6", "postcss-url": "^7.1.2", "pretty-error": "^2.1.1", @@ -124,7 +124,7 @@ }, "devDependencies": { "ava": "^0.22.0", - "babel-eslint": "^7.2.3", + "babel-eslint": "^8.0.0", "babel-plugin-array-includes": "^2.0.3", "babel-plugin-external-helpers": "^6.22.0", "babel-plugin-istanbul": "^4.1.4", @@ -146,12 +146,12 @@ "request": "^2.81.0", "request-promise-native": "^1.0.4", "rimraf": "^2.6.1", - "rollup": "^0.49.2", + "rollup": "^0.50.0", "rollup-plugin-alias": "^1.3.1", "rollup-plugin-babel": "^3.0.2", "rollup-plugin-commonjs": "^8.2.0", "rollup-plugin-node-resolve": "^3.0.0", - "rollup-plugin-replace": "^1.1.1", + "rollup-plugin-replace": "^2.0.0", "rollup-watch": "^4.3.1", "std-mocks": "^1.0.1", "uglify-js": "^3.0.28" diff --git a/start/package.json b/start/package.json index 2a158122b0..fc67f8fced 100644 --- a/start/package.json +++ b/start/package.json @@ -63,13 +63,14 @@ "compression": "^1.7.0", "fs-extra": "^4.0.1", "vue-server-renderer": "~2.4.2", - "@nuxtjs/youch": "3.0.2", + "@nuxtjs/youch": "3.1.0", "source-map": "^0.5.7", "connect": "^3.6.3", "vue": "~2.4.2", "vue-meta": "^1.1.0", "lru-cache": "^4.1.1", - "server-destroy": "^1.0.1" + "server-destroy": "^1.0.1", + "open-in-editor": "^2.2.0" }, "collective": { "type": "opencollective", diff --git a/yarn.lock b/yarn.lock index 83d95b3af1..7a1c08fe84 100644 --- a/yarn.lock +++ b/yarn.lock @@ -44,9 +44,9 @@ dependencies: arrify "^1.0.1" -"@nuxtjs/youch@3.0.2": - version "3.0.2" - resolved "https://registry.yarnpkg.com/@nuxtjs/youch/-/youch-3.0.2.tgz#03fff829ca45bd1c3ece84c08270f9686229dd4a" +"@nuxtjs/youch@3.1.0": + version "3.1.0" + resolved "https://registry.yarnpkg.com/@nuxtjs/youch/-/youch-3.1.0.tgz#0e4f38d1b9ede2a77b121c02cbd839937e8918ad" dependencies: cookie "^0.3.1" mustache "^2.3.0" @@ -440,6 +440,14 @@ aws4@^1.2.1: version "1.6.0" resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.6.0.tgz#83ef5ca860b2b32e4a0deedee8c771b9db57471e" +babel-code-frame@7.0.0-beta.0: + version "7.0.0-beta.0" + resolved "https://registry.yarnpkg.com/babel-code-frame/-/babel-code-frame-7.0.0-beta.0.tgz#418a7b5f3f7dc9a4670e61b1158b4c5661bec98d" + dependencies: + chalk "^2.0.0" + esutils "^2.0.2" + js-tokens "^3.0.0" + babel-code-frame@^6.11.0, babel-code-frame@^6.22.0, babel-code-frame@^6.26.0: version "6.26.0" resolved "https://registry.yarnpkg.com/babel-code-frame/-/babel-code-frame-6.26.0.tgz#63fd43f7dc1e3bb7ce35947db8fe369a3f58c74b" @@ -472,14 +480,14 @@ babel-core@^6.17.0, babel-core@^6.26.0: slash "^1.0.0" source-map "^0.5.6" -babel-eslint@^7.2.3: - version "7.2.3" - resolved "https://registry.yarnpkg.com/babel-eslint/-/babel-eslint-7.2.3.tgz#b2fe2d80126470f5c19442dc757253a897710827" +babel-eslint@^8.0.0: + version "8.0.0" + resolved "https://registry.yarnpkg.com/babel-eslint/-/babel-eslint-8.0.0.tgz#ce06f385bdfb5b6d7e603f06222f891abd14c240" dependencies: - babel-code-frame "^6.22.0" - babel-traverse "^6.23.1" - babel-types "^6.23.0" - babylon "^6.17.0" + babel-code-frame "7.0.0-beta.0" + babel-traverse "7.0.0-beta.0" + babel-types "7.0.0-beta.0" + babylon "7.0.0-beta.22" babel-generator@^6.1.0, babel-generator@^6.18.0, babel-generator@^6.26.0: version "6.26.0" @@ -528,6 +536,15 @@ babel-helper-explode-assignable-expression@^6.24.1: babel-traverse "^6.24.1" babel-types "^6.24.1" +babel-helper-function-name@7.0.0-beta.0: + version "7.0.0-beta.0" + resolved "https://registry.yarnpkg.com/babel-helper-function-name/-/babel-helper-function-name-7.0.0-beta.0.tgz#d1b6779b647e5c5c31ebeb05e13b998e4d352d56" + dependencies: + babel-helper-get-function-arity "7.0.0-beta.0" + babel-template "7.0.0-beta.0" + babel-traverse "7.0.0-beta.0" + babel-types "7.0.0-beta.0" + babel-helper-function-name@^6.24.1: version "6.24.1" resolved "https://registry.yarnpkg.com/babel-helper-function-name/-/babel-helper-function-name-6.24.1.tgz#d3475b8c03ed98242a25b48351ab18399d3580a9" @@ -538,6 +555,12 @@ babel-helper-function-name@^6.24.1: babel-traverse "^6.24.1" babel-types "^6.24.1" +babel-helper-get-function-arity@7.0.0-beta.0: + version "7.0.0-beta.0" + resolved "https://registry.yarnpkg.com/babel-helper-get-function-arity/-/babel-helper-get-function-arity-7.0.0-beta.0.tgz#9d1ab7213bb5efe1ef1638a8ea1489969b5a8b6e" + dependencies: + babel-types "7.0.0-beta.0" + babel-helper-get-function-arity@^6.24.1: version "6.24.1" resolved "https://registry.yarnpkg.com/babel-helper-get-function-arity/-/babel-helper-get-function-arity-6.24.1.tgz#8f7782aa93407c41d3aa50908f89b031b1b6853d" @@ -607,6 +630,10 @@ babel-loader@^7.1.2: loader-utils "^1.0.2" mkdirp "^0.5.1" +babel-messages@7.0.0-beta.0: + version "7.0.0-beta.0" + resolved "https://registry.yarnpkg.com/babel-messages/-/babel-messages-7.0.0-beta.0.tgz#6df01296e49fc8fbd0637394326a167f36da817b" + babel-messages@^6.23.0: version "6.23.0" resolved "https://registry.yarnpkg.com/babel-messages/-/babel-messages-6.23.0.tgz#f3cdf4703858035b2a2951c6ec5edf6c62f2630e" @@ -693,7 +720,7 @@ babel-plugin-transform-es2015-block-scoped-functions@^6.22.0: dependencies: babel-runtime "^6.22.0" -babel-plugin-transform-es2015-block-scoping@^6.23.0, babel-plugin-transform-es2015-block-scoping@^6.24.1: +babel-plugin-transform-es2015-block-scoping@^6.23.0: version "6.26.0" resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-block-scoping/-/babel-plugin-transform-es2015-block-scoping-6.26.0.tgz#d70f5299c1308d05c12f463813b0a09e73b1895f" dependencies: @@ -703,7 +730,7 @@ babel-plugin-transform-es2015-block-scoping@^6.23.0, babel-plugin-transform-es20 babel-types "^6.26.0" lodash "^4.17.4" -babel-plugin-transform-es2015-classes@^6.23.0, babel-plugin-transform-es2015-classes@^6.24.1: +babel-plugin-transform-es2015-classes@^6.23.0: version "6.24.1" resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-classes/-/babel-plugin-transform-es2015-classes-6.24.1.tgz#5a4c58a50c9c9461e564b4b2a3bfabc97a2584db" dependencies: @@ -717,33 +744,33 @@ babel-plugin-transform-es2015-classes@^6.23.0, babel-plugin-transform-es2015-cla babel-traverse "^6.24.1" babel-types "^6.24.1" -babel-plugin-transform-es2015-computed-properties@^6.22.0, babel-plugin-transform-es2015-computed-properties@^6.24.1: +babel-plugin-transform-es2015-computed-properties@^6.22.0: version "6.24.1" resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-computed-properties/-/babel-plugin-transform-es2015-computed-properties-6.24.1.tgz#6fe2a8d16895d5634f4cd999b6d3480a308159b3" dependencies: babel-runtime "^6.22.0" babel-template "^6.24.1" -babel-plugin-transform-es2015-destructuring@^6.19.0, babel-plugin-transform-es2015-destructuring@^6.22.0, babel-plugin-transform-es2015-destructuring@^6.23.0: +babel-plugin-transform-es2015-destructuring@^6.19.0, babel-plugin-transform-es2015-destructuring@^6.23.0: version "6.23.0" resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-destructuring/-/babel-plugin-transform-es2015-destructuring-6.23.0.tgz#997bb1f1ab967f682d2b0876fe358d60e765c56d" dependencies: babel-runtime "^6.22.0" -babel-plugin-transform-es2015-duplicate-keys@^6.22.0, babel-plugin-transform-es2015-duplicate-keys@^6.24.1: +babel-plugin-transform-es2015-duplicate-keys@^6.22.0: version "6.24.1" resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-duplicate-keys/-/babel-plugin-transform-es2015-duplicate-keys-6.24.1.tgz#73eb3d310ca969e3ef9ec91c53741a6f1576423e" dependencies: babel-runtime "^6.22.0" babel-types "^6.24.1" -babel-plugin-transform-es2015-for-of@^6.22.0, babel-plugin-transform-es2015-for-of@^6.23.0: +babel-plugin-transform-es2015-for-of@^6.23.0: version "6.23.0" resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-for-of/-/babel-plugin-transform-es2015-for-of-6.23.0.tgz#f47c95b2b613df1d3ecc2fdb7573623c75248691" dependencies: babel-runtime "^6.22.0" -babel-plugin-transform-es2015-function-name@^6.22.0, babel-plugin-transform-es2015-function-name@^6.24.1, babel-plugin-transform-es2015-function-name@^6.9.0: +babel-plugin-transform-es2015-function-name@^6.22.0, babel-plugin-transform-es2015-function-name@^6.9.0: version "6.24.1" resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-function-name/-/babel-plugin-transform-es2015-function-name-6.24.1.tgz#834c89853bc36b1af0f3a4c5dbaa94fd8eacaa8b" dependencies: @@ -774,7 +801,7 @@ babel-plugin-transform-es2015-modules-commonjs@^6.18.0, babel-plugin-transform-e babel-template "^6.26.0" babel-types "^6.26.0" -babel-plugin-transform-es2015-modules-systemjs@^6.23.0, babel-plugin-transform-es2015-modules-systemjs@^6.24.1: +babel-plugin-transform-es2015-modules-systemjs@^6.23.0: version "6.24.1" resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-modules-systemjs/-/babel-plugin-transform-es2015-modules-systemjs-6.24.1.tgz#ff89a142b9119a906195f5f106ecf305d9407d23" dependencies: @@ -782,7 +809,7 @@ babel-plugin-transform-es2015-modules-systemjs@^6.23.0, babel-plugin-transform-e babel-runtime "^6.22.0" babel-template "^6.24.1" -babel-plugin-transform-es2015-modules-umd@^6.23.0, babel-plugin-transform-es2015-modules-umd@^6.24.1: +babel-plugin-transform-es2015-modules-umd@^6.23.0: version "6.24.1" resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-modules-umd/-/babel-plugin-transform-es2015-modules-umd-6.24.1.tgz#ac997e6285cd18ed6176adb607d602344ad38468" dependencies: @@ -790,14 +817,14 @@ babel-plugin-transform-es2015-modules-umd@^6.23.0, babel-plugin-transform-es2015 babel-runtime "^6.22.0" babel-template "^6.24.1" -babel-plugin-transform-es2015-object-super@^6.22.0, babel-plugin-transform-es2015-object-super@^6.24.1: +babel-plugin-transform-es2015-object-super@^6.22.0: version "6.24.1" resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-object-super/-/babel-plugin-transform-es2015-object-super-6.24.1.tgz#24cef69ae21cb83a7f8603dad021f572eb278f8d" dependencies: babel-helper-replace-supers "^6.24.1" babel-runtime "^6.22.0" -babel-plugin-transform-es2015-parameters@^6.21.0, babel-plugin-transform-es2015-parameters@^6.23.0, babel-plugin-transform-es2015-parameters@^6.24.1: +babel-plugin-transform-es2015-parameters@^6.21.0, babel-plugin-transform-es2015-parameters@^6.23.0: version "6.24.1" resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-parameters/-/babel-plugin-transform-es2015-parameters-6.24.1.tgz#57ac351ab49caf14a97cd13b09f66fdf0a625f2b" dependencies: @@ -808,7 +835,7 @@ babel-plugin-transform-es2015-parameters@^6.21.0, babel-plugin-transform-es2015- babel-traverse "^6.24.1" babel-types "^6.24.1" -babel-plugin-transform-es2015-shorthand-properties@^6.22.0, babel-plugin-transform-es2015-shorthand-properties@^6.24.1: +babel-plugin-transform-es2015-shorthand-properties@^6.22.0: version "6.24.1" resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-shorthand-properties/-/babel-plugin-transform-es2015-shorthand-properties-6.24.1.tgz#24f875d6721c87661bbd99a4622e51f14de38aa0" dependencies: @@ -821,7 +848,7 @@ babel-plugin-transform-es2015-spread@^6.22.0, babel-plugin-transform-es2015-spre dependencies: babel-runtime "^6.22.0" -babel-plugin-transform-es2015-sticky-regex@^6.22.0, babel-plugin-transform-es2015-sticky-regex@^6.24.1, babel-plugin-transform-es2015-sticky-regex@^6.8.0: +babel-plugin-transform-es2015-sticky-regex@^6.22.0, babel-plugin-transform-es2015-sticky-regex@^6.8.0: version "6.24.1" resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-sticky-regex/-/babel-plugin-transform-es2015-sticky-regex-6.24.1.tgz#00c1cdb1aca71112cdf0cf6126c2ed6b457ccdbc" dependencies: @@ -835,13 +862,13 @@ babel-plugin-transform-es2015-template-literals@^6.22.0: dependencies: babel-runtime "^6.22.0" -babel-plugin-transform-es2015-typeof-symbol@^6.22.0, babel-plugin-transform-es2015-typeof-symbol@^6.23.0: +babel-plugin-transform-es2015-typeof-symbol@^6.23.0: version "6.23.0" resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-typeof-symbol/-/babel-plugin-transform-es2015-typeof-symbol-6.23.0.tgz#dec09f1cddff94b52ac73d505c84df59dcceb372" dependencies: babel-runtime "^6.22.0" -babel-plugin-transform-es2015-unicode-regex@^6.11.0, babel-plugin-transform-es2015-unicode-regex@^6.22.0, babel-plugin-transform-es2015-unicode-regex@^6.24.1: +babel-plugin-transform-es2015-unicode-regex@^6.11.0, babel-plugin-transform-es2015-unicode-regex@^6.22.0: version "6.24.1" resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-unicode-regex/-/babel-plugin-transform-es2015-unicode-regex-6.24.1.tgz#d38b12f42ea7323f729387f18a7c5ae1faeb35e9" dependencies: @@ -864,7 +891,7 @@ babel-plugin-transform-object-rest-spread@^6.26.0: babel-plugin-syntax-object-rest-spread "^6.8.0" babel-runtime "^6.26.0" -babel-plugin-transform-regenerator@^6.22.0, babel-plugin-transform-regenerator@^6.24.1: +babel-plugin-transform-regenerator@^6.22.0: version "6.26.0" resolved "https://registry.yarnpkg.com/babel-plugin-transform-regenerator/-/babel-plugin-transform-regenerator-6.26.0.tgz#e0703696fbde27f0a3efcacf8b4dca2f7b3a8f2f" dependencies: @@ -932,35 +959,6 @@ babel-preset-env@^1.6.0: invariant "^2.2.2" semver "^5.3.0" -babel-preset-es2015@^6.24.1: - version "6.24.1" - resolved "https://registry.yarnpkg.com/babel-preset-es2015/-/babel-preset-es2015-6.24.1.tgz#d44050d6bc2c9feea702aaf38d727a0210538939" - dependencies: - babel-plugin-check-es2015-constants "^6.22.0" - babel-plugin-transform-es2015-arrow-functions "^6.22.0" - babel-plugin-transform-es2015-block-scoped-functions "^6.22.0" - babel-plugin-transform-es2015-block-scoping "^6.24.1" - babel-plugin-transform-es2015-classes "^6.24.1" - babel-plugin-transform-es2015-computed-properties "^6.24.1" - babel-plugin-transform-es2015-destructuring "^6.22.0" - babel-plugin-transform-es2015-duplicate-keys "^6.24.1" - babel-plugin-transform-es2015-for-of "^6.22.0" - babel-plugin-transform-es2015-function-name "^6.24.1" - babel-plugin-transform-es2015-literals "^6.22.0" - babel-plugin-transform-es2015-modules-amd "^6.24.1" - babel-plugin-transform-es2015-modules-commonjs "^6.24.1" - babel-plugin-transform-es2015-modules-systemjs "^6.24.1" - babel-plugin-transform-es2015-modules-umd "^6.24.1" - babel-plugin-transform-es2015-object-super "^6.24.1" - babel-plugin-transform-es2015-parameters "^6.24.1" - babel-plugin-transform-es2015-shorthand-properties "^6.24.1" - babel-plugin-transform-es2015-spread "^6.22.0" - babel-plugin-transform-es2015-sticky-regex "^6.24.1" - babel-plugin-transform-es2015-template-literals "^6.22.0" - babel-plugin-transform-es2015-typeof-symbol "^6.22.0" - babel-plugin-transform-es2015-unicode-regex "^6.24.1" - babel-plugin-transform-regenerator "^6.24.1" - babel-preset-vue-app@^1.3.0: version "1.3.0" resolved "https://registry.yarnpkg.com/babel-preset-vue-app/-/babel-preset-vue-app-1.3.0.tgz#4b31f690a353c8735963e06927a072a0bb82126f" @@ -999,6 +997,15 @@ babel-runtime@^6.18.0, babel-runtime@^6.20.0, babel-runtime@^6.22.0, babel-runti core-js "^2.4.0" regenerator-runtime "^0.11.0" +babel-template@7.0.0-beta.0: + version "7.0.0-beta.0" + resolved "https://registry.yarnpkg.com/babel-template/-/babel-template-7.0.0-beta.0.tgz#85083cf9e4395d5e48bf5154d7a8d6991cafecfb" + dependencies: + babel-traverse "7.0.0-beta.0" + babel-types "7.0.0-beta.0" + babylon "7.0.0-beta.22" + lodash "^4.2.0" + babel-template@^6.16.0, babel-template@^6.24.1, babel-template@^6.26.0: version "6.26.0" resolved "https://registry.yarnpkg.com/babel-template/-/babel-template-6.26.0.tgz#de03e2d16396b069f46dd9fff8521fb1a0e35e02" @@ -1009,7 +1016,21 @@ babel-template@^6.16.0, babel-template@^6.24.1, babel-template@^6.26.0: babylon "^6.18.0" lodash "^4.17.4" -babel-traverse@^6.18.0, babel-traverse@^6.23.1, babel-traverse@^6.24.1, babel-traverse@^6.26.0: +babel-traverse@7.0.0-beta.0: + version "7.0.0-beta.0" + resolved "https://registry.yarnpkg.com/babel-traverse/-/babel-traverse-7.0.0-beta.0.tgz#da14be9b762f62a2f060db464eaafdd8cd072a41" + dependencies: + babel-code-frame "7.0.0-beta.0" + babel-helper-function-name "7.0.0-beta.0" + babel-messages "7.0.0-beta.0" + babel-types "7.0.0-beta.0" + babylon "7.0.0-beta.22" + debug "^3.0.1" + globals "^10.0.0" + invariant "^2.2.0" + lodash "^4.2.0" + +babel-traverse@^6.18.0, babel-traverse@^6.24.1, babel-traverse@^6.26.0: version "6.26.0" resolved "https://registry.yarnpkg.com/babel-traverse/-/babel-traverse-6.26.0.tgz#46a9cbd7edcc62c8e5c064e2d2d8d0f4035766ee" dependencies: @@ -1023,7 +1044,15 @@ babel-traverse@^6.18.0, babel-traverse@^6.23.1, babel-traverse@^6.24.1, babel-tr invariant "^2.2.2" lodash "^4.17.4" -babel-types@^6.18.0, babel-types@^6.19.0, babel-types@^6.23.0, babel-types@^6.24.1, babel-types@^6.26.0: +babel-types@7.0.0-beta.0: + version "7.0.0-beta.0" + resolved "https://registry.yarnpkg.com/babel-types/-/babel-types-7.0.0-beta.0.tgz#eb8b6e556470e6dcc4aef982d79ad229469b5169" + dependencies: + esutils "^2.0.2" + lodash "^4.2.0" + to-fast-properties "^2.0.0" + +babel-types@^6.18.0, babel-types@^6.19.0, babel-types@^6.24.1, babel-types@^6.26.0: version "6.26.0" resolved "https://registry.yarnpkg.com/babel-types/-/babel-types-6.26.0.tgz#a3b073f94ab49eb6fa55cd65227a334380632497" dependencies: @@ -1032,7 +1061,11 @@ babel-types@^6.18.0, babel-types@^6.19.0, babel-types@^6.23.0, babel-types@^6.24 lodash "^4.17.4" to-fast-properties "^1.0.3" -babylon@^6.1.0, babylon@^6.17.0, babylon@^6.17.4, babylon@^6.18.0: +babylon@7.0.0-beta.22: + version "7.0.0-beta.22" + resolved "https://registry.yarnpkg.com/babylon/-/babylon-7.0.0-beta.22.tgz#74f0ad82ed7c7c3cfeab74cf684f815104161b65" + +babylon@^6.1.0, babylon@^6.17.4, babylon@^6.18.0: version "6.18.0" resolved "https://registry.yarnpkg.com/babylon/-/babylon-6.18.0.tgz#af2f3b88fa6f5c1e4c634d1a0f8eac4f55b395e3" @@ -1344,7 +1377,7 @@ chalk@^0.4.0: has-color "~0.1.0" strip-ansi "~0.1.0" -chalk@^2.0.1, chalk@^2.1.0: +chalk@^2.0.0, chalk@^2.0.1, chalk@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.1.0.tgz#ac5becf14fa21b99c6c92ca7a7d7cfd5b17e743e" dependencies: @@ -1388,6 +1421,12 @@ clap@^1.0.9: dependencies: chalk "^1.1.3" +clap@^1.1.3: + version "1.2.3" + resolved "https://registry.yarnpkg.com/clap/-/clap-1.2.3.tgz#4f36745b32008492557f46412d66d50cb99bce51" + dependencies: + chalk "^1.1.3" + clean-css@4.1.x: version "4.1.7" resolved "https://registry.yarnpkg.com/clean-css/-/clean-css-4.1.7.tgz#b9aea4f85679889cf3eae8b40349ec4ebdfdd032" @@ -2902,6 +2941,10 @@ glob@^7.0.3, glob@^7.0.5, glob@^7.0.6, glob@^7.1.2: once "^1.3.0" path-is-absolute "^1.0.0" +globals@^10.0.0: + version "10.1.0" + resolved "https://registry.yarnpkg.com/globals/-/globals-10.1.0.tgz#4425a1881be0d336b4a823a82a7be725d5dd987c" + globals@^9.17.0, globals@^9.18.0: version "9.18.0" resolved "https://registry.yarnpkg.com/globals/-/globals-9.18.0.tgz#aa3896b3e69b487f17e31ed2143d69a8e30c2d8a" @@ -3268,7 +3311,7 @@ interpret@^1.0.0: version "1.0.3" resolved "https://registry.yarnpkg.com/interpret/-/interpret-1.0.3.tgz#cbc35c62eeee73f19ab7b10a801511401afc0f90" -invariant@^2.2.2: +invariant@^2.2.0, invariant@^2.2.2: version "2.2.2" resolved "https://registry.yarnpkg.com/invariant/-/invariant-2.2.2.tgz#9e1f56ac0acdb6bf303306f338be3b204ae60360" dependencies: @@ -3852,7 +3895,7 @@ lodash.uniq@^4.5.0: version "4.5.0" resolved "https://registry.yarnpkg.com/lodash.uniq/-/lodash.uniq-4.5.0.tgz#d0225373aeb652adc1bc82e4945339a842754773" -lodash@^4.0.0, lodash@^4.11.1, lodash@^4.13.1, lodash@^4.14.0, lodash@^4.17.3, lodash@^4.17.4, lodash@^4.3.0: +lodash@^4.0.0, lodash@^4.11.1, lodash@^4.13.1, lodash@^4.14.0, lodash@^4.17.3, lodash@^4.17.4, lodash@^4.2.0, lodash@^4.3.0: version "4.17.4" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.4.tgz#78203a4d1c328ae1d86dca6460e369b57f4055ae" @@ -3898,12 +3941,6 @@ macaddress@^0.2.8: version "0.2.8" resolved "https://registry.yarnpkg.com/macaddress/-/macaddress-0.2.8.tgz#5904dc537c39ec6dbefeae902327135fa8511f12" -magic-string@^0.15.2: - version "0.15.2" - resolved "https://registry.yarnpkg.com/magic-string/-/magic-string-0.15.2.tgz#0681d7388741bbc3addaa65060992624c6c09e9c" - dependencies: - vlq "^0.2.1" - magic-string@^0.22.4: version "0.22.4" resolved "https://registry.yarnpkg.com/magic-string/-/magic-string-0.22.4.tgz#31039b4e40366395618c1d6cf8193c53917475ff" @@ -4348,6 +4385,13 @@ onetime@^2.0.0: dependencies: mimic-fn "^1.0.0" +open-in-editor@^2.2.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/open-in-editor/-/open-in-editor-2.2.0.tgz#c5b21aa76f6acd4cbbd3c3b2e77dccb4b75a2020" + dependencies: + clap "^1.1.3" + os-homedir "~1.0.2" + opencollective@^1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/opencollective/-/opencollective-1.0.3.tgz#aee6372bc28144583690c3ca8daecfc120dd0ef1" @@ -4396,7 +4440,7 @@ os-browserify@^0.2.0: version "0.2.1" resolved "https://registry.yarnpkg.com/os-browserify/-/os-browserify-0.2.1.tgz#63fc4ccee5d2d7763d26bbf8601078e6c2e0044f" -os-homedir@^1.0.0, os-homedir@^1.0.1: +os-homedir@^1.0.0, os-homedir@^1.0.1, os-homedir@~1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/os-homedir/-/os-homedir-1.0.2.tgz#ffbc4988336e0e833de0c168c7ef152121aa7fb3" @@ -4879,11 +4923,10 @@ postcss-image-set-polyfill@^0.3.5: postcss "^6.0.1" postcss-media-query-parser "^0.2.3" -postcss-import@^10.0.0: - version "10.0.0" - resolved "https://registry.yarnpkg.com/postcss-import/-/postcss-import-10.0.0.tgz#4c85c97b099136cc5ea0240dc1dfdbfde4e2ebbe" +postcss-import@^11.0.0: + version "11.0.0" + resolved "https://registry.yarnpkg.com/postcss-import/-/postcss-import-11.0.0.tgz#a962e2df82d3bc5a6da6a386841747204f41ef5b" dependencies: - object-assign "^4.0.1" postcss "^6.0.1" postcss-value-parser "^3.2.3" read-cache "^1.0.0" @@ -5682,13 +5725,13 @@ rollup-plugin-node-resolve@^3.0.0: is-module "^1.0.0" resolve "^1.1.6" -rollup-plugin-replace@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/rollup-plugin-replace/-/rollup-plugin-replace-1.1.1.tgz#396315ded050a6ce43b9518a886a3f60efb1ea33" +rollup-plugin-replace@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/rollup-plugin-replace/-/rollup-plugin-replace-2.0.0.tgz#19074089c8ed57184b8cc64e967a03d095119277" dependencies: - magic-string "^0.15.2" + magic-string "^0.22.4" minimatch "^3.0.2" - rollup-pluginutils "^1.5.0" + rollup-pluginutils "^2.0.1" rollup-pluginutils@^1.5.0: version "1.5.2" @@ -5712,9 +5755,9 @@ rollup-watch@^4.3.1: require-relative "0.8.7" rollup-pluginutils "^2.0.1" -rollup@^0.49.2: - version "0.49.2" - resolved "https://registry.yarnpkg.com/rollup/-/rollup-0.49.2.tgz#a18f07595cde3b11875c9fece45b25ad3b220d1a" +rollup@^0.50.0: + version "0.50.0" + resolved "https://registry.yarnpkg.com/rollup/-/rollup-0.50.0.tgz#4c158f4e780e6cb33ff0dbfc184a52cc58cd5f3b" run-async@^2.2.0: version "2.3.0" @@ -6237,6 +6280,10 @@ to-fast-properties@^1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/to-fast-properties/-/to-fast-properties-1.0.3.tgz#b83571fa4d8c25b82e231b06e3a3055de4ca1a47" +to-fast-properties@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/to-fast-properties/-/to-fast-properties-2.0.0.tgz#dc5e698cbd079265bc73e0377681a4e4e83f616e" + toposort@^1.0.0: version "1.0.3" resolved "https://registry.yarnpkg.com/toposort/-/toposort-1.0.3.tgz#f02cd8a74bd8be2fc0e98611c3bacb95a171869c" From 604dfc95de348efb8d5f939f96ce6b533cc27d98 Mon Sep 17 00:00:00 2001 From: Sebastien Chopin Date: Fri, 22 Sep 2017 15:21:39 +0200 Subject: [PATCH 080/316] Link to doc --- examples/spa/nuxt.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/spa/nuxt.config.js b/examples/spa/nuxt.config.js index 7040b5d3dc..7108b6c479 100644 --- a/examples/spa/nuxt.config.js +++ b/examples/spa/nuxt.config.js @@ -27,7 +27,7 @@ module.exports = { */ loadingIndicator: { /* - ** See https://github.com/nuxt/nuxt.js/tree/dev/lib/app/views/loading for available loading indicators + ** See https://nuxtjs.org/api/configuration-loading-indicator for available loading indicators ** You can add a custom indicator by giving a path */ // name: 'folding-cube', From 9e4f864e4d25af2e9668767bb297182656e19cba Mon Sep 17 00:00:00 2001 From: Sebastien Chopin Date: Fri, 22 Sep 2017 16:05:59 +0200 Subject: [PATCH 081/316] Fix issue #1629 --- lib/app/client.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/app/client.js b/lib/app/client.js index 4c43a21682..b4087f8129 100644 --- a/lib/app/client.js +++ b/lib/app/client.js @@ -562,10 +562,12 @@ async function mountApp(__app) { return } - render.call(_app, router.currentRoute, router.currentRoute, path => { + // First render on client-side + render.call(_app, router.currentRoute, router.currentRoute, (path) => { + // If not redirected if (!path) { normalizeComponents(router.currentRoute, router.currentRoute) - fixPrepatch.call(_app, router.currentRoute, router.currentRoute) + // Dont call fixPrepatch.call(_app, router.currentRoute, router.currentRoute) since it's first render mountApp() return } From 7d8392f03683044da26b5a5865e5239491c07c53 Mon Sep 17 00:00:00 2001 From: Wu Haotian Date: Sun, 24 Sep 2017 18:34:44 +0800 Subject: [PATCH 082/316] Upgrade Vue to 2.4.4 --- package.json | 6 +++--- start/package.json | 4 ++-- yarn.lock | 18 +++++++++--------- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/package.json b/package.json index 598d5389cd..e53f742c33 100644 --- a/package.json +++ b/package.json @@ -109,12 +109,12 @@ "source-map-support": "^0.4.17", "tappable": "^1.1.0", "url-loader": "^0.5.9", - "vue": "~2.4.2", + "vue": "~2.4.4", "vue-loader": "^13.0.4", "vue-meta": "^1.1.0", "vue-router": "^2.7.0", - "vue-server-renderer": "~2.4.2", - "vue-template-compiler": "~2.4.2", + "vue-server-renderer": "~2.4.4", + "vue-template-compiler": "~2.4.4", "vuex": "^2.4.0", "webpack": "^3.5.5", "webpack-bundle-analyzer": "^2.9.0", diff --git a/start/package.json b/start/package.json index fc67f8fced..ce427c9554 100644 --- a/start/package.json +++ b/start/package.json @@ -62,11 +62,11 @@ "serve-static": "^1.12.4", "compression": "^1.7.0", "fs-extra": "^4.0.1", - "vue-server-renderer": "~2.4.2", + "vue-server-renderer": "~2.4.4", "@nuxtjs/youch": "3.1.0", "source-map": "^0.5.7", "connect": "^3.6.3", - "vue": "~2.4.2", + "vue": "~2.4.4", "vue-meta": "^1.1.0", "lru-cache": "^4.1.1", "server-destroy": "^1.0.1", diff --git a/yarn.lock b/yarn.lock index 7a1c08fe84..03abc1fe20 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6570,9 +6570,9 @@ vue-router@^2.7.0: version "2.7.0" resolved "https://registry.yarnpkg.com/vue-router/-/vue-router-2.7.0.tgz#16d424493aa51c3c8cce8b7c7210ea4c3a89aff1" -vue-server-renderer@~2.4.2: - version "2.4.2" - resolved "https://registry.yarnpkg.com/vue-server-renderer/-/vue-server-renderer-2.4.2.tgz#0ba0f984181ea1c455362b09bddf60bc0e0a03fa" +vue-server-renderer@~2.4.4: + version "2.4.4" + resolved "http://registry.npm.taobao.org/vue-server-renderer/download/vue-server-renderer-2.4.4.tgz#bd59cf4e42dfaf2c9e388af8837b5420dd51360d" dependencies: chalk "^1.1.3" hash-sum "^1.0.2" @@ -6590,9 +6590,9 @@ vue-style-loader@^3.0.0: hash-sum "^1.0.2" loader-utils "^1.0.2" -vue-template-compiler@~2.4.2: - version "2.4.2" - resolved "https://registry.yarnpkg.com/vue-template-compiler/-/vue-template-compiler-2.4.2.tgz#5a45d843f148b098f6c1d1e35ac20c4956d30ad1" +vue-template-compiler@~2.4.4: + version "2.4.4" + resolved "http://registry.npm.taobao.org/vue-template-compiler/download/vue-template-compiler-2.4.4.tgz#2cde3b704124985c27d50b5387c9691ba515fb57" dependencies: de-indent "^1.0.2" he "^1.1.0" @@ -6601,9 +6601,9 @@ vue-template-es2015-compiler@^1.5.3: version "1.5.3" resolved "https://registry.yarnpkg.com/vue-template-es2015-compiler/-/vue-template-es2015-compiler-1.5.3.tgz#22787de4e37ebd9339b74223bc467d1adee30545" -vue@~2.4.2: - version "2.4.2" - resolved "https://registry.yarnpkg.com/vue/-/vue-2.4.2.tgz#a9855261f191c978cc0dc1150531b8d08149b58c" +vue@~2.4.4: + version "2.4.4" + resolved "http://registry.npm.taobao.org/vue/download/vue-2.4.4.tgz#ea9550b96a71465fd2b8b17b61673b3561861789" vuex@^2.4.0: version "2.4.0" From ddfe0eb7f7246a9b59263119f205b6475f4994e8 Mon Sep 17 00:00:00 2001 From: Wu Haotian Date: Sun, 24 Sep 2017 18:39:38 +0800 Subject: [PATCH 083/316] use yarnpkg registry --- .npmrc | 1 + yarn.lock | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) create mode 100644 .npmrc diff --git a/.npmrc b/.npmrc new file mode 100644 index 0000000000..9841c0bd3f --- /dev/null +++ b/.npmrc @@ -0,0 +1 @@ +registry=https://registry.yarnpkg.com diff --git a/yarn.lock b/yarn.lock index 03abc1fe20..fb9a89ee33 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6572,7 +6572,7 @@ vue-router@^2.7.0: vue-server-renderer@~2.4.4: version "2.4.4" - resolved "http://registry.npm.taobao.org/vue-server-renderer/download/vue-server-renderer-2.4.4.tgz#bd59cf4e42dfaf2c9e388af8837b5420dd51360d" + resolved "https://registry.yarnpkg.com/vue-server-renderer/-/vue-server-renderer-2.4.4.tgz#bd59cf4e42dfaf2c9e388af8837b5420dd51360d" dependencies: chalk "^1.1.3" hash-sum "^1.0.2" @@ -6592,7 +6592,7 @@ vue-style-loader@^3.0.0: vue-template-compiler@~2.4.4: version "2.4.4" - resolved "http://registry.npm.taobao.org/vue-template-compiler/download/vue-template-compiler-2.4.4.tgz#2cde3b704124985c27d50b5387c9691ba515fb57" + resolved "https://registry.yarnpkg.com/vue-template-compiler/-/vue-template-compiler-2.4.4.tgz#2cde3b704124985c27d50b5387c9691ba515fb57" dependencies: de-indent "^1.0.2" he "^1.1.0" @@ -6603,7 +6603,7 @@ vue-template-es2015-compiler@^1.5.3: vue@~2.4.4: version "2.4.4" - resolved "http://registry.npm.taobao.org/vue/download/vue-2.4.4.tgz#ea9550b96a71465fd2b8b17b61673b3561861789" + resolved "https://registry.yarnpkg.com/vue/-/vue-2.4.4.tgz#ea9550b96a71465fd2b8b17b61673b3561861789" vuex@^2.4.0: version "2.4.0" From 3d3e8a298bcd49763438319b56541076abbe86db Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Fri, 6 Oct 2017 22:21:43 +0330 Subject: [PATCH 084/316] chore(package): upgrade dependencies --- package.json | 72 +-- start/package.json | 20 +- yarn.lock | 1140 ++++++++++++++++++++++++-------------------- 3 files changed, 673 insertions(+), 559 deletions(-) diff --git a/package.json b/package.json index e53f742c33..d1e3fb782b 100644 --- a/package.json +++ b/package.json @@ -66,27 +66,27 @@ "dependencies": { "@nuxtjs/youch": "3.1.0", "ansi-html": "^0.0.7", - "autoprefixer": "^7.1.3", + "autoprefixer": "^7.1.4", "babel-core": "^6.26.0", "babel-loader": "^7.1.2", - "babel-preset-vue-app": "^1.3.0", + "babel-preset-vue-app": "^1.3.1", "chalk": "^2.1.0", "chokidar": "^1.7.0", "clone": "^2.1.1", - "compression": "^1.7.0", - "connect": "^3.6.3", + "compression": "^1.7.1", + "connect": "^3.6.5", "css-loader": "^0.28.7", - "debug": "^3.0.1", + "debug": "^3.1.0", "es6-promise": "^4.1.1", - "etag": "^1.8.0", - "extract-text-webpack-plugin": "^3.0.0", - "file-loader": "^0.11.2", - "fresh": "^0.5.0", + "etag": "^1.8.1", + "extract-text-webpack-plugin": "^3.0.1", + "file-loader": "^1.1.5", + "fresh": "^0.5.2", "friendly-errors-webpack-plugin": "^1.6.1", - "fs-extra": "^4.0.1", + "fs-extra": "^4.0.2", "glob": "^7.1.2", "hash-sum": "^1.0.2", - "html-minifier": "^3.5.3", + "html-minifier": "^3.5.5", "html-webpack-plugin": "^2.30.1", "lodash": "^4.17.4", "lru-cache": "^4.1.1", @@ -95,7 +95,7 @@ "open-in-editor": "^2.2.0", "opencollective": "^1.0.3", "pify": "^3.0.0", - "postcss": "^6.0.10", + "postcss": "^6.0.13", "postcss-cssnext": "^3.0.2", "postcss-import": "^11.0.0", "postcss-loader": "^2.0.6", @@ -103,58 +103,58 @@ "pretty-error": "^2.1.1", "progress-bar-webpack-plugin": "^1.10.0", "serialize-javascript": "^1.4.0", - "serve-static": "^1.12.4", + "serve-static": "^1.13.1", "server-destroy": "^1.0.1", - "source-map": "^0.5.7", - "source-map-support": "^0.4.17", + "source-map": "^0.6.1", + "source-map-support": "^0.5.0", "tappable": "^1.1.0", - "url-loader": "^0.5.9", + "url-loader": "^0.6.2", "vue": "~2.4.4", - "vue-loader": "^13.0.4", - "vue-meta": "^1.1.0", + "vue-loader": "^13.0.5", + "vue-meta": "^1.2.0", "vue-router": "^2.7.0", "vue-server-renderer": "~2.4.4", "vue-template-compiler": "~2.4.4", - "vuex": "^2.4.0", - "webpack": "^3.5.5", + "vuex": "^2.4.1", + "webpack": "^3.6.0", "webpack-bundle-analyzer": "^2.9.0", "webpack-dev-middleware": "^1.12.0", - "webpack-hot-middleware": "^2.18.2", + "webpack-hot-middleware": "^2.19.1", "webpack-node-externals": "^1.6.0" }, "devDependencies": { "ava": "^0.22.0", - "babel-eslint": "^8.0.0", + "babel-eslint": "^8.0.1", "babel-plugin-array-includes": "^2.0.3", "babel-plugin-external-helpers": "^6.22.0", - "babel-plugin-istanbul": "^4.1.4", + "babel-plugin-istanbul": "^4.1.5", "codecov": "^2.3.0", - "copy-webpack-plugin": "^4.0.1", + "copy-webpack-plugin": "^4.1.1", "cross-env": "^5.0.5", - "eslint": "^4.6.1", + "eslint": "^4.8.0", "eslint-config-standard": "^10.2.1", - "eslint-plugin-html": "^3.2.1", + "eslint-plugin-html": "^3.2.2", "eslint-plugin-import": "^2.7.0", - "eslint-plugin-node": "^5.1.1", + "eslint-plugin-node": "^5.2.0", "eslint-plugin-promise": "^3.5.0", "eslint-plugin-standard": "^3.0.1", - "express": "^4.15.4", - "finalhandler": "^1.0.4", - "jsdom": "^11.2.0", + "express": "^4.16.1", + "finalhandler": "^1.1.0", + "jsdom": "^11.3.0", "json-loader": "^0.5.7", - "nyc": "^11.1.0", - "request": "^2.81.0", - "request-promise-native": "^1.0.4", - "rimraf": "^2.6.1", + "nyc": "^11.2.1", + "request": "^2.83.0", + "request-promise-native": "^1.0.5", + "rimraf": "^2.6.2", "rollup": "^0.50.0", "rollup-plugin-alias": "^1.3.1", "rollup-plugin-babel": "^3.0.2", - "rollup-plugin-commonjs": "^8.2.0", + "rollup-plugin-commonjs": "^8.2.1", "rollup-plugin-node-resolve": "^3.0.0", "rollup-plugin-replace": "^2.0.0", "rollup-watch": "^4.3.1", "std-mocks": "^1.0.1", - "uglify-js": "^3.0.28" + "uglify-js": "^3.1.3" }, "collective": { "type": "opencollective", diff --git a/start/package.json b/start/package.json index ce427c9554..49f2857e24 100644 --- a/start/package.json +++ b/start/package.json @@ -46,28 +46,28 @@ "npm": ">=3.10.0" }, "dependencies": { - "source-map-support": "^0.4.17", + "source-map-support": "^0.5.0", "pretty-error": "^2.1.1", "minimist": "^1.2.0", "lodash": "^4.17.4", "hash-sum": "^1.0.2", "tappable": "^1.1.0", - "debug": "^3.0.1", + "debug": "^3.1.0", "chalk": "^2.1.0", "ansi-html": "^0.0.7", "serialize-javascript": "^1.4.0", - "etag": "^1.8.0", - "fresh": "^0.5.0", + "etag": "^1.8.1", + "fresh": "^0.5.2", "pify": "^3.0.0", - "serve-static": "^1.12.4", - "compression": "^1.7.0", - "fs-extra": "^4.0.1", + "serve-static": "^1.13.1", + "compression": "^1.7.1", + "fs-extra": "^4.0.2", "vue-server-renderer": "~2.4.4", "@nuxtjs/youch": "3.1.0", - "source-map": "^0.5.7", - "connect": "^3.6.3", + "source-map": "^0.6.1", + "connect": "^3.6.5", "vue": "~2.4.4", - "vue-meta": "^1.1.0", + "vue-meta": "^1.2.0", "lru-cache": "^4.1.1", "server-destroy": "^1.0.1", "open-in-editor": "^2.2.0" diff --git a/yarn.lock b/yarn.lock index fb9a89ee33..2fc4e425be 100644 --- a/yarn.lock +++ b/yarn.lock @@ -53,18 +53,18 @@ stack-trace "0.0.10" "@types/node@^6.0.46": - version "6.0.88" - resolved "https://registry.yarnpkg.com/@types/node/-/node-6.0.88.tgz#f618f11a944f6a18d92b5c472028728a3e3d4b66" + version "6.0.89" + resolved "https://registry.yarnpkg.com/@types/node/-/node-6.0.89.tgz#154be0e6a823760cd6083aa8c48f952e2e63e0b0" abab@^1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/abab/-/abab-1.0.3.tgz#b81de5f7274ec4e756d797cd834f303642724e5d" + version "1.0.4" + resolved "https://registry.yarnpkg.com/abab/-/abab-1.0.4.tgz#5faad9c2c07f60dd76770f71cf025b62a63cfd4e" abbrev@1: - version "1.1.0" - resolved "https://registry.yarnpkg.com/abbrev/-/abbrev-1.1.0.tgz#d0554c2256636e2f56e7c2e5ad183f859428d81f" + version "1.1.1" + resolved "https://registry.yarnpkg.com/abbrev/-/abbrev-1.1.1.tgz#f8f2c887ad10bf67f634f005b6987fed3179aac8" -accepts@~1.3.3: +accepts@~1.3.4: version "1.3.4" resolved "https://registry.yarnpkg.com/accepts/-/accepts-1.3.4.tgz#86246758c7dd6d21a6474ff084a4740ec05eb21f" dependencies: @@ -77,11 +77,11 @@ acorn-dynamic-import@^2.0.0: dependencies: acorn "^4.0.3" -acorn-globals@^3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/acorn-globals/-/acorn-globals-3.1.0.tgz#fd8270f71fbb4996b004fa880ee5d46573a731bf" +acorn-globals@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/acorn-globals/-/acorn-globals-4.0.0.tgz#0d771eb8c5b8e244124af193d006e21bd7d309c6" dependencies: - acorn "^4.0.4" + acorn "^5.0.0" acorn-jsx@^3.0.0: version "3.0.1" @@ -93,32 +93,28 @@ acorn@^3.0.4: version "3.3.0" resolved "https://registry.yarnpkg.com/acorn/-/acorn-3.3.0.tgz#45e37fb39e8da3f25baee3ff5369e2bb5f22017a" -acorn@^4.0.3, acorn@^4.0.4: +acorn@^4.0.3: version "4.0.13" resolved "https://registry.yarnpkg.com/acorn/-/acorn-4.0.13.tgz#105495ae5361d697bd195c825192e1ad7f253787" -acorn@^5.0.0, acorn@^5.1.1: - version "5.1.1" - resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.1.1.tgz#53fe161111f912ab999ee887a90a0bc52822fd75" +acorn@^5.0.0, acorn@^5.1.1, acorn@^5.1.2: + version "5.1.2" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.1.2.tgz#911cb53e036807cf0fa778dc5d370fbd864246d7" -ajv-keywords@^1.0.0: - version "1.5.1" - resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-1.5.1.tgz#314dd0a4b3368fad3dfcdc54ede6171b886daf3c" - -ajv-keywords@^2.0.0: +ajv-keywords@^2.0.0, ajv-keywords@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-2.1.0.tgz#a296e17f7bfae7c1ce4f7e0de53d29cb32162df0" -ajv@^4.7.0, ajv@^4.9.1: +ajv@^4.9.1: version "4.11.8" resolved "https://registry.yarnpkg.com/ajv/-/ajv-4.11.8.tgz#82ffb02b29e662ae53bdc20af15947706739c536" dependencies: co "^4.6.0" json-stable-stringify "^1.0.1" -ajv@^5.0.0, ajv@^5.1.5, ajv@^5.2.0: - version "5.2.2" - resolved "https://registry.yarnpkg.com/ajv/-/ajv-5.2.2.tgz#47c68d69e86f5d953103b0074a9430dc63da5e39" +ajv@^5.0.0, ajv@^5.1.0, ajv@^5.1.5, ajv@^5.2.0, ajv@^5.2.3: + version "5.2.3" + resolved "https://registry.yarnpkg.com/ajv/-/ajv-5.2.3.tgz#c06f598778c44c6b161abafe3466b81ad1814ed2" dependencies: co "^4.6.0" fast-deep-equal "^1.0.0" @@ -155,6 +151,10 @@ ansi-escapes@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-2.0.0.tgz#5bae52be424878dd9783e8910e3fc2922e83c81b" +ansi-escapes@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-3.0.0.tgz#ec3e8b4e9f8064fc02c3ac9b65f1c275bda8ef92" + ansi-html@0.0.7, ansi-html@^0.0.7: version "0.0.7" resolved "https://registry.yarnpkg.com/ansi-html/-/ansi-html-0.0.7.tgz#813584021962a9e9e6fd039f940d12f56ca7859e" @@ -195,8 +195,8 @@ append-transform@^0.4.0: default-require-extensions "^1.0.0" aproba@^1.0.3: - version "1.1.2" - resolved "https://registry.yarnpkg.com/aproba/-/aproba-1.1.2.tgz#45c6629094de4e96f693ef7eab74ae079c240fc1" + version "1.2.0" + resolved "https://registry.yarnpkg.com/aproba/-/aproba-1.2.0.tgz#6802e6264efd18c790a1b0d517f0f2627bf2c94a" archy@^1.0.0: version "1.0.0" @@ -326,15 +326,15 @@ autoprefixer@^6.3.1: postcss "^5.2.16" postcss-value-parser "^3.2.3" -autoprefixer@^7.1.1, autoprefixer@^7.1.3: - version "7.1.3" - resolved "https://registry.yarnpkg.com/autoprefixer/-/autoprefixer-7.1.3.tgz#0e8d337976d6f13644db9f8813b4c42f3d1ccc34" +autoprefixer@^7.1.1, autoprefixer@^7.1.4: + version "7.1.4" + resolved "https://registry.yarnpkg.com/autoprefixer/-/autoprefixer-7.1.4.tgz#960847dbaa4016bc8e8e52ec891cbf8f1257a748" dependencies: browserslist "^2.4.0" - caniuse-lite "^1.0.30000718" + caniuse-lite "^1.0.30000726" normalize-range "^0.1.2" num2fraction "^1.2.2" - postcss "^6.0.10" + postcss "^6.0.11" postcss-value-parser "^3.2.3" ava-init@^0.2.0: @@ -436,7 +436,11 @@ aws-sign2@~0.6.0: version "0.6.0" resolved "https://registry.yarnpkg.com/aws-sign2/-/aws-sign2-0.6.0.tgz#14342dd38dbcc94d0e5b87d763cd63612c0e794f" -aws4@^1.2.1: +aws-sign2@~0.7.0: + version "0.7.0" + resolved "https://registry.yarnpkg.com/aws-sign2/-/aws-sign2-0.7.0.tgz#b46e890934a9591f2d2f6f86d7e6a9f1b3fe76a8" + +aws4@^1.2.1, aws4@^1.6.0: version "1.6.0" resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.6.0.tgz#83ef5ca860b2b32e4a0deedee8c771b9db57471e" @@ -480,9 +484,9 @@ babel-core@^6.17.0, babel-core@^6.26.0: slash "^1.0.0" source-map "^0.5.6" -babel-eslint@^8.0.0: - version "8.0.0" - resolved "https://registry.yarnpkg.com/babel-eslint/-/babel-eslint-8.0.0.tgz#ce06f385bdfb5b6d7e603f06222f891abd14c240" +babel-eslint@^8.0.1: + version "8.0.1" + resolved "https://registry.yarnpkg.com/babel-eslint/-/babel-eslint-8.0.1.tgz#5d718be7a328625d006022eb293ed3008cbd6346" dependencies: babel-code-frame "7.0.0-beta.0" babel-traverse "7.0.0-beta.0" @@ -668,14 +672,30 @@ babel-plugin-external-helpers@^6.22.0: dependencies: babel-runtime "^6.22.0" -babel-plugin-istanbul@^4.1.4: - version "4.1.4" - resolved "https://registry.yarnpkg.com/babel-plugin-istanbul/-/babel-plugin-istanbul-4.1.4.tgz#18dde84bf3ce329fddf3f4103fae921456d8e587" +babel-plugin-istanbul@^4.1.5: + version "4.1.5" + resolved "https://registry.yarnpkg.com/babel-plugin-istanbul/-/babel-plugin-istanbul-4.1.5.tgz#6760cdd977f411d3e175bb064f2bc327d99b2b6e" dependencies: find-up "^2.1.0" - istanbul-lib-instrument "^1.7.2" + istanbul-lib-instrument "^1.7.5" test-exclude "^4.1.1" +babel-plugin-jsx-event-modifiers@^2.0.2: + version "2.0.5" + resolved "https://registry.yarnpkg.com/babel-plugin-jsx-event-modifiers/-/babel-plugin-jsx-event-modifiers-2.0.5.tgz#93e6ebb5d7553bb08f9fedbf7a0bee3af09a0472" + +babel-plugin-jsx-v-model@^2.0.1: + version "2.0.3" + resolved "https://registry.yarnpkg.com/babel-plugin-jsx-v-model/-/babel-plugin-jsx-v-model-2.0.3.tgz#c396416b99cb1af782087315ae1d3e62e070f47d" + dependencies: + babel-plugin-syntax-jsx "^6.18.0" + html-tags "^2.0.0" + svg-tags "^1.0.0" + +babel-plugin-jsx-vue-functional@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/babel-plugin-jsx-vue-functional/-/babel-plugin-jsx-vue-functional-2.1.0.tgz#5630a0c86fe1904d28c30465e6bf1cf71235a239" + babel-plugin-syntax-async-functions@^6.8.0: version "6.13.0" resolved "https://registry.yarnpkg.com/babel-plugin-syntax-async-functions/-/babel-plugin-syntax-async-functions-6.13.0.tgz#cad9cad1191b5ad634bf30ae0872391e0647be95" @@ -910,7 +930,7 @@ babel-plugin-transform-strict-mode@^6.24.1: babel-runtime "^6.22.0" babel-types "^6.24.1" -babel-plugin-transform-vue-jsx@^3.1.2: +babel-plugin-transform-vue-jsx@^3.5.0: version "3.5.0" resolved "https://registry.yarnpkg.com/babel-plugin-transform-vue-jsx/-/babel-plugin-transform-vue-jsx-3.5.0.tgz#6b1ad29351ad753919403675f0bf8b2a43e17671" dependencies: @@ -959,24 +979,27 @@ babel-preset-env@^1.6.0: invariant "^2.2.2" semver "^5.3.0" -babel-preset-vue-app@^1.3.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/babel-preset-vue-app/-/babel-preset-vue-app-1.3.0.tgz#4b31f690a353c8735963e06927a072a0bb82126f" +babel-preset-vue-app@^1.3.1: + version "1.3.1" + resolved "https://registry.yarnpkg.com/babel-preset-vue-app/-/babel-preset-vue-app-1.3.1.tgz#5216b8446d1453de0dbd8849e50ebdc189f877ed" dependencies: babel-plugin-syntax-dynamic-import "^6.18.0" babel-plugin-transform-object-rest-spread "^6.26.0" babel-plugin-transform-runtime "^6.15.0" babel-preset-env "^1.6.0" - babel-preset-vue "^0.1.0" + babel-preset-vue "^1.2.1" babel-runtime "^6.20.0" -babel-preset-vue@^0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/babel-preset-vue/-/babel-preset-vue-0.1.0.tgz#adb84ceab3873bd72606fdd3f7047640f032301f" +babel-preset-vue@^1.2.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/babel-preset-vue/-/babel-preset-vue-1.2.1.tgz#b0de8977e0ce981fc6824cf0a537917a02a6fe87" dependencies: babel-helper-vue-jsx-merge-props "^2.0.2" + babel-plugin-jsx-event-modifiers "^2.0.2" + babel-plugin-jsx-v-model "^2.0.1" + babel-plugin-jsx-vue-functional "^2.1.0" babel-plugin-syntax-jsx "^6.18.0" - babel-plugin-transform-vue-jsx "^3.1.2" + babel-plugin-transform-vue-jsx "^3.5.0" babel-register@^6.26.0: version "6.26.0" @@ -1065,7 +1088,7 @@ babylon@7.0.0-beta.22: version "7.0.0-beta.22" resolved "https://registry.yarnpkg.com/babylon/-/babylon-7.0.0-beta.22.tgz#74f0ad82ed7c7c3cfeab74cf684f815104161b65" -babylon@^6.1.0, babylon@^6.17.4, babylon@^6.18.0: +babylon@^6.1.0, babylon@^6.18.0: version "6.18.0" resolved "https://registry.yarnpkg.com/babylon/-/babylon-6.18.0.tgz#af2f3b88fa6f5c1e4c634d1a0f8eac4f55b395e3" @@ -1092,8 +1115,8 @@ bcrypt-pbkdf@^1.0.0: tweetnacl "^0.14.3" big.js@^3.1.3: - version "3.1.3" - resolved "https://registry.yarnpkg.com/big.js/-/big.js-3.1.3.tgz#4cada2193652eb3ca9ec8e55c9015669c9806978" + version "3.2.0" + resolved "https://registry.yarnpkg.com/big.js/-/big.js-3.2.0.tgz#a5fc298b81b9e0dca2e458824784b65c52ba588e" binary-extensions@^1.0.0: version "1.10.0" @@ -1105,18 +1128,29 @@ block-stream@*: dependencies: inherits "~2.0.0" -bluebird@^2.10.2: - version "2.11.0" - resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-2.11.0.tgz#534b9033c022c9579c56ba3b3e5a5caafbb650e1" - -bluebird@^3.0.0, bluebird@^3.0.5, bluebird@^3.1.1, bluebird@^3.4.7: - version "3.5.0" - resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.5.0.tgz#791420d7f551eea2897453a8a77653f96606d67c" +bluebird@^3.0.0, bluebird@^3.1.1, bluebird@^3.4.7, bluebird@^3.5.1: + version "3.5.1" + resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.5.1.tgz#d9551f9de98f1fcda1e683d17ee91a0602ee2eb9" bn.js@^4.0.0, bn.js@^4.1.0, bn.js@^4.1.1, bn.js@^4.4.0: version "4.11.8" resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-4.11.8.tgz#2cde09eb5ee341f484746bb0309b3253b1b1442f" +body-parser@1.18.2: + version "1.18.2" + resolved "https://registry.yarnpkg.com/body-parser/-/body-parser-1.18.2.tgz#87678a19d84b47d859b83199bd59bce222b10454" + dependencies: + bytes "3.0.0" + content-type "~1.0.4" + debug "2.6.9" + depd "~1.1.1" + http-errors "~1.6.2" + iconv-lite "0.4.19" + on-finished "~2.3.0" + qs "6.5.1" + raw-body "2.3.2" + type-is "~1.6.15" + boolbase@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/boolbase/-/boolbase-1.0.0.tgz#68dff5fbe60c51eb37725ea9e3ed310dcc1e776e" @@ -1127,6 +1161,18 @@ boom@2.x.x: dependencies: hoek "2.x.x" +boom@4.x.x: + version "4.3.1" + resolved "https://registry.yarnpkg.com/boom/-/boom-4.3.1.tgz#4f8a3005cb4a7e3889f749030fd25b96e01d2e31" + dependencies: + hoek "4.x.x" + +boom@5.x.x: + version "5.2.0" + resolved "https://registry.yarnpkg.com/boom/-/boom-5.2.0.tgz#5dd9da6ee3a5f302077436290cb717d3f4a54e02" + dependencies: + hoek "4.x.x" + boxen@^1.0.0: version "1.2.1" resolved "https://registry.yarnpkg.com/boxen/-/boxen-1.2.1.tgz#0f11e7fe344edb9397977fc13ede7f64d956481d" @@ -1165,14 +1211,15 @@ browser-resolve@^1.11.0: resolve "1.1.7" browserify-aes@^1.0.0, browserify-aes@^1.0.4: - version "1.0.6" - resolved "https://registry.yarnpkg.com/browserify-aes/-/browserify-aes-1.0.6.tgz#5e7725dbdef1fd5930d4ebab48567ce451c48a0a" + version "1.0.8" + resolved "https://registry.yarnpkg.com/browserify-aes/-/browserify-aes-1.0.8.tgz#c8fa3b1b7585bb7ba77c5560b60996ddec6d5309" dependencies: - buffer-xor "^1.0.2" + buffer-xor "^1.0.3" cipher-base "^1.0.0" create-hash "^1.1.0" - evp_bytestokey "^1.0.0" + evp_bytestokey "^1.0.3" inherits "^2.0.1" + safe-buffer "^5.0.1" browserify-cipher@^1.0.0: version "1.0.0" @@ -1233,7 +1280,7 @@ buf-compare@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/buf-compare/-/buf-compare-1.0.1.tgz#fef28da8b8113a0a0db4430b0b6467b69730b34a" -buffer-xor@^1.0.2: +buffer-xor@^1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/buffer-xor/-/buffer-xor-1.0.3.tgz#26e61ed1422fb70dd42e6e36729ed51d855fe8d9" @@ -1253,9 +1300,9 @@ builtin-status-codes@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/builtin-status-codes/-/builtin-status-codes-3.0.0.tgz#85982878e21b98e1c66425e03d0174788f569ee8" -bytes@2.5.0: - version "2.5.0" - resolved "https://registry.yarnpkg.com/bytes/-/bytes-2.5.0.tgz#4c9423ea2d252c270c41b2bdefeff9bb6b62c06a" +bytes@3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/bytes/-/bytes-3.0.0.tgz#d32815404d689699f85a4ea4fa8755dd13a96048" caching-transform@^1.0.0: version "1.0.1" @@ -1337,12 +1384,12 @@ caniuse-api@^2.0.0: lodash.uniq "^4.5.0" caniuse-db@^1.0.30000529, caniuse-db@^1.0.30000634, caniuse-db@^1.0.30000639: - version "1.0.30000721" - resolved "https://registry.yarnpkg.com/caniuse-db/-/caniuse-db-1.0.30000721.tgz#cdc52efe8f82dd13916615b78e86f704ece61802" + version "1.0.30000744" + resolved "https://registry.yarnpkg.com/caniuse-db/-/caniuse-db-1.0.30000744.tgz#00758ff7dd5f7138d34a15608dccf71a59656ffe" -caniuse-lite@^1.0.0, caniuse-lite@^1.0.30000718: - version "1.0.30000721" - resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30000721.tgz#931a21a7bd85016300328d21f126d84b73437d35" +caniuse-lite@^1.0.0, caniuse-lite@^1.0.30000718, caniuse-lite@^1.0.30000726: + version "1.0.30000744" + resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30000744.tgz#860fa5c83ba34fe619397d607f30bb474821671b" capture-stack-trace@^1.0.0: version "1.0.0" @@ -1401,8 +1448,8 @@ chokidar@^1.4.2, chokidar@^1.7.0: fsevents "^1.0.0" ci-info@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/ci-info/-/ci-info-1.0.0.tgz#dc5285f2b4e251821683681c381c3388f46ec534" + version "1.1.1" + resolved "https://registry.yarnpkg.com/ci-info/-/ci-info-1.1.1.tgz#47b44df118c48d2597b56d342e7e25791060171a" cipher-base@^1.0.0, cipher-base@^1.0.1, cipher-base@^1.0.3: version "1.0.4" @@ -1415,21 +1462,15 @@ circular-json@^0.3.1: version "0.3.3" resolved "https://registry.yarnpkg.com/circular-json/-/circular-json-0.3.3.tgz#815c99ea84f6809529d2f45791bdf82711352d66" -clap@^1.0.9: - version "1.2.0" - resolved "https://registry.yarnpkg.com/clap/-/clap-1.2.0.tgz#59c90fe3e137104746ff19469a27a634ff68c857" - dependencies: - chalk "^1.1.3" - -clap@^1.1.3: +clap@^1.0.9, clap@^1.1.3: version "1.2.3" resolved "https://registry.yarnpkg.com/clap/-/clap-1.2.3.tgz#4f36745b32008492557f46412d66d50cb99bce51" dependencies: chalk "^1.1.3" clean-css@4.1.x: - version "4.1.7" - resolved "https://registry.yarnpkg.com/clean-css/-/clean-css-4.1.7.tgz#b9aea4f85679889cf3eae8b40349ec4ebdfdd032" + version "4.1.9" + resolved "https://registry.yarnpkg.com/clean-css/-/clean-css-4.1.9.tgz#35cee8ae7687a49b98034f70de00c4edd3826301" dependencies: source-map "0.5.x" @@ -1452,8 +1493,8 @@ cli-cursor@^2.1.0: restore-cursor "^2.0.0" cli-spinners@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/cli-spinners/-/cli-spinners-1.0.0.tgz#ef987ed3d48391ac3dab9180b406a742180d6e6a" + version "1.1.0" + resolved "https://registry.yarnpkg.com/cli-spinners/-/cli-spinners-1.1.0.tgz#f1847b168844d917a671eb9d147e3df497c90d06" cli-truncate@^1.0.0: version "1.1.0" @@ -1592,23 +1633,23 @@ commondir@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/commondir/-/commondir-1.0.1.tgz#ddd800da0c66127393cca5950ea968a3aaf1253b" -compressible@~2.0.10: +compressible@~2.0.11: version "2.0.11" resolved "https://registry.yarnpkg.com/compressible/-/compressible-2.0.11.tgz#16718a75de283ed8e604041625a2064586797d8a" dependencies: mime-db ">= 1.29.0 < 2" -compression@^1.7.0: - version "1.7.0" - resolved "https://registry.yarnpkg.com/compression/-/compression-1.7.0.tgz#030c9f198f1643a057d776a738e922da4373012d" +compression@^1.7.1: + version "1.7.1" + resolved "https://registry.yarnpkg.com/compression/-/compression-1.7.1.tgz#eff2603efc2e22cf86f35d2eb93589f9875373db" dependencies: - accepts "~1.3.3" - bytes "2.5.0" - compressible "~2.0.10" - debug "2.6.8" + accepts "~1.3.4" + bytes "3.0.0" + compressible "~2.0.11" + debug "2.6.9" on-headers "~1.0.1" safe-buffer "5.1.1" - vary "~1.1.1" + vary "~1.1.2" concat-map@0.0.1: version "0.0.1" @@ -1638,13 +1679,6 @@ concordance@^3.0.0: semver "^5.3.0" well-known-symbols "^1.0.0" -config-chain@~1.1.5: - version "1.1.11" - resolved "https://registry.yarnpkg.com/config-chain/-/config-chain-1.1.11.tgz#aba09747dfbe4c3e70e766a6e41586e1859fc6f2" - dependencies: - ini "^1.3.4" - proto-list "~1.2.1" - configstore@^3.0.0: version "3.1.1" resolved "https://registry.yarnpkg.com/configstore/-/configstore-3.1.1.tgz#094ee662ab83fad9917678de114faaea8fcdca90" @@ -1656,14 +1690,14 @@ configstore@^3.0.0: write-file-atomic "^2.0.0" xdg-basedir "^3.0.0" -connect@^3.6.3: - version "3.6.3" - resolved "https://registry.yarnpkg.com/connect/-/connect-3.6.3.tgz#f7320d46a25b4be7b483a2236517f24b1e27e301" +connect@^3.6.5: + version "3.6.5" + resolved "https://registry.yarnpkg.com/connect/-/connect-3.6.5.tgz#fb8dde7ba0763877d0ec9df9dac0b4b40e72c7da" dependencies: - debug "2.6.8" - finalhandler "1.0.4" - parseurl "~1.3.1" - utils-merge "1.0.0" + debug "2.6.9" + finalhandler "1.0.6" + parseurl "~1.3.2" + utils-merge "1.0.1" console-browserify@^1.1.0: version "1.1.0" @@ -1697,9 +1731,9 @@ content-type-parser@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/content-type-parser/-/content-type-parser-1.0.1.tgz#c3e56988c53c65127fb46d4032a3a900246fdc94" -content-type@~1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/content-type/-/content-type-1.0.2.tgz#b7d113aee7a8dd27bd21133c4dc2529df1721eed" +content-type@~1.0.4: + version "1.0.4" + resolved "https://registry.yarnpkg.com/content-type/-/content-type-1.0.4.tgz#e138cc75e040c727b1966fe5e5f8c9aee256fe3b" convert-source-map@^1.2.0, convert-source-map@^1.3.0, convert-source-map@^1.5.0: version "1.5.0" @@ -1717,17 +1751,17 @@ cookie@0.3.1, cookie@^0.3.1: version "0.3.1" resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.3.1.tgz#e7e0a1f9ef43b4c8ba925c5c5a96e806d16873bb" -copy-webpack-plugin@^4.0.1: - version "4.0.1" - resolved "https://registry.yarnpkg.com/copy-webpack-plugin/-/copy-webpack-plugin-4.0.1.tgz#9728e383b94316050d0c7463958f2b85c0aa8200" +copy-webpack-plugin@^4.1.1: + version "4.1.1" + resolved "https://registry.yarnpkg.com/copy-webpack-plugin/-/copy-webpack-plugin-4.1.1.tgz#53ae69e04955ebfa9fda411f54cbb968531d71fd" dependencies: - bluebird "^2.10.2" - fs-extra "^0.26.4" - glob "^6.0.4" - is-glob "^3.1.0" + bluebird "^3.5.1" + fs-extra "^4.0.2" + glob "^7.1.2" + is-glob "^4.0.0" loader-utils "^0.2.15" lodash "^4.3.0" - minimatch "^3.0.0" + minimatch "^3.0.4" node-dir "^0.1.10" core-assert@^0.2.0: @@ -1738,8 +1772,8 @@ core-assert@^0.2.0: is-error "^2.2.0" core-js@^2.0.0, core-js@^2.4.0, core-js@^2.5.0: - version "2.5.0" - resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.5.0.tgz#569c050918be6486b3837552028ae0466b717086" + version "2.5.1" + resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.5.1.tgz#ae6874dc66937789b80754ff5428df66819ca50b" core-util-is@1.0.2, core-util-is@~1.0.0: version "1.0.2" @@ -1818,6 +1852,12 @@ cryptiles@2.x.x: dependencies: boom "2.x.x" +cryptiles@3.x.x: + version "3.1.2" + resolved "https://registry.yarnpkg.com/cryptiles/-/cryptiles-3.1.2.tgz#a89fbb220f5ce25ec56e8c4aa8a4fd7b5b0d29fe" + dependencies: + boom "5.x.x" + crypto-browserify@^3.11.0: version "3.11.1" resolved "https://registry.yarnpkg.com/crypto-browserify/-/crypto-browserify-3.11.1.tgz#948945efc6757a400d6e5e5af47194d10064279f" @@ -1838,12 +1878,12 @@ crypto-random-string@^1.0.0: resolved "https://registry.yarnpkg.com/crypto-random-string/-/crypto-random-string-1.0.0.tgz#a230f64f568310e1498009940790ec99545bca7e" css-color-function@^1.3.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/css-color-function/-/css-color-function-1.3.0.tgz#72c767baf978f01b8a8a94f42f17ba5d22a776fc" + version "1.3.2" + resolved "https://registry.yarnpkg.com/css-color-function/-/css-color-function-1.3.2.tgz#4ba3e892fee9794644e6b0e1fd1df7811cd75502" dependencies: balanced-match "0.1.0" color "^0.11.0" - debug "~0.7.4" + debug "^3.1.0" rgb "~0.1.0" css-color-names@0.0.4: @@ -1996,22 +2036,18 @@ debug-log@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/debug-log/-/debug-log-1.0.1.tgz#2307632d4c04382b8df8a32f70b895046d52745f" -debug@2.6.8, debug@^2.2.0, debug@^2.6.3, debug@^2.6.8: - version "2.6.8" - resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.8.tgz#e731531ca2ede27d188222427da17821d68ff4fc" +debug@2.6.9, debug@^2.2.0, debug@^2.6.3, debug@^2.6.8: + version "2.6.9" + resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f" dependencies: ms "2.0.0" -debug@^3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/debug/-/debug-3.0.1.tgz#0564c612b521dc92d9f2988f0549e34f9c98db64" +debug@^3.0.1, debug@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261" dependencies: ms "2.0.0" -debug@~0.7.4: - version "0.7.4" - resolved "https://registry.yarnpkg.com/debug/-/debug-0.7.4.tgz#06e1ea8082c2cb14e39806e22e2f6f757f92af39" - decamelize@^1.0.0, decamelize@^1.1.1, decamelize@^1.1.2: version "1.2.0" resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290" @@ -2029,8 +2065,8 @@ deep-is@~0.1.3: resolved "https://registry.yarnpkg.com/deep-is/-/deep-is-0.1.3.tgz#b369d6fb5dbc13eecf524f91b070feedc357cf34" deepmerge@^1.5.0: - version "1.5.1" - resolved "https://registry.yarnpkg.com/deepmerge/-/deepmerge-1.5.1.tgz#c053bf06fd7276f1994f70c09a0760cb61a56237" + version "1.5.2" + resolved "https://registry.yarnpkg.com/deepmerge/-/deepmerge-1.5.2.tgz#10499d868844cdad4fee0842df8c7f6f0c95a753" default-require-extensions@^1.0.0: version "1.0.0" @@ -2141,6 +2177,10 @@ domelementtype@~1.1.1: version "1.1.3" resolved "https://registry.yarnpkg.com/domelementtype/-/domelementtype-1.1.3.tgz#bd28773e2642881aec51544924299c5cd822185b" +domexception@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/domexception/-/domexception-1.0.0.tgz#81fe5df81b3f057052cde3a9fa9bf536a85b9ab0" + domhandler@2.1: version "2.1.0" resolved "https://registry.yarnpkg.com/domhandler/-/domhandler-2.1.0.tgz#d2646f5e57f6c3bab11cf6cb05d3c0acf7412594" @@ -2193,16 +2233,6 @@ ecc-jsbn@~0.1.1: dependencies: jsbn "~0.1.0" -editorconfig@^0.13.2: - version "0.13.3" - resolved "https://registry.yarnpkg.com/editorconfig/-/editorconfig-0.13.3.tgz#e5219e587951d60958fd94ea9a9a008cdeff1b34" - dependencies: - bluebird "^3.0.5" - commander "^2.9.0" - lru-cache "^3.2.0" - semver "^5.1.0" - sigmund "^1.0.1" - ee-first@1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d" @@ -2212,8 +2242,8 @@ ejs@^2.5.6: resolved "https://registry.yarnpkg.com/ejs/-/ejs-2.5.7.tgz#cc872c168880ae3c7189762fd5ffc00896c9518a" electron-to-chromium@^1.2.7, electron-to-chromium@^1.3.18: - version "1.3.18" - resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.18.tgz#3dcc99da3e6b665f6abbc71c28ad51a2cd731a9c" + version "1.3.24" + resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.24.tgz#9b7b88bb05ceb9fa016a177833cc2dde388f21b6" elliptic@^6.0.0: version "6.4.0" @@ -2351,16 +2381,16 @@ escape-string-regexp@^1.0.2, escape-string-regexp@^1.0.4, escape-string-regexp@^ version "1.0.5" resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" -escodegen@^1.6.1: - version "1.8.1" - resolved "https://registry.yarnpkg.com/escodegen/-/escodegen-1.8.1.tgz#5a5b53af4693110bebb0867aa3430dd3b70a1018" +escodegen@^1.9.0: + version "1.9.0" + resolved "https://registry.yarnpkg.com/escodegen/-/escodegen-1.9.0.tgz#9811a2f265dc1cd3894420ee3717064b632b8852" dependencies: - esprima "^2.7.1" - estraverse "^1.9.1" + esprima "^3.1.3" + estraverse "^4.2.0" esutils "^2.0.2" optionator "^0.8.1" optionalDependencies: - source-map "~0.2.0" + source-map "~0.5.6" escope@^3.6.0: version "3.6.0" @@ -2389,9 +2419,9 @@ eslint-module-utils@^2.1.1: debug "^2.6.8" pkg-dir "^1.0.0" -eslint-plugin-html@^3.2.1: - version "3.2.1" - resolved "https://registry.yarnpkg.com/eslint-plugin-html/-/eslint-plugin-html-3.2.1.tgz#4289d38245f3d95134d22c17b1894d78db92c572" +eslint-plugin-html@^3.2.2: + version "3.2.2" + resolved "https://registry.yarnpkg.com/eslint-plugin-html/-/eslint-plugin-html-3.2.2.tgz#ef7093621d3a93de3206fd1f92f347ea9a1a4dfa" dependencies: htmlparser2 "^3.8.2" semver "^5.4.1" @@ -2411,9 +2441,9 @@ eslint-plugin-import@^2.7.0: minimatch "^3.0.3" read-pkg-up "^2.0.0" -eslint-plugin-node@^5.1.1: - version "5.1.1" - resolved "https://registry.yarnpkg.com/eslint-plugin-node/-/eslint-plugin-node-5.1.1.tgz#a7ed956e780c22aef6afd1116005acd82f26eac6" +eslint-plugin-node@^5.2.0: + version "5.2.0" + resolved "https://registry.yarnpkg.com/eslint-plugin-node/-/eslint-plugin-node-5.2.0.tgz#e1efca04a385516cff3f2f04027ce8c5ae6db749" dependencies: ignore "^3.3.3" minimatch "^3.0.4" @@ -2435,19 +2465,19 @@ eslint-scope@^3.7.1: esrecurse "^4.1.0" estraverse "^4.1.1" -eslint@^4.6.1: - version "4.6.1" - resolved "https://registry.yarnpkg.com/eslint/-/eslint-4.6.1.tgz#ddc7fc7fd70bf93205b0b3449bb16a1e9e7d4950" +eslint@^4.8.0: + version "4.8.0" + resolved "https://registry.yarnpkg.com/eslint/-/eslint-4.8.0.tgz#229ef0e354e0e61d837c7a80fdfba825e199815e" dependencies: ajv "^5.2.0" babel-code-frame "^6.22.0" chalk "^2.1.0" concat-stream "^1.6.0" cross-spawn "^5.1.0" - debug "^2.6.8" + debug "^3.0.1" doctrine "^2.0.0" eslint-scope "^3.7.1" - espree "^3.5.0" + espree "^3.5.1" esquery "^1.0.0" estraverse "^4.2.0" esutils "^2.0.2" @@ -2468,7 +2498,7 @@ eslint@^4.6.1: natural-compare "^1.4.0" optionator "^0.8.2" path-is-inside "^1.0.2" - pluralize "^4.0.0" + pluralize "^7.0.0" progress "^2.0.0" require-uncached "^1.0.3" semver "^5.3.0" @@ -2486,17 +2516,21 @@ espower-location-detector@^1.0.0: source-map "^0.5.0" xtend "^4.0.0" -espree@^3.5.0: - version "3.5.0" - resolved "https://registry.yarnpkg.com/espree/-/espree-3.5.0.tgz#98358625bdd055861ea27e2867ea729faf463d8d" +espree@^3.5.1: + version "3.5.1" + resolved "https://registry.yarnpkg.com/espree/-/espree-3.5.1.tgz#0c988b8ab46db53100a1954ae4ba995ddd27d87e" dependencies: acorn "^5.1.1" acorn-jsx "^3.0.0" -esprima@^2.6.0, esprima@^2.7.1: +esprima@^2.6.0: version "2.7.3" resolved "https://registry.yarnpkg.com/esprima/-/esprima-2.7.3.tgz#96e3b70d5779f6ad49cd032673d1c312767ba581" +esprima@^3.1.3: + version "3.1.3" + resolved "https://registry.yarnpkg.com/esprima/-/esprima-3.1.3.tgz#fdca51cee6133895e3c88d535ce49dbff62a4633" + esprima@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.0.tgz#4499eddcd1110e0b218bacf2fa7f7f59f55ca804" @@ -2520,10 +2554,6 @@ esrecurse@^4.1.0: estraverse "^4.1.0" object-assign "^4.0.1" -estraverse@^1.9.1: - version "1.9.3" - resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-1.9.3.tgz#af67f2dc922582415950926091a4005d29c9bb44" - estraverse@^4.0.0, estraverse@^4.1.0, estraverse@^4.1.1, estraverse@^4.2.0: version "4.2.0" resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-4.2.0.tgz#0dee3fed31fcd469618ce7342099fc1afa0bdb13" @@ -2544,9 +2574,9 @@ esutils@^2.0.2: version "2.0.2" resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.2.tgz#0abf4f1caa5bcb1f7a9d8acc6dea4faaa04bac9b" -etag@^1.8.0, etag@~1.8.0: - version "1.8.0" - resolved "https://registry.yarnpkg.com/etag/-/etag-1.8.0.tgz#6f631aef336d6c46362b51764044ce216be3c051" +etag@^1.8.1, etag@~1.8.1: + version "1.8.1" + resolved "https://registry.yarnpkg.com/etag/-/etag-1.8.1.tgz#41ae2eeb65efa62268aebfea83ac7d79299b0887" event-emitter@~0.3.5: version "0.3.5" @@ -2559,9 +2589,9 @@ events@^1.0.0: version "1.1.1" resolved "https://registry.yarnpkg.com/events/-/events-1.1.1.tgz#9ebdb7635ad099c70dcc4c2a1f5004288e8bd924" -evp_bytestokey@^1.0.0: - version "1.0.2" - resolved "https://registry.yarnpkg.com/evp_bytestokey/-/evp_bytestokey-1.0.2.tgz#f66bb88ecd57f71a766821e20283ea38c68bf80a" +evp_bytestokey@^1.0.0, evp_bytestokey@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/evp_bytestokey/-/evp_bytestokey-1.0.3.tgz#7fcbdb198dc71959432efe13842684e0525acb02" dependencies: md5.js "^1.3.4" safe-buffer "^5.1.1" @@ -2590,50 +2620,52 @@ expand-range@^1.8.1: dependencies: fill-range "^2.1.0" -express@^4.15.2, express@^4.15.4: - version "4.15.4" - resolved "https://registry.yarnpkg.com/express/-/express-4.15.4.tgz#032e2253489cf8fce02666beca3d11ed7a2daed1" +express@^4.15.2, express@^4.16.1: + version "4.16.1" + resolved "https://registry.yarnpkg.com/express/-/express-4.16.1.tgz#6b33b560183c9b253b7b62144df33a4654ac9ed0" dependencies: - accepts "~1.3.3" + accepts "~1.3.4" array-flatten "1.1.1" + body-parser "1.18.2" content-disposition "0.5.2" - content-type "~1.0.2" + content-type "~1.0.4" cookie "0.3.1" cookie-signature "1.0.6" - debug "2.6.8" + debug "2.6.9" depd "~1.1.1" encodeurl "~1.0.1" escape-html "~1.0.3" - etag "~1.8.0" - finalhandler "~1.0.4" - fresh "0.5.0" + etag "~1.8.1" + finalhandler "1.1.0" + fresh "0.5.2" merge-descriptors "1.0.1" methods "~1.1.2" on-finished "~2.3.0" - parseurl "~1.3.1" + parseurl "~1.3.2" path-to-regexp "0.1.7" - proxy-addr "~1.1.5" - qs "6.5.0" + proxy-addr "~2.0.2" + qs "6.5.1" range-parser "~1.2.0" - send "0.15.4" - serve-static "1.12.4" - setprototypeof "1.0.3" + safe-buffer "5.1.1" + send "0.16.1" + serve-static "1.13.1" + setprototypeof "1.1.0" statuses "~1.3.1" type-is "~1.6.15" - utils-merge "1.0.0" - vary "~1.1.1" + utils-merge "1.0.1" + vary "~1.1.2" -extend@~3.0.0: +extend@~3.0.0, extend@~3.0.1: version "3.0.1" resolved "https://registry.yarnpkg.com/extend/-/extend-3.0.1.tgz#a755ea7bc1adfcc5a31ce7e762dbaadc5e636444" -external-editor@^2.0.1: - version "2.0.4" - resolved "https://registry.yarnpkg.com/external-editor/-/external-editor-2.0.4.tgz#1ed9199da9cbfe2ef2f7a31b2fde8b0d12368972" +external-editor@^2.0.1, external-editor@^2.0.4: + version "2.0.5" + resolved "https://registry.yarnpkg.com/external-editor/-/external-editor-2.0.5.tgz#52c249a3981b9ba187c7cacf5beb50bf1d91a6bc" dependencies: iconv-lite "^0.4.17" jschardet "^1.4.2" - tmp "^0.0.31" + tmp "^0.0.33" extglob@^0.3.1: version "0.3.2" @@ -2641,9 +2673,9 @@ extglob@^0.3.1: dependencies: is-extglob "^1.0.0" -extract-text-webpack-plugin@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/extract-text-webpack-plugin/-/extract-text-webpack-plugin-3.0.0.tgz#90caa7907bc449f335005e3ac7532b41b00de612" +extract-text-webpack-plugin@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/extract-text-webpack-plugin/-/extract-text-webpack-plugin-3.0.1.tgz#605a8893faca1dd49bb0d2ca87493f33fd43d102" dependencies: async "^2.4.1" loader-utils "^1.1.0" @@ -2659,8 +2691,8 @@ fast-deep-equal@^1.0.0: resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-1.0.0.tgz#96256a3bc975595eb36d82e9929d060d893439ff" fast-diff@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/fast-diff/-/fast-diff-1.1.1.tgz#0aea0e4e605b6a2189f0e936d4b7fbaf1b7cfd9b" + version "1.1.2" + resolved "https://registry.yarnpkg.com/fast-diff/-/fast-diff-1.1.2.tgz#4b62c42b8e03de3f848460b639079920695d0154" fast-levenshtein@~2.0.4: version "2.0.6" @@ -2683,11 +2715,12 @@ file-entry-cache@^2.0.0: flat-cache "^1.2.1" object-assign "^4.0.1" -file-loader@^0.11.2: - version "0.11.2" - resolved "https://registry.yarnpkg.com/file-loader/-/file-loader-0.11.2.tgz#4ff1df28af38719a6098093b88c82c71d1794a34" +file-loader@^1.1.5: + version "1.1.5" + resolved "https://registry.yarnpkg.com/file-loader/-/file-loader-1.1.5.tgz#91c25b6b6fbe56dae99f10a425fd64933b5c9daa" dependencies: loader-utils "^1.0.2" + schema-utils "^0.3.0" filename-regex@^2.0.0: version "2.0.1" @@ -2707,15 +2740,27 @@ fill-range@^2.1.0: repeat-element "^1.1.2" repeat-string "^1.5.2" -finalhandler@1.0.4, finalhandler@^1.0.4, finalhandler@~1.0.4: - version "1.0.4" - resolved "https://registry.yarnpkg.com/finalhandler/-/finalhandler-1.0.4.tgz#18574f2e7c4b98b8ae3b230c21f201f31bdb3fb7" +finalhandler@1.0.6: + version "1.0.6" + resolved "https://registry.yarnpkg.com/finalhandler/-/finalhandler-1.0.6.tgz#007aea33d1a4d3e42017f624848ad58d212f814f" dependencies: - debug "2.6.8" + debug "2.6.9" encodeurl "~1.0.1" escape-html "~1.0.3" on-finished "~2.3.0" - parseurl "~1.3.1" + parseurl "~1.3.2" + statuses "~1.3.1" + unpipe "~1.0.0" + +finalhandler@1.1.0, finalhandler@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/finalhandler/-/finalhandler-1.1.0.tgz#ce0b6855b45853e791b2fcc680046d88253dd7f5" + dependencies: + debug "2.6.9" + encodeurl "~1.0.1" + escape-html "~1.0.3" + on-finished "~2.3.0" + parseurl "~1.3.2" statuses "~1.3.1" unpipe "~1.0.0" @@ -2749,8 +2794,8 @@ find-up@^2.0.0, find-up@^2.1.0: locate-path "^2.0.0" flat-cache@^1.2.1: - version "1.2.2" - resolved "https://registry.yarnpkg.com/flat-cache/-/flat-cache-1.2.2.tgz#fa86714e72c21db88601761ecf2f555d1abc6b96" + version "1.3.0" + resolved "https://registry.yarnpkg.com/flat-cache/-/flat-cache-1.3.0.tgz#d3030b32b38154f4e3b7e9c709f490f7ef97c481" dependencies: circular-json "^0.3.1" del "^2.0.2" @@ -2798,13 +2843,21 @@ form-data@~2.1.1: combined-stream "^1.0.5" mime-types "^2.1.12" -forwarded@~0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/forwarded/-/forwarded-0.1.0.tgz#19ef9874c4ae1c297bcf078fde63a09b66a84363" +form-data@~2.3.1: + version "2.3.1" + resolved "https://registry.yarnpkg.com/form-data/-/form-data-2.3.1.tgz#6fb94fbd71885306d73d15cc497fe4cc4ecd44bf" + dependencies: + asynckit "^0.4.0" + combined-stream "^1.0.5" + mime-types "^2.1.12" -fresh@0.5.0, fresh@^0.5.0: - version "0.5.0" - resolved "https://registry.yarnpkg.com/fresh/-/fresh-0.5.0.tgz#f474ca5e6a9246d6fd8e0953cfa9b9c805afa78e" +forwarded@~0.1.2: + version "0.1.2" + resolved "https://registry.yarnpkg.com/forwarded/-/forwarded-0.1.2.tgz#98c23dab1175657b8c0573e8ceccd91b0ff18c84" + +fresh@0.5.2, fresh@^0.5.2: + version "0.5.2" + resolved "https://registry.yarnpkg.com/fresh/-/fresh-0.5.2.tgz#3d8cadd90d976569fa835ab1f8e4b23a105605a7" friendly-errors-webpack-plugin@^1.6.1: version "1.6.1" @@ -2814,22 +2867,12 @@ friendly-errors-webpack-plugin@^1.6.1: error-stack-parser "^2.0.0" string-length "^1.0.1" -fs-extra@^0.26.4: - version "0.26.7" - resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-0.26.7.tgz#9ae1fdd94897798edab76d0918cf42d0c3184fa9" +fs-extra@^4.0.2: + version "4.0.2" + resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-4.0.2.tgz#f91704c53d1b461f893452b0c307d9997647ab6b" dependencies: graceful-fs "^4.1.2" - jsonfile "^2.1.0" - klaw "^1.0.0" - path-is-absolute "^1.0.0" - rimraf "^2.2.8" - -fs-extra@^4.0.1: - version "4.0.1" - resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-4.0.1.tgz#7fc0c6c8957f983f57f306a24e5b9ddd8d0dd880" - dependencies: - graceful-fs "^4.1.2" - jsonfile "^3.0.0" + jsonfile "^4.0.0" universalify "^0.1.0" fs.realpath@^1.0.0: @@ -2920,16 +2963,6 @@ glob-parent@^2.0.0: dependencies: is-glob "^2.0.0" -glob@^6.0.4: - version "6.0.4" - resolved "https://registry.yarnpkg.com/glob/-/glob-6.0.4.tgz#0f08860f6a155127b2fadd4f9ce24b1aab6e4d22" - dependencies: - inflight "^1.0.4" - inherits "2" - minimatch "2 || 3" - once "^1.3.0" - path-is-absolute "^1.0.0" - glob@^7.0.3, glob@^7.0.5, glob@^7.0.6, glob@^7.1.2: version "7.1.2" resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.2.tgz#c19c9df9a028702d678612384a6552404c636d15" @@ -2986,7 +3019,7 @@ got@^6.7.1: unzip-response "^2.0.1" url-parse-lax "^1.0.0" -graceful-fs@^4.1.11, graceful-fs@^4.1.2, graceful-fs@^4.1.6, graceful-fs@^4.1.9: +graceful-fs@^4.1.11, graceful-fs@^4.1.2, graceful-fs@^4.1.6: version "4.1.11" resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.11.tgz#0e8bdfe4d1ddb8854d64e04ea7c00e2a026e5658" @@ -3010,6 +3043,10 @@ har-schema@^1.0.5: version "1.0.5" resolved "https://registry.yarnpkg.com/har-schema/-/har-schema-1.0.5.tgz#d263135f43307c02c602afc8fe95970c0151369e" +har-schema@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/har-schema/-/har-schema-2.0.0.tgz#a94c2224ebcac04782a0d9035521f24735b7ec92" + har-validator@~4.2.1: version "4.2.1" resolved "https://registry.yarnpkg.com/har-validator/-/har-validator-4.2.1.tgz#33481d0f1bbff600dd203d75812a6a5fba002e2a" @@ -3017,6 +3054,13 @@ har-validator@~4.2.1: ajv "^4.9.1" har-schema "^1.0.5" +har-validator@~5.0.3: + version "5.0.3" + resolved "https://registry.yarnpkg.com/har-validator/-/har-validator-5.0.3.tgz#ba402c266194f15956ef15e0fcf242993f6a7dfd" + dependencies: + ajv "^5.1.0" + har-schema "^2.0.0" + has-ansi@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/has-ansi/-/has-ansi-2.0.0.tgz#34f5049ce1ecdf2b0649af3ef24e45ed35416d91" @@ -3073,7 +3117,7 @@ hash.js@^1.0.0, hash.js@^1.0.3: inherits "^2.0.3" minimalistic-assert "^1.0.0" -hawk@~3.1.3: +hawk@3.1.3, hawk@~3.1.3: version "3.1.3" resolved "https://registry.yarnpkg.com/hawk/-/hawk-3.1.3.tgz#078444bd7c1640b0fe540d2c9b73d59678e8e1c4" dependencies: @@ -3082,6 +3126,15 @@ hawk@~3.1.3: hoek "2.x.x" sntp "1.x.x" +hawk@~6.0.2: + version "6.0.2" + resolved "https://registry.yarnpkg.com/hawk/-/hawk-6.0.2.tgz#af4d914eb065f9b5ce4d9d11c1cb2126eecc3038" + dependencies: + boom "4.x.x" + cryptiles "3.x.x" + hoek "4.x.x" + sntp "2.x.x" + he@1.1.x, he@^1.1.0: version "1.1.1" resolved "https://registry.yarnpkg.com/he/-/he-1.1.1.tgz#93410fd21b009735151f8868c2f271f3427e23fd" @@ -3098,6 +3151,10 @@ hoek@2.x.x: version "2.16.3" resolved "https://registry.yarnpkg.com/hoek/-/hoek-2.16.3.tgz#20bb7403d3cea398e91dc4710a8ff1b8274a25ed" +hoek@4.x.x: + version "4.2.0" + resolved "https://registry.yarnpkg.com/hoek/-/hoek-4.2.0.tgz#72d9d0754f7fe25ca2d01ad8f8f9a9449a89526d" + home-or-tmp@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/home-or-tmp/-/home-or-tmp-2.0.0.tgz#e36c3f2d2cae7d746a857e38d18d5f32a7882db8" @@ -3123,9 +3180,9 @@ html-entities@^1.2.0: version "1.2.1" resolved "https://registry.yarnpkg.com/html-entities/-/html-entities-1.2.1.tgz#0df29351f0721163515dfb9e5543e5f6eed5162f" -html-minifier@^3.2.3, html-minifier@^3.5.3: - version "3.5.3" - resolved "https://registry.yarnpkg.com/html-minifier/-/html-minifier-3.5.3.tgz#4a275e3b1a16639abb79b4c11191ff0d0fcf1ab9" +html-minifier@^3.2.3, html-minifier@^3.5.5: + version "3.5.5" + resolved "https://registry.yarnpkg.com/html-minifier/-/html-minifier-3.5.5.tgz#3bdc9427e638bbe3dbde96c0eb988b044f02739e" dependencies: camel-case "3.0.x" clean-css "4.1.x" @@ -3134,7 +3191,11 @@ html-minifier@^3.2.3, html-minifier@^3.5.3: ncname "1.0.x" param-case "2.1.x" relateurl "0.2.x" - uglify-js "3.0.x" + uglify-js "3.1.x" + +html-tags@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/html-tags/-/html-tags-2.0.0.tgz#10b30a386085f43cede353cc8fa7cb0deeea668b" html-webpack-plugin@^2.30.1: version "2.30.1" @@ -3167,7 +3228,7 @@ htmlparser2@~3.3.0: domutils "1.1" readable-stream "1.0" -http-errors@~1.6.2: +http-errors@1.6.2, http-errors@~1.6.2: version "1.6.2" resolved "https://registry.yarnpkg.com/http-errors/-/http-errors-1.6.2.tgz#0a002cc85707192a7e7946ceedc11155f60ec736" dependencies: @@ -3184,6 +3245,14 @@ http-signature@~1.1.0: jsprim "^1.2.2" sshpk "^1.7.0" +http-signature@~1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/http-signature/-/http-signature-1.2.0.tgz#9aecd925114772f3d95b65a60abb8f7c18fbace1" + dependencies: + assert-plus "^1.0.0" + jsprim "^1.2.2" + sshpk "^1.7.0" + https-browserify@0.0.1: version "0.0.1" resolved "https://registry.yarnpkg.com/https-browserify/-/https-browserify-0.0.1.tgz#3f91365cabe60b77ed0ebba24b454e3e09d95a82" @@ -3211,9 +3280,9 @@ iconv-lite@0.4.13: version "0.4.13" resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.13.tgz#1f88aba4ab0b1508e8312acc39345f36e992e2f2" -iconv-lite@^0.4.17, iconv-lite@~0.4.13: - version "0.4.18" - resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.18.tgz#23d8656b16aae6742ac29732ea8f0336a4789cf2" +iconv-lite@0.4.19, iconv-lite@^0.4.17, iconv-lite@~0.4.13: + version "0.4.19" + resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.19.tgz#f7468f60135f5e5dad3399c0a81be9a1603a082b" icss-replace-symbols@^1.1.0: version "1.1.0" @@ -3285,11 +3354,11 @@ inherits@2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.1.tgz#b17d08d326b4423e568eff719f91b0b1cbdf69f1" -ini@^1.3.4, ini@~1.3.0: +ini@~1.3.0: version "1.3.4" resolved "https://registry.yarnpkg.com/ini/-/ini-1.3.4.tgz#0537cb79daf59b59a1a517dff706c86ec039162e" -inquirer@3.0.6, inquirer@^3.0.6: +inquirer@3.0.6: version "3.0.6" resolved "https://registry.yarnpkg.com/inquirer/-/inquirer-3.0.6.tgz#e04aaa9d05b7a3cb9b0f407d04375f0447190347" dependencies: @@ -3307,9 +3376,28 @@ inquirer@3.0.6, inquirer@^3.0.6: strip-ansi "^3.0.0" through "^2.3.6" +inquirer@^3.0.6: + version "3.3.0" + resolved "https://registry.yarnpkg.com/inquirer/-/inquirer-3.3.0.tgz#9dd2f2ad765dcab1ff0443b491442a20ba227dc9" + dependencies: + ansi-escapes "^3.0.0" + chalk "^2.0.0" + cli-cursor "^2.1.0" + cli-width "^2.0.0" + external-editor "^2.0.4" + figures "^2.0.0" + lodash "^4.3.0" + mute-stream "0.0.7" + run-async "^2.2.0" + rx-lite "^4.0.8" + rx-lite-aggregates "^4.0.8" + string-width "^2.1.0" + strip-ansi "^4.0.0" + through "^2.3.6" + interpret@^1.0.0: - version "1.0.3" - resolved "https://registry.yarnpkg.com/interpret/-/interpret-1.0.3.tgz#cbc35c62eeee73f19ab7b10a801511401afc0f90" + version "1.0.4" + resolved "https://registry.yarnpkg.com/interpret/-/interpret-1.0.4.tgz#820cdd588b868ffb191a809506d6c9c8f212b1b0" invariant@^2.2.0, invariant@^2.2.2: version "2.2.2" @@ -3321,9 +3409,9 @@ invert-kv@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/invert-kv/-/invert-kv-1.0.0.tgz#104a8e4aaca6d3d8cd157a8ef8bfab2d7a3ffdb6" -ipaddr.js@1.4.0: - version "1.4.0" - resolved "https://registry.yarnpkg.com/ipaddr.js/-/ipaddr.js-1.4.0.tgz#296aca878a821816e5b85d0a285a99bcff4582f0" +ipaddr.js@1.5.2: + version "1.5.2" + resolved "https://registry.yarnpkg.com/ipaddr.js/-/ipaddr.js-1.5.2.tgz#d4b505bde9946987ccf0fc58d9010ff9607e3fa0" irregular-plurals@^1.0.0: version "1.3.0" @@ -3389,7 +3477,7 @@ is-extglob@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-1.0.0.tgz#ac468177c4943405a092fc8f29760c6ffc6206c0" -is-extglob@^2.1.0: +is-extglob@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-2.1.1.tgz#a88c02535791f02ed37c76a1b9ea9773c833f8c2" @@ -3419,11 +3507,11 @@ is-glob@^2.0.0, is-glob@^2.0.1: dependencies: is-extglob "^1.0.0" -is-glob@^3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-3.1.0.tgz#7ba5ae24217804ac70707b96922567486cc3e84a" +is-glob@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-4.0.0.tgz#9521c76845cc2610a85203ddf080a958c2ffabc0" dependencies: - is-extglob "^2.1.0" + is-extglob "^2.1.1" is-module@^1.0.0: version "1.0.0" @@ -3563,15 +3651,15 @@ istanbul-lib-hook@^1.0.7: dependencies: append-transform "^0.4.0" -istanbul-lib-instrument@^1.7.2, istanbul-lib-instrument@^1.7.4: - version "1.7.5" - resolved "https://registry.yarnpkg.com/istanbul-lib-instrument/-/istanbul-lib-instrument-1.7.5.tgz#adb596f8f0cb8b95e739206351a38a586af21b1e" +istanbul-lib-instrument@^1.7.5, istanbul-lib-instrument@^1.8.0: + version "1.8.0" + resolved "https://registry.yarnpkg.com/istanbul-lib-instrument/-/istanbul-lib-instrument-1.8.0.tgz#66f6c9421cc9ec4704f76f2db084ba9078a2b532" dependencies: babel-generator "^6.18.0" babel-template "^6.16.0" babel-traverse "^6.18.0" babel-types "^6.18.0" - babylon "^6.17.4" + babylon "^6.18.0" istanbul-lib-coverage "^1.1.1" semver "^5.3.0" @@ -3601,17 +3689,8 @@ istanbul-reports@^1.1.1: handlebars "^4.0.3" js-base64@^2.1.9: - version "2.1.9" - resolved "https://registry.yarnpkg.com/js-base64/-/js-base64-2.1.9.tgz#f0e80ae039a4bd654b5f281fc93f04a914a7fcce" - -js-beautify@^1.6.14: - version "1.6.14" - resolved "https://registry.yarnpkg.com/js-beautify/-/js-beautify-1.6.14.tgz#d3b8f7322d02b9277d58bd238264c327e58044cd" - dependencies: - config-chain "~1.1.5" - editorconfig "^0.13.2" - mkdirp "~0.5.0" - nopt "~3.0.1" + version "2.3.2" + resolved "https://registry.yarnpkg.com/js-base64/-/js-base64-2.3.2.tgz#a79a923666372b580f8e27f51845c6f7e8fbfbaf" js-string-escape@^1.0.1: version "1.0.1" @@ -3622,8 +3701,8 @@ js-tokens@^3.0.0, js-tokens@^3.0.2: resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.2.tgz#9866df395102130e38f7f996bceb65443209c25b" js-yaml@^3.4.3, js-yaml@^3.8.2, js-yaml@^3.9.1: - version "3.9.1" - resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.9.1.tgz#08775cebdfdd359209f0d2acd383c8f86a6904a0" + version "3.10.0" + resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.10.0.tgz#2e78441646bd4682e963f22b6e92823c309c62dc" dependencies: argparse "^1.0.7" esprima "^4.0.0" @@ -3643,30 +3722,31 @@ jschardet@^1.4.2: version "1.5.1" resolved "https://registry.yarnpkg.com/jschardet/-/jschardet-1.5.1.tgz#c519f629f86b3a5bedba58a88d311309eec097f9" -jsdom@^11.2.0: - version "11.2.0" - resolved "https://registry.yarnpkg.com/jsdom/-/jsdom-11.2.0.tgz#4f6b8736af3357c3af7227a3b54a5bda1c513fd6" +jsdom@^11.3.0: + version "11.3.0" + resolved "https://registry.yarnpkg.com/jsdom/-/jsdom-11.3.0.tgz#7b2dfe6227d014084d80f6b3e98fa1e4cef199e7" dependencies: abab "^1.0.3" - acorn "^4.0.4" - acorn-globals "^3.1.0" + acorn "^5.1.2" + acorn-globals "^4.0.0" array-equal "^1.0.0" content-type-parser "^1.0.1" cssom ">= 0.3.2 < 0.4.0" cssstyle ">= 0.2.37 < 0.3.0" - escodegen "^1.6.1" + domexception "^1.0.0" + escodegen "^1.9.0" html-encoding-sniffer "^1.0.1" nwmatcher "^1.4.1" parse5 "^3.0.2" pn "^1.0.0" - request "^2.79.0" + request "^2.83.0" request-promise-native "^1.0.3" sax "^1.2.1" symbol-tree "^3.2.1" - tough-cookie "^2.3.2" - webidl-conversions "^4.0.0" + tough-cookie "^2.3.3" + webidl-conversions "^4.0.2" whatwg-encoding "^1.0.1" - whatwg-url "^6.1.0" + whatwg-url "^6.3.0" xml-name-validator "^2.0.1" jsesc@^1.3.0: @@ -3703,15 +3783,9 @@ json5@^0.5.0, json5@^0.5.1: version "0.5.1" resolved "https://registry.yarnpkg.com/json5/-/json5-0.5.1.tgz#1eade7acc012034ad84e2396767ead9fa5495821" -jsonfile@^2.1.0: - version "2.4.0" - resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-2.4.0.tgz#3736a2b428b87bbda0cc83b53fa3d633a35c2ae8" - optionalDependencies: - graceful-fs "^4.1.6" - -jsonfile@^3.0.0: - version "3.0.1" - resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-3.0.1.tgz#a5ecc6f65f53f662c4415c7675a0331d0992ec66" +jsonfile@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-4.0.0.tgz#8771aae0799b64076b76640fca058f9c10e33ecb" optionalDependencies: graceful-fs "^4.1.6" @@ -3740,12 +3814,6 @@ kind-of@^4.0.0: dependencies: is-buffer "^1.1.5" -klaw@^1.0.0: - version "1.3.1" - resolved "https://registry.yarnpkg.com/klaw/-/klaw-1.3.1.tgz#4088433b46b3b1ba259d78785d8e96f73ba02439" - optionalDependencies: - graceful-fs "^4.1.9" - last-line-stream@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/last-line-stream/-/last-line-stream-1.0.0.tgz#d1b64d69f86ff24af2d04883a2ceee14520a5600" @@ -3895,7 +3963,7 @@ lodash.uniq@^4.5.0: version "4.5.0" resolved "https://registry.yarnpkg.com/lodash.uniq/-/lodash.uniq-4.5.0.tgz#d0225373aeb652adc1bc82e4945339a842754773" -lodash@^4.0.0, lodash@^4.11.1, lodash@^4.13.1, lodash@^4.14.0, lodash@^4.17.3, lodash@^4.17.4, lodash@^4.2.0, lodash@^4.3.0: +lodash@^4.11.1, lodash@^4.13.1, lodash@^4.14.0, lodash@^4.17.3, lodash@^4.17.4, lodash@^4.2.0, lodash@^4.3.0: version "4.17.4" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.4.tgz#78203a4d1c328ae1d86dca6460e369b57f4055ae" @@ -3924,12 +3992,6 @@ lowercase-keys@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/lowercase-keys/-/lowercase-keys-1.0.0.tgz#4e3366b39e7f5457e35f1324bdf6f88d0bfc7306" -lru-cache@^3.2.0: - version "3.2.0" - resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-3.2.0.tgz#71789b3b7f5399bec8565dda38aa30d2a097efee" - dependencies: - pseudomap "^1.0.1" - lru-cache@^4.0.1, lru-cache@^4.1.1: version "4.1.1" resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-4.1.1.tgz#622e32e82488b49279114a4f9ecf45e7cd6bba55" @@ -4055,37 +4117,25 @@ micromatch@^2.1.5, micromatch@^2.3.11: regex-cache "^0.4.2" miller-rabin@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/miller-rabin/-/miller-rabin-4.0.0.tgz#4a62fb1d42933c05583982f4c716f6fb9e6c6d3d" + version "4.0.1" + resolved "https://registry.yarnpkg.com/miller-rabin/-/miller-rabin-4.0.1.tgz#f080351c865b0dc562a8462966daa53543c78a4d" dependencies: bn.js "^4.0.0" brorand "^1.0.1" -"mime-db@>= 1.29.0 < 2": +"mime-db@>= 1.29.0 < 2", mime-db@~1.30.0: version "1.30.0" resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.30.0.tgz#74c643da2dd9d6a45399963465b26d5ca7d71f01" -mime-db@~1.29.0: - version "1.29.0" - resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.29.0.tgz#48d26d235589651704ac5916ca06001914266878" - -mime-types@^2.1.12, mime-types@~2.1.15, mime-types@~2.1.16, mime-types@~2.1.7: - version "2.1.16" - resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.16.tgz#2b858a52e5ecd516db897ac2be87487830698e23" +mime-types@^2.1.12, mime-types@~2.1.15, mime-types@~2.1.16, mime-types@~2.1.17, mime-types@~2.1.7: + version "2.1.17" + resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.17.tgz#09d7a393f03e995a79f8af857b70a9e0ab16557a" dependencies: - mime-db "~1.29.0" + mime-db "~1.30.0" -mime@1.3.4: - version "1.3.4" - resolved "https://registry.yarnpkg.com/mime/-/mime-1.3.4.tgz#115f9e3b6b3daf2959983cb38f149a2d40eb5d53" - -mime@1.3.x: - version "1.3.6" - resolved "https://registry.yarnpkg.com/mime/-/mime-1.3.6.tgz#591d84d3653a6b0b4a3b9df8de5aa8108e72e5e0" - -mime@^1.2.11, mime@^1.3.4: - version "1.4.0" - resolved "https://registry.yarnpkg.com/mime/-/mime-1.4.0.tgz#69e9e0db51d44f2a3b56e48b7817d7d137f1a343" +mime@1.4.1, mime@^1.2.11, mime@^1.3.4, mime@^1.4.1: + version "1.4.1" + resolved "https://registry.yarnpkg.com/mime/-/mime-1.4.1.tgz#121f9ebc49e3766f311a76e1fa1c8003c4b03aa6" mimic-fn@^1.0.0: version "1.1.0" @@ -4099,13 +4149,13 @@ minimalistic-crypto-utils@^1.0.0, minimalistic-crypto-utils@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz#f6c00c1c0b082246e5c4d99dfb8c7c083b2b582a" -"minimatch@2 || 3", minimatch@^3.0.0, minimatch@^3.0.2, minimatch@^3.0.3, minimatch@^3.0.4: +minimatch@^3.0.0, minimatch@^3.0.2, minimatch@^3.0.3, minimatch@^3.0.4: version "3.0.4" resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083" dependencies: brace-expansion "^1.1.7" -minimist@0.0.8, minimist@~0.0.1: +minimist@0.0.8: version "0.0.8" resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.8.tgz#857fcabfc3397d2625b8228262e86aa7a011b05d" @@ -4113,6 +4163,10 @@ minimist@1.2.0, minimist@^1.1.3, minimist@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284" +minimist@~0.0.1: + version "0.0.10" + resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.10.tgz#de3f98543dbf96082be48ad1a0c7cda836301dcf" + "mkdirp@>=0.5 0", mkdirp@^0.5.0, mkdirp@^0.5.1, mkdirp@~0.5.0, mkdirp@~0.5.1: version "0.5.1" resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.1.tgz#30057438eac6cf7f8c4767f38648d6697d75c903" @@ -4159,8 +4213,8 @@ negotiator@0.6.1: resolved "https://registry.yarnpkg.com/negotiator/-/negotiator-0.6.1.tgz#2b327184e8992101177b28563fb5e7102acd0ca9" no-case@^2.2.0: - version "2.3.1" - resolved "https://registry.yarnpkg.com/no-case/-/no-case-2.3.1.tgz#7aeba1c73a52184265554b7dc03baf720df80081" + version "2.3.2" + resolved "https://registry.yarnpkg.com/no-case/-/no-case-2.3.2.tgz#60b813396be39b3f1288a4c1ed5d1e7d28b464ac" dependencies: lower-case "^1.1.1" @@ -4206,14 +4260,15 @@ node-libs-browser@^2.0.0: vm-browserify "0.0.4" node-pre-gyp@^0.6.36: - version "0.6.36" - resolved "https://registry.yarnpkg.com/node-pre-gyp/-/node-pre-gyp-0.6.36.tgz#db604112cb74e0d477554e9b505b17abddfab786" + version "0.6.38" + resolved "https://registry.yarnpkg.com/node-pre-gyp/-/node-pre-gyp-0.6.38.tgz#e92a20f83416415bb4086f6d1fb78b3da73d113d" dependencies: + hawk "3.1.3" mkdirp "^0.5.1" nopt "^4.0.1" npmlog "^4.0.2" rc "^1.1.7" - request "^2.81.0" + request "2.81.0" rimraf "^2.6.1" semver "^5.3.0" tar "^2.2.1" @@ -4226,12 +4281,6 @@ nopt@^4.0.1: abbrev "1" osenv "^0.1.4" -nopt@~3.0.1: - version "3.0.6" - resolved "https://registry.yarnpkg.com/nopt/-/nopt-3.0.6.tgz#c6465dbf08abcd4db359317f79ac68a646b28ff9" - dependencies: - abbrev "1" - normalize-package-data@^2.3.2, normalize-package-data@^2.3.4: version "2.4.0" resolved "https://registry.yarnpkg.com/normalize-package-data/-/normalize-package-data-2.4.0.tgz#12f95a307d58352075a04907b84ac8be98ac012f" @@ -4290,12 +4339,12 @@ number-is-nan@^1.0.0: resolved "https://registry.yarnpkg.com/number-is-nan/-/number-is-nan-1.0.1.tgz#097b602b53422a522c1afb8790318336941a011d" nwmatcher@^1.4.1: - version "1.4.1" - resolved "https://registry.yarnpkg.com/nwmatcher/-/nwmatcher-1.4.1.tgz#7ae9b07b0ea804db7e25f05cb5fe4097d4e4949f" + version "1.4.2" + resolved "https://registry.yarnpkg.com/nwmatcher/-/nwmatcher-1.4.2.tgz#c5e545ab40d22a56b0326531c4beaed7a888b3ea" -nyc@^11.1.0: - version "11.1.0" - resolved "https://registry.yarnpkg.com/nyc/-/nyc-11.1.0.tgz#d6b3c5e16892a25af63138ba484676aa8a22eda7" +nyc@^11.2.1: + version "11.2.1" + resolved "https://registry.yarnpkg.com/nyc/-/nyc-11.2.1.tgz#ad850afe9dbad7f4970728b4b2e47fed1c38721c" dependencies: archy "^1.0.0" arrify "^1.0.1" @@ -4309,7 +4358,7 @@ nyc@^11.1.0: glob "^7.0.6" istanbul-lib-coverage "^1.1.1" istanbul-lib-hook "^1.0.7" - istanbul-lib-instrument "^1.7.4" + istanbul-lib-instrument "^1.8.0" istanbul-lib-report "^1.1.1" istanbul-lib-source-maps "^1.2.1" istanbul-reports "^1.1.1" @@ -4325,7 +4374,7 @@ nyc@^11.1.0: yargs "^8.0.1" yargs-parser "^5.0.0" -oauth-sign@~0.8.1: +oauth-sign@~0.8.1, oauth-sign@~0.8.2: version "0.8.2" resolved "https://registry.yarnpkg.com/oauth-sign/-/oauth-sign-0.8.2.tgz#46a6ab7f0aead8deae9ec0565780b7d4efeb9d43" @@ -4452,7 +4501,7 @@ os-locale@^2.0.0: lcid "^1.0.0" mem "^1.1.0" -os-tmpdir@^1.0.0, os-tmpdir@^1.0.1, os-tmpdir@~1.0.1: +os-tmpdir@^1.0.0, os-tmpdir@^1.0.1, os-tmpdir@~1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274" @@ -4550,9 +4599,9 @@ parse5@^3.0.2: dependencies: "@types/node" "^6.0.46" -parseurl@~1.3.1: - version "1.3.1" - resolved "https://registry.yarnpkg.com/parseurl/-/parseurl-1.3.1.tgz#c8ab8c9223ba34888aa64a297b28853bec18da56" +parseurl@~1.3.2: + version "1.3.2" + resolved "https://registry.yarnpkg.com/parseurl/-/parseurl-1.3.2.tgz#fc289d4ed8993119460c156253262cdc8de65bf3" path-browserify@0.0.0: version "0.0.0" @@ -4603,8 +4652,8 @@ path-type@^2.0.0: pify "^2.0.0" pbkdf2@^3.0.3: - version "3.0.13" - resolved "https://registry.yarnpkg.com/pbkdf2/-/pbkdf2-3.0.13.tgz#c37d295531e786b1da3e3eadc840426accb0ae25" + version "3.0.14" + resolved "https://registry.yarnpkg.com/pbkdf2/-/pbkdf2-3.0.14.tgz#a35e13c64799b06ce15320f459c230e68e73bade" dependencies: create-hash "^1.1.2" create-hmac "^1.1.4" @@ -4616,6 +4665,10 @@ performance-now@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/performance-now/-/performance-now-0.2.0.tgz#33ef30c5c77d4ea21c5a53869d91b56d8f2555e5" +performance-now@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/performance-now/-/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b" + pify@^2.0.0, pify@^2.3.0: version "2.3.0" resolved "https://registry.yarnpkg.com/pify/-/pify-2.3.0.tgz#ed141a6ac043a849ea588498e7dca8b15330e90c" @@ -4688,9 +4741,9 @@ plur@^2.0.0: dependencies: irregular-plurals "^1.0.0" -pluralize@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/pluralize/-/pluralize-4.0.0.tgz#59b708c1c0190a2f692f1c7618c446b052fd1762" +pluralize@^7.0.0: + version "7.0.0" + resolved "https://registry.yarnpkg.com/pluralize/-/pluralize-7.0.0.tgz#298b89df8b93b0221dbf421ad2b1b1ea23fc6777" pn@^1.0.0: version "1.0.0" @@ -4851,11 +4904,11 @@ postcss-custom-media@^6.0.0: postcss "^6.0.1" postcss-custom-properties@^6.1.0: - version "6.1.0" - resolved "https://registry.yarnpkg.com/postcss-custom-properties/-/postcss-custom-properties-6.1.0.tgz#9caf1151ac41b1e9e64d3a2ff9ece996ca18977d" + version "6.2.0" + resolved "https://registry.yarnpkg.com/postcss-custom-properties/-/postcss-custom-properties-6.2.0.tgz#5d929a7f06e9b84e0f11334194c0ba9a30acfbe9" dependencies: balanced-match "^1.0.0" - postcss "^6.0.3" + postcss "^6.0.13" postcss-custom-selectors@^4.0.1: version "4.0.1" @@ -5070,10 +5123,10 @@ postcss-modules-values@^1.1.0: postcss "^6.0.1" postcss-nesting@^4.0.1: - version "4.1.0" - resolved "https://registry.yarnpkg.com/postcss-nesting/-/postcss-nesting-4.1.0.tgz#28ef1e7cf9d497618ad2e5fa4de25d4757da1653" + version "4.2.1" + resolved "https://registry.yarnpkg.com/postcss-nesting/-/postcss-nesting-4.2.1.tgz#0483bce338b3f0828ced90ff530b29b98b00300d" dependencies: - postcss "^6.0.1" + postcss "^6.0.11" postcss-normalize-charset@^1.1.0: version "1.1.1" @@ -5199,21 +5252,21 @@ postcss-zindex@^2.0.1: uniqs "^2.0.0" postcss@^5.0.10, postcss@^5.0.11, postcss@^5.0.12, postcss@^5.0.13, postcss@^5.0.14, postcss@^5.0.16, postcss@^5.0.2, postcss@^5.0.4, postcss@^5.0.5, postcss@^5.0.6, postcss@^5.0.8, postcss@^5.2.16: - version "5.2.17" - resolved "https://registry.yarnpkg.com/postcss/-/postcss-5.2.17.tgz#cf4f597b864d65c8a492b2eabe9d706c879c388b" + version "5.2.18" + resolved "https://registry.yarnpkg.com/postcss/-/postcss-5.2.18.tgz#badfa1497d46244f6390f58b319830d9107853c5" dependencies: chalk "^1.1.3" js-base64 "^2.1.9" source-map "^0.5.6" supports-color "^3.2.3" -postcss@^6.0.0, postcss@^6.0.1, postcss@^6.0.10, postcss@^6.0.2, postcss@^6.0.3, postcss@^6.0.5, postcss@^6.0.6: - version "6.0.10" - resolved "https://registry.yarnpkg.com/postcss/-/postcss-6.0.10.tgz#c311b89734483d87a91a56dc9e53f15f4e6e84e4" +postcss@^6.0.0, postcss@^6.0.1, postcss@^6.0.11, postcss@^6.0.13, postcss@^6.0.2, postcss@^6.0.5, postcss@^6.0.6: + version "6.0.13" + resolved "https://registry.yarnpkg.com/postcss/-/postcss-6.0.13.tgz#b9ecab4ee00c89db3ec931145bd9590bbf3f125f" dependencies: chalk "^2.1.0" - source-map "^0.5.7" - supports-color "^4.2.1" + source-map "^0.6.1" + supports-color "^4.4.0" prelude-ls@~1.1.2: version "1.1.2" @@ -5227,6 +5280,10 @@ preserve@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/preserve/-/preserve-0.2.0.tgz#815ed1f6ebc65926f865b310c0713bcb3315ce4b" +prettier@^1.7.0: + version "1.7.4" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.7.4.tgz#5e8624ae9363c80f95ec644584ecdf55d74f93fa" + pretty-error@^2.0.2, pretty-error@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/pretty-error/-/pretty-error-2.1.1.tgz#5f4f87c8f91e5ae3f3ba87ab4cf5e03b1a17f1a3" @@ -5276,22 +5333,18 @@ progress@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/progress/-/progress-2.0.0.tgz#8a1be366bf8fc23db2bd23f10c6fe920b4389d1f" -proto-list@~1.2.1: - version "1.2.4" - resolved "https://registry.yarnpkg.com/proto-list/-/proto-list-1.2.4.tgz#212d5bfe1318306a420f6402b8e26ff39647a849" - -proxy-addr@~1.1.5: - version "1.1.5" - resolved "https://registry.yarnpkg.com/proxy-addr/-/proxy-addr-1.1.5.tgz#71c0ee3b102de3f202f3b64f608d173fcba1a918" +proxy-addr@~2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/proxy-addr/-/proxy-addr-2.0.2.tgz#6571504f47bb988ec8180253f85dd7e14952bdec" dependencies: - forwarded "~0.1.0" - ipaddr.js "1.4.0" + forwarded "~0.1.2" + ipaddr.js "1.5.2" prr@~0.0.0: version "0.0.0" resolved "https://registry.yarnpkg.com/prr/-/prr-0.0.0.tgz#1a84b85908325501411853d0081ee3fa86e2926a" -pseudomap@^1.0.1, pseudomap@^1.0.2: +pseudomap@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/pseudomap/-/pseudomap-1.0.2.tgz#f052a28da70e618917ef0a8ac34c1ae5a68286b3" @@ -5313,13 +5366,17 @@ punycode@^1.2.4, punycode@^1.4.1: version "1.4.1" resolved "https://registry.yarnpkg.com/punycode/-/punycode-1.4.1.tgz#c0d5a63b2718800ad8e1eb0fa5269c84dd41845e" +punycode@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.0.tgz#5f863edc89b96db09074bad7947bf09056ca4e7d" + q@^1.1.2: version "1.5.0" resolved "https://registry.yarnpkg.com/q/-/q-1.5.0.tgz#dd01bac9d06d30e6f219aecb8253ee9ebdc308f1" -qs@6.5.0: - version "6.5.0" - resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.0.tgz#8d04954d364def3efc55b5a0793e1e2c8b1e6e49" +qs@6.5.1, qs@~6.5.1: + version "6.5.1" + resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.1.tgz#349cdf6eef89ec45c12d7d5eb3fc0c870343a6d8" qs@~6.4.0: version "6.4.0" @@ -5357,6 +5414,15 @@ range-parser@^1.0.3, range-parser@~1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/range-parser/-/range-parser-1.2.0.tgz#f49be6b487894ddc40dcc94a322f611092e00d5e" +raw-body@2.3.2: + version "2.3.2" + resolved "https://registry.yarnpkg.com/raw-body/-/raw-body-2.3.2.tgz#bcd60c77d3eb93cde0050295c3f379389bc88f89" + dependencies: + bytes "3.0.0" + http-errors "1.6.2" + iconv-lite "0.4.19" + unpipe "1.0.0" + rc@^1.0.1, rc@^1.1.6, rc@^1.1.7: version "1.2.1" resolved "https://registry.yarnpkg.com/rc/-/rc-1.2.1.tgz#2e03e8e42ee450b8cb3dce65be1bf8974e1dfd95" @@ -5461,8 +5527,8 @@ reduce-function-call@^1.0.1, reduce-function-call@^1.0.2: balanced-match "^0.4.2" regenerate@^1.2.1: - version "1.3.2" - resolved "https://registry.yarnpkg.com/regenerate/-/regenerate-1.3.2.tgz#d1941c67bad437e1be76433add5b385f95b19260" + version "1.3.3" + resolved "https://registry.yarnpkg.com/regenerate/-/regenerate-1.3.3.tgz#0c336d3980553d755c39b586ae3b20aa49c82b7f" regenerator-runtime@^0.10.0: version "0.10.5" @@ -5481,11 +5547,10 @@ regenerator-transform@^0.10.0: private "^0.1.6" regex-cache@^0.4.2: - version "0.4.3" - resolved "https://registry.yarnpkg.com/regex-cache/-/regex-cache-0.4.3.tgz#9b1a6c35d4d0dfcef5711ae651e8e9d3d7114145" + version "0.4.4" + resolved "https://registry.yarnpkg.com/regex-cache/-/regex-cache-0.4.4.tgz#75bdc58a2a1496cec48a12835bc54c8d562336dd" dependencies: is-equal-shallow "^0.1.3" - is-primitive "^2.0.0" regexpu-core@^1.0.0: version "1.0.0" @@ -5570,15 +5635,15 @@ request-promise-core@1.1.1: dependencies: lodash "^4.13.1" -request-promise-native@^1.0.3, request-promise-native@^1.0.4: - version "1.0.4" - resolved "https://registry.yarnpkg.com/request-promise-native/-/request-promise-native-1.0.4.tgz#86988ec8eee408e45579fce83bfd05b3adf9a155" +request-promise-native@^1.0.3, request-promise-native@^1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/request-promise-native/-/request-promise-native-1.0.5.tgz#5281770f68e0c9719e5163fd3fab482215f4fda5" dependencies: request-promise-core "1.1.1" stealthy-require "^1.1.0" - tough-cookie ">=2.3.0" + tough-cookie ">=2.3.3" -request@2.81.0, request@^2.79.0, request@^2.81.0: +request@2.81.0: version "2.81.0" resolved "https://registry.yarnpkg.com/request/-/request-2.81.0.tgz#c6928946a0e06c5f8d6f8a9333469ffda46298a0" dependencies: @@ -5605,6 +5670,33 @@ request@2.81.0, request@^2.79.0, request@^2.81.0: tunnel-agent "^0.6.0" uuid "^3.0.0" +request@^2.83.0: + version "2.83.0" + resolved "https://registry.yarnpkg.com/request/-/request-2.83.0.tgz#ca0b65da02ed62935887808e6f510381034e3356" + dependencies: + aws-sign2 "~0.7.0" + aws4 "^1.6.0" + caseless "~0.12.0" + combined-stream "~1.0.5" + extend "~3.0.1" + forever-agent "~0.6.1" + form-data "~2.3.1" + har-validator "~5.0.3" + hawk "~6.0.2" + http-signature "~1.2.0" + is-typedarray "~1.0.0" + isstream "~0.1.2" + json-stringify-safe "~5.0.1" + mime-types "~2.1.17" + oauth-sign "~0.8.2" + performance-now "^2.1.0" + qs "~6.5.1" + safe-buffer "^5.1.1" + stringstream "~0.0.5" + tough-cookie "~2.3.3" + tunnel-agent "^0.6.0" + uuid "^3.1.0" + require-directory@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42" @@ -5681,9 +5773,9 @@ right-align@^0.1.1: dependencies: align-text "^0.1.1" -rimraf@2, rimraf@^2.2.8, rimraf@^2.3.3, rimraf@^2.5.1, rimraf@^2.5.4, rimraf@^2.6.1: - version "2.6.1" - resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.6.1.tgz#c2338ec643df7a1b7fe5c54fa86f57428a55f33d" +rimraf@2, rimraf@^2.2.8, rimraf@^2.3.3, rimraf@^2.5.1, rimraf@^2.5.4, rimraf@^2.6.1, rimraf@^2.6.2: + version "2.6.2" + resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.6.2.tgz#2ed8150d24a16ea8651e6d6ef0f47c4158ce7a36" dependencies: glob "^7.0.5" @@ -5706,9 +5798,9 @@ rollup-plugin-babel@^3.0.2: dependencies: rollup-pluginutils "^1.5.0" -rollup-plugin-commonjs@^8.2.0: - version "8.2.0" - resolved "https://registry.yarnpkg.com/rollup-plugin-commonjs/-/rollup-plugin-commonjs-8.2.0.tgz#d7b16ebb9a36b754df888fc552dfa775c1174f9d" +rollup-plugin-commonjs@^8.2.1: + version "8.2.1" + resolved "https://registry.yarnpkg.com/rollup-plugin-commonjs/-/rollup-plugin-commonjs-8.2.1.tgz#5e40c78375eb163c14c76bce69da1750e5905a2e" dependencies: acorn "^5.1.1" estree-walker "^0.5.0" @@ -5765,6 +5857,16 @@ run-async@^2.2.0: dependencies: is-promise "^2.1.0" +rx-lite-aggregates@^4.0.8: + version "4.0.8" + resolved "https://registry.yarnpkg.com/rx-lite-aggregates/-/rx-lite-aggregates-4.0.8.tgz#753b87a89a11c95467c4ac1626c4efc4e05c67be" + dependencies: + rx-lite "*" + +rx-lite@*, rx-lite@^4.0.8: + version "4.0.8" + resolved "https://registry.yarnpkg.com/rx-lite/-/rx-lite-4.0.8.tgz#0b1e11af8bc44836f04a6407e92da42467b79444" + rx@^4.1.0: version "4.1.0" resolved "https://registry.yarnpkg.com/rx/-/rx-4.1.0.tgz#a5f13ff79ef3b740fe30aa803fb09f98805d4782" @@ -5801,19 +5903,19 @@ semver@5.3.0: version "5.3.0" resolved "https://registry.yarnpkg.com/semver/-/semver-5.3.0.tgz#9b2ce5d3de02d17c6012ad326aa6b4d0cf54f94f" -send@0.15.4: - version "0.15.4" - resolved "https://registry.yarnpkg.com/send/-/send-0.15.4.tgz#985faa3e284b0273c793364a35c6737bd93905b9" +send@0.16.1: + version "0.16.1" + resolved "https://registry.yarnpkg.com/send/-/send-0.16.1.tgz#a70e1ca21d1382c11d0d9f6231deb281080d7ab3" dependencies: - debug "2.6.8" + debug "2.6.9" depd "~1.1.1" destroy "~1.0.4" encodeurl "~1.0.1" escape-html "~1.0.3" - etag "~1.8.0" - fresh "0.5.0" + etag "~1.8.1" + fresh "0.5.2" http-errors "~1.6.2" - mime "1.3.4" + mime "1.4.1" ms "2.0.0" on-finished "~2.3.0" range-parser "~1.2.0" @@ -5823,14 +5925,14 @@ serialize-javascript@^1.3.0, serialize-javascript@^1.4.0: version "1.4.0" resolved "https://registry.yarnpkg.com/serialize-javascript/-/serialize-javascript-1.4.0.tgz#7c958514db6ac2443a8abc062dc9f7886a7f6005" -serve-static@1.12.4, serve-static@^1.12.4: - version "1.12.4" - resolved "https://registry.yarnpkg.com/serve-static/-/serve-static-1.12.4.tgz#9b6aa98eeb7253c4eedc4c1f6fdbca609901a961" +serve-static@1.13.1, serve-static@^1.13.1: + version "1.13.1" + resolved "https://registry.yarnpkg.com/serve-static/-/serve-static-1.13.1.tgz#4c57d53404a761d8f2e7c1e8a18a47dbf278a719" dependencies: encodeurl "~1.0.1" escape-html "~1.0.3" - parseurl "~1.3.1" - send "0.15.4" + parseurl "~1.3.2" + send "0.16.1" server-destroy@^1.0.1: version "1.0.1" @@ -5852,11 +5954,16 @@ setprototypeof@1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/setprototypeof/-/setprototypeof-1.0.3.tgz#66567e37043eeb4f04d91bd658c0cbefb55b8e04" +setprototypeof@1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/setprototypeof/-/setprototypeof-1.1.0.tgz#d0bd85536887b6fe7c0d818cb962d9d91c54e656" + sha.js@^2.4.0, sha.js@^2.4.8: - version "2.4.8" - resolved "https://registry.yarnpkg.com/sha.js/-/sha.js-2.4.8.tgz#37068c2c476b6baf402d14a49c67f597921f634f" + version "2.4.9" + resolved "https://registry.yarnpkg.com/sha.js/-/sha.js-2.4.9.tgz#98f64880474b74f4a38b8da9d3c0f2d104633e7d" dependencies: inherits "^2.0.1" + safe-buffer "^5.0.1" shebang-command@^1.2.0: version "1.2.0" @@ -5868,10 +5975,6 @@ shebang-regex@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-1.0.0.tgz#da42f49740c0b42db2ca9728571cb190c98efea3" -sigmund@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/sigmund/-/sigmund-1.0.1.tgz#3ff21f198cad2175f9f3b781853fd94d0d19b590" - signal-exit@^3.0.0, signal-exit@^3.0.1, signal-exit@^3.0.2: version "3.0.2" resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.2.tgz#b5fdc08f1287ea1178628e415e25132b73646c6d" @@ -5886,11 +5989,7 @@ slash@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/slash/-/slash-1.0.0.tgz#c41f2f6c39fc16d1cd17ad4b5d896114ae470d55" -slice-ansi@0.0.4: - version "0.0.4" - resolved "https://registry.yarnpkg.com/slice-ansi/-/slice-ansi-0.0.4.tgz#edbf8903f66f7ce2f8eafd6ceed65e264c831b35" - -slice-ansi@^1.0.0: +slice-ansi@1.0.0, slice-ansi@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/slice-ansi/-/slice-ansi-1.0.0.tgz#044f1a49d8842ff307aad6b505ed178bd950134d" dependencies: @@ -5906,6 +6005,12 @@ sntp@1.x.x: dependencies: hoek "2.x.x" +sntp@2.x.x: + version "2.0.2" + resolved "https://registry.yarnpkg.com/sntp/-/sntp-2.0.2.tgz#5064110f0af85f7cfdb7d6b67a40028ce52b4b2b" + dependencies: + hoek "4.x.x" + sort-keys@^1.0.0, sort-keys@^1.1.1: version "1.1.2" resolved "https://registry.yarnpkg.com/sort-keys/-/sort-keys-1.1.2.tgz#441b6d4d346798f1b4e49e8920adfba0e543f9ad" @@ -5923,22 +6028,22 @@ source-list-map@^2.0.0: resolved "https://registry.yarnpkg.com/source-list-map/-/source-list-map-2.0.0.tgz#aaa47403f7b245a92fbc97ea08f250d6087ed085" source-map-support@^0.4.0, source-map-support@^0.4.15: - version "0.4.16" - resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.4.16.tgz#16fecf98212467d017d586a2af68d628b9421cd8" + version "0.4.18" + resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.4.18.tgz#0286a6de8be42641338594e97ccea75f0a2c585f" dependencies: source-map "^0.5.6" -source-map-support@^0.4.17: - version "0.4.17" - resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.4.17.tgz#6f2150553e6375375d0ccb3180502b78c18ba430" +source-map-support@^0.5.0: + version "0.5.0" + resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.0.tgz#2018a7ad2bdf8faf2691e5fddab26bed5a2bacab" dependencies: - source-map "^0.5.6" + source-map "^0.6.0" source-map@0.5.6: version "0.5.6" resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.6.tgz#75ce38f52bf0733c5a7f0c118d81334a2bb5f412" -source-map@0.5.x, source-map@^0.5.0, source-map@^0.5.3, source-map@^0.5.6, source-map@^0.5.7, source-map@~0.5.1, source-map@~0.5.3: +source-map@0.5.x, source-map@^0.5.0, source-map@^0.5.3, source-map@^0.5.6, source-map@~0.5.1, source-map@~0.5.3, source-map@~0.5.6: version "0.5.7" resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc" @@ -5948,11 +6053,9 @@ source-map@^0.4.4: dependencies: amdefine ">=0.0.4" -source-map@~0.2.0: - version "0.2.0" - resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.2.0.tgz#dab73fbcfc2ba819b4de03bd6f6eaa48164b3f9d" - dependencies: - amdefine ">=0.0.4" +source-map@^0.6.0, source-map@^0.6.1: + version "0.6.1" + resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" spawn-wrap@^1.3.8: version "1.3.8" @@ -6058,7 +6161,7 @@ string-width@^1.0.1, string-width@^1.0.2: is-fullwidth-code-point "^1.0.0" strip-ansi "^3.0.0" -string-width@^2.0.0: +string-width@^2.0.0, string-width@^2.1.0, string-width@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/string-width/-/string-width-2.1.1.tgz#ab93f27a8dc13d28cac815c462143a6d9012ae9e" dependencies: @@ -6075,7 +6178,7 @@ string_decoder@~1.0.3: dependencies: safe-buffer "~5.1.0" -stringstream@~0.0.4: +stringstream@~0.0.4, stringstream@~0.0.5: version "0.0.5" resolved "https://registry.yarnpkg.com/stringstream/-/stringstream-0.0.5.tgz#4e484cd4de5a0bbbee18e46307710a8a81621878" @@ -6135,12 +6238,16 @@ supports-color@^3.1.2, supports-color@^3.2.3: dependencies: has-flag "^1.0.0" -supports-color@^4.0.0, supports-color@^4.2.1: - version "4.2.1" - resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-4.2.1.tgz#65a4bb2631e90e02420dba5554c375a4754bb836" +supports-color@^4.0.0, supports-color@^4.2.1, supports-color@^4.4.0: + version "4.4.0" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-4.4.0.tgz#883f7ddabc165142b2a61427f3352ded195d1a3e" dependencies: has-flag "^2.0.0" +svg-tags@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/svg-tags/-/svg-tags-1.0.0.tgz#58f71cee3bd519b59d4b2a843b6c7de64ac04764" + svgo@^0.7.0: version "0.7.2" resolved "https://registry.yarnpkg.com/svgo/-/svgo-0.7.2.tgz#9f5772413952135c6fefbf40afe6a4faa88b4bb5" @@ -6166,15 +6273,15 @@ symbol-tree@^3.2.1: resolved "https://registry.yarnpkg.com/symbol-tree/-/symbol-tree-3.2.2.tgz#ae27db38f660a7ae2e1c3b7d1bc290819b8519e6" table@^4.0.1: - version "4.0.1" - resolved "https://registry.yarnpkg.com/table/-/table-4.0.1.tgz#a8116c133fac2c61f4a420ab6cdf5c4d61f0e435" + version "4.0.2" + resolved "https://registry.yarnpkg.com/table/-/table-4.0.2.tgz#a33447375391e766ad34d3486e6e2aedc84d2e36" dependencies: - ajv "^4.7.0" - ajv-keywords "^1.0.0" - chalk "^1.1.1" - lodash "^4.0.0" - slice-ansi "0.0.4" - string-width "^2.0.0" + ajv "^5.2.3" + ajv-keywords "^2.1.0" + chalk "^2.1.0" + lodash "^4.17.4" + slice-ansi "1.0.0" + string-width "^2.1.1" tapable@^0.2.6, tapable@^0.2.7: version "0.2.8" @@ -6266,11 +6373,11 @@ timers-browserify@^2.0.2: dependencies: setimmediate "^1.0.4" -tmp@^0.0.31: - version "0.0.31" - resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.0.31.tgz#8f38ab9438e17315e5dbd8b3657e8bfb277ae4a7" +tmp@^0.0.33: + version "0.0.33" + resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.0.33.tgz#6d34335889768d21b2bcda0aa277ced3b1bfadf9" dependencies: - os-tmpdir "~1.0.1" + os-tmpdir "~1.0.2" to-arraybuffer@^1.0.0: version "1.0.1" @@ -6285,18 +6392,20 @@ to-fast-properties@^2.0.0: resolved "https://registry.yarnpkg.com/to-fast-properties/-/to-fast-properties-2.0.0.tgz#dc5e698cbd079265bc73e0377681a4e4e83f616e" toposort@^1.0.0: - version "1.0.3" - resolved "https://registry.yarnpkg.com/toposort/-/toposort-1.0.3.tgz#f02cd8a74bd8be2fc0e98611c3bacb95a171869c" + version "1.0.6" + resolved "https://registry.yarnpkg.com/toposort/-/toposort-1.0.6.tgz#c31748e55d210effc00fdcdc7d6e68d7d7bb9cec" -tough-cookie@>=2.3.0, tough-cookie@^2.3.2, tough-cookie@~2.3.0: - version "2.3.2" - resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-2.3.2.tgz#f081f76e4c85720e6c37a5faced737150d84072a" +tough-cookie@>=2.3.3, tough-cookie@^2.3.3, tough-cookie@~2.3.0, tough-cookie@~2.3.3: + version "2.3.3" + resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-2.3.3.tgz#0b618a5565b6dea90bf3425d04d55edc475a7561" dependencies: punycode "^1.4.1" -tr46@~0.0.3: - version "0.0.3" - resolved "https://registry.yarnpkg.com/tr46/-/tr46-0.0.3.tgz#8184fd347dac9cdc185992f3a6622e14b9d9ab6a" +tr46@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/tr46/-/tr46-1.0.1.tgz#a8b13fd6bfd2489519674ccde55ba3693b706d09" + dependencies: + punycode "^2.1.0" trim-newlines@^1.0.0: version "1.0.0" @@ -6345,9 +6454,9 @@ typedarray@^0.0.6: version "0.0.6" resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" -uglify-js@3.0.x, uglify-js@^3.0.28: - version "3.0.28" - resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.0.28.tgz#96b8495f0272944787b5843a1679aa326640d5f7" +uglify-js@3.1.x, uglify-js@^3.1.3: + version "3.1.3" + resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.1.3.tgz#d61f0453b4718cab01581f3162aa90bab7520b42" dependencies: commander "~2.11.0" source-map "~0.5.1" @@ -6424,7 +6533,7 @@ universalify@^0.1.0: version "0.1.1" resolved "https://registry.yarnpkg.com/universalify/-/universalify-0.1.1.tgz#fa71badd4437af4c148841e3b3b165f9e9e590b7" -unpipe@~1.0.0: +unpipe@1.0.0, unpipe@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/unpipe/-/unpipe-1.0.0.tgz#b2bf4ee8514aae6165b4817829d21b2ef49904ec" @@ -6449,12 +6558,13 @@ upper-case@^1.1.1: version "1.1.3" resolved "https://registry.yarnpkg.com/upper-case/-/upper-case-1.1.3.tgz#f6b4501c2ec4cdd26ba78be7222961de77621598" -url-loader@^0.5.9: - version "0.5.9" - resolved "https://registry.yarnpkg.com/url-loader/-/url-loader-0.5.9.tgz#cc8fea82c7b906e7777019250869e569e995c295" +url-loader@^0.6.2: + version "0.6.2" + resolved "https://registry.yarnpkg.com/url-loader/-/url-loader-0.6.2.tgz#a007a7109620e9d988d14bce677a1decb9a993f7" dependencies: loader-utils "^1.0.2" - mime "1.3.x" + mime "^1.4.1" + schema-utils "^0.3.0" url-parse-lax@^1.0.0: version "1.0.0" @@ -6491,11 +6601,11 @@ utila@~0.4: version "0.4.0" resolved "https://registry.yarnpkg.com/utila/-/utila-0.4.0.tgz#8a16a05d445657a3aea5eecc5b12a4fa5379772c" -utils-merge@1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/utils-merge/-/utils-merge-1.0.0.tgz#0294fb922bb9375153541c4f7096231f287c8af8" +utils-merge@1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/utils-merge/-/utils-merge-1.0.1.tgz#9f95710f50a267947b2ccc124741c1028427e713" -uuid@^3.0.0: +uuid@^3.0.0, uuid@^3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.1.0.tgz#3dd3d3e790abc24d7b0d3a034ffababe28ebbc04" @@ -6506,9 +6616,9 @@ validate-npm-package-license@^3.0.1: spdx-correct "~1.0.0" spdx-expression-parse "~1.0.0" -vary@~1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/vary/-/vary-1.1.1.tgz#67535ebb694c1d52257457984665323f587e8d37" +vary@~1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/vary/-/vary-1.1.2.tgz#2299f02c6ded30d4a5961b0b9f74524a18f634fc" vendors@^1.0.0: version "1.0.1" @@ -6527,8 +6637,8 @@ viewport-dimensions@^0.2.0: resolved "https://registry.yarnpkg.com/viewport-dimensions/-/viewport-dimensions-0.2.0.tgz#de740747db5387fd1725f5175e91bac76afdf36c" vlq@^0.2.1: - version "0.2.2" - resolved "https://registry.yarnpkg.com/vlq/-/vlq-0.2.2.tgz#e316d5257b40b86bb43cb8d5fea5d7f54d6b0ca1" + version "0.2.3" + resolved "https://registry.yarnpkg.com/vlq/-/vlq-0.2.3.tgz#8f3e4328cf63b1540c0d67e1b2778386f8975b26" vm-browserify@0.0.4: version "0.0.4" @@ -6537,30 +6647,30 @@ vm-browserify@0.0.4: indexof "0.0.1" vue-hot-reload-api@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/vue-hot-reload-api/-/vue-hot-reload-api-2.1.0.tgz#9ca58a6e0df9078554ce1708688b6578754d86de" + version "2.1.1" + resolved "https://registry.yarnpkg.com/vue-hot-reload-api/-/vue-hot-reload-api-2.1.1.tgz#1ba6712166182fd651753804b9d8d8d02d855579" -vue-loader@^13.0.4: - version "13.0.4" - resolved "https://registry.yarnpkg.com/vue-loader/-/vue-loader-13.0.4.tgz#0a6d893698735fcf7037b20a23d724cb39eee7d4" +vue-loader@^13.0.5: + version "13.0.5" + resolved "https://registry.yarnpkg.com/vue-loader/-/vue-loader-13.0.5.tgz#3639e9fb3940cded7f0fc34429277fb6de70a57c" dependencies: consolidate "^0.14.0" hash-sum "^1.0.2" - js-beautify "^1.6.14" loader-utils "^1.1.0" lru-cache "^4.1.1" postcss "^6.0.6" postcss-load-config "^1.1.0" postcss-selector-parser "^2.0.0" + prettier "^1.7.0" resolve "^1.3.3" source-map "^0.5.6" vue-hot-reload-api "^2.1.0" vue-style-loader "^3.0.0" vue-template-es2015-compiler "^1.5.3" -vue-meta@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/vue-meta/-/vue-meta-1.1.0.tgz#595922573de5e64203c7460f1902d5e7c93917b4" +vue-meta@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/vue-meta/-/vue-meta-1.2.0.tgz#f4cedccaae566ea0a27f052820dc076510d0080c" dependencies: deepmerge "^1.5.0" lodash.isplainobject "^4.0.6" @@ -6584,8 +6694,8 @@ vue-server-renderer@~2.4.4: source-map "0.5.6" vue-style-loader@^3.0.0: - version "3.0.1" - resolved "https://registry.yarnpkg.com/vue-style-loader/-/vue-style-loader-3.0.1.tgz#c8b639bb2f24baf9d78274dc17e4f264c1deda08" + version "3.0.3" + resolved "https://registry.yarnpkg.com/vue-style-loader/-/vue-style-loader-3.0.3.tgz#623658f81506aef9d121cdc113a4f5c9cac32df7" dependencies: hash-sum "^1.0.2" loader-utils "^1.0.2" @@ -6605,9 +6715,9 @@ vue@~2.4.4: version "2.4.4" resolved "https://registry.yarnpkg.com/vue/-/vue-2.4.4.tgz#ea9550b96a71465fd2b8b17b61673b3561861789" -vuex@^2.4.0: - version "2.4.0" - resolved "https://registry.yarnpkg.com/vuex/-/vuex-2.4.0.tgz#e1d0430646282b40007fdd06ec6ae88a9f5a1e14" +vuex@^2.4.1: + version "2.4.1" + resolved "https://registry.yarnpkg.com/vuex/-/vuex-2.4.1.tgz#7890b650ba8565b70937b4e7670577082dfe8bc1" watchpack@^1.4.0: version "1.4.0" @@ -6617,7 +6727,7 @@ watchpack@^1.4.0: chokidar "^1.7.0" graceful-fs "^4.1.2" -webidl-conversions@^4.0.0, webidl-conversions@^4.0.1: +webidl-conversions@^4.0.1, webidl-conversions@^4.0.2: version "4.0.2" resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-4.0.2.tgz#a855980b1f0b6b359ba1d5d9fb39ae941faa63ad" @@ -6647,9 +6757,9 @@ webpack-dev-middleware@^1.12.0: range-parser "^1.0.3" time-stamp "^2.0.0" -webpack-hot-middleware@^2.18.2: - version "2.18.2" - resolved "https://registry.yarnpkg.com/webpack-hot-middleware/-/webpack-hot-middleware-2.18.2.tgz#84dee643f037c3d59c9de142548430371aa8d3b2" +webpack-hot-middleware@^2.19.1: + version "2.19.1" + resolved "https://registry.yarnpkg.com/webpack-hot-middleware/-/webpack-hot-middleware-2.19.1.tgz#5db32c31c955c1ead114d37c7519ea554da0d405" dependencies: ansi-html "0.0.7" html-entities "^1.2.0" @@ -6667,9 +6777,9 @@ webpack-sources@^1.0.1: source-list-map "^2.0.0" source-map "~0.5.3" -webpack@^3.5.5: - version "3.5.5" - resolved "https://registry.yarnpkg.com/webpack/-/webpack-3.5.5.tgz#3226f09fc8b3e435ff781e7af34f82b68b26996c" +webpack@^3.6.0: + version "3.6.0" + resolved "https://registry.yarnpkg.com/webpack/-/webpack-3.6.0.tgz#a89a929fbee205d35a4fa2cc487be9cbec8898bc" dependencies: acorn "^5.0.0" acorn-dynamic-import "^2.0.0" @@ -6704,12 +6814,12 @@ whatwg-encoding@^1.0.1: dependencies: iconv-lite "0.4.13" -whatwg-url@^6.1.0: - version "6.1.0" - resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-6.1.0.tgz#5fc8279b93d75483b9ced8b26239854847a18578" +whatwg-url@^6.3.0: + version "6.3.0" + resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-6.3.0.tgz#597ee5488371abe7922c843397ddec1ae94c048d" dependencies: lodash.sortby "^4.7.0" - tr46 "~0.0.3" + tr46 "^1.0.0" webidl-conversions "^4.0.1" whet.extend@~0.9.9: @@ -6742,10 +6852,14 @@ window-size@0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/window-size/-/window-size-0.1.0.tgz#5438cd2ea93b202efa3a19fe8887aee7c94f9c9d" -wordwrap@0.0.2, wordwrap@~0.0.2: +wordwrap@0.0.2: version "0.0.2" resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-0.0.2.tgz#b79669bb42ecb409f83d583cad52ca17eaa1643f" +wordwrap@~0.0.2: + version "0.0.3" + resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-0.0.3.tgz#a3d5da6cd5c0bc0008d37234bbaf1bed63059107" + wordwrap@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-1.0.0.tgz#27584810891456a4171c8d0226441ade90cbcaeb" From 20992779af31b7ba972461915b8580c919484f99 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Sat, 7 Oct 2017 00:05:14 +0330 Subject: [PATCH 085/316] fix no-ssr client side test --- test/basic.test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/basic.test.js b/test/basic.test.js index ff9df26c0b..a35c7bf893 100755 --- a/test/basic.test.js +++ b/test/basic.test.js @@ -153,10 +153,10 @@ test('/no-ssr', async t => { t.true(html.includes('
<p>Loading...</p>
')) }) -test('/no-ssr (clien-side)', async t => { +test('/no-ssr (client-side)', async t => { const window = await nuxt.renderAndGetWindow(url('/no-ssr')) const html = window.document.body.innerHTML - t.true(html.includes('

Displayed only on client-side

')) + t.true(html.includes('Displayed only on client-side')) }) test('ETag Header', async t => { From f4695842629b672f5bf527b345e53ddc228e8eda Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Sat, 7 Oct 2017 11:56:00 +0330 Subject: [PATCH 086/316] test: mark generate with validate as todo #1705 --- test/basic.generate.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/basic.generate.test.js b/test/basic.generate.test.js index 313203637a..39f016293a 100644 --- a/test/basic.generate.test.js +++ b/test/basic.generate.test.js @@ -104,7 +104,7 @@ test('/validate -> should display a 404', async t => { t.true(html.includes('This page could not be found')) }) -test('/validate?valid=true', async t => { +test.failing('fix me (#1705)', '/validate?valid=true', async t => { const window = await nuxt.renderAndGetWindow(url('/validate?valid=true')) const html = window.document.body.innerHTML t.true(html.includes('I am valid')) From 45840bf064c41760d1db0ec7ea5cffaba0a66648 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Sat, 7 Oct 2017 12:07:21 +0330 Subject: [PATCH 087/316] appveyor --- test/basic.generate.test.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/test/basic.generate.test.js b/test/basic.generate.test.js index 39f016293a..5edb80d0d4 100644 --- a/test/basic.generate.test.js +++ b/test/basic.generate.test.js @@ -104,11 +104,12 @@ test('/validate -> should display a 404', async t => { t.true(html.includes('This page could not be found')) }) -test.failing('fix me (#1705)', '/validate?valid=true', async t => { - const window = await nuxt.renderAndGetWindow(url('/validate?valid=true')) - const html = window.document.body.innerHTML - t.true(html.includes('I am valid')) -}) +test.todo('/validate?valid=true (#1705)') +// test('/validate?valid=true', async t => { +// const window = await nuxt.renderAndGetWindow(url('/validate?valid=true')) +// const html = window.document.body.innerHTML +// t.true(html.includes('I am valid')) +// }) test('/redirect should not be server-rendered', async t => { const html = await rp(url('/redirect')) From 5f8be571726064b3cfcbb9a7fc624fe27ca6aac2 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Sat, 7 Oct 2017 12:21:28 +0330 Subject: [PATCH 088/316] workaround for appveyor memory limit --- test/ssr.test.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/ssr.test.js b/test/ssr.test.js index 82f3c15c27..267aaba508 100755 --- a/test/ssr.test.js +++ b/test/ssr.test.js @@ -14,6 +14,8 @@ const match = (regex, text) => (regex.exec(text) || [])[1] const url = (route) => 'http://localhost:' + port + route +const isWindows = /^win/.test(process.platform) + // Init nuxt.js and create server listening on localhost:4000 test.before('Init Nuxt.js', async t => { const options = { @@ -93,6 +95,12 @@ test('unique responses with fetch', async t => { const stressTest = async (t, _url, concurrency = 64, steps = 256) => { let statusCodes = { } + // appveyor memory limit! + if (isWindows) { + concurrency = 1 + steps = 1 + } + await Utils.sequence(range(steps), async () => { await Utils.parallel(range(concurrency), async () => { let response = await rp(url(_url), { resolveWithFullResponse: true }) From f6d09642d769af70169bf49c1b580e0f03d62435 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Sat, 7 Oct 2017 12:36:34 +0330 Subject: [PATCH 089/316] fix renderAndGetWindow for SPA mode --- lib/core/renderer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/core/renderer.js b/lib/core/renderer.js index 9e28ae2ddb..dd0b5ddf8e 100644 --- a/lib/core/renderer.js +++ b/lib/core/renderer.js @@ -579,7 +579,7 @@ export default class Renderer extends Tapable { url = url || 'http://localhost:3000' const { window } = await jsdom.JSDOM.fromURL(url, options) // If Nuxt could not be loaded (error from the server-side) - const nuxtExists = window.document.body.innerHTML.includes('window.__NUXT__') + const nuxtExists = window.document.body.innerHTML.includes(this.options.render.ssr ? 'window.__NUXT__' : '
') /* istanbul ignore if */ if (!nuxtExists) { let error = new Error('Could not load the nuxt app') From 75350cdd78d17e565b6c58d6c1aaa00c5146cbae Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Sat, 7 Oct 2017 12:37:52 +0330 Subject: [PATCH 090/316] test: add tests for spa --- test/fixtures/spa/layouts/custom.vue | 7 ++++++ test/fixtures/spa/nuxt.config.js | 5 ++++ test/fixtures/spa/pages/index.vue | 15 ++++++++++++ test/spa.test.js | 36 ++++++++++++++++++++++++++++ 4 files changed, 63 insertions(+) create mode 100644 test/fixtures/spa/layouts/custom.vue create mode 100644 test/fixtures/spa/nuxt.config.js create mode 100644 test/fixtures/spa/pages/index.vue create mode 100755 test/spa.test.js diff --git a/test/fixtures/spa/layouts/custom.vue b/test/fixtures/spa/layouts/custom.vue new file mode 100644 index 0000000000..5a02389c29 --- /dev/null +++ b/test/fixtures/spa/layouts/custom.vue @@ -0,0 +1,7 @@ + \ No newline at end of file diff --git a/test/fixtures/spa/nuxt.config.js b/test/fixtures/spa/nuxt.config.js new file mode 100644 index 0000000000..a17da47b52 --- /dev/null +++ b/test/fixtures/spa/nuxt.config.js @@ -0,0 +1,5 @@ +module.exports = { + rootDir: __dirname, + mode: 'spa', + dev: false +} diff --git a/test/fixtures/spa/pages/index.vue b/test/fixtures/spa/pages/index.vue new file mode 100644 index 0000000000..e903a5128f --- /dev/null +++ b/test/fixtures/spa/pages/index.vue @@ -0,0 +1,15 @@ + + + \ No newline at end of file diff --git a/test/spa.test.js b/test/spa.test.js new file mode 100755 index 0000000000..4dac8b0370 --- /dev/null +++ b/test/spa.test.js @@ -0,0 +1,36 @@ +import test from 'ava' +import { resolve } from 'path' +import { Nuxt, Builder } from '../index.js' + +let nuxt = null + +const port = 4004 +const url = (route) => 'http://localhost:' + port + route + +const renderRoute = async _url => { + const window = await nuxt.renderAndGetWindow(url(_url)) + const html = window.document.body.innerHTML + return { window, html } +} + +// Init nuxt.js and create server listening on localhost:4000 +test.before('Init Nuxt.js', async t => { + nuxt = new Nuxt(require('./fixtures/spa/nuxt.config')) + await new Builder(nuxt).build() + await nuxt.listen(port, 'localhost') +}) + +test('/ (basic spa)', async t => { + const { html } = await renderRoute('/') + t.true(html.includes('Hello SPA!')) +}) + +test('/ (custom layout)', async t => { + const { html } = await renderRoute('/') + t.true(html.includes('Custom layout')) +}) + +// Close server and ask nuxt to stop listening to file changes +test.after('Closing server and nuxt.js', t => { + nuxt.close() +}) From 870cbd6278918c326a8812e518cad1daf1753b2c Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Sat, 7 Oct 2017 13:13:09 +0330 Subject: [PATCH 091/316] rewrite App.vue with render function --- lib/app/App.vue | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/lib/app/App.vue b/lib/app/App.vue index 771bd613f7..0c00e2678b 100644 --- a/lib/app/App.vue +++ b/lib/app/App.vue @@ -1,12 +1,3 @@ - - \ No newline at end of file diff --git a/test/fixtures/spa/pages/index.vue b/test/fixtures/spa/pages/index.vue index e903a5128f..512da5741b 100644 --- a/test/fixtures/spa/pages/index.vue +++ b/test/fixtures/spa/pages/index.vue @@ -6,7 +6,6 @@ diff --git a/lib/app/components/nuxt-link.js b/lib/app/components/nuxt-link.js index c23fdd7ac3..fea5f308ce 100644 --- a/lib/app/components/nuxt-link.js +++ b/lib/app/components/nuxt-link.js @@ -1,5 +1,3 @@ -import Vue from 'vue' - export default { name: 'nuxt-link', functional: true, diff --git a/lib/app/components/nuxt.vue b/lib/app/components/nuxt.js similarity index 92% rename from lib/app/components/nuxt.vue rename to lib/app/components/nuxt.js index c392f882bf..068b1b16e5 100644 --- a/lib/app/components/nuxt.vue +++ b/lib/app/components/nuxt.js @@ -1,4 +1,3 @@ - diff --git a/lib/app/index.js b/lib/app/index.js index 05cf531221..ce1763aec2 100644 --- a/lib/app/index.js +++ b/lib/app/index.js @@ -6,9 +6,9 @@ import NoSSR from './components/no-ssr.js' import NuxtChild from './components/nuxt-child.js' import NuxtLink from './components/nuxt-link.js' import NuxtError from '<%= components.ErrorPage ? components.ErrorPage : "./components/nuxt-error.vue" %>' -import Nuxt from './components/nuxt.vue' +import Nuxt from './components/nuxt.js' import App from '<%= appPath %>' -import { getContext, getLocation } from './utils' +import { setContext, getLocation } from './utils' <% if (store) { %>import { createStore } from './store.js'<% } %> <% plugins.forEach(plugin => { %>import <%= plugin.name %> from '<%= plugin.name %>' <% }) %> @@ -37,7 +37,8 @@ const defaultTransition = <%= serialize(transition) .replace('beforeEnter(', 'function(').replace('enter(', 'function(').replace('afterEnter(', 'function(') .replace('enterCancelled(', 'function(').replace('beforeLeave(', 'function(').replace('leave(', 'function(') - .replace('afterLeave(', 'function(').replace('leaveCancelled(', 'function(') + .replace('afterLeave(', 'function(').replace('leaveCancelled(', 'function(').replace('beforeAppear(', 'function(') + .replace('appear(', 'function(').replace('afterAppear(', 'function(').replace('appearCancelled(', 'function(') %> async function createApp (ssrContext) { @@ -55,7 +56,7 @@ async function createApp (ssrContext) { const app = { router, <% if (store) { %>store,<% } %> - _nuxt: { + nuxt: { defaultTransition, transitions: [ defaultTransition ], setTransitions (transitions) { @@ -72,29 +73,30 @@ async function createApp (ssrContext) { } return transition }) - this.$options._nuxt.transitions = transitions + this.$options.nuxt.transitions = transitions return transitions }, err: null, dateErr: null, error (err) { err = err || null - if (typeof err === 'string') { - err = { statusCode: 500, message: err } - } - const _nuxt = this._nuxt || this.$options._nuxt - _nuxt.dateErr = Date.now() - _nuxt.err = err + if (typeof err === 'string') err = { statusCode: 500, message: err } + const nuxt = this.nuxt || this.$options.nuxt + nuxt.dateErr = Date.now() + nuxt.err = err + // Used in lib/server.js + if (ssrContext) ssrContext.nuxt.error = err return err } }, ...App } <% if (store) { %> - // Make app available in store + // Make app available into store via this.app store.app = app <% } %> const next = ssrContext ? ssrContext.next : location => app.router.push(location) + // Resolve route let route if (ssrContext) { route = router.resolve(ssrContext.url).route @@ -102,17 +104,19 @@ async function createApp (ssrContext) { const path = getLocation(router.options.base) route = router.resolve(path).route } - const ctx = getContext({ + + // Set context to app.context + await setContext(app, { isServer: !!ssrContext, isClient: !ssrContext, route, next, - error: app._nuxt.error.bind(app), - <% if (store) { %>store,<% } %> + error: app.nuxt.error.bind(app), + <% if (store) { %>store,<% } %> req: ssrContext ? ssrContext.req : undefined, res: ssrContext ? ssrContext.res : undefined, beforeRenderFns: ssrContext ? ssrContext.beforeRenderFns : undefined - }, app) + }) const inject = function (key, value) { if (!key) throw new Error('inject(key, value) has no key provided') @@ -120,11 +124,12 @@ async function createApp (ssrContext) { key = '$' + key // Add into app app[key] = value - // Add into vm + // Check if plugin not already installed + const installKey = '__nuxt_' + key + '_installed__' + if (Vue[installKey]) return + Vue[installKey] = true + // Call Vue.use() to install the plugin into vm Vue.use(() => { - const installKey = '__nuxt_' + key + '_installed__' - if (Vue[installKey]) return - Vue[installKey] = true if (!Vue.prototype.hasOwnProperty(key)) { Object.defineProperty(Vue.prototype, key, { get () { @@ -148,16 +153,15 @@ async function createApp (ssrContext) { } <% } %> + // Plugin execution <% plugins.filter(p => p.ssr).forEach(plugin => { %> - if (typeof <%= plugin.name %> === 'function') await <%= plugin.name %>(ctx, inject)<% }) %> + if (typeof <%= plugin.name %> === 'function') await <%= plugin.name %>(app.context, inject)<% }) %> <% if (plugins.filter(p => !p.ssr).length) { %> if (process.browser) { <% plugins.filter(p => !p.ssr).forEach(plugin => { %> - if (typeof <%= plugin.name %> === 'function') await <%= plugin.name %>(ctx, inject)<% }) %> + if (typeof <%= plugin.name %> === 'function') await <%= plugin.name %>(app.context, inject)<% }) %> }<% } %> - // Inject context - inject('ctx', ctx) - + // If server-side, wait for async component to be resolved first if (process.server && ssrContext && ssrContext.url) { await new Promise((resolve, reject) => { router.push(ssrContext.url, resolve, reject) diff --git a/lib/app/server.js b/lib/app/server.js index 01c62be7e6..427633defc 100644 --- a/lib/app/server.js +++ b/lib/app/server.js @@ -13,11 +13,11 @@ const isDev = <%= isDev %> const noopApp = () => new Vue({ render: (h) => h('div') }) -const createNext = context => opts => { - context.redirected = opts +const createNext = ssrContext => opts => { + ssrContext.redirected = opts // If nuxt generate - if (!context.res) { - context.nuxt.serverRendered = false + if (!ssrContext.res) { + ssrContext.nuxt.serverRendered = false return } opts.query = stringify(opts.query) @@ -26,14 +26,14 @@ const createNext = context => opts => { opts.path = urlJoin('<%= router.base %>', opts.path) } // Avoid loop redirect - if (opts.path === context.url) { - context.redirected = false + if (opts.path === ssrContext.url) { + ssrContext.redirected = false return } - context.res.writeHead(opts.status, { + ssrContext.res.writeHead(opts.status, { 'Location': opts.path }) - context.res.end() + ssrContext.res.end() } // This exported function will be called by `bundleRenderer`. @@ -41,137 +41,142 @@ const createNext = context => opts => { // state of our application before actually rendering it. // Since data fetching is async, this function is expected to // return a Promise that resolves to the app instance. -export default async context => { - // Create context.next for simulate next() of beforeEach() when wanted to redirect - context.redirected = false - context.next = createNext(context) - context.beforeRenderFns = [] +export default async ssrContext => { + // Create ssrContext.next for simulate next() of beforeEach() when wanted to redirect + ssrContext.redirected = false + ssrContext.next = createNext(ssrContext) + // Used for beforeNuxtRender({ Components, nuxtState }) + ssrContext.beforeRenderFns = [] - const { app, router<%= (store ? ', store' : '') %> } = await createApp(context) + // Create the app definition and the instance (created for each request) + const { app, router<%= (store ? ', store' : '') %> } = await createApp(ssrContext) const _app = new Vue(app) - <% if (store) { %> - // Add store to the context - context.store = store - <% } %> + // Nuxt object (window.__NUXT__) + ssrContext.nuxt = { layout: 'default', data: [], error: null<%= (store ? ', state: null' : '') %>, serverRendered: true } + // Add meta infos (used in renderer.js) + ssrContext.meta = _app.$meta() + // Keep asyncData for each matched component in ssrContext (used in app/utils.js via this.$ssrContext) + ssrContext.asyncData = {} - // Add route to the context - context.route = router.currentRoute - - // Nuxt object - context.nuxt = { layout: 'default', data: [], error: null<%= (store ? ', state: null' : '') %>, serverRendered: true } - - // Add meta infos - context.meta = _app.$meta() - - // Error function - context.error = _app.$options._nuxt.error.bind(_app) - - // Keep asyncData for each matched component in context - context.asyncData = {} - - // Create shared ctx - const ctx = getContext(context, app) + const beforeRender = async () => { + // Call beforeNuxtRender() methods + await Promise.all(ssrContext.beforeRenderFns.map((fn) => promisify(fn, { Components, nuxtState: ssrContext.nuxt }))) + <% if (store) { %> + // Add the state from the vuex store + ssrContext.nuxt.state = store.state + <% } %> + } + const renderErrorPage = async () => { + // Load layout for error page + let errLayout = (typeof NuxtError.layout === 'function' ? NuxtError.layout(app.context) : NuxtError.layout) + ssrContext.nuxt.layout = errLayout || '' + await _app.loadLayout(errLayout) + _app.setLayout(errLayout) + await beforeRender() + return _app + } + const render404Page = async () => { + app.context.error({ statusCode: 404, message: '<%= messages.error_404 %>' }) + return await renderErrorPage() + } <% if (isDev) { %>const s = isDev && Date.now()<% } %> - // Resolve components - let Components = [] - try { - Components = await Promise.all(getMatchedComponents(router.match(context.url)).map(Component => { - if (typeof Component !== 'function' || Component.cid) { - return sanitizeComponent(Component) - } - return Component().then(Component => sanitizeComponent(Component)) - })) - } catch (err) { - // Throw back error to renderRoute() - throw err - } + // Components are already resolved by setContext -> getRouteData (app/utils.js) + const Components = getMatchedComponents(router.match(ssrContext.url)) <% if (store) { %> - // Dispatch store nuxtServerInit + /* + ** Dispatch store nuxtServerInit + */ if (store._actions && store._actions.nuxtServerInit) { - await store.dispatch('nuxtServerInit', ctx) + await store.dispatch('nuxtServerInit', app.context) } - // ...If there is a redirect - if (context.redirected) return noopApp() + // ...If there is a redirect or an error, stop the process + if (ssrContext.redirected) return noopApp() + if (ssrContext.nuxt.error) return await renderErrorPage() <% } %> - // Call global middleware (nuxt.config.js) + /* + ** Call global middleware (nuxt.config.js) + */ let midd = <%= serialize(router.middleware, { isJSON: true }) %> midd = midd.map((name) => { if (typeof middleware[name] !== 'function') { - context.nuxt.error = context.error({ statusCode: 500, message: 'Unknown middleware ' + name }) + ssrContext.error({ statusCode: 500, message: 'Unknown middleware ' + name }) } return middleware[name] }) - if (!context.nuxt.error) { - await middlewareSeries(midd, ctx) - } - // ...If there is a redirect - if (context.redirected) return noopApp() + await middlewareSeries(midd, app.context) + // ...If there is a redirect or an error, stop the process + if (ssrContext.redirected) return noopApp() + if (ssrContext.nuxt.error) return await renderErrorPage() - // Set layout + /* + ** Set layout + */ let layout = Components.length ? Components[0].options.layout : NuxtError.layout - if (typeof layout === 'function') layout = layout(ctx) + if (typeof layout === 'function') layout = layout(app.context) await _app.loadLayout(layout) layout = _app.setLayout(layout) // ...Set layout to __NUXT__ - context.nuxt.layout = _app.layoutName + ssrContext.nuxt.layout = _app.layoutName - // Call middleware (layout + pages) - if (!context.nuxt.error) { - midd = [] - if (layout.middleware) midd = midd.concat(layout.middleware) - Components.forEach((Component) => { - if (Component.options.middleware) { - midd = midd.concat(Component.options.middleware) - } - }) - midd = midd.map((name) => { - if (typeof middleware[name] !== 'function') { - context.nuxt.error = context.error({ statusCode: 500, message: 'Unknown middleware ' + name }) - } - return middleware[name] - }) + /* + ** Call middleware (layout + pages) + */ + midd = [] + if (layout.middleware) midd = midd.concat(layout.middleware) + Components.forEach((Component) => { + if (Component.options.middleware) { + midd = midd.concat(Component.options.middleware) + } + }) + midd = midd.map((name) => { + if (typeof middleware[name] !== 'function') { + app.context.error({ statusCode: 500, message: 'Unknown middleware ' + name }) + } + return middleware[name] + }) + await middlewareSeries(midd, app.context) + // ...If there is a redirect or an error, stop the process + if (ssrContext.redirected) return noopApp() + if (ssrContext.nuxt.error) return await renderErrorPage() - await middlewareSeries(midd, ctx) - - // If there is a redirect - if (context.redirected) return noopApp() - } - - // Call .validate() + /* + ** Call .validate() + */ let isValid = true Components.forEach((Component) => { if (!isValid) return if (typeof Component.options.validate !== 'function') return isValid = Component.options.validate({ - params: context.route.params || {}, - query: context.route.query || {}, - <%= (store ? 'store: ctx.store' : '') %> + params: app.context.route.params || {}, + query: app.context.route.query || {}, + <%= (store ? 'store' : '') %> }) }) // ...If .validate() returned false if (!isValid) { // Don't server-render the page in generate mode - if (context._generate) { - context.nuxt.serverRendered = false - } - // Call the 404 error by making the Components array empty - Components = [] + if (ssrContext._generate) ssrContext.nuxt.serverRendered = false + // Render a 404 error page + return render404Page() } + // If no Components found, returns 404 + if (!Components.length) return render404Page() + // Call asyncData & fetch hooks on components matched by the route. let asyncDatas = await Promise.all(Components.map(Component => { let promises = [] // Call asyncData(context) if (Component.options.asyncData && typeof Component.options.asyncData === 'function') { - let promise = promisify(Component.options.asyncData, ctx) + let promise = promisify(Component.options.asyncData, app.context) promise.then(asyncDataResult => { - context.asyncData[Component.cid] = asyncDataResult + ssrContext.asyncData[Component.cid] = asyncDataResult applyAsyncData(Component) return asyncDataResult }) @@ -182,7 +187,7 @@ export default async context => { // Call fetch(context) if (Component.options.fetch) { - promises.push(Component.options.fetch(ctx)) + promises.push(Component.options.fetch(app.context)) } else { promises.push(null) @@ -191,38 +196,17 @@ export default async context => { return Promise.all(promises) })) - // If no Components found, returns 404 - if (!Components.length) { - context.nuxt.error = context.error({ statusCode: 404, message: '<%= messages.error_404 %>' }) - } - - <% if (isDev) { %>if (asyncDatas.length) debug('Data fetching ' + context.url + ': ' + (Date.now() - s) + 'ms')<% } %> + <% if (isDev) { %>if (asyncDatas.length) debug('Data fetching ' + ssrContext.url + ': ' + (Date.now() - s) + 'ms')<% } %> // datas are the first row of each - context.nuxt.data = asyncDatas.map(r => r[0] || {}) + ssrContext.nuxt.data = asyncDatas.map(r => r[0] || {}) - // If an error occured in the execution - if (_app.$options._nuxt.err) { - context.nuxt.error = _app.$options._nuxt.err - } - - <% if (store) { %> - // Add the state from the vuex store - context.nuxt.state = store.state - <% } %> - - await Promise.all(context.beforeRenderFns.map((fn) => promisify(fn, { Components, nuxtState: context.nuxt }))) - - // If no error, return main app - if (!context.nuxt.error) { - return _app - } - - // Load layout for error page - layout = (typeof NuxtError.layout === 'function' ? NuxtError.layout(ctx) : NuxtError.layout) - context.nuxt.layout = layout || '' - await _app.loadLayout(layout) - _app.setLayout(layout) + // ...If there is a redirect or an error, stop the process + if (ssrContext.redirected) return noopApp() + if (ssrContext.nuxt.error) return await renderErrorPage() + // Call beforeNuxtRender methods & add store state + await beforeRender() + return _app } diff --git a/lib/app/utils.js b/lib/app/utils.js index d98304dd73..bffc4fba74 100644 --- a/lib/app/utils.js +++ b/lib/app/utils.js @@ -11,7 +11,7 @@ if (process.browser) { } } -export function applyAsyncData (Component, asyncData) { +export function applyAsyncData(Component, asyncData) { const ComponentData = Component.options.data || noopData // Prevent calling this method for each request on SSR context if (!asyncData && Component.options.hasAsyncData) { @@ -30,7 +30,11 @@ export function applyAsyncData (Component, asyncData) { } } -export function sanitizeComponent (Component) { +export function sanitizeComponent(Component) { + // If Component already sanitized + if (Component.options && Component._Ctor === Component) { + return Component + } if (!Component.options) { Component = Vue.extend(Component) // fix issue #6 Component._Ctor = Component @@ -45,7 +49,7 @@ export function sanitizeComponent (Component) { return Component } -export function getMatchedComponents (route) { +export function getMatchedComponents(route) { return [].concat.apply([], route.matched.map(function (m) { return Object.keys(m.components).map(function (key) { return m.components[key] @@ -53,7 +57,7 @@ export function getMatchedComponents (route) { })) } -export function getMatchedComponentsInstances (route) { +export function getMatchedComponentsInstances(route) { return [].concat.apply([], route.matched.map(function (m) { return Object.keys(m.instances).map(function (key) { return m.instances[key] @@ -61,7 +65,7 @@ export function getMatchedComponentsInstances (route) { })) } -export function flatMapComponents (route, fn) { +export function flatMapComponents(route, fn) { return Array.prototype.concat.apply([], route.matched.map(function (m, index) { return Object.keys(m.components).map(function (key) { return fn(m.components[key], m.instances[key], m, key, index) @@ -69,53 +73,79 @@ export function flatMapComponents (route, fn) { })) } -export function getContext (context, app) { - let ctx = { - isServer: !!context.isServer, - isClient: !!context.isClient, - isStatic: process.static, - isDev: <%= isDev %>, - isHMR: context.isHMR || false, - app: app, - <%= (store ? 'store: context.store,' : '') %> - route: (context.to ? context.to : context.route), - payload: context.payload, - error: context.error, - base: '<%= router.base %>', - env: <%= JSON.stringify(env) %> - } - const next = context.next - ctx.params = ctx.route.params || {} - ctx.query = ctx.route.query || {} - ctx.redirect = function (status, path, query) { - if (!status) return - ctx._redirected = true // Used in middleware - // if only 1 or 2 arguments: redirect('/') or redirect('/', { foo: 'bar' }) - if (typeof status === 'string' && (typeof path === 'undefined' || typeof path === 'object')) { - query = path || {} - path = status - status = 302 - } - next({ - path: path, - query: query, - status: status +export async function resolveRouteComponents(route) { + await Promise.all( + flatMapComponents(route, async (Component, _, match, key) => { + // If component is a function, resolve it + if (typeof Component === 'function' && !Component.options) { + Component = await Component() + } + return match.components[key] = sanitizeComponent(Component) }) - } - if (context.req) ctx.req = context.req - if (context.res) ctx.res = context.res - if (context.from) ctx.from = context.from - if (ctx.isServer && context.beforeRenderFns) { - ctx.beforeNuxtRender = (fn) => context.beforeRenderFns.push(fn) - } - if (ctx.isClient && window.__NUXT__) { - ctx.nuxtState = window.__NUXT__ - } - return ctx + ) } -export function middlewareSeries (promises, context) { - if (!promises.length || context._redirected) { +async function getRouteData(route) { + // Make sure the components are resolved (code-splitting) + await resolveRouteComponents(route) + // Send back a copy of route with meta based on Component definition + return { + ...route, + meta: getMatchedComponents(route).map((Component) => { + return Component.options.meta || {} + }) + } +} + +export async function setContext(app, context) { + const route = (context.to ? context.to : context.route) + // If context not defined, create it + if (!app.context) { + app.context = { + isServer: !!context.isServer, + isClient: !!context.isClient, + isStatic: process.static, + isDev: <%= isDev %>, + isHMR: false, + app, + <%= (store ? 'store: app.store,' : '') %> + payload: context.payload, + error: context.error, + base: '<%= router.base %>', + env: <%= JSON.stringify(env) %> + } + // Only set once + if (context.req) app.context.req = context.req + if (context.res) app.context.res = context.res + app.context.redirect = function (status, path, query) { + if (!status) return + ctx._redirected = true // Used in middleware + // if only 1 or 2 arguments: redirect('/') or redirect('/', { foo: 'bar' }) + if (typeof status === 'string' && (typeof path === 'undefined' || typeof path === 'object')) { + query = path || {} + path = status + status = 302 + } + app.context.next({ + path: path, + query: query, + status: status + }) + } + if (app.context.isServer) app.context.beforeNuxtRender = (fn) => context.beforeRenderFns.push(fn) + if (app.context.isClient) app.context.nuxtState = window.__NUXT__ + } + // Dynamic keys + app.context.next = context.next + app.context.isHMR = !!context.isHMR + if (context.route) app.context.route = await getRouteData(context.route) + app.context.params = app.context.route.params || {} + app.context.query = app.context.route.query || {} + if (context.from) app.context.from = await getRouteData(context.from) +} + +export function middlewareSeries(promises, appContext) { + if (!promises.length || appContext._redirected || appContext.app.nuxt.err) { return Promise.resolve() } return promisify(promises[0], context) @@ -124,7 +154,7 @@ export function middlewareSeries (promises, context) { }) } -export function promisify (fn, context) { +export function promisify(fn, context) { let promise if (fn.length === 2) { // fn(context, callback) @@ -147,7 +177,7 @@ export function promisify (fn, context) { } // Imported from vue-router -export function getLocation (base, mode) { +export function getLocation(base, mode) { var path = window.location.pathname if (mode === 'hash') { return window.location.hash.replace(/^#\//, '') @@ -158,7 +188,7 @@ export function getLocation (base, mode) { return (path || '/') + window.location.search + window.location.hash } -export function urlJoin () { +export function urlJoin() { return [].slice.call(arguments).join('/').replace(/\/+/g, '/') } @@ -171,7 +201,7 @@ export function urlJoin () { * @param {Object=} options * @return {!function(Object=, Object=)} */ -export function compile (str, options) { +export function compile(str, options) { return tokensToFunction(parse(str, options)) } @@ -200,7 +230,7 @@ const PATH_REGEXP = new RegExp([ * @param {Object=} options * @return {!Array} */ -function parse (str, options) { +function parse(str, options) { var tokens = [] var key = 0 var index = 0 @@ -272,7 +302,7 @@ function parse (str, options) { * @param {string} * @return {string} */ -function encodeURIComponentPretty (str) { +function encodeURIComponentPretty(str) { return encodeURI(str).replace(/[\/?#]/g, function (c) { return '%' + c.charCodeAt(0).toString(16).toUpperCase() }) @@ -284,7 +314,7 @@ function encodeURIComponentPretty (str) { * @param {string} * @return {string} */ -function encodeAsterisk (str) { +function encodeAsterisk(str) { return encodeURI(str).replace(/[?#]/g, function (c) { return '%' + c.charCodeAt(0).toString(16).toUpperCase() }) @@ -293,7 +323,7 @@ function encodeAsterisk (str) { /** * Expose a method for transforming tokens into the path function. */ -function tokensToFunction (tokens) { +function tokensToFunction(tokens) { // Compile all the tokens into regexps. var matches = new Array(tokens.length) @@ -304,7 +334,7 @@ function tokensToFunction (tokens) { } } - return function (obj, opts) { + return function(obj, opts) { var path = '' var data = obj || {} var options = opts || {} @@ -380,7 +410,7 @@ function tokensToFunction (tokens) { * @param {string} str * @return {string} */ -function escapeString (str) { +function escapeString(str) { return str.replace(/([.+*?=^!:${}()[\]|\/\\])/g, '\\$1') } @@ -390,6 +420,6 @@ function escapeString (str) { * @param {string} group * @return {string} */ -function escapeGroup (group) { +function escapeGroup(group) { return group.replace(/([=!:$\/()])/g, '\\$1') } diff --git a/lib/builder/builder.js b/lib/builder/builder.js index 25b280796e..a9ec11e2dd 100644 --- a/lib/builder/builder.js +++ b/lib/builder/builder.js @@ -184,7 +184,7 @@ export default class Builder extends Tapable { debug('Generating files...') // -- Templates -- let templatesFiles = [ - 'App.vue', + 'App.js', 'client.js', 'index.js', 'middleware.js', @@ -196,7 +196,7 @@ export default class Builder extends Tapable { 'components/nuxt-loading.vue', 'components/nuxt-child.js', 'components/nuxt-link.js', - 'components/nuxt.vue', + 'components/nuxt.js', 'components/no-ssr.js', 'views/app.template.html', 'views/error.html' @@ -215,7 +215,7 @@ export default class Builder extends Tapable { store: this.options.store, css: this.options.css, plugins: this.plugins, - appPath: './App.vue', + appPath: './App.js', layouts: Object.assign({}, this.options.layouts), loading: typeof this.options.loading === 'string' ? this.relativeToBuild(this.options.srcDir, this.options.loading) : this.options.loading, transition: this.options.transition, From cfc9eff3c7cbd2ac2272923eb3a8102f8a739b2b Mon Sep 17 00:00:00 2001 From: sdras Date: Sat, 14 Oct 2017 13:03:03 -0400 Subject: [PATCH 100/316] update gitignore --- .gitignore | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 9b8a0a54a8..6b2d6f7e1d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,18 +1,21 @@ -# dependencies +# Dependencies node_modules examples/**/*/yarn.lock +jspm_packages +package-lock.json -# logs +# Logs *.log +npm-debug.log* -# other +# Other .nuxt .cache # Dist folder dist -# dist example generation +# Dist example generation examples/**/dist # Coverage support @@ -25,5 +28,23 @@ coverage *.iml .idea -# Macos -.DS_Store +# OSX +*.DS_Store +.AppleDouble +.LSOverride + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk \ No newline at end of file From 0b46b06c7c62f81c904cf7452eedb895afcd3e06 Mon Sep 17 00:00:00 2001 From: FieryCod Date: Sun, 15 Oct 2017 21:31:01 +0200 Subject: [PATCH 101/316] Adds support for folders in /layouts --- lib/builder/builder.js | 4 ++-- .../with-config/layouts/desktop/default.vue | 20 ++++++++++++++++++ .../with-config/layouts/mobile/default.vue | 21 +++++++++++++++++++ test/fixtures/with-config/pages/desktop.vue | 12 +++++++++++ test/fixtures/with-config/pages/mobile.vue | 12 +++++++++++ test/with-config.test.js | 18 +++++++++++++++- 6 files changed, 84 insertions(+), 3 deletions(-) create mode 100644 test/fixtures/with-config/layouts/desktop/default.vue create mode 100644 test/fixtures/with-config/layouts/mobile/default.vue create mode 100644 test/fixtures/with-config/pages/desktop.vue create mode 100644 test/fixtures/with-config/pages/mobile.vue diff --git a/lib/builder/builder.js b/lib/builder/builder.js index 655b3a85f9..c85c5c7b5c 100644 --- a/lib/builder/builder.js +++ b/lib/builder/builder.js @@ -227,10 +227,10 @@ export default class Builder extends Tapable { // -- Layouts -- if (fs.existsSync(resolve(this.options.srcDir, 'layouts'))) { - const layoutsFiles = await glob('layouts/*.vue', { cwd: this.options.srcDir }) + const layoutsFiles = await glob('layouts/**/*.vue', { cwd: this.options.srcDir }) let hasErrorLayout = false layoutsFiles.forEach((file) => { - let name = file.split('/').slice(-1)[0].replace(/\.vue$/, '') + let name = file.split('/').slice(1).join('/').replace(/\.vue$/, '') if (name === 'error') { hasErrorLayout = true return diff --git a/test/fixtures/with-config/layouts/desktop/default.vue b/test/fixtures/with-config/layouts/desktop/default.vue new file mode 100644 index 0000000000..329274e836 --- /dev/null +++ b/test/fixtures/with-config/layouts/desktop/default.vue @@ -0,0 +1,20 @@ + + + diff --git a/test/fixtures/with-config/layouts/mobile/default.vue b/test/fixtures/with-config/layouts/mobile/default.vue new file mode 100644 index 0000000000..548fe9b27b --- /dev/null +++ b/test/fixtures/with-config/layouts/mobile/default.vue @@ -0,0 +1,21 @@ + + + + diff --git a/test/fixtures/with-config/pages/desktop.vue b/test/fixtures/with-config/pages/desktop.vue new file mode 100644 index 0000000000..4c0951062e --- /dev/null +++ b/test/fixtures/with-config/pages/desktop.vue @@ -0,0 +1,12 @@ + + + + diff --git a/test/fixtures/with-config/pages/mobile.vue b/test/fixtures/with-config/pages/mobile.vue new file mode 100644 index 0000000000..915e603c6e --- /dev/null +++ b/test/fixtures/with-config/pages/mobile.vue @@ -0,0 +1,12 @@ + + + + diff --git a/test/with-config.test.js b/test/with-config.test.js index 579affa5cd..c0bfe0674b 100644 --- a/test/with-config.test.js +++ b/test/with-config.test.js @@ -61,6 +61,22 @@ test('/test/about (custom layout)', async t => { t.true(html.includes('

About page

')) }) +test('/test/desktop (custom layout in desktop folder)', async t => { + const window = await nuxt.renderAndGetWindow(url('/test/desktop')) + const html = window.document.body.innerHTML + t.is(window.__NUXT__.layout, 'desktop/default') + t.true(html.includes('

Default desktop layout

')) + t.true(html.includes('

Desktop page

')) +}) + +test('/test/mobile (custom layout in mobile folder)', async t => { + const window = await nuxt.renderAndGetWindow(url('/test/mobile')) + const html = window.document.body.innerHTML + t.is(window.__NUXT__.layout, 'mobile/default') + t.true(html.includes('

Default mobile layout

')) + t.true(html.includes('

Mobile page

')) +}) + test('/test/env', async t => { const window = await nuxt.renderAndGetWindow(url('/test/env')) const html = window.document.body.innerHTML @@ -95,7 +111,7 @@ test('/test/about-bis (added with extendRoutes)', async t => { test('Check stats.json generated by build.analyze', t => { const stats = require(resolve(__dirname, 'fixtures/with-config/.nuxt/dist/stats.json')) - t.is(stats.assets.length, 27) + t.is(stats.assets.length, 35) }) test('Check /test/test.txt with custom serve-static options', async t => { From efd044fad663241695d9c5f1fc558e563528a268 Mon Sep 17 00:00:00 2001 From: Clark Du Date: Mon, 16 Oct 2017 11:08:33 +0800 Subject: [PATCH 102/316] chore: upgrade vue to 2.5.x --- package.json | 8 ++++---- start/package.json | 4 ++-- yarn.lock | 24 ++++++++++++------------ 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/package.json b/package.json index d1e3fb782b..92befe2339 100644 --- a/package.json +++ b/package.json @@ -109,13 +109,13 @@ "source-map-support": "^0.5.0", "tappable": "^1.1.0", "url-loader": "^0.6.2", - "vue": "~2.4.4", + "vue": "~2.5.2", "vue-loader": "^13.0.5", "vue-meta": "^1.2.0", "vue-router": "^2.7.0", - "vue-server-renderer": "~2.4.4", - "vue-template-compiler": "~2.4.4", - "vuex": "^2.4.1", + "vue-server-renderer": "~2.5.2", + "vue-template-compiler": "~2.5.2", + "vuex": "^3.0.0", "webpack": "^3.6.0", "webpack-bundle-analyzer": "^2.9.0", "webpack-dev-middleware": "^1.12.0", diff --git a/start/package.json b/start/package.json index 49f2857e24..c3a0b495a8 100644 --- a/start/package.json +++ b/start/package.json @@ -62,11 +62,11 @@ "serve-static": "^1.13.1", "compression": "^1.7.1", "fs-extra": "^4.0.2", - "vue-server-renderer": "~2.4.4", + "vue-server-renderer": "~2.5.2", "@nuxtjs/youch": "3.1.0", "source-map": "^0.6.1", "connect": "^3.6.5", - "vue": "~2.4.4", + "vue": "~2.5.2", "vue-meta": "^1.2.0", "lru-cache": "^4.1.1", "server-destroy": "^1.0.1", diff --git a/yarn.lock b/yarn.lock index 2fc4e425be..9d2a96d2c4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6680,9 +6680,9 @@ vue-router@^2.7.0: version "2.7.0" resolved "https://registry.yarnpkg.com/vue-router/-/vue-router-2.7.0.tgz#16d424493aa51c3c8cce8b7c7210ea4c3a89aff1" -vue-server-renderer@~2.4.4: - version "2.4.4" - resolved "https://registry.yarnpkg.com/vue-server-renderer/-/vue-server-renderer-2.4.4.tgz#bd59cf4e42dfaf2c9e388af8837b5420dd51360d" +vue-server-renderer@~2.5.2: + version "2.5.2" + resolved "https://registry.yarnpkg.com/vue-server-renderer/-/vue-server-renderer-2.5.2.tgz#c96a4368caa3fd298a528f1bf40632d8f696ff25" dependencies: chalk "^1.1.3" hash-sum "^1.0.2" @@ -6700,9 +6700,9 @@ vue-style-loader@^3.0.0: hash-sum "^1.0.2" loader-utils "^1.0.2" -vue-template-compiler@~2.4.4: - version "2.4.4" - resolved "https://registry.yarnpkg.com/vue-template-compiler/-/vue-template-compiler-2.4.4.tgz#2cde3b704124985c27d50b5387c9691ba515fb57" +vue-template-compiler@~2.5.2: + version "2.5.2" + resolved "https://registry.yarnpkg.com/vue-template-compiler/-/vue-template-compiler-2.5.2.tgz#6f198ebc677b8f804315cd33b91e849315ae7177" dependencies: de-indent "^1.0.2" he "^1.1.0" @@ -6711,13 +6711,13 @@ vue-template-es2015-compiler@^1.5.3: version "1.5.3" resolved "https://registry.yarnpkg.com/vue-template-es2015-compiler/-/vue-template-es2015-compiler-1.5.3.tgz#22787de4e37ebd9339b74223bc467d1adee30545" -vue@~2.4.4: - version "2.4.4" - resolved "https://registry.yarnpkg.com/vue/-/vue-2.4.4.tgz#ea9550b96a71465fd2b8b17b61673b3561861789" +vue@~2.5.2: + version "2.5.2" + resolved "https://registry.yarnpkg.com/vue/-/vue-2.5.2.tgz#fd367a87bae7535e47f9dc5c9ec3b496e5feb5a4" -vuex@^2.4.1: - version "2.4.1" - resolved "https://registry.yarnpkg.com/vuex/-/vuex-2.4.1.tgz#7890b650ba8565b70937b4e7670577082dfe8bc1" +vuex@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/vuex/-/vuex-3.0.0.tgz#98b4b5c4954b1c1c1f5b29fa0476a23580315814" watchpack@^1.4.0: version "1.4.0" From f8bc7e23838f38b76cb8b05a98b1878090966d15 Mon Sep 17 00:00:00 2001 From: Clark Du Date: Mon, 16 Oct 2017 11:29:09 +0800 Subject: [PATCH 103/316] refactor: renderToString now returns a Promise if no callback is passed --- lib/core/renderer.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/lib/core/renderer.js b/lib/core/renderer.js index dd0b5ddf8e..ee5f279c84 100644 --- a/lib/core/renderer.js +++ b/lib/core/renderer.js @@ -3,7 +3,6 @@ import serialize from 'serialize-javascript' import generateETag from 'etag' import fresh from 'fresh' import Tapable from 'tappable' -import pify from 'pify' import serveStatic from 'serve-static' import compression from 'compression' import _ from 'lodash' @@ -167,9 +166,6 @@ export default class Renderer extends Tapable { runInNewContext: false, basedir: this.options.rootDir }, this.options.render.bundleRenderer)) - - // Promisify renderToString - this.bundleRenderer.renderToString = pify(this.bundleRenderer.renderToString) } useMiddleware (m) { From df2af66355712b78245203f6980557e1c9ef0537 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Chopin?= Date: Mon, 16 Oct 2017 10:40:08 +0200 Subject: [PATCH 104/316] Refacto client app --- lib/app/client.js | 115 +++++++++++++++++++--------------------------- 1 file changed, 47 insertions(+), 68 deletions(-) diff --git a/lib/app/client.js b/lib/app/client.js index b4087f8129..5cc56ad020 100644 --- a/lib/app/client.js +++ b/lib/app/client.js @@ -4,10 +4,11 @@ import { createApp, NuxtError } from './index' import { applyAsyncData, sanitizeComponent, + resolveRouteComponents, getMatchedComponents, getMatchedComponentsInstances, flatMapComponents, - getContext, + setContext, middlewareSeries, promisify, getLocation, @@ -96,40 +97,25 @@ function mapTransitions(Components, to, from) { } async function loadAsyncComponents (to, from, next) { - // Check if route hash changed + // Check if route hash changed (this._hashChanged) const fromPath = from.fullPath.split('#')[0] const toPath = to.fullPath.split('#')[0] this._hashChanged = fromPath === toPath <% if (loading) { %> if (!this._hashChanged && this.$loading.start) { - this.$loading.start() + this.$loading.start() } <% } %> try { - await Promise.all(flatMapComponents(to, (Component, _, match, key) => { - // If component already resolved - if (typeof Component !== 'function' || Component.options) { - const _Component = sanitizeComponent(Component) - match.components[key] = _Component - return _Component - } - - // Resolve component - return Component().then(Component => { - const _Component = sanitizeComponent(Component) - match.components[key] = _Component - return _Component - }) - })) - + await resolveRouteComponents(to) next() } catch (err) { - if (!err) err = {} - const statusCode = err.statusCode || err.status || (err.response && err.response.status) || 500 - this.error({ statusCode, message: err.message }) - next(false) + err = err || {} + const statusCode = err.statusCode || err.status || (err.response && err.response.status) || 500 + this.error({ statusCode, message: err.message }) + next(false) } } @@ -145,20 +131,15 @@ function applySSRData(Component, ssrData) { function resolveComponents(router) { const path = getLocation(router.options.base, router.options.mode) - return flatMapComponents(router.match(path), (Component, _, match, key, index) => { - // If component already resolved - if (typeof Component !== 'function' || Component.options) { - const _Component = applySSRData(sanitizeComponent(Component), NUXT.data ? NUXT.data[index] : null) - match.components[key] = _Component - return _Component + return flatMapComponents(router.match(path), async (Component, _, match, key, index) => { + // If component is not resolved yet, resolve it + if (typeof Component === 'function' && !Component.options) { + Component = await Component() } - - // Resolve component - return Component().then(Component => { - const _Component = applySSRData(sanitizeComponent(Component), NUXT.data ? NUXT.data[index] : null) - match.components[key] = _Component - return _Component - }) + // Sanitize it and save it + const _Component = applySSRData(sanitizeComponent(Component), NUXT.data ? NUXT.data[index] : null) + match.components[key] = _Component + return _Component }) } @@ -204,17 +185,13 @@ async function render (to, from, next) { } // Update context - const context = getContext({ - to, + setContext(app, { + route: to, from, - <% if (store) { %>store,<% } %> - isClient: true, - next: _next.bind(this), - error: this.error.bind(this) - }, app) - this._context = context - this._dateLastError = this.$options._nuxt.dateErr - this._hadError = !!this.$options._nuxt.err + next: _next.bind(this) + }) + this._dateLastError = app.nuxt.dateErr + this._hadError = !!app.nuxt.err // Get route's matched components const Components = getMatchedComponents(to) @@ -222,15 +199,14 @@ async function render (to, from, next) { // If no Components matched, generate 404 if (!Components.length) { // Default layout - await callMiddleware.call(this, Components, context) - if (context._redirected) return - + await callMiddleware.call(this, Components, app.context) + if (app.context._redirected) return // Load layout for error page - const layout = await this.loadLayout(typeof NuxtError.layout === 'function' ? NuxtError.layout(context) : NuxtError.layout) + const layout = await this.loadLayout(typeof NuxtError.layout === 'function' ? NuxtError.layout(app.context) : NuxtError.layout) await callMiddleware.call(this, Components, context, layout) if (context._redirected) return - - this.error({ statusCode: 404, message: '<%= messages.error_404 %>' }) + // Show error page + app.context.error({ statusCode: 404, message: '<%= messages.error_404 %>' }) return next() } @@ -247,19 +223,19 @@ async function render (to, from, next) { try { // Call middleware - await callMiddleware.call(this, Components, context) - if (context._redirected) return + await callMiddleware.call(this, Components, app.context) + if (app.context._redirected) return // Set layout let layout = Components[0].options.layout if (typeof layout === 'function') { - layout = layout(context) + layout = layout(app.context) } layout = await this.loadLayout(layout) // Call middleware for layout - await callMiddleware.call(this, Components, context, layout) - if (context._redirected) return + await callMiddleware.call(this, Components, app.context, layout) + if (app.context._redirected) return // Call .validate() let isValid = true @@ -269,7 +245,7 @@ async function render (to, from, next) { isValid = Component.options.validate({ params: to.params || {}, query : to.query || {}, - <% if(store) { %>store: context.store <% } %> + <% if(store) { %>store<% } %> }) }) // ...If .validate() returned false @@ -294,7 +270,7 @@ async function render (to, from, next) { // Call asyncData(context) if (hasAsyncData) { - const promise = promisify(Component.options.asyncData, context) + const promise = promisify(Component.options.asyncData, app.context) .then(asyncDataResult => { applyAsyncData(Component, asyncDataResult) <% if(loading) { %>if(this.$loading.increase) this.$loading.increase(loadingIncrease)<% } %> @@ -304,7 +280,7 @@ async function render (to, from, next) { // Call fetch(context) if (hasFetch) { - let p = Component.options.fetch(context) + let p = Component.options.fetch(app.context) if (!p || (!(p instanceof Promise) && (typeof p.then !== 'function'))) { p = Promise.resolve(p) } @@ -332,7 +308,7 @@ async function render (to, from, next) { // Load error layout let layout = NuxtError.layout if (typeof layout === 'function') { - layout = layout(context) + layout = layout(app.context) } await this.loadLayout(layout) @@ -376,14 +352,14 @@ function fixPrepatch (to, ___) { }) // Hide error component if no error - if (this._hadError && this._dateLastError === this.$options._nuxt.dateErr) { + if (this._hadError && this._dateLastError === this.$options.nuxt.dateErr) { this.error() } // Set layout - let layout = this.$options._nuxt.err ? NuxtError.layout : to.matched[0].components.default.options.layout + let layout = this.$options.nuxt.err ? NuxtError.layout : to.matched[0].components.default.options.layout if (typeof layout === 'function') { - layout = layout(this._context) + layout = layout(app.context) } this.setLayout(layout) @@ -459,9 +435,13 @@ function addHotReload ($component, depth) { <%= (loading ? 'this.$loading.finish && this.$loading.finish()' : '') %> router.push(path) } - let context = getContext({ route: router.currentRoute<%= (store ? ', store' : '') %>, isClient: true, isHMR: true, next: next.bind(this), error: this.error }, app) + setContext(app, { + route: router.currentRoute, + isHMR: true, + next: next.bind(this) + }) <%= (loading ? 'this.$loading.start && this.$loading.start()' : '') %> - callMiddleware.call(this, Components, context) + callMiddleware.call(this, Components, app.context) .then(() => { // If layout changed if (depth !== 0) return Promise.resolve() @@ -538,7 +518,7 @@ async function mountApp(__app) { } // Enable transitions - _app.setTransitions = _app.$options._nuxt.setTransitions.bind(_app) + _app.setTransitions = _app.$options.nuxt.setTransitions.bind(_app) if (Components.length) { _app.setTransitions(mapTransitions(Components, router.currentRoute)) _lastPaths = router.currentRoute.matched.map(route => compile(route.path)(router.currentRoute.params)) @@ -546,7 +526,6 @@ async function mountApp(__app) { } // Initialize error handler - _app.error = _app.$options._nuxt.error.bind(_app) _app.$loading = {} // To avoid error while _app.$nuxt does not exist if (NUXT.error) _app.error(NUXT.error) From 7cff6cd666337c7f4bb7f2ecb20ec5ab491a28b2 Mon Sep 17 00:00:00 2001 From: Sebastien Chopin Date: Mon, 16 Oct 2017 16:36:21 +0200 Subject: [PATCH 105/316] Fix serverMiddleware as express app without path --- lib/core/renderer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/core/renderer.js b/lib/core/renderer.js index dd0b5ddf8e..14bbea5482 100644 --- a/lib/core/renderer.js +++ b/lib/core/renderer.js @@ -186,7 +186,7 @@ export default class Renderer extends Tapable { } const handler = m.handler || m - const path = (((m.prefix !== false) ? this.options.router.base : '') + (m.path ? m.path : '')).replace(/\/\//g, '/') + const path = (((m.prefix !== false) ? this.options.router.base : '') + (typeof m.path === 'string' ? m.path : '')).replace(/\/\//g, '/') // Inject $src and $m to final handler if (src) handler.$src = src From 9a5bfe6cb49d0d01a099fa08830e0a82c3998891 Mon Sep 17 00:00:00 2001 From: Ademola Adegbuyi Date: Mon, 16 Oct 2017 16:01:19 +0100 Subject: [PATCH 106/316] Add Contributing.md file --- .contributing.md | 8 ++++++++ README.md | 5 ++++- 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 .contributing.md diff --git a/.contributing.md b/.contributing.md new file mode 100644 index 0000000000..1e3b5d528a --- /dev/null +++ b/.contributing.md @@ -0,0 +1,8 @@ +# Contributing to Nuxt.js + +1. [Fork](https://help.github.com/articles/fork-a-repo/) this repository to your own GitHub account and then [clone](https://help.github.com/articles/cloning-a-repository/) it to your local device. +2. Install the dependencies: `npm install`. +3. Run `npm link` to link the local repo to NPM. +4. Run `npm run build` to build and watch for code changes. +5. Then npm link this repo inside any example app with `npm link nuxt`. +6. Then you can run your example app with the local version of Nuxt.js (You may need to re-run the example app as you change server side code in the Nuxt.js repository). \ No newline at end of file diff --git a/README.md b/README.md index 224ba8c977..75f5826a6b 100644 --- a/README.md +++ b/README.md @@ -164,7 +164,7 @@ You can start by using one of our starter templates: - [koa](https://github.com/nuxt-community/koa-template): Nuxt.js + Koa - [adonuxt](https://github.com/nuxt-community/adonuxt-template): Nuxt.js + AdonisJS - [micro](https://github.com/nuxt-community/micro-template): Nuxt.js + Micro -- [nuxtent](https://github.com/nuxt-community/nuxtent-template): Nuxt.js + Nuxtent module for content heavy sites +- [nuxtent](https://github.com/nuxt-community/nuxtent-template): Nuxt.js + Nuxtent module for content heavy sites ## Using nuxt.js programmatically @@ -252,3 +252,6 @@ Note: we recommend putting `.nuxt` in `.npmignore` or `.gitignore`. ## Roadmap https://github.com/nuxt/nuxt.js/projects/1 + +## Contributing +Please see our [contributing.md](./contributing.md) \ No newline at end of file From 10c4190732938fe5783eee20aef4e9535b798458 Mon Sep 17 00:00:00 2001 From: sdras Date: Sat, 14 Oct 2017 13:03:03 -0400 Subject: [PATCH 107/316] update gitignore --- .gitignore | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 9b8a0a54a8..6b2d6f7e1d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,18 +1,21 @@ -# dependencies +# Dependencies node_modules examples/**/*/yarn.lock +jspm_packages +package-lock.json -# logs +# Logs *.log +npm-debug.log* -# other +# Other .nuxt .cache # Dist folder dist -# dist example generation +# Dist example generation examples/**/dist # Coverage support @@ -25,5 +28,23 @@ coverage *.iml .idea -# Macos -.DS_Store +# OSX +*.DS_Store +.AppleDouble +.LSOverride + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk \ No newline at end of file From c99a86d8abc31082709e4473588df21c8354ae68 Mon Sep 17 00:00:00 2001 From: FieryCod Date: Sun, 15 Oct 2017 21:31:01 +0200 Subject: [PATCH 108/316] Adds support for folders in /layouts --- lib/builder/builder.js | 4 ++-- .../with-config/layouts/desktop/default.vue | 20 ++++++++++++++++++ .../with-config/layouts/mobile/default.vue | 21 +++++++++++++++++++ test/fixtures/with-config/pages/desktop.vue | 12 +++++++++++ test/fixtures/with-config/pages/mobile.vue | 12 +++++++++++ test/with-config.test.js | 18 +++++++++++++++- 6 files changed, 84 insertions(+), 3 deletions(-) create mode 100644 test/fixtures/with-config/layouts/desktop/default.vue create mode 100644 test/fixtures/with-config/layouts/mobile/default.vue create mode 100644 test/fixtures/with-config/pages/desktop.vue create mode 100644 test/fixtures/with-config/pages/mobile.vue diff --git a/lib/builder/builder.js b/lib/builder/builder.js index a9ec11e2dd..fb543a95e6 100644 --- a/lib/builder/builder.js +++ b/lib/builder/builder.js @@ -227,10 +227,10 @@ export default class Builder extends Tapable { // -- Layouts -- if (fs.existsSync(resolve(this.options.srcDir, 'layouts'))) { - const layoutsFiles = await glob('layouts/*.vue', { cwd: this.options.srcDir }) + const layoutsFiles = await glob('layouts/**/*.vue', { cwd: this.options.srcDir }) let hasErrorLayout = false layoutsFiles.forEach((file) => { - let name = file.split('/').slice(-1)[0].replace(/\.vue$/, '') + let name = file.split('/').slice(1).join('/').replace(/\.vue$/, '') if (name === 'error') { hasErrorLayout = true return diff --git a/test/fixtures/with-config/layouts/desktop/default.vue b/test/fixtures/with-config/layouts/desktop/default.vue new file mode 100644 index 0000000000..329274e836 --- /dev/null +++ b/test/fixtures/with-config/layouts/desktop/default.vue @@ -0,0 +1,20 @@ + + + diff --git a/test/fixtures/with-config/layouts/mobile/default.vue b/test/fixtures/with-config/layouts/mobile/default.vue new file mode 100644 index 0000000000..548fe9b27b --- /dev/null +++ b/test/fixtures/with-config/layouts/mobile/default.vue @@ -0,0 +1,21 @@ + + + + diff --git a/test/fixtures/with-config/pages/desktop.vue b/test/fixtures/with-config/pages/desktop.vue new file mode 100644 index 0000000000..4c0951062e --- /dev/null +++ b/test/fixtures/with-config/pages/desktop.vue @@ -0,0 +1,12 @@ + + + + diff --git a/test/fixtures/with-config/pages/mobile.vue b/test/fixtures/with-config/pages/mobile.vue new file mode 100644 index 0000000000..915e603c6e --- /dev/null +++ b/test/fixtures/with-config/pages/mobile.vue @@ -0,0 +1,12 @@ + + + + diff --git a/test/with-config.test.js b/test/with-config.test.js index 579affa5cd..c0bfe0674b 100644 --- a/test/with-config.test.js +++ b/test/with-config.test.js @@ -61,6 +61,22 @@ test('/test/about (custom layout)', async t => { t.true(html.includes('

About page

')) }) +test('/test/desktop (custom layout in desktop folder)', async t => { + const window = await nuxt.renderAndGetWindow(url('/test/desktop')) + const html = window.document.body.innerHTML + t.is(window.__NUXT__.layout, 'desktop/default') + t.true(html.includes('

Default desktop layout

')) + t.true(html.includes('

Desktop page

')) +}) + +test('/test/mobile (custom layout in mobile folder)', async t => { + const window = await nuxt.renderAndGetWindow(url('/test/mobile')) + const html = window.document.body.innerHTML + t.is(window.__NUXT__.layout, 'mobile/default') + t.true(html.includes('

Default mobile layout

')) + t.true(html.includes('

Mobile page

')) +}) + test('/test/env', async t => { const window = await nuxt.renderAndGetWindow(url('/test/env')) const html = window.document.body.innerHTML @@ -95,7 +111,7 @@ test('/test/about-bis (added with extendRoutes)', async t => { test('Check stats.json generated by build.analyze', t => { const stats = require(resolve(__dirname, 'fixtures/with-config/.nuxt/dist/stats.json')) - t.is(stats.assets.length, 27) + t.is(stats.assets.length, 35) }) test('Check /test/test.txt with custom serve-static options', async t => { From 7df46279bf29302730cf316cd2fe6e50377f16f8 Mon Sep 17 00:00:00 2001 From: Clark Du Date: Mon, 16 Oct 2017 11:08:33 +0800 Subject: [PATCH 109/316] chore: upgrade vue to 2.5.x --- package.json | 8 ++++---- start/package.json | 4 ++-- yarn.lock | 24 ++++++++++++------------ 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/package.json b/package.json index d1e3fb782b..92befe2339 100644 --- a/package.json +++ b/package.json @@ -109,13 +109,13 @@ "source-map-support": "^0.5.0", "tappable": "^1.1.0", "url-loader": "^0.6.2", - "vue": "~2.4.4", + "vue": "~2.5.2", "vue-loader": "^13.0.5", "vue-meta": "^1.2.0", "vue-router": "^2.7.0", - "vue-server-renderer": "~2.4.4", - "vue-template-compiler": "~2.4.4", - "vuex": "^2.4.1", + "vue-server-renderer": "~2.5.2", + "vue-template-compiler": "~2.5.2", + "vuex": "^3.0.0", "webpack": "^3.6.0", "webpack-bundle-analyzer": "^2.9.0", "webpack-dev-middleware": "^1.12.0", diff --git a/start/package.json b/start/package.json index 49f2857e24..c3a0b495a8 100644 --- a/start/package.json +++ b/start/package.json @@ -62,11 +62,11 @@ "serve-static": "^1.13.1", "compression": "^1.7.1", "fs-extra": "^4.0.2", - "vue-server-renderer": "~2.4.4", + "vue-server-renderer": "~2.5.2", "@nuxtjs/youch": "3.1.0", "source-map": "^0.6.1", "connect": "^3.6.5", - "vue": "~2.4.4", + "vue": "~2.5.2", "vue-meta": "^1.2.0", "lru-cache": "^4.1.1", "server-destroy": "^1.0.1", diff --git a/yarn.lock b/yarn.lock index 2fc4e425be..9d2a96d2c4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6680,9 +6680,9 @@ vue-router@^2.7.0: version "2.7.0" resolved "https://registry.yarnpkg.com/vue-router/-/vue-router-2.7.0.tgz#16d424493aa51c3c8cce8b7c7210ea4c3a89aff1" -vue-server-renderer@~2.4.4: - version "2.4.4" - resolved "https://registry.yarnpkg.com/vue-server-renderer/-/vue-server-renderer-2.4.4.tgz#bd59cf4e42dfaf2c9e388af8837b5420dd51360d" +vue-server-renderer@~2.5.2: + version "2.5.2" + resolved "https://registry.yarnpkg.com/vue-server-renderer/-/vue-server-renderer-2.5.2.tgz#c96a4368caa3fd298a528f1bf40632d8f696ff25" dependencies: chalk "^1.1.3" hash-sum "^1.0.2" @@ -6700,9 +6700,9 @@ vue-style-loader@^3.0.0: hash-sum "^1.0.2" loader-utils "^1.0.2" -vue-template-compiler@~2.4.4: - version "2.4.4" - resolved "https://registry.yarnpkg.com/vue-template-compiler/-/vue-template-compiler-2.4.4.tgz#2cde3b704124985c27d50b5387c9691ba515fb57" +vue-template-compiler@~2.5.2: + version "2.5.2" + resolved "https://registry.yarnpkg.com/vue-template-compiler/-/vue-template-compiler-2.5.2.tgz#6f198ebc677b8f804315cd33b91e849315ae7177" dependencies: de-indent "^1.0.2" he "^1.1.0" @@ -6711,13 +6711,13 @@ vue-template-es2015-compiler@^1.5.3: version "1.5.3" resolved "https://registry.yarnpkg.com/vue-template-es2015-compiler/-/vue-template-es2015-compiler-1.5.3.tgz#22787de4e37ebd9339b74223bc467d1adee30545" -vue@~2.4.4: - version "2.4.4" - resolved "https://registry.yarnpkg.com/vue/-/vue-2.4.4.tgz#ea9550b96a71465fd2b8b17b61673b3561861789" +vue@~2.5.2: + version "2.5.2" + resolved "https://registry.yarnpkg.com/vue/-/vue-2.5.2.tgz#fd367a87bae7535e47f9dc5c9ec3b496e5feb5a4" -vuex@^2.4.1: - version "2.4.1" - resolved "https://registry.yarnpkg.com/vuex/-/vuex-2.4.1.tgz#7890b650ba8565b70937b4e7670577082dfe8bc1" +vuex@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/vuex/-/vuex-3.0.0.tgz#98b4b5c4954b1c1c1f5b29fa0476a23580315814" watchpack@^1.4.0: version "1.4.0" From c659f9bce4eb36deaf66f81cfaeb2b5f4766bc67 Mon Sep 17 00:00:00 2001 From: Clark Du Date: Mon, 16 Oct 2017 11:29:09 +0800 Subject: [PATCH 110/316] refactor: renderToString now returns a Promise if no callback is passed --- lib/core/renderer.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/lib/core/renderer.js b/lib/core/renderer.js index 14bbea5482..0bdef1ab06 100644 --- a/lib/core/renderer.js +++ b/lib/core/renderer.js @@ -3,7 +3,6 @@ import serialize from 'serialize-javascript' import generateETag from 'etag' import fresh from 'fresh' import Tapable from 'tappable' -import pify from 'pify' import serveStatic from 'serve-static' import compression from 'compression' import _ from 'lodash' @@ -167,9 +166,6 @@ export default class Renderer extends Tapable { runInNewContext: false, basedir: this.options.rootDir }, this.options.render.bundleRenderer)) - - // Promisify renderToString - this.bundleRenderer.renderToString = pify(this.bundleRenderer.renderToString) } useMiddleware (m) { From ad2649dc995ae4a78e0147ae4c18672f874ce634 Mon Sep 17 00:00:00 2001 From: Sebastien Chopin Date: Tue, 17 Oct 2017 12:31:49 +0200 Subject: [PATCH 111/316] Upgrade dependencies --- package.json | 30 +++++++++++++++--------------- start/package.json | 5 ++--- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/package.json b/package.json index 92befe2339..9622dcb1e7 100644 --- a/package.json +++ b/package.json @@ -66,7 +66,7 @@ "dependencies": { "@nuxtjs/youch": "3.1.0", "ansi-html": "^0.0.7", - "autoprefixer": "^7.1.4", + "autoprefixer": "^7.1.5", "babel-core": "^6.26.0", "babel-loader": "^7.1.2", "babel-preset-vue-app": "^1.3.1", @@ -98,7 +98,7 @@ "postcss": "^6.0.13", "postcss-cssnext": "^3.0.2", "postcss-import": "^11.0.0", - "postcss-loader": "^2.0.6", + "postcss-loader": "^2.0.8", "postcss-url": "^7.1.2", "pretty-error": "^2.1.1", "progress-bar-webpack-plugin": "^1.10.0", @@ -109,17 +109,17 @@ "source-map-support": "^0.5.0", "tappable": "^1.1.0", "url-loader": "^0.6.2", - "vue": "~2.5.2", - "vue-loader": "^13.0.5", + "vue": "^2.5.2", + "vue-loader": "^13.3.0", "vue-meta": "^1.2.0", - "vue-router": "^2.7.0", - "vue-server-renderer": "~2.5.2", - "vue-template-compiler": "~2.5.2", + "vue-router": "^3.0.1", + "vue-server-renderer": "^2.5.2", + "vue-template-compiler": "^2.5.2", "vuex": "^3.0.0", - "webpack": "^3.6.0", + "webpack": "^3.8.0", "webpack-bundle-analyzer": "^2.9.0", "webpack-dev-middleware": "^1.12.0", - "webpack-hot-middleware": "^2.19.1", + "webpack-hot-middleware": "^2.20.0", "webpack-node-externals": "^1.6.0" }, "devDependencies": { @@ -128,17 +128,17 @@ "babel-plugin-array-includes": "^2.0.3", "babel-plugin-external-helpers": "^6.22.0", "babel-plugin-istanbul": "^4.1.5", - "codecov": "^2.3.0", + "codecov": "^2.3.1", "copy-webpack-plugin": "^4.1.1", - "cross-env": "^5.0.5", - "eslint": "^4.8.0", + "cross-env": "^5.1.0", + "eslint": "^4.9.0", "eslint-config-standard": "^10.2.1", "eslint-plugin-html": "^3.2.2", "eslint-plugin-import": "^2.7.0", "eslint-plugin-node": "^5.2.0", - "eslint-plugin-promise": "^3.5.0", + "eslint-plugin-promise": "^3.6.0", "eslint-plugin-standard": "^3.0.1", - "express": "^4.16.1", + "express": "^4.16.2", "finalhandler": "^1.1.0", "jsdom": "^11.3.0", "json-loader": "^0.5.7", @@ -154,7 +154,7 @@ "rollup-plugin-replace": "^2.0.0", "rollup-watch": "^4.3.1", "std-mocks": "^1.0.1", - "uglify-js": "^3.1.3" + "uglify-js": "^3.1.4" }, "collective": { "type": "opencollective", diff --git a/start/package.json b/start/package.json index c3a0b495a8..f775eee62c 100644 --- a/start/package.json +++ b/start/package.json @@ -58,15 +58,14 @@ "serialize-javascript": "^1.4.0", "etag": "^1.8.1", "fresh": "^0.5.2", - "pify": "^3.0.0", "serve-static": "^1.13.1", "compression": "^1.7.1", "fs-extra": "^4.0.2", - "vue-server-renderer": "~2.5.2", + "vue-server-renderer": "^2.5.2", "@nuxtjs/youch": "3.1.0", "source-map": "^0.6.1", "connect": "^3.6.5", - "vue": "~2.5.2", + "vue": "^2.5.2", "vue-meta": "^1.2.0", "lru-cache": "^4.1.1", "server-destroy": "^1.0.1", From 84a7d6d91c94f6cef6e1a4ee4acd59d882acb913 Mon Sep 17 00:00:00 2001 From: Ademola Adegbuyi Date: Tue, 17 Oct 2017 16:13:37 +0100 Subject: [PATCH 112/316] Add with muse-ui example --- examples/with-museui/nuxt.config.js | 26 ++++++++++++++++ examples/with-museui/package.json | 12 +++++++ examples/with-museui/pages/index.vue | 43 ++++++++++++++++++++++++++ examples/with-museui/plugins/museui.js | 4 +++ 4 files changed, 85 insertions(+) create mode 100644 examples/with-museui/nuxt.config.js create mode 100644 examples/with-museui/package.json create mode 100644 examples/with-museui/pages/index.vue create mode 100644 examples/with-museui/plugins/museui.js diff --git a/examples/with-museui/nuxt.config.js b/examples/with-museui/nuxt.config.js new file mode 100644 index 0000000000..309fb1105b --- /dev/null +++ b/examples/with-museui/nuxt.config.js @@ -0,0 +1,26 @@ +module.exports = { + head: { + meta: [ + { + name: 'viewport', + content: 'width=device-width, initial-scale=1' + } + ], + link: [ + { + rel: 'stylesheet', + href: + 'https://fonts.googleapis.com/css?family=Roboto:300,400,500,700,400italic' + }, + { + rel: 'stylesheet', + href: 'https://fonts.googleapis.com/icon?family=Material+Icons' + }, + { + rel: 'stylesheet', + href: 'https://unpkg.com/muse-ui@2.1.0/dist/muse-ui.css' + } + ] + }, + plugins: ['~/plugins/museui'] +}; diff --git a/examples/with-museui/package.json b/examples/with-museui/package.json new file mode 100644 index 0000000000..6f88ac897c --- /dev/null +++ b/examples/with-museui/package.json @@ -0,0 +1,12 @@ +{ + "name": "with-museui", + "dependencies": { + "nuxt": "latest", + "muse-ui": "latest" + }, + "scripts": { + "dev": "nuxt", + "build": "nuxt build", + "start": "nuxt start" + } +} diff --git a/examples/with-museui/pages/index.vue b/examples/with-museui/pages/index.vue new file mode 100644 index 0000000000..f34ba7029d --- /dev/null +++ b/examples/with-museui/pages/index.vue @@ -0,0 +1,43 @@ + + + + + diff --git a/examples/with-museui/plugins/museui.js b/examples/with-museui/plugins/museui.js new file mode 100644 index 0000000000..ae071085bb --- /dev/null +++ b/examples/with-museui/plugins/museui.js @@ -0,0 +1,4 @@ +import Vue from 'vue'; +import MuseUI from 'muse-ui'; + +Vue.use(MuseUI); From 2f670c5ef738471d1cbccbeaf9d8b1f9f3fd56f3 Mon Sep 17 00:00:00 2001 From: Clark Du Date: Thu, 19 Oct 2017 16:56:00 +0800 Subject: [PATCH 113/316] feat: improve vue-class-component example --- .../vue-class-component/components/Base.vue | 40 +++++++++++++++++++ .../vue-class-component/components/Child.vue | 23 +++++++++++ examples/vue-class-component/pages/about.vue | 5 ++- examples/vue-class-component/pages/index.vue | 33 +++------------ 4 files changed, 72 insertions(+), 29 deletions(-) create mode 100644 examples/vue-class-component/components/Base.vue create mode 100644 examples/vue-class-component/components/Child.vue diff --git a/examples/vue-class-component/components/Base.vue b/examples/vue-class-component/components/Base.vue new file mode 100644 index 0000000000..e2790a4ec2 --- /dev/null +++ b/examples/vue-class-component/components/Base.vue @@ -0,0 +1,40 @@ + + + diff --git a/examples/vue-class-component/components/Child.vue b/examples/vue-class-component/components/Child.vue new file mode 100644 index 0000000000..b3c5155dc0 --- /dev/null +++ b/examples/vue-class-component/components/Child.vue @@ -0,0 +1,23 @@ + + + diff --git a/examples/vue-class-component/pages/about.vue b/examples/vue-class-component/pages/about.vue index 484c798b82..cbe04d7fda 100644 --- a/examples/vue-class-component/pages/about.vue +++ b/examples/vue-class-component/pages/about.vue @@ -1,3 +1,6 @@ diff --git a/examples/vue-class-component/pages/index.vue b/examples/vue-class-component/pages/index.vue index ce87828622..ff468d2ed9 100644 --- a/examples/vue-class-component/pages/index.vue +++ b/examples/vue-class-component/pages/index.vue @@ -1,41 +1,18 @@ From dca0bd9a70243144842a6bda64679c118743a2bd Mon Sep 17 00:00:00 2001 From: Clark Du Date: Thu, 19 Oct 2017 16:57:08 +0800 Subject: [PATCH 114/316] fix: error alias in vue-class-component example --- examples/vue-class-component/nuxt.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/vue-class-component/nuxt.config.js b/examples/vue-class-component/nuxt.config.js index a61292b4ae..4e7a3097a9 100644 --- a/examples/vue-class-component/nuxt.config.js +++ b/examples/vue-class-component/nuxt.config.js @@ -4,7 +4,7 @@ module.exports = { plugins: ['transform-decorators-legacy', 'transform-class-properties'] }, extend (config) { - config.resolve.alias['nuxt-class-component'] = '~plugins/nuxt-class-component' + config.resolve.alias['nuxt-class-component'] = '@/plugins/nuxt-class-component' } } } From 50ade95694d8f659ee6253455e69a73915aed0b5 Mon Sep 17 00:00:00 2001 From: Clark Du Date: Thu, 19 Oct 2017 17:51:48 +0800 Subject: [PATCH 115/316] feat: cache dependencies in ci building --- .travis.yml | 4 ++++ appveyor.yml | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/.travis.yml b/.travis.yml index a833fdf3d6..a92abde5dc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,6 +2,10 @@ language: node_js node_js: - "8" - "6" +cache: + yarn: true + directories: + - node_modules install: - yarn install - yarn run build diff --git a/appveyor.yml b/appveyor.yml index 5c62e6be35..f001912793 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -4,6 +4,10 @@ environment: - nodejs_version: "6" - nodejs_version: "8" +cache: + - "%LOCALAPPDATA%\\Yarn" + - node_modules + # Install scripts. (runs after repo cloning) install: # Get the latest stable version of Node.js or io.js From d2a57bc3291b7c0d4276af78cc3811977a87b352 Mon Sep 17 00:00:00 2001 From: Clark Du Date: Fri, 20 Oct 2017 14:41:06 +0800 Subject: [PATCH 116/316] feat: update with-ava example --- examples/with-ava/package.json | 2 +- examples/with-ava/test/index.test.js | 9 +++------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/examples/with-ava/package.json b/examples/with-ava/package.json index f8925f9997..02065f4c57 100755 --- a/examples/with-ava/package.json +++ b/examples/with-ava/package.json @@ -11,6 +11,6 @@ "jsdom": "^11.0.0" }, "dependencies": { - "nuxt": "^1.0.0-alpha2" + "nuxt": "latest" } } diff --git a/examples/with-ava/test/index.test.js b/examples/with-ava/test/index.test.js index 21c25e9320..47ce1fadec 100755 --- a/examples/with-ava/test/index.test.js +++ b/examples/with-ava/test/index.test.js @@ -1,11 +1,10 @@ import test from 'ava' -import Nuxt from 'nuxt' +import { Nuxt, Builder } from 'nuxt' import { resolve } from 'path' // We keep the nuxt and server instance // So we can close them at the end of the test let nuxt = null -let server = null // Init Nuxt.js and create a server listening on localhost:4000 test.before('Init Nuxt.js', async t => { @@ -15,9 +14,8 @@ test.before('Init Nuxt.js', async t => { config.rootDir = rootDir // project folder config.dev = false // production build nuxt = new Nuxt(config) - await nuxt.build() - server = new nuxt.Server(nuxt) - server.listen(4000, 'localhost') + await new Builder(nuxt).build() + await nuxt.listen(4000, 'localhost') }) // Example of testing only generated html @@ -39,6 +37,5 @@ test('Route / exits and render HTML with CSS applied', async t => { // Close server and ask nuxt to stop listening to file changes test.after('Closing server and nuxt.js', t => { - server.close() nuxt.close() }) From 725283ebce80416fb5241f39c05868f715d8d78b Mon Sep 17 00:00:00 2001 From: Clark Du Date: Fri, 20 Oct 2017 14:45:34 +0800 Subject: [PATCH 117/316] feat: update dynamic-component example --- examples/dynamic-components/js/messages.js | 16 ++++++++-------- examples/dynamic-components/package.json | 2 +- examples/dynamic-components/pages/index.vue | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/examples/dynamic-components/js/messages.js b/examples/dynamic-components/js/messages.js index aac4333f6a..ec2bba5c08 100644 --- a/examples/dynamic-components/js/messages.js +++ b/examples/dynamic-components/js/messages.js @@ -6,16 +6,16 @@ export const messages = [ component: 'vChart', data: { labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'], - datasets:[ - { - label: 'Activity', - backgroundColor: '#41b883', - data: [40, 20, 12, 39, 10, 40, 39, 50, 40, 20, 12, 11] - } + datasets: [ + { + label: 'Activity', + backgroundColor: '#41b883', + data: [40, 20, 12, 39, 10, 40, 39, 50, 40, 20, 12, 11] + } ] } }, - { component: 'vText', data: 'End of demo 🎉' }, + { component: 'vText', data: 'End of demo 🎉' } ] async function streamMessages (fn, i = 0) { @@ -24,4 +24,4 @@ async function streamMessages (fn, i = 0) { setTimeout(() => streamMessages(fn, i + 1), 1500) } -export default streamMessages \ No newline at end of file +export default streamMessages diff --git a/examples/dynamic-components/package.json b/examples/dynamic-components/package.json index 300c9256e4..7486edc9cd 100644 --- a/examples/dynamic-components/package.json +++ b/examples/dynamic-components/package.json @@ -2,7 +2,7 @@ "name": "dynamic-components-nuxt", "dependencies": { "chart.js": "^2.7.0", - "nuxt": "^1.0.0-rc11", + "nuxt": "latest", "vue-chartjs": "^2.8.7" }, "scripts": { diff --git a/examples/dynamic-components/pages/index.vue b/examples/dynamic-components/pages/index.vue index 6381e70525..67b000ceaf 100755 --- a/examples/dynamic-components/pages/index.vue +++ b/examples/dynamic-components/pages/index.vue @@ -16,7 +16,7 @@ const components = { vText: () => import('@/components/text.vue' /* webpackChunkName: "components/text" */), vImage: () => import('@/components/image.vue' /* webpackChunkName: "components/image" */), vCode: () => import('@/components/code.vue' /* webpackChunkName: "components/code" */), - vChart: () => import('@/components/chart.js' /* webpackChunkName: "components/chart" */).then((m) => m.default()), + vChart: () => import('@/components/chart.js' /* webpackChunkName: "components/chart" */).then((m) => m.default()) } export default { From 161d9b59d2acbccd24f2271523e5a18e9a4e0778 Mon Sep 17 00:00:00 2001 From: Clark Du Date: Fri, 20 Oct 2017 14:51:55 +0800 Subject: [PATCH 118/316] feat: use latest nuxt in i18n example --- examples/i18n/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/i18n/package.json b/examples/i18n/package.json index 6c75b31cb7..0761757ce8 100644 --- a/examples/i18n/package.json +++ b/examples/i18n/package.json @@ -1,8 +1,8 @@ { "name": "nuxt-i18n", "dependencies": { - "nuxt": "^1.0.0-rc9", - "vue-i18n": "^7.0.5" + "nuxt": "latest", + "vue-i18n": "^7.3.2" }, "scripts": { "dev": "nuxt", From 1453a98b5f54a1ffbb6317038bed650878cb077d Mon Sep 17 00:00:00 2001 From: Clark Du Date: Fri, 20 Oct 2017 14:56:20 +0800 Subject: [PATCH 119/316] feat: use latest nuxt in vuex-persistedstate example --- examples/vuex-persistedstate/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/vuex-persistedstate/package.json b/examples/vuex-persistedstate/package.json index 7b83e11f23..5d9eef3ddf 100644 --- a/examples/vuex-persistedstate/package.json +++ b/examples/vuex-persistedstate/package.json @@ -1,7 +1,7 @@ { "name": "nuxt-vuex-store", "dependencies": { - "nuxt": "^1.0.0-rc6", + "nuxt": "latest", "vuex-persistedstate": "^2.0.0" }, "scripts": { From 7cd22a44e70060a53b85fa4362ba347284552bbf Mon Sep 17 00:00:00 2001 From: Clark Du Date: Fri, 20 Oct 2017 15:13:17 +0800 Subject: [PATCH 120/316] feat: update with-sockets example --- examples/with-sockets/io/index.js | 8 ++++---- examples/with-sockets/package.json | 2 +- examples/with-sockets/server.js | 19 ++++++++----------- 3 files changed, 13 insertions(+), 16 deletions(-) diff --git a/examples/with-sockets/io/index.js b/examples/with-sockets/io/index.js index 95e55fcf91..53560a8eb7 100644 --- a/examples/with-sockets/io/index.js +++ b/examples/with-sockets/io/index.js @@ -9,16 +9,16 @@ module.exports = function () { // Add `socket.io-client` in vendor this.addVendor('socket.io-client') - + // Add socket.io events let messages = [] io.on('connection', (socket) => { socket.on('last-messages', function (fn) { fn(messages.slice(-50)) - }); + }) socket.on('send-message', function (message) { messages.push(message) socket.broadcast.emit('new-message', message) }) - }); -} \ No newline at end of file + }) +} diff --git a/examples/with-sockets/package.json b/examples/with-sockets/package.json index 4f4c523957..b29200ff34 100644 --- a/examples/with-sockets/package.json +++ b/examples/with-sockets/package.json @@ -7,7 +7,7 @@ }, "dependencies": { "express": "^4.14.0", - "nuxt": "^0.9.5", + "nuxt": "latest", "socket.io": "^1.7.2", "socket.io-client": "^1.7.2" }, diff --git a/examples/with-sockets/server.js b/examples/with-sockets/server.js index 1f3312b7b6..1cd396440d 100644 --- a/examples/with-sockets/server.js +++ b/examples/with-sockets/server.js @@ -1,4 +1,4 @@ -const Nuxt = require('nuxt') +const { Nuxt, Builder } = require('nuxt') const app = require('express')() const server = require('http').createServer(app) const io = require('socket.io')(server) @@ -8,17 +8,14 @@ const isProd = process.env.NODE_ENV === 'production' // We instantiate Nuxt.js with the options let config = require('./nuxt.config.js') config.dev = !isProd -const nuxt = new Nuxt(config) -app.use(nuxt.render) -// Build only in dev mode +const nuxt = new Nuxt(config) +// Start build process in dev mode if (config.dev) { - nuxt.build() - .catch((error) => { - console.error(error) // eslint-disable-line no-console - process.exit(1) - }) + const builder = new Builder(nuxt) + builder.build() } +app.use(nuxt.render) // Listen the server server.listen(port, '0.0.0.0') @@ -29,9 +26,9 @@ let messages = [] io.on('connection', (socket) => { socket.on('last-messages', function (fn) { fn(messages.slice(-50)) - }); + }) socket.on('send-message', function (message) { messages.push(message) socket.broadcast.emit('new-message', message) }) -}); +}) From 4b6236499c73dadbbd8fc0f8eed1910ae07f5b8d Mon Sep 17 00:00:00 2001 From: Clark Du Date: Thu, 19 Oct 2017 17:25:19 +0800 Subject: [PATCH 121/316] fix: with-firebase example --- examples/with-firebase/package.json | 2 +- examples/with-firebase/pages/index.vue | 10 ++++------ examples/with-firebase/pages/users/_key.vue | 10 ++++------ 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/examples/with-firebase/package.json b/examples/with-firebase/package.json index 6f1b1f08d4..99d0797aa6 100644 --- a/examples/with-firebase/package.json +++ b/examples/with-firebase/package.json @@ -15,6 +15,6 @@ "license": "MIT", "dependencies": { "axios": "^0.15.3", - "nuxt": "^0.9.9" + "nuxt": "latest" } } diff --git a/examples/with-firebase/pages/index.vue b/examples/with-firebase/pages/index.vue index 87fbc6bbee..0486e2c820 100644 --- a/examples/with-firebase/pages/index.vue +++ b/examples/with-firebase/pages/index.vue @@ -28,14 +28,12 @@ diff --git a/examples/with-firebase/pages/users/_key.vue b/examples/with-firebase/pages/users/_key.vue index 94a2735870..0935ddc1d3 100644 --- a/examples/with-firebase/pages/users/_key.vue +++ b/examples/with-firebase/pages/users/_key.vue @@ -11,15 +11,13 @@ From 65136ac55045ef8e761c930089bb2d0b146c6363 Mon Sep 17 00:00:00 2001 From: Clark Du Date: Thu, 19 Oct 2017 17:38:18 +0800 Subject: [PATCH 122/316] feat: improve custom-server example --- examples/custom-server/package.json | 3 ++- examples/custom-server/server.js | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/examples/custom-server/package.json b/examples/custom-server/package.json index fb6d0d7247..eb4e86d015 100644 --- a/examples/custom-server/package.json +++ b/examples/custom-server/package.json @@ -1,8 +1,9 @@ { "name": "nuxt-custom-server", "dependencies": { + "chalk": "^2.2.0", "express": "^4.15.3", - "nuxt": "^1.0.0-rc3" + "nuxt": "latest" }, "scripts": { "dev": "node server.js", diff --git a/examples/custom-server/server.js b/examples/custom-server/server.js index 04ade773c1..67a3a1fb63 100644 --- a/examples/custom-server/server.js +++ b/examples/custom-server/server.js @@ -1,5 +1,6 @@ const app = require('express')() const { Nuxt, Builder } = require('nuxt') +const chalk = require('chalk') const host = process.env.HOST || '127.0.0.1' const port = process.env.PORT || 3000 @@ -21,4 +22,4 @@ app.use(nuxt.render) // Start express server app.listen(port, host) -console.log('Server listening on ' + host + ':' + port) +console.log('\n' + chalk.bgGreen.black(' OPEN ') + chalk.green(` http://${host}:${port}`)) From a66220b58cfb56ab85791261a9d57b9104a8a9e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ant=C3=A9rio=20Vieira?= Date: Fri, 20 Oct 2017 05:31:56 -0200 Subject: [PATCH 123/316] style(app): spaces removed (#1898) --- lib/app/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/app/index.js b/lib/app/index.js index 05cf531221..6cb9e387e8 100644 --- a/lib/app/index.js +++ b/lib/app/index.js @@ -167,7 +167,7 @@ async function createApp (ssrContext) { return { app, router, - <% if(store) { %> store <% } %> + <% if(store) { %>store<% } %> } } From d745f496885741242040658455d466cea5a57601 Mon Sep 17 00:00:00 2001 From: devneko Date: Thu, 19 Oct 2017 22:42:47 +0900 Subject: [PATCH 124/316] fix contributing.md link --- .contributing.md => contributing.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .contributing.md => contributing.md (100%) diff --git a/.contributing.md b/contributing.md similarity index 100% rename from .contributing.md rename to contributing.md From 1d3b5cd87b56ffb6038e103f07dbb5663335626e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Chopin?= Date: Fri, 20 Oct 2017 10:32:44 +0200 Subject: [PATCH 125/316] Create CODE_OF_CONDUCT.md --- CODE_OF_CONDUCT.md | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 CODE_OF_CONDUCT.md diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000000..a91492b217 --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,46 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at team@nuxtjs.org. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version] + +[homepage]: http://contributor-covenant.org +[version]: http://contributor-covenant.org/version/1/4/ From 1b18bc692b8099c68b96ba4387dd5c3d99f6b98b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Chopin?= Date: Fri, 20 Oct 2017 10:34:47 +0200 Subject: [PATCH 126/316] Update and rename contributing.md to CONTRIBUTING.md --- contributing.md => CONTRIBUTING.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) rename contributing.md => CONTRIBUTING.md (68%) diff --git a/contributing.md b/CONTRIBUTING.md similarity index 68% rename from contributing.md rename to CONTRIBUTING.md index 1e3b5d528a..966a162f9a 100644 --- a/contributing.md +++ b/CONTRIBUTING.md @@ -3,6 +3,8 @@ 1. [Fork](https://help.github.com/articles/fork-a-repo/) this repository to your own GitHub account and then [clone](https://help.github.com/articles/cloning-a-repository/) it to your local device. 2. Install the dependencies: `npm install`. 3. Run `npm link` to link the local repo to NPM. -4. Run `npm run build` to build and watch for code changes. +4. Run `npm run build` to build or `npm run watch` to build and watch for code changes. 5. Then npm link this repo inside any example app with `npm link nuxt`. -6. Then you can run your example app with the local version of Nuxt.js (You may need to re-run the example app as you change server side code in the Nuxt.js repository). \ No newline at end of file +6. Then you can run your example app with the local version of Nuxt.js (You may need to re-run the example app as you change server side code in the Nuxt.js repository). + +Make sure to add tests into `test/` directory and try them with `npm test` before making a pull request. From dd7d8bbafc9d38ee60fd3aee9d9f9b9b2c91f5ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Chopin?= Date: Fri, 13 Oct 2017 22:20:16 +0200 Subject: [PATCH 127/316] dev: Improve template debugging in development --- lib/builder/builder.js | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/lib/builder/builder.js b/lib/builder/builder.js index c85c5c7b5c..acffbfe671 100644 --- a/lib/builder/builder.js +++ b/lib/builder/builder.js @@ -335,23 +335,28 @@ export default class Builder extends Tapable { this.options.build.watch.push(src) // Render template to dst const fileContent = await readFile(src, 'utf8') - const template = _.template(fileContent, { - imports: { - serialize, - hash, - r, - wp, - wChunk, - resolvePath: this.nuxt.resolvePath.bind(this.nuxt), - relativeToBuild: this.relativeToBuild - } - }) - const content = template(Object.assign({}, templateVars, { - options: options || {}, - custom, - src, - dst - })) + let content + try { + const template = _.template(fileContent, { + imports: { + serialize, + hash, + r, + wp, + wChunk, + resolvePath: this.nuxt.resolvePath.bind(this.nuxt), + relativeToBuild: this.relativeToBuild + } + }) + content = template(Object.assign({}, templateVars, { + options: options || {}, + custom, + src, + dst + })) + } catch (err) { + throw new Error(`Could not compile template ${src}: ${err.message}`) + } const path = r(this.options.buildDir, dst) // Ensure parent dir exits await mkdirp(dirname(path)) From 5b09b92286bb3a6896c55713594c5a394a9374a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Chopin?= Date: Fri, 13 Oct 2017 23:53:04 +0200 Subject: [PATCH 128/316] Refactor to use only one context and add route.meta --- lib/app/{App.vue => App.js} | 5 +- lib/app/components/nuxt-link.js | 2 - lib/app/components/{nuxt.vue => nuxt.js} | 4 +- lib/app/index.js | 54 +++--- lib/app/server.js | 232 +++++++++++------------ lib/app/utils.js | 150 +++++++++------ lib/builder/builder.js | 6 +- 7 files changed, 232 insertions(+), 221 deletions(-) rename lib/app/{App.vue => App.js} (97%) rename lib/app/components/{nuxt.vue => nuxt.js} (92%) diff --git a/lib/app/App.vue b/lib/app/App.js similarity index 97% rename from lib/app/App.vue rename to lib/app/App.js index 54b5251da8..37e81a2af4 100644 --- a/lib/app/App.vue +++ b/lib/app/App.js @@ -1,4 +1,3 @@ - diff --git a/lib/app/components/nuxt-link.js b/lib/app/components/nuxt-link.js index c23fdd7ac3..fea5f308ce 100644 --- a/lib/app/components/nuxt-link.js +++ b/lib/app/components/nuxt-link.js @@ -1,5 +1,3 @@ -import Vue from 'vue' - export default { name: 'nuxt-link', functional: true, diff --git a/lib/app/components/nuxt.vue b/lib/app/components/nuxt.js similarity index 92% rename from lib/app/components/nuxt.vue rename to lib/app/components/nuxt.js index c392f882bf..068b1b16e5 100644 --- a/lib/app/components/nuxt.vue +++ b/lib/app/components/nuxt.js @@ -1,4 +1,3 @@ - diff --git a/lib/app/index.js b/lib/app/index.js index 05cf531221..ce1763aec2 100644 --- a/lib/app/index.js +++ b/lib/app/index.js @@ -6,9 +6,9 @@ import NoSSR from './components/no-ssr.js' import NuxtChild from './components/nuxt-child.js' import NuxtLink from './components/nuxt-link.js' import NuxtError from '<%= components.ErrorPage ? components.ErrorPage : "./components/nuxt-error.vue" %>' -import Nuxt from './components/nuxt.vue' +import Nuxt from './components/nuxt.js' import App from '<%= appPath %>' -import { getContext, getLocation } from './utils' +import { setContext, getLocation } from './utils' <% if (store) { %>import { createStore } from './store.js'<% } %> <% plugins.forEach(plugin => { %>import <%= plugin.name %> from '<%= plugin.name %>' <% }) %> @@ -37,7 +37,8 @@ const defaultTransition = <%= serialize(transition) .replace('beforeEnter(', 'function(').replace('enter(', 'function(').replace('afterEnter(', 'function(') .replace('enterCancelled(', 'function(').replace('beforeLeave(', 'function(').replace('leave(', 'function(') - .replace('afterLeave(', 'function(').replace('leaveCancelled(', 'function(') + .replace('afterLeave(', 'function(').replace('leaveCancelled(', 'function(').replace('beforeAppear(', 'function(') + .replace('appear(', 'function(').replace('afterAppear(', 'function(').replace('appearCancelled(', 'function(') %> async function createApp (ssrContext) { @@ -55,7 +56,7 @@ async function createApp (ssrContext) { const app = { router, <% if (store) { %>store,<% } %> - _nuxt: { + nuxt: { defaultTransition, transitions: [ defaultTransition ], setTransitions (transitions) { @@ -72,29 +73,30 @@ async function createApp (ssrContext) { } return transition }) - this.$options._nuxt.transitions = transitions + this.$options.nuxt.transitions = transitions return transitions }, err: null, dateErr: null, error (err) { err = err || null - if (typeof err === 'string') { - err = { statusCode: 500, message: err } - } - const _nuxt = this._nuxt || this.$options._nuxt - _nuxt.dateErr = Date.now() - _nuxt.err = err + if (typeof err === 'string') err = { statusCode: 500, message: err } + const nuxt = this.nuxt || this.$options.nuxt + nuxt.dateErr = Date.now() + nuxt.err = err + // Used in lib/server.js + if (ssrContext) ssrContext.nuxt.error = err return err } }, ...App } <% if (store) { %> - // Make app available in store + // Make app available into store via this.app store.app = app <% } %> const next = ssrContext ? ssrContext.next : location => app.router.push(location) + // Resolve route let route if (ssrContext) { route = router.resolve(ssrContext.url).route @@ -102,17 +104,19 @@ async function createApp (ssrContext) { const path = getLocation(router.options.base) route = router.resolve(path).route } - const ctx = getContext({ + + // Set context to app.context + await setContext(app, { isServer: !!ssrContext, isClient: !ssrContext, route, next, - error: app._nuxt.error.bind(app), - <% if (store) { %>store,<% } %> + error: app.nuxt.error.bind(app), + <% if (store) { %>store,<% } %> req: ssrContext ? ssrContext.req : undefined, res: ssrContext ? ssrContext.res : undefined, beforeRenderFns: ssrContext ? ssrContext.beforeRenderFns : undefined - }, app) + }) const inject = function (key, value) { if (!key) throw new Error('inject(key, value) has no key provided') @@ -120,11 +124,12 @@ async function createApp (ssrContext) { key = '$' + key // Add into app app[key] = value - // Add into vm + // Check if plugin not already installed + const installKey = '__nuxt_' + key + '_installed__' + if (Vue[installKey]) return + Vue[installKey] = true + // Call Vue.use() to install the plugin into vm Vue.use(() => { - const installKey = '__nuxt_' + key + '_installed__' - if (Vue[installKey]) return - Vue[installKey] = true if (!Vue.prototype.hasOwnProperty(key)) { Object.defineProperty(Vue.prototype, key, { get () { @@ -148,16 +153,15 @@ async function createApp (ssrContext) { } <% } %> + // Plugin execution <% plugins.filter(p => p.ssr).forEach(plugin => { %> - if (typeof <%= plugin.name %> === 'function') await <%= plugin.name %>(ctx, inject)<% }) %> + if (typeof <%= plugin.name %> === 'function') await <%= plugin.name %>(app.context, inject)<% }) %> <% if (plugins.filter(p => !p.ssr).length) { %> if (process.browser) { <% plugins.filter(p => !p.ssr).forEach(plugin => { %> - if (typeof <%= plugin.name %> === 'function') await <%= plugin.name %>(ctx, inject)<% }) %> + if (typeof <%= plugin.name %> === 'function') await <%= plugin.name %>(app.context, inject)<% }) %> }<% } %> - // Inject context - inject('ctx', ctx) - + // If server-side, wait for async component to be resolved first if (process.server && ssrContext && ssrContext.url) { await new Promise((resolve, reject) => { router.push(ssrContext.url, resolve, reject) diff --git a/lib/app/server.js b/lib/app/server.js index 01c62be7e6..427633defc 100644 --- a/lib/app/server.js +++ b/lib/app/server.js @@ -13,11 +13,11 @@ const isDev = <%= isDev %> const noopApp = () => new Vue({ render: (h) => h('div') }) -const createNext = context => opts => { - context.redirected = opts +const createNext = ssrContext => opts => { + ssrContext.redirected = opts // If nuxt generate - if (!context.res) { - context.nuxt.serverRendered = false + if (!ssrContext.res) { + ssrContext.nuxt.serverRendered = false return } opts.query = stringify(opts.query) @@ -26,14 +26,14 @@ const createNext = context => opts => { opts.path = urlJoin('<%= router.base %>', opts.path) } // Avoid loop redirect - if (opts.path === context.url) { - context.redirected = false + if (opts.path === ssrContext.url) { + ssrContext.redirected = false return } - context.res.writeHead(opts.status, { + ssrContext.res.writeHead(opts.status, { 'Location': opts.path }) - context.res.end() + ssrContext.res.end() } // This exported function will be called by `bundleRenderer`. @@ -41,137 +41,142 @@ const createNext = context => opts => { // state of our application before actually rendering it. // Since data fetching is async, this function is expected to // return a Promise that resolves to the app instance. -export default async context => { - // Create context.next for simulate next() of beforeEach() when wanted to redirect - context.redirected = false - context.next = createNext(context) - context.beforeRenderFns = [] +export default async ssrContext => { + // Create ssrContext.next for simulate next() of beforeEach() when wanted to redirect + ssrContext.redirected = false + ssrContext.next = createNext(ssrContext) + // Used for beforeNuxtRender({ Components, nuxtState }) + ssrContext.beforeRenderFns = [] - const { app, router<%= (store ? ', store' : '') %> } = await createApp(context) + // Create the app definition and the instance (created for each request) + const { app, router<%= (store ? ', store' : '') %> } = await createApp(ssrContext) const _app = new Vue(app) - <% if (store) { %> - // Add store to the context - context.store = store - <% } %> + // Nuxt object (window.__NUXT__) + ssrContext.nuxt = { layout: 'default', data: [], error: null<%= (store ? ', state: null' : '') %>, serverRendered: true } + // Add meta infos (used in renderer.js) + ssrContext.meta = _app.$meta() + // Keep asyncData for each matched component in ssrContext (used in app/utils.js via this.$ssrContext) + ssrContext.asyncData = {} - // Add route to the context - context.route = router.currentRoute - - // Nuxt object - context.nuxt = { layout: 'default', data: [], error: null<%= (store ? ', state: null' : '') %>, serverRendered: true } - - // Add meta infos - context.meta = _app.$meta() - - // Error function - context.error = _app.$options._nuxt.error.bind(_app) - - // Keep asyncData for each matched component in context - context.asyncData = {} - - // Create shared ctx - const ctx = getContext(context, app) + const beforeRender = async () => { + // Call beforeNuxtRender() methods + await Promise.all(ssrContext.beforeRenderFns.map((fn) => promisify(fn, { Components, nuxtState: ssrContext.nuxt }))) + <% if (store) { %> + // Add the state from the vuex store + ssrContext.nuxt.state = store.state + <% } %> + } + const renderErrorPage = async () => { + // Load layout for error page + let errLayout = (typeof NuxtError.layout === 'function' ? NuxtError.layout(app.context) : NuxtError.layout) + ssrContext.nuxt.layout = errLayout || '' + await _app.loadLayout(errLayout) + _app.setLayout(errLayout) + await beforeRender() + return _app + } + const render404Page = async () => { + app.context.error({ statusCode: 404, message: '<%= messages.error_404 %>' }) + return await renderErrorPage() + } <% if (isDev) { %>const s = isDev && Date.now()<% } %> - // Resolve components - let Components = [] - try { - Components = await Promise.all(getMatchedComponents(router.match(context.url)).map(Component => { - if (typeof Component !== 'function' || Component.cid) { - return sanitizeComponent(Component) - } - return Component().then(Component => sanitizeComponent(Component)) - })) - } catch (err) { - // Throw back error to renderRoute() - throw err - } + // Components are already resolved by setContext -> getRouteData (app/utils.js) + const Components = getMatchedComponents(router.match(ssrContext.url)) <% if (store) { %> - // Dispatch store nuxtServerInit + /* + ** Dispatch store nuxtServerInit + */ if (store._actions && store._actions.nuxtServerInit) { - await store.dispatch('nuxtServerInit', ctx) + await store.dispatch('nuxtServerInit', app.context) } - // ...If there is a redirect - if (context.redirected) return noopApp() + // ...If there is a redirect or an error, stop the process + if (ssrContext.redirected) return noopApp() + if (ssrContext.nuxt.error) return await renderErrorPage() <% } %> - // Call global middleware (nuxt.config.js) + /* + ** Call global middleware (nuxt.config.js) + */ let midd = <%= serialize(router.middleware, { isJSON: true }) %> midd = midd.map((name) => { if (typeof middleware[name] !== 'function') { - context.nuxt.error = context.error({ statusCode: 500, message: 'Unknown middleware ' + name }) + ssrContext.error({ statusCode: 500, message: 'Unknown middleware ' + name }) } return middleware[name] }) - if (!context.nuxt.error) { - await middlewareSeries(midd, ctx) - } - // ...If there is a redirect - if (context.redirected) return noopApp() + await middlewareSeries(midd, app.context) + // ...If there is a redirect or an error, stop the process + if (ssrContext.redirected) return noopApp() + if (ssrContext.nuxt.error) return await renderErrorPage() - // Set layout + /* + ** Set layout + */ let layout = Components.length ? Components[0].options.layout : NuxtError.layout - if (typeof layout === 'function') layout = layout(ctx) + if (typeof layout === 'function') layout = layout(app.context) await _app.loadLayout(layout) layout = _app.setLayout(layout) // ...Set layout to __NUXT__ - context.nuxt.layout = _app.layoutName + ssrContext.nuxt.layout = _app.layoutName - // Call middleware (layout + pages) - if (!context.nuxt.error) { - midd = [] - if (layout.middleware) midd = midd.concat(layout.middleware) - Components.forEach((Component) => { - if (Component.options.middleware) { - midd = midd.concat(Component.options.middleware) - } - }) - midd = midd.map((name) => { - if (typeof middleware[name] !== 'function') { - context.nuxt.error = context.error({ statusCode: 500, message: 'Unknown middleware ' + name }) - } - return middleware[name] - }) + /* + ** Call middleware (layout + pages) + */ + midd = [] + if (layout.middleware) midd = midd.concat(layout.middleware) + Components.forEach((Component) => { + if (Component.options.middleware) { + midd = midd.concat(Component.options.middleware) + } + }) + midd = midd.map((name) => { + if (typeof middleware[name] !== 'function') { + app.context.error({ statusCode: 500, message: 'Unknown middleware ' + name }) + } + return middleware[name] + }) + await middlewareSeries(midd, app.context) + // ...If there is a redirect or an error, stop the process + if (ssrContext.redirected) return noopApp() + if (ssrContext.nuxt.error) return await renderErrorPage() - await middlewareSeries(midd, ctx) - - // If there is a redirect - if (context.redirected) return noopApp() - } - - // Call .validate() + /* + ** Call .validate() + */ let isValid = true Components.forEach((Component) => { if (!isValid) return if (typeof Component.options.validate !== 'function') return isValid = Component.options.validate({ - params: context.route.params || {}, - query: context.route.query || {}, - <%= (store ? 'store: ctx.store' : '') %> + params: app.context.route.params || {}, + query: app.context.route.query || {}, + <%= (store ? 'store' : '') %> }) }) // ...If .validate() returned false if (!isValid) { // Don't server-render the page in generate mode - if (context._generate) { - context.nuxt.serverRendered = false - } - // Call the 404 error by making the Components array empty - Components = [] + if (ssrContext._generate) ssrContext.nuxt.serverRendered = false + // Render a 404 error page + return render404Page() } + // If no Components found, returns 404 + if (!Components.length) return render404Page() + // Call asyncData & fetch hooks on components matched by the route. let asyncDatas = await Promise.all(Components.map(Component => { let promises = [] // Call asyncData(context) if (Component.options.asyncData && typeof Component.options.asyncData === 'function') { - let promise = promisify(Component.options.asyncData, ctx) + let promise = promisify(Component.options.asyncData, app.context) promise.then(asyncDataResult => { - context.asyncData[Component.cid] = asyncDataResult + ssrContext.asyncData[Component.cid] = asyncDataResult applyAsyncData(Component) return asyncDataResult }) @@ -182,7 +187,7 @@ export default async context => { // Call fetch(context) if (Component.options.fetch) { - promises.push(Component.options.fetch(ctx)) + promises.push(Component.options.fetch(app.context)) } else { promises.push(null) @@ -191,38 +196,17 @@ export default async context => { return Promise.all(promises) })) - // If no Components found, returns 404 - if (!Components.length) { - context.nuxt.error = context.error({ statusCode: 404, message: '<%= messages.error_404 %>' }) - } - - <% if (isDev) { %>if (asyncDatas.length) debug('Data fetching ' + context.url + ': ' + (Date.now() - s) + 'ms')<% } %> + <% if (isDev) { %>if (asyncDatas.length) debug('Data fetching ' + ssrContext.url + ': ' + (Date.now() - s) + 'ms')<% } %> // datas are the first row of each - context.nuxt.data = asyncDatas.map(r => r[0] || {}) + ssrContext.nuxt.data = asyncDatas.map(r => r[0] || {}) - // If an error occured in the execution - if (_app.$options._nuxt.err) { - context.nuxt.error = _app.$options._nuxt.err - } - - <% if (store) { %> - // Add the state from the vuex store - context.nuxt.state = store.state - <% } %> - - await Promise.all(context.beforeRenderFns.map((fn) => promisify(fn, { Components, nuxtState: context.nuxt }))) - - // If no error, return main app - if (!context.nuxt.error) { - return _app - } - - // Load layout for error page - layout = (typeof NuxtError.layout === 'function' ? NuxtError.layout(ctx) : NuxtError.layout) - context.nuxt.layout = layout || '' - await _app.loadLayout(layout) - _app.setLayout(layout) + // ...If there is a redirect or an error, stop the process + if (ssrContext.redirected) return noopApp() + if (ssrContext.nuxt.error) return await renderErrorPage() + // Call beforeNuxtRender methods & add store state + await beforeRender() + return _app } diff --git a/lib/app/utils.js b/lib/app/utils.js index d98304dd73..bffc4fba74 100644 --- a/lib/app/utils.js +++ b/lib/app/utils.js @@ -11,7 +11,7 @@ if (process.browser) { } } -export function applyAsyncData (Component, asyncData) { +export function applyAsyncData(Component, asyncData) { const ComponentData = Component.options.data || noopData // Prevent calling this method for each request on SSR context if (!asyncData && Component.options.hasAsyncData) { @@ -30,7 +30,11 @@ export function applyAsyncData (Component, asyncData) { } } -export function sanitizeComponent (Component) { +export function sanitizeComponent(Component) { + // If Component already sanitized + if (Component.options && Component._Ctor === Component) { + return Component + } if (!Component.options) { Component = Vue.extend(Component) // fix issue #6 Component._Ctor = Component @@ -45,7 +49,7 @@ export function sanitizeComponent (Component) { return Component } -export function getMatchedComponents (route) { +export function getMatchedComponents(route) { return [].concat.apply([], route.matched.map(function (m) { return Object.keys(m.components).map(function (key) { return m.components[key] @@ -53,7 +57,7 @@ export function getMatchedComponents (route) { })) } -export function getMatchedComponentsInstances (route) { +export function getMatchedComponentsInstances(route) { return [].concat.apply([], route.matched.map(function (m) { return Object.keys(m.instances).map(function (key) { return m.instances[key] @@ -61,7 +65,7 @@ export function getMatchedComponentsInstances (route) { })) } -export function flatMapComponents (route, fn) { +export function flatMapComponents(route, fn) { return Array.prototype.concat.apply([], route.matched.map(function (m, index) { return Object.keys(m.components).map(function (key) { return fn(m.components[key], m.instances[key], m, key, index) @@ -69,53 +73,79 @@ export function flatMapComponents (route, fn) { })) } -export function getContext (context, app) { - let ctx = { - isServer: !!context.isServer, - isClient: !!context.isClient, - isStatic: process.static, - isDev: <%= isDev %>, - isHMR: context.isHMR || false, - app: app, - <%= (store ? 'store: context.store,' : '') %> - route: (context.to ? context.to : context.route), - payload: context.payload, - error: context.error, - base: '<%= router.base %>', - env: <%= JSON.stringify(env) %> - } - const next = context.next - ctx.params = ctx.route.params || {} - ctx.query = ctx.route.query || {} - ctx.redirect = function (status, path, query) { - if (!status) return - ctx._redirected = true // Used in middleware - // if only 1 or 2 arguments: redirect('/') or redirect('/', { foo: 'bar' }) - if (typeof status === 'string' && (typeof path === 'undefined' || typeof path === 'object')) { - query = path || {} - path = status - status = 302 - } - next({ - path: path, - query: query, - status: status +export async function resolveRouteComponents(route) { + await Promise.all( + flatMapComponents(route, async (Component, _, match, key) => { + // If component is a function, resolve it + if (typeof Component === 'function' && !Component.options) { + Component = await Component() + } + return match.components[key] = sanitizeComponent(Component) }) - } - if (context.req) ctx.req = context.req - if (context.res) ctx.res = context.res - if (context.from) ctx.from = context.from - if (ctx.isServer && context.beforeRenderFns) { - ctx.beforeNuxtRender = (fn) => context.beforeRenderFns.push(fn) - } - if (ctx.isClient && window.__NUXT__) { - ctx.nuxtState = window.__NUXT__ - } - return ctx + ) } -export function middlewareSeries (promises, context) { - if (!promises.length || context._redirected) { +async function getRouteData(route) { + // Make sure the components are resolved (code-splitting) + await resolveRouteComponents(route) + // Send back a copy of route with meta based on Component definition + return { + ...route, + meta: getMatchedComponents(route).map((Component) => { + return Component.options.meta || {} + }) + } +} + +export async function setContext(app, context) { + const route = (context.to ? context.to : context.route) + // If context not defined, create it + if (!app.context) { + app.context = { + isServer: !!context.isServer, + isClient: !!context.isClient, + isStatic: process.static, + isDev: <%= isDev %>, + isHMR: false, + app, + <%= (store ? 'store: app.store,' : '') %> + payload: context.payload, + error: context.error, + base: '<%= router.base %>', + env: <%= JSON.stringify(env) %> + } + // Only set once + if (context.req) app.context.req = context.req + if (context.res) app.context.res = context.res + app.context.redirect = function (status, path, query) { + if (!status) return + ctx._redirected = true // Used in middleware + // if only 1 or 2 arguments: redirect('/') or redirect('/', { foo: 'bar' }) + if (typeof status === 'string' && (typeof path === 'undefined' || typeof path === 'object')) { + query = path || {} + path = status + status = 302 + } + app.context.next({ + path: path, + query: query, + status: status + }) + } + if (app.context.isServer) app.context.beforeNuxtRender = (fn) => context.beforeRenderFns.push(fn) + if (app.context.isClient) app.context.nuxtState = window.__NUXT__ + } + // Dynamic keys + app.context.next = context.next + app.context.isHMR = !!context.isHMR + if (context.route) app.context.route = await getRouteData(context.route) + app.context.params = app.context.route.params || {} + app.context.query = app.context.route.query || {} + if (context.from) app.context.from = await getRouteData(context.from) +} + +export function middlewareSeries(promises, appContext) { + if (!promises.length || appContext._redirected || appContext.app.nuxt.err) { return Promise.resolve() } return promisify(promises[0], context) @@ -124,7 +154,7 @@ export function middlewareSeries (promises, context) { }) } -export function promisify (fn, context) { +export function promisify(fn, context) { let promise if (fn.length === 2) { // fn(context, callback) @@ -147,7 +177,7 @@ export function promisify (fn, context) { } // Imported from vue-router -export function getLocation (base, mode) { +export function getLocation(base, mode) { var path = window.location.pathname if (mode === 'hash') { return window.location.hash.replace(/^#\//, '') @@ -158,7 +188,7 @@ export function getLocation (base, mode) { return (path || '/') + window.location.search + window.location.hash } -export function urlJoin () { +export function urlJoin() { return [].slice.call(arguments).join('/').replace(/\/+/g, '/') } @@ -171,7 +201,7 @@ export function urlJoin () { * @param {Object=} options * @return {!function(Object=, Object=)} */ -export function compile (str, options) { +export function compile(str, options) { return tokensToFunction(parse(str, options)) } @@ -200,7 +230,7 @@ const PATH_REGEXP = new RegExp([ * @param {Object=} options * @return {!Array} */ -function parse (str, options) { +function parse(str, options) { var tokens = [] var key = 0 var index = 0 @@ -272,7 +302,7 @@ function parse (str, options) { * @param {string} * @return {string} */ -function encodeURIComponentPretty (str) { +function encodeURIComponentPretty(str) { return encodeURI(str).replace(/[\/?#]/g, function (c) { return '%' + c.charCodeAt(0).toString(16).toUpperCase() }) @@ -284,7 +314,7 @@ function encodeURIComponentPretty (str) { * @param {string} * @return {string} */ -function encodeAsterisk (str) { +function encodeAsterisk(str) { return encodeURI(str).replace(/[?#]/g, function (c) { return '%' + c.charCodeAt(0).toString(16).toUpperCase() }) @@ -293,7 +323,7 @@ function encodeAsterisk (str) { /** * Expose a method for transforming tokens into the path function. */ -function tokensToFunction (tokens) { +function tokensToFunction(tokens) { // Compile all the tokens into regexps. var matches = new Array(tokens.length) @@ -304,7 +334,7 @@ function tokensToFunction (tokens) { } } - return function (obj, opts) { + return function(obj, opts) { var path = '' var data = obj || {} var options = opts || {} @@ -380,7 +410,7 @@ function tokensToFunction (tokens) { * @param {string} str * @return {string} */ -function escapeString (str) { +function escapeString(str) { return str.replace(/([.+*?=^!:${}()[\]|\/\\])/g, '\\$1') } @@ -390,6 +420,6 @@ function escapeString (str) { * @param {string} group * @return {string} */ -function escapeGroup (group) { +function escapeGroup(group) { return group.replace(/([=!:$\/()])/g, '\\$1') } diff --git a/lib/builder/builder.js b/lib/builder/builder.js index acffbfe671..fb543a95e6 100644 --- a/lib/builder/builder.js +++ b/lib/builder/builder.js @@ -184,7 +184,7 @@ export default class Builder extends Tapable { debug('Generating files...') // -- Templates -- let templatesFiles = [ - 'App.vue', + 'App.js', 'client.js', 'index.js', 'middleware.js', @@ -196,7 +196,7 @@ export default class Builder extends Tapable { 'components/nuxt-loading.vue', 'components/nuxt-child.js', 'components/nuxt-link.js', - 'components/nuxt.vue', + 'components/nuxt.js', 'components/no-ssr.js', 'views/app.template.html', 'views/error.html' @@ -215,7 +215,7 @@ export default class Builder extends Tapable { store: this.options.store, css: this.options.css, plugins: this.plugins, - appPath: './App.vue', + appPath: './App.js', layouts: Object.assign({}, this.options.layouts), loading: typeof this.options.loading === 'string' ? this.relativeToBuild(this.options.srcDir, this.options.loading) : this.options.loading, transition: this.options.transition, From 83c25084f1b267775ad094612c8f6b5eadf0980e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Chopin?= Date: Mon, 16 Oct 2017 10:40:08 +0200 Subject: [PATCH 129/316] Refacto client app --- lib/app/client.js | 115 +++++++++++++++++++--------------------------- 1 file changed, 47 insertions(+), 68 deletions(-) diff --git a/lib/app/client.js b/lib/app/client.js index b4087f8129..5cc56ad020 100644 --- a/lib/app/client.js +++ b/lib/app/client.js @@ -4,10 +4,11 @@ import { createApp, NuxtError } from './index' import { applyAsyncData, sanitizeComponent, + resolveRouteComponents, getMatchedComponents, getMatchedComponentsInstances, flatMapComponents, - getContext, + setContext, middlewareSeries, promisify, getLocation, @@ -96,40 +97,25 @@ function mapTransitions(Components, to, from) { } async function loadAsyncComponents (to, from, next) { - // Check if route hash changed + // Check if route hash changed (this._hashChanged) const fromPath = from.fullPath.split('#')[0] const toPath = to.fullPath.split('#')[0] this._hashChanged = fromPath === toPath <% if (loading) { %> if (!this._hashChanged && this.$loading.start) { - this.$loading.start() + this.$loading.start() } <% } %> try { - await Promise.all(flatMapComponents(to, (Component, _, match, key) => { - // If component already resolved - if (typeof Component !== 'function' || Component.options) { - const _Component = sanitizeComponent(Component) - match.components[key] = _Component - return _Component - } - - // Resolve component - return Component().then(Component => { - const _Component = sanitizeComponent(Component) - match.components[key] = _Component - return _Component - }) - })) - + await resolveRouteComponents(to) next() } catch (err) { - if (!err) err = {} - const statusCode = err.statusCode || err.status || (err.response && err.response.status) || 500 - this.error({ statusCode, message: err.message }) - next(false) + err = err || {} + const statusCode = err.statusCode || err.status || (err.response && err.response.status) || 500 + this.error({ statusCode, message: err.message }) + next(false) } } @@ -145,20 +131,15 @@ function applySSRData(Component, ssrData) { function resolveComponents(router) { const path = getLocation(router.options.base, router.options.mode) - return flatMapComponents(router.match(path), (Component, _, match, key, index) => { - // If component already resolved - if (typeof Component !== 'function' || Component.options) { - const _Component = applySSRData(sanitizeComponent(Component), NUXT.data ? NUXT.data[index] : null) - match.components[key] = _Component - return _Component + return flatMapComponents(router.match(path), async (Component, _, match, key, index) => { + // If component is not resolved yet, resolve it + if (typeof Component === 'function' && !Component.options) { + Component = await Component() } - - // Resolve component - return Component().then(Component => { - const _Component = applySSRData(sanitizeComponent(Component), NUXT.data ? NUXT.data[index] : null) - match.components[key] = _Component - return _Component - }) + // Sanitize it and save it + const _Component = applySSRData(sanitizeComponent(Component), NUXT.data ? NUXT.data[index] : null) + match.components[key] = _Component + return _Component }) } @@ -204,17 +185,13 @@ async function render (to, from, next) { } // Update context - const context = getContext({ - to, + setContext(app, { + route: to, from, - <% if (store) { %>store,<% } %> - isClient: true, - next: _next.bind(this), - error: this.error.bind(this) - }, app) - this._context = context - this._dateLastError = this.$options._nuxt.dateErr - this._hadError = !!this.$options._nuxt.err + next: _next.bind(this) + }) + this._dateLastError = app.nuxt.dateErr + this._hadError = !!app.nuxt.err // Get route's matched components const Components = getMatchedComponents(to) @@ -222,15 +199,14 @@ async function render (to, from, next) { // If no Components matched, generate 404 if (!Components.length) { // Default layout - await callMiddleware.call(this, Components, context) - if (context._redirected) return - + await callMiddleware.call(this, Components, app.context) + if (app.context._redirected) return // Load layout for error page - const layout = await this.loadLayout(typeof NuxtError.layout === 'function' ? NuxtError.layout(context) : NuxtError.layout) + const layout = await this.loadLayout(typeof NuxtError.layout === 'function' ? NuxtError.layout(app.context) : NuxtError.layout) await callMiddleware.call(this, Components, context, layout) if (context._redirected) return - - this.error({ statusCode: 404, message: '<%= messages.error_404 %>' }) + // Show error page + app.context.error({ statusCode: 404, message: '<%= messages.error_404 %>' }) return next() } @@ -247,19 +223,19 @@ async function render (to, from, next) { try { // Call middleware - await callMiddleware.call(this, Components, context) - if (context._redirected) return + await callMiddleware.call(this, Components, app.context) + if (app.context._redirected) return // Set layout let layout = Components[0].options.layout if (typeof layout === 'function') { - layout = layout(context) + layout = layout(app.context) } layout = await this.loadLayout(layout) // Call middleware for layout - await callMiddleware.call(this, Components, context, layout) - if (context._redirected) return + await callMiddleware.call(this, Components, app.context, layout) + if (app.context._redirected) return // Call .validate() let isValid = true @@ -269,7 +245,7 @@ async function render (to, from, next) { isValid = Component.options.validate({ params: to.params || {}, query : to.query || {}, - <% if(store) { %>store: context.store <% } %> + <% if(store) { %>store<% } %> }) }) // ...If .validate() returned false @@ -294,7 +270,7 @@ async function render (to, from, next) { // Call asyncData(context) if (hasAsyncData) { - const promise = promisify(Component.options.asyncData, context) + const promise = promisify(Component.options.asyncData, app.context) .then(asyncDataResult => { applyAsyncData(Component, asyncDataResult) <% if(loading) { %>if(this.$loading.increase) this.$loading.increase(loadingIncrease)<% } %> @@ -304,7 +280,7 @@ async function render (to, from, next) { // Call fetch(context) if (hasFetch) { - let p = Component.options.fetch(context) + let p = Component.options.fetch(app.context) if (!p || (!(p instanceof Promise) && (typeof p.then !== 'function'))) { p = Promise.resolve(p) } @@ -332,7 +308,7 @@ async function render (to, from, next) { // Load error layout let layout = NuxtError.layout if (typeof layout === 'function') { - layout = layout(context) + layout = layout(app.context) } await this.loadLayout(layout) @@ -376,14 +352,14 @@ function fixPrepatch (to, ___) { }) // Hide error component if no error - if (this._hadError && this._dateLastError === this.$options._nuxt.dateErr) { + if (this._hadError && this._dateLastError === this.$options.nuxt.dateErr) { this.error() } // Set layout - let layout = this.$options._nuxt.err ? NuxtError.layout : to.matched[0].components.default.options.layout + let layout = this.$options.nuxt.err ? NuxtError.layout : to.matched[0].components.default.options.layout if (typeof layout === 'function') { - layout = layout(this._context) + layout = layout(app.context) } this.setLayout(layout) @@ -459,9 +435,13 @@ function addHotReload ($component, depth) { <%= (loading ? 'this.$loading.finish && this.$loading.finish()' : '') %> router.push(path) } - let context = getContext({ route: router.currentRoute<%= (store ? ', store' : '') %>, isClient: true, isHMR: true, next: next.bind(this), error: this.error }, app) + setContext(app, { + route: router.currentRoute, + isHMR: true, + next: next.bind(this) + }) <%= (loading ? 'this.$loading.start && this.$loading.start()' : '') %> - callMiddleware.call(this, Components, context) + callMiddleware.call(this, Components, app.context) .then(() => { // If layout changed if (depth !== 0) return Promise.resolve() @@ -538,7 +518,7 @@ async function mountApp(__app) { } // Enable transitions - _app.setTransitions = _app.$options._nuxt.setTransitions.bind(_app) + _app.setTransitions = _app.$options.nuxt.setTransitions.bind(_app) if (Components.length) { _app.setTransitions(mapTransitions(Components, router.currentRoute)) _lastPaths = router.currentRoute.matched.map(route => compile(route.path)(router.currentRoute.params)) @@ -546,7 +526,6 @@ async function mountApp(__app) { } // Initialize error handler - _app.error = _app.$options._nuxt.error.bind(_app) _app.$loading = {} // To avoid error while _app.$nuxt does not exist if (NUXT.error) _app.error(NUXT.error) From 7afa5e4c13e54a1e2e2d0e7ba1efd07927ddd078 Mon Sep 17 00:00:00 2001 From: Sebastien Chopin Date: Mon, 16 Oct 2017 16:36:21 +0200 Subject: [PATCH 130/316] Fix serverMiddleware as express app without path --- lib/core/renderer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/core/renderer.js b/lib/core/renderer.js index ee5f279c84..0bdef1ab06 100644 --- a/lib/core/renderer.js +++ b/lib/core/renderer.js @@ -182,7 +182,7 @@ export default class Renderer extends Tapable { } const handler = m.handler || m - const path = (((m.prefix !== false) ? this.options.router.base : '') + (m.path ? m.path : '')).replace(/\/\//g, '/') + const path = (((m.prefix !== false) ? this.options.router.base : '') + (typeof m.path === 'string' ? m.path : '')).replace(/\/\//g, '/') // Inject $src and $m to final handler if (src) handler.$src = src From abf7174602c98260ced9e6915bb2082818d8c51e Mon Sep 17 00:00:00 2001 From: Sebastien Chopin Date: Tue, 17 Oct 2017 12:31:49 +0200 Subject: [PATCH 131/316] Upgrade dependencies --- package.json | 30 +++++++++++++++--------------- start/package.json | 5 ++--- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/package.json b/package.json index 92befe2339..9622dcb1e7 100644 --- a/package.json +++ b/package.json @@ -66,7 +66,7 @@ "dependencies": { "@nuxtjs/youch": "3.1.0", "ansi-html": "^0.0.7", - "autoprefixer": "^7.1.4", + "autoprefixer": "^7.1.5", "babel-core": "^6.26.0", "babel-loader": "^7.1.2", "babel-preset-vue-app": "^1.3.1", @@ -98,7 +98,7 @@ "postcss": "^6.0.13", "postcss-cssnext": "^3.0.2", "postcss-import": "^11.0.0", - "postcss-loader": "^2.0.6", + "postcss-loader": "^2.0.8", "postcss-url": "^7.1.2", "pretty-error": "^2.1.1", "progress-bar-webpack-plugin": "^1.10.0", @@ -109,17 +109,17 @@ "source-map-support": "^0.5.0", "tappable": "^1.1.0", "url-loader": "^0.6.2", - "vue": "~2.5.2", - "vue-loader": "^13.0.5", + "vue": "^2.5.2", + "vue-loader": "^13.3.0", "vue-meta": "^1.2.0", - "vue-router": "^2.7.0", - "vue-server-renderer": "~2.5.2", - "vue-template-compiler": "~2.5.2", + "vue-router": "^3.0.1", + "vue-server-renderer": "^2.5.2", + "vue-template-compiler": "^2.5.2", "vuex": "^3.0.0", - "webpack": "^3.6.0", + "webpack": "^3.8.0", "webpack-bundle-analyzer": "^2.9.0", "webpack-dev-middleware": "^1.12.0", - "webpack-hot-middleware": "^2.19.1", + "webpack-hot-middleware": "^2.20.0", "webpack-node-externals": "^1.6.0" }, "devDependencies": { @@ -128,17 +128,17 @@ "babel-plugin-array-includes": "^2.0.3", "babel-plugin-external-helpers": "^6.22.0", "babel-plugin-istanbul": "^4.1.5", - "codecov": "^2.3.0", + "codecov": "^2.3.1", "copy-webpack-plugin": "^4.1.1", - "cross-env": "^5.0.5", - "eslint": "^4.8.0", + "cross-env": "^5.1.0", + "eslint": "^4.9.0", "eslint-config-standard": "^10.2.1", "eslint-plugin-html": "^3.2.2", "eslint-plugin-import": "^2.7.0", "eslint-plugin-node": "^5.2.0", - "eslint-plugin-promise": "^3.5.0", + "eslint-plugin-promise": "^3.6.0", "eslint-plugin-standard": "^3.0.1", - "express": "^4.16.1", + "express": "^4.16.2", "finalhandler": "^1.1.0", "jsdom": "^11.3.0", "json-loader": "^0.5.7", @@ -154,7 +154,7 @@ "rollup-plugin-replace": "^2.0.0", "rollup-watch": "^4.3.1", "std-mocks": "^1.0.1", - "uglify-js": "^3.1.3" + "uglify-js": "^3.1.4" }, "collective": { "type": "opencollective", diff --git a/start/package.json b/start/package.json index c3a0b495a8..f775eee62c 100644 --- a/start/package.json +++ b/start/package.json @@ -58,15 +58,14 @@ "serialize-javascript": "^1.4.0", "etag": "^1.8.1", "fresh": "^0.5.2", - "pify": "^3.0.0", "serve-static": "^1.13.1", "compression": "^1.7.1", "fs-extra": "^4.0.2", - "vue-server-renderer": "~2.5.2", + "vue-server-renderer": "^2.5.2", "@nuxtjs/youch": "3.1.0", "source-map": "^0.6.1", "connect": "^3.6.5", - "vue": "~2.5.2", + "vue": "^2.5.2", "vue-meta": "^1.2.0", "lru-cache": "^4.1.1", "server-destroy": "^1.0.1", From e3974b4729bfe1784f75337bab61a63bc2a5d0c9 Mon Sep 17 00:00:00 2001 From: Sebastien Chopin Date: Fri, 20 Oct 2017 12:05:22 +0200 Subject: [PATCH 132/316] deprecation: Deprecate isServer, isClient and dev --- lib/app/index.js | 2 -- lib/app/server.js | 2 +- lib/app/utils.js | 14 ++++++++++---- lib/builder/webpack/client.config.js | 8 +++++++- lib/builder/webpack/server.config.js | 8 +++++++- lib/core/renderer.js | 2 -- 6 files changed, 25 insertions(+), 11 deletions(-) diff --git a/lib/app/index.js b/lib/app/index.js index ffbe374972..b40dec9436 100644 --- a/lib/app/index.js +++ b/lib/app/index.js @@ -107,8 +107,6 @@ async function createApp (ssrContext) { // Set context to app.context await setContext(app, { - isServer: !!ssrContext, - isClient: !ssrContext, route, next, error: app.nuxt.error.bind(app), diff --git a/lib/app/server.js b/lib/app/server.js index 427633defc..61175aac5e 100644 --- a/lib/app/server.js +++ b/lib/app/server.js @@ -207,6 +207,6 @@ export default async ssrContext => { // Call beforeNuxtRender methods & add store state await beforeRender() - + return _app } diff --git a/lib/app/utils.js b/lib/app/utils.js index bffc4fba74..f3cbeefc7f 100644 --- a/lib/app/utils.js +++ b/lib/app/utils.js @@ -102,8 +102,14 @@ export async function setContext(app, context) { // If context not defined, create it if (!app.context) { app.context = { - isServer: !!context.isServer, - isClient: !!context.isClient, + get isServer() { + console.warn('context.isServer has been deprecated, please use process.server instead.') + return process.server + }, + get isClient() { + console.warn('context.isClient has been deprecated, please use process.client instead.') + return process.client + }, isStatic: process.static, isDev: <%= isDev %>, isHMR: false, @@ -132,8 +138,8 @@ export async function setContext(app, context) { status: status }) } - if (app.context.isServer) app.context.beforeNuxtRender = (fn) => context.beforeRenderFns.push(fn) - if (app.context.isClient) app.context.nuxtState = window.__NUXT__ + if (process.server) app.context.beforeNuxtRender = (fn) => context.beforeRenderFns.push(fn) + if (process.client) app.context.nuxtState = window.__NUXT__ } // Dynamic keys app.context.next = context.next diff --git a/lib/builder/webpack/client.config.js b/lib/builder/webpack/client.config.js index 7f6a5da9ea..eee26861ef 100644 --- a/lib/builder/webpack/client.config.js +++ b/lib/builder/webpack/client.config.js @@ -129,6 +129,7 @@ export default function webpackClientConfig () { 'process.env.VUE_ENV': JSON.stringify('client'), 'process.mode': JSON.stringify(this.options.mode), 'process.browser': true, + 'process.client': true, 'process.server': false, 'process.static': this.isStatic })) @@ -220,8 +221,13 @@ export default function webpackClientConfig () { // Extend config if (typeof this.options.build.extend === 'function') { + const isDev = this.options.dev const extendedConfig = this.options.build.extend.call(this, config, { - dev: this.options.dev, + get dev () { + console.warn('dev has been deprecated into build.extend, please use isDev') // eslint-disable-line no-console + return isDev + }, + isDev, isClient: true }) // Only overwrite config when something is returned for backwards compatibility diff --git a/lib/builder/webpack/server.config.js b/lib/builder/webpack/server.config.js index 7009ed5603..6e2ebf6cfc 100644 --- a/lib/builder/webpack/server.config.js +++ b/lib/builder/webpack/server.config.js @@ -43,6 +43,7 @@ export default function webpackServerConfig () { 'process.env.VUE_ENV': JSON.stringify('server'), 'process.mode': JSON.stringify(this.options.mode), 'process.browser': false, + 'process.client': false, 'process.server': true, 'process.static': this.isStatic })) @@ -75,8 +76,13 @@ export default function webpackServerConfig () { // Extend config if (typeof this.options.build.extend === 'function') { + const isDev = this.options.dev const extendedConfig = this.options.build.extend.call(this, config, { - dev: this.options.dev, + get dev () { + console.warn('dev has been deprecated into build.extend, please use isDev') // eslint-disable-line no-console + return isDev + }, + isDev, isServer: true }) // Only overwrite config when something is returned for backwards compatibility diff --git a/lib/core/renderer.js b/lib/core/renderer.js index 0bdef1ab06..97ce462f90 100644 --- a/lib/core/renderer.js +++ b/lib/core/renderer.js @@ -111,7 +111,6 @@ export default class Renderer extends Tapable { await this.applyPluginsAsync('resourcesLoaded', this.resources) if (updated.length > 0) { - // debug('Updated', updated.join(', '), isServer) this.createRenderer() } } @@ -484,7 +483,6 @@ export default class Renderer extends Tapable { // Add url and isSever to the context context.url = url - context.isServer = true // Basic response if SSR is disabled or spa data provided const spa = context.spa || (context.res && context.res.spa) From e711e8e431f0c83945a7686d4c899353b2d65fec Mon Sep 17 00:00:00 2001 From: Ademola Adegbuyi Date: Fri, 20 Oct 2017 13:31:29 +0100 Subject: [PATCH 133/316] Add with-tape example --- examples/with-tape/package.json | 21 +++++++++++++ examples/with-tape/pages/index.vue | 31 +++++++++++++++++++ examples/with-tape/test/index.test.js | 43 +++++++++++++++++++++++++++ examples/with-tape/test/setup.js | 14 +++++++++ 4 files changed, 109 insertions(+) create mode 100755 examples/with-tape/package.json create mode 100755 examples/with-tape/pages/index.vue create mode 100755 examples/with-tape/test/index.test.js create mode 100644 examples/with-tape/test/setup.js diff --git a/examples/with-tape/package.json b/examples/with-tape/package.json new file mode 100755 index 0000000000..afb974ee4a --- /dev/null +++ b/examples/with-tape/package.json @@ -0,0 +1,21 @@ +{ + "name": "nuxt-with-tape", + "scripts": { + "dev": "nuxt", + "build": "nuxt build", + "start": "nuxt start", + "test": "tape ./test/**/*.js -r ./test/setup.js | tap-spec" + }, + "devDependencies": { + "browser-env": "^3.2.1", + "require-extension-hooks": "^0.3.2", + "require-extension-hooks-babel": "^0.1.1", + "require-extension-hooks-vue": "^0.4.1", + "tap-spec": "^4.1.1", + "tape": "^4.8.0", + "vue-test-utils": "^1.0.0-beta.2" + }, + "dependencies": { + "nuxt": "latest" + } +} diff --git a/examples/with-tape/pages/index.vue b/examples/with-tape/pages/index.vue new file mode 100755 index 0000000000..1ceb0086e2 --- /dev/null +++ b/examples/with-tape/pages/index.vue @@ -0,0 +1,31 @@ + + + + + diff --git a/examples/with-tape/test/index.test.js b/examples/with-tape/test/index.test.js new file mode 100755 index 0000000000..f586b68538 --- /dev/null +++ b/examples/with-tape/test/index.test.js @@ -0,0 +1,43 @@ +import test from 'tape' +import { shallow } from 'vue-test-utils' +import Index from '../pages/index.vue' + +test('renders Index.vue correctly', t => { + t.plan(4) + + const wrapper = shallow(Index, { + data: { + name: 'nuxt' + } + }) + + const button = wrapper.find('button') + + t.equal( + wrapper.find('h1').text(), + 'Hello nuxt!', + 'renders "Hello nuxt!" text' + ) + + t.equal( + wrapper.find('h1').hasClass('red'), + true, + 'h1 has a red class [default]' + ) + + button.trigger('click') + + t.equal( + wrapper.find('h1').hasClass('blue'), + true, + 'h1 class changes to blue [after 1st click]' + ) + + button.trigger('click') + + t.equal( + wrapper.find('h1').hasClass('green'), + true, + 'h1 class changes to green [after 2nd click]' + ) +}) diff --git a/examples/with-tape/test/setup.js b/examples/with-tape/test/setup.js new file mode 100644 index 0000000000..2e41fab524 --- /dev/null +++ b/examples/with-tape/test/setup.js @@ -0,0 +1,14 @@ +const hooks = require('require-extension-hooks') + +// Setup browser environment +require('browser-env')() + +// Setup vue files to be processed by `require-extension-hooks-vue` +hooks('vue') + .plugin('vue') + .push() + +// Setup vue and js files to be processed by `require-extension-hooks-babel` +hooks(['vue', 'js']) + .plugin('babel') + .push() From 37c23c33d237e4d953f050afe0bcfaf0836c3046 Mon Sep 17 00:00:00 2001 From: Clark Du Date: Sat, 21 Oct 2017 21:05:07 +0800 Subject: [PATCH 134/316] feat: update nuxt to latest in apollo example --- examples/vue-apollo/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/vue-apollo/package.json b/examples/vue-apollo/package.json index f26ec4014c..c9ffee9f88 100644 --- a/examples/vue-apollo/package.json +++ b/examples/vue-apollo/package.json @@ -2,7 +2,7 @@ "name": "nuxt-vue-apollo", "dependencies": { "@nuxtjs/apollo": "^2.1.1", - "nuxt": "^1.0.0-rc9" + "nuxt": "latest" }, "scripts": { "dev": "nuxt", From 671b8d0759d602398d196abf5fbaef651e7cfd87 Mon Sep 17 00:00:00 2001 From: Paul Gascou-Vaillancourt Date: Sat, 21 Oct 2017 12:32:44 -0400 Subject: [PATCH 135/316] Fix CONTRIBUTING.md link --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 75f5826a6b..4a75680844 100644 --- a/README.md +++ b/README.md @@ -254,4 +254,4 @@ Note: we recommend putting `.nuxt` in `.npmignore` or `.gitignore`. https://github.com/nuxt/nuxt.js/projects/1 ## Contributing -Please see our [contributing.md](./contributing.md) \ No newline at end of file +Please see our [CONTRIBUTING.md](./CONTRIBUTING.md) From 386096a21e9d6d0c37830059aca49eeec24a949a Mon Sep 17 00:00:00 2001 From: Clark Du Date: Sun, 22 Oct 2017 12:43:05 +0800 Subject: [PATCH 136/316] feat: update nuxt to latest in typescript example --- examples/typescript/package.json | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/examples/typescript/package.json b/examples/typescript/package.json index 17973f83f6..5e795aa8a0 100644 --- a/examples/typescript/package.json +++ b/examples/typescript/package.json @@ -4,12 +4,15 @@ "dependencies": { "axios": "^0.16.1", "gsap": "^1.19.1", - "nuxt": "^1.0.0-alpha2", - "nuxt-class-component": "^1.0.1", + "nuxt": "latest", + "nuxt-class-component": "^1.0.3", "tachyons": "^4.7.0", - "vue-class-component": "^5.0.1", - "vue-property-decorator": "^5.0.1", - "vuex-class": "^0.2.0" + "vue": "~2.5.1", + "vue-server-renderer": "~2.5.1", + "vue-template-compiler": "~2.5.1", + "vue-class-component": "^6.0.0", + "vue-property-decorator": "^6.0.0", + "vuex-class": "^0.3.0" }, "scripts": { "dev": "nuxt", @@ -18,7 +21,7 @@ "generate": "nuxt generate" }, "devDependencies": { - "ts-loader": "^2.0.3", + "ts-loader": "^3.0.0", "typescript": "^2.2.2" } } From c0a6ed9ea3eea7e2ee8563502041a3054d199180 Mon Sep 17 00:00:00 2001 From: Clark Du Date: Sun, 22 Oct 2017 12:44:33 +0800 Subject: [PATCH 137/316] fix: error alias in typescript example --- examples/typescript/nuxt.config.js | 2 +- examples/typescript/pages/index.vue | 4 +- examples/typescript/store/index.ts | 66 ++++++++++++++--------------- 3 files changed, 36 insertions(+), 36 deletions(-) diff --git a/examples/typescript/nuxt.config.js b/examples/typescript/nuxt.config.js index e6c3bdf87d..cc6493b7ed 100644 --- a/examples/typescript/nuxt.config.js +++ b/examples/typescript/nuxt.config.js @@ -22,5 +22,5 @@ module.exports = { build: { vendor: ['axios', 'gsap', 'vuex-class', 'nuxt-class-component'] }, - modules: ['~modules/typescript'] + modules: ['~/modules/typescript'] } diff --git a/examples/typescript/pages/index.vue b/examples/typescript/pages/index.vue index f92713be3c..a241284c62 100644 --- a/examples/typescript/pages/index.vue +++ b/examples/typescript/pages/index.vue @@ -16,7 +16,7 @@ \ No newline at end of file + diff --git a/examples/typescript/store/index.ts b/examples/typescript/store/index.ts index 292c381318..bfffcd5175 100644 --- a/examples/typescript/store/index.ts +++ b/examples/typescript/store/index.ts @@ -1,33 +1,33 @@ -import axios from "~plugins/axios"; - -export const state = () => ({ - selected: 1, - people: [] -}); - -export const mutations = { - select(state, id) { - state.selected = id; - }, - setPeople(state, people) { - state.people = people; - } -}; - -export const getters = { - selectedPerson: state => { - const p = state.people.find(person => person.id === state.selected); - return p ? p : { first_name: "Please,", last_name: "select someone" }; - } -}; - -export const actions = { - async nuxtServerInit({ commit }) { - const response = await axios.get("/random-data.json"); - const people = response.data.slice(0, 10); - commit("setPeople", people); - }, - select({ commit }, id) { - commit("select", id); - } -}; +import axios from "~/plugins/axios"; + +export const state = () => ({ + selected: 1, + people: [] +}); + +export const mutations = { + select(state, id) { + state.selected = id; + }, + setPeople(state, people) { + state.people = people; + } +}; + +export const getters = { + selectedPerson: state => { + const p = state.people.find(person => person.id === state.selected); + return p ? p : { first_name: "Please,", last_name: "select someone" }; + } +}; + +export const actions = { + async nuxtServerInit({ commit }) { + const response = await axios.get("/random-data.json"); + const people = response.data.slice(0, 10); + commit("setPeople", people); + }, + select({ commit }, id) { + commit("select", id); + } +}; From 05d0b7a3cdfb90446024189c49fba84f2ec9b562 Mon Sep 17 00:00:00 2001 From: Clark Du Date: Sun, 22 Oct 2017 12:46:19 +0800 Subject: [PATCH 138/316] fix: adjust ts config to fix startup error --- examples/typescript/modules/typescript.js | 30 ++++++++---- examples/typescript/tsconfig.json | 58 +++++++++++------------ 2 files changed, 49 insertions(+), 39 deletions(-) diff --git a/examples/typescript/modules/typescript.js b/examples/typescript/modules/typescript.js index a45d341b89..2bad37f199 100644 --- a/examples/typescript/modules/typescript.js +++ b/examples/typescript/modules/typescript.js @@ -1,16 +1,26 @@ -module.exports = function (options) { +module.exports = function(options) { // Extend build - this.extendBuild((config) => { + this.extendBuild(config => { + const tsLoader = { + loader: "ts-loader", + options: { + appendTsSuffixTo: [/\.vue$/] + } + }; // Add TypeScript loader - config.module.rules.push({ - test: /\.ts$/, - loader: 'ts-loader' - }) + config.module.rules.push( + Object.assign( + { + test: /((client|server)\.js)|(\.tsx?)$/ + }, + tsLoader + ) + ); // Add TypeScript loader for vue files for (let rule of config.module.rules) { - if (rule.loader === 'vue-loader') { - rule.query.loaders.ts = 'ts-loader?{"appendTsSuffixTo":["\\\\.vue$"]}' + if (rule.loader === "vue-loader") { + rule.options.loaders.ts = tsLoader; } } - }) -} + }); +}; diff --git a/examples/typescript/tsconfig.json b/examples/typescript/tsconfig.json index 3a40a830cd..557fd275fa 100644 --- a/examples/typescript/tsconfig.json +++ b/examples/typescript/tsconfig.json @@ -1,29 +1,29 @@ -{ - "compilerOptions": { - "target": "es5", - "lib": [ - "dom", - "es2015" - ], - "module": "es2015", - "moduleResolution": "node", - "experimentalDecorators": true, - "declaration": true, - "noImplicitAny": false, - "noImplicitThis": false, - "strictNullChecks": true, - "removeComments": true, - "suppressImplicitAnyIndexErrors": true, - "allowSyntheticDefaultImports": true, - "baseUrl": ".", - "paths": { - "~": ["./"], - "~assets/*": ["./assets/*"], - "~components/*": ["./components/*"], - "~middleware/*": ["./middleware/*"], - "~pages/*": ["./pages/*"], - "~plugins/*": ["./plugins/*"], - "~static/*": ["./static/*"] - } - } -} +{ + "compilerOptions": { + "target": "es5", + "lib": [ + "dom", + "es2015" + ], + "module": "es2015", + "moduleResolution": "node", + "experimentalDecorators": true, + "noImplicitAny": false, + "noImplicitThis": false, + "strictNullChecks": true, + "removeComments": true, + "suppressImplicitAnyIndexErrors": true, + "allowSyntheticDefaultImports": true, + "baseUrl": ".", + "allowJs": true, + "paths": { + "~/": ["./"], + "~/assets/*": ["./assets/*"], + "~/components/*": ["./components/*"], + "~/middleware/*": ["./middleware/*"], + "~/pages/*": ["./pages/*"], + "~/plugins/*": ["./plugins/*"], + "~/static/*": ["./static/*"] + } + } +} From 407569480b7ef5fa016a919f4185a0a851bf0b43 Mon Sep 17 00:00:00 2001 From: Clark Du Date: Mon, 23 Oct 2017 17:27:30 +0800 Subject: [PATCH 139/316] refactor: use nuxt-class-component in example --- examples/vue-class-component/nuxt.config.js | 3 --- examples/vue-class-component/package.json | 3 ++- .../plugins/nuxt-class-component.js | 14 -------------- 3 files changed, 2 insertions(+), 18 deletions(-) delete mode 100644 examples/vue-class-component/plugins/nuxt-class-component.js diff --git a/examples/vue-class-component/nuxt.config.js b/examples/vue-class-component/nuxt.config.js index 4e7a3097a9..4d32a9ca0a 100644 --- a/examples/vue-class-component/nuxt.config.js +++ b/examples/vue-class-component/nuxt.config.js @@ -2,9 +2,6 @@ module.exports = { build: { babel: { plugins: ['transform-decorators-legacy', 'transform-class-properties'] - }, - extend (config) { - config.resolve.alias['nuxt-class-component'] = '@/plugins/nuxt-class-component' } } } diff --git a/examples/vue-class-component/package.json b/examples/vue-class-component/package.json index e672615065..89e9d65c2a 100644 --- a/examples/vue-class-component/package.json +++ b/examples/vue-class-component/package.json @@ -4,7 +4,8 @@ "babel-plugin-transform-class-properties": "^6.24.1", "babel-plugin-transform-decorators-legacy": "^1.3.4", "nuxt": "latest", - "vue-class-component": "^5.0.1" + "nuxt-class-component": "^1.0.3", + "vue": "~2.4.2" }, "scripts": { "dev": "nuxt", diff --git a/examples/vue-class-component/plugins/nuxt-class-component.js b/examples/vue-class-component/plugins/nuxt-class-component.js deleted file mode 100644 index 2f5188d00b..0000000000 --- a/examples/vue-class-component/plugins/nuxt-class-component.js +++ /dev/null @@ -1,14 +0,0 @@ -import Component from 'vue-class-component' - -Component.registerHooks([ - 'beforeRouteEnter', - 'beforeRouteLeave', - 'asyncData', - 'fetch', - 'middleware', - 'layout', - 'transition', - 'scrollToTop' -]) - -export default Component From 72529c69da186f821be1d38d6e22866ba3d4f6f9 Mon Sep 17 00:00:00 2001 From: pimlie Date: Mon, 23 Oct 2017 23:43:59 +0200 Subject: [PATCH 140/316] dont assume /index.html exists --- lib/builder/generator.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/builder/generator.js b/lib/builder/generator.js index 950ee46b52..71a8986d55 100644 --- a/lib/builder/generator.js +++ b/lib/builder/generator.js @@ -73,11 +73,14 @@ export default class Generator extends Tapable { })) } - // Copy /index.html to /200.html for surge SPA - // https://surge.sh/help/adding-a-200-page-for-client-side-routing - const _200Path = join(this.distPath, '200.html') - if (!existsSync(_200Path)) { - await copy(join(this.distPath, 'index.html'), _200Path) + const indexPath = join(this.distPath, 'index.html') + if (existsSync(indexPath) { + // Copy /index.html to /200.html for surge SPA + // https://surge.sh/help/adding-a-200-page-for-client-side-routing + const _200Path = join(this.distPath, '200.html') + if (!existsSync(_200Path)) { + await copy(indexPath, _200Path) + } } const duration = Math.round((Date.now() - s) / 100) / 10 From 780013e59005677101c23a20d2be8873889d745a Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Wed, 25 Oct 2017 00:49:01 +0330 Subject: [PATCH 141/316] sync yarn.lock with package.json --- yarn.lock | 241 +++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 193 insertions(+), 48 deletions(-) diff --git a/yarn.lock b/yarn.lock index 9d2a96d2c4..7afe7e6eeb 100644 --- a/yarn.lock +++ b/yarn.lock @@ -326,7 +326,7 @@ autoprefixer@^6.3.1: postcss "^5.2.16" postcss-value-parser "^3.2.3" -autoprefixer@^7.1.1, autoprefixer@^7.1.4: +autoprefixer@^7.1.1: version "7.1.4" resolved "https://registry.yarnpkg.com/autoprefixer/-/autoprefixer-7.1.4.tgz#960847dbaa4016bc8e8e52ec891cbf8f1257a748" dependencies: @@ -337,6 +337,17 @@ autoprefixer@^7.1.1, autoprefixer@^7.1.4: postcss "^6.0.11" postcss-value-parser "^3.2.3" +autoprefixer@^7.1.5: + version "7.1.6" + resolved "https://registry.yarnpkg.com/autoprefixer/-/autoprefixer-7.1.6.tgz#fb933039f74af74a83e71225ce78d9fd58ba84d7" + dependencies: + browserslist "^2.5.1" + caniuse-lite "^1.0.30000748" + normalize-range "^0.1.2" + num2fraction "^1.2.2" + postcss "^6.0.13" + postcss-value-parser "^3.2.3" + ava-init@^0.2.0: version "0.2.1" resolved "https://registry.yarnpkg.com/ava-init/-/ava-init-0.2.1.tgz#75ac4c8553326290d2866e63b62fa7035684bd58" @@ -1276,6 +1287,13 @@ browserslist@^2.0.0, browserslist@^2.1.2, browserslist@^2.4.0: caniuse-lite "^1.0.30000718" electron-to-chromium "^1.3.18" +browserslist@^2.5.1: + version "2.5.1" + resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-2.5.1.tgz#68e4bc536bbcc6086d62843a2ffccea8396821c6" + dependencies: + caniuse-lite "^1.0.30000744" + electron-to-chromium "^1.3.24" + buf-compare@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/buf-compare/-/buf-compare-1.0.1.tgz#fef28da8b8113a0a0db4430b0b6467b69730b34a" @@ -1391,10 +1409,18 @@ caniuse-lite@^1.0.0, caniuse-lite@^1.0.30000718, caniuse-lite@^1.0.30000726: version "1.0.30000744" resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30000744.tgz#860fa5c83ba34fe619397d607f30bb474821671b" +caniuse-lite@^1.0.30000744, caniuse-lite@^1.0.30000748: + version "1.0.30000749" + resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30000749.tgz#2ff382865aead8cca35dacfbab04f58effa4c01c" + capture-stack-trace@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/capture-stack-trace/-/capture-stack-trace-1.0.0.tgz#4a6fa07399c26bba47f0b2496b4d0fb408c5550d" +caseless@~0.11.0: + version "0.11.0" + resolved "https://registry.yarnpkg.com/caseless/-/caseless-0.11.0.tgz#715b96ea9841593cc33067923f5ec60ebda4f7d7" + caseless@~0.12.0: version "0.12.0" resolved "https://registry.yarnpkg.com/caseless/-/caseless-0.12.0.tgz#1b681c21ff84033c826543090689420d187151dc" @@ -1557,12 +1583,12 @@ 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" -codecov@^2.3.0: - version "2.3.0" - resolved "https://registry.yarnpkg.com/codecov/-/codecov-2.3.0.tgz#ad25a2c6e0442d13740d9d4ddbb9a3e2714330f4" +codecov@^2.3.1: + version "2.3.1" + resolved "https://registry.yarnpkg.com/codecov/-/codecov-2.3.1.tgz#7dda945cd58a1f6081025b5b03ee01a2ef20f86e" dependencies: argv "0.0.2" - request "2.81.0" + request "2.77.0" urlgrey "0.4.4" color-convert@^1.3.0, color-convert@^1.8.2, color-convert@^1.9.0: @@ -1824,9 +1850,9 @@ create-hmac@^1.1.0, create-hmac@^1.1.2, create-hmac@^1.1.4: safe-buffer "^5.0.1" sha.js "^2.4.8" -cross-env@^5.0.5: - version "5.0.5" - resolved "https://registry.yarnpkg.com/cross-env/-/cross-env-5.0.5.tgz#4383d364d9660873dd185b398af3bfef5efffef3" +cross-env@^5.1.0: + version "5.1.0" + resolved "https://registry.yarnpkg.com/cross-env/-/cross-env-5.1.0.tgz#1f12d6b3777d5847dcf9cf39fbee3c6a76dd5058" dependencies: cross-spawn "^5.1.0" is-windows "^1.0.0" @@ -2245,6 +2271,10 @@ electron-to-chromium@^1.2.7, electron-to-chromium@^1.3.18: version "1.3.24" resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.24.tgz#9b7b88bb05ceb9fa016a177833cc2dde388f21b6" +electron-to-chromium@^1.3.24: + version "1.3.27" + resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.27.tgz#78ecb8a399066187bb374eede35d9c70565a803d" + elliptic@^6.0.0: version "6.4.0" resolved "https://registry.yarnpkg.com/elliptic/-/elliptic-6.4.0.tgz#cac9af8762c85836187003c8dfe193e5e2eae5df" @@ -2450,9 +2480,9 @@ eslint-plugin-node@^5.2.0: resolve "^1.3.3" semver "5.3.0" -eslint-plugin-promise@^3.5.0: - version "3.5.0" - resolved "https://registry.yarnpkg.com/eslint-plugin-promise/-/eslint-plugin-promise-3.5.0.tgz#78fbb6ffe047201627569e85a6c5373af2a68fca" +eslint-plugin-promise@^3.6.0: + version "3.6.0" + resolved "https://registry.yarnpkg.com/eslint-plugin-promise/-/eslint-plugin-promise-3.6.0.tgz#54b7658c8f454813dc2a870aff8152ec4969ba75" eslint-plugin-standard@^3.0.1: version "3.0.1" @@ -2465,9 +2495,9 @@ eslint-scope@^3.7.1: esrecurse "^4.1.0" estraverse "^4.1.1" -eslint@^4.8.0: - version "4.8.0" - resolved "https://registry.yarnpkg.com/eslint/-/eslint-4.8.0.tgz#229ef0e354e0e61d837c7a80fdfba825e199815e" +eslint@^4.9.0: + version "4.9.0" + resolved "https://registry.yarnpkg.com/eslint/-/eslint-4.9.0.tgz#76879d274068261b191fe0f2f56c74c2f4208e8b" dependencies: ajv "^5.2.0" babel-code-frame "^6.22.0" @@ -2620,7 +2650,7 @@ expand-range@^1.8.1: dependencies: fill-range "^2.1.0" -express@^4.15.2, express@^4.16.1: +express@^4.15.2: version "4.16.1" resolved "https://registry.yarnpkg.com/express/-/express-4.16.1.tgz#6b33b560183c9b253b7b62144df33a4654ac9ed0" dependencies: @@ -2655,6 +2685,41 @@ express@^4.15.2, express@^4.16.1: utils-merge "1.0.1" vary "~1.1.2" +express@^4.16.2: + version "4.16.2" + resolved "https://registry.yarnpkg.com/express/-/express-4.16.2.tgz#e35c6dfe2d64b7dca0a5cd4f21781be3299e076c" + dependencies: + accepts "~1.3.4" + array-flatten "1.1.1" + body-parser "1.18.2" + content-disposition "0.5.2" + content-type "~1.0.4" + cookie "0.3.1" + cookie-signature "1.0.6" + debug "2.6.9" + depd "~1.1.1" + encodeurl "~1.0.1" + escape-html "~1.0.3" + etag "~1.8.1" + finalhandler "1.1.0" + fresh "0.5.2" + merge-descriptors "1.0.1" + methods "~1.1.2" + on-finished "~2.3.0" + parseurl "~1.3.2" + path-to-regexp "0.1.7" + proxy-addr "~2.0.2" + qs "6.5.1" + range-parser "~1.2.0" + safe-buffer "5.1.1" + send "0.16.1" + serve-static "1.13.1" + setprototypeof "1.1.0" + statuses "~1.3.1" + type-is "~1.6.15" + utils-merge "1.0.1" + vary "~1.1.2" + extend@~3.0.0, extend@~3.0.1: version "3.0.1" resolved "https://registry.yarnpkg.com/extend/-/extend-3.0.1.tgz#a755ea7bc1adfcc5a31ce7e762dbaadc5e636444" @@ -2928,6 +2993,16 @@ gauge@~2.7.3: strip-ansi "^3.0.1" wide-align "^1.1.0" +generate-function@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/generate-function/-/generate-function-2.0.0.tgz#6858fe7c0969b7d4e9093337647ac79f60dfbe74" + +generate-object-property@^1.1.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/generate-object-property/-/generate-object-property-1.2.0.tgz#9c0e1c40308ce804f4783618b937fa88f99d50d0" + dependencies: + is-property "^1.0.0" + get-caller-file@^1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-1.0.2.tgz#f702e63127e7e231c160a80c1554acb70d5047e5" @@ -3047,6 +3122,15 @@ har-schema@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/har-schema/-/har-schema-2.0.0.tgz#a94c2224ebcac04782a0d9035521f24735b7ec92" +har-validator@~2.0.6: + version "2.0.6" + resolved "https://registry.yarnpkg.com/har-validator/-/har-validator-2.0.6.tgz#cdcbc08188265ad119b6a5a7c8ab70eecfb5d27d" + dependencies: + chalk "^1.1.1" + commander "^2.9.0" + is-my-json-valid "^2.12.4" + pinkie-promise "^2.0.0" + har-validator@~4.2.1: version "4.2.1" resolved "https://registry.yarnpkg.com/har-validator/-/har-validator-4.2.1.tgz#33481d0f1bbff600dd203d75812a6a5fba002e2a" @@ -3517,6 +3601,15 @@ is-module@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/is-module/-/is-module-1.0.0.tgz#3258fb69f78c14d5b815d664336b4cffb6441591" +is-my-json-valid@^2.12.4: + version "2.16.1" + resolved "https://registry.yarnpkg.com/is-my-json-valid/-/is-my-json-valid-2.16.1.tgz#5a846777e2c2620d1e69104e5d3a03b1f6088f11" + dependencies: + generate-function "^2.0.0" + generate-object-property "^1.1.0" + jsonpointer "^4.0.0" + xtend "^4.0.0" + is-npm@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/is-npm/-/is-npm-1.0.0.tgz#f2fb63a65e4905b406c86072765a1a4dc793b9f4" @@ -3575,6 +3668,10 @@ is-promise@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/is-promise/-/is-promise-2.1.0.tgz#79a2a9ece7f096e80f36d2b2f3bc16c1ff4bf3fa" +is-property@^1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/is-property/-/is-property-1.0.2.tgz#57fe1c4e48474edd65b09911f26b1cd4095dda84" + is-redirect@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/is-redirect/-/is-redirect-1.0.0.tgz#1d03dded53bd8db0f30c26e4f95d36fc7c87dc24" @@ -3793,6 +3890,10 @@ jsonify@~0.0.0: version "0.0.0" resolved "https://registry.yarnpkg.com/jsonify/-/jsonify-0.0.0.tgz#2c74b6ee41d93ca51b7b5aaee8f503631d252a73" +jsonpointer@^4.0.0: + version "4.0.1" + resolved "https://registry.yarnpkg.com/jsonpointer/-/jsonpointer-4.0.1.tgz#4fd92cb34e0e9db3c89c8622ecf51f9b978c6cb9" + jsprim@^1.2.2: version "1.4.1" resolved "https://registry.yarnpkg.com/jsprim/-/jsprim-1.4.1.tgz#313e66bc1e5cc06e438bc1b7499c2e5c56acb6a2" @@ -4274,6 +4375,10 @@ node-pre-gyp@^0.6.36: tar "^2.2.1" tar-pack "^3.4.0" +node-uuid@~1.4.7: + version "1.4.8" + resolved "https://registry.yarnpkg.com/node-uuid/-/node-uuid-1.4.8.tgz#b040eb0923968afabf8d32fb1f17f1167fdab907" + nopt@^4.0.1: version "4.0.1" resolved "https://registry.yarnpkg.com/nopt/-/nopt-4.0.1.tgz#d0d4685afd5415193c8c7505602d0d17cd64474d" @@ -5015,12 +5120,12 @@ postcss-load-plugins@^2.3.0: cosmiconfig "^2.1.1" object-assign "^4.1.0" -postcss-loader@^2.0.6: - version "2.0.6" - resolved "https://registry.yarnpkg.com/postcss-loader/-/postcss-loader-2.0.6.tgz#8c7e0055a3df1889abc6bad52dd45b2f41bbc6fc" +postcss-loader@^2.0.8: + version "2.0.8" + resolved "https://registry.yarnpkg.com/postcss-loader/-/postcss-loader-2.0.8.tgz#8c67ddb029407dfafe684a406cfc16bad2ce0814" dependencies: loader-utils "^1.1.0" - postcss "^6.0.2" + postcss "^6.0.0" postcss-load-config "^1.2.0" schema-utils "^0.3.0" @@ -5260,7 +5365,7 @@ postcss@^5.0.10, postcss@^5.0.11, postcss@^5.0.12, postcss@^5.0.13, postcss@^5.0 source-map "^0.5.6" supports-color "^3.2.3" -postcss@^6.0.0, postcss@^6.0.1, postcss@^6.0.11, postcss@^6.0.13, postcss@^6.0.2, postcss@^6.0.5, postcss@^6.0.6: +postcss@^6.0.0, postcss@^6.0.1, postcss@^6.0.11, postcss@^6.0.13, postcss@^6.0.5, postcss@^6.0.6, postcss@^6.0.8: version "6.0.13" resolved "https://registry.yarnpkg.com/postcss/-/postcss-6.0.13.tgz#b9ecab4ee00c89db3ec931145bd9590bbf3f125f" dependencies: @@ -5378,6 +5483,10 @@ qs@6.5.1, qs@~6.5.1: version "6.5.1" resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.1.tgz#349cdf6eef89ec45c12d7d5eb3fc0c870343a6d8" +qs@~6.3.0: + version "6.3.2" + resolved "https://registry.yarnpkg.com/qs/-/qs-6.3.2.tgz#e75bd5f6e268122a2a0e0bda630b2550c166502c" + qs@~6.4.0: version "6.4.0" resolved "https://registry.yarnpkg.com/qs/-/qs-6.4.0.tgz#13e26d28ad6b0ffaa91312cd3bf708ed351e7233" @@ -5643,6 +5752,31 @@ request-promise-native@^1.0.3, request-promise-native@^1.0.5: stealthy-require "^1.1.0" tough-cookie ">=2.3.3" +request@2.77.0: + version "2.77.0" + resolved "https://registry.yarnpkg.com/request/-/request-2.77.0.tgz#2b00d82030ededcc97089ffa5d8810a9c2aa314b" + dependencies: + aws-sign2 "~0.6.0" + aws4 "^1.2.1" + caseless "~0.11.0" + combined-stream "~1.0.5" + extend "~3.0.0" + forever-agent "~0.6.1" + form-data "~2.1.1" + har-validator "~2.0.6" + hawk "~3.1.3" + http-signature "~1.1.0" + is-typedarray "~1.0.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.3.0" + stringstream "~0.0.4" + tough-cookie "~2.3.0" + tunnel-agent "~0.4.1" + request@2.81.0: version "2.81.0" resolved "https://registry.yarnpkg.com/request/-/request-2.81.0.tgz#c6928946a0e06c5f8d6f8a9333469ffda46298a0" @@ -6053,7 +6187,7 @@ source-map@^0.4.4: dependencies: amdefine ">=0.0.4" -source-map@^0.6.0, source-map@^0.6.1: +source-map@^0.6.0, source-map@^0.6.1, source-map@~0.6.1: version "0.6.1" resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" @@ -6433,6 +6567,10 @@ tunnel-agent@^0.6.0: dependencies: safe-buffer "^5.0.1" +tunnel-agent@~0.4.1: + version "0.4.3" + resolved "https://registry.yarnpkg.com/tunnel-agent/-/tunnel-agent-0.4.3.tgz#6373db76909fe570e08d73583365ed828a74eeeb" + tweetnacl@^0.14.3, tweetnacl@~0.14.0: version "0.14.5" resolved "https://registry.yarnpkg.com/tweetnacl/-/tweetnacl-0.14.5.tgz#5ae68177f192d4456269d108afa93ff8743f4f64" @@ -6454,7 +6592,7 @@ typedarray@^0.0.6: version "0.0.6" resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" -uglify-js@3.1.x, uglify-js@^3.1.3: +uglify-js@3.1.x: version "3.1.3" resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.1.3.tgz#d61f0453b4718cab01581f3162aa90bab7520b42" dependencies: @@ -6470,6 +6608,13 @@ uglify-js@^2.6, uglify-js@^2.8.29: optionalDependencies: uglify-to-browserify "~1.0.0" +uglify-js@^3.1.4: + version "3.1.5" + resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.1.5.tgz#4c1a6d53b2fe77e4710dd94631853effd3ff5143" + dependencies: + commander "~2.11.0" + source-map "~0.6.1" + uglify-to-browserify@~1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/uglify-to-browserify/-/uglify-to-browserify-1.0.2.tgz#6e0924d6bda6b5afe349e39a6d632850a0f882b7" @@ -6646,27 +6791,27 @@ vm-browserify@0.0.4: dependencies: indexof "0.0.1" -vue-hot-reload-api@^2.1.0: - version "2.1.1" - resolved "https://registry.yarnpkg.com/vue-hot-reload-api/-/vue-hot-reload-api-2.1.1.tgz#1ba6712166182fd651753804b9d8d8d02d855579" +vue-hot-reload-api@^2.2.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/vue-hot-reload-api/-/vue-hot-reload-api-2.2.0.tgz#9a21b35ced3634434a43ee80efb7350ea8fb206d" -vue-loader@^13.0.5: - version "13.0.5" - resolved "https://registry.yarnpkg.com/vue-loader/-/vue-loader-13.0.5.tgz#3639e9fb3940cded7f0fc34429277fb6de70a57c" +vue-loader@^13.3.0: + version "13.3.0" + resolved "https://registry.yarnpkg.com/vue-loader/-/vue-loader-13.3.0.tgz#3bf837d490ba5dea6fc07e0835ffa6c688c8af33" dependencies: consolidate "^0.14.0" hash-sum "^1.0.2" loader-utils "^1.1.0" lru-cache "^4.1.1" - postcss "^6.0.6" + postcss "^6.0.8" postcss-load-config "^1.1.0" postcss-selector-parser "^2.0.0" prettier "^1.7.0" - resolve "^1.3.3" - source-map "^0.5.6" - vue-hot-reload-api "^2.1.0" + resolve "^1.4.0" + source-map "^0.6.1" + vue-hot-reload-api "^2.2.0" vue-style-loader "^3.0.0" - vue-template-es2015-compiler "^1.5.3" + vue-template-es2015-compiler "^1.6.0" vue-meta@^1.2.0: version "1.2.0" @@ -6676,11 +6821,11 @@ vue-meta@^1.2.0: lodash.isplainobject "^4.0.6" object-assign "^4.1.1" -vue-router@^2.7.0: - version "2.7.0" - resolved "https://registry.yarnpkg.com/vue-router/-/vue-router-2.7.0.tgz#16d424493aa51c3c8cce8b7c7210ea4c3a89aff1" +vue-router@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/vue-router/-/vue-router-3.0.1.tgz#d9b05ad9c7420ba0f626d6500d693e60092cc1e9" -vue-server-renderer@~2.5.2: +vue-server-renderer@^2.5.2: version "2.5.2" resolved "https://registry.yarnpkg.com/vue-server-renderer/-/vue-server-renderer-2.5.2.tgz#c96a4368caa3fd298a528f1bf40632d8f696ff25" dependencies: @@ -6700,18 +6845,18 @@ vue-style-loader@^3.0.0: hash-sum "^1.0.2" loader-utils "^1.0.2" -vue-template-compiler@~2.5.2: +vue-template-compiler@^2.5.2: version "2.5.2" resolved "https://registry.yarnpkg.com/vue-template-compiler/-/vue-template-compiler-2.5.2.tgz#6f198ebc677b8f804315cd33b91e849315ae7177" dependencies: de-indent "^1.0.2" he "^1.1.0" -vue-template-es2015-compiler@^1.5.3: - version "1.5.3" - resolved "https://registry.yarnpkg.com/vue-template-es2015-compiler/-/vue-template-es2015-compiler-1.5.3.tgz#22787de4e37ebd9339b74223bc467d1adee30545" +vue-template-es2015-compiler@^1.6.0: + version "1.6.0" + resolved "https://registry.yarnpkg.com/vue-template-es2015-compiler/-/vue-template-es2015-compiler-1.6.0.tgz#dc42697133302ce3017524356a6c61b7b69b4a18" -vue@~2.5.2: +vue@^2.5.2: version "2.5.2" resolved "https://registry.yarnpkg.com/vue/-/vue-2.5.2.tgz#fd367a87bae7535e47f9dc5c9ec3b496e5feb5a4" @@ -6757,9 +6902,9 @@ webpack-dev-middleware@^1.12.0: range-parser "^1.0.3" time-stamp "^2.0.0" -webpack-hot-middleware@^2.19.1: - version "2.19.1" - resolved "https://registry.yarnpkg.com/webpack-hot-middleware/-/webpack-hot-middleware-2.19.1.tgz#5db32c31c955c1ead114d37c7519ea554da0d405" +webpack-hot-middleware@^2.20.0: + version "2.20.0" + resolved "https://registry.yarnpkg.com/webpack-hot-middleware/-/webpack-hot-middleware-2.20.0.tgz#cb896d837758b6408fe0afeeafdc0e5316b15319" dependencies: ansi-html "0.0.7" html-entities "^1.2.0" @@ -6777,9 +6922,9 @@ webpack-sources@^1.0.1: source-list-map "^2.0.0" source-map "~0.5.3" -webpack@^3.6.0: - version "3.6.0" - resolved "https://registry.yarnpkg.com/webpack/-/webpack-3.6.0.tgz#a89a929fbee205d35a4fa2cc487be9cbec8898bc" +webpack@^3.8.0: + version "3.8.1" + resolved "https://registry.yarnpkg.com/webpack/-/webpack-3.8.1.tgz#b16968a81100abe61608b0153c9159ef8bb2bd83" dependencies: acorn "^5.0.0" acorn-dynamic-import "^2.0.0" From aefa9f8c31c3a983a78e038b0e3c98e4b712c1a0 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Wed, 25 Oct 2017 00:49:14 +0330 Subject: [PATCH 142/316] context => appContext --- lib/app/utils.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/app/utils.js b/lib/app/utils.js index f3cbeefc7f..a091740125 100644 --- a/lib/app/utils.js +++ b/lib/app/utils.js @@ -154,9 +154,9 @@ export function middlewareSeries(promises, appContext) { if (!promises.length || appContext._redirected || appContext.app.nuxt.err) { return Promise.resolve() } - return promisify(promises[0], context) + return promisify(promises[0], appContext) .then(() => { - return middlewareSeries(promises.slice(1), context) + return middlewareSeries(promises.slice(1), appContext) }) } From 5384ee1a5cc1e0f895e651459789863d3157fe27 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Wed, 25 Oct 2017 01:08:31 +0330 Subject: [PATCH 143/316] ctx => app.context --- lib/app/utils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/app/utils.js b/lib/app/utils.js index a091740125..e5d05b0a1a 100644 --- a/lib/app/utils.js +++ b/lib/app/utils.js @@ -125,7 +125,7 @@ export async function setContext(app, context) { if (context.res) app.context.res = context.res app.context.redirect = function (status, path, query) { if (!status) return - ctx._redirected = true // Used in middleware + app.context._redirected = true // Used in middleware // if only 1 or 2 arguments: redirect('/') or redirect('/', { foo: 'bar' }) if (typeof status === 'string' && (typeof path === 'undefined' || typeof path === 'object')) { query = path || {} From 1cb1238d8a83dfbe24e156862e80594a75cf824a Mon Sep 17 00:00:00 2001 From: Clark Du Date: Wed, 25 Oct 2017 10:07:29 +0800 Subject: [PATCH 144/316] refactor: remove vue dependency after nuxt-class-component upgrade --- examples/vue-class-component/package.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/examples/vue-class-component/package.json b/examples/vue-class-component/package.json index 89e9d65c2a..f4953a0a84 100644 --- a/examples/vue-class-component/package.json +++ b/examples/vue-class-component/package.json @@ -4,8 +4,7 @@ "babel-plugin-transform-class-properties": "^6.24.1", "babel-plugin-transform-decorators-legacy": "^1.3.4", "nuxt": "latest", - "nuxt-class-component": "^1.0.3", - "vue": "~2.4.2" + "nuxt-class-component": "^1.0.3" }, "scripts": { "dev": "nuxt", From f5acb6fc0ee81f501745f8393305fd38c4097048 Mon Sep 17 00:00:00 2001 From: Clark Du Date: Wed, 25 Oct 2017 19:27:51 +0800 Subject: [PATCH 145/316] fix: syntax error in generator.js --- lib/builder/generator.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/builder/generator.js b/lib/builder/generator.js index 71a8986d55..3afd1cb79a 100644 --- a/lib/builder/generator.js +++ b/lib/builder/generator.js @@ -74,7 +74,7 @@ export default class Generator extends Tapable { } const indexPath = join(this.distPath, 'index.html') - if (existsSync(indexPath) { + if (existsSync(indexPath)) { // Copy /index.html to /200.html for surge SPA // https://surge.sh/help/adding-a-200-page-for-client-side-routing const _200Path = join(this.distPath, '200.html') From 5d3156c0c7da70915d6a1600879077f41ea013af Mon Sep 17 00:00:00 2001 From: John Fischer Date: Sat, 14 Oct 2017 19:33:26 +0200 Subject: [PATCH 146/316] Catch cryptic error when a plugin is not found --- lib/builder/builder.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/builder/builder.js b/lib/builder/builder.js index c85c5c7b5c..4010101abe 100644 --- a/lib/builder/builder.js +++ b/lib/builder/builder.js @@ -5,7 +5,7 @@ import hash from 'hash-sum' import pify from 'pify' import webpack from 'webpack' import serialize from 'serialize-javascript' -import { join, resolve, basename, dirname } from 'path' +import { join, resolve, basename, extname, dirname } from 'path' import Tapable from 'tappable' import MFS from 'memory-fs' import webpackDevMiddleware from 'webpack-dev-middleware' @@ -62,8 +62,11 @@ export default class Builder extends Tapable { get plugins () { return this.options.plugins.map((p, i) => { if (typeof p === 'string') p = { src: p } - p.src = this.nuxt.resolvePath(p.src) - return { src: p.src, ssr: (p.ssr !== false), name: `plugin${i}` } + return { + src: this.nuxt.resolvePath(p.src), + ssr: (p.ssr !== false), + name: basename(p.src, extname(p.src)).replace(/[^a-zA-Z?\d\s:]/g, '') + } }) } From 8a2adbeee428188fb72c9422e68f7f41c098530c Mon Sep 17 00:00:00 2001 From: Atinux Date: Fri, 27 Oct 2017 12:17:35 +0200 Subject: [PATCH 147/316] patch: Fix typo in warning --- lib/builder/webpack/client.config.js | 2 +- lib/builder/webpack/server.config.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/builder/webpack/client.config.js b/lib/builder/webpack/client.config.js index eee26861ef..2d9d9de909 100644 --- a/lib/builder/webpack/client.config.js +++ b/lib/builder/webpack/client.config.js @@ -224,7 +224,7 @@ export default function webpackClientConfig () { const isDev = this.options.dev const extendedConfig = this.options.build.extend.call(this, config, { get dev () { - console.warn('dev has been deprecated into build.extend, please use isDev') // eslint-disable-line no-console + console.warn('dev has been deprecated in build.extend(), please use isDev') // eslint-disable-line no-console return isDev }, isDev, diff --git a/lib/builder/webpack/server.config.js b/lib/builder/webpack/server.config.js index 6e2ebf6cfc..2ee1809780 100644 --- a/lib/builder/webpack/server.config.js +++ b/lib/builder/webpack/server.config.js @@ -79,7 +79,7 @@ export default function webpackServerConfig () { const isDev = this.options.dev const extendedConfig = this.options.build.extend.call(this, config, { get dev () { - console.warn('dev has been deprecated into build.extend, please use isDev') // eslint-disable-line no-console + console.warn('dev has been deprecated in build.extend(), please use isDev') // eslint-disable-line no-console return isDev }, isDev, From 08e770c1e00c30d1115a2698b0a20d243d09710a Mon Sep 17 00:00:00 2001 From: Clark Du Date: Fri, 27 Oct 2017 22:15:34 +0800 Subject: [PATCH 148/316] refactor: upgrade nuxt-class-component to a stabe version --- examples/vue-class-component/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/vue-class-component/package.json b/examples/vue-class-component/package.json index f4953a0a84..797a48f36e 100644 --- a/examples/vue-class-component/package.json +++ b/examples/vue-class-component/package.json @@ -4,7 +4,7 @@ "babel-plugin-transform-class-properties": "^6.24.1", "babel-plugin-transform-decorators-legacy": "^1.3.4", "nuxt": "latest", - "nuxt-class-component": "^1.0.3" + "nuxt-class-component": "^1.0.4" }, "scripts": { "dev": "nuxt", From f2663033fcc275fff592944ba54a7b7b36b7a21d Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Fri, 27 Oct 2017 18:45:34 +0330 Subject: [PATCH 149/316] feat(nuxt-generate): --no-build flag Much faster generates for when just dynamic routes changed --- bin/nuxt-generate | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/bin/nuxt-generate b/bin/nuxt-generate index f86cd43eba..d0313caa19 100755 --- a/bin/nuxt-generate +++ b/bin/nuxt-generate @@ -17,10 +17,11 @@ const argv = parseArgs(process.argv.slice(2), { s: 'spa', u: 'universal' }, - boolean: ['h', 's', 'u'], + boolean: ['h', 's', 'u', 'build'], string: ['c'], default: { - c: 'nuxt.config.js' + c: 'nuxt.config.js', + build: true } }) @@ -36,6 +37,7 @@ if (argv.help) { --universal Launch in Universal mode (default) --config-file, -c Path to Nuxt.js config file (default: nuxt.config.js) --help, -h Displays this message + --no-build Just run generate for faster builds when just dynamic routes changed. Nuxt build is needed before this command. `) process.exit(0) } @@ -62,7 +64,13 @@ debug('Generating...') const nuxt = new Nuxt(options) const builder = new Builder(nuxt) const generator = new Generator(nuxt, builder) -generator.generate() + +const generateOptions = { + init: true, + build: argv['build'] +} + +generator.generate(generateOptions) .then(() => { debug('Generate done') process.exit(0) From 1e4c95554aa725e48a04eb874e646e5e526fd1cd Mon Sep 17 00:00:00 2001 From: Clark Du Date: Sat, 28 Oct 2017 00:20:12 +0800 Subject: [PATCH 150/316] feat: add markdown example --- examples/markdownit/README.md | 5 +++++ examples/markdownit/nuxt.config.js | 16 ++++++++++++++++ examples/markdownit/package.json | 13 +++++++++++++ examples/markdownit/pages/about.vue | 6 ++++++ examples/markdownit/pages/index.vue | 19 +++++++++++++++++++ 5 files changed, 59 insertions(+) create mode 100644 examples/markdownit/README.md create mode 100644 examples/markdownit/nuxt.config.js create mode 100644 examples/markdownit/package.json create mode 100644 examples/markdownit/pages/about.vue create mode 100644 examples/markdownit/pages/index.vue diff --git a/examples/markdownit/README.md b/examples/markdownit/README.md new file mode 100644 index 0000000000..a287cad252 --- /dev/null +++ b/examples/markdownit/README.md @@ -0,0 +1,5 @@ +# Markdown Example + +> Convert Markdown file to HTML using markdown-it. + +**See [Markdownit Module](https://github.com/nuxt-community/modules/tree/master/packages/markdownit) for easy integration with [Nuxt.js](https://nuxtjs.org).** diff --git a/examples/markdownit/nuxt.config.js b/examples/markdownit/nuxt.config.js new file mode 100644 index 0000000000..5660fb118d --- /dev/null +++ b/examples/markdownit/nuxt.config.js @@ -0,0 +1,16 @@ +module.exports = { + modules: [ + '@nuxtjs/markdownit' + ] + // [optional] markdownit options + // See https://github.com/markdown-it/markdown-it + // markdownit: { + // preset: 'default', + // linkify: true, + // breaks: true, + // use: [ + // 'markdown-it-container', + // 'markdown-it-attrs' + // ] + // } +} diff --git a/examples/markdownit/package.json b/examples/markdownit/package.json new file mode 100644 index 0000000000..fae0d3f7bb --- /dev/null +++ b/examples/markdownit/package.json @@ -0,0 +1,13 @@ +{ + "name": "nuxt-markdownit", + "version": "1.0.0", + "dependencies": { + "@nuxtjs/markdownit": "^1.1.2", + "nuxt": "latest" + }, + "scripts": { + "dev": "nuxt", + "build": "nuxt build", + "start": "nuxt start" + } +} diff --git a/examples/markdownit/pages/about.vue b/examples/markdownit/pages/about.vue new file mode 100644 index 0000000000..819feae465 --- /dev/null +++ b/examples/markdownit/pages/about.vue @@ -0,0 +1,6 @@ + diff --git a/examples/markdownit/pages/index.vue b/examples/markdownit/pages/index.vue new file mode 100644 index 0000000000..61869bd5b2 --- /dev/null +++ b/examples/markdownit/pages/index.vue @@ -0,0 +1,19 @@ + + +< From 84783a988c435c5e50e81234b112792d088030d9 Mon Sep 17 00:00:00 2001 From: Clark Du Date: Sat, 28 Oct 2017 00:38:47 +0800 Subject: [PATCH 151/316] feat: add pug example --- examples/markdownit/package.json | 3 ++- examples/markdownit/pages/about.vue | 2 +- examples/markdownit/pages/index.vue | 6 ++++-- examples/markdownit/pages/pug.vue | 17 +++++++++++++++++ 4 files changed, 24 insertions(+), 4 deletions(-) create mode 100644 examples/markdownit/pages/pug.vue diff --git a/examples/markdownit/package.json b/examples/markdownit/package.json index fae0d3f7bb..76056fdcbb 100644 --- a/examples/markdownit/package.json +++ b/examples/markdownit/package.json @@ -3,7 +3,8 @@ "version": "1.0.0", "dependencies": { "@nuxtjs/markdownit": "^1.1.2", - "nuxt": "latest" + "nuxt": "latest", + "pug": "^2.0.0-rc.4" }, "scripts": { "dev": "nuxt", diff --git a/examples/markdownit/pages/about.vue b/examples/markdownit/pages/about.vue index 819feae465..aa487b80bb 100644 --- a/examples/markdownit/pages/about.vue +++ b/examples/markdownit/pages/about.vue @@ -1,5 +1,5 @@ -< From 5081789a62fd91e36eceaa7df204db2a6c9beec7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Chopin?= Date: Sat, 28 Oct 2017 11:01:23 +0200 Subject: [PATCH 152/316] example: Fix pug page --- examples/markdownit/pages/pug.vue | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/markdownit/pages/pug.vue b/examples/markdownit/pages/pug.vue index ac42f00b0c..b243bbc660 100644 --- a/examples/markdownit/pages/pug.vue +++ b/examples/markdownit/pages/pug.vue @@ -3,7 +3,8 @@ h1 Pug Page div(language="md") Current route is: {{ $route.name }} div(language="md") Data model is: {{ model }} - a(href='/') Back Home + br + nuxt-link(to='/') Back Home From b28cfe0db8cbf548db5ea78929bf63c62c401927 Mon Sep 17 00:00:00 2001 From: Clark Du Date: Sun, 29 Oct 2017 18:24:58 +0800 Subject: [PATCH 171/316] test: add test for dll --- test/dll.test.js | 31 +++++++++++++++++++++++++++++++ test/fixtures/dll/nuxt.config.js | 5 +++++ test/fixtures/dll/pages/index.vue | 0 3 files changed, 36 insertions(+) create mode 100644 test/dll.test.js create mode 100644 test/fixtures/dll/nuxt.config.js create mode 100644 test/fixtures/dll/pages/index.vue diff --git a/test/dll.test.js b/test/dll.test.js new file mode 100644 index 0000000000..70137c950a --- /dev/null +++ b/test/dll.test.js @@ -0,0 +1,31 @@ +import test from 'ava' +import { resolve } from 'path' +import fs from 'fs' +import pify from 'pify' +import { Nuxt, Builder } from '../index.js' + +const readFile = pify(fs.readFile) +const rootDir = resolve(__dirname, './fixtures/dll') +const dllDir = resolve(rootDir, '.cache/client-dll') + +const checkCache = (lib) => { + return async (t) => { + const manifest = await readFile(resolve(dllDir, `./${lib}-manifest.json`), 'utf-8') + t.truthy(JSON.parse(manifest).name) + t.true(fs.existsSync(resolve(dllDir, `./${JSON.parse(manifest).name}.js`))) + } +} + +test.before('Init Nuxt.js', async t => { + let config = require(resolve(rootDir, 'nuxt.config.js')) + config.rootDir = rootDir + config.dev = true + const nuxt = new Nuxt(config) + await new Builder(nuxt).build() +}) + +test('Check vue cache', checkCache('vue')) + +test('Check vue-meta cache', checkCache('vue-meta')) + +test('Check vue-router cache', checkCache('vue-router')) diff --git a/test/fixtures/dll/nuxt.config.js b/test/fixtures/dll/nuxt.config.js new file mode 100644 index 0000000000..51f3132191 --- /dev/null +++ b/test/fixtures/dll/nuxt.config.js @@ -0,0 +1,5 @@ +module.exports = { + build: { + dll: true + } +} diff --git a/test/fixtures/dll/pages/index.vue b/test/fixtures/dll/pages/index.vue new file mode 100644 index 0000000000..e69de29bb2 From 7739421e9216545b6c1a4a4b5ba11a83cc0cb915 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Chopin?= Date: Sun, 29 Oct 2017 14:59:38 +0100 Subject: [PATCH 172/316] test: Add puppeteer for testing (wip) --- package.json | 1 + test/basic.dom.test.js | 212 +++++++++++++++++++++++++++++++++++++++++ yarn.lock | 95 +++++++++++++++++- 3 files changed, 305 insertions(+), 3 deletions(-) create mode 100644 test/basic.dom.test.js diff --git a/package.json b/package.json index 9ae70b1ddb..d6397fdf3b 100644 --- a/package.json +++ b/package.json @@ -144,6 +144,7 @@ "jsdom": "^11.3.0", "json-loader": "^0.5.7", "nyc": "^11.2.1", + "puppeteer": "^0.12.0", "request": "^2.83.0", "request-promise-native": "^1.0.5", "rimraf": "^2.6.2", diff --git a/test/basic.dom.test.js b/test/basic.dom.test.js new file mode 100644 index 0000000000..992aadde17 --- /dev/null +++ b/test/basic.dom.test.js @@ -0,0 +1,212 @@ +import test from 'ava' +import { resolve } from 'path' +import puppeteer from 'puppeteer' +import { Nuxt, Builder } from '../index.js' + +const port = 4003 +const url = (route) => 'http://localhost:' + port + route + +let nuxt = null +let browser +const open = async (path) => { + const page = await browser.newPage() + await page.goto(url(path)) + await page.waitForFunction('!!window.$nuxt') + page.html = () => page.evaluate(() => window.document.documentElement.outerHTML) + return page +} + +// Init nuxt.js and create server listening on localhost:4003 +test.before('Init Nuxt.js', async t => { + const options = { + rootDir: resolve(__dirname, 'fixtures/basic'), + dev: false, + head: { + titleTemplate (titleChunk) { + return titleChunk ? `${titleChunk} - Nuxt.js` : 'Nuxt.js' + } + } + } + nuxt = new Nuxt(options) + await new Builder(nuxt).build() + + await nuxt.listen(port, 'localhost') +}) + +test.before('Start Puppeteer', async t => { + browser = await puppeteer.launch({ + // https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#puppeteerlaunchoptions + }) +}) + +test('/stateless', async t => { + const page = await open('/stateless') + const h1 = await page.$eval('h1', (h1) => h1.textContent) + const loading = await page.evaluate(() => window.$nuxt.$loading.$data) + + t.is(await page.title(), 'Nuxt.js') + t.is(h1, 'My component!') + t.is(loading.show, false) + t.is(loading.percent, 0) + await page.close() +}) + +test('/css', async t => { + const page = await open('/css') + t.is(await page.$eval('.red', (red) => red.textContent), 'This is red') + t.is(await page.$eval('.red', (red) => window.getComputedStyle(red).color), 'rgb(255, 0, 0)') + await page.close() +}) + +test('/stateful', async t => { + const page = await open('/stateful') + const html = await page.html() + t.true(html.includes('

The answer is 42

')) + await page.close() +}) + +// test('/store', async t => { +// const { html } = await nuxt.renderRoute('/store') +// t.true(html.includes('

Vuex Nested Modules

')) +// t.true(html.includes('

1

')) +// }) + +// test('/head', async t => { +// const window = await nuxt.renderAndGetWindow(url('/head'), { virtualConsole: false }) +// const html = window.document.body.innerHTML +// const metas = window.document.getElementsByTagName('meta') +// t.is(window.document.title, 'My title - Nuxt.js') +// t.is(metas[0].getAttribute('content'), 'my meta') +// t.true(html.includes('

I can haz meta tags

')) +// }) + +// test('/async-data', async t => { +// const { html } = await nuxt.renderRoute('/async-data') +// t.true(html.includes('

Nuxt.js

')) +// }) + +// test('/await-async-data', async t => { +// const { html } = await nuxt.renderRoute('/await-async-data') +// t.true(html.includes('

Await Nuxt.js

')) +// }) + +// test('/callback-async-data', async t => { +// const { html } = await nuxt.renderRoute('/callback-async-data') +// t.true(html.includes('

Callback Nuxt.js

')) +// }) + +// test('/users/1', async t => { +// const { html } = await nuxt.renderRoute('/users/1') +// t.true(html.includes('

User: 1

')) +// }) + +// test('/validate should display a 404', async t => { +// const { html } = await nuxt.renderRoute('/validate') +// t.true(html.includes('This page could not be found')) +// }) + +// test('/validate?valid=true', async t => { +// const { html } = await nuxt.renderRoute('/validate?valid=true') +// t.true(html.includes('

I am valid

')) +// }) + +// test('/redirect', async t => { +// const { html, redirected } = await nuxt.renderRoute('/redirect') +// t.true(html.includes('
')) +// t.true(redirected.path === '/') +// t.true(redirected.status === 302) +// }) + +// test('/redirect -> check redirected source', async t => { +// const window = await nuxt.renderAndGetWindow(url('/redirect')) +// const html = window.document.body.innerHTML +// t.true(html.includes('

Index page

')) +// }) + +// test('/special-state -> check window.__NUXT__.test = true', async t => { +// const window = await nuxt.renderAndGetWindow(url('/special-state')) +// t.is(window.document.title, 'Nuxt.js') +// t.is(window.__NUXT__.test, true) +// }) + +// test('/error', async t => { +// try { +// await nuxt.renderRoute('/error', { req: {}, res: {} }) +// } catch (err) { +// t.true(err.message.includes('Error mouahahah')) +// } +// }) + +// test('/error status code', async t => { +// try { +// await rp(url('/error')) +// } catch (err) { +// t.true(err.statusCode === 500) +// t.true(err.response.body.includes('An error occurred in the application and your page could not be served')) +// } +// }) + +// test('/error2', async t => { +// const { html, error } = await nuxt.renderRoute('/error2') +// t.true(html.includes('Custom error')) +// t.true(error.message.includes('Custom error')) +// t.true(error.statusCode === undefined) +// }) + +// test('/error2 status code', async t => { +// try { +// await rp(url('/error2')) +// } catch (err) { +// t.is(err.statusCode, 500) +// t.true(err.response.body.includes('Custom error')) +// } +// }) + +// test('/redirect2', async t => { +// stdMocks.use() +// await rp(url('/redirect2')) // Should console.error +// stdMocks.restore() +// const output = stdMocks.flush() +// // Don't display error since redirect returns a noopApp +// t.true(output.stderr.length === 0) +// }) + +// test('/no-ssr', async t => { +// const { html } = await nuxt.renderRoute('/no-ssr') +// t.true(html.includes('
<p>Loading...</p>
')) +// }) + +// test('/no-ssr (client-side)', async t => { +// const window = await nuxt.renderAndGetWindow(url('/no-ssr')) +// const html = window.document.body.innerHTML +// t.true(html.includes('Displayed only on client-side')) +// }) + +// test('ETag Header', async t => { +// const { headers: { etag } } = await rp(url('/stateless'), { resolveWithFullResponse: true }) +// // Validate etag +// t.regex(etag, /W\/".*"$/) +// // Verify functionality +// const error = await t.throws(rp(url('/stateless'), { headers: { 'If-None-Match': etag } })) +// t.is(error.statusCode, 304) +// }) + +// test('/_nuxt/server-bundle.json should return 404', async t => { +// const err = await t.throws(rp(url('/_nuxt/server-bundle.json'), { resolveWithFullResponse: true })) +// t.is(err.statusCode, 404) +// }) + +// test('/_nuxt/ should return 404', async t => { +// const err = await t.throws(rp(url('/_nuxt/'), { resolveWithFullResponse: true })) +// t.is(err.statusCode, 404) +// }) + +// Close server and ask nuxt to stop listening to file changes +test.after('Closing server and nuxt.js', t => { + nuxt.close() +}) + +test.after('Close Puppeteer', async t => { + await browser.close() + browser = null +}) diff --git a/yarn.lock b/yarn.lock index e24768274b..1ec7e417c8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -101,6 +101,12 @@ acorn@^5.0.0, acorn@^5.1.1, acorn@^5.1.2: version "5.1.2" resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.1.2.tgz#911cb53e036807cf0fa778dc5d370fbd864246d7" +agent-base@^4.1.0: + version "4.1.1" + resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-4.1.1.tgz#92d8a4fc2524a3b09b3666a33b6c97960f23d6a4" + dependencies: + es6-promisify "^5.0.0" + ajv-keywords@^2.0.0, ajv-keywords@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-2.1.0.tgz#a296e17f7bfae7c1ce4f7e0de53d29cb32162df0" @@ -293,6 +299,10 @@ async-each@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/async-each/-/async-each-1.0.1.tgz#19d386a1d9edc6e7c1c85d388aedbcc56d33602d" +async-limiter@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/async-limiter/-/async-limiter-1.0.0.tgz#78faed8c3d074ab81f22b4e985d79e8738f720f8" + async@^1.4.0: version "1.5.2" resolved "https://registry.yarnpkg.com/async/-/async-1.5.2.tgz#ec6a61ae56480c0c3cb241c95618e20892f9672a" @@ -1669,7 +1679,7 @@ concat-map@0.0.1: version "0.0.1" resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" -concat-stream@^1.5.0, concat-stream@^1.6.0: +concat-stream@1.6.0, concat-stream@^1.5.0, concat-stream@^1.6.0: version "1.6.0" resolved "https://registry.yarnpkg.com/concat-stream/-/concat-stream-1.6.0.tgz#0aac662fd52be78964d5532f694784e70110acf7" dependencies: @@ -2065,7 +2075,13 @@ debug-log@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/debug-log/-/debug-log-1.0.1.tgz#2307632d4c04382b8df8a32f70b895046d52745f" -debug@2.6.9, debug@^2.2.0, debug@^2.6.8: +debug@2.2.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/debug/-/debug-2.2.0.tgz#f87057e995b1a1f6ae6a4960664137bc56f039da" + dependencies: + ms "0.7.1" + +debug@2.6.9, debug@^2.2.0, debug@^2.4.1, debug@^2.6.8: version "2.6.9" resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f" dependencies: @@ -2387,10 +2403,16 @@ es6-map@^0.1.3: es6-symbol "~3.1.1" event-emitter "~0.3.5" -es6-promise@^4.1.1: +es6-promise@^4.0.3, es6-promise@^4.1.1: version "4.1.1" resolved "https://registry.yarnpkg.com/es6-promise/-/es6-promise-4.1.1.tgz#8811e90915d9a0dba36274f0b242dbda78f9c92a" +es6-promisify@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/es6-promisify/-/es6-promisify-5.0.0.tgz#5109d62f3e56ea967c4b63505aef08291c8a5203" + dependencies: + es6-promise "^4.0.3" + es6-set@~0.1.5: version "0.1.5" resolved "https://registry.yarnpkg.com/es6-set/-/es6-set-0.1.5.tgz#d2b3ec5d4d800ced818db538d28974db0a73ccb1" @@ -2726,6 +2748,15 @@ extract-text-webpack-plugin@^3.0.2: schema-utils "^0.3.0" webpack-sources "^1.0.1" +extract-zip@^1.6.5: + version "1.6.5" + resolved "https://registry.yarnpkg.com/extract-zip/-/extract-zip-1.6.5.tgz#99a06735b6ea20ea9b705d779acffcc87cff0440" + dependencies: + concat-stream "1.6.0" + debug "2.2.0" + mkdirp "0.5.0" + yauzl "2.4.1" + extsprintf@1.3.0, extsprintf@^1.2.0: version "1.3.0" resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.3.0.tgz#96918440e3041a7a414f8c52e3c574eb3c3e1e05" @@ -2750,6 +2781,12 @@ fastparse@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/fastparse/-/fastparse-1.1.1.tgz#d1e2643b38a94d7583b479060e6c4affc94071f8" +fd-slicer@~1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/fd-slicer/-/fd-slicer-1.0.1.tgz#8b5bcbd9ec327c5041bf9ab023fd6750f1177e65" + dependencies: + pend "~1.2.0" + figures@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/figures/-/figures-2.0.0.tgz#3ab1a2d2a62c8bfb431a0c94cb797a2fce27c962" @@ -3334,6 +3371,13 @@ https-browserify@0.0.1: version "0.0.1" resolved "https://registry.yarnpkg.com/https-browserify/-/https-browserify-0.0.1.tgz#3f91365cabe60b77ed0ebba24b454e3e09d95a82" +https-proxy-agent@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-2.1.0.tgz#1391bee7fd66aeabc0df2a1fa90f58954f43e443" + dependencies: + agent-base "^4.1.0" + debug "^2.4.1" + hullabaloo-config-manager@^1.1.0: version "1.1.1" resolved "https://registry.yarnpkg.com/hullabaloo-config-manager/-/hullabaloo-config-manager-1.1.1.tgz#1d9117813129ad035fd9e8477eaf066911269fe3" @@ -4251,6 +4295,12 @@ mississippi@^1.3.0: stream-each "^1.1.0" through2 "^2.0.0" +mkdirp@0.5.0: + version "0.5.0" + resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.0.tgz#1d73076a6df986cd9344e15e71fcc05a4c9abf12" + dependencies: + minimist "0.0.8" + "mkdirp@>=0.5 0", mkdirp@^0.5.0, mkdirp@^0.5.1, mkdirp@~0.5.0, mkdirp@~0.5.1: version "0.5.1" resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.1.tgz#30057438eac6cf7f8c4767f38648d6697d75c903" @@ -4268,6 +4318,10 @@ move-concurrently@^1.0.1: rimraf "^2.5.4" run-queue "^1.0.3" +ms@0.7.1: + version "0.7.1" + resolved "https://registry.yarnpkg.com/ms/-/ms-0.7.1.tgz#9cd13c03adbff25b65effde7ce864ee952017098" + ms@2.0.0, ms@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" @@ -4764,6 +4818,10 @@ pbkdf2@^3.0.3: safe-buffer "^5.0.1" sha.js "^2.4.8" +pend@~1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/pend/-/pend-1.2.0.tgz#7a57eb550a6783f9115331fcf4663d5c8e007a50" + performance-now@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/performance-now/-/performance-now-0.2.0.tgz#33ef30c5c77d4ea21c5a53869d91b56d8f2555e5" @@ -5442,6 +5500,10 @@ proxy-addr@~2.0.2: forwarded "~0.1.2" ipaddr.js "1.5.2" +proxy-from-env@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/proxy-from-env/-/proxy-from-env-1.0.0.tgz#33c50398f70ea7eb96d21f7b817630a55791c7ee" + prr@~0.0.0: version "0.0.0" resolved "https://registry.yarnpkg.com/prr/-/prr-0.0.0.tgz#1a84b85908325501411853d0081ee3fa86e2926a" @@ -5487,6 +5549,19 @@ punycode@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.0.tgz#5f863edc89b96db09074bad7947bf09056ca4e7d" +puppeteer@^0.12.0: + version "0.12.0" + resolved "https://registry.yarnpkg.com/puppeteer/-/puppeteer-0.12.0.tgz#9c421930851594dfdd479d07646666a74ced7719" + dependencies: + debug "^2.6.8" + extract-zip "^1.6.5" + https-proxy-agent "^2.1.0" + mime "^1.3.4" + progress "^2.0.0" + proxy-from-env "^1.0.0" + rimraf "^2.6.1" + ws "^3.0.0" + q@^1.1.2: version "1.5.1" resolved "https://registry.yarnpkg.com/q/-/q-1.5.1.tgz#7e32f75b41381291d04611f1bf14109ac00651d7" @@ -7087,6 +7162,14 @@ ws@^2.3.1: safe-buffer "~5.0.1" ultron "~1.1.0" +ws@^3.0.0: + version "3.2.0" + resolved "https://registry.yarnpkg.com/ws/-/ws-3.2.0.tgz#d5d3d6b11aff71e73f808f40cc69d52bb6d4a185" + dependencies: + async-limiter "~1.0.0" + safe-buffer "~5.1.0" + ultron "~1.1.0" + xdg-basedir@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/xdg-basedir/-/xdg-basedir-3.0.0.tgz#496b2cc109eca8dbacfe2dc72b603c17c5870ad4" @@ -7172,3 +7255,9 @@ yargs@~3.10.0: cliui "^2.1.0" decamelize "^1.0.0" window-size "0.1.0" + +yauzl@2.4.1: + version "2.4.1" + resolved "https://registry.yarnpkg.com/yauzl/-/yauzl-2.4.1.tgz#9528f442dab1b2284e58b4379bb194e22e0c4005" + dependencies: + fd-slicer "~1.0.1" From be4fc4a518ea7dd6b2ddb19d52d7bd4ee2174d04 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Mon, 30 Oct 2017 00:00:54 +0330 Subject: [PATCH 173/316] fix(circleCI): puppeteer support --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 75fd8d2c14..51c01eb619 100755 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -3,7 +3,7 @@ jobs: build: working_directory: /usr/src/app docker: - - image: banian/node + - image: banian/node-headless-chrome steps: # Checkout repository - checkout From 45bba51e9621488bdb4d8dedafe3495a65d30a90 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Mon, 30 Oct 2017 00:08:23 +0330 Subject: [PATCH 174/316] disable puppeteer sandbox for tests --- test/basic.dom.test.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/basic.dom.test.js b/test/basic.dom.test.js index 992aadde17..9835832037 100644 --- a/test/basic.dom.test.js +++ b/test/basic.dom.test.js @@ -34,8 +34,9 @@ test.before('Init Nuxt.js', async t => { }) test.before('Start Puppeteer', async t => { + // https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#puppeteerlaunchoptions browser = await puppeteer.launch({ - // https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#puppeteerlaunchoptions + args: ['--no-sandbox', '--disable-setuid-sandbox'] }) }) From 72b31a217fbd7ddf636529eec587904372e186cf Mon Sep 17 00:00:00 2001 From: Clark Du Date: Mon, 30 Oct 2017 11:30:47 +0800 Subject: [PATCH 175/316] test: add test for open-in-editor --- test/debug.test.js | 36 +++++++++++++++++++++++++++++ test/fixtures/debug/nuxt.config.js | 10 ++++++++ test/fixtures/debug/pages/index.vue | 0 3 files changed, 46 insertions(+) create mode 100644 test/debug.test.js create mode 100644 test/fixtures/debug/nuxt.config.js create mode 100644 test/fixtures/debug/pages/index.vue diff --git a/test/debug.test.js b/test/debug.test.js new file mode 100644 index 0000000000..f9d2d5ba23 --- /dev/null +++ b/test/debug.test.js @@ -0,0 +1,36 @@ +import test from 'ava' +import { resolve } from 'path' +import rp from 'request-promise-native' +import { Nuxt, Builder } from '../index.js' + +const port = 4009 +const url = (route) => 'http://localhost:' + port + route + +let nuxt = null + +// Init nuxt.js and create server listening on localhost:4000 +test.before('Init Nuxt.js', async t => { + const rootDir = resolve(__dirname, 'fixtures/debug') + let config = require(resolve(rootDir, 'nuxt.config.js')) + config.rootDir = rootDir + config.dev = false + nuxt = new Nuxt(config) + await new Builder(nuxt).build() + + await nuxt.listen(port, 'localhost') +}) + +test('Check /test/_open (open-in-editor)', async t => { + const { body } = await rp(url('/test/_open?file=pages/index.vue'), { resolveWithFullResponse: true }) + t.is(body, 'opened in editor!') +}) + +test('Check /test/_open with error (open-in-editor)', async t => { + const { body } = await rp(url('/test/_open?file='), { resolveWithFullResponse: true }) + t.is(body, 'File is not specified') +}) + +// Close server and ask nuxt to stop listening to file changes +test.after('Closing server and nuxt.js', t => { + nuxt.close() +}) diff --git a/test/fixtures/debug/nuxt.config.js b/test/fixtures/debug/nuxt.config.js new file mode 100644 index 0000000000..2e05a7cd6e --- /dev/null +++ b/test/fixtures/debug/nuxt.config.js @@ -0,0 +1,10 @@ +module.exports = { + router: { + base: '/test/' + }, + debug: true, + editor: { + cmd: 'echo', + pattern: '' + } +} diff --git a/test/fixtures/debug/pages/index.vue b/test/fixtures/debug/pages/index.vue new file mode 100644 index 0000000000..e69de29bb2 From cbd73463f8f9231a7a6786e3fed64a57b073b377 Mon Sep 17 00:00:00 2001 From: Clark Du Date: Mon, 30 Oct 2017 11:31:08 +0800 Subject: [PATCH 176/316] test: add test for youch --- test/debug.test.js | 8 ++++++++ test/fixtures/debug/pages/error.vue | 12 ++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 test/fixtures/debug/pages/error.vue diff --git a/test/debug.test.js b/test/debug.test.js index f9d2d5ba23..d19ebe955d 100644 --- a/test/debug.test.js +++ b/test/debug.test.js @@ -30,6 +30,14 @@ test('Check /test/_open with error (open-in-editor)', async t => { t.is(body, 'File is not specified') }) +test('Check /test/error (Youch)', async t => { + const { response, error } = await t.throws(nuxt.renderAndGetWindow(url('/test/error'))) + t.is(response.statusCode, 500) + t.is(response.statusMessage, 'NuxtServerError') + t.true(error.includes('test youch !')) + t.true(error.includes('
')) +}) + // Close server and ask nuxt to stop listening to file changes test.after('Closing server and nuxt.js', t => { nuxt.close() diff --git a/test/fixtures/debug/pages/error.vue b/test/fixtures/debug/pages/error.vue new file mode 100644 index 0000000000..ed9d681ade --- /dev/null +++ b/test/fixtures/debug/pages/error.vue @@ -0,0 +1,12 @@ + + + From 7d2ea44c83add4b35c6700742232f2e577b0af84 Mon Sep 17 00:00:00 2001 From: Clark Du Date: Mon, 30 Oct 2017 11:40:31 +0800 Subject: [PATCH 177/316] test: normalize test title --- test/debug.test.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/debug.test.js b/test/debug.test.js index d19ebe955d..189721bc16 100644 --- a/test/debug.test.js +++ b/test/debug.test.js @@ -20,17 +20,17 @@ test.before('Init Nuxt.js', async t => { await nuxt.listen(port, 'localhost') }) -test('Check /test/_open (open-in-editor)', async t => { +test('/test/_open (open-in-editor)', async t => { const { body } = await rp(url('/test/_open?file=pages/index.vue'), { resolveWithFullResponse: true }) t.is(body, 'opened in editor!') }) -test('Check /test/_open with error (open-in-editor)', async t => { +test('/test/_open should return error (open-in-editor)', async t => { const { body } = await rp(url('/test/_open?file='), { resolveWithFullResponse: true }) t.is(body, 'File is not specified') }) -test('Check /test/error (Youch)', async t => { +test('/test/error should return error stack trace (Youch)', async t => { const { response, error } = await t.throws(nuxt.renderAndGetWindow(url('/test/error'))) t.is(response.statusCode, 500) t.is(response.statusMessage, 'NuxtServerError') From 327fabb663e213ee46db61a2a2ded561e03ec923 Mon Sep 17 00:00:00 2001 From: Clark Du Date: Mon, 30 Oct 2017 12:15:25 +0800 Subject: [PATCH 178/316] fix: originalPositionFor return null when using babel-loader --- lib/core/renderer.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/core/renderer.js b/lib/core/renderer.js index f3be97e5bb..821512c7cd 100644 --- a/lib/core/renderer.js +++ b/lib/core/renderer.js @@ -413,7 +413,8 @@ export default class Renderer extends Tapable { // Try to find original position const { line, column, name, source } = smc.originalPositionFor({ line: frame.getLineNumber() || 0, - column: frame.getColumnNumber() || 0 + column: frame.getColumnNumber() || 0, + bias: SourceMapConsumer.LEAST_UPPER_BOUND }) if (line) { frame.lineNumber = line From c0e9e66eef243e397f50c7b3fc5604f43dbf631c Mon Sep 17 00:00:00 2001 From: Clark Du Date: Mon, 30 Oct 2017 17:11:55 +0800 Subject: [PATCH 179/316] fix: with-feathers nuxt.build is not a function --- examples/with-feathers/src/middleware/nuxt.js | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/examples/with-feathers/src/middleware/nuxt.js b/examples/with-feathers/src/middleware/nuxt.js index d473826111..147e1bc364 100644 --- a/examples/with-feathers/src/middleware/nuxt.js +++ b/examples/with-feathers/src/middleware/nuxt.js @@ -1,22 +1,23 @@ -const resolve = require('path').resolve; -const Nuxt = require('nuxt'); +const resolve = require('path').resolve +const { Nuxt, Builder } = require('nuxt') // Setup nuxt.js -let config = {}; +let config = {} try { - config = require('../../nuxt.config.js'); + config = require('../../nuxt.config.js') } catch (e) {} -config.rootDir = resolve(__dirname, '..', '..'); -config.dev = process.env.NODE_ENV !== 'production'; -const nuxt = new Nuxt(config); +config.rootDir = resolve(__dirname, '..', '..') +config.dev = process.env.NODE_ENV !== 'production' + +const nuxt = new Nuxt(config) if (config.dev) { - nuxt.build().then(() => { - process.emit('nuxt:build:done'); - }); + const builder = new Builder(nuxt) + builder.build() } else { - process.nextTick(() => process.emit('nuxt:build:done')); + process.nextTick(() => process.emit('nuxt:build:done')) } + // Add nuxt.js middleware module.exports = function (req, res) { - nuxt.render(req, res); -}; + nuxt.render(req, res) +} From 147d210c0a87c1e798fb9e32a7f99f3e1953da0c Mon Sep 17 00:00:00 2001 From: Clark Du Date: Mon, 30 Oct 2017 18:01:23 +0800 Subject: [PATCH 180/316] fix: with-feathers not startup with listening 3000 --- examples/with-feathers/src/middleware/nuxt.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/with-feathers/src/middleware/nuxt.js b/examples/with-feathers/src/middleware/nuxt.js index 147e1bc364..c389b9f259 100644 --- a/examples/with-feathers/src/middleware/nuxt.js +++ b/examples/with-feathers/src/middleware/nuxt.js @@ -12,7 +12,7 @@ config.dev = process.env.NODE_ENV !== 'production' const nuxt = new Nuxt(config) if (config.dev) { const builder = new Builder(nuxt) - builder.build() + builder.build().then(() => process.emit('nuxt:build:done')) } else { process.nextTick(() => process.emit('nuxt:build:done')) } From 4b5a0352ff9db4e792050a75bf4c5e1ea12f6390 Mon Sep 17 00:00:00 2001 From: devneko Date: Mon, 30 Oct 2017 20:05:12 +0900 Subject: [PATCH 181/316] fix: Fix regression bug related to setContext() --- lib/app/client.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/app/client.js b/lib/app/client.js index 004788d4eb..87ed476617 100644 --- a/lib/app/client.js +++ b/lib/app/client.js @@ -185,7 +185,7 @@ async function render (to, from, next) { } // Update context - setContext(app, { + await setContext(app, { route: to, from, next: _next.bind(this) @@ -418,7 +418,7 @@ function addHotReload ($component, depth) { var _forceUpdate = $component.$forceUpdate.bind($component.$parent) - $component.$vnode.context.$forceUpdate = () => { + $component.$vnode.context.$forceUpdate = async () => { let Components = getMatchedComponents(router.currentRoute) let Component = Components[depth] if (!Component) return _forceUpdate() @@ -433,7 +433,7 @@ function addHotReload ($component, depth) { <%= (loading ? 'this.$loading.finish && this.$loading.finish()' : '') %> router.push(path) } - setContext(app, { + await setContext(app, { route: router.currentRoute, isHMR: true, next: next.bind(this) From 379d4f72d4b629d023e1bc7338e7db14f1e9d374 Mon Sep 17 00:00:00 2001 From: Atinux Date: Mon, 30 Oct 2017 15:42:59 +0100 Subject: [PATCH 182/316] refacto: Refacto nuxt.build() to finish after webpack is done --- lib/builder/builder.js | 134 ++++++++++++++++------------------------- lib/core/nuxt.js | 14 ++--- lib/core/renderer.js | 5 +- 3 files changed, 56 insertions(+), 97 deletions(-) diff --git a/lib/builder/builder.js b/lib/builder/builder.js index 243e333ea7..2fa55682ed 100644 --- a/lib/builder/builder.js +++ b/lib/builder/builder.js @@ -406,19 +406,14 @@ export default class Builder extends Tapable { } }) - // Make a dll plugin after compile to make next dev builds faster + // Make a dll plugin after compile to make nuxt dev builds faster if (this.options.build.dll && this.options.dev) { compilersOptions.push(dllWebpackConfig.call(this, clientConfig)) } // Simulate webpack multi compiler interface // Separate compilers are simpler, safer and faster - this.compiler = { compilers: [] } - this.compiler.plugin = (...args) => { - this.compiler.compilers.forEach(compiler => { - compiler.plugin(...args) - }) - } + this.compilers = [] // Initialize shared FS and Cache const sharedFS = this.options.dev && new MFS() @@ -427,100 +422,73 @@ export default class Builder extends Tapable { // Initialize compilers compilersOptions.forEach(compilersOption => { const compiler = webpack(compilersOption) + // In dev, write files in memory FS (except for DLL) if (sharedFS && !compiler.name.includes('-dll')) { compiler.outputFileSystem = sharedFS } compiler.cache = sharedCache - this.compiler.compilers.push(compiler) + this.compilers.push(compiler) }) - // Access to compilers with name - this.compiler.compilers.forEach(compiler => { - if (compiler.name) { - this.compiler[compiler.name] = compiler - } - }) - - // Run after each compile - this.compiler.plugin('done', async stats => { - // Don't reload failed builds - /* istanbul ignore if */ - if (stats.hasErrors()) { - return - } - - // console.log(stats.toString({ chunks: true })) - - // Reload renderer if available - if (this.nuxt.renderer) { - this.nuxt.renderer.loadResources(sharedFS || fs) - } - - await this.applyPluginsAsync('done', { builder: this, stats }) - }) - - // Add dev Stuff - if (this.options.dev) { - this.webpackDev() - } - - await this.applyPluginsAsync('compile', { builder: this, compiler: this.compiler }) - // Start Builds - await sequence(this.compiler.compilers, compiler => new Promise((resolve, reject) => { + await sequence(this.compilers, (compiler) => new Promise(async (resolve, reject) => { + const name = compiler.options.name + await this.applyPluginsAsync('compile', { builder: this, compiler, name }) + + // Resolve only when compiler emit done event + compiler.plugin('done', async (stats) => { + await this.applyPluginsAsync('compiled', { builder: this, compiler, name, stats }) + process.nextTick(resolve) + }) + // --- Dev Build --- if (this.options.dev) { - // --- Dev Build --- + // Client Build, watch is started by dev-middleware if (compiler.options.name === 'client') { - // Client watch is started by dev-middleware - resolve() - } else if (compiler.options.name.includes('-dll')) { - // DLL builds should run once - compiler.run((err, stats) => { - if (err) { - return reject(err) - } - debug('[DLL] updated') - resolve() - }) - } else { - // Build and watch for changes - compiler.watch(this.options.watchers.webpack, (err) => { - /* istanbul ignore if */ - if (err) { - return reject(err) - } - resolve() - }) + return this.webpackDev(compiler) } - } else { - // --- Production Build --- - compiler.run((err, stats) => { + // DLL build, should run only once + if (compiler.options.name.includes('-dll')) { + compiler.run((err, stats) => { + if (err) return reject(err) + debug('[DLL] updated') + }) + return + } + // Server, build and watch for changes + compiler.watch(this.options.watchers.webpack, (err) => { /* istanbul ignore if */ - if (err) { - console.error(err) // eslint-disable-line no-console - return reject(err) - } - - // Show build stats for production - console.log(stats.toString(this.webpackStats)) // eslint-disable-line no-console - - /* istanbul ignore if */ - if (stats.hasErrors()) { - return reject(new Error('Webpack build exited with errors')) - } - resolve() + if (err) return reject(err) }) + return } - })) + // --- Production Build --- + compiler.run((err, stats) => { + /* istanbul ignore if */ + if (err) { + console.error(err) // eslint-disable-line no-console + return reject(err) + } - await this.applyPluginsAsync('compiled', this) + // Show build stats for production + console.log(stats.toString(this.webpackStats)) // eslint-disable-line no-console + + /* istanbul ignore if */ + if (stats.hasErrors()) { + return reject(new Error('Webpack build exited with errors')) + } + }) + })) + // Reload renderer if available + if (this.nuxt.renderer) { + this.nuxt.renderer.loadResources(sharedFS || fs) + } } - webpackDev () { + webpackDev (compiler) { debug('Adding webpack middleware...') // Create webpack dev middleware - this.webpackDevMiddleware = pify(webpackDevMiddleware(this.compiler.client, Object.assign({ + this.webpackDevMiddleware = pify(webpackDevMiddleware(compiler, Object.assign({ publicPath: this.options.build.publicPath, stats: this.webpackStats, noInfo: true, @@ -528,7 +496,7 @@ export default class Builder extends Tapable { watchOptions: this.options.watchers.webpack }, this.options.build.devMiddleware))) - this.webpackHotMiddleware = pify(webpackHotMiddleware(this.compiler.client, Object.assign({ + this.webpackHotMiddleware = pify(webpackHotMiddleware(compiler, Object.assign({ log: false, heartbeat: 10000 }, this.options.build.hotMiddleware))) diff --git a/lib/core/nuxt.js b/lib/core/nuxt.js index 68eb6ef964..8ae6a2fc60 100644 --- a/lib/core/nuxt.js +++ b/lib/core/nuxt.js @@ -32,9 +32,6 @@ export default class Nuxt extends Tapable { this.renderRoute = this.renderer.renderRoute.bind(this.renderer) this.renderAndGetWindow = this.renderer.renderAndGetWindow.bind(this.renderer) - // Default Show Open if Nuxt is not listening - this.showOpen = () => {} - this._ready = this.ready().catch(this.errorHandler) } @@ -52,13 +49,6 @@ export default class Nuxt extends Tapable { } listen (port = 3000, host = 'localhost') { - // Update showOpen - this.showOpen = () => { - const _host = host === '0.0.0.0' ? 'localhost' : host - // eslint-disable-next-line no-console - console.log('\n' + chalk.bgGreen.black(' OPEN ') + chalk.green(` http://${_host}:${port}\n`)) - } - return new Promise((resolve, reject) => { const server = this.renderer.app.listen({ port, host, exclusive: false }, err => { /* istanbul ignore if */ @@ -66,6 +56,10 @@ export default class Nuxt extends Tapable { return reject(err) } + const _host = host === '0.0.0.0' ? 'localhost' : host + // eslint-disable-next-line no-console + console.log('\n' + chalk.bgGreen.black(' OPEN ') + chalk.green(` http://${_host}:${port}\n`)) + // Close server on nuxt close this.plugin('close', () => new Promise((resolve, reject) => { // Destroy server by forcing every connection to be closed diff --git a/lib/core/renderer.js b/lib/core/renderer.js index 821512c7cd..65132bcf74 100644 --- a/lib/core/renderer.js +++ b/lib/core/renderer.js @@ -57,7 +57,7 @@ export default class Renderer extends Tapable { // Setup nuxt middleware await this.setupMiddleware() - // Load SSR resources from fs + // Production: Load SSR resources from fs if (!this.options.dev) { await this.loadResources() } @@ -151,9 +151,6 @@ export default class Renderer extends Tapable { // Create Meta Renderer this.metaRenderer = new MetaRenderer(this.nuxt, this) - // Show Open URL - this.nuxt.showOpen() - // Skip following steps if noSSR mode if (this.noSSR) { return From 69fa6fc637085e078b2d9a89d7c95e3f1bf6d320 Mon Sep 17 00:00:00 2001 From: Atinux Date: Mon, 30 Oct 2017 15:48:19 +0100 Subject: [PATCH 183/316] lint: Lint bin/nuxt --- bin/nuxt-dev | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/nuxt-dev b/bin/nuxt-dev index 321a1fce5a..4f827a1a58 100755 --- a/bin/nuxt-dev +++ b/bin/nuxt-dev @@ -31,7 +31,7 @@ const argv = parseArgs(process.argv.slice(2), { } }) -if(argv.version){ +if (argv.version) { console.log(pkg.version) process.exit(0) } From 83815de91b2f89775b3859fc83e52d17cc7c2743 Mon Sep 17 00:00:00 2001 From: Atinux Date: Mon, 30 Oct 2017 17:51:11 +0100 Subject: [PATCH 184/316] lint: Update linting rule on space-before-paren --- .eslintrc.js | 9 ++++++- lib/builder/webpack/base.config.js | 4 ++-- lib/builder/webpack/client.config.js | 6 ++--- lib/builder/webpack/dll.config.js | 2 +- lib/builder/webpack/server.config.js | 4 ++-- lib/builder/webpack/style-loader.js | 2 +- lib/common/utils.js | 36 ++++++++++++++-------------- lib/core/meta.js | 6 ++--- test/basic.dom.test.js | 2 +- test/basic.fail.generate.test.js | 2 +- test/basic.test.js | 2 +- 11 files changed, 41 insertions(+), 34 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 987af7e911..69b6b59125 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -22,7 +22,14 @@ module.exports = { // allow debugger during development 'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0, // do not allow console.logs etc... - 'no-console': 2 + 'no-console': 2, + 'space-before-function-paren': [ + 2, + { + anonymous: 'always', + named: 'never' + } + ], }, globals: {} } diff --git a/lib/builder/webpack/base.config.js b/lib/builder/webpack/base.config.js index 7e1d3c5b0d..e9546072e3 100644 --- a/lib/builder/webpack/base.config.js +++ b/lib/builder/webpack/base.config.js @@ -12,7 +12,7 @@ import { isUrl, urlJoin } from 'utils' | webpack config files |-------------------------------------------------------------------------- */ -export default function webpackBaseConfig (name) { +export default function webpackBaseConfig(name) { const nodeModulesDir = join(__dirname, '..', 'node_modules') const config = { @@ -113,7 +113,7 @@ export default function webpackBaseConfig (name) { // Workaround for hiding Warnings about plugins without a default export (#1179) config.plugins.push({ - apply (compiler) { + apply(compiler) { compiler.plugin('done', stats => { stats.compilation.warnings = stats.compilation.warnings.filter(warn => { if (warn.name === 'ModuleDependencyWarning' && warn.message.includes(`export 'default'`) && warn.message.includes('plugin')) { diff --git a/lib/builder/webpack/client.config.js b/lib/builder/webpack/client.config.js index 5f1d48490e..c61b130e59 100644 --- a/lib/builder/webpack/client.config.js +++ b/lib/builder/webpack/client.config.js @@ -24,7 +24,7 @@ debug.color = 2 // Force green color | In production, will generate public/dist/style.css |-------------------------------------------------------------------------- */ -export default function webpackClientConfig () { +export default function webpackClientConfig() { let config = base.call(this, 'client') // App entry @@ -48,7 +48,7 @@ export default function webpackClientConfig () { new webpack.optimize.CommonsChunkPlugin({ name: 'common', filename: this.options.build.filenames.vendor, - minChunks (module, count) { + minChunks(module, count) { // In the dev we use on-demand-entries. // So, it makes no sense to use commonChunks based on the minChunks count. // Instead, we move all the code in node_modules into each of the pages. @@ -222,7 +222,7 @@ export default function webpackClientConfig () { if (typeof this.options.build.extend === 'function') { const isDev = this.options.dev const extendedConfig = this.options.build.extend.call(this, config, { - get dev () { + get dev() { console.warn('dev has been deprecated in build.extend(), please use isDev') // eslint-disable-line no-console return isDev }, diff --git a/lib/builder/webpack/dll.config.js b/lib/builder/webpack/dll.config.js index 8b030f6766..725015c7df 100644 --- a/lib/builder/webpack/dll.config.js +++ b/lib/builder/webpack/dll.config.js @@ -8,7 +8,7 @@ import ClientConfig from './client.config' | https://github.com/webpack/webpack/tree/master/examples/dll |-------------------------------------------------------------------------- */ -export default function webpackDllConfig (_refConfig) { +export default function webpackDllConfig(_refConfig) { const refConfig = _refConfig || new ClientConfig() const name = refConfig.name + '-dll' diff --git a/lib/builder/webpack/server.config.js b/lib/builder/webpack/server.config.js index 2ee1809780..47a74cd3cb 100644 --- a/lib/builder/webpack/server.config.js +++ b/lib/builder/webpack/server.config.js @@ -11,7 +11,7 @@ import base from './base.config.js' | Webpack Server Config |-------------------------------------------------------------------------- */ -export default function webpackServerConfig () { +export default function webpackServerConfig() { let config = base.call(this, 'server') // env object defined in nuxt.config.js @@ -78,7 +78,7 @@ export default function webpackServerConfig () { if (typeof this.options.build.extend === 'function') { const isDev = this.options.dev const extendedConfig = this.options.build.extend.call(this, config, { - get dev () { + get dev() { console.warn('dev has been deprecated in build.extend(), please use isDev') // eslint-disable-line no-console return isDev }, diff --git a/lib/builder/webpack/style-loader.js b/lib/builder/webpack/style-loader.js index 82a1183cfe..1e4b71171d 100755 --- a/lib/builder/webpack/style-loader.js +++ b/lib/builder/webpack/style-loader.js @@ -1,7 +1,7 @@ import ExtractTextPlugin from 'extract-text-webpack-plugin' import { join } from 'path' -export default function styleLoader (ext, loaders = [], isVueLoader = false) { +export default function styleLoader(ext, loaders = [], isVueLoader = false) { // Normalize loaders loaders = (Array.isArray(loaders) ? loaders : [loaders]).map(loader => { if (typeof loader === 'string') { diff --git a/lib/common/utils.js b/lib/common/utils.js index ad0b90bef2..4932974119 100644 --- a/lib/common/utils.js +++ b/lib/common/utils.js @@ -1,15 +1,15 @@ import { resolve, relative, sep } from 'path' import _ from 'lodash' -export function encodeHtml (str) { +export function encodeHtml(str) { return str.replace(//g, '>') } -export function getContext (req, res) { +export function getContext(req, res) { return { req, res } } -export function setAnsiColors (ansiHTML) { +export function setAnsiColors(ansiHTML) { ansiHTML.setColors({ reset: ['efefef', 'a6004c'], darkgrey: '5a012b', @@ -22,21 +22,21 @@ export function setAnsiColors (ansiHTML) { }) } -export async function waitFor (ms) { +export async function waitFor(ms) { return new Promise(function (resolve) { setTimeout(resolve, (ms || 0)) }) } -export function urlJoin () { +export function urlJoin() { return [].slice.call(arguments).join('/').replace(/\/+/g, '/').replace(':/', '://') } -export function isUrl (url) { +export function isUrl(url) { return (url.indexOf('http') === 0 || url.indexOf('//') === 0) } -export function promisifyRoute (fn) { +export function promisifyRoute(fn) { // If routes is an array if (Array.isArray(fn)) { return Promise.resolve(fn) @@ -59,15 +59,15 @@ export function promisifyRoute (fn) { return promise } -export function sequence (tasks, fn) { +export function sequence(tasks, fn) { return tasks.reduce((promise, task) => promise.then(() => fn(task)), Promise.resolve()) } -export function parallel (tasks, fn) { +export function parallel(tasks, fn) { return Promise.all(tasks.map(task => fn(task))) } -export function chainFn (base, fn) { +export function chainFn(base, fn) { /* istanbul ignore if */ if (!(fn instanceof Function)) { return @@ -90,13 +90,13 @@ export function chainFn (base, fn) { } } -export function isPureObject (o) { +export function isPureObject(o) { return !Array.isArray(o) && typeof o === 'object' } export const isWindows = /^win/.test(process.platform) -export function wp (p = '') { +export function wp(p = '') { /* istanbul ignore if */ if (isWindows) { return p.replace(/\\/g, '\\\\') @@ -104,7 +104,7 @@ export function wp (p = '') { return p } -export function wChunk (p = '') { +export function wChunk(p = '') { /* istanbul ignore if */ if (isWindows) { return p.replace(/\//g, '\\\\') @@ -116,7 +116,7 @@ const reqSep = /\//g const sysSep = _.escapeRegExp(sep) const normalize = string => string.replace(reqSep, sysSep) -export function r () { +export function r() { let args = Array.prototype.slice.apply(arguments) let lastArg = _.last(args) @@ -127,7 +127,7 @@ export function r () { return wp(resolve(...args.map(normalize))) } -export function relativeTo () { +export function relativeTo() { let args = Array.prototype.slice.apply(arguments) let dir = args.shift() @@ -147,7 +147,7 @@ export function relativeTo () { return wp(rp) } -export function flatRoutes (router, path = '', routes = []) { +export function flatRoutes(router, path = '', routes = []) { router.forEach((r) => { if (!r.path.includes(':') && !r.path.includes('*')) { /* istanbul ignore if */ @@ -161,7 +161,7 @@ export function flatRoutes (router, path = '', routes = []) { return routes } -export function cleanChildrenRoutes (routes, isChild = false) { +export function cleanChildrenRoutes(routes, isChild = false) { let start = -1 let routesIndex = [] routes.forEach((route) => { @@ -207,7 +207,7 @@ export function cleanChildrenRoutes (routes, isChild = false) { return routes } -export function createRoutes (files, srcDir) { +export function createRoutes(files, srcDir) { let routes = [] files.forEach((file) => { let keys = file.replace(/^pages/, '').replace(/\.vue$/, '').replace(/\/{2,}/g, '/').split('/').slice(1) diff --git a/lib/core/meta.js b/lib/core/meta.js index 55538f5da4..8975894324 100644 --- a/lib/core/meta.js +++ b/lib/core/meta.js @@ -5,7 +5,7 @@ import VueServerRenderer from 'vue-server-renderer' import LRU from 'lru-cache' export default class MetaRenderer { - constructor (nuxt, renderer) { + constructor(nuxt, renderer) { this.nuxt = nuxt this.renderer = renderer this.options = nuxt.options @@ -22,7 +22,7 @@ export default class MetaRenderer { }) } - getMeta (url) { + getMeta(url) { return new Promise((resolve, reject) => { const vm = new Vue({ render: (h) => h(), // Render empty html tag @@ -35,7 +35,7 @@ export default class MetaRenderer { }) } - async render ({ url = '/' }) { + async render({ url = '/' }) { let meta = this.cache.get(url) if (meta) { diff --git a/test/basic.dom.test.js b/test/basic.dom.test.js index 9835832037..9e3b881a67 100644 --- a/test/basic.dom.test.js +++ b/test/basic.dom.test.js @@ -22,7 +22,7 @@ test.before('Init Nuxt.js', async t => { rootDir: resolve(__dirname, 'fixtures/basic'), dev: false, head: { - titleTemplate (titleChunk) { + titleTemplate(titleChunk) { return titleChunk ? `${titleChunk} - Nuxt.js` : 'Nuxt.js' } } diff --git a/test/basic.fail.generate.test.js b/test/basic.fail.generate.test.js index 65f996193d..e5386e0bcf 100644 --- a/test/basic.fail.generate.test.js +++ b/test/basic.fail.generate.test.js @@ -7,7 +7,7 @@ test('Fail with routes() which throw an error', async t => { rootDir: resolve(__dirname, 'fixtures/basic'), dev: false, generate: { - async routes () { + async routes() { throw new Error('Not today!') } } diff --git a/test/basic.test.js b/test/basic.test.js index 2420cce13b..c290c184b8 100755 --- a/test/basic.test.js +++ b/test/basic.test.js @@ -15,7 +15,7 @@ test.before('Init Nuxt.js', async t => { rootDir: resolve(__dirname, 'fixtures/basic'), dev: false, head: { - titleTemplate (titleChunk) { + titleTemplate(titleChunk) { return titleChunk ? `${titleChunk} - Nuxt.js` : 'Nuxt.js' } } From 6648695015a28402bd78a4e5f03ea39e44a05b31 Mon Sep 17 00:00:00 2001 From: Atinux Date: Mon, 30 Oct 2017 18:41:22 +0100 Subject: [PATCH 185/316] refacto: Hooks --- lib/builder/builder.js | 39 ++++++++++++++++++---------------- lib/builder/generator.js | 23 ++++++++++---------- lib/core/module.js | 36 ++++++++++++++++++-------------- lib/core/nuxt.js | 18 ++++++++-------- lib/core/renderer.js | 45 ++++++++++++++++++++-------------------- 5 files changed, 85 insertions(+), 76 deletions(-) diff --git a/lib/builder/builder.js b/lib/builder/builder.js index 2fa55682ed..d3cccca87a 100644 --- a/lib/builder/builder.js +++ b/lib/builder/builder.js @@ -25,7 +25,7 @@ debug.color = 2 // Force green color const glob = pify(Glob) export default class Builder extends Tapable { - constructor (nuxt) { + constructor(nuxt) { super() this.nuxt = nuxt this.isStatic = false // Flag to know if the build is for a generated app @@ -57,9 +57,12 @@ export default class Builder extends Tapable { this.vueLoader = vueLoaderConfig.bind(this) this._buildStatus = STATUS.INITIAL + + // Call class hook + this.nuxt.applyPlugins('builder', this) } - get plugins () { + get plugins() { return this.options.plugins.map((p, i) => { if (typeof p === 'string') p = { src: p } return { @@ -70,7 +73,7 @@ export default class Builder extends Tapable { }) } - vendor () { + vendor() { return [ 'vue', 'vue-router', @@ -79,7 +82,7 @@ export default class Builder extends Tapable { ].concat(this.options.build.vendor).filter(v => v) } - vendorEntries () { + vendorEntries() { // Used for dll const vendor = this.vendor() const vendorEntries = {} @@ -94,11 +97,11 @@ export default class Builder extends Tapable { return vendorEntries } - forGenerate () { + forGenerate() { this.isStatic = true } - async build () { + async build() { // Avoid calling build() method multiple times when dev:true /* istanbul ignore if */ if (this._buildStatus === STATUS.BUILD_DONE && this.options.dev) { @@ -119,7 +122,7 @@ export default class Builder extends Tapable { await this.nuxt.ready() // Wait for build plugins - await this.nuxt.applyPluginsAsync('build', this) + await this.applyPluginsAsync('build', this.options.build) // Babel options this.babelOptions = _.defaults(this.options.build.babel, { @@ -177,15 +180,15 @@ export default class Builder extends Tapable { // Start webpack build await this.webpackBuild() - await this.applyPluginsAsync('built', this) - // Flag to set that building is done this._buildStatus = STATUS.BUILD_DONE + await this.applyPluginsAsync('built') + return this } - async generateRoutesAndFiles () { + async generateRoutesAndFiles() { debug('Generating files...') // -- Templates -- let templatesFiles = [ @@ -264,7 +267,7 @@ export default class Builder extends Tapable { templateVars.router.routes = this.options.build.createRoutes(this.options.srcDir) } - await this.applyPluginsAsync('extendRoutes', { routes: templateVars.router.routes, templateVars, r }) + await this.applyPluginsAsync('extendRoutes', templateVars.router.routes) // router.extendRoutes method if (typeof this.options.router.extendRoutes === 'function') { @@ -332,7 +335,7 @@ export default class Builder extends Tapable { } } - await this.applyPluginsAsync('generate', { builder: this, templatesFiles, templateVars }) + await this.applyPluginsAsync('generate', { templatesFiles, templateVars, resolve: r }) // Interpret and move template files to .nuxt/ await Promise.all(templatesFiles.map(async ({ src, dst, options, custom }) => { @@ -372,10 +375,10 @@ export default class Builder extends Tapable { return utimes(path, dateFS, dateFS) })) - await this.applyPluginsAsync('generated', this) + await this.applyPluginsAsync('generated') } - async webpackBuild () { + async webpackBuild() { debug('Building files...') const compilersOptions = [] @@ -433,11 +436,11 @@ export default class Builder extends Tapable { // Start Builds await sequence(this.compilers, (compiler) => new Promise(async (resolve, reject) => { const name = compiler.options.name - await this.applyPluginsAsync('compile', { builder: this, compiler, name }) + await this.applyPluginsAsync('compile', { name, compiler }) // Resolve only when compiler emit done event compiler.plugin('done', async (stats) => { - await this.applyPluginsAsync('compiled', { builder: this, compiler, name, stats }) + await this.applyPluginsAsync('compiled', { name, compiler, stats }) process.nextTick(resolve) }) // --- Dev Build --- @@ -484,7 +487,7 @@ export default class Builder extends Tapable { } } - webpackDev (compiler) { + webpackDev(compiler) { debug('Adding webpack middleware...') // Create webpack dev middleware @@ -516,7 +519,7 @@ export default class Builder extends Tapable { this.watchFiles() } - watchFiles () { + watchFiles() { const patterns = [ r(this.options.srcDir, 'layouts'), r(this.options.srcDir, 'store'), diff --git a/lib/builder/generator.js b/lib/builder/generator.js index 3afd1cb79a..da49c7fafc 100644 --- a/lib/builder/generator.js +++ b/lib/builder/generator.js @@ -9,7 +9,7 @@ import Debug from 'debug' const debug = Debug('nuxt:generate') export default class Generator extends Tapable { - constructor (nuxt, builder) { + constructor(nuxt, builder) { super() this.nuxt = nuxt this.options = nuxt.options @@ -20,9 +20,12 @@ export default class Generator extends Tapable { this.srcBuiltPath = resolve(this.options.buildDir, 'dist') this.distPath = resolve(this.options.rootDir, this.options.generate.dir) this.distNuxtPath = join(this.distPath, (isUrl(this.options.build.publicPath) ? '' : this.options.build.publicPath)) + + // Call class hook + this.nuxt.applyPlugins('generator', this) } - async generate ({ build = true, init = true } = {}) { + async generate({ build = true, init = true } = {}) { const s = Date.now() let errors = [] @@ -50,10 +53,8 @@ export default class Generator extends Tapable { try { console.log('Generating routes') // eslint-disable-line no-console generateRoutes = await promisifyRoute(this.options.generate.routes || []) - await this.applyPluginsAsync('generateRoutes', { generator: this, generateRoutes }) } catch (e) { console.error('Could not resolve routes') // eslint-disable-line no-console - console.error(e) // eslint-disable-line no-console throw e // eslint-disable-line no-unreachable } } @@ -62,7 +63,7 @@ export default class Generator extends Tapable { let routes = (this.options.router.mode === 'hash') ? ['/'] : flatRoutes(this.options.router.routes) routes = this.decorateWithPayloads(routes, generateRoutes) - await this.applyPluginsAsync('generate', { generator: this, routes }) + await this.applyPluginsAsync('generate', routes) // Start generate process while (routes.length) { @@ -86,6 +87,8 @@ export default class Generator extends Tapable { const duration = Math.round((Date.now() - s) / 100) / 10 debug(`HTML Files generated in ${duration}s`) + await this.applyPluginsAsync('generated', errors) + if (errors.length) { const report = errors.map(({ type, route, error }) => { /* istanbul ignore if */ @@ -98,12 +101,10 @@ export default class Generator extends Tapable { console.error('==== Error report ==== \n' + report.join('\n\n')) // eslint-disable-line no-console } - await this.applyPluginsAsync('generated', this) - return { duration, errors } } - async initDist () { + async initDist() { // Clean destination folder await remove(this.distPath) debug('Destination folder cleaned') @@ -137,7 +138,7 @@ export default class Generator extends Tapable { debug('Static & build files copied') } - decorateWithPayloads (routes, generateRoutes) { + decorateWithPayloads(routes, generateRoutes) { let routeMap = {} // Fill routeMap for known routes routes.forEach((route) => { @@ -148,7 +149,7 @@ export default class Generator extends Tapable { }) // Fill routeMap with given generate.routes generateRoutes.forEach((route) => { - // route is either a string or like {route : "/my_route/1"} + // route is either a string or like { route : '/my_route/1', payload: {} } const path = _.isString(route) ? route : route.route routeMap[path] = { route: path, @@ -158,7 +159,7 @@ export default class Generator extends Tapable { return _.values(routeMap) } - async generateRoute ({ route, payload = {}, errors = [] }) { + async generateRoute({ route, payload = {}, errors = [] }) { let html try { diff --git a/lib/core/module.js b/lib/core/module.js index 726227b8c7..09ae587144 100755 --- a/lib/core/module.js +++ b/lib/core/module.js @@ -9,19 +9,24 @@ import Debug from 'debug' const debug = Debug('nuxt:module') export default class ModuleContainer extends Tapable { - constructor (nuxt) { + constructor(nuxt) { super() this.nuxt = nuxt this.options = nuxt.options this.requiredModules = [] + + // Call class hook + console.log('call module container') + this.nuxt.applyPlugins('moduleContainer', this) } - async _ready () { + async ready() { + // Load every module in sequence await sequence(this.options.modules, this.addModule.bind(this)) - await this.applyPluginsAsync('ready', this) + await this.applyPluginsAsync('ready') } - addVendor (vendor) { + addVendor(vendor) { /* istanbul ignore if */ if (!vendor) { return @@ -29,7 +34,7 @@ export default class ModuleContainer extends Tapable { this.options.build.vendor = uniq(this.options.build.vendor.concat(vendor)) } - addTemplate (template) { + addTemplate(template) { /* istanbul ignore if */ if (!template) { return @@ -56,7 +61,7 @@ export default class ModuleContainer extends Tapable { return templateObj } - addPlugin (template) { + addPlugin(template) { const { dst } = this.addTemplate(template) // Add to nuxt plugins this.options.plugins.unshift({ @@ -65,31 +70,29 @@ export default class ModuleContainer extends Tapable { }) } - addServerMiddleware (middleware) { + addServerMiddleware(middleware) { this.options.serverMiddleware.push(middleware) } - extendBuild (fn) { + extendBuild(fn) { this.options.build.extend = chainFn(this.options.build.extend, fn) } - extendRoutes (fn) { + extendRoutes(fn) { this.options.router.extendRoutes = chainFn(this.options.router.extendRoutes, fn) } - requireModule (moduleOpts) { + requireModule(moduleOpts) { // Require once return this.addModule(moduleOpts, true) } - async addModule (moduleOpts, requireOnce) { + async addModule(moduleOpts, requireOnce) { /* istanbul ignore if */ if (!moduleOpts) { return } - await this.applyPluginsAsync('add', {moduleOpts, requireOnce}) - // Allow using babel style array options if (Array.isArray(moduleOpts)) { moduleOpts = { @@ -129,13 +132,13 @@ export default class ModuleContainer extends Tapable { } // Call module with `this` context and pass options - return new Promise((resolve, reject) => { - const result = module.call(this, options, err => { + const m = await new Promise((resolve, reject) => { + const result = module.call(this, options, (err, m) => { /* istanbul ignore if */ if (err) { return reject(err) } - resolve(module) + resolve(m) }) // If module send back a promise if (result && result.then instanceof Function) { @@ -146,5 +149,6 @@ export default class ModuleContainer extends Tapable { return resolve(module) } }) + await this.applyPluginsAsync('module', { meta: module.meta, module: m }) } } diff --git a/lib/core/nuxt.js b/lib/core/nuxt.js index 8ae6a2fc60..9e94dd6267 100644 --- a/lib/core/nuxt.js +++ b/lib/core/nuxt.js @@ -12,10 +12,10 @@ const debug = Debug('nuxt:') debug.color = 5 export default class Nuxt extends Tapable { - constructor (_options = {}) { + constructor(options = {}) { super() - this.options = Options.from(_options) + this.options = Options.from(options) // Paths for resolving requires from `rootDir` this.nodeModulePaths = Module._nodeModulePaths(this.options.rootDir) @@ -35,20 +35,20 @@ export default class Nuxt extends Tapable { this._ready = this.ready().catch(this.errorHandler) } - async ready () { + async ready() { if (this._ready) { return this._ready } - await this.moduleContainer._ready() + await this.moduleContainer.ready() await this.applyPluginsAsync('ready') - await this.renderer._ready() + await this.renderer.ready() this.initialized = true return this } - listen (port = 3000, host = 'localhost') { + listen(port = 3000, host = 'localhost') { return new Promise((resolve, reject) => { const server = this.renderer.app.listen({ port, host, exclusive: false }, err => { /* istanbul ignore if */ @@ -81,7 +81,7 @@ export default class Nuxt extends Tapable { }) } - errorHandler /* istanbul ignore next */() { + errorHandler/* istanbul ignore next */() { // Apply plugins // eslint-disable-next-line no-console this.applyPluginsAsync('error', ...arguments).catch(console.error) @@ -101,7 +101,7 @@ export default class Nuxt extends Tapable { console.error(...arguments) } - resolvePath (path) { + resolvePath(path) { // Try to resolve using NPM resolve path first try { let resolvedPath = Module._resolveFilename(path, { paths: this.nodeModulePaths }) @@ -118,7 +118,7 @@ export default class Nuxt extends Tapable { return resolve(this.options.srcDir, path) } - async close (callback) { + async close(callback) { await this.applyPluginsAsync('close') /* istanbul ignore if */ diff --git a/lib/core/renderer.js b/lib/core/renderer.js index 65132bcf74..e3dc16236e 100644 --- a/lib/core/renderer.js +++ b/lib/core/renderer.js @@ -25,7 +25,7 @@ setAnsiColors(ansiHTML) let jsdom = null export default class Renderer extends Tapable { - constructor (nuxt) { + constructor(nuxt) { super() this.nuxt = nuxt this.options = nuxt.options @@ -49,11 +49,12 @@ export default class Renderer extends Tapable { spaTemplate: null, errorTemplate: parseTemplate('Nuxt.js Internal Server Error') } + + // Call class hook + this.nuxt.applyPlugins('renderer', this) } - async _ready () { - await this.nuxt.applyPluginsAsync('renderer', this) - + async ready() { // Setup nuxt middleware await this.setupMiddleware() @@ -63,10 +64,10 @@ export default class Renderer extends Tapable { } // Call ready plugin - await this.applyPluginsAsync('ready', this) + await this.applyPluginsAsync('ready') } - async loadResources (_fs = fs) { + async loadResources(_fs = fs) { let distPath = resolve(this.options.buildDir, 'dist') let updated = [] @@ -115,11 +116,11 @@ export default class Renderer extends Tapable { } } - get noSSR () { + get noSSR() { return this.options.render.ssr === false } - get isReady () { + get isReady() { if (this.noSSR) { return Boolean(this.resources.spaTemplate) } @@ -127,7 +128,7 @@ export default class Renderer extends Tapable { return Boolean(this.bundleRenderer && this.resources.ssrTemplate) } - get isResourcesAvailable () { + get isResourcesAvailable() { // Required for both if (!this.resources.clientManifest) { return false @@ -142,7 +143,7 @@ export default class Renderer extends Tapable { return Boolean(this.resources.ssrTemplate && this.resources.serverBundle) } - createRenderer () { + createRenderer() { // Ensure resources are available if (!this.isResourcesAvailable) { return @@ -164,7 +165,7 @@ export default class Renderer extends Tapable { }, this.options.render.bundleRenderer)) } - useMiddleware (m) { + useMiddleware(m) { // Resolve const $m = m let src @@ -188,11 +189,11 @@ export default class Renderer extends Tapable { this.app.use(path, handler) } - get publicPath () { + get publicPath() { return isUrl(this.options.build.publicPath) ? Options.defaults.build.publicPath : this.options.build.publicPath } - async setupMiddleware () { + async setupMiddleware() { // Apply setupMiddleware from modules first await this.applyPluginsAsync('setupMiddleware', this.app) @@ -229,7 +230,7 @@ export default class Renderer extends Tapable { if (this.options.debug) { this.useMiddleware({ path: '_open', - handler (req, res) { + handler(req, res) { // Lazy load open-in-editor const openInEditor = require('open-in-editor') const editor = openInEditor.configure(_this.options.editor) @@ -280,9 +281,10 @@ export default class Renderer extends Tapable { this.useMiddleware(this.errorMiddleware.bind(this)) } - async nuxtMiddleware (req, res, next) { + async nuxtMiddleware(req, res, next) { // Get context const context = getContext(req, res) + res.statusCode = 200 try { const { html, error, redirected, resourceHints } = await this.renderRoute(req.url, context) @@ -338,7 +340,7 @@ export default class Renderer extends Tapable { } } - errorMiddleware (err, req, res, next) { + errorMiddleware(err, req, res, next) { // ensure statusCode, message and name fields err.statusCode = err.statusCode || 500 err.message = err.message || 'Nuxt Server Error' @@ -390,7 +392,7 @@ export default class Renderer extends Tapable { } } - async readSource (frame) { + async readSource(frame) { const serverBundle = this.resources.serverBundle // Remove webpack:/// & query string from the end @@ -468,7 +470,7 @@ export default class Renderer extends Tapable { } } - async renderRoute (url, context = {}) { + async renderRoute(url, context = {}) { /* istanbul ignore if */ if (!this.isReady) { return new Promise(resolve => { @@ -546,7 +548,7 @@ export default class Renderer extends Tapable { } } - async renderAndGetWindow (url, opts = {}) { + async renderAndGetWindow(url, opts = {}) { /* istanbul ignore if */ if (!jsdom) { try { @@ -561,10 +563,9 @@ export default class Renderer extends Tapable { let options = { resources: 'usable', // load subresources (https://github.com/tmpvar/jsdom#loading-subresources) runScripts: 'dangerously', - beforeParse (window) { + beforeParse(window) { // Mock window.scrollTo - window.scrollTo = () => { - } + window.scrollTo = () => {} } } if (opts.virtualConsole !== false) { From f72e620d7d3366cf44d3a572b08b8cefe0d12a3f Mon Sep 17 00:00:00 2001 From: Atinux Date: Mon, 30 Oct 2017 18:44:39 +0100 Subject: [PATCH 186/316] fix: Remove console.log --- lib/core/module.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/core/module.js b/lib/core/module.js index 09ae587144..257c5fad02 100755 --- a/lib/core/module.js +++ b/lib/core/module.js @@ -16,7 +16,6 @@ export default class ModuleContainer extends Tapable { this.requiredModules = [] // Call class hook - console.log('call module container') this.nuxt.applyPlugins('moduleContainer', this) } From 94ad5955e644550b1f6dc73b7f09a2f7b0591b28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Chopin?= Date: Mon, 30 Oct 2017 22:39:08 +0100 Subject: [PATCH 187/316] Hooks ready to be tested --- lib/builder/builder.js | 28 +++++------- lib/builder/generator.js | 24 +++++------ lib/common/options.js | 1 + lib/core/module.js | 43 +++++++++---------- lib/core/nuxt.js | 39 ++++++++++++----- lib/core/renderer.js | 16 +++---- package.json | 1 - .../modules/{tapable => hooks}/index.js | 6 +-- test/fixtures/module/nuxt.config.js | 2 +- test/module.test.js | 2 +- yarn.lock | 9 +--- 11 files changed, 84 insertions(+), 87 deletions(-) rename test/fixtures/module/modules/{tapable => hooks}/index.js (66%) diff --git a/lib/builder/builder.js b/lib/builder/builder.js index d3cccca87a..1dbef90a59 100644 --- a/lib/builder/builder.js +++ b/lib/builder/builder.js @@ -6,7 +6,6 @@ import pify from 'pify' import webpack from 'webpack' import serialize from 'serialize-javascript' import { join, resolve, basename, extname, dirname } from 'path' -import Tapable from 'tappable' import MFS from 'memory-fs' import webpackDevMiddleware from 'webpack-dev-middleware' import webpackHotMiddleware from 'webpack-hot-middleware' @@ -24,9 +23,8 @@ debug.color = 2 // Force green color const glob = pify(Glob) -export default class Builder extends Tapable { +export default class Builder { constructor(nuxt) { - super() this.nuxt = nuxt this.isStatic = false // Flag to know if the build is for a generated app this.options = nuxt.options @@ -57,9 +55,6 @@ export default class Builder extends Tapable { this.vueLoader = vueLoaderConfig.bind(this) this._buildStatus = STATUS.INITIAL - - // Call class hook - this.nuxt.applyPlugins('builder', this) } get plugins() { @@ -121,8 +116,8 @@ export default class Builder extends Tapable { // Wait for nuxt ready await this.nuxt.ready() - // Wait for build plugins - await this.applyPluginsAsync('build', this.options.build) + // Call before hook + await this.nuxt.callHook('build:before', this, this.options.build) // Babel options this.babelOptions = _.defaults(this.options.build.babel, { @@ -183,7 +178,8 @@ export default class Builder extends Tapable { // Flag to set that building is done this._buildStatus = STATUS.BUILD_DONE - await this.applyPluginsAsync('built') + // Call done hook + await this.nuxt.callHook('build:done', this) return this } @@ -267,7 +263,7 @@ export default class Builder extends Tapable { templateVars.router.routes = this.options.build.createRoutes(this.options.srcDir) } - await this.applyPluginsAsync('extendRoutes', templateVars.router.routes) + await this.nuxt.callHook('build:extendRoutes', templateVars.router.routes, r) // router.extendRoutes method if (typeof this.options.router.extendRoutes === 'function') { @@ -335,7 +331,7 @@ export default class Builder extends Tapable { } } - await this.applyPluginsAsync('generate', { templatesFiles, templateVars, resolve: r }) + await this.nuxt.callHook('build:templates', { templatesFiles, templateVars, resolve: r }) // Interpret and move template files to .nuxt/ await Promise.all(templatesFiles.map(async ({ src, dst, options, custom }) => { @@ -374,8 +370,6 @@ export default class Builder extends Tapable { const dateFS = Date.now() / 1000 - 1000 return utimes(path, dateFS, dateFS) })) - - await this.applyPluginsAsync('generated') } async webpackBuild() { @@ -436,11 +430,11 @@ export default class Builder extends Tapable { // Start Builds await sequence(this.compilers, (compiler) => new Promise(async (resolve, reject) => { const name = compiler.options.name - await this.applyPluginsAsync('compile', { name, compiler }) + await this.nuxt.callHook('build:compile', { name, compiler }) // Resolve only when compiler emit done event compiler.plugin('done', async (stats) => { - await this.applyPluginsAsync('compiled', { name, compiler, stats }) + await this.nuxt.callHook('build:compiled', { name, compiler, stats }) process.nextTick(resolve) }) // --- Dev Build --- @@ -511,7 +505,7 @@ export default class Builder extends Tapable { } // Stop webpack middleware on nuxt.close() - this.nuxt.plugin('close', () => new Promise(resolve => { + this.nuxt.hook('close', () => new Promise(resolve => { this.webpackDevMiddleware.close(() => resolve()) })) @@ -548,7 +542,7 @@ export default class Builder extends Tapable { .on('change', refreshFiles) // Stop watching on nuxt.close() - this.nuxt.plugin('close', () => { + this.nuxt.hook('close', () => { filesWatcher.close() customFilesWatcher.close() }) diff --git a/lib/builder/generator.js b/lib/builder/generator.js index da49c7fafc..750bc51510 100644 --- a/lib/builder/generator.js +++ b/lib/builder/generator.js @@ -2,15 +2,13 @@ import { copy, remove, writeFile, mkdirp, removeSync, existsSync } from 'fs-extr import _ from 'lodash' import { resolve, join, dirname, sep } from 'path' import { minify } from 'html-minifier' -import Tapable from 'tappable' import { isUrl, promisifyRoute, waitFor, flatRoutes } from 'utils' import Debug from 'debug' const debug = Debug('nuxt:generate') -export default class Generator extends Tapable { +export default class Generator { constructor(nuxt, builder) { - super() this.nuxt = nuxt this.options = nuxt.options this.builder = builder @@ -20,28 +18,26 @@ export default class Generator extends Tapable { this.srcBuiltPath = resolve(this.options.buildDir, 'dist') this.distPath = resolve(this.options.rootDir, this.options.generate.dir) this.distNuxtPath = join(this.distPath, (isUrl(this.options.build.publicPath) ? '' : this.options.build.publicPath)) - - // Call class hook - this.nuxt.applyPlugins('generator', this) } async generate({ build = true, init = true } = {}) { + // Wait for nuxt be ready + await this.nuxt.ready() + + // Call before hook + await this.nuxt.callHook('generate:before', this, this.options.generate) + const s = Date.now() let errors = [] // Add flag to set process.static this.builder.forGenerate() - // Wait for nuxt be ready - await this.nuxt.ready() - // Start build process if (build) { await this.builder.build() } - await this.nuxt.applyPluginsAsync('generator', this) - // Initialize dist directory if (init) { await this.initDist() @@ -63,7 +59,8 @@ export default class Generator extends Tapable { let routes = (this.options.router.mode === 'hash') ? ['/'] : flatRoutes(this.options.router.routes) routes = this.decorateWithPayloads(routes, generateRoutes) - await this.applyPluginsAsync('generate', routes) + // extendRoutes hook + await this.nuxt.callHook('generate:extendRoutes', routes) // Start generate process while (routes.length) { @@ -87,7 +84,8 @@ export default class Generator extends Tapable { const duration = Math.round((Date.now() - s) / 100) / 10 debug(`HTML Files generated in ${duration}s`) - await this.applyPluginsAsync('generated', errors) + // done hook + await this.nuxt.callHook('generate:done', this, errors) if (errors.length) { const report = errors.map(({ type, route, error }) => { diff --git a/lib/common/options.js b/lib/common/options.js index 2d708f3b23..fc31e04878 100755 --- a/lib/common/options.js +++ b/lib/common/options.js @@ -291,6 +291,7 @@ Options.defaults = { editor: { editor: 'code' }, + hooks: () => {}, messages: { error_404: 'This page could not be found', server_error: 'Server error', diff --git a/lib/core/module.js b/lib/core/module.js index 257c5fad02..d55eed13f0 100755 --- a/lib/core/module.js +++ b/lib/core/module.js @@ -2,27 +2,24 @@ import path from 'path' import fs from 'fs' import { uniq } from 'lodash' import hash from 'hash-sum' -import Tapable from 'tappable' import { chainFn, sequence } from 'utils' import Debug from 'debug' const debug = Debug('nuxt:module') -export default class ModuleContainer extends Tapable { +export default class ModuleContainer { constructor(nuxt) { - super() this.nuxt = nuxt this.options = nuxt.options this.requiredModules = [] - - // Call class hook - this.nuxt.applyPlugins('moduleContainer', this) } async ready() { + this.nuxt.callHook('modules:before', this, this.options.modules) // Load every module in sequence await sequence(this.options.modules, this.addModule.bind(this)) - await this.applyPluginsAsync('ready') + // Call done hook + await this.nuxt.callHook('modules:done', this) } addVendor(vendor) { @@ -102,42 +99,43 @@ export default class ModuleContainer extends Tapable { // Allows passing runtime options to each module const options = moduleOpts.options || (typeof moduleOpts === 'object' ? moduleOpts : {}) - const originalSrc = moduleOpts.src || moduleOpts + const src = moduleOpts.src || moduleOpts // Resolve module - let module = originalSrc - if (typeof module === 'string') { - module = require(this.nuxt.resolvePath(module)) + let module + if (typeof src === 'string') { + module = require(this.nuxt.resolvePath(src)) } // Validate module /* istanbul ignore if */ if (typeof module !== 'function') { - throw new Error(`[nuxt] Module ${JSON.stringify(originalSrc)} should export a function`) + throw new Error(`[nuxt] Module ${JSON.stringify(src)} should export a function`) } // Module meta - if (!module.meta) { - module.meta = {} - } - if (module.meta.name) { - const alreadyRequired = this.requiredModules.indexOf(module.meta.name) !== -1 + module.meta = module.meta || {} + let name = module.meta.name || module.name + + // If requireOnce specified & module from NPM or with specified name + if (requireOnce && name) { + const alreadyRequired = this.requiredModules.indexOf(name) !== -1 if (requireOnce && alreadyRequired) { return } if (!alreadyRequired) { - this.requiredModules.push(module.meta.name) + this.requiredModules.push(name) } } // Call module with `this` context and pass options - const m = await new Promise((resolve, reject) => { - const result = module.call(this, options, (err, m) => { + await new Promise((resolve, reject) => { + const result = module.call(this, options, (err) => { /* istanbul ignore if */ if (err) { return reject(err) } - resolve(m) + resolve() }) // If module send back a promise if (result && result.then instanceof Function) { @@ -145,9 +143,8 @@ export default class ModuleContainer extends Tapable { } // If not expecting a callback but returns no promise (=synchronous) if (module.length < 2) { - return resolve(module) + return resolve() } }) - await this.applyPluginsAsync('module', { meta: module.meta, module: m }) } } diff --git a/lib/core/nuxt.js b/lib/core/nuxt.js index 9e94dd6267..da6dd0358d 100644 --- a/lib/core/nuxt.js +++ b/lib/core/nuxt.js @@ -1,6 +1,6 @@ -import Tapable from 'tappable' import chalk from 'chalk' import { Options } from 'common' +import { sequence } from 'utils' import ModuleContainer from './module' import Renderer from './renderer' import Debug from 'debug' @@ -11,10 +11,8 @@ import { join, resolve } from 'path' const debug = Debug('nuxt:') debug.color = 5 -export default class Nuxt extends Tapable { +export default class Nuxt { constructor(options = {}) { - super() - this.options = Options.from(options) // Paths for resolving requires from `rootDir` @@ -22,6 +20,9 @@ export default class Nuxt extends Tapable { this.initialized = false this.errorHandler = this.errorHandler.bind(this) + // Hooks + this._hooks = {} + this.hook = this.hook.bind(this) // Create instance of core components this.moduleContainer = new ModuleContainer(this) @@ -40,17 +41,35 @@ export default class Nuxt extends Tapable { return this._ready } + // Call hooks + if (typeof this.options.hooks === 'function') { + this.options.hooks(this.hook) + } + // Add nuxt modules await this.moduleContainer.ready() - await this.applyPluginsAsync('ready') await this.renderer.ready() this.initialized = true + await this.callHook('ready', this) + return this } + hook(name, fn) { + this._hooks[name] = this._hooks[name] || [] + this._hooks[name].push(fn) + } + + async callHook(name, ...args) { + if (!this._hooks[name]) { + return + } + await sequence(this._hooks[name], (fn) => fn(...args)) + } + listen(port = 3000, host = 'localhost') { return new Promise((resolve, reject) => { - const server = this.renderer.app.listen({ port, host, exclusive: false }, err => { + const server = this.renderer.app.listen({ port, host, exclusive: false }, (err) => { /* istanbul ignore if */ if (err) { return reject(err) @@ -61,7 +80,7 @@ export default class Nuxt extends Tapable { console.log('\n' + chalk.bgGreen.black(' OPEN ') + chalk.green(` http://${_host}:${port}\n`)) // Close server on nuxt close - this.plugin('close', () => new Promise((resolve, reject) => { + this.hook('close', () => new Promise((resolve, reject) => { // Destroy server by forcing every connection to be closed server.destroy(err => { debug('server closed') @@ -73,7 +92,7 @@ export default class Nuxt extends Tapable { }) })) - resolve(this.applyPluginsAsync('listen', { server, port, host })) + this.callHook('listen', server, { port, host }).then(resolve) }) // Add server.destroy(cb) method @@ -84,7 +103,7 @@ export default class Nuxt extends Tapable { errorHandler/* istanbul ignore next */() { // Apply plugins // eslint-disable-next-line no-console - this.applyPluginsAsync('error', ...arguments).catch(console.error) + this.callHook('error', ...arguments).catch(console.error) // Silent if (this.options.errorHandler === false) { @@ -119,7 +138,7 @@ export default class Nuxt extends Tapable { } async close(callback) { - await this.applyPluginsAsync('close') + await this.callHook('close', this) /* istanbul ignore if */ if (typeof callback === 'function') { diff --git a/lib/core/renderer.js b/lib/core/renderer.js index e3dc16236e..6c09c18001 100644 --- a/lib/core/renderer.js +++ b/lib/core/renderer.js @@ -2,7 +2,6 @@ import ansiHTML from 'ansi-html' import serialize from 'serialize-javascript' import generateETag from 'etag' import fresh from 'fresh' -import Tapable from 'tappable' import serveStatic from 'serve-static' import compression from 'compression' import _ from 'lodash' @@ -24,9 +23,8 @@ setAnsiColors(ansiHTML) let jsdom = null -export default class Renderer extends Tapable { +export default class Renderer { constructor(nuxt) { - super() this.nuxt = nuxt this.options = nuxt.options @@ -49,12 +47,10 @@ export default class Renderer extends Tapable { spaTemplate: null, errorTemplate: parseTemplate('Nuxt.js Internal Server Error') } - - // Call class hook - this.nuxt.applyPlugins('renderer', this) } async ready() { + await this.nuxt.callHook('render:before', this, this.options.render) // Setup nuxt middleware await this.setupMiddleware() @@ -63,8 +59,8 @@ export default class Renderer extends Tapable { await this.loadResources() } - // Call ready plugin - await this.applyPluginsAsync('ready') + // Call done hook + await this.nuxt.callHook('render:done', this) } async loadResources(_fs = fs) { @@ -109,7 +105,7 @@ export default class Renderer extends Tapable { } // Call resourcesLoaded plugin - await this.applyPluginsAsync('resourcesLoaded', this.resources) + await this.nuxt.callHook('render:resourcesLoaded', this.resources) if (updated.length > 0) { this.createRenderer() @@ -195,7 +191,7 @@ export default class Renderer extends Tapable { async setupMiddleware() { // Apply setupMiddleware from modules first - await this.applyPluginsAsync('setupMiddleware', this.app) + await this.nuxt.callHook('render:setupMiddleware', this.app) // Gzip middleware for production if (!this.options.dev && this.options.render.gzip) { diff --git a/package.json b/package.json index d6397fdf3b..d3c3d6c877 100644 --- a/package.json +++ b/package.json @@ -107,7 +107,6 @@ "server-destroy": "^1.0.1", "source-map": "^0.6.1", "source-map-support": "^0.5.0", - "tappable": "^1.1.0", "uglifyjs-webpack-plugin": "^1.0.1", "url-loader": "^0.6.2", "vue": "^2.5.2", diff --git a/test/fixtures/module/modules/tapable/index.js b/test/fixtures/module/modules/hooks/index.js similarity index 66% rename from test/fixtures/module/modules/tapable/index.js rename to test/fixtures/module/modules/hooks/index.js index fa5bd572ef..2c0e2949d0 100644 --- a/test/fixtures/module/modules/tapable/index.js +++ b/test/fixtures/module/modules/hooks/index.js @@ -2,17 +2,17 @@ module.exports = function () { let ctr = 1 // Add hook for module - this.plugin('ready', moduleContainer => { + this.plugin('modules:done', (moduleContainer) => { this.nuxt.__module_hook = moduleContainer && ctr++ }) // Add hook for renderer - this.nuxt.plugin('renderer', renderer => { + this.nuxt.hook('render:done', (renderer) => { this.nuxt.__renderer_hook = renderer && ctr++ }) // Add hook for build - this.nuxt.plugin('build', builder => { + this.nuxt.plugin('build:done', (builder) => { this.nuxt.__builder_hook = builder && ctr++ }) } diff --git a/test/fixtures/module/nuxt.config.js b/test/fixtures/module/nuxt.config.js index 9b53c2a7d1..d60660981f 100755 --- a/test/fixtures/module/nuxt.config.js +++ b/test/fixtures/module/nuxt.config.js @@ -2,7 +2,7 @@ module.exports = { loading: true, modules: [ '~/modules/basic', - '~/modules/tapable', + '~/modules/hooks', { src: '~/modules/middleware', options: { diff --git a/test/module.test.js b/test/module.test.js index 26ac78c81d..a7e6c8eeb1 100755 --- a/test/module.test.js +++ b/test/module.test.js @@ -36,7 +36,7 @@ test('Middleware', async t => { t.is(response, 'It works!', '/api response is correct') }) -test('Tapable', async t => { +test('Hooks', async t => { t.is(nuxt.__module_hook, 1) t.is(nuxt.__renderer_hook, 2) t.is(nuxt.__builder_hook, 3) diff --git a/yarn.lock b/yarn.lock index 1ec7e417c8..f36ff3232c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6488,17 +6488,10 @@ table@^4.0.1: slice-ansi "1.0.0" string-width "^2.1.1" -tapable@^0.2.6, tapable@^0.2.7: +tapable@^0.2.7: version "0.2.8" resolved "https://registry.yarnpkg.com/tapable/-/tapable-0.2.8.tgz#99372a5c999bf2df160afc0d74bed4f47948cd22" -tappable@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/tappable/-/tappable-1.1.0.tgz#521770dea7dc4715d48ddb4c471071afee012025" - dependencies: - pify "^3.0.0" - tapable "^0.2.6" - tar-pack@^3.4.0: version "3.4.1" resolved "https://registry.yarnpkg.com/tar-pack/-/tar-pack-3.4.1.tgz#e1dbc03a9b9d3ba07e896ad027317eb679a10a1f" From 2e8271f65826e0dd537fd862687351035e1a0af3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Chopin?= Date: Mon, 30 Oct 2017 22:39:26 +0100 Subject: [PATCH 188/316] lint: Lint file --- lib/builder/webpack/vue-loader.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/builder/webpack/vue-loader.config.js b/lib/builder/webpack/vue-loader.config.js index c0f70a7d20..f3a2aaa4a3 100644 --- a/lib/builder/webpack/vue-loader.config.js +++ b/lib/builder/webpack/vue-loader.config.js @@ -1,4 +1,4 @@ -export default function vueLoader () { +export default function vueLoader() { // https://vue-loader.vuejs.org/en const config = { postcss: this.options.build.postcss, From fe0ad908b7a41d98eb4b4fec1f4748bca73f1808 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Chopin?= Date: Mon, 30 Oct 2017 23:14:21 +0100 Subject: [PATCH 189/316] hook: Add generate:page hook --- lib/builder/generator.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/builder/generator.js b/lib/builder/generator.js index 750bc51510..b24a5680b3 100644 --- a/lib/builder/generator.js +++ b/lib/builder/generator.js @@ -182,12 +182,17 @@ export default class Generator { let path = join(route, sep, 'index.html') // /about -> /about/index.html path = (path === '/404/index.html') ? '/404.html' : path // /404 -> /404.html - debug('Generate file: ' + path) - path = join(this.distPath, path) + + // Call hook to let user update the path & html + const page = { route, path, html } + await this.nuxt.callHook('generate:page', page) + + debug('Generate file: ' + page.path) + page.path = join(this.distPath, page.path) // Make sure the sub folders are created - await mkdirp(dirname(path)) - await writeFile(path, html, 'utf8') + await mkdirp(dirname(page.path)) + await writeFile(page.path, page.html, 'utf8') return true } From ad59f788dc2417e4bb5ce5861deb693f2ef3888c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Chopin?= Date: Mon, 30 Oct 2017 23:15:06 +0100 Subject: [PATCH 190/316] hook: Add render:route hook --- lib/core/renderer.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/core/renderer.js b/lib/core/renderer.js index 6c09c18001..f9d0209e4d 100644 --- a/lib/core/renderer.js +++ b/lib/core/renderer.js @@ -283,7 +283,10 @@ export default class Renderer { res.statusCode = 200 try { - const { html, error, redirected, resourceHints } = await this.renderRoute(req.url, context) + const result = await this.renderRoute(req.url, context) + await this.nuxt.callHook('render:route', req.url, result) + const { html, error, redirected, resourceHints } = result + if (redirected) { return html } From daaa5bdd1213ad3abfde5e45cdeec96ca7a22b58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Chopin?= Date: Mon, 30 Oct 2017 23:15:35 +0100 Subject: [PATCH 191/316] hook: Handle hook error and continue process --- lib/core/nuxt.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/core/nuxt.js b/lib/core/nuxt.js index da6dd0358d..7bc22fac2e 100644 --- a/lib/core/nuxt.js +++ b/lib/core/nuxt.js @@ -64,7 +64,13 @@ export default class Nuxt { if (!this._hooks[name]) { return } - await sequence(this._hooks[name], (fn) => fn(...args)) + debug(`Call ${name} hooks (${this._hooks[name].length})`) + try { + await sequence(this._hooks[name], (fn) => fn(...args)) + } catch (err) { + console.error(`> Error on hook "${name}":`) // eslint-disable-line no-console + console.error(err) // eslint-disable-line no-console + } } listen(port = 3000, host = 'localhost') { From 7aa0863cb7d74abbd4ba2b744696fda495659091 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Chopin?= Date: Mon, 30 Oct 2017 23:17:46 +0100 Subject: [PATCH 192/316] test: Fix test for hooks --- test/fixtures/module/modules/hooks/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/fixtures/module/modules/hooks/index.js b/test/fixtures/module/modules/hooks/index.js index 2c0e2949d0..5349106c6e 100644 --- a/test/fixtures/module/modules/hooks/index.js +++ b/test/fixtures/module/modules/hooks/index.js @@ -2,7 +2,7 @@ module.exports = function () { let ctr = 1 // Add hook for module - this.plugin('modules:done', (moduleContainer) => { + this.nuxt.hook('modules:done', (moduleContainer) => { this.nuxt.__module_hook = moduleContainer && ctr++ }) @@ -12,7 +12,7 @@ module.exports = function () { }) // Add hook for build - this.nuxt.plugin('build:done', (builder) => { + this.nuxt.hook('build:done', (builder) => { this.nuxt.__builder_hook = builder && ctr++ }) } From 7137f848a295c95a0d41e9d0e7ed150d77ce6b24 Mon Sep 17 00:00:00 2001 From: Atinux Date: Tue, 31 Oct 2017 12:33:15 +0100 Subject: [PATCH 193/316] hooks: Handle hooks as object --- lib/common/options.js | 2 +- lib/core/nuxt.js | 21 +++++++++++++++++++-- test/basic.generate.test.js | 4 ++++ test/fixtures/basic/nuxt.config.js | 7 +++++++ 4 files changed, 31 insertions(+), 3 deletions(-) diff --git a/lib/common/options.js b/lib/common/options.js index fc31e04878..3aea5e59ae 100755 --- a/lib/common/options.js +++ b/lib/common/options.js @@ -291,7 +291,7 @@ Options.defaults = { editor: { editor: 'code' }, - hooks: () => {}, + hooks: null, messages: { error_404: 'This page could not be found', server_error: 'Server error', diff --git a/lib/core/nuxt.js b/lib/core/nuxt.js index 7bc22fac2e..e418db59c4 100644 --- a/lib/core/nuxt.js +++ b/lib/core/nuxt.js @@ -6,6 +6,7 @@ import Renderer from './renderer' import Debug from 'debug' import enableDestroy from 'server-destroy' import Module from 'module' +import { isPlainObject } from 'lodash' import { join, resolve } from 'path' const debug = Debug('nuxt:') @@ -41,8 +42,10 @@ export default class Nuxt { return this._ready } - // Call hooks - if (typeof this.options.hooks === 'function') { + // Add hooks + if (isPlainObject(this.options.hooks)) { + this.addObjectHooks(this.options.hooks) + } else if (typeof this.options.hooks === 'function') { this.options.hooks(this.hook) } // Add nuxt modules @@ -56,6 +59,9 @@ export default class Nuxt { } hook(name, fn) { + if (!name || typeof fn !== 'function') { + return + } this._hooks[name] = this._hooks[name] || [] this._hooks[name].push(fn) } @@ -73,6 +79,17 @@ export default class Nuxt { } } + addObjectHooks(hooksObj) { + Object.keys(hooksObj).forEach((name) => { + let hooks = hooksObj[name] + hooks = (Array.isArray(hooks) ? hooks : [hooks]) + + hooks.forEach((hook) => { + this.hook(name, hook) + }) + }) + } + listen(port = 3000, host = 'localhost') { return new Promise((resolve, reject) => { const server = this.renderer.app.listen({ port, host, exclusive: false }, (err) => { diff --git a/test/basic.generate.test.js b/test/basic.generate.test.js index 313203637a..dc0eb55caf 100644 --- a/test/basic.generate.test.js +++ b/test/basic.generate.test.js @@ -32,6 +32,10 @@ test.before('Init Nuxt.js', async t => { server.listen(port) }) +test('Check ready hook called', async t => { + t.true(nuxt.__hook_called__) +}) + test('/stateless', async t => { const window = await nuxt.renderAndGetWindow(url('/stateless')) const html = window.document.body.innerHTML diff --git a/test/fixtures/basic/nuxt.config.js b/test/fixtures/basic/nuxt.config.js index fb6e6734c7..ace0d54b37 100644 --- a/test/fixtures/basic/nuxt.config.js +++ b/test/fixtures/basic/nuxt.config.js @@ -6,5 +6,12 @@ module.exports = { { route: '/users/3', payload: { id: 3000 } } ], interval: 200 + }, + hooks: { + ready(nuxt) { + nuxt.__hook_called__ = true + }, + bad: null, + '': true } } From 8e9f17c491098e0c5920bb366223f8c2332b4bc8 Mon Sep 17 00:00:00 2001 From: Atinux Date: Tue, 31 Oct 2017 12:45:32 +0100 Subject: [PATCH 194/316] hooks: Await for modules:before hook --- lib/core/module.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/core/module.js b/lib/core/module.js index d55eed13f0..b5a234fc69 100755 --- a/lib/core/module.js +++ b/lib/core/module.js @@ -15,7 +15,7 @@ export default class ModuleContainer { } async ready() { - this.nuxt.callHook('modules:before', this, this.options.modules) + await this.nuxt.callHook('modules:before', this, this.options.modules) // Load every module in sequence await sequence(this.options.modules, this.addModule.bind(this)) // Call done hook From d93eb06ae9a61704f5661be38bd3b54b3991cef6 Mon Sep 17 00:00:00 2001 From: Atinux Date: Tue, 31 Oct 2017 14:16:40 +0100 Subject: [PATCH 195/316] lint: Lint files --- bin/nuxt-build | 4 ++-- bin/nuxt-dev | 7 ++++--- bin/nuxt-generate | 3 ++- bin/nuxt-start | 6 +++--- package.json | 2 +- 5 files changed, 12 insertions(+), 10 deletions(-) diff --git a/bin/nuxt-build b/bin/nuxt-build index 1d3a290e89..9222db6df2 100755 --- a/bin/nuxt-build +++ b/bin/nuxt-build @@ -1,4 +1,5 @@ #!/usr/bin/env node +/* eslint-disable no-console */ // Show logs process.env.DEBUG = process.env.DEBUG || 'nuxt:*' @@ -75,7 +76,7 @@ if (options.mode !== 'spa') { builder.build() .then(() => debug('Building done')) .catch((err) => { - console.error(err) // eslint-disable-line no-console + console.error(err) process.exit(1) }) } else { @@ -84,7 +85,6 @@ if (options.mode !== 'spa') { // Generate on spa mode new Generator(nuxt, builder).generate({ build: true }).then(() => { if (!nuxt.options.dev) { - // eslint-disable-next-line no-console console.log(`✓ You can now directly upload ${nuxt.options.generate.dir}/ or start server using "nuxt start"`) } }) diff --git a/bin/nuxt-dev b/bin/nuxt-dev index 4f827a1a58..5d0dda8be7 100755 --- a/bin/nuxt-dev +++ b/bin/nuxt-dev @@ -1,4 +1,5 @@ #!/usr/bin/env node +/* eslint-disable no-console */ // Show logs process.env.DEBUG = process.env.DEBUG || 'nuxt:*' @@ -12,7 +13,7 @@ const { Nuxt, Builder } = require('../') const chokidar = require('chokidar') const path = require('path') const resolve = path.resolve -const pkg = require(path.join('..','package.json')) +const pkg = require(path.join('..', 'package.json')) const argv = parseArgs(process.argv.slice(2), { alias: { @@ -78,7 +79,7 @@ chokidar dev = dev.then(startDev) }), 2500) -function startDev (oldNuxt) { +function startDev(oldNuxt) { // Get latest environment variables const port = argv.port || process.env.PORT || process.env.npm_package_config_nuxt_port const host = argv.hostname || process.env.HOST || process.env.npm_package_config_nuxt_host @@ -103,7 +104,7 @@ function startDev (oldNuxt) { .then(() => nuxt) // 4- Pass new nuxt to watch chain } -function loadNuxtConfig () { +function loadNuxtConfig() { let options = {} if (fs.existsSync(nuxtConfigFile)) { diff --git a/bin/nuxt-generate b/bin/nuxt-generate index d0313caa19..1d9ace2e91 100755 --- a/bin/nuxt-generate +++ b/bin/nuxt-generate @@ -1,4 +1,5 @@ #!/usr/bin/env node +/* eslint-disable no-console */ // Show logs process.env.DEBUG = process.env.DEBUG || 'nuxt:*' @@ -76,6 +77,6 @@ generator.generate(generateOptions) process.exit(0) }) .catch((err) => { - console.error(err) // eslint-disable-line no-console + console.error(err) process.exit(1) }) diff --git a/bin/nuxt-start b/bin/nuxt-start index 632bba2726..cc18b1dada 100755 --- a/bin/nuxt-start +++ b/bin/nuxt-start @@ -1,9 +1,10 @@ #!/usr/bin/env node +/* eslint-disable no-console */ const fs = require('fs') const parseArgs = require('minimist') const { Nuxt } = require('../') -const { join, resolve } = require('path') +const { resolve } = require('path') const argv = parseArgs(process.argv.slice(2), { alias: { @@ -71,7 +72,7 @@ const nuxt = new Nuxt(options) // Check if project is built for production const distDir = resolve(nuxt.options.rootDir, nuxt.options.buildDir || '.nuxt', 'dist') if (!fs.existsSync(distDir)) { - console.error('> No build files found, please run `nuxt build` before launching `nuxt start`') // eslint-disable-line no-console + console.error('> No build files found, please run `nuxt build` before launching `nuxt start`') process.exit(1) } @@ -79,7 +80,6 @@ if (!fs.existsSync(distDir)) { if (nuxt.options.render.ssr === true) { const ssrBundlePath = resolve(distDir, 'server-bundle.json') if (!fs.existsSync(ssrBundlePath)) { - // eslint-disable-next-line no-console console.error('> No SSR build! Please start with `nuxt start --spa` or build using `nuxt build --universal`') process.exit(1) } diff --git a/package.json b/package.json index d3c3d6c877..20bd9936e4 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "scripts": { "test": "npm run lint && cross-env NODE_ENV=test npm run build:nuxt && nyc ava --verbose --serial test/ -- && nyc report --reporter=html", "coverage": "nyc report --reporter=text-lcov > coverage.lcov && codecov", - "lint": "eslint --ext .js,.vue bin lib pages test/*.js --ignore-pattern app", + "lint": "eslint --ext .js,.vue bin/** lib/** test/*.js --ignore-pattern app", "build": "rimraf dist/ && npm run build:nuxt && npm run build:core", "build:nuxt": "rollup -c build/rollup.config.js --environment TARGET:nuxt", "build:core": "rollup -c build/rollup.config.js --environment TARGET:core", From b214972469eb1cd7d3addbc8634e152e4329e13a Mon Sep 17 00:00:00 2001 From: Atinux Date: Tue, 31 Oct 2017 14:16:53 +0100 Subject: [PATCH 196/316] package: Remove tappable --- start/package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/start/package.json b/start/package.json index 327cfbee58..9bb31292aa 100644 --- a/start/package.json +++ b/start/package.json @@ -51,7 +51,6 @@ "minimist": "^1.2.0", "lodash": "^4.17.4", "hash-sum": "^1.0.2", - "tappable": "^1.1.0", "debug": "^3.1.0", "chalk": "^2.3.0", "ansi-html": "^0.0.7", From b132decf9dd139a72d4605d46296ba1c614a98a0 Mon Sep 17 00:00:00 2001 From: Atinux Date: Tue, 31 Oct 2017 14:26:19 +0100 Subject: [PATCH 197/316] lint: Lint test/ --- package.json | 2 +- test/fixtures/basic/pages/async-data.vue | 2 +- test/fixtures/basic/pages/await-async-data.vue | 5 +++-- test/fixtures/basic/pages/callback-async-data.vue | 2 +- test/fixtures/basic/pages/error.vue | 2 +- test/fixtures/basic/pages/error2.vue | 2 +- test/fixtures/basic/pages/redirect.vue | 2 +- test/fixtures/basic/pages/redirect2.vue | 2 +- test/fixtures/basic/pages/special-state.vue | 2 +- test/fixtures/basic/pages/stateful.vue | 4 ++-- test/fixtures/basic/pages/users/_id.vue | 2 +- test/fixtures/basic/pages/validate.vue | 2 +- test/fixtures/basic/store/foo/bar.js | 2 +- test/fixtures/basic/store/index.js | 2 +- test/fixtures/children/pages/parent.vue | 8 ++++---- test/fixtures/children/pages/parent/_id.vue | 10 +++++----- test/fixtures/children/pages/parent/validate-child.vue | 2 +- test/fixtures/debug/pages/error.vue | 2 +- test/fixtures/module/modules/basic/index.js | 2 +- test/fixtures/module/modules/basic/reverse.js | 2 +- test/fixtures/module/modules/empty/index.js | 2 +- test/fixtures/module/modules/middleware/index.js | 4 ++-- test/fixtures/module/router.js | 2 +- test/fixtures/spa/pages/custom.vue | 6 +++--- test/fixtures/spa/pages/index.vue | 6 +++--- test/fixtures/ssr/components/test.vue | 8 ++++---- test/fixtures/ssr/pages/asyncComponent.vue | 2 +- test/fixtures/ssr/pages/asyncData.vue | 8 ++++---- test/fixtures/ssr/pages/component.vue | 6 +++--- test/fixtures/ssr/pages/data.vue | 8 ++++---- test/fixtures/ssr/pages/fetch.vue | 8 ++++---- test/fixtures/ssr/store/index.js | 4 ++-- test/fixtures/with-config/components/loading.vue | 4 ++-- test/fixtures/with-config/middleware/noop.js | 4 ++-- test/fixtures/with-config/nuxt.config.js | 4 ++-- test/fixtures/with-config/pages/env.vue | 2 +- test/fixtures/with-config/pages/error.vue | 2 +- test/fixtures/with-config/pages/user-agent.vue | 2 +- test/fixtures/with-config/store/index.js | 2 +- 39 files changed, 72 insertions(+), 71 deletions(-) diff --git a/package.json b/package.json index 20bd9936e4..058e583002 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "scripts": { "test": "npm run lint && cross-env NODE_ENV=test npm run build:nuxt && nyc ava --verbose --serial test/ -- && nyc report --reporter=html", "coverage": "nyc report --reporter=text-lcov > coverage.lcov && codecov", - "lint": "eslint --ext .js,.vue bin/** lib/** test/*.js --ignore-pattern app", + "lint": "eslint --ext .js,.vue bin/** lib/** test/** --ignore-pattern app --ignore-pattern node_modules --ignore-pattern dist/", "build": "rimraf dist/ && npm run build:nuxt && npm run build:core", "build:nuxt": "rollup -c build/rollup.config.js --environment TARGET:nuxt", "build:core": "rollup -c build/rollup.config.js --environment TARGET:core", diff --git a/test/fixtures/basic/pages/async-data.vue b/test/fixtures/basic/pages/async-data.vue index f999fb6871..752a286c18 100755 --- a/test/fixtures/basic/pages/async-data.vue +++ b/test/fixtures/basic/pages/async-data.vue @@ -4,7 +4,7 @@ diff --git a/test/fixtures/basic/pages/callback-async-data.vue b/test/fixtures/basic/pages/callback-async-data.vue index 7b0610e5ac..07481dd1fb 100644 --- a/test/fixtures/basic/pages/callback-async-data.vue +++ b/test/fixtures/basic/pages/callback-async-data.vue @@ -4,7 +4,7 @@ diff --git a/test/fixtures/children/pages/parent/_id.vue b/test/fixtures/children/pages/parent/_id.vue index 39d66d2396..8fbd0650a0 100644 --- a/test/fixtures/children/pages/parent/_id.vue +++ b/test/fixtures/children/pages/parent/_id.vue @@ -5,16 +5,16 @@ diff --git a/test/fixtures/children/pages/parent/validate-child.vue b/test/fixtures/children/pages/parent/validate-child.vue index 4fd4d4bb2d..c832cd4be0 100644 --- a/test/fixtures/children/pages/parent/validate-child.vue +++ b/test/fixtures/children/pages/parent/validate-child.vue @@ -4,7 +4,7 @@ \ No newline at end of file + diff --git a/test/fixtures/spa/pages/index.vue b/test/fixtures/spa/pages/index.vue index 54eff53255..c60926b6ac 100644 --- a/test/fixtures/spa/pages/index.vue +++ b/test/fixtures/spa/pages/index.vue @@ -4,9 +4,9 @@ \ No newline at end of file + diff --git a/test/fixtures/ssr/components/test.vue b/test/fixtures/ssr/components/test.vue index cdc10f9b6f..9a0b51634b 100644 --- a/test/fixtures/ssr/components/test.vue +++ b/test/fixtures/ssr/components/test.vue @@ -8,10 +8,10 @@ import { nextId } from '@/lib/db' export default { - data() { - return { - id: nextId() - } + data() { + return { + id: nextId() } + } } \ No newline at end of file diff --git a/test/fixtures/ssr/pages/asyncComponent.vue b/test/fixtures/ssr/pages/asyncComponent.vue index 947aa7994c..53b77b0d20 100644 --- a/test/fixtures/ssr/pages/asyncComponent.vue +++ b/test/fixtures/ssr/pages/asyncComponent.vue @@ -8,7 +8,7 @@ const AsyncTest = () => import('@/components/test.vue').then((m) => m.default || m) export default { - components:{ + components: { AsyncTest } } diff --git a/test/fixtures/ssr/pages/asyncData.vue b/test/fixtures/ssr/pages/asyncData.vue index 5f194666ed..f2883f6dc1 100644 --- a/test/fixtures/ssr/pages/asyncData.vue +++ b/test/fixtures/ssr/pages/asyncData.vue @@ -6,10 +6,10 @@ import { nextId } from '@/lib/db' export default { - async asyncData() { - return { - id: nextId() - } + async asyncData() { + return { + id: nextId() } + } } diff --git a/test/fixtures/ssr/pages/component.vue b/test/fixtures/ssr/pages/component.vue index 316ad6e5ec..3ab75cac5b 100644 --- a/test/fixtures/ssr/pages/component.vue +++ b/test/fixtures/ssr/pages/component.vue @@ -8,8 +8,8 @@ import test from '@/components/test' export default { - components : { - test - } + components: { + test + } } \ No newline at end of file diff --git a/test/fixtures/ssr/pages/data.vue b/test/fixtures/ssr/pages/data.vue index f627b7b373..fbf8c51259 100644 --- a/test/fixtures/ssr/pages/data.vue +++ b/test/fixtures/ssr/pages/data.vue @@ -6,10 +6,10 @@ import { nextId } from '@/lib/db' export default { - data() { - return { - id: nextId() - } + data() { + return { + id: nextId() } + } } diff --git a/test/fixtures/ssr/pages/fetch.vue b/test/fixtures/ssr/pages/fetch.vue index 27ed0ec8bc..6accc75c5c 100644 --- a/test/fixtures/ssr/pages/fetch.vue +++ b/test/fixtures/ssr/pages/fetch.vue @@ -6,9 +6,9 @@ import { nextId } from '@/lib/db' export default { - async fetch({store}) { - // We use store just as a shared reference - store.__id = nextId() - }, + async fetch({store}) { + // We use store just as a shared reference + store.__id = nextId() + } } diff --git a/test/fixtures/ssr/store/index.js b/test/fixtures/ssr/store/index.js index e98ccc4f5d..4e5552d398 100644 --- a/test/fixtures/ssr/store/index.js +++ b/test/fixtures/ssr/store/index.js @@ -8,13 +8,13 @@ export const state = () => { } export const mutations = { - setId2 (state, id) { + setId2(state, id) { state.id2 = id } } export const actions = { - nuxtServerInit ({ commit, state }, { route }) { + nuxtServerInit({ commit, state }, { route }) { if (route.query.onServerInit === '1') { commit('setId2', nextId()) } diff --git a/test/fixtures/with-config/components/loading.vue b/test/fixtures/with-config/components/loading.vue index 9c28022726..4cec640bfc 100644 --- a/test/fixtures/with-config/components/loading.vue +++ b/test/fixtures/with-config/components/loading.vue @@ -10,10 +10,10 @@ export default { loading: false }), methods: { - start () { + start() { this.loading = true }, - finish () { + finish() { this.loading = false } } diff --git a/test/fixtures/with-config/middleware/noop.js b/test/fixtures/with-config/middleware/noop.js index 26f7210f3d..335d554e10 100644 --- a/test/fixtures/with-config/middleware/noop.js +++ b/test/fixtures/with-config/middleware/noop.js @@ -1,3 +1,3 @@ export default function () { - // NOOP! -} \ No newline at end of file + // NOOP! +} diff --git a/test/fixtures/with-config/nuxt.config.js b/test/fixtures/with-config/nuxt.config.js index 2b60043d1c..44ec31ec13 100644 --- a/test/fixtures/with-config/nuxt.config.js +++ b/test/fixtures/with-config/nuxt.config.js @@ -3,7 +3,7 @@ module.exports = { router: { base: '/test/', middleware: 'noop', - extendRoutes (routes) { + extendRoutes(routes) { return [ ...routes, { @@ -42,7 +42,7 @@ module.exports = { analyzerMode: 'disabled', generateStatsFile: true }, - extend (config, options) { + extend(config, options) { return Object.assign({}, config, { devtool: 'nosources-source-map' }) diff --git a/test/fixtures/with-config/pages/env.vue b/test/fixtures/with-config/pages/env.vue index 5f65ca8d87..1c2dd3419e 100644 --- a/test/fixtures/with-config/pages/env.vue +++ b/test/fixtures/with-config/pages/env.vue @@ -13,7 +13,7 @@ export default { data() { return { processEnv: process.env.object } }, - asyncData ({ env }) { + asyncData({ env }) { delete env.object return { env } } diff --git a/test/fixtures/with-config/pages/error.vue b/test/fixtures/with-config/pages/error.vue index a707538cd6..d786a73ea4 100644 --- a/test/fixtures/with-config/pages/error.vue +++ b/test/fixtures/with-config/pages/error.vue @@ -4,7 +4,7 @@ diff --git a/examples/hello-world-jsx/pages/about.vue b/examples/hello-world-jsx/pages/about.vue index 7f7b2af070..26ed2649b8 100644 --- a/examples/hello-world-jsx/pages/about.vue +++ b/examples/hello-world-jsx/pages/about.vue @@ -1,11 +1,11 @@ diff --git a/examples/vue-class-component/components/Child.vue b/examples/vue-class-component/components/Child.vue index b3c5155dc0..8063fc7bc4 100644 --- a/examples/vue-class-component/components/Child.vue +++ b/examples/vue-class-component/components/Child.vue @@ -16,8 +16,8 @@ import Base from '@/components/Base' @Component export default class Child extends Base { // override parent method - greet () { - console.log('child greeting: ' + this.msg) + greet() { + console.log('child greeting: ' + this.msg) // eslint-disable-line no-console } } diff --git a/examples/vue-class-component/pages/index.vue b/examples/vue-class-component/pages/index.vue index ff468d2ed9..35e0116da2 100644 --- a/examples/vue-class-component/pages/index.vue +++ b/examples/vue-class-component/pages/index.vue @@ -11,7 +11,7 @@ import Child from '@/components/Child' components: { Child } }) export default class App extends Vue { - asyncData ({ req }) { + asyncData({ req }) { return { env: req ? 'server' : 'client' } } } diff --git a/examples/vuex-store-modules/pages/index.vue b/examples/vuex-store-modules/pages/index.vue index da3c9a4cac..33035823fc 100644 --- a/examples/vuex-store-modules/pages/index.vue +++ b/examples/vuex-store-modules/pages/index.vue @@ -23,14 +23,14 @@ import { mapState } from 'vuex' export default { // fetch(context) is called by the server-side // and before instantiating the component - fetch ({ store }) { + fetch({ store }) { store.commit('increment') }, computed: mapState([ 'counter' ]), methods: { - increment () { + increment() { this.$store.commit('increment') } } diff --git a/examples/vuex-store-modules/pages/todos.vue b/examples/vuex-store-modules/pages/todos.vue index a3aef45096..3c21b92a22 100644 --- a/examples/vuex-store-modules/pages/todos.vue +++ b/examples/vuex-store-modules/pages/todos.vue @@ -20,7 +20,7 @@ export default { todos: 'todos/todos' }), methods: { - addTodo (e) { + addTodo(e) { var text = e.target.value if (text.trim()) { this.$store.commit('todos/add', { text }) diff --git a/examples/vuex-store-modules/store/articles.js b/examples/vuex-store-modules/store/articles.js index e2fb76f674..a19b962c88 100644 --- a/examples/vuex-store-modules/store/articles.js +++ b/examples/vuex-store-modules/store/articles.js @@ -7,13 +7,13 @@ export const state = () => ({ }) export const mutations = { - add (state, title) { + add(state, title) { state.list.push(title) } } export const getters = { - get (state) { + get(state) { return state.list } } diff --git a/examples/vuex-store-modules/store/articles/comments.js b/examples/vuex-store-modules/store/articles/comments.js index dd7f3c47c0..4092086eee 100644 --- a/examples/vuex-store-modules/store/articles/comments.js +++ b/examples/vuex-store-modules/store/articles/comments.js @@ -7,13 +7,13 @@ export const state = () => ({ }) export const mutations = { - add (state, title) { + add(state, title) { state.list.push(title) } } export const getters = { - get (state) { + get(state) { return state.list } } diff --git a/examples/vuex-store-modules/store/index.js b/examples/vuex-store-modules/store/index.js index 63f1975bf2..b22221c9c7 100644 --- a/examples/vuex-store-modules/store/index.js +++ b/examples/vuex-store-modules/store/index.js @@ -3,7 +3,7 @@ export const state = () => ({ }) export const mutations = { - increment (state) { + increment(state) { state.counter++ } } diff --git a/examples/vuex-store-modules/store/todos.js b/examples/vuex-store-modules/store/todos.js index 5063cbd1b8..f482ec1242 100644 --- a/examples/vuex-store-modules/store/todos.js +++ b/examples/vuex-store-modules/store/todos.js @@ -3,20 +3,20 @@ export const state = () => ({ }) export const mutations = { - add (state, { text }) { + add(state, { text }) { state.list.push({ text, done: false }) }, - toggle (state, todo) { + toggle(state, todo) { todo.done = !todo.done } } export const getters = { - todos (state) { + todos(state) { return state.list } } diff --git a/examples/vuex-store/pages/index.vue b/examples/vuex-store/pages/index.vue index 0e9a15da3c..7406a84dd8 100644 --- a/examples/vuex-store/pages/index.vue +++ b/examples/vuex-store/pages/index.vue @@ -13,14 +13,14 @@ import { mapState } from 'vuex' export default { // fetch(context) is called by the server-side // and nuxt before instantiating the component - fetch ({ store }) { + fetch({ store }) { store.commit('increment') }, computed: mapState([ 'counter' ]), methods: { - increment () { + increment() { this.$store.commit('increment') } } diff --git a/examples/vuex-store/store/mutations.js b/examples/vuex-store/store/mutations.js index e85cce517e..81783007a1 100644 --- a/examples/vuex-store/store/mutations.js +++ b/examples/vuex-store/store/mutations.js @@ -1,7 +1,7 @@ const mutations = { - increment (state) { - state.counter++ - } + increment(state) { + state.counter++ + } } -export default mutations \ No newline at end of file +export default mutations diff --git a/examples/with-ava/pages/index.vue b/examples/with-ava/pages/index.vue index a3d80ae170..b411fa4762 100755 --- a/examples/with-ava/pages/index.vue +++ b/examples/with-ava/pages/index.vue @@ -4,7 +4,7 @@ diff --git a/examples/with-museui/plugins/museui.js b/examples/with-museui/plugins/museui.js index ae071085bb..623286c123 100644 --- a/examples/with-museui/plugins/museui.js +++ b/examples/with-museui/plugins/museui.js @@ -1,4 +1,4 @@ -import Vue from 'vue'; -import MuseUI from 'muse-ui'; +import Vue from 'vue' +import MuseUI from 'muse-ui' -Vue.use(MuseUI); +Vue.use(MuseUI) diff --git a/examples/with-sockets/pages/index.vue b/examples/with-sockets/pages/index.vue index 1e2fb24700..7184116d06 100644 --- a/examples/with-sockets/pages/index.vue +++ b/examples/with-sockets/pages/index.vue @@ -17,7 +17,7 @@ import socket from '~/plugins/socket.io.js' export default { - asyncData (context, callback) { + asyncData(context, callback) { socket.emit('last-messages', function (messages) { callback(null, { messages, @@ -28,16 +28,16 @@ export default { watch: { 'messages': 'scrollToBottom' }, - beforeMount () { + beforeMount() { socket.on('new-message', (message) => { this.messages.push(message) }) }, - mounted () { + mounted() { this.scrollToBottom() }, methods: { - sendMessage () { + sendMessage() { if (!this.message.trim()) return let message = { date: new Date().toJSON(), @@ -47,7 +47,7 @@ export default { this.message = '' socket.emit('send-message', message) }, - scrollToBottom () { + scrollToBottom() { this.$nextTick(() => { this.$refs.messages.scrollTop = this.$refs.messages.scrollHeight }) diff --git a/examples/with-tape/pages/index.vue b/examples/with-tape/pages/index.vue index 1ceb0086e2..b66e85f73e 100755 --- a/examples/with-tape/pages/index.vue +++ b/examples/with-tape/pages/index.vue @@ -7,14 +7,14 @@ diff --git a/examples/with-tape/test/index.test.js b/examples/with-tape/test/index.test.js index f586b68538..7d46c3d11e 100755 --- a/examples/with-tape/test/index.test.js +++ b/examples/with-tape/test/index.test.js @@ -3,41 +3,41 @@ import { shallow } from 'vue-test-utils' import Index from '../pages/index.vue' test('renders Index.vue correctly', t => { - t.plan(4) + t.plan(4) - const wrapper = shallow(Index, { - data: { - name: 'nuxt' - } - }) + const wrapper = shallow(Index, { + data: { + name: 'nuxt' + } + }) - const button = wrapper.find('button') + const button = wrapper.find('button') - t.equal( - wrapper.find('h1').text(), - 'Hello nuxt!', - 'renders "Hello nuxt!" text' - ) + t.equal( + wrapper.find('h1').text(), + 'Hello nuxt!', + 'renders "Hello nuxt!" text' + ) - t.equal( - wrapper.find('h1').hasClass('red'), - true, - 'h1 has a red class [default]' - ) + t.equal( + wrapper.find('h1').hasClass('red'), + true, + 'h1 has a red class [default]' + ) - button.trigger('click') + button.trigger('click') - t.equal( - wrapper.find('h1').hasClass('blue'), - true, - 'h1 class changes to blue [after 1st click]' - ) + t.equal( + wrapper.find('h1').hasClass('blue'), + true, + 'h1 class changes to blue [after 1st click]' + ) - button.trigger('click') + button.trigger('click') - t.equal( - wrapper.find('h1').hasClass('green'), - true, - 'h1 class changes to green [after 2nd click]' - ) + t.equal( + wrapper.find('h1').hasClass('green'), + true, + 'h1 class changes to green [after 2nd click]' + ) }) diff --git a/examples/with-tape/test/setup.js b/examples/with-tape/test/setup.js index 2e41fab524..69cf3aa353 100644 --- a/examples/with-tape/test/setup.js +++ b/examples/with-tape/test/setup.js @@ -5,10 +5,10 @@ require('browser-env')() // Setup vue files to be processed by `require-extension-hooks-vue` hooks('vue') - .plugin('vue') - .push() + .plugin('vue') + .push() // Setup vue and js files to be processed by `require-extension-hooks-babel` hooks(['vue', 'js']) - .plugin('babel') - .push() + .plugin('babel') + .push() diff --git a/examples/with-vuetify/nuxt.config.js b/examples/with-vuetify/nuxt.config.js index c1fc371f7a..df74955493 100644 --- a/examples/with-vuetify/nuxt.config.js +++ b/examples/with-vuetify/nuxt.config.js @@ -1,6 +1,3 @@ - -const { join } = require('path') - module.exports = { /* ** Head elements diff --git a/package.json b/package.json index 058e583002..8135fa0469 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "scripts": { "test": "npm run lint && cross-env NODE_ENV=test npm run build:nuxt && nyc ava --verbose --serial test/ -- && nyc report --reporter=html", "coverage": "nyc report --reporter=text-lcov > coverage.lcov && codecov", - "lint": "eslint --ext .js,.vue bin/** lib/** test/** --ignore-pattern app --ignore-pattern node_modules --ignore-pattern dist/", + "lint": "eslint --ext .js,.vue bin/** lib/** test/*.js examples/**", "build": "rimraf dist/ && npm run build:nuxt && npm run build:core", "build:nuxt": "rollup -c build/rollup.config.js --environment TARGET:nuxt", "build:core": "rollup -c build/rollup.config.js --environment TARGET:core", From 64285cd3498c84fe827b2ae36c1419b732bad26d Mon Sep 17 00:00:00 2001 From: Atinux Date: Tue, 31 Oct 2017 15:02:49 +0100 Subject: [PATCH 199/316] fix: Fix lint script --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8135fa0469..2107472b52 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "scripts": { "test": "npm run lint && cross-env NODE_ENV=test npm run build:nuxt && nyc ava --verbose --serial test/ -- && nyc report --reporter=html", "coverage": "nyc report --reporter=text-lcov > coverage.lcov && codecov", - "lint": "eslint --ext .js,.vue bin/** lib/** test/*.js examples/**", + "lint": "eslint --ext .js,.vue bin/ lib/ test/ examples/", "build": "rimraf dist/ && npm run build:nuxt && npm run build:core", "build:nuxt": "rollup -c build/rollup.config.js --environment TARGET:nuxt", "build:core": "rollup -c build/rollup.config.js --environment TARGET:core", From 76aca28cdc53ae7fccb7e4aaa3e1de7f2bc18381 Mon Sep 17 00:00:00 2001 From: Atinux Date: Tue, 31 Oct 2017 18:32:42 +0100 Subject: [PATCH 200/316] fix: Fix context undefined --- lib/app/client.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/app/client.js b/lib/app/client.js index 63e22c585e..c2da03ceb1 100644 --- a/lib/app/client.js +++ b/lib/app/client.js @@ -203,8 +203,8 @@ async function render (to, from, next) { if (app.context._redirected) return // Load layout for error page const layout = await this.loadLayout(typeof NuxtError.layout === 'function' ? NuxtError.layout(app.context) : NuxtError.layout) - await callMiddleware.call(this, Components, context, layout) - if (context._redirected) return + await callMiddleware.call(this, Components, app.context, layout) + if (app.context._redirected) return // Show error page app.context.error({ statusCode: 404, message: '<%= messages.error_404 %>' }) return next() From 8318ce75101d707b7a9d30a059387ded72bed629 Mon Sep 17 00:00:00 2001 From: Atinux Date: Tue, 31 Oct 2017 18:33:25 +0100 Subject: [PATCH 201/316] fix: loadResources after every build --- lib/builder/builder.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/builder/builder.js b/lib/builder/builder.js index 1dbef90a59..b5a51aee9b 100644 --- a/lib/builder/builder.js +++ b/lib/builder/builder.js @@ -435,6 +435,9 @@ export default class Builder { // Resolve only when compiler emit done event compiler.plugin('done', async (stats) => { await this.nuxt.callHook('build:compiled', { name, compiler, stats }) + // Reload renderer if available + this.nuxt.renderer.loadResources(sharedFS || fs) + // Resolve on next tick process.nextTick(resolve) }) // --- Dev Build --- @@ -475,10 +478,6 @@ export default class Builder { } }) })) - // Reload renderer if available - if (this.nuxt.renderer) { - this.nuxt.renderer.loadResources(sharedFS || fs) - } } webpackDev(compiler) { From dc7d4bfab7e04a295a0e59f52dd7d45216034b49 Mon Sep 17 00:00:00 2001 From: Atinux Date: Tue, 31 Oct 2017 18:33:46 +0100 Subject: [PATCH 202/316] test: Add children fixPrepatch example --- test/fixtures/children/layouts/patch.vue | 13 +++++++++++++ test/fixtures/children/pages/patch.vue | 17 +++++++++++++++++ test/fixtures/children/pages/patch/_id.vue | 16 ++++++++++++++++ .../fixtures/children/pages/patch/_id/child.vue | 16 ++++++++++++++++ .../children/pages/patch/_id/child/_slug.vue | 13 +++++++++++++ .../fixtures/children/pages/patch/_id/index.vue | 3 +++ test/fixtures/children/pages/patch/index.vue | 3 +++ 7 files changed, 81 insertions(+) create mode 100644 test/fixtures/children/layouts/patch.vue create mode 100644 test/fixtures/children/pages/patch.vue create mode 100644 test/fixtures/children/pages/patch/_id.vue create mode 100644 test/fixtures/children/pages/patch/_id/child.vue create mode 100644 test/fixtures/children/pages/patch/_id/child/_slug.vue create mode 100644 test/fixtures/children/pages/patch/_id/index.vue create mode 100644 test/fixtures/children/pages/patch/index.vue diff --git a/test/fixtures/children/layouts/patch.vue b/test/fixtures/children/layouts/patch.vue new file mode 100644 index 0000000000..3fa8ff94b8 --- /dev/null +++ b/test/fixtures/children/layouts/patch.vue @@ -0,0 +1,13 @@ + diff --git a/test/fixtures/children/pages/patch.vue b/test/fixtures/children/pages/patch.vue new file mode 100644 index 0000000000..0c56e113b2 --- /dev/null +++ b/test/fixtures/children/pages/patch.vue @@ -0,0 +1,17 @@ + + + diff --git a/test/fixtures/children/pages/patch/_id.vue b/test/fixtures/children/pages/patch/_id.vue new file mode 100644 index 0000000000..4f83f42169 --- /dev/null +++ b/test/fixtures/children/pages/patch/_id.vue @@ -0,0 +1,16 @@ + + + diff --git a/test/fixtures/children/pages/patch/_id/child.vue b/test/fixtures/children/pages/patch/_id/child.vue new file mode 100644 index 0000000000..8e0c0d02d0 --- /dev/null +++ b/test/fixtures/children/pages/patch/_id/child.vue @@ -0,0 +1,16 @@ + + + diff --git a/test/fixtures/children/pages/patch/_id/child/_slug.vue b/test/fixtures/children/pages/patch/_id/child/_slug.vue new file mode 100644 index 0000000000..ed5491dfc1 --- /dev/null +++ b/test/fixtures/children/pages/patch/_id/child/_slug.vue @@ -0,0 +1,13 @@ + + + diff --git a/test/fixtures/children/pages/patch/_id/index.vue b/test/fixtures/children/pages/patch/_id/index.vue new file mode 100644 index 0000000000..d86b9896cf --- /dev/null +++ b/test/fixtures/children/pages/patch/_id/index.vue @@ -0,0 +1,3 @@ + diff --git a/test/fixtures/children/pages/patch/index.vue b/test/fixtures/children/pages/patch/index.vue new file mode 100644 index 0000000000..5d848671f3 --- /dev/null +++ b/test/fixtures/children/pages/patch/index.vue @@ -0,0 +1,3 @@ + From 2c8023bde997209031c13525f4aab2aa786ccf17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Chopin?= Date: Wed, 1 Nov 2017 16:44:27 +0100 Subject: [PATCH 203/316] tests: Add more tests with dom testing --- test/basic.dom.test.js | 35 +++----- test/children.path.test.js | 80 +++++++++++++++++++ test/fixtures/children/layouts/patch.vue | 2 + test/fixtures/children/pages/patch.vue | 2 +- test/fixtures/children/pages/patch/_id.vue | 2 +- .../children/pages/patch/_id/child/_slug.vue | 45 ++++++++++- test/helpers/browser.js | 41 ++++++++++ 7 files changed, 179 insertions(+), 28 deletions(-) create mode 100644 test/children.path.test.js create mode 100644 test/helpers/browser.js diff --git a/test/basic.dom.test.js b/test/basic.dom.test.js index 9e3b881a67..6a3198e134 100644 --- a/test/basic.dom.test.js +++ b/test/basic.dom.test.js @@ -1,20 +1,12 @@ import test from 'ava' import { resolve } from 'path' -import puppeteer from 'puppeteer' -import { Nuxt, Builder } from '../index.js' +import { Nuxt, Builder } from '../index' +import * as browser from './helpers/browser' const port = 4003 const url = (route) => 'http://localhost:' + port + route let nuxt = null -let browser -const open = async (path) => { - const page = await browser.newPage() - await page.goto(url(path)) - await page.waitForFunction('!!window.$nuxt') - page.html = () => page.evaluate(() => window.document.documentElement.outerHTML) - return page -} // Init nuxt.js and create server listening on localhost:4003 test.before('Init Nuxt.js', async t => { @@ -33,34 +25,30 @@ test.before('Init Nuxt.js', async t => { await nuxt.listen(port, 'localhost') }) -test.before('Start Puppeteer', async t => { - // https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#puppeteerlaunchoptions - browser = await puppeteer.launch({ - args: ['--no-sandbox', '--disable-setuid-sandbox'] - }) +test.before('Start browser', async t => { + await browser.start() }) test('/stateless', async t => { - const page = await open('/stateless') - const h1 = await page.$eval('h1', (h1) => h1.textContent) - const loading = await page.evaluate(() => window.$nuxt.$loading.$data) + const page = await browser.page(url('/stateless')) + const loading = await page.nuxt.loadingData() t.is(await page.title(), 'Nuxt.js') - t.is(h1, 'My component!') + t.is(await page.$text('h1'), 'My component!') t.is(loading.show, false) t.is(loading.percent, 0) await page.close() }) test('/css', async t => { - const page = await open('/css') + const page = await browser.page(url('/css')) t.is(await page.$eval('.red', (red) => red.textContent), 'This is red') t.is(await page.$eval('.red', (red) => window.getComputedStyle(red).color), 'rgb(255, 0, 0)') await page.close() }) test('/stateful', async t => { - const page = await open('/stateful') + const page = await browser.page(url('/stateful')) const html = await page.html() t.true(html.includes('

The answer is 42

')) await page.close() @@ -207,7 +195,6 @@ test.after('Closing server and nuxt.js', t => { nuxt.close() }) -test.after('Close Puppeteer', async t => { - await browser.close() - browser = null +test.after('Stop browser', async t => { + await browser.stop() }) diff --git a/test/children.path.test.js b/test/children.path.test.js new file mode 100644 index 0000000000..fcdc2d90d5 --- /dev/null +++ b/test/children.path.test.js @@ -0,0 +1,80 @@ +import test from 'ava' +import { resolve } from 'path' +import { Nuxt, Builder } from '../index.js' +import * as browser from './helpers/browser' + +const port = 4005 +const url = (route) => 'http://localhost:' + port + route + +let nuxt = null + +// Init nuxt.js and create server listening on localhost:4000 +test.before('Init Nuxt.js', async t => { + const options = { + rootDir: resolve(__dirname, 'fixtures/children'), + dev: false + } + nuxt = new Nuxt(options) + await new Builder(nuxt).build() + + await nuxt.listen(port, 'localhost') +}) +test.before('Start browser', async t => { + await browser.start() +}) + +let page +const dates = {} + +test('Loading /patch and keep ', async t => { + page = await browser.page(url('/patch')) + + const h1 = await page.$text('h1') + t.true(h1.includes('patch:')) + const h2 = await page.$text('h2') + t.is(h2, 'Index') + dates.patch = await page.$text('[data-date-patch]') +}) + +test('Navigate to /patch/1', async t => { + await page.nuxt.navigate('/patch/1') + const loading = await page.nuxt.loadingData() + t.is(loading.show, true) + await page.nuxt.waitForNavigation() + + const h2 = await page.$text('h2') + t.true(h2.includes('_id:')) + dates.id = await page.$text('[data-date-id]') + + t.is(dates.patch, await page.$text('[data-date-patch]')) +}) + +test('Navigate to /patch/2', async t => { + await page.nuxt.navigate('/patch/2', true) + const date = await page.$text('[data-date-id]') + + t.is(dates.patch, await page.$text('[data-date-patch]')) + t.true(+dates.id < +date) + dates.id = date +}) + +test('Navigate to /patch/2?test=true', async t => { + await page.nuxt.navigate('/patch/2?test=true', true) + t.is(dates.patch, await page.$text('[data-date-patch]')) + t.is(dates.id, await page.$text('[data-date-id]')) +}) + +test('Navigate to /patch/2#test', async t => { + await page.nuxt.navigate('/patch/2#test', true) + t.is(dates.patch, await page.$text('[data-date-patch]')) + t.is(dates.id, await page.$text('[data-date-id]')) +}) + +// Close server and ask nuxt to stop listening to file changes +test.after('Closing server and nuxt.js', t => { + nuxt.close() +}) +test.after('Stop browser', async t => { + await page.close() + await browser.stop() +}) diff --git a/test/fixtures/children/layouts/patch.vue b/test/fixtures/children/layouts/patch.vue index 3fa8ff94b8..4900a5be00 100644 --- a/test/fixtures/children/layouts/patch.vue +++ b/test/fixtures/children/layouts/patch.vue @@ -5,9 +5,11 @@
  • /patch
  • /patch/1
  • /patch/2
  • +
  • /patch/2#test
  • /patch/2/child
  • /patch/2/child/1
  • /patch/2/child/1?query=true
  • +
  • /patch/2/child/1?query=true#test
  • diff --git a/test/fixtures/children/pages/patch.vue b/test/fixtures/children/pages/patch.vue index 0c56e113b2..c4cfa21c6f 100644 --- a/test/fixtures/children/pages/patch.vue +++ b/test/fixtures/children/pages/patch.vue @@ -1,6 +1,6 @@ diff --git a/test/fixtures/children/pages/patch/_id.vue b/test/fixtures/children/pages/patch/_id.vue index 4f83f42169..dc5940e40c 100644 --- a/test/fixtures/children/pages/patch/_id.vue +++ b/test/fixtures/children/pages/patch/_id.vue @@ -1,6 +1,6 @@ diff --git a/test/fixtures/children/pages/patch/_id/child/_slug.vue b/test/fixtures/children/pages/patch/_id/child/_slug.vue index ed5491dfc1..c82d3aa74d 100644 --- a/test/fixtures/children/pages/patch/_id/child/_slug.vue +++ b/test/fixtures/children/pages/patch/_id/child/_slug.vue @@ -1,13 +1,54 @@ diff --git a/test/helpers/browser.js b/test/helpers/browser.js new file mode 100644 index 0000000000..168a0809c5 --- /dev/null +++ b/test/helpers/browser.js @@ -0,0 +1,41 @@ +import puppeteer from 'puppeteer' + +let browser = null + +export async function start() { + // https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#puppeteerlaunchoptions + browser = await puppeteer.launch({ + args: ['--no-sandbox', '--disable-setuid-sandbox'] + }) +} + +export async function stop() { + if (!browser) return + await browser.close() +} + +export async function page(url) { + if (!browser) throw new Error('Please call start() before page(url)') + const page = await browser.newPage() + await page.goto(url) + await page.waitForFunction('!!window.$nuxt') + page.html = () => page.evaluate(() => window.document.documentElement.outerHTML) + page.$text = (selector) => page.$eval(selector, (el) => el.textContent) + page.$nuxt = await page.evaluateHandle('window.$nuxt') + + page.nuxt = { + async navigate(path, wait = false) { + await page.evaluate(($nuxt, path) => $nuxt.$router.push(path), page.$nuxt, path) + if (wait) { + await this.waitForNavigation() + } + }, + loadingData() { + return page.evaluate(($nuxt) => $nuxt.$loading.$data, page.$nuxt) + }, + waitForNavigation() { + return page.waitForFunction('window.$nuxt.$loading.$data.show === false') + } + } + return page +} From 6e44afedb82219b1db892b1f09986b0afcda8191 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Chopin?= Date: Wed, 1 Nov 2017 16:44:57 +0100 Subject: [PATCH 204/316] router: Don't call middleware and asyncData on query changes --- lib/app/client.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/lib/app/client.js b/lib/app/client.js index c2da03ceb1..c6638e5a68 100644 --- a/lib/app/client.js +++ b/lib/app/client.js @@ -97,13 +97,11 @@ function mapTransitions(Components, to, from) { } async function loadAsyncComponents (to, from, next) { - // Check if route hash changed (this._hashChanged) - const fromPath = from.fullPath.split('#')[0] - const toPath = to.fullPath.split('#')[0] - this._hashChanged = fromPath === toPath + // Check if route path changed (this._pathChanged) + this._pathChanged = from.path !== to.path <% if (loading) { %> - if (!this._hashChanged && this.$loading.start) { + if (this._pathChanged && this.$loading.start) { this.$loading.start() } <% } %> @@ -173,7 +171,7 @@ function callMiddleware (Components, context, layout) { } async function render (to, from, next) { - if (this._hashChanged) return next() + if (this._pathChanged === false) return next() // nextCalled is true when redirected let nextCalled = false @@ -258,7 +256,7 @@ async function render (to, from, next) { await Promise.all(Components.map((Component, i) => { // Check if only children route changed Component._path = compile(to.matched[i].path)(to.params) - if (!this._hadError && this._isMounted && Component._path === _lastPaths[i] && (i + 1) !== Components.length) { + if (!this._hadError && this._isMounted && Component._path === _lastPaths[i]) { return Promise.resolve() } @@ -347,7 +345,7 @@ function showNextPage(to) { // When navigating on a different route but the same component is used, Vue.js // Will not update the instance data, so we have to update $data ourselves function fixPrepatch (to, from) { - if (this._hashChanged) return + if (this._pathChanged === false) return Vue.nextTick(() => { const instances = getChangedComponentsInstances(to, from) From 4c90888e155962f4beb55cbeca93d8bf833fdb88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Chopin?= Date: Thu, 2 Nov 2017 12:31:48 +0100 Subject: [PATCH 205/316] Update roadmap link --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 41b4ef402c..3b27ba6ea3 100644 --- a/README.md +++ b/README.md @@ -251,7 +251,7 @@ Note: we recommend putting `.nuxt` in `.npmignore` or `.gitignore`. ## Roadmap -https://github.com/nuxt/nuxt.js/projects/1 +https://trello.com/b/lgy93IOl/nuxtjs-10 ## Contributing Please see our [CONTRIBUTING.md](./CONTRIBUTING.md) From 8015a29d313bb6de3ca98598b1f3443830ac44db Mon Sep 17 00:00:00 2001 From: Atinux Date: Thu, 2 Nov 2017 14:23:46 +0100 Subject: [PATCH 206/316] package: Upgrade dependencies --- package.json | 16 ++++++++-------- yarn.lock | 37 ++++++++++++++++++++++++------------- 2 files changed, 32 insertions(+), 21 deletions(-) diff --git a/package.json b/package.json index 2107472b52..ced6834a43 100644 --- a/package.json +++ b/package.json @@ -115,7 +115,7 @@ "vue-router": "^3.0.1", "vue-server-renderer": "^2.5.2", "vue-template-compiler": "^2.5.2", - "vuex": "^3.0.0", + "vuex": "^3.0.1", "webpack": "^3.8.1", "webpack-bundle-analyzer": "^2.9.0", "webpack-dev-middleware": "^1.12.0", @@ -129,20 +129,20 @@ "babel-plugin-external-helpers": "^6.22.0", "babel-plugin-istanbul": "^4.1.5", "codecov": "^3.0.0", - "copy-webpack-plugin": "^4.1.1", - "cross-env": "^5.1.0", - "eslint": "^4.9.0", + "copy-webpack-plugin": "^4.2.0", + "cross-env": "^5.1.1", + "eslint": "^4.10.0", "eslint-config-standard": "^10.2.1", "eslint-plugin-html": "^3.2.2", "eslint-plugin-import": "^2.8.0", - "eslint-plugin-node": "^5.2.0", + "eslint-plugin-node": "^5.2.1", "eslint-plugin-promise": "^3.6.0", "eslint-plugin-standard": "^3.0.1", "express": "^4.16.2", "finalhandler": "^1.1.0", "jsdom": "^11.3.0", "json-loader": "^0.5.7", - "nyc": "^11.2.1", + "nyc": "^11.3.0", "puppeteer": "^0.12.0", "request": "^2.83.0", "request-promise-native": "^1.0.5", @@ -150,12 +150,12 @@ "rollup": "^0.50.0", "rollup-plugin-alias": "^1.4.0", "rollup-plugin-babel": "^3.0.2", - "rollup-plugin-commonjs": "^8.2.1", + "rollup-plugin-commonjs": "^8.2.6", "rollup-plugin-node-resolve": "^3.0.0", "rollup-plugin-replace": "^2.0.0", "rollup-watch": "^4.3.1", "std-mocks": "^1.0.1", - "uglify-js": "^3.1.4" + "uglify-js": "^3.1.6" }, "collective": { "type": "opencollective", diff --git a/yarn.lock b/yarn.lock index f36ff3232c..a950b8b34a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -101,6 +101,10 @@ acorn@^5.0.0, acorn@^5.1.1, acorn@^5.1.2: version "5.1.2" resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.1.2.tgz#911cb53e036807cf0fa778dc5d370fbd864246d7" +acorn@^5.2.1: + version "5.2.1" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.2.1.tgz#317ac7821826c22c702d66189ab8359675f135d7" + agent-base@^4.1.0: version "4.1.1" resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-4.1.1.tgz#92d8a4fc2524a3b09b3666a33b6c97960f23d6a4" @@ -1786,7 +1790,7 @@ copy-concurrently@^1.0.0: rimraf "^2.5.4" run-queue "^1.0.0" -copy-webpack-plugin@^4.1.1: +copy-webpack-plugin@^4.2.0: version "4.2.0" resolved "https://registry.yarnpkg.com/copy-webpack-plugin/-/copy-webpack-plugin-4.2.0.tgz#252bb94597f96399d23d7fad355f8d3a661ac096" dependencies: @@ -1859,7 +1863,7 @@ create-hmac@^1.1.0, create-hmac@^1.1.2, create-hmac@^1.1.4: safe-buffer "^5.0.1" sha.js "^2.4.8" -cross-env@^5.1.0: +cross-env@^5.1.1: version "5.1.1" resolved "https://registry.yarnpkg.com/cross-env/-/cross-env-5.1.1.tgz#b6d8ab97f304c0f71dae7277b75fe424c08dfa74" dependencies: @@ -2507,7 +2511,7 @@ eslint-plugin-import@^2.8.0: minimatch "^3.0.3" read-pkg-up "^2.0.0" -eslint-plugin-node@^5.2.0: +eslint-plugin-node@^5.2.1: version "5.2.1" resolved "https://registry.yarnpkg.com/eslint-plugin-node/-/eslint-plugin-node-5.2.1.tgz#80df3253c4d7901045ec87fa660a284e32bdca29" dependencies: @@ -2531,7 +2535,7 @@ eslint-scope@^3.7.1: esrecurse "^4.1.0" estraverse "^4.1.1" -eslint@^4.9.0: +eslint@^4.10.0: version "4.10.0" resolved "https://registry.yarnpkg.com/eslint/-/eslint-4.10.0.tgz#f25d0d7955c81968c2309aa5c9a229e045176bb7" dependencies: @@ -4491,7 +4495,7 @@ nwmatcher@^1.4.1: version "1.4.3" resolved "https://registry.yarnpkg.com/nwmatcher/-/nwmatcher-1.4.3.tgz#64348e3b3d80f035b40ac11563d278f8b72db89c" -nyc@^11.2.1: +nyc@^11.3.0: version "11.3.0" resolved "https://registry.yarnpkg.com/nyc/-/nyc-11.3.0.tgz#a42bc17b3cfa41f7b15eb602bc98b2633ddd76f0" dependencies: @@ -5990,11 +5994,11 @@ rollup-plugin-babel@^3.0.2: dependencies: rollup-pluginutils "^1.5.0" -rollup-plugin-commonjs@^8.2.1: - version "8.2.5" - resolved "https://registry.yarnpkg.com/rollup-plugin-commonjs/-/rollup-plugin-commonjs-8.2.5.tgz#924421278a6f879fd976b2ef1a28391b1e4f2a6e" +rollup-plugin-commonjs@^8.2.6: + version "8.2.6" + resolved "https://registry.yarnpkg.com/rollup-plugin-commonjs/-/rollup-plugin-commonjs-8.2.6.tgz#27e5b9069ff94005bb01e01bb46a1e4873784677" dependencies: - acorn "^5.1.2" + acorn "^5.2.1" estree-walker "^0.5.0" magic-string "^0.22.4" resolve "^1.4.0" @@ -6659,7 +6663,7 @@ uglify-es@^3.1.3: commander "~2.11.0" source-map "~0.6.1" -uglify-js@3.1.x, uglify-js@^3.1.4: +uglify-js@3.1.x: version "3.1.5" resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.1.5.tgz#4c1a6d53b2fe77e4710dd94631853effd3ff5143" dependencies: @@ -6675,6 +6679,13 @@ uglify-js@^2.6, uglify-js@^2.8.29: optionalDependencies: uglify-to-browserify "~1.0.0" +uglify-js@^3.1.6: + version "3.1.6" + resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.1.6.tgz#918832602036e95d2318e11f27ee8461a8592c5d" + dependencies: + commander "~2.11.0" + source-map "~0.6.1" + uglify-to-browserify@~1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/uglify-to-browserify/-/uglify-to-browserify-1.0.2.tgz#6e0924d6bda6b5afe349e39a6d632850a0f882b7" @@ -6945,9 +6956,9 @@ vue@^2.5.2: version "2.5.2" resolved "https://registry.yarnpkg.com/vue/-/vue-2.5.2.tgz#fd367a87bae7535e47f9dc5c9ec3b496e5feb5a4" -vuex@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/vuex/-/vuex-3.0.0.tgz#98b4b5c4954b1c1c1f5b29fa0476a23580315814" +vuex@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/vuex/-/vuex-3.0.1.tgz#e761352ebe0af537d4bb755a9b9dc4be3df7efd2" watchpack@^1.4.0: version "1.4.0" From c533ff9c46b0369da7918a0d4e301af99e60c9b3 Mon Sep 17 00:00:00 2001 From: Atinux Date: Thu, 2 Nov 2017 14:24:20 +0100 Subject: [PATCH 207/316] tests: Add more feature to browser helpers --- test/children.path.test.js | 80 -------------------------------------- test/helpers/browser.js | 15 +++++-- 2 files changed, 12 insertions(+), 83 deletions(-) delete mode 100644 test/children.path.test.js diff --git a/test/children.path.test.js b/test/children.path.test.js deleted file mode 100644 index fcdc2d90d5..0000000000 --- a/test/children.path.test.js +++ /dev/null @@ -1,80 +0,0 @@ -import test from 'ava' -import { resolve } from 'path' -import { Nuxt, Builder } from '../index.js' -import * as browser from './helpers/browser' - -const port = 4005 -const url = (route) => 'http://localhost:' + port + route - -let nuxt = null - -// Init nuxt.js and create server listening on localhost:4000 -test.before('Init Nuxt.js', async t => { - const options = { - rootDir: resolve(__dirname, 'fixtures/children'), - dev: false - } - nuxt = new Nuxt(options) - await new Builder(nuxt).build() - - await nuxt.listen(port, 'localhost') -}) -test.before('Start browser', async t => { - await browser.start() -}) - -let page -const dates = {} - -test('Loading /patch and keep ', async t => { - page = await browser.page(url('/patch')) - - const h1 = await page.$text('h1') - t.true(h1.includes('patch:')) - const h2 = await page.$text('h2') - t.is(h2, 'Index') - dates.patch = await page.$text('[data-date-patch]') -}) - -test('Navigate to /patch/1', async t => { - await page.nuxt.navigate('/patch/1') - const loading = await page.nuxt.loadingData() - t.is(loading.show, true) - await page.nuxt.waitForNavigation() - - const h2 = await page.$text('h2') - t.true(h2.includes('_id:')) - dates.id = await page.$text('[data-date-id]') - - t.is(dates.patch, await page.$text('[data-date-patch]')) -}) - -test('Navigate to /patch/2', async t => { - await page.nuxt.navigate('/patch/2', true) - const date = await page.$text('[data-date-id]') - - t.is(dates.patch, await page.$text('[data-date-patch]')) - t.true(+dates.id < +date) - dates.id = date -}) - -test('Navigate to /patch/2?test=true', async t => { - await page.nuxt.navigate('/patch/2?test=true', true) - t.is(dates.patch, await page.$text('[data-date-patch]')) - t.is(dates.id, await page.$text('[data-date-id]')) -}) - -test('Navigate to /patch/2#test', async t => { - await page.nuxt.navigate('/patch/2#test', true) - t.is(dates.patch, await page.$text('[data-date-patch]')) - t.is(dates.id, await page.$text('[data-date-id]')) -}) - -// Close server and ask nuxt to stop listening to file changes -test.after('Closing server and nuxt.js', t => { - nuxt.close() -}) -test.after('Stop browser', async t => { - await page.close() - await browser.stop() -}) diff --git a/test/helpers/browser.js b/test/helpers/browser.js index 168a0809c5..f3cba4715c 100644 --- a/test/helpers/browser.js +++ b/test/helpers/browser.js @@ -2,11 +2,11 @@ import puppeteer from 'puppeteer' let browser = null -export async function start() { +export async function start(options = {}) { // https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#puppeteerlaunchoptions - browser = await puppeteer.launch({ + browser = await puppeteer.launch(Object.assign({ args: ['--no-sandbox', '--disable-setuid-sandbox'] - }) + }, options)) } export async function stop() { @@ -21,6 +21,7 @@ export async function page(url) { await page.waitForFunction('!!window.$nuxt') page.html = () => page.evaluate(() => window.document.documentElement.outerHTML) page.$text = (selector) => page.$eval(selector, (el) => el.textContent) + page.$$text = (selector) => page.$$eval(selector, (els) => els.map((el) => el.textContent)) page.$nuxt = await page.evaluateHandle('window.$nuxt') page.nuxt = { @@ -30,6 +31,14 @@ export async function page(url) { await this.waitForNavigation() } }, + routeData() { + return page.evaluate(($nuxt) => { + return { + path: $nuxt.$route.path, + query: $nuxt.$route.query + } + }, page.$nuxt) + }, loadingData() { return page.evaluate(($nuxt) => $nuxt.$loading.$data, page.$nuxt) }, From 8157fbfde948fbdb8589a84ef2ac3dcdb2c9baf3 Mon Sep 17 00:00:00 2001 From: Atinux Date: Thu, 2 Nov 2017 14:24:43 +0100 Subject: [PATCH 208/316] tests: Finish fixPrepatch tests --- test/children.patch.test.js | 143 ++++++++++++++++++ .../children/pages/patch/_id/child.vue | 2 +- .../children/pages/patch/_id/child/_slug.vue | 6 +- 3 files changed, 147 insertions(+), 4 deletions(-) create mode 100644 test/children.patch.test.js diff --git a/test/children.patch.test.js b/test/children.patch.test.js new file mode 100644 index 0000000000..60a010e865 --- /dev/null +++ b/test/children.patch.test.js @@ -0,0 +1,143 @@ +import test from 'ava' +import { resolve } from 'path' +import { Nuxt, Builder, Utils } from '../index.js' +import * as browser from './helpers/browser' + +const port = 4005 +const url = (route) => 'http://localhost:' + port + route + +let nuxt = null + +// Init nuxt.js and create server listening on localhost:4000 +test.before('Init Nuxt.js', async t => { + const options = { + rootDir: resolve(__dirname, 'fixtures/children'), + dev: false + } + nuxt = new Nuxt(options) + await new Builder(nuxt).build() + + await nuxt.listen(port, 'localhost') +}) +test.before('Start browser', async t => { + await browser.start({ + // slowMo: 50, + // headless: false + }) +}) + +let page +const dates = {} + +test('Loading /patch and keep ', async t => { + page = await browser.page(url('/patch')) + + const h1 = await page.$text('h1') + t.true(h1.includes('patch:')) + const h2 = await page.$text('h2') + t.is(h2, 'Index') + dates.patch = await page.$text('[data-date-patch]') +}) + +test('Navigate to /patch/1', async t => { + await page.nuxt.navigate('/patch/1') + const loading = await page.nuxt.loadingData() + t.is(loading.show, true) + await page.nuxt.waitForNavigation() + + const h2 = await page.$text('h2') + t.true(h2.includes('_id:')) + dates.id = await page.$text('[data-date-id]') + + t.is(dates.patch, await page.$text('[data-date-patch]')) +}) + +test('Navigate to /patch/2', async t => { + await page.nuxt.navigate('/patch/2', true) + const date = await page.$text('[data-date-id]') + + t.is(await page.$text('h3'), 'Index') + t.is(dates.patch, await page.$text('[data-date-patch]')) + t.true(+dates.id < +date) + dates.id = date +}) + +test('Navigate to /patch/2?test=true', async t => { + await page.nuxt.navigate('/patch/2?test=true', true) + t.is(dates.patch, await page.$text('[data-date-patch]')) + t.is(dates.id, await page.$text('[data-date-id]')) +}) + +test('Navigate to /patch/2#test', async t => { + await page.nuxt.navigate('/patch/2#test', true) + t.is(dates.patch, await page.$text('[data-date-patch]')) + t.is(dates.id, await page.$text('[data-date-id]')) +}) + +test('Navigate to /patch/2/child', async t => { + await page.nuxt.navigate('/patch/2/child', true) + dates.child = await page.$text('[data-date-child]') + + t.is(dates.patch, await page.$text('[data-date-patch]')) + t.is(dates.id, await page.$text('[data-date-id]')) + t.true(+dates.child > +dates.id) +}) + +test('Navigate to /patch/2/child', async t => { + await page.nuxt.navigate('/patch/2/child', true) + dates.child = await page.$text('[data-date-child]') + dates.slug = await page.$text('[data-date-child-slug]') + + t.is(dates.patch, await page.$text('[data-date-patch]')) + t.is(dates.id, await page.$text('[data-date-id]')) + t.true(+dates.child > +dates.id) + t.true(+dates.slug > +dates.child) +}) + +test('Navigate to /patch/2/child/1', async t => { + await page.nuxt.navigate('/patch/2/child/1', true) + const date = await page.$text('[data-date-child-slug]') + + t.is(dates.patch, await page.$text('[data-date-patch]')) + t.is(dates.id, await page.$text('[data-date-id]')) + t.is(dates.child, await page.$text('[data-date-child]')) + t.true(+date > +dates.slug) + dates.slug = date +}) + +test('Navigate to /patch/2/child/1?foo=bar', async t => { + await page.nuxt.navigate('/patch/2/child/1?foo=bar', true) + + t.is(dates.patch, await page.$text('[data-date-patch]')) + t.is(dates.id, await page.$text('[data-date-id]')) + t.is(dates.child, await page.$text('[data-date-child]')) + t.is(dates.slug, await page.$text('[data-date-child-slug]')) +}) + +test('Search a country', async t => { + const countries = await page.$$text('[data-test-search-result]') + t.is(countries.length, 5) + + await page.type('[data-test-search-input]', 'gu') + + await Utils.waitFor(100) + const newCountries = await page.$$text('[data-test-search-result]') + t.is(newCountries.length, 1) + t.deepEqual(newCountries, ['Guinea']) + t.deepEqual(await page.nuxt.routeData(), { + path: '/patch/2/child/1', + query: { + foo: 'bar', + q: 'gu' + } + }) +}) + +// Close server and ask nuxt to stop listening to file changes +test.after('Closing server and nuxt.js', t => { + nuxt.close() +}) +test.after('Stop browser', async t => { + await page.close() + await browser.stop() +}) diff --git a/test/fixtures/children/pages/patch/_id/child.vue b/test/fixtures/children/pages/patch/_id/child.vue index 8e0c0d02d0..346f2123ab 100644 --- a/test/fixtures/children/pages/patch/_id/child.vue +++ b/test/fixtures/children/pages/patch/_id/child.vue @@ -1,6 +1,6 @@ diff --git a/test/fixtures/children/pages/patch/_id/child/_slug.vue b/test/fixtures/children/pages/patch/_id/child/_slug.vue index c82d3aa74d..3ac44c444e 100644 --- a/test/fixtures/children/pages/patch/_id/child/_slug.vue +++ b/test/fixtures/children/pages/patch/_id/child/_slug.vue @@ -1,8 +1,8 @@ From a2cc3afe609f9a99957af62555e7f874ca1d3c35 Mon Sep 17 00:00:00 2001 From: Atinux Date: Thu, 2 Nov 2017 17:47:33 +0100 Subject: [PATCH 209/316] fix: Dont call pages asyncData/fetch if middleware redirected or errored --- lib/app/client.js | 6 ++++-- lib/app/index.js | 1 + lib/app/utils.js | 3 ++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/app/client.js b/lib/app/client.js index c6638e5a68..e247b63713 100644 --- a/lib/app/client.js +++ b/lib/app/client.js @@ -97,8 +97,8 @@ function mapTransitions(Components, to, from) { } async function loadAsyncComponents (to, from, next) { - // Check if route path changed (this._pathChanged) - this._pathChanged = from.path !== to.path + // Check if route path changed (this._pathChanged), only if the page is not an error (for validate()) + this._pathChanged = !!app.nuxt.err || from.path !== to.path <% if (loading) { %> if (this._pathChanged && this.$loading.start) { @@ -223,6 +223,7 @@ async function render (to, from, next) { // Call middleware await callMiddleware.call(this, Components, app.context) if (app.context._redirected) return + if (app.context._errored) return next() // Set layout let layout = Components[0].options.layout @@ -234,6 +235,7 @@ async function render (to, from, next) { // Call middleware for layout await callMiddleware.call(this, Components, app.context, layout) if (app.context._redirected) return + if (app.context._errored) return next() // Call .validate() let isValid = true diff --git a/lib/app/index.js b/lib/app/index.js index dec76840ad..f780d4e168 100644 --- a/lib/app/index.js +++ b/lib/app/index.js @@ -80,6 +80,7 @@ async function createApp (ssrContext) { dateErr: null, error (err) { err = err || null + app.context._errored = !!err if (typeof err === 'string') err = { statusCode: 500, message: err } const nuxt = this.nuxt || this.$options.nuxt nuxt.dateErr = Date.now() diff --git a/lib/app/utils.js b/lib/app/utils.js index 52d4440496..11f5f8378b 100644 --- a/lib/app/utils.js +++ b/lib/app/utils.js @@ -186,6 +186,7 @@ export async function setContext(app, context) { // Dynamic keys app.context.next = context.next app.context._redirected = false + app.context._errored = false app.context.isHMR = !!context.isHMR if (context.route) app.context.route = await getRouteData(context.route) app.context.params = app.context.route.params || {} @@ -194,7 +195,7 @@ export async function setContext(app, context) { } export function middlewareSeries(promises, appContext) { - if (!promises.length || appContext._redirected || appContext.app.nuxt.err) { + if (!promises.length || appContext._redirected || appContext._errored) { return Promise.resolve() } return promisify(promises[0], appContext) From 297b1a1434368f83ee1a7bd47174a96da245be4a Mon Sep 17 00:00:00 2001 From: Atinux Date: Thu, 2 Nov 2017 17:47:50 +0100 Subject: [PATCH 210/316] add: Add more methods to browser util --- test/helpers/browser.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/helpers/browser.js b/test/helpers/browser.js index f3cba4715c..b26ea5e35a 100644 --- a/test/helpers/browser.js +++ b/test/helpers/browser.js @@ -22,6 +22,8 @@ export async function page(url) { page.html = () => page.evaluate(() => window.document.documentElement.outerHTML) page.$text = (selector) => page.$eval(selector, (el) => el.textContent) page.$$text = (selector) => page.$$eval(selector, (els) => els.map((el) => el.textContent)) + page.$attr = (selector, attr) => page.$eval(selector, (el, attr) => el.getAttribute(attr), attr) + page.$$attr = (selector, attr) => page.$$eval(selector, (els, attr) => els.map((el) => el.getAttribute(attr)), attr) page.$nuxt = await page.evaluateHandle('window.$nuxt') page.nuxt = { @@ -42,6 +44,9 @@ export async function page(url) { loadingData() { return page.evaluate(($nuxt) => $nuxt.$loading.$data, page.$nuxt) }, + errorData() { + return page.evaluate(($nuxt) => $nuxt.nuxt.err, page.$nuxt) + }, waitForNavigation() { return page.waitForFunction('window.$nuxt.$loading.$data.show === false') } From 5edf9c4c9542521d9128a0b08d009c4de8e12bc2 Mon Sep 17 00:00:00 2001 From: Atinux Date: Thu, 2 Nov 2017 17:48:20 +0100 Subject: [PATCH 211/316] tests: Add CSR tests --- test/basic.csr.test.js | 157 +++++++++++++++++ test/basic.dom.test.js | 200 ---------------------- test/{basic.test.js => basic.ssr.test.js} | 16 +- test/fixtures/basic/middleware/error.js | 3 + test/fixtures/basic/pages/error-midd.vue | 13 ++ test/fixtures/basic/pages/error.vue | 5 +- 6 files changed, 189 insertions(+), 205 deletions(-) create mode 100644 test/basic.csr.test.js delete mode 100644 test/basic.dom.test.js rename test/{basic.test.js => basic.ssr.test.js} (93%) create mode 100644 test/fixtures/basic/middleware/error.js create mode 100644 test/fixtures/basic/pages/error-midd.vue diff --git a/test/basic.csr.test.js b/test/basic.csr.test.js new file mode 100644 index 0000000000..9ad0c0d97b --- /dev/null +++ b/test/basic.csr.test.js @@ -0,0 +1,157 @@ +import test from 'ava' +import { resolve } from 'path' +import { Nuxt, Builder } from '../index' +import * as browser from './helpers/browser' + +const port = 4003 +const url = (route) => 'http://localhost:' + port + route + +let nuxt = null +let page = null + +// Init nuxt.js and create server listening on localhost:4003 +test.before('Init Nuxt.js', async t => { + const options = { + rootDir: resolve(__dirname, 'fixtures/basic'), + dev: false, + head: { + titleTemplate(titleChunk) { + return titleChunk ? `${titleChunk} - Nuxt.js` : 'Nuxt.js' + } + } + } + nuxt = new Nuxt(options) + await new Builder(nuxt).build() + + await nuxt.listen(port, 'localhost') +}) + +test.before('Start browser', async t => { + await browser.start({ + // slowMo: 50, + // headless: false + }) +}) + +test('Open /', async t => { + page = await browser.page(url('/')) + + t.is(await page.$text('h1'), 'Index page') +}) + +test('/stateless', async t => { + await page.nuxt.navigate('/stateless') + const loading = await page.nuxt.loadingData() + + t.is(loading.show, true) + await page.nuxt.waitForNavigation() + t.is(await page.$text('h1'), 'My component!') +}) + +test('/css', async t => { + await page.nuxt.navigate('/css', true) + + t.is(await page.$text('.red'), 'This is red') + t.is(await page.$eval('.red', (red) => window.getComputedStyle(red).color), 'rgb(255, 0, 0)') +}) + +test('/stateful', async t => { + await page.nuxt.navigate('/stateful', true) + + t.is(await page.$text('p'), 'The answer is 42') +}) + +test('/store', async t => { + await page.nuxt.navigate('/store', true) + + t.is(await page.$text('h1'), 'Vuex Nested Modules') + t.is(await page.$text('p'), '1') +}) + +test('/head', async t => { + await page.nuxt.navigate('/head', true) + const metas = await page.$$attr('meta', 'content') + + t.is(await page.title(), 'My title - Nuxt.js') + t.is(await page.$text('h1'), 'I can haz meta tags') + t.is(metas[0], 'my meta') +}) + +test('/async-data', async t => { + await page.nuxt.navigate('/async-data', true) + + t.is(await page.$text('p'), 'Nuxt.js') +}) + +test('/await-async-data', async t => { + await page.nuxt.navigate('/await-async-data', true) + + t.is(await page.$text('p'), 'Await Nuxt.js') +}) + +test('/callback-async-data', async t => { + await page.nuxt.navigate('/callback-async-data', true) + + t.is(await page.$text('p'), 'Callback Nuxt.js') +}) + +test('/users/1', async t => { + await page.nuxt.navigate('/users/1', true) + + t.is(await page.$text('h1'), 'User: 1') +}) + +test('/validate should display a 404', async t => { + await page.nuxt.navigate('/validate', true) + const error = await page.nuxt.errorData() + + t.is(error.statusCode, 404) + t.is(error.message, 'This page could not be found') +}) + +test('/validate?valid=true', async t => { + await page.nuxt.navigate('/validate?valid=true', true) + + t.is(await page.$text('h1'), 'I am valid') +}) + +test('/redirect', async t => { + await page.nuxt.navigate('/redirect', true) + + t.is(await page.$text('h1'), 'Index page') +}) + +test('/error', async t => { + await page.nuxt.navigate('/error', true) + + t.deepEqual(await page.nuxt.errorData(), { statusCode: 500 }) + t.is(await page.$text('.title'), 'Error mouahahah') +}) + +test('/error2', async t => { + await page.nuxt.navigate('/error2', true) + + t.is(await page.$text('.title'), 'Custom error') + t.deepEqual(await page.nuxt.errorData(), { message: 'Custom error' }) +}) + +test('/redirect2', async t => { + await page.nuxt.navigate('/redirect2', true) + + t.is(await page.$text('h1'), 'Index page') +}) + +test('/no-ssr', async t => { + await page.nuxt.navigate('/no-ssr', true) + + t.is(await page.$text('h1'), 'Displayed only on client-side') +}) + +// Close server and ask nuxt to stop listening to file changes +test.after('Closing server and nuxt.js', t => { + nuxt.close() +}) + +test.after('Stop browser', async t => { + await browser.stop() +}) diff --git a/test/basic.dom.test.js b/test/basic.dom.test.js deleted file mode 100644 index 6a3198e134..0000000000 --- a/test/basic.dom.test.js +++ /dev/null @@ -1,200 +0,0 @@ -import test from 'ava' -import { resolve } from 'path' -import { Nuxt, Builder } from '../index' -import * as browser from './helpers/browser' - -const port = 4003 -const url = (route) => 'http://localhost:' + port + route - -let nuxt = null - -// Init nuxt.js and create server listening on localhost:4003 -test.before('Init Nuxt.js', async t => { - const options = { - rootDir: resolve(__dirname, 'fixtures/basic'), - dev: false, - head: { - titleTemplate(titleChunk) { - return titleChunk ? `${titleChunk} - Nuxt.js` : 'Nuxt.js' - } - } - } - nuxt = new Nuxt(options) - await new Builder(nuxt).build() - - await nuxt.listen(port, 'localhost') -}) - -test.before('Start browser', async t => { - await browser.start() -}) - -test('/stateless', async t => { - const page = await browser.page(url('/stateless')) - const loading = await page.nuxt.loadingData() - - t.is(await page.title(), 'Nuxt.js') - t.is(await page.$text('h1'), 'My component!') - t.is(loading.show, false) - t.is(loading.percent, 0) - await page.close() -}) - -test('/css', async t => { - const page = await browser.page(url('/css')) - t.is(await page.$eval('.red', (red) => red.textContent), 'This is red') - t.is(await page.$eval('.red', (red) => window.getComputedStyle(red).color), 'rgb(255, 0, 0)') - await page.close() -}) - -test('/stateful', async t => { - const page = await browser.page(url('/stateful')) - const html = await page.html() - t.true(html.includes('

    The answer is 42

    ')) - await page.close() -}) - -// test('/store', async t => { -// const { html } = await nuxt.renderRoute('/store') -// t.true(html.includes('

    Vuex Nested Modules

    ')) -// t.true(html.includes('

    1

    ')) -// }) - -// test('/head', async t => { -// const window = await nuxt.renderAndGetWindow(url('/head'), { virtualConsole: false }) -// const html = window.document.body.innerHTML -// const metas = window.document.getElementsByTagName('meta') -// t.is(window.document.title, 'My title - Nuxt.js') -// t.is(metas[0].getAttribute('content'), 'my meta') -// t.true(html.includes('

    I can haz meta tags

    ')) -// }) - -// test('/async-data', async t => { -// const { html } = await nuxt.renderRoute('/async-data') -// t.true(html.includes('

    Nuxt.js

    ')) -// }) - -// test('/await-async-data', async t => { -// const { html } = await nuxt.renderRoute('/await-async-data') -// t.true(html.includes('

    Await Nuxt.js

    ')) -// }) - -// test('/callback-async-data', async t => { -// const { html } = await nuxt.renderRoute('/callback-async-data') -// t.true(html.includes('

    Callback Nuxt.js

    ')) -// }) - -// test('/users/1', async t => { -// const { html } = await nuxt.renderRoute('/users/1') -// t.true(html.includes('

    User: 1

    ')) -// }) - -// test('/validate should display a 404', async t => { -// const { html } = await nuxt.renderRoute('/validate') -// t.true(html.includes('This page could not be found')) -// }) - -// test('/validate?valid=true', async t => { -// const { html } = await nuxt.renderRoute('/validate?valid=true') -// t.true(html.includes('

    I am valid

    ')) -// }) - -// test('/redirect', async t => { -// const { html, redirected } = await nuxt.renderRoute('/redirect') -// t.true(html.includes('
    ')) -// t.true(redirected.path === '/') -// t.true(redirected.status === 302) -// }) - -// test('/redirect -> check redirected source', async t => { -// const window = await nuxt.renderAndGetWindow(url('/redirect')) -// const html = window.document.body.innerHTML -// t.true(html.includes('

    Index page

    ')) -// }) - -// test('/special-state -> check window.__NUXT__.test = true', async t => { -// const window = await nuxt.renderAndGetWindow(url('/special-state')) -// t.is(window.document.title, 'Nuxt.js') -// t.is(window.__NUXT__.test, true) -// }) - -// test('/error', async t => { -// try { -// await nuxt.renderRoute('/error', { req: {}, res: {} }) -// } catch (err) { -// t.true(err.message.includes('Error mouahahah')) -// } -// }) - -// test('/error status code', async t => { -// try { -// await rp(url('/error')) -// } catch (err) { -// t.true(err.statusCode === 500) -// t.true(err.response.body.includes('An error occurred in the application and your page could not be served')) -// } -// }) - -// test('/error2', async t => { -// const { html, error } = await nuxt.renderRoute('/error2') -// t.true(html.includes('Custom error')) -// t.true(error.message.includes('Custom error')) -// t.true(error.statusCode === undefined) -// }) - -// test('/error2 status code', async t => { -// try { -// await rp(url('/error2')) -// } catch (err) { -// t.is(err.statusCode, 500) -// t.true(err.response.body.includes('Custom error')) -// } -// }) - -// test('/redirect2', async t => { -// stdMocks.use() -// await rp(url('/redirect2')) // Should console.error -// stdMocks.restore() -// const output = stdMocks.flush() -// // Don't display error since redirect returns a noopApp -// t.true(output.stderr.length === 0) -// }) - -// test('/no-ssr', async t => { -// const { html } = await nuxt.renderRoute('/no-ssr') -// t.true(html.includes('
    <p>Loading...</p>
    ')) -// }) - -// test('/no-ssr (client-side)', async t => { -// const window = await nuxt.renderAndGetWindow(url('/no-ssr')) -// const html = window.document.body.innerHTML -// t.true(html.includes('Displayed only on client-side')) -// }) - -// test('ETag Header', async t => { -// const { headers: { etag } } = await rp(url('/stateless'), { resolveWithFullResponse: true }) -// // Validate etag -// t.regex(etag, /W\/".*"$/) -// // Verify functionality -// const error = await t.throws(rp(url('/stateless'), { headers: { 'If-None-Match': etag } })) -// t.is(error.statusCode, 304) -// }) - -// test('/_nuxt/server-bundle.json should return 404', async t => { -// const err = await t.throws(rp(url('/_nuxt/server-bundle.json'), { resolveWithFullResponse: true })) -// t.is(err.statusCode, 404) -// }) - -// test('/_nuxt/ should return 404', async t => { -// const err = await t.throws(rp(url('/_nuxt/'), { resolveWithFullResponse: true })) -// t.is(err.statusCode, 404) -// }) - -// Close server and ask nuxt to stop listening to file changes -test.after('Closing server and nuxt.js', t => { - nuxt.close() -}) - -test.after('Stop browser', async t => { - await browser.stop() -}) diff --git a/test/basic.test.js b/test/basic.ssr.test.js similarity index 93% rename from test/basic.test.js rename to test/basic.ssr.test.js index c290c184b8..88fe599f45 100755 --- a/test/basic.test.js +++ b/test/basic.ssr.test.js @@ -145,9 +145,23 @@ test('/error2 status code', async t => { } }) +test('/error-midd', async t => { + stdMocks.use() + try { + await rp(url('/error-midd')) + } catch (err) { + stdMocks.restore() + t.is(err.statusCode, 505) + t.true(err.response.body.includes('Middleware Error')) + const output = stdMocks.flush() + // Don't display error since redirect returns a noopApp + t.true(output.stderr.length === 0) + } +}) + test('/redirect2', async t => { stdMocks.use() - await rp(url('/redirect2')) // Should console.error + await rp(url('/redirect2')) // Should not console.error stdMocks.restore() const output = stdMocks.flush() // Don't display error since redirect returns a noopApp diff --git a/test/fixtures/basic/middleware/error.js b/test/fixtures/basic/middleware/error.js new file mode 100644 index 0000000000..dc473a11b6 --- /dev/null +++ b/test/fixtures/basic/middleware/error.js @@ -0,0 +1,3 @@ +export default function ({ error }) { + error({ message: 'Middleware Error', statusCode: 505 }) +} diff --git a/test/fixtures/basic/pages/error-midd.vue b/test/fixtures/basic/pages/error-midd.vue new file mode 100644 index 0000000000..8326830af5 --- /dev/null +++ b/test/fixtures/basic/pages/error-midd.vue @@ -0,0 +1,13 @@ + + + diff --git a/test/fixtures/basic/pages/error.vue b/test/fixtures/basic/pages/error.vue index 48f35a3b40..2b2308b386 100644 --- a/test/fixtures/basic/pages/error.vue +++ b/test/fixtures/basic/pages/error.vue @@ -5,10 +5,7 @@ From 20b548a17523e54d7f24cede4ada358d359e6f78 Mon Sep 17 00:00:00 2001 From: Atinux Date: Thu, 2 Nov 2017 18:07:33 +0100 Subject: [PATCH 212/316] test: Add route.meta test --- test/basic.csr.test.js | 7 +++++++ test/basic.ssr.test.js | 6 ++++++ test/fixtures/basic/middleware/meta.js | 3 +++ test/fixtures/basic/pages/meta.vue | 12 ++++++++++++ test/fixtures/basic/store/index.js | 6 +++++- test/helpers/browser.js | 3 +++ 6 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 test/fixtures/basic/middleware/meta.js create mode 100644 test/fixtures/basic/pages/meta.vue diff --git a/test/basic.csr.test.js b/test/basic.csr.test.js index 9ad0c0d97b..3840b95b10 100644 --- a/test/basic.csr.test.js +++ b/test/basic.csr.test.js @@ -147,6 +147,13 @@ test('/no-ssr', async t => { t.is(await page.$text('h1'), 'Displayed only on client-side') }) +test('/meta', async t => { + await page.nuxt.navigate('/meta', true) + + const state = await page.nuxt.storeState() + t.deepEqual(state.meta, [{ works: true }]) +}) + // Close server and ask nuxt to stop listening to file changes test.after('Closing server and nuxt.js', t => { nuxt.close() diff --git a/test/basic.ssr.test.js b/test/basic.ssr.test.js index 88fe599f45..c487581f4f 100755 --- a/test/basic.ssr.test.js +++ b/test/basic.ssr.test.js @@ -198,6 +198,12 @@ test('/_nuxt/ should return 404', async t => { t.is(err.statusCode, 404) }) +test('/meta', async t => { + const { html } = await nuxt.renderRoute('/meta') + + t.true(html.includes('"meta":[{"works":true}]')) +}) + // Close server and ask nuxt to stop listening to file changes test.after('Closing server and nuxt.js', t => { nuxt.close() diff --git a/test/fixtures/basic/middleware/meta.js b/test/fixtures/basic/middleware/meta.js new file mode 100644 index 0000000000..c438131406 --- /dev/null +++ b/test/fixtures/basic/middleware/meta.js @@ -0,0 +1,3 @@ +export default ({ store, route, redirect }) => { + store.commit('setMeta', route.meta) +} diff --git a/test/fixtures/basic/pages/meta.vue b/test/fixtures/basic/pages/meta.vue new file mode 100644 index 0000000000..4649b02390 --- /dev/null +++ b/test/fixtures/basic/pages/meta.vue @@ -0,0 +1,12 @@ + + + diff --git a/test/fixtures/basic/store/index.js b/test/fixtures/basic/store/index.js index 5c1372507f..8052bed3ad 100755 --- a/test/fixtures/basic/store/index.js +++ b/test/fixtures/basic/store/index.js @@ -1,9 +1,13 @@ export const state = () => ({ - counter: 1 + counter: 1, + meta: [] }) export const mutations = { increment(state) { state.counter++ + }, + setMeta(state, meta) { + state.meta = meta } } diff --git a/test/helpers/browser.js b/test/helpers/browser.js index b26ea5e35a..fdde550d93 100644 --- a/test/helpers/browser.js +++ b/test/helpers/browser.js @@ -47,6 +47,9 @@ export async function page(url) { errorData() { return page.evaluate(($nuxt) => $nuxt.nuxt.err, page.$nuxt) }, + storeState() { + return page.evaluate(($nuxt) => $nuxt.$store.state, page.$nuxt) + }, waitForNavigation() { return page.waitForFunction('window.$nuxt.$loading.$data.show === false') } From 04a2ffb016c85422f3ae74364b1b6da794a57a9e Mon Sep 17 00:00:00 2001 From: Clark Du Date: Fri, 3 Nov 2017 10:36:01 +0800 Subject: [PATCH 213/316] fix: video can not be loaded --- lib/builder/webpack/vue-loader.config.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/builder/webpack/vue-loader.config.js b/lib/builder/webpack/vue-loader.config.js index f3a2aaa4a3..f281c06fe1 100644 --- a/lib/builder/webpack/vue-loader.config.js +++ b/lib/builder/webpack/vue-loader.config.js @@ -20,6 +20,10 @@ export default function vueLoader() { }, template: { doctype: 'html' // For pug, see https://github.com/vuejs/vue-loader/issues/55 + }, + transformToRequire: { + video: 'src', + source: 'src' } } From 0fb8431ac2f550d3b0d094a7a1834f9f4f5685fa Mon Sep 17 00:00:00 2001 From: Atinux Date: Fri, 3 Nov 2017 12:30:23 +0100 Subject: [PATCH 214/316] example: Add Tailwind CSS example --- examples/tailwindcss/README.md | 5 + examples/tailwindcss/assets/css/tailwind.css | 45 ++ examples/tailwindcss/layouts/default.vue | 14 + examples/tailwindcss/nuxt.config.js | 3 + examples/tailwindcss/package.json | 16 + examples/tailwindcss/pages/about.vue | 19 + examples/tailwindcss/pages/index.vue | 17 + examples/tailwindcss/postcss.config.js | 6 + examples/tailwindcss/tailwind.js | 744 +++++++++++++++++++ 9 files changed, 869 insertions(+) create mode 100644 examples/tailwindcss/README.md create mode 100644 examples/tailwindcss/assets/css/tailwind.css create mode 100644 examples/tailwindcss/layouts/default.vue create mode 100644 examples/tailwindcss/nuxt.config.js create mode 100644 examples/tailwindcss/package.json create mode 100644 examples/tailwindcss/pages/about.vue create mode 100644 examples/tailwindcss/pages/index.vue create mode 100644 examples/tailwindcss/postcss.config.js create mode 100644 examples/tailwindcss/tailwind.js diff --git a/examples/tailwindcss/README.md b/examples/tailwindcss/README.md new file mode 100644 index 0000000000..ed20a3dab7 --- /dev/null +++ b/examples/tailwindcss/README.md @@ -0,0 +1,5 @@ +# Nuxt.js with Tailwind CSS + +See https://tailwindcss.com/docs/what-is-tailwind/ + +Demo: https://tailwindcss.nuxtjs.org diff --git a/examples/tailwindcss/assets/css/tailwind.css b/examples/tailwindcss/assets/css/tailwind.css new file mode 100644 index 0000000000..74a97f8831 --- /dev/null +++ b/examples/tailwindcss/assets/css/tailwind.css @@ -0,0 +1,45 @@ +/** + * This injects Tailwind's base styles, which is a combination of + * Normalize.css and some additional base styles. + * + * You can see the styles here: + * https://github.com/tailwindcss/tailwindcss/blob/master/css/preflight.css + */ + @tailwind preflight; + + /** + * Here you would add any of your custom component classes; stuff that you'd + * want loaded *before* the utilities so that the utilities could still + * override them. + * + * Example: + * + * .btn { ... } + * .form-input { ... } + * + * Or if using a preprocessor: + * + * @import "components/buttons"; + * @import "components/forms"; + */ + + /** + * This injects all of Tailwind's utility classes, generated based on your + * config file. + */ + @tailwind utilities; + + /** + * Here you would add any custom utilities you need that don't come out of the + * box with Tailwind. + * + * Example : + * + * .bg-pattern-graph-paper { ... } + * .skew-45 { ... } + * + * Or if using a preprocessor.. + * + * @import "utilities/backgrond-patterns"; + * @import "utilities/skew-transforms"; + */ diff --git a/examples/tailwindcss/layouts/default.vue b/examples/tailwindcss/layouts/default.vue new file mode 100644 index 0000000000..09ad8b846b --- /dev/null +++ b/examples/tailwindcss/layouts/default.vue @@ -0,0 +1,14 @@ + diff --git a/examples/tailwindcss/nuxt.config.js b/examples/tailwindcss/nuxt.config.js new file mode 100644 index 0000000000..7550d05a97 --- /dev/null +++ b/examples/tailwindcss/nuxt.config.js @@ -0,0 +1,3 @@ +module.exports = { + css: ['~/assets/css/tailwind.css'] +} diff --git a/examples/tailwindcss/package.json b/examples/tailwindcss/package.json new file mode 100644 index 0000000000..11c1208cb1 --- /dev/null +++ b/examples/tailwindcss/package.json @@ -0,0 +1,16 @@ +{ + "name": "nuxt-tailwindcss", + "description": "Nuxt.js with Tailwind CSS", + "scripts": { + "dev": "nuxt", + "build": "nuxt build", + "start": "nuxt start" + }, + "dependencies": { + "nuxt": "latest" + }, + "devDependencies": { + "autoprefixer": "^7.1.6", + "tailwindcss": "^0.1.3" + } +} diff --git a/examples/tailwindcss/pages/about.vue b/examples/tailwindcss/pages/about.vue new file mode 100644 index 0000000000..9e13161e79 --- /dev/null +++ b/examples/tailwindcss/pages/about.vue @@ -0,0 +1,19 @@ + + + diff --git a/examples/tailwindcss/pages/index.vue b/examples/tailwindcss/pages/index.vue new file mode 100644 index 0000000000..42b3f02ef1 --- /dev/null +++ b/examples/tailwindcss/pages/index.vue @@ -0,0 +1,17 @@ + diff --git a/examples/tailwindcss/postcss.config.js b/examples/tailwindcss/postcss.config.js new file mode 100644 index 0000000000..6b4212984e --- /dev/null +++ b/examples/tailwindcss/postcss.config.js @@ -0,0 +1,6 @@ +module.exports = { + plugins: [ + require('tailwindcss')('./tailwind.js'), + require('autoprefixer') + ] +} diff --git a/examples/tailwindcss/tailwind.js b/examples/tailwindcss/tailwind.js new file mode 100644 index 0000000000..9a4af76aba --- /dev/null +++ b/examples/tailwindcss/tailwind.js @@ -0,0 +1,744 @@ +/* + +Tailwind - The Utility-First CSS Framework + +A project by Adam Wathan (@adamwathan), Jonathan Reinink (@reinink), +David Hemphill (@davidhemphill) and Steve Schoger (@steveschoger). + +Welcome to the Tailwind config file. This is where you can customize +Tailwind specifically for your project. Don't be intimidated by the +length of this file. It's really just a big JavaScript object and +we've done our very best to explain each section. + +View the full documentation at https://tailwindcss.com. + +|------------------------------------------------------------------------------- +| The default config +|------------------------------------------------------------------------------- +| +| This variable contains the default Tailwind config. You don't have +| to use it, but it can sometimes be helpful to have available. For +| example, you may choose to merge your custom configuration +| values with some of the Tailwind defaults. +| +*/ + +// var defaultConfig = require('tailwindcss').defaultConfig() + +/* +|------------------------------------------------------------------------------- +| Colors https://tailwindcss.com/docs/colors +|------------------------------------------------------------------------------- +| +| Here you can specify the colors used in your project. To get you started, +| we've provided a generous palette of great looking colors that are perfect +| for prototyping, but don't hesitate to change them for your project. You +| own these colors, nothing will break if you change everything about them. +| +| We've used literal color names ("red", "blue", etc.) for the default +| palette, but if you'd rather use functional names like "primary" and +| "secondary", or even a numeric scale like "100" and "200", go for it. +| +*/ + +var colors = { + 'transparent': 'transparent', + + 'black': '#222b2f', + 'grey-darkest': '#364349', + 'grey-darker': '#596a73', + 'grey-dark': '#70818a', + 'grey': '#9babb4', + 'grey-light': '#dae4e9', + 'grey-lighter': '#f3f7f9', + 'grey-lightest': '#fafcfc', + 'white': '#ffffff', + + 'red-darkest': '#420806', + 'red-darker': '#6a1b19', + 'red-dark': '#cc1f1a', + 'red': '#e3342f', + 'red-light': '#ef5753', + 'red-lighter': '#f9acaa', + 'red-lightest': '#fcebea', + + 'orange-darkest': '#542605', + 'orange-darker': '#7f4012', + 'orange-dark': '#de751f', + 'orange': '#f6993f', + 'orange-light': '#faad63', + 'orange-lighter': '#fcd9b6', + 'orange-lightest': '#fff5eb', + + 'yellow-darkest': '#453411', + 'yellow-darker': '#684f1d', + 'yellow-dark': '#f2d024', + 'yellow': '#ffed4a', + 'yellow-light': '#fff382', + 'yellow-lighter': '#fff9c2', + 'yellow-lightest': '#fcfbeb', + + 'green-darkest': '#032d19', + 'green-darker': '#0b4228', + 'green-dark': '#1f9d55', + 'green': '#38c172', + 'green-light': '#51d88a', + 'green-lighter': '#a2f5bf', + 'green-lightest': '#e3fcec', + + 'teal-darkest': '#0d3331', + 'teal-darker': '#174e4b', + 'teal-dark': '#38a89d', + 'teal': '#4dc0b5', + 'teal-light': '#64d5ca', + 'teal-lighter': '#a0f0ed', + 'teal-lightest': '#e8fffe', + + 'blue-darkest': '#05233b', + 'blue-darker': '#103d60', + 'blue-dark': '#2779bd', + 'blue': '#3490dc', + 'blue-light': '#6cb2eb', + 'blue-lighter': '#bcdefa', + 'blue-lightest': '#eff8ff', + + 'indigo-darkest': '#191e38', + 'indigo-darker': '#2f365f', + 'indigo-dark': '#5661b3', + 'indigo': '#6574cd', + 'indigo-light': '#7886d7', + 'indigo-lighter': '#b2b7ff', + 'indigo-lightest': '#e6e8ff', + + 'purple-darkest': '#1f133f', + 'purple-darker': '#352465', + 'purple-dark': '#794acf', + 'purple': '#9561e2', + 'purple-light': '#a779e9', + 'purple-lighter': '#d6bbfc', + 'purple-lightest': '#f3ebff', + + 'pink-darkest': '#45051e', + 'pink-darker': '#72173a', + 'pink-dark': '#eb5286', + 'pink': '#f66d9b', + 'pink-light': '#fa7ea8', + 'pink-lighter': '#ffbbca', + 'pink-lightest': '#ffebef' +} + +module.exports = { + + /* + |----------------------------------------------------------------------------- + | Colors https://tailwindcss.com/docs/colors + |----------------------------------------------------------------------------- + | + | The color palette defined above is also assigned to the "colors" key of + | your Tailwind config. This makes it easy to access them in your CSS + | using Tailwind's config helper. For example: + | + | .error { color: config('colors.red') } + | + */ + + colors: colors, + + /* + |----------------------------------------------------------------------------- + | Screens https://tailwindcss.com/docs/responsive-design + |----------------------------------------------------------------------------- + | + | Screens in Tailwind are translated to CSS media queries. They define the + | responsive breakpoints for your project. By default Tailwind takes a + | "mobile first" approach, where each screen size represents a minimum + | viewport width. Feel free to have as few or as many screens as you + | want, naming them in whatever way you'd prefer for your project. + | + | Tailwind also allows for more complex screen definitions, which can be + | useful in certain situations. Be sure to see the full responsive + | documentation for a complete list of options. + | + | Class name: .{screen}:{utility} + | + */ + + screens: { + 'sm': '576px', + 'md': '768px', + 'lg': '992px', + 'xl': '1200px' + }, + + /* + |----------------------------------------------------------------------------- + | Fonts https://tailwindcss.com/docs/fonts + |----------------------------------------------------------------------------- + | + | Here is where you define your project's font stack, or font families. + | Keep in mind that Tailwind doesn't actually load any fonts for you. + | If you're using custom fonts you'll need to import them prior to + | defining them here. + | + | By default we provide a native font stack that works remarkably well on + | any device or OS you're using, since it just uses the default fonts + | provided by the platform. + | + | Class name: .font-{name} + | + */ + + fonts: { + 'sans': [ + '-apple-system', + 'BlinkMacSystemFont', + 'Segoe UI', + 'Roboto', + 'Oxygen', + 'Ubuntu', + 'Cantarell', + 'Fira Sans', + 'Droid Sans', + 'Helvetica Neue' + ], + 'serif': [ + 'Constantia', + 'Lucida Bright', + 'Lucidabright', + 'Lucida Serif', + 'Lucida', + 'DejaVu Serif', + 'Bitstream Vera Serif', + 'Liberation Serif', + 'Georgia', + 'serif' + ], + 'mono': [ + 'Menlo', + 'Monaco', + 'Consolas', + 'Liberation Mono', + 'Courier New', + 'monospace' + ] + }, + + /* + |----------------------------------------------------------------------------- + | Text sizes https://tailwindcss.com/docs/text-sizing + |----------------------------------------------------------------------------- + | + | Here is where you define your text sizes. Name these in whatever way + | makes the most sense to you. We use size names by default, but + | you're welcome to use a numeric scale or even something else + | entirely. + | + | By default Tailwind uses the "rem" unit type for most measurements. + | This allows you to set a root font size which all other sizes are + | then based on. That said, you are free to use whatever units you + | prefer, be it rems, ems, pixels or other. + | + | Class name: .text-{size} + | + */ + + textSizes: { + 'xs': '.75rem', // 12px + 'sm': '.875rem', // 14px + 'base': '1rem', // 16px + 'lg': '1.125rem', // 18px + 'xl': '1.25rem', // 20px + '2xl': '1.5rem', // 24px + '3xl': '1.875rem', // 30px + '4xl': '2.25rem', // 36px + '5xl': '3rem' // 48px + }, + + /* + |----------------------------------------------------------------------------- + | Font weights https://tailwindcss.com/docs/font-weight + |----------------------------------------------------------------------------- + | + | Here is where you define your font weights. We've provided a list of + | common font weight names with their respective numeric scale values + | to get you started. It's unlikely that your project will require + | all of these, so we recommend removing those you don't need. + | + | Class name: .font-{weight} + | + */ + + fontWeights: { + 'hairline': 100, + 'thin': 200, + 'light': 300, + 'normal': 400, + 'medium': 500, + 'semibold': 600, + 'bold': 700, + 'extrabold': 800, + 'black': 900 + }, + + /* + |----------------------------------------------------------------------------- + | Leading (line height) https://tailwindcss.com/docs/line-height + |----------------------------------------------------------------------------- + | + | Here is where you define your line height values, or as we call + | them in Tailwind, leadings. + | + | Class name: .leading-{size} + | + */ + + leading: { + 'none': 1, + 'tight': 1.25, + 'normal': 1.5, + 'loose': 2 + }, + + /* + |----------------------------------------------------------------------------- + | Tracking (letter spacing) https://tailwindcss.com/docs/letter-spacing + |----------------------------------------------------------------------------- + | + | Here is where you define your letter spacing values, or as we call + | them in Tailwind, tracking. + | + | Class name: .tracking-{size} + | + */ + + tracking: { + 'tight': '-0.05em', + 'normal': '0', + 'wide': '0.05em' + }, + + /* + |----------------------------------------------------------------------------- + | Text colors https://tailwindcss.com/docs/text-color + |----------------------------------------------------------------------------- + | + | Here is where you define your text colors. By default these use the + | color palette we defined above, however you're welcome to set these + | independently if that makes sense for your project. + | + | Class name: .text-{color} + | + */ + + textColors: colors, + + /* + |----------------------------------------------------------------------------- + | Background colors https://tailwindcss.com/docs/background-color + |----------------------------------------------------------------------------- + | + | Here is where you define your background colors. By default these use + | the color palette we defined above, however you're welcome to set + | these independently if that makes sense for your project. + | + | Class name: .bg-{color} + | + */ + + backgroundColors: colors, + + /* + |----------------------------------------------------------------------------- + | Border widths https://tailwindcss.com/docs/border-width + |----------------------------------------------------------------------------- + | + | Here is where you define your border widths. Take note that border + | widths require a special "default" value set as well. This is the + | width that will be used when you do not specify a border width. + | + | Class name: .border{-side?}{-width?} + | + */ + + borderWidths: { + default: '1px', + '0': '0', + '2': '2px', + '4': '4px', + '8': '8px' + }, + + /* + |----------------------------------------------------------------------------- + | Border colors https://tailwindcss.com/docs/border-color + |----------------------------------------------------------------------------- + | + | Here is where you define your border colors. By default these use the + | color palette we defined above, however you're welcome to set these + | independently if that makes sense for your project. + | + | Take note that border colors require a special "default" value set + | as well. This is the color that will be used when you do not + | specify a border color. + | + | Class name: .border-{color} + | + */ + + borderColors: Object.assign({ default: colors['grey-light'] }, colors), + + /* + |----------------------------------------------------------------------------- + | Border radius https://tailwindcss.com/docs/border-radius + |----------------------------------------------------------------------------- + | + | Here is where you define your border radius values. If a `default` radius + | is provided, it will be made available as the non-suffixed `.rounded` + | utility. + | + | Class name: .rounded{-radius?} + | + */ + + borderRadius: { + default: '.25rem', + 'sm': '.125rem', + 'lg': '.5rem', + 'full': '9999px', + 'none': '0' + }, + + /* + |----------------------------------------------------------------------------- + | Width https://tailwindcss.com/docs/width + |----------------------------------------------------------------------------- + | + | Here is where you define your width utility sizes. These can be + | percentage based, pixels, rems, or any other units. By default + | we provide a sensible rem based numeric scale, a percentage + | based fraction scale, plus some other common use-cases. You + | can, of course, modify these values as needed. + | + | + | It's also worth mentioning that Tailwind automatically escapes + | invalid CSS class name characters, which allows you to have + | awesome classes like .w-2/3. + | + | Class name: .w-{size} + | + */ + + width: { + 'auto': 'auto', + 'px': '1px', + '1': '0.25rem', + '2': '0.5rem', + '3': '0.75rem', + '4': '1rem', + '6': '1.5rem', + '8': '2rem', + '10': '2.5rem', + '12': '3rem', + '16': '4rem', + '24': '6rem', + '32': '8rem', + '48': '12rem', + '64': '16rem', + '1/2': '50%', + '1/3': '33.33333%', + '2/3': '66.66667%', + '1/4': '25%', + '3/4': '75%', + '1/5': '20%', + '2/5': '40%', + '3/5': '60%', + '4/5': '80%', + '1/6': '16.66667%', + '5/6': '83.33333%', + 'full': '100%', + 'screen': '100vw' + }, + + /* + |----------------------------------------------------------------------------- + | Height https://tailwindcss.com/docs/height + |----------------------------------------------------------------------------- + | + | Here is where you define your height utility sizes. These can be + | percentage based, pixels, rems, or any other units. By default + | we provide a sensible rem based numeric scale plus some other + | common use-cases. You can, of course, modify these values as + | needed. + | + | Class name: .h-{size} + | + */ + + height: { + 'auto': 'auto', + 'px': '1px', + '1': '0.25rem', + '2': '0.5rem', + '3': '0.75rem', + '4': '1rem', + '6': '1.5rem', + '8': '2rem', + '10': '2.5rem', + '12': '3rem', + '16': '4rem', + '24': '6rem', + '32': '8rem', + '48': '12rem', + '64': '16rem', + 'full': '100%', + 'screen': '100vh' + }, + + /* + |----------------------------------------------------------------------------- + | Minimum width https://tailwindcss.com/docs/min-width + |----------------------------------------------------------------------------- + | + | Here is where you define your minimum width utility sizes. These can + | be percentage based, pixels, rems, or any other units. We provide a + | couple common use-cases by default. You can, of course, modify + | these values as needed. + | + | Class name: .min-w-{size} + | + */ + + minWidth: { + '0': '0', + 'full': '100%' + }, + + /* + |----------------------------------------------------------------------------- + | Minimum height https://tailwindcss.com/docs/min-height + |----------------------------------------------------------------------------- + | + | Here is where you define your minimum height utility sizes. These can + | be percentage based, pixels, rems, or any other units. We provide a + | few common use-cases by default. You can, of course, modify these + | values as needed. + | + | Class name: .min-h-{size} + | + */ + + minHeight: { + '0': '0', + 'full': '100%', + 'screen': '100vh' + }, + + /* + |----------------------------------------------------------------------------- + | Maximum width https://tailwindcss.com/docs/max-width + |----------------------------------------------------------------------------- + | + | Here is where you define your maximum width utility sizes. These can + | be percentage based, pixels, rems, or any other units. By default + | we provide a sensible rem based scale and a "full width" size, + | which is basically a reset utility. You can, of course, + | modify these values as needed. + | + | Class name: .max-w-{size} + | + */ + + maxWidth: { + 'xs': '20rem', + 'sm': '30rem', + 'md': '40rem', + 'lg': '50rem', + 'xl': '60rem', + '2xl': '70rem', + '3xl': '80rem', + '4xl': '90rem', + '5xl': '100rem', + 'full': '100%' + }, + + /* + |----------------------------------------------------------------------------- + | Maximum height https://tailwindcss.com/docs/max-height + |----------------------------------------------------------------------------- + | + | Here is where you define your maximum height utility sizes. These can + | be percentage based, pixels, rems, or any other units. We provide a + | couple common use-cases by default. You can, of course, modify + | these values as needed. + | + | Class name: .max-h-{size} + | + */ + + maxHeight: { + 'full': '100%', + 'screen': '100vh' + }, + + /* + |----------------------------------------------------------------------------- + | Padding https://tailwindcss.com/docs/padding + |----------------------------------------------------------------------------- + | + | Here is where you define your padding utility sizes. These can be + | percentage based, pixels, rems, or any other units. By default we + | provide a sensible rem based numeric scale plus a couple other + | common use-cases like "1px". You can, of course, modify these + | values as needed. + | + | Class name: .p{side?}-{size} + | + */ + + padding: { + 'px': '1px', + '0': '0', + '1': '0.25rem', + '2': '0.5rem', + '3': '0.75rem', + '4': '1rem', + '6': '1.5rem', + '8': '2rem' + }, + + /* + |----------------------------------------------------------------------------- + | Margin https://tailwindcss.com/docs/margin + |----------------------------------------------------------------------------- + | + | Here is where you define your margin utility sizes. These can be + | percentage based, pixels, rems, or any other units. By default we + | provide a sensible rem based numeric scale plus a couple other + | common use-cases like "1px". You can, of course, modify these + | values as needed. + | + | Class name: .m{side?}-{size} + | + */ + + margin: { + 'px': '1px', + '0': '0', + '1': '0.25rem', + '2': '0.5rem', + '3': '0.75rem', + '4': '1rem', + '6': '1.5rem', + '8': '2rem' + }, + + /* + |----------------------------------------------------------------------------- + | Negative margin https://tailwindcss.com/docs/negative-margin + |----------------------------------------------------------------------------- + | + | Here is where you define your negative margin utility sizes. These can + | be percentage based, pixels, rems, or any other units. By default we + | provide matching values to the padding scale since these utilities + | generally get used together. You can, of course, modify these + | values as needed. + | + | Class name: .-m{side?}-{size} + | + */ + + negativeMargin: { + 'px': '1px', + '0': '0', + '1': '0.25rem', + '2': '0.5rem', + '3': '0.75rem', + '4': '1rem', + '6': '1.5rem', + '8': '2rem' + }, + + /* + |----------------------------------------------------------------------------- + | Shadows https://tailwindcss.com/docs/shadows + |----------------------------------------------------------------------------- + | + | Here is where you define your shadow utilities. As you can see from + | the defaults we provide, it's possible to apply multiple shadows + | per utility using comma separation. + | + | If a `default` shadow is provided, it will be made available as the non- + | suffixed `.shadow` utility. + | + | Class name: .shadow-{size?} + | + */ + + shadows: { + default: '0 2px 4px 0 rgba(0,0,0,0.10)', + 'md': '0 4px 8px 0 rgba(0,0,0,0.12), 0 2px 4px 0 rgba(0,0,0,0.08)', + 'lg': '0 15px 30px 0 rgba(0,0,0,0.11), 0 5px 15px 0 rgba(0,0,0,0.08)', + 'inner': 'inset 0 2px 4px 0 rgba(0,0,0,0.06)', + 'none': 'none' + }, + + /* + |----------------------------------------------------------------------------- + | Z-index https://tailwindcss.com/docs/z-index + |----------------------------------------------------------------------------- + | + | Here is where you define your z-index utility values. By default we + | provide a sensible numeric scale. You can, of course, modify these + | values as needed. + | + | Class name: .z-{index} + | + */ + + zIndex: { + '0': 0, + '10': 10, + '20': 20, + '30': 30, + '40': 40, + '50': 50, + 'auto': 'auto' + }, + + /* + |----------------------------------------------------------------------------- + | Opacity https://tailwindcss.com/docs/opacity + |----------------------------------------------------------------------------- + | + | Here is where you define your opacity utility values. By default we + | provide a sensible numeric scale. You can, of course, modify these + | values as needed. + | + | Class name: .opacity-{name} + | + */ + + opacity: { + '0': '0', + '25': '.25', + '50': '.5', + '75': '.75', + '100': '1' + }, + + /* + |----------------------------------------------------------------------------- + | Packages + |----------------------------------------------------------------------------- + | + | Here is where you can define the configuration for any Tailwind packages + | you're using. These can be utility packs, component bundles, or even + | complete themes. You'll want to reference each package's + | documentation for a list of settings available for it. + | + */ + + packages: { + } + +} From 42073db28936e0317f6dd7e77387570d486c43aa Mon Sep 17 00:00:00 2001 From: Atinux Date: Fri, 3 Nov 2017 12:30:49 +0100 Subject: [PATCH 215/316] fix: Remove useless console.log --- lib/builder/generator.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/builder/generator.js b/lib/builder/generator.js index b24a5680b3..42cddada32 100644 --- a/lib/builder/generator.js +++ b/lib/builder/generator.js @@ -47,7 +47,6 @@ export default class Generator { let generateRoutes = [] if (this.options.router.mode !== 'hash') { try { - console.log('Generating routes') // eslint-disable-line no-console generateRoutes = await promisifyRoute(this.options.generate.routes || []) } catch (e) { console.error('Could not resolve routes') // eslint-disable-line no-console From ac3b3f27a70a06b1a4b70c3e5bd0c3355a7da434 Mon Sep 17 00:00:00 2001 From: Atinux Date: Fri, 3 Nov 2017 12:31:12 +0100 Subject: [PATCH 216/316] debug: Show what PostCSS configuration is used --- lib/common/options.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/common/options.js b/lib/common/options.js index 3aea5e59ae..c2c71a0fc5 100755 --- a/lib/common/options.js +++ b/lib/common/options.js @@ -1,8 +1,12 @@ import _ from 'lodash' +import Debug from 'debug' import { join, resolve } from 'path' import { existsSync } from 'fs' import { isUrl, isPureObject } from 'utils' +const debug = Debug('nuxt:build') +debug.color = 2 // Force green color + const Options = {} export default Options @@ -96,6 +100,7 @@ Options.from = function (_options) { // Default postcss options if (postcssConfigPath) { + debug(`Using PostCSS config file: ${postcssConfigPath}`) options.build.postcss = { sourceMap: options.build.cssSourceMap, // https://github.com/postcss/postcss-loader/blob/master/lib/index.js#L79 @@ -104,6 +109,7 @@ Options.from = function (_options) { } } } else { + debug('Using PostCSS config from `build.postcss`') // Normalize & Apply default plugins if (Array.isArray(options.build.postcss)) { options.build.postcss = { plugins: options.build.postcss } From aa342330d7fc6ca9d757792bfd6677184779640c Mon Sep 17 00:00:00 2001 From: Atinux Date: Fri, 3 Nov 2017 12:31:35 +0100 Subject: [PATCH 217/316] fix: Fix PostCSS plugin resolution when used in nuxt.config.js --- lib/builder/builder.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/builder/builder.js b/lib/builder/builder.js index b5a51aee9b..91f3a66746 100644 --- a/lib/builder/builder.js +++ b/lib/builder/builder.js @@ -137,7 +137,7 @@ export default class Builder { if (isPureObject(this.options.build.postcss.plugins)) { this.options.build.postcss.plugins = Object.keys(this.options.build.postcss.plugins) .map(p => { - const plugin = require(p) + const plugin = require(this.nuxt.resolvePath(p)) const opts = this.options.build.postcss.plugins[p] if (opts === false) return // Disabled const instance = plugin(opts) From c17cb24aaa4445c6055b1532cee341d4f814e099 Mon Sep 17 00:00:00 2001 From: Atinux Date: Fri, 3 Nov 2017 16:00:09 +0100 Subject: [PATCH 218/316] fix: generate.minify.collapseWhitespace is false by default --- lib/common/options.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/common/options.js b/lib/common/options.js index c2c71a0fc5..b08784aa34 100755 --- a/lib/common/options.js +++ b/lib/common/options.js @@ -210,7 +210,7 @@ Options.defaults = { interval: 0, minify: { collapseBooleanAttributes: true, - collapseWhitespace: true, + collapseWhitespace: false, decodeEntities: true, minifyCSS: true, minifyJS: true, From 23919a9e0114b0d9a5c0769ab3ce3d12fca48301 Mon Sep 17 00:00:00 2001 From: Atinux Date: Fri, 3 Nov 2017 17:14:05 +0100 Subject: [PATCH 219/316] feat: Add middleware as function --- lib/app/client.js | 1 + lib/app/server.js | 2 ++ test/basic.csr.test.js | 14 ++++++++++++++ test/basic.ssr.test.js | 11 +++++++++++ test/fixtures/basic/pages/fn-midd.vue | 17 +++++++++++++++++ 5 files changed, 45 insertions(+) create mode 100644 test/fixtures/basic/pages/fn-midd.vue diff --git a/lib/app/client.js b/lib/app/client.js index e247b63713..0c5a6ff3a7 100644 --- a/lib/app/client.js +++ b/lib/app/client.js @@ -159,6 +159,7 @@ function callMiddleware (Components, context, layout) { } midd = midd.map(name => { + if (typeof name === 'function') return name if (typeof middleware[name] !== 'function') { unknownMiddleware = true this.error({ statusCode: 500, message: 'Unknown middleware ' + name }) diff --git a/lib/app/server.js b/lib/app/server.js index 61175aac5e..fdf484b1da 100644 --- a/lib/app/server.js +++ b/lib/app/server.js @@ -103,6 +103,7 @@ export default async ssrContext => { */ let midd = <%= serialize(router.middleware, { isJSON: true }) %> midd = midd.map((name) => { + if (typeof name === 'function') return name if (typeof middleware[name] !== 'function') { ssrContext.error({ statusCode: 500, message: 'Unknown middleware ' + name }) } @@ -134,6 +135,7 @@ export default async ssrContext => { } }) midd = midd.map((name) => { + if (typeof name === 'function') return name if (typeof middleware[name] !== 'function') { app.context.error({ statusCode: 500, message: 'Unknown middleware ' + name }) } diff --git a/test/basic.csr.test.js b/test/basic.csr.test.js index 3840b95b10..ff0f278f1f 100644 --- a/test/basic.csr.test.js +++ b/test/basic.csr.test.js @@ -154,6 +154,20 @@ test('/meta', async t => { t.deepEqual(state.meta, [{ works: true }]) }) +test('/fn-midd', async t => { + await page.nuxt.navigate('/fn-midd', true) + + t.is(await page.$text('.title'), 'You need to ask the permission') + t.deepEqual(await page.nuxt.errorData(), { message: 'You need to ask the permission', statusCode: 403 }) +}) + +test('/fn-midd?please=true', async t => { + await page.nuxt.navigate('/fn-midd?please=true', true) + + const h1 = await page.$text('h1') + t.true(h1.includes('Date:')) +}) + // Close server and ask nuxt to stop listening to file changes test.after('Closing server and nuxt.js', t => { nuxt.close() diff --git a/test/basic.ssr.test.js b/test/basic.ssr.test.js index c487581f4f..268a45ea33 100755 --- a/test/basic.ssr.test.js +++ b/test/basic.ssr.test.js @@ -204,6 +204,17 @@ test('/meta', async t => { t.true(html.includes('"meta":[{"works":true}]')) }) +test('/fn-midd', async t => { + const err = await t.throws(rp(url('/fn-midd'), { resolveWithFullResponse: true })) + t.is(err.statusCode, 403) + t.true(err.response.body.includes('You need to ask the permission')) +}) + +test('/fn-midd?please=true', async t => { + const { html } = await nuxt.renderRoute('/fn-midd?please=true') + t.true(html.includes('

    Date:')) +}) + // Close server and ask nuxt to stop listening to file changes test.after('Closing server and nuxt.js', t => { nuxt.close() diff --git a/test/fixtures/basic/pages/fn-midd.vue b/test/fixtures/basic/pages/fn-midd.vue new file mode 100644 index 0000000000..1d2a4e4bb2 --- /dev/null +++ b/test/fixtures/basic/pages/fn-midd.vue @@ -0,0 +1,17 @@ + + + From e97bb1d099df31f620e34ed4c52bc0f7aeeba33c Mon Sep 17 00:00:00 2001 From: Atinux Date: Fri, 3 Nov 2017 17:24:20 +0100 Subject: [PATCH 220/316] fix: Handle middleware fn in nuxt.config.js --- lib/app/server.js | 2 +- lib/common/options.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/app/server.js b/lib/app/server.js index fdf484b1da..ac6f004409 100644 --- a/lib/app/server.js +++ b/lib/app/server.js @@ -101,7 +101,7 @@ export default async ssrContext => { /* ** Call global middleware (nuxt.config.js) */ - let midd = <%= serialize(router.middleware, { isJSON: true }) %> + let midd = <%= serialize(router.middleware).replace('middleware(', 'function(') %> midd = midd.map((name) => { if (typeof name === 'function') return name if (typeof middleware[name] !== 'function') { diff --git a/lib/common/options.js b/lib/common/options.js index b08784aa34..672a216c85 100755 --- a/lib/common/options.js +++ b/lib/common/options.js @@ -19,7 +19,7 @@ Options.from = function (_options) { if (options.loading === true) { delete options.loading } - if (options.router && typeof options.router.middleware === 'string') { + if (options.router && options.router.middleware && !Array.isArray(options.router.middleware)) { options.router.middleware = [options.router.middleware] } if (options.router && typeof options.router.base === 'string') { From 7e71de4d6e9f4f1b9d6dea508dbbfc8bd341b0ca Mon Sep 17 00:00:00 2001 From: Clark Du Date: Mon, 6 Nov 2017 10:16:26 +0800 Subject: [PATCH 221/316] refactor: add script in meta example --- examples/head-elements/pages/index.vue | 6 ++++++ examples/head-elements/static/about.js | 1 + examples/head-elements/static/body.js | 1 + examples/head-elements/static/defer.js | 1 + examples/head-elements/static/head.js | 1 + 5 files changed, 10 insertions(+) create mode 100644 examples/head-elements/static/about.js create mode 100644 examples/head-elements/static/body.js create mode 100644 examples/head-elements/static/defer.js create mode 100644 examples/head-elements/static/head.js diff --git a/examples/head-elements/pages/index.vue b/examples/head-elements/pages/index.vue index a613b81b47..b77ebe973f 100755 --- a/examples/head-elements/pages/index.vue +++ b/examples/head-elements/pages/index.vue @@ -11,6 +11,12 @@ export default { title: 'Home page 🚀', meta: [ { hid: 'description', name: 'description', content: 'Home page description' } + ], + script: [ + { src: '/head.js' }, + // will be supported in the near future + { src: '/body.js', body: true }, + { src: '/defer.js', defer: undefined } ] } } diff --git a/examples/head-elements/static/about.js b/examples/head-elements/static/about.js new file mode 100644 index 0000000000..464cf12450 --- /dev/null +++ b/examples/head-elements/static/about.js @@ -0,0 +1 @@ +console.log('about.js loaded!') // eslint-disable-line no-console diff --git a/examples/head-elements/static/body.js b/examples/head-elements/static/body.js new file mode 100644 index 0000000000..7469d61dc5 --- /dev/null +++ b/examples/head-elements/static/body.js @@ -0,0 +1 @@ +console.log('body.js loaded!') // eslint-disable-line no-console diff --git a/examples/head-elements/static/defer.js b/examples/head-elements/static/defer.js new file mode 100644 index 0000000000..9437a02b35 --- /dev/null +++ b/examples/head-elements/static/defer.js @@ -0,0 +1 @@ +console.log('defer.js loaded!') // eslint-disable-line no-console diff --git a/examples/head-elements/static/head.js b/examples/head-elements/static/head.js new file mode 100644 index 0000000000..6869a2c47a --- /dev/null +++ b/examples/head-elements/static/head.js @@ -0,0 +1 @@ +console.log('head.js loaded!') // eslint-disable-line no-console From bacac23d03f3ce5076c53b353c1adc4155595914 Mon Sep 17 00:00:00 2001 From: Clark Du Date: Mon, 6 Nov 2017 10:30:37 +0800 Subject: [PATCH 222/316] refactor: documentation and adjust example name --- examples/head-elements/README.md | 3 --- examples/meta-info/README.md | 13 +++++++++++++ .../components/twitter-head-card.vue | 0 .../{head-elements => meta-info}/nuxt.config.js | 0 examples/{head-elements => meta-info}/package.json | 0 .../{head-elements => meta-info}/pages/about.vue | 0 .../{head-elements => meta-info}/pages/index.vue | 0 .../{head-elements => meta-info}/static/about.js | 0 .../{head-elements => meta-info}/static/body.js | 0 .../{head-elements => meta-info}/static/defer.js | 0 .../{head-elements => meta-info}/static/head.js | 0 11 files changed, 13 insertions(+), 3 deletions(-) delete mode 100644 examples/head-elements/README.md create mode 100644 examples/meta-info/README.md rename examples/{head-elements => meta-info}/components/twitter-head-card.vue (100%) rename examples/{head-elements => meta-info}/nuxt.config.js (100%) rename examples/{head-elements => meta-info}/package.json (100%) rename examples/{head-elements => meta-info}/pages/about.vue (100%) rename examples/{head-elements => meta-info}/pages/index.vue (100%) rename examples/{head-elements => meta-info}/static/about.js (100%) rename examples/{head-elements => meta-info}/static/body.js (100%) rename examples/{head-elements => meta-info}/static/defer.js (100%) rename examples/{head-elements => meta-info}/static/head.js (100%) diff --git a/examples/head-elements/README.md b/examples/head-elements/README.md deleted file mode 100644 index 1b7d3962d2..0000000000 --- a/examples/head-elements/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# Updating headers with Nuxt.js - -https://nuxtjs.org/examples/seo-html-head diff --git a/examples/meta-info/README.md b/examples/meta-info/README.md new file mode 100644 index 0000000000..9832e65a42 --- /dev/null +++ b/examples/meta-info/README.md @@ -0,0 +1,13 @@ +# Manage your app's meta information + +Nuxt.js uses [vue-meta](https://github.com/declandewet/vue-meta) to manage page meta info (such as: meta, title, link, style, script) of your application. + +## Example + +SEO: https://nuxtjs.org/examples/seo-html-head + +## Documentation + +Nuxt.js: https://nuxtjs.org/guide/views#html-head + +vue-meta: https://github.com/declandewet/vue-meta#table-of-contents diff --git a/examples/head-elements/components/twitter-head-card.vue b/examples/meta-info/components/twitter-head-card.vue similarity index 100% rename from examples/head-elements/components/twitter-head-card.vue rename to examples/meta-info/components/twitter-head-card.vue diff --git a/examples/head-elements/nuxt.config.js b/examples/meta-info/nuxt.config.js similarity index 100% rename from examples/head-elements/nuxt.config.js rename to examples/meta-info/nuxt.config.js diff --git a/examples/head-elements/package.json b/examples/meta-info/package.json similarity index 100% rename from examples/head-elements/package.json rename to examples/meta-info/package.json diff --git a/examples/head-elements/pages/about.vue b/examples/meta-info/pages/about.vue similarity index 100% rename from examples/head-elements/pages/about.vue rename to examples/meta-info/pages/about.vue diff --git a/examples/head-elements/pages/index.vue b/examples/meta-info/pages/index.vue similarity index 100% rename from examples/head-elements/pages/index.vue rename to examples/meta-info/pages/index.vue diff --git a/examples/head-elements/static/about.js b/examples/meta-info/static/about.js similarity index 100% rename from examples/head-elements/static/about.js rename to examples/meta-info/static/about.js diff --git a/examples/head-elements/static/body.js b/examples/meta-info/static/body.js similarity index 100% rename from examples/head-elements/static/body.js rename to examples/meta-info/static/body.js diff --git a/examples/head-elements/static/defer.js b/examples/meta-info/static/defer.js similarity index 100% rename from examples/head-elements/static/defer.js rename to examples/meta-info/static/defer.js diff --git a/examples/head-elements/static/head.js b/examples/meta-info/static/head.js similarity index 100% rename from examples/head-elements/static/head.js rename to examples/meta-info/static/head.js From e7b6fe8b6376f48683c9f51018f5041ab651715c Mon Sep 17 00:00:00 2001 From: Clark Du Date: Mon, 6 Nov 2017 11:16:23 +0800 Subject: [PATCH 223/316] feat: add element-ui example --- examples/with-element-ui/layouts/default.vue | 10 ++ examples/with-element-ui/nuxt.config.js | 15 +++ examples/with-element-ui/package.json | 18 ++++ examples/with-element-ui/pages/index.vue | 100 ++++++++++++++++++ .../with-element-ui/plugins/element-ui.js | 7 ++ 5 files changed, 150 insertions(+) create mode 100644 examples/with-element-ui/layouts/default.vue create mode 100644 examples/with-element-ui/nuxt.config.js create mode 100644 examples/with-element-ui/package.json create mode 100644 examples/with-element-ui/pages/index.vue create mode 100644 examples/with-element-ui/plugins/element-ui.js diff --git a/examples/with-element-ui/layouts/default.vue b/examples/with-element-ui/layouts/default.vue new file mode 100644 index 0000000000..184d6f6fd3 --- /dev/null +++ b/examples/with-element-ui/layouts/default.vue @@ -0,0 +1,10 @@ + diff --git a/examples/with-element-ui/nuxt.config.js b/examples/with-element-ui/nuxt.config.js new file mode 100644 index 0000000000..643f79ee78 --- /dev/null +++ b/examples/with-element-ui/nuxt.config.js @@ -0,0 +1,15 @@ +module.exports = { + /* + ** Global CSS + */ + css: [ + 'element-ui/lib/theme-default/index.css' + ], + + /* + ** Add element-ui in our app, see plugins/element-ui.js file + */ + plugins: [ + '@/plugins/element-ui' + ] +} diff --git a/examples/with-element-ui/package.json b/examples/with-element-ui/package.json new file mode 100644 index 0000000000..d5696a30ea --- /dev/null +++ b/examples/with-element-ui/package.json @@ -0,0 +1,18 @@ +{ + "name": "with-element-ui", + "version": "1.0.0", + "license": "MIT", + "dependencies": { + "element-ui": "^1.4.9", + "nuxt": "latest" + }, + "scripts": { + "dev": "nuxt", + "build": "nuxt build", + "start": "nuxt start" + }, + "devDependencies": { + "node-sass": "^4.6.0", + "sass-loader": "^6.0.6" + } +} diff --git a/examples/with-element-ui/pages/index.vue b/examples/with-element-ui/pages/index.vue new file mode 100644 index 0000000000..69c4a92771 --- /dev/null +++ b/examples/with-element-ui/pages/index.vue @@ -0,0 +1,100 @@ + + + + + diff --git a/examples/with-element-ui/plugins/element-ui.js b/examples/with-element-ui/plugins/element-ui.js new file mode 100644 index 0000000000..cb618add96 --- /dev/null +++ b/examples/with-element-ui/plugins/element-ui.js @@ -0,0 +1,7 @@ +import Vue from 'vue' +import Element from 'element-ui/lib/element-ui.common' +import locale from 'element-ui/lib/locale/lang/en' + +export default () => { + Vue.use(Element, { locale }) +} From 59ad4780377e748c9fb83d4a25927b0da06781fa Mon Sep 17 00:00:00 2001 From: Gomah Date: Mon, 6 Nov 2017 18:36:28 +1100 Subject: [PATCH 224/316] Add subFolders option for generate --- lib/builder/generator.js | 11 +++++++++-- lib/common/options.js | 1 + 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/builder/generator.js b/lib/builder/generator.js index 42cddada32..7b46a94c72 100644 --- a/lib/builder/generator.js +++ b/lib/builder/generator.js @@ -179,8 +179,15 @@ export default class Generator { } } - let path = join(route, sep, 'index.html') // /about -> /about/index.html - path = (path === '/404/index.html') ? '/404.html' : path // /404 -> /404.html + let path + + if (this.options.generate.subFolders) { + path = join(route, sep, 'index.html') // /about -> /about/index.html + path = path === '/404/index.html' ? '/404.html' : path // /404 -> /404.html + } else { + path = + route.length > 1 ? join(sep, route + '.html') : join(sep, 'index.html') + } // Call hook to let user update the path & html const page = { route, path, html } diff --git a/lib/common/options.js b/lib/common/options.js index 672a216c85..42d7963f13 100755 --- a/lib/common/options.js +++ b/lib/common/options.js @@ -208,6 +208,7 @@ Options.defaults = { routes: [], concurrency: 500, interval: 0, + subFolders: true, minify: { collapseBooleanAttributes: true, collapseWhitespace: false, From a7a5aea0032ef79ccc567984efbd9ef01ea8a90b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Chopin?= Date: Mon, 6 Nov 2017 10:43:52 +0100 Subject: [PATCH 225/316] Update comment --- examples/meta-info/pages/index.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/meta-info/pages/index.vue b/examples/meta-info/pages/index.vue index b77ebe973f..17854a3aa8 100755 --- a/examples/meta-info/pages/index.vue +++ b/examples/meta-info/pages/index.vue @@ -14,7 +14,7 @@ export default { ], script: [ { src: '/head.js' }, - // will be supported in the near future + // Supported since 1.0 { src: '/body.js', body: true }, { src: '/defer.js', defer: undefined } ] From 97772467ba05a12da291734cb37eec38c8583c89 Mon Sep 17 00:00:00 2001 From: Atinux Date: Mon, 6 Nov 2017 13:32:43 +0100 Subject: [PATCH 226/316] package: Upgrade dependencies --- package.json | 14 ++++++------- start/package.json | 8 +++---- yarn.lock | 52 ++++++++++++++++++++++++++-------------------- 3 files changed, 41 insertions(+), 33 deletions(-) diff --git a/package.json b/package.json index ced6834a43..03c2648b67 100644 --- a/package.json +++ b/package.json @@ -95,7 +95,7 @@ "open-in-editor": "^2.2.0", "opencollective": "^1.0.3", "pify": "^3.0.0", - "postcss": "^6.0.13", + "postcss": "^6.0.14", "postcss-cssnext": "^3.0.2", "postcss-import": "^11.0.0", "postcss-loader": "^2.0.8", @@ -109,12 +109,12 @@ "source-map-support": "^0.5.0", "uglifyjs-webpack-plugin": "^1.0.1", "url-loader": "^0.6.2", - "vue": "^2.5.2", - "vue-loader": "^13.3.0", - "vue-meta": "^1.2.0", + "vue": "^2.5.3", + "vue-loader": "^13.4.0", + "vue-meta": "^1.3.1", "vue-router": "^3.0.1", - "vue-server-renderer": "^2.5.2", - "vue-template-compiler": "^2.5.2", + "vue-server-renderer": "^2.5.3", + "vue-template-compiler": "^2.5.3", "vuex": "^3.0.1", "webpack": "^3.8.1", "webpack-bundle-analyzer": "^2.9.0", @@ -155,7 +155,7 @@ "rollup-plugin-replace": "^2.0.0", "rollup-watch": "^4.3.1", "std-mocks": "^1.0.1", - "uglify-js": "^3.1.6" + "uglify-js": "^3.1.7" }, "collective": { "type": "opencollective", diff --git a/start/package.json b/start/package.json index 9bb31292aa..573cdeffca 100644 --- a/start/package.json +++ b/start/package.json @@ -50,8 +50,8 @@ "pretty-error": "^2.1.1", "minimist": "^1.2.0", "lodash": "^4.17.4", - "hash-sum": "^1.0.2", "debug": "^3.1.0", + "hash-sum": "^1.0.2", "chalk": "^2.3.0", "ansi-html": "^0.0.7", "serialize-javascript": "^1.4.0", @@ -60,12 +60,12 @@ "serve-static": "^1.13.1", "compression": "^1.7.1", "fs-extra": "^4.0.2", - "vue-server-renderer": "^2.5.2", + "vue-server-renderer": "^2.5.3", "@nuxtjs/youch": "^3.1.0", "source-map": "^0.6.1", "connect": "^3.6.5", - "vue": "^2.5.2", - "vue-meta": "^1.2.0", + "vue": "^2.5.3", + "vue-meta": "^1.3.1", "lru-cache": "^4.1.1", "server-destroy": "^1.0.1", "open-in-editor": "^2.2.0" diff --git a/yarn.lock b/yarn.lock index a950b8b34a..a52d59d04e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2113,9 +2113,9 @@ deep-is@~0.1.3: version "0.1.3" resolved "https://registry.yarnpkg.com/deep-is/-/deep-is-0.1.3.tgz#b369d6fb5dbc13eecf524f91b070feedc357cf34" -deepmerge@^1.5.0: - version "1.5.2" - resolved "https://registry.yarnpkg.com/deepmerge/-/deepmerge-1.5.2.tgz#10499d868844cdad4fee0842df8c7f6f0c95a753" +deepmerge@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/deepmerge/-/deepmerge-2.0.1.tgz#25c1c24f110fb914f80001b925264dd77f3f4312" default-require-extensions@^1.0.0: version "1.0.0" @@ -5429,6 +5429,14 @@ postcss@^6.0.0, postcss@^6.0.1, postcss@^6.0.11, postcss@^6.0.13, postcss@^6.0.5 source-map "^0.6.1" supports-color "^4.4.0" +postcss@^6.0.14: + version "6.0.14" + resolved "https://registry.yarnpkg.com/postcss/-/postcss-6.0.14.tgz#5534c72114739e75d0afcf017db853099f562885" + dependencies: + chalk "^2.3.0" + source-map "^0.6.1" + supports-color "^4.4.0" + prelude-ls@~1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54" @@ -6679,9 +6687,9 @@ uglify-js@^2.6, uglify-js@^2.8.29: optionalDependencies: uglify-to-browserify "~1.0.0" -uglify-js@^3.1.6: - version "3.1.6" - resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.1.6.tgz#918832602036e95d2318e11f27ee8461a8592c5d" +uglify-js@^3.1.7: + version "3.1.7" + resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.1.7.tgz#13379168b7fcf132ed977254a7802e0a294b1ffb" dependencies: commander "~2.11.0" source-map "~0.6.1" @@ -6891,9 +6899,9 @@ vue-hot-reload-api@^2.2.0: version "2.2.0" resolved "https://registry.yarnpkg.com/vue-hot-reload-api/-/vue-hot-reload-api-2.2.0.tgz#9a21b35ced3634434a43ee80efb7350ea8fb206d" -vue-loader@^13.3.0: - version "13.3.0" - resolved "https://registry.yarnpkg.com/vue-loader/-/vue-loader-13.3.0.tgz#3bf837d490ba5dea6fc07e0835ffa6c688c8af33" +vue-loader@^13.4.0: + version "13.4.0" + resolved "https://registry.yarnpkg.com/vue-loader/-/vue-loader-13.4.0.tgz#44aa7eef4fb1be89fbc37193ad33b8253417c4b9" dependencies: consolidate "^0.14.0" hash-sum "^1.0.2" @@ -6909,11 +6917,11 @@ vue-loader@^13.3.0: vue-style-loader "^3.0.0" vue-template-es2015-compiler "^1.6.0" -vue-meta@^1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/vue-meta/-/vue-meta-1.2.0.tgz#f4cedccaae566ea0a27f052820dc076510d0080c" +vue-meta@^1.3.1: + version "1.3.1" + resolved "https://registry.yarnpkg.com/vue-meta/-/vue-meta-1.3.1.tgz#1c46c9af6119c61934a5b2783538b062c03be2c7" dependencies: - deepmerge "^1.5.0" + deepmerge "^2.0.0" lodash.isplainobject "^4.0.6" object-assign "^4.1.1" @@ -6921,9 +6929,9 @@ vue-router@^3.0.1: version "3.0.1" resolved "https://registry.yarnpkg.com/vue-router/-/vue-router-3.0.1.tgz#d9b05ad9c7420ba0f626d6500d693e60092cc1e9" -vue-server-renderer@^2.5.2: - version "2.5.2" - resolved "https://registry.yarnpkg.com/vue-server-renderer/-/vue-server-renderer-2.5.2.tgz#c96a4368caa3fd298a528f1bf40632d8f696ff25" +vue-server-renderer@^2.5.3: + version "2.5.3" + resolved "https://registry.yarnpkg.com/vue-server-renderer/-/vue-server-renderer-2.5.3.tgz#cac10b4a9d147b04cf70cd8bc3ac95f5e630794b" dependencies: chalk "^1.1.3" hash-sum "^1.0.2" @@ -6941,9 +6949,9 @@ vue-style-loader@^3.0.0: hash-sum "^1.0.2" loader-utils "^1.0.2" -vue-template-compiler@^2.5.2: - version "2.5.2" - resolved "https://registry.yarnpkg.com/vue-template-compiler/-/vue-template-compiler-2.5.2.tgz#6f198ebc677b8f804315cd33b91e849315ae7177" +vue-template-compiler@^2.5.3: + version "2.5.3" + resolved "https://registry.yarnpkg.com/vue-template-compiler/-/vue-template-compiler-2.5.3.tgz#ab631b0694e211a6aaf0d800102b37836aae36a4" dependencies: de-indent "^1.0.2" he "^1.1.0" @@ -6952,9 +6960,9 @@ vue-template-es2015-compiler@^1.6.0: version "1.6.0" resolved "https://registry.yarnpkg.com/vue-template-es2015-compiler/-/vue-template-es2015-compiler-1.6.0.tgz#dc42697133302ce3017524356a6c61b7b69b4a18" -vue@^2.5.2: - version "2.5.2" - resolved "https://registry.yarnpkg.com/vue/-/vue-2.5.2.tgz#fd367a87bae7535e47f9dc5c9ec3b496e5feb5a4" +vue@^2.5.3: + version "2.5.3" + resolved "https://registry.yarnpkg.com/vue/-/vue-2.5.3.tgz#e1a3b1f49b6e93e574ce040b95cbc873912fecc1" vuex@^3.0.1: version "3.0.1" From 4cfc8f5c49bb6444019b48143ce63e7fa351188d Mon Sep 17 00:00:00 2001 From: Atinux Date: Mon, 6 Nov 2017 13:33:03 +0100 Subject: [PATCH 227/316] example: Update defer attribute --- examples/meta-info/pages/index.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/meta-info/pages/index.vue b/examples/meta-info/pages/index.vue index 17854a3aa8..84b1fc33b9 100755 --- a/examples/meta-info/pages/index.vue +++ b/examples/meta-info/pages/index.vue @@ -16,7 +16,7 @@ export default { { src: '/head.js' }, // Supported since 1.0 { src: '/body.js', body: true }, - { src: '/defer.js', defer: undefined } + { src: '/defer.js', defer: '' } ] } } From 07eab4c643f889de694a994f4f70a28b22be54bc Mon Sep 17 00:00:00 2001 From: Atinux Date: Mon, 6 Nov 2017 13:33:19 +0100 Subject: [PATCH 228/316] feat: Handle body scripts from vue-meta --- lib/core/meta.js | 5 ++++- lib/core/renderer.js | 5 +++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/core/meta.js b/lib/core/meta.js index 8975894324..8264a506ab 100644 --- a/lib/core/meta.js +++ b/lib/core/meta.js @@ -45,7 +45,8 @@ export default class MetaRenderer { meta = { HTML_ATTRS: '', BODY_ATTRS: '', - HEAD: '' + HEAD: '', + BODY_SCRIPTS: '' } // Get vue-meta context const m = await this.getMeta(url) @@ -55,6 +56,8 @@ export default class MetaRenderer { meta.BODY_ATTRS = m.bodyAttrs.text() // HEAD tags meta.HEAD = m.meta.text() + m.title.text() + m.link.text() + m.style.text() + m.script.text() + m.noscript.text() + // BODY_SCRIPTS + meta.BODY_SCRIPTS = m.script.text({ body: true }) // Resources Hints meta.resourceHints = '' // Resource Hints diff --git a/lib/core/renderer.js b/lib/core/renderer.js index f9d0209e4d..cbf0ffe521 100644 --- a/lib/core/renderer.js +++ b/lib/core/renderer.js @@ -488,8 +488,8 @@ export default class Renderer { const ENV = this.options.env if (this.noSSR || spa) { - const { HTML_ATTRS, BODY_ATTRS, HEAD, resourceHints } = await this.metaRenderer.render(context) - const APP = `
    ${this.resources.loadingHTML}
    ` + const { HTML_ATTRS, BODY_ATTRS, HEAD, BODY_SCRIPTS, resourceHints } = await this.metaRenderer.render(context) + const APP = `
    ${this.resources.loadingHTML}
    ` + BODY_SCRIPTS // Detect 404 errors if (url.includes(this.options.build.publicPath) || url.includes('__webpack')) { @@ -528,6 +528,7 @@ export default class Renderer { } APP += `` APP += context.renderScripts() + APP += m.script.text({ body: true }) HEAD += context.renderStyles() From 46eac50d8760155454b8512db19cf6ba1ba0b64a Mon Sep 17 00:00:00 2001 From: Atinux Date: Mon, 6 Nov 2017 13:49:24 +0100 Subject: [PATCH 229/316] tests: Add tests for body scripts --- test/basic.csr.test.js | 2 ++ test/basic.ssr.test.js | 5 +++++ test/fixtures/basic/pages/head.vue | 3 +++ test/fixtures/basic/static/body.js | 2 ++ 4 files changed, 12 insertions(+) create mode 100644 test/fixtures/basic/static/body.js diff --git a/test/basic.csr.test.js b/test/basic.csr.test.js index ff0f278f1f..7955899218 100644 --- a/test/basic.csr.test.js +++ b/test/basic.csr.test.js @@ -69,9 +69,11 @@ test('/store', async t => { }) test('/head', async t => { + const msg = new Promise((resolve) => page.on('console', (msg) => resolve(msg.text))) await page.nuxt.navigate('/head', true) const metas = await page.$$attr('meta', 'content') + t.is(await msg, 'Body script!') t.is(await page.title(), 'My title - Nuxt.js') t.is(await page.$text('h1'), 'I can haz meta tags') t.is(metas[0], 'my meta') diff --git a/test/basic.ssr.test.js b/test/basic.ssr.test.js index 268a45ea33..9b9a4d62a8 100755 --- a/test/basic.ssr.test.js +++ b/test/basic.ssr.test.js @@ -55,12 +55,17 @@ test('/store', async t => { }) test('/head', async t => { + stdMocks.use() const window = await nuxt.renderAndGetWindow(url('/head'), { virtualConsole: false }) const html = window.document.body.innerHTML const metas = window.document.getElementsByTagName('meta') + stdMocks.restore() + const { stdout } = stdMocks.flush() + t.is(stdout[0], 'Body script!\n') t.is(window.document.title, 'My title - Nuxt.js') t.is(metas[0].getAttribute('content'), 'my meta') t.true(html.includes('

    I can haz meta tags

    ')) + t.true(html.includes(' + + diff --git a/examples/layout-transitions/pages/users.vue b/examples/layout-transitions/pages/users.vue index d608a5ad7f..f7399382cf 100644 --- a/examples/layout-transitions/pages/users.vue +++ b/examples/layout-transitions/pages/users.vue @@ -6,7 +6,7 @@ Next > Next >
      -
    • +
    • {{ user.first_name }} {{ user.last_name }}
    • @@ -19,15 +19,20 @@ import axios from 'axios' export default { + // Watch for $route.query.page to call Component methods (asyncData, fetch, validate, layout, etc.) + watchQuery: ['page'], + // Key for (transitions) + key: (to) => to.fullPath, + // Called to know which transition to apply transition(to, from) { if (!from) return 'slide-left' return +to.query.page < +from.query.page ? 'slide-right' : 'slide-left' }, async asyncData({ query }) { - const page = query.page || 1 + const page = +(query.page || 1) const { data } = await axios.get(`https://reqres.in/api/users?page=${page}`) return { - page: +data.page, + page, totalPages: data.total_pages, users: data.data } From e80a77782af1369923617cd4c70d7ea3f8d872b5 Mon Sep 17 00:00:00 2001 From: Atinux Date: Mon, 6 Nov 2017 18:29:45 +0100 Subject: [PATCH 231/316] update: Use path by default or Page.key --- lib/app/components/nuxt.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/app/components/nuxt.js b/lib/app/components/nuxt.js index 068b1b16e5..f0bad06587 100644 --- a/lib/app/components/nuxt.js +++ b/lib/app/components/nuxt.js @@ -29,7 +29,11 @@ export default { if (typeof this.nuxtChildKey !== 'undefined' || this.$route.matched.length > 1) { return this.nuxtChildKey || compile(this.$route.matched[0].path)(this.$route.params) } - return this.$route.fullPath.split('#')[0] + const Component = this.$route.matched[0].components.default + if (Component && Component.options && Component.options.key) { + return (typeof Component.options.key === 'function' ? Component.options.key(this.$route) : Component.options.key) + } + return this.$route.path } }, components: { From fb44c2eb8e606739f038a7871f332d175348bf0a Mon Sep 17 00:00:00 2001 From: Atinux Date: Mon, 6 Nov 2017 18:30:15 +0100 Subject: [PATCH 232/316] fix: Fix Layouts transitions --- lib/app/App.js | 10 +++++++--- lib/app/components/nuxt-child.js | 21 ++------------------- 2 files changed, 9 insertions(+), 22 deletions(-) diff --git a/lib/app/App.js b/lib/app/App.js index d4725ee730..dd52c9d252 100644 --- a/lib/app/App.js +++ b/lib/app/App.js @@ -18,16 +18,20 @@ export default { head: <%= serialize(head).replace('titleTemplate(', 'function(') %>, render(h, props) { <% if (loading) { %>const loadingEl = h('nuxt-loading', { ref: 'loading' })<% } %> - const layoutEl = h(this.nuxt.err ? 'nuxt' : this.layout, { + const layoutEl = h(this.layout || 'nuxt') + const templateEl = h('div', { + domProps: { + id: '__layout' + }, key: this.layoutName - }) + }, [ layoutEl ]) const transitionEl = h('transition', { props: { name: '<%= layoutTransition.name %>', mode: '<%= layoutTransition.mode %>' } - }, [ layoutEl ]) + }, [ templateEl ]) return h('div',{ domProps: { diff --git a/lib/app/components/nuxt-child.js b/lib/app/components/nuxt-child.js index 9fc6f6a8ed..52b5c2a78b 100644 --- a/lib/app/components/nuxt-child.js +++ b/lib/app/components/nuxt-child.js @@ -2,26 +2,11 @@ export default { name: 'nuxt-child', functional: true, render (h, { parent, data }) { - const nuxt = parent.$root.nuxt - const component = parent.$route.matched[0].components.default - - const layoutUid = parent._uid - const layoutName = component.options ? component.options.layout : null - - // If we're changing layout render the stored vnode - if (nuxt._layoutUid === layoutUid && - nuxt._layoutName !== layoutName - ) { - return nuxt._childVnode - } - - nuxt._layoutUid = layoutUid - nuxt._layoutName = layoutName - data.nuxtChild = true const _parent = parent const transitions = parent.$nuxt.nuxt.transitions const defaultTransition = parent.$nuxt.nuxt.defaultTransition + let depth = 0 while (parent) { if (parent.$vnode && parent.$vnode.data.nuxtChild) { @@ -44,14 +29,12 @@ export default { } }) - nuxt._childVnode = h('transition', { + return h('transition', { props: transitionProps, on: listeners }, [ h('router-view', data) ]) - - return nuxt._childVnode } } From 3d49d8d2905796f063b171fdd935da721622fe05 Mon Sep 17 00:00:00 2001 From: Atinux Date: Mon, 6 Nov 2017 18:30:37 +0100 Subject: [PATCH 233/316] feat: Add Page.watchQuery --- lib/app/client.js | 64 ++++++++++++++++++++++++++++++++++------------- lib/app/server.js | 2 +- lib/app/utils.js | 55 +++++++++------------------------------- 3 files changed, 59 insertions(+), 62 deletions(-) diff --git a/lib/app/client.js b/lib/app/client.js index 0c5a6ff3a7..dc91da015c 100644 --- a/lib/app/client.js +++ b/lib/app/client.js @@ -6,13 +6,14 @@ import { sanitizeComponent, resolveRouteComponents, getMatchedComponents, - getChangedComponentsInstances, + getMatchedComponentsInstances, flatMapComponents, setContext, middlewareSeries, promisify, getLocation, - compile + compile, + getQueryDiff } from './utils' const noopData = () => { return {} } @@ -20,7 +21,6 @@ const noopFetch = () => {} // Global shared references let _lastPaths = [] -let _lastComponentsFiles = [] let app let router <% if (store) { %>let store<% } %> @@ -99,6 +99,8 @@ function mapTransitions(Components, to, from) { async function loadAsyncComponents (to, from, next) { // Check if route path changed (this._pathChanged), only if the page is not an error (for validate()) this._pathChanged = !!app.nuxt.err || from.path !== to.path + this._queryChanged = JSON.stringify(to.query) !== JSON.stringify(from.query) + this._diffQuery = (this._queryChanged ? getQueryDiff(to.query, from.query) : []) <% if (loading) { %> if (this._pathChanged && this.$loading.start) { @@ -107,7 +109,24 @@ async function loadAsyncComponents (to, from, next) { <% } %> try { - await resolveRouteComponents(to) + const Components = await resolveRouteComponents(to) + <% if (loading) { %> + if (!this._pathChanged && this._queryChanged) { + // Add a marker on each component that it needs to refresh or not + const startLoader = Components.some((Component) => { + const watchQuery = Component.options.watchQuery + if (watchQuery === true) return true + if (Array.isArray(watchQuery)) { + return watchQuery.some((key) => this._diffQuery[key]) + } + return false + }) + if (startLoader && this.$loading.start) { + this.$loading.start() + } + } + <% } %> + // Call next() next() } catch (err) { err = err || {} @@ -172,7 +191,8 @@ function callMiddleware (Components, context, layout) { } async function render (to, from, next) { - if (this._pathChanged === false) return next() + if (this._pathChanged === false && this._queryChanged === false) return next() + console.log('Render') // nextCalled is true when redirected let nextCalled = false @@ -259,7 +279,20 @@ async function render (to, from, next) { await Promise.all(Components.map((Component, i) => { // Check if only children route changed Component._path = compile(to.matched[i].path)(to.params) - if (!this._hadError && this._isMounted && Component._path === _lastPaths[i]) { + Component._dataRefresh = false + // Check if Component need to be refreshed (call asyncData & fetch) + // Only if its slug has changed or is watch query changes + if (this._pathChanged && Component._path !== _lastPaths[i]) { + Component._dataRefresh = true + } else if (!this._pathChanged && this._queryChanged) { + const watchQuery = Component.options.watchQuery + if (watchQuery === true) { + Component._dataRefresh = true + } else if (Array.isArray(watchQuery)) { + Component._dataRefresh = watchQuery.some((key) => this._diffQuery[key]) + } + } + if (!this._hadError && this._isMounted && !Component._dataRefresh) { return Promise.resolve() } @@ -347,26 +380,22 @@ function showNextPage(to) { // When navigating on a different route but the same component is used, Vue.js // Will not update the instance data, so we have to update $data ourselves -function fixPrepatch (to, from) { - if (this._pathChanged === false) return +function fixPrepatch(to, ___) { + if (this._pathChanged === false && this._queryChanged === false) return Vue.nextTick(() => { - const instances = getChangedComponentsInstances(to, from) + const instances = getMatchedComponentsInstances(to) - var dlen = to.matched.length - instances.length - _lastComponentsFiles = instances.map((instance, i) => { - if (!instance) return ''; - - if (_lastPaths[dlen + i] === instance.constructor._path && typeof instance.constructor.options.data === 'function') { + instances.forEach((instance, i) => { + if (!instance) return + if (instance.constructor._dataRefresh && _lastPaths[i] === instance.constructor._path && typeof instance.constructor.options.data === 'function') { + console.log('Refresh instance', instance) const newData = instance.constructor.options.data.call(instance) for (let key in newData) { Vue.set(instance.$data, key, newData[key]) } } - - return instance.constructor.options.__file }) - showNextPage.call(this, to) <% if (isDev) { %> // Hot reloading @@ -523,7 +552,6 @@ async function mountApp(__app) { if (Components.length) { _app.setTransitions(mapTransitions(Components, router.currentRoute)) _lastPaths = router.currentRoute.matched.map(route => compile(route.path)(router.currentRoute.params)) - _lastComponentsFiles = Components.map(Component => Component.options.__file) } // Initialize error handler diff --git a/lib/app/server.js b/lib/app/server.js index ac6f004409..df23de17c2 100644 --- a/lib/app/server.js +++ b/lib/app/server.js @@ -70,7 +70,7 @@ export default async ssrContext => { const renderErrorPage = async () => { // Load layout for error page let errLayout = (typeof NuxtError.layout === 'function' ? NuxtError.layout(app.context) : NuxtError.layout) - ssrContext.nuxt.layout = errLayout || '' + ssrContext.nuxt.layout = errLayout || 'default' await _app.loadLayout(errLayout) _app.setLayout(errLayout) await beforeRender() diff --git a/lib/app/utils.js b/lib/app/utils.js index 11f5f8378b..a7b6603de0 100644 --- a/lib/app/utils.js +++ b/lib/app/utils.js @@ -65,48 +65,6 @@ export function getMatchedComponentsInstances(route) { })) } -function getRouteRecordWithParamNames (route) { - return route.matched.map(m => { - var paramNames = m.path.match(new RegExp(':[^\\/\\?]+', 'g')) - if (paramNames !== null) { - paramNames = paramNames.map(function (name) { - return name.substring(1) - }) - } - return { - routeRecord: m, - paramNames: paramNames - } - }) -} - -export function getChangedComponentsInstances (to, from) { - var records = getRouteRecordWithParamNames(to) - var r = [] - var parentChange = false - for (var i = 0; i < records.length; i++ ) { - var paramNames = records[i].paramNames - var instances = records[i].routeRecord.instances - instances = Object.keys(instances).map(function (key) { - return instances[key] - }) - if (parentChange) { - r = [].concat(r, instances) - } else if (paramNames !== null) { - for (var pi in paramNames) { - var name = paramNames[pi] - if (to.params[name] !== from.params[name]) { - parentChange = true - r = [].concat(r, instances) - break - } - } - } - } - return r -} - - export function flatMapComponents(route, fn) { return Array.prototype.concat.apply([], route.matched.map(function (m, index) { return Object.keys(m.components).map(function (key) { @@ -116,7 +74,7 @@ export function flatMapComponents(route, fn) { } export async function resolveRouteComponents(route) { - await Promise.all( + return await Promise.all( flatMapComponents(route, async (Component, _, match, key) => { // If component is a function, resolve it if (typeof Component === 'function' && !Component.options) { @@ -255,6 +213,17 @@ export function compile(str, options) { return tokensToFunction(parse(str, options)) } +export function getQueryDiff(toQuery, fromQuery) { + const diff = {} + const queries = { ...toQuery, ...fromQuery } + for (const k in queries) { + if (String(toQuery[k]) !== String(fromQuery[k])) { + diff[k] = true + } + } + return diff +} + /** * The main path matching regexp utility. * From f5fa44d8aa8da987ac7e223dbf4101eebf666c5a Mon Sep 17 00:00:00 2001 From: Atinux Date: Mon, 6 Nov 2017 18:30:50 +0100 Subject: [PATCH 234/316] debug: Show PostCSS config only when used --- lib/common/options.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/common/options.js b/lib/common/options.js index 672a216c85..bf7b14651c 100755 --- a/lib/common/options.js +++ b/lib/common/options.js @@ -109,7 +109,9 @@ Options.from = function (_options) { } } } else { - debug('Using PostCSS config from `build.postcss`') + if (Object.keys(options.build.postcss).length) { + debug('Using PostCSS config from `build.postcss`') + } // Normalize & Apply default plugins if (Array.isArray(options.build.postcss)) { options.build.postcss = { plugins: options.build.postcss } From 231ad4b4dccc3c250ff48b9c5dd8d8a7ddd906bd Mon Sep 17 00:00:00 2001 From: Clark Du Date: Tue, 7 Nov 2017 11:22:19 +0800 Subject: [PATCH 235/316] feat: add buefy example --- examples/with-buefy/assets/logo.png | Bin 0 -> 4252 bytes examples/with-buefy/nuxt.config.js | 11 +++++++++++ examples/with-buefy/package.json | 20 ++++++++++++++++++++ examples/with-buefy/pages/about.vue | 3 +++ examples/with-buefy/pages/index.vue | 25 +++++++++++++++++++++++++ examples/with-buefy/plugins/buefy.js | 4 ++++ 6 files changed, 63 insertions(+) create mode 100644 examples/with-buefy/assets/logo.png create mode 100644 examples/with-buefy/nuxt.config.js create mode 100644 examples/with-buefy/package.json create mode 100644 examples/with-buefy/pages/about.vue create mode 100644 examples/with-buefy/pages/index.vue create mode 100644 examples/with-buefy/plugins/buefy.js diff --git a/examples/with-buefy/assets/logo.png b/examples/with-buefy/assets/logo.png new file mode 100644 index 0000000000000000000000000000000000000000..7f238b598c85d618ae0c601fec86455a2a1ed4e1 GIT binary patch literal 4252 zcmV;N5M%F&P)g` zMQS+^rII|YPa_znyK06zSH+#;sbvrYPbJ-$aIST{pJ152GFi-#g|FGax5DoN-#l6N znP8Z{O75z3{VsQE_oQAM(2rSB>QQRU zvXfygeLVz&U3Iqn8=TBG#8!!K*Cbf&uJ(bxb!UbDitto?d`>X@x=IFHmdF0)s+QTt zz*EWA#-FYm>9*QezkPnmi1MbyzC2lAUPBGRV5^K~6WASrA#4Kx-Mos5-dd~{>#wS~ zrQTH$#1{KL(I(eyzbDhOLkO36Hu;a2~U~Gh7 zn4s?0CQ+*2Co>X>_szN1Nor_(Z1>d@PC@}40}z-KH{!k$41cfY(cbk5XTjh_#Q=Qm z&g9Fz+KE53?<6R}|2Q206qpk$PKMWacMuH!Q}U7zwoR(-S$(Z4#`=HN*weM@R0Qor z`g=n}zJ6e_SO|vSE4QyJ((JlQt~7x9X;LQ>OUOTV_q;~0Cm5`sTJt$-se=G$ zizeQ8c~V#9?`RDMk9(JxlePk#gy3~{%0kD`ryJRoa)qm+VQ^HSpN?kS2CLa0X!9~y zA^~L+0F<*xu=#?tdw6g`W4KloYily2o7dM(S;OOFTQAC-L;~9Y=(GB~^4-G405eXT zCKcVhrd|<$c@mD#{IaoI99>E6UNwo)P4p~V2T7k zzhg3+7aWGv?rM6*i9z4xi&S!_WA2RQ``CWo9GO273AWfTp}c5eVHh{+k7wS6`5HFG zDL5B`87uZPR_M~Z;KS>&_!jIgc0Z$V%< zU!jDXRBVb>@SY2q8xJv70S3Pdw1v}QH`Imz%a4Isn6fy@phck>X#!@3j-uSt!OyMBKL_fZ7nEw~s)IH%~C+^))O387J0O0K?hY+Y?R&JH-wJ=G6~rR&!;Rir z5}<)lXEh-4J~wS{W9Zk7?oPexg4ZC$D>x?tkQu;Pz3C7~=!-V1g#wV}^^Oe9VGKAk zPN*1#>l-m^>tWi7gw_xskZ{1fUQ&OUs~BoWx>jS&IN?-ahX`n`fZh=64pN~4q=o<~ z>CzLS)g7&K4+F?J!Bg+pO{&YoNaosuG?VI3L+m@ok@};iq+ze_na$=oh9RxHdJ)Vx zvC7HKoz@DDi|vn=l2SjFR9QTiFo2BH4P=~3%#)dWImE`^0?oW`cOWI@AG&#FT&JBg z7~V8zpk(6}( zIZ?-8{~W+@u|kD^ee_Di+;o_+3Lgf?Q&R8KUtiC53}u6DE8GT>eG=;z1_12Lv-mUHg=QxOvv0|JLAM^UJo31z`TN6j=c-Pm`m=l;Y&KQNW zzzep*G-(Y?NfAiE7op@fRL?vHo!RJ<^9cJR@-8>R7^{#>Du#vta|k^p<$FH3qB9z1 z7{k}rLi`!$HyP`o8@fTlK!VLjPf10BPx%=$iD6Jb2Hx`Jg8jD0$v{lU5&Ep&jBZ{< zg6)^({bM6DhT%?40$YVU<9sV-Zaa*_q)ux}dL!=3%wVV=?FR4n!k=-52^h;}hyh%g zIFynuKN(ir)jr)AEEbEn_$~h1B9EdN=ou#tVMs~Ai%>xHJFOTpdTPJ{g7+RLkdv1u z{;4osDJf{6wCb|y!=N?k-LvlDe-Q6VDE^T!y(#I@+u%hgx@p4jwmAoP#wq`iaqc^Y z#iZg(Nj)5R#P3yB@^oP6)(&q=zJ&cACr2JI6UPz$lyu{HN!QTelw-JDsmA{x-fIza z^C7G!68@AF!;4UGVW=2tTN!tfr^20a2J+!;ky$2qmsEg60+`pu(ZS`dO}H`8GR~0v z7x**Idl8H^*w#n*XZ0QjUWDQu@bsn$rli<0#B`K$)Dm!q5DW%9QcJmCC5*$z|FvY# zzn1TvrCPR^YvJsRe+6U?4>>5DcUU27;ltf6#$Ui#oOk#&Vtga!m?`n1%7^MRh>?!$A+P%p=HHx{-wJw(XPMc z6z%kgsHvayHM5Pa9lR}WSMR@e0K>f(pPV-wsj8cJbrX~FU+%7f%aR_5{*=#J+qU(r zv2EM7xwdVOZQHhSzPo4rM(JhutHn$^>6=t;-O5QPZ{un{eNAmmq~N##PJyTHOVI_l&f;}LqIsSwGt>_0!cZr@Qrc)|LK}jWAl9PY*j~E*O1LVf_hgBAC7Z}+2qGI%iVR&Rz z)6(;wjjWin*Jr;Ks-th~^Vf!BL9vwAoXjaK0}KwnQ9lRSq?FA&Yi ziTbH9z-k(rcJQ>&fKsyZXCG!zDHRjf!J%Qg!+=o;p02L3WeZDV^#KJi0s6xLd+f|h8_HVB-MxMEhXLjpdIH6;@d}^1 zPFP1*&oLDB_xw zDkd&)N9Jz9z=rWKz-k+scks2B?~x>D=F=aBx2nwg!^*&bt8UTuj>0k@2H3r)3Gaw` zM;HBJsBdaTyTOI(=5AwSe%i z0S0Yj%>l)YM^#HIYRF+ItEyYMPfo|$>kG^jt~a$MR3PuyTxxabi@XR)`HF_ z(y>LzLKrciBvRSKq2Uo#Q&%*dGgt339|o!9iAWcn{dr;r2@J5f3pWu`d52S5c><9N z?i><-kvx7@HgTS+V?$Miwz}q^65b}$VUSKGF5V#o6@ed!KYwdZ7+Tvq;jh;mP$Cx< zkSm5O+rrkUBgg|{@K|?Pc{59WCLR0s<5y5vxf+%bjAaJ~n0NST_*`p`(1=r4!At^%mICtu)w|@YR3xw*{!x=x!4UP?k6+O~9AZAjQV1QyH z(X(5;QwSb{hBhY*P|oopkT>S2S!K-j0@-$MElF4wMGWQmL+Qk~#rdKa2MW+0kuLmq=?<2f0b&t)Usn&c>4+F1(TxyK zP%YEQ=vY}*ZE98lh%cgFMCK$@5T*1LB&P6Ysa^#+fRg%+fi1VF> +

      About

      + diff --git a/examples/with-buefy/pages/index.vue b/examples/with-buefy/pages/index.vue new file mode 100644 index 0000000000..36c91c9994 --- /dev/null +++ b/examples/with-buefy/pages/index.vue @@ -0,0 +1,25 @@ + + + + diff --git a/examples/with-buefy/plugins/buefy.js b/examples/with-buefy/plugins/buefy.js new file mode 100644 index 0000000000..9fc091d0b9 --- /dev/null +++ b/examples/with-buefy/plugins/buefy.js @@ -0,0 +1,4 @@ +import Vue from 'vue' +import Buefy from 'buefy' + +Vue.use(Buefy) From 3ccc57502bc2cfda22aadfe1e8726ab2a2bb09f4 Mon Sep 17 00:00:00 2001 From: Clark Du Date: Tue, 7 Nov 2017 12:04:21 +0800 Subject: [PATCH 236/316] fix: basic.csr /head error --- lib/app/client.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/app/client.js b/lib/app/client.js index dc91da015c..cbb43f7f43 100644 --- a/lib/app/client.js +++ b/lib/app/client.js @@ -192,7 +192,6 @@ function callMiddleware (Components, context, layout) { async function render (to, from, next) { if (this._pathChanged === false && this._queryChanged === false) return next() - console.log('Render') // nextCalled is true when redirected let nextCalled = false From f626acf1f95a5cd4d97c300e011f7c646aaff105 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Tue, 7 Nov 2017 13:16:29 +0330 Subject: [PATCH 237/316] refactor: simplify internal compilers --- lib/builder/builder.js | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/lib/builder/builder.js b/lib/builder/builder.js index 91f3a66746..fd970b902f 100644 --- a/lib/builder/builder.js +++ b/lib/builder/builder.js @@ -30,7 +30,7 @@ export default class Builder { this.options = nuxt.options // Fields that set on build - this.compiler = null + this.compilers = [] this.webpackDevMiddleware = null this.webpackHotMiddleware = null @@ -408,23 +408,19 @@ export default class Builder { compilersOptions.push(dllWebpackConfig.call(this, clientConfig)) } - // Simulate webpack multi compiler interface - // Separate compilers are simpler, safer and faster - this.compilers = [] - // Initialize shared FS and Cache const sharedFS = this.options.dev && new MFS() const sharedCache = {} // Initialize compilers - compilersOptions.forEach(compilersOption => { + this.compilers = compilersOptions.map(compilersOption => { const compiler = webpack(compilersOption) // In dev, write files in memory FS (except for DLL) if (sharedFS && !compiler.name.includes('-dll')) { compiler.outputFileSystem = sharedFS } compiler.cache = sharedCache - this.compilers.push(compiler) + return compiler }) // Start Builds From 80fb65040b14849a7fad33bfae8647fdbae722ec Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Tue, 7 Nov 2017 13:17:50 +0330 Subject: [PATCH 238/316] fix(builder): add hash to generated plugin names A plugin named `bootstrap` results importing bootstrap jquery! --- lib/builder/builder.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/builder/builder.js b/lib/builder/builder.js index fd970b902f..c670b5b742 100644 --- a/lib/builder/builder.js +++ b/lib/builder/builder.js @@ -63,7 +63,7 @@ export default class Builder { return { src: this.nuxt.resolvePath(p.src), ssr: (p.ssr !== false), - name: basename(p.src, extname(p.src)).replace(/[^a-zA-Z?\d\s:]/g, '') + name: basename(p.src, extname(p.src)).replace(/[^a-zA-Z?\d\s:]/g, '') + '_' + hash(p.src) } }) } From 1eee113d6dd1865a011bc9aea3de56fe392552a0 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Tue, 7 Nov 2017 13:32:10 +0330 Subject: [PATCH 239/316] chore(builder): better naming for plugin generated aliases Help developers tracing exact source of warns/errors --- lib/app/index.js | 7 +++++-- lib/builder/builder.js | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/app/index.js b/lib/app/index.js index f780d4e168..986ad113ec 100644 --- a/lib/app/index.js +++ b/lib/app/index.js @@ -10,8 +10,11 @@ import Nuxt from './components/nuxt.js' import App from '<%= appPath %>' import { setContext, getLocation } from './utils' <% if (store) { %>import { createStore } from './store.js'<% } %> -<% plugins.forEach(plugin => { %>import <%= plugin.name %> from '<%= plugin.name %>' -<% }) %> + +/* Plugins */ + +<% plugins.forEach(plugin => { %>// <%= plugin.src %><%= (plugin.ssr===false) ? ' (Only included in client bundle)' : '' %> +import <%= plugin.name %> from '<%= plugin.name %>'<% }) %> // Component: Vue.component(NoSSR.name, NoSSR) diff --git a/lib/builder/builder.js b/lib/builder/builder.js index c670b5b742..38265c5ed1 100644 --- a/lib/builder/builder.js +++ b/lib/builder/builder.js @@ -63,7 +63,7 @@ export default class Builder { return { src: this.nuxt.resolvePath(p.src), ssr: (p.ssr !== false), - name: basename(p.src, extname(p.src)).replace(/[^a-zA-Z?\d\s:]/g, '') + '_' + hash(p.src) + name: basename(p.src, extname(p.src)).replace(/[^a-zA-Z?\d\s:]/g, '') + '_plugin_' + hash(p.src) } }) } From e05da610c8da1ef5fc5fc810e42c36ae113c2f01 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Tue, 7 Nov 2017 14:01:53 +0330 Subject: [PATCH 240/316] add caniuse-lite dependency To avoid peer dep warning for postcss-cssnext --- package.json | 1 + yarn.lock | 344 +++++++++++++++++++++++++++------------------------ 2 files changed, 183 insertions(+), 162 deletions(-) diff --git a/package.json b/package.json index 03c2648b67..a05a00d5b7 100644 --- a/package.json +++ b/package.json @@ -70,6 +70,7 @@ "babel-core": "^6.26.0", "babel-loader": "^7.1.2", "babel-preset-vue-app": "^1.3.1", + "caniuse-lite": "^1.0.30000758", "chalk": "^2.3.0", "chokidar": "^1.7.0", "clone": "^2.1.1", diff --git a/yarn.lock b/yarn.lock index a52d59d04e..7bac0dbd3e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -38,6 +38,59 @@ imurmurhash "^0.1.4" slide "^1.1.5" +"@babel/code-frame@7.0.0-beta.31", "@babel/code-frame@^7.0.0-beta.31": + version "7.0.0-beta.31" + resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.0.0-beta.31.tgz#473d021ecc573a2cce1c07d5b509d5215f46ba35" + dependencies: + chalk "^2.0.0" + esutils "^2.0.2" + js-tokens "^3.0.0" + +"@babel/helper-function-name@7.0.0-beta.31": + version "7.0.0-beta.31" + resolved "https://registry.yarnpkg.com/@babel/helper-function-name/-/helper-function-name-7.0.0-beta.31.tgz#afe63ad799209989348b1109b44feb66aa245f57" + dependencies: + "@babel/helper-get-function-arity" "7.0.0-beta.31" + "@babel/template" "7.0.0-beta.31" + "@babel/traverse" "7.0.0-beta.31" + "@babel/types" "7.0.0-beta.31" + +"@babel/helper-get-function-arity@7.0.0-beta.31": + version "7.0.0-beta.31" + resolved "https://registry.yarnpkg.com/@babel/helper-get-function-arity/-/helper-get-function-arity-7.0.0-beta.31.tgz#1176d79252741218e0aec872ada07efb2b37a493" + dependencies: + "@babel/types" "7.0.0-beta.31" + +"@babel/template@7.0.0-beta.31": + version "7.0.0-beta.31" + resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.0.0-beta.31.tgz#577bb29389f6c497c3e7d014617e7d6713f68bda" + dependencies: + "@babel/code-frame" "7.0.0-beta.31" + "@babel/types" "7.0.0-beta.31" + babylon "7.0.0-beta.31" + lodash "^4.2.0" + +"@babel/traverse@7.0.0-beta.31", "@babel/traverse@^7.0.0-beta.31": + version "7.0.0-beta.31" + resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.0.0-beta.31.tgz#db399499ad74aefda014f0c10321ab255134b1df" + dependencies: + "@babel/code-frame" "7.0.0-beta.31" + "@babel/helper-function-name" "7.0.0-beta.31" + "@babel/types" "7.0.0-beta.31" + babylon "7.0.0-beta.31" + debug "^3.0.1" + globals "^10.0.0" + invariant "^2.2.0" + lodash "^4.2.0" + +"@babel/types@7.0.0-beta.31", "@babel/types@^7.0.0-beta.31": + version "7.0.0-beta.31" + resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.0.0-beta.31.tgz#42c9c86784f674c173fb21882ca9643334029de4" + dependencies: + esutils "^2.0.2" + lodash "^4.2.0" + to-fast-properties "^2.0.0" + "@concordance/react@^1.0.0": version "1.0.0" resolved "https://registry.yarnpkg.com/@concordance/react/-/react-1.0.0.tgz#fcf3cad020e5121bfd1c61d05bc3516aac25f734" @@ -52,9 +105,9 @@ mustache "^2.3.0" stack-trace "0.0.10" -"@types/node@^6.0.46": - version "6.0.90" - resolved "https://registry.yarnpkg.com/@types/node/-/node-6.0.90.tgz#0ed74833fa1b73dcdb9409dcb1c97ec0a8b13b02" +"@types/node@*": + version "8.0.49" + resolved "https://registry.yarnpkg.com/@types/node/-/node-8.0.49.tgz#417f86ab4829c629fe561779ee48751e0fe2a11b" abab@^1.0.3: version "1.0.4" @@ -97,11 +150,7 @@ acorn@^4.0.3: version "4.0.13" resolved "https://registry.yarnpkg.com/acorn/-/acorn-4.0.13.tgz#105495ae5361d697bd195c825192e1ad7f253787" -acorn@^5.0.0, acorn@^5.1.1, acorn@^5.1.2: - version "5.1.2" - resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.1.2.tgz#911cb53e036807cf0fa778dc5d370fbd864246d7" - -acorn@^5.2.1: +acorn@^5.0.0, acorn@^5.1.1, acorn@^5.1.2, acorn@^5.2.1: version "5.2.1" resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.2.1.tgz#317ac7821826c22c702d66189ab8359675f135d7" @@ -112,8 +161,8 @@ agent-base@^4.1.0: es6-promisify "^5.0.0" ajv-keywords@^2.0.0, ajv-keywords@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-2.1.0.tgz#a296e17f7bfae7c1ce4f7e0de53d29cb32162df0" + version "2.1.1" + resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-2.1.1.tgz#617997fc5f60576894c435f940d819e135b80762" ajv@^4.9.1: version "4.11.8" @@ -161,6 +210,10 @@ ansi-escapes@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-2.0.0.tgz#5bae52be424878dd9783e8910e3fc2922e83c81b" +ansi-escapes@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-3.0.0.tgz#ec3e8b4e9f8064fc02c3ac9b65f1c275bda8ef92" + ansi-html@0.0.7, ansi-html@^0.0.7: version "0.0.7" resolved "https://registry.yarnpkg.com/ansi-html/-/ansi-html-0.0.7.tgz#813584021962a9e9e6fd039f940d12f56ca7859e" @@ -274,8 +327,8 @@ arrify@^1.0.0, arrify@^1.0.1: resolved "https://registry.yarnpkg.com/arrify/-/arrify-1.0.1.tgz#898508da2226f380df904728456849c1501a4b0d" asn1.js@^4.0.0: - version "4.9.1" - resolved "https://registry.yarnpkg.com/asn1.js/-/asn1.js-4.9.1.tgz#48ba240b45a9280e94748990ba597d216617fd40" + version "4.9.2" + resolved "https://registry.yarnpkg.com/asn1.js/-/asn1.js-4.9.2.tgz#8117ef4f7ed87cd8f89044b5bff97ac243a16c9a" dependencies: bn.js "^4.0.0" inherits "^2.0.1" @@ -312,8 +365,8 @@ async@^1.4.0: resolved "https://registry.yarnpkg.com/async/-/async-1.5.2.tgz#ec6a61ae56480c0c3cb241c95618e20892f9672a" async@^2.1.2, async@^2.4.1: - version "2.5.0" - resolved "https://registry.yarnpkg.com/async/-/async-2.5.0.tgz#843190fd6b7357a0b9e1c956edddd5ec8462b54d" + version "2.6.0" + resolved "https://registry.yarnpkg.com/async/-/async-2.6.0.tgz#61a29abb6fcc026fea77e56d1c6ec53a795951f4" dependencies: lodash "^4.14.0" @@ -454,14 +507,6 @@ aws4@^1.2.1, aws4@^1.6.0: version "1.6.0" resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.6.0.tgz#83ef5ca860b2b32e4a0deedee8c771b9db57471e" -babel-code-frame@7.0.0-beta.0: - version "7.0.0-beta.0" - resolved "https://registry.yarnpkg.com/babel-code-frame/-/babel-code-frame-7.0.0-beta.0.tgz#418a7b5f3f7dc9a4670e61b1158b4c5661bec98d" - dependencies: - chalk "^2.0.0" - esutils "^2.0.2" - js-tokens "^3.0.0" - babel-code-frame@^6.11.0, babel-code-frame@^6.22.0, babel-code-frame@^6.26.0: version "6.26.0" resolved "https://registry.yarnpkg.com/babel-code-frame/-/babel-code-frame-6.26.0.tgz#63fd43f7dc1e3bb7ce35947db8fe369a3f58c74b" @@ -495,13 +540,13 @@ babel-core@^6.17.0, babel-core@^6.26.0: source-map "^0.5.6" babel-eslint@^8.0.1: - version "8.0.1" - resolved "https://registry.yarnpkg.com/babel-eslint/-/babel-eslint-8.0.1.tgz#5d718be7a328625d006022eb293ed3008cbd6346" + version "8.0.2" + resolved "https://registry.yarnpkg.com/babel-eslint/-/babel-eslint-8.0.2.tgz#e44fb9a037d749486071d52d65312f5c20aa7530" dependencies: - babel-code-frame "7.0.0-beta.0" - babel-traverse "7.0.0-beta.0" - babel-types "7.0.0-beta.0" - babylon "7.0.0-beta.22" + "@babel/code-frame" "^7.0.0-beta.31" + "@babel/traverse" "^7.0.0-beta.31" + "@babel/types" "^7.0.0-beta.31" + babylon "^7.0.0-beta.31" babel-generator@^6.1.0, babel-generator@^6.18.0, babel-generator@^6.26.0: version "6.26.0" @@ -550,15 +595,6 @@ babel-helper-explode-assignable-expression@^6.24.1: babel-traverse "^6.24.1" babel-types "^6.24.1" -babel-helper-function-name@7.0.0-beta.0: - version "7.0.0-beta.0" - resolved "https://registry.yarnpkg.com/babel-helper-function-name/-/babel-helper-function-name-7.0.0-beta.0.tgz#d1b6779b647e5c5c31ebeb05e13b998e4d352d56" - dependencies: - babel-helper-get-function-arity "7.0.0-beta.0" - babel-template "7.0.0-beta.0" - babel-traverse "7.0.0-beta.0" - babel-types "7.0.0-beta.0" - babel-helper-function-name@^6.24.1: version "6.24.1" resolved "https://registry.yarnpkg.com/babel-helper-function-name/-/babel-helper-function-name-6.24.1.tgz#d3475b8c03ed98242a25b48351ab18399d3580a9" @@ -569,12 +605,6 @@ babel-helper-function-name@^6.24.1: babel-traverse "^6.24.1" babel-types "^6.24.1" -babel-helper-get-function-arity@7.0.0-beta.0: - version "7.0.0-beta.0" - resolved "https://registry.yarnpkg.com/babel-helper-get-function-arity/-/babel-helper-get-function-arity-7.0.0-beta.0.tgz#9d1ab7213bb5efe1ef1638a8ea1489969b5a8b6e" - dependencies: - babel-types "7.0.0-beta.0" - babel-helper-get-function-arity@^6.24.1: version "6.24.1" resolved "https://registry.yarnpkg.com/babel-helper-get-function-arity/-/babel-helper-get-function-arity-6.24.1.tgz#8f7782aa93407c41d3aa50908f89b031b1b6853d" @@ -644,10 +674,6 @@ babel-loader@^7.1.2: loader-utils "^1.0.2" mkdirp "^0.5.1" -babel-messages@7.0.0-beta.0: - version "7.0.0-beta.0" - resolved "https://registry.yarnpkg.com/babel-messages/-/babel-messages-7.0.0-beta.0.tgz#6df01296e49fc8fbd0637394326a167f36da817b" - babel-messages@^6.23.0: version "6.23.0" resolved "https://registry.yarnpkg.com/babel-messages/-/babel-messages-6.23.0.tgz#f3cdf4703858035b2a2951c6ec5edf6c62f2630e" @@ -1030,15 +1056,6 @@ babel-runtime@^6.18.0, babel-runtime@^6.20.0, babel-runtime@^6.22.0, babel-runti core-js "^2.4.0" regenerator-runtime "^0.11.0" -babel-template@7.0.0-beta.0: - version "7.0.0-beta.0" - resolved "https://registry.yarnpkg.com/babel-template/-/babel-template-7.0.0-beta.0.tgz#85083cf9e4395d5e48bf5154d7a8d6991cafecfb" - dependencies: - babel-traverse "7.0.0-beta.0" - babel-types "7.0.0-beta.0" - babylon "7.0.0-beta.22" - lodash "^4.2.0" - babel-template@^6.16.0, babel-template@^6.24.1, babel-template@^6.26.0: version "6.26.0" resolved "https://registry.yarnpkg.com/babel-template/-/babel-template-6.26.0.tgz#de03e2d16396b069f46dd9fff8521fb1a0e35e02" @@ -1049,20 +1066,6 @@ babel-template@^6.16.0, babel-template@^6.24.1, babel-template@^6.26.0: babylon "^6.18.0" lodash "^4.17.4" -babel-traverse@7.0.0-beta.0: - version "7.0.0-beta.0" - resolved "https://registry.yarnpkg.com/babel-traverse/-/babel-traverse-7.0.0-beta.0.tgz#da14be9b762f62a2f060db464eaafdd8cd072a41" - dependencies: - babel-code-frame "7.0.0-beta.0" - babel-helper-function-name "7.0.0-beta.0" - babel-messages "7.0.0-beta.0" - babel-types "7.0.0-beta.0" - babylon "7.0.0-beta.22" - debug "^3.0.1" - globals "^10.0.0" - invariant "^2.2.0" - lodash "^4.2.0" - babel-traverse@^6.18.0, babel-traverse@^6.24.1, babel-traverse@^6.26.0: version "6.26.0" resolved "https://registry.yarnpkg.com/babel-traverse/-/babel-traverse-6.26.0.tgz#46a9cbd7edcc62c8e5c064e2d2d8d0f4035766ee" @@ -1077,14 +1080,6 @@ babel-traverse@^6.18.0, babel-traverse@^6.24.1, babel-traverse@^6.26.0: invariant "^2.2.2" lodash "^4.17.4" -babel-types@7.0.0-beta.0: - version "7.0.0-beta.0" - resolved "https://registry.yarnpkg.com/babel-types/-/babel-types-7.0.0-beta.0.tgz#eb8b6e556470e6dcc4aef982d79ad229469b5169" - dependencies: - esutils "^2.0.2" - lodash "^4.2.0" - to-fast-properties "^2.0.0" - babel-types@^6.18.0, babel-types@^6.19.0, babel-types@^6.24.1, babel-types@^6.26.0: version "6.26.0" resolved "https://registry.yarnpkg.com/babel-types/-/babel-types-6.26.0.tgz#a3b073f94ab49eb6fa55cd65227a334380632497" @@ -1094,9 +1089,9 @@ babel-types@^6.18.0, babel-types@^6.19.0, babel-types@^6.24.1, babel-types@^6.26 lodash "^4.17.4" to-fast-properties "^1.0.3" -babylon@7.0.0-beta.22: - version "7.0.0-beta.22" - resolved "https://registry.yarnpkg.com/babylon/-/babylon-7.0.0-beta.22.tgz#74f0ad82ed7c7c3cfeab74cf684f815104161b65" +babylon@7.0.0-beta.31, babylon@^7.0.0-beta.31: + version "7.0.0-beta.31" + resolved "https://registry.yarnpkg.com/babylon/-/babylon-7.0.0-beta.31.tgz#7ec10f81e0e456fd0f855ad60fa30c2ac454283f" babylon@^6.1.0, babylon@^6.18.0: version "6.18.0" @@ -1280,11 +1275,11 @@ browserslist@^1.3.6, browserslist@^1.5.2, browserslist@^1.7.6: electron-to-chromium "^1.2.7" browserslist@^2.0.0, browserslist@^2.1.2, browserslist@^2.5.1: - version "2.5.1" - resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-2.5.1.tgz#68e4bc536bbcc6086d62843a2ffccea8396821c6" + version "2.7.0" + resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-2.7.0.tgz#dc375dc70048fec3d989042a35022342902eff00" dependencies: - caniuse-lite "^1.0.30000744" - electron-to-chromium "^1.3.24" + caniuse-lite "^1.0.30000757" + electron-to-chromium "^1.3.27" buf-compare@^1.0.0: version "1.0.1" @@ -1408,12 +1403,12 @@ caniuse-api@^2.0.0: lodash.uniq "^4.5.0" caniuse-db@^1.0.30000529, caniuse-db@^1.0.30000634, caniuse-db@^1.0.30000639: - version "1.0.30000755" - resolved "https://registry.yarnpkg.com/caniuse-db/-/caniuse-db-1.0.30000755.tgz#a08c547c39dbe4ad07dcca9763fcbbff0c891de0" + version "1.0.30000758" + resolved "https://registry.yarnpkg.com/caniuse-db/-/caniuse-db-1.0.30000758.tgz#a235627b1922e878b63164942c991b84de92c810" -caniuse-lite@^1.0.0, caniuse-lite@^1.0.30000744, caniuse-lite@^1.0.30000748: - version "1.0.30000755" - resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30000755.tgz#9ce5f6e06bd75ec8209abe8853c3beef02248d65" +caniuse-lite@^1.0.0, caniuse-lite@^1.0.30000748, caniuse-lite@^1.0.30000757, caniuse-lite@^1.0.30000758: + version "1.0.30000758" + resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30000758.tgz#e261140076651049cf6891ed4bc649b5c8c26c69" capture-stack-trace@^1.0.0: version "1.0.0" @@ -1898,8 +1893,8 @@ cryptiles@3.x.x: boom "5.x.x" crypto-browserify@^3.11.0: - version "3.11.1" - resolved "https://registry.yarnpkg.com/crypto-browserify/-/crypto-browserify-3.11.1.tgz#948945efc6757a400d6e5e5af47194d10064279f" + version "3.12.0" + resolved "https://registry.yarnpkg.com/crypto-browserify/-/crypto-browserify-3.12.0.tgz#396cf9f3137f03e4b8e532c58f698254e00f80ec" dependencies: browserify-cipher "^1.0.0" browserify-sign "^4.0.0" @@ -1911,12 +1906,13 @@ crypto-browserify@^3.11.0: pbkdf2 "^3.0.3" public-encrypt "^4.0.0" randombytes "^2.0.0" + randomfill "^1.0.3" crypto-random-string@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/crypto-random-string/-/crypto-random-string-1.0.0.tgz#a230f64f568310e1498009940790ec99545bca7e" -css-color-function@^1.3.0: +css-color-function@~1.3.3: version "1.3.3" resolved "https://registry.yarnpkg.com/css-color-function/-/css-color-function-1.3.3.tgz#8ed24c2c0205073339fafa004bc8c141fccb282e" dependencies: @@ -2079,12 +2075,6 @@ debug-log@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/debug-log/-/debug-log-1.0.1.tgz#2307632d4c04382b8df8a32f70b895046d52745f" -debug@2.2.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/debug/-/debug-2.2.0.tgz#f87057e995b1a1f6ae6a4960664137bc56f039da" - dependencies: - ms "0.7.1" - debug@2.6.9, debug@^2.2.0, debug@^2.4.1, debug@^2.6.8: version "2.6.9" resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f" @@ -2179,6 +2169,10 @@ detect-indent@^5.0.0: version "5.0.0" resolved "https://registry.yarnpkg.com/detect-indent/-/detect-indent-5.0.0.tgz#3871cc0a6a002e8c3e5b3cf7f336264675f06b9d" +detect-libc@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/detect-libc/-/detect-libc-1.0.2.tgz#71ad5d204bf17a6a6ca8f450c61454066ef461e1" + diffie-hellman@^5.0.0: version "5.0.2" resolved "https://registry.yarnpkg.com/diffie-hellman/-/diffie-hellman-5.0.2.tgz#b5835739270cfe26acf632099fded2a07f209e5e" @@ -2299,7 +2293,7 @@ ejs@^2.5.6: version "2.5.7" resolved "https://registry.yarnpkg.com/ejs/-/ejs-2.5.7.tgz#cc872c168880ae3c7189762fd5ffc00896c9518a" -electron-to-chromium@^1.2.7, electron-to-chromium@^1.3.24: +electron-to-chromium@^1.2.7, electron-to-chromium@^1.3.27: version "1.3.27" resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.27.tgz#78ecb8a399066187bb374eede35d9c70565a803d" @@ -2729,7 +2723,7 @@ extend@~3.0.0, extend@~3.0.1: version "3.0.1" resolved "https://registry.yarnpkg.com/extend/-/extend-3.0.1.tgz#a755ea7bc1adfcc5a31ce7e762dbaadc5e636444" -external-editor@^2.0.1: +external-editor@^2.0.1, external-editor@^2.0.4: version "2.0.5" resolved "https://registry.yarnpkg.com/external-editor/-/external-editor-2.0.5.tgz#52c249a3981b9ba187c7cacf5beb50bf1d91a6bc" dependencies: @@ -2753,11 +2747,11 @@ extract-text-webpack-plugin@^3.0.2: webpack-sources "^1.0.1" extract-zip@^1.6.5: - version "1.6.5" - resolved "https://registry.yarnpkg.com/extract-zip/-/extract-zip-1.6.5.tgz#99a06735b6ea20ea9b705d779acffcc87cff0440" + version "1.6.6" + resolved "https://registry.yarnpkg.com/extract-zip/-/extract-zip-1.6.6.tgz#1290ede8d20d0872b429fd3f351ca128ec5ef85c" dependencies: concat-stream "1.6.0" - debug "2.2.0" + debug "2.6.9" mkdirp "0.5.0" yauzl "2.4.1" @@ -3093,8 +3087,8 @@ global-dirs@^0.1.0: ini "^1.3.4" globals@^10.0.0: - version "10.1.0" - resolved "https://registry.yarnpkg.com/globals/-/globals-10.1.0.tgz#4425a1881be0d336b4a823a82a7be725d5dd987c" + version "10.3.0" + resolved "https://registry.yarnpkg.com/globals/-/globals-10.3.0.tgz#716aba93657b56630b5a0e77de5ea8ac6215afaa" globals@^9.17.0, globals@^9.18.0: version "9.18.0" @@ -3401,10 +3395,6 @@ hullabaloo-config-manager@^1.1.0: resolve-from "^3.0.0" safe-buffer "^5.0.1" -iconv-lite@0.4.13: - version "0.4.13" - resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.13.tgz#1f88aba4ab0b1508e8312acc39345f36e992e2f2" - iconv-lite@0.4.19, iconv-lite@^0.4.17, iconv-lite@~0.4.13: version "0.4.19" resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.19.tgz#f7468f60135f5e5dad3399c0a81be9a1603a082b" @@ -3487,7 +3477,7 @@ ini@^1.3.4, ini@~1.3.0: version "1.3.4" resolved "https://registry.yarnpkg.com/ini/-/ini-1.3.4.tgz#0537cb79daf59b59a1a517dff706c86ec039162e" -inquirer@3.0.6, inquirer@^3.0.6: +inquirer@3.0.6: version "3.0.6" resolved "https://registry.yarnpkg.com/inquirer/-/inquirer-3.0.6.tgz#e04aaa9d05b7a3cb9b0f407d04375f0447190347" dependencies: @@ -3505,6 +3495,25 @@ inquirer@3.0.6, inquirer@^3.0.6: strip-ansi "^3.0.0" through "^2.3.6" +inquirer@^3.0.6: + version "3.3.0" + resolved "https://registry.yarnpkg.com/inquirer/-/inquirer-3.3.0.tgz#9dd2f2ad765dcab1ff0443b491442a20ba227dc9" + dependencies: + ansi-escapes "^3.0.0" + chalk "^2.0.0" + cli-cursor "^2.1.0" + cli-width "^2.0.0" + external-editor "^2.0.4" + figures "^2.0.0" + lodash "^4.3.0" + mute-stream "0.0.7" + run-async "^2.2.0" + rx-lite "^4.0.8" + rx-lite-aggregates "^4.0.8" + string-width "^2.1.0" + strip-ansi "^4.0.0" + through "^2.3.6" + interpret@^1.0.0: version "1.0.4" resolved "https://registry.yarnpkg.com/interpret/-/interpret-1.0.4.tgz#820cdd588b868ffb191a809506d6c9c8f212b1b0" @@ -4276,7 +4285,7 @@ minimatch@^3.0.0, minimatch@^3.0.2, minimatch@^3.0.3, minimatch@^3.0.4: dependencies: brace-expansion "^1.1.7" -minimist@0.0.8, minimist@~0.0.1: +minimist@0.0.8: version "0.0.8" resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.8.tgz#857fcabfc3397d2625b8228262e86aa7a011b05d" @@ -4284,6 +4293,10 @@ minimist@1.2.0, minimist@^1.1.3, minimist@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284" +minimist@~0.0.1: + version "0.0.10" + resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.10.tgz#de3f98543dbf96082be48ad1a0c7cda836301dcf" + mississippi@^1.3.0: version "1.3.0" resolved "https://registry.yarnpkg.com/mississippi/-/mississippi-1.3.0.tgz#d201583eb12327e3c5c1642a404a9cacf94e34f5" @@ -4322,10 +4335,6 @@ move-concurrently@^1.0.1: rimraf "^2.5.4" run-queue "^1.0.3" -ms@0.7.1: - version "0.7.1" - resolved "https://registry.yarnpkg.com/ms/-/ms-0.7.1.tgz#9cd13c03adbff25b65effde7ce864ee952017098" - ms@2.0.0, ms@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" @@ -4413,9 +4422,10 @@ node-libs-browser@^2.0.0: vm-browserify "0.0.4" node-pre-gyp@^0.6.36: - version "0.6.38" - resolved "https://registry.yarnpkg.com/node-pre-gyp/-/node-pre-gyp-0.6.38.tgz#e92a20f83416415bb4086f6d1fb78b3da73d113d" + version "0.6.39" + resolved "https://registry.yarnpkg.com/node-pre-gyp/-/node-pre-gyp-0.6.39.tgz#c00e96860b23c0e1420ac7befc5044e1d78d8649" dependencies: + detect-libc "^1.0.2" hawk "3.1.3" mkdirp "^0.5.1" nopt "^4.0.1" @@ -4755,10 +4765,10 @@ parse-ms@^1.0.0: resolved "https://registry.yarnpkg.com/parse-ms/-/parse-ms-1.0.1.tgz#56346d4749d78f23430ca0c713850aef91aa361d" parse5@^3.0.2: - version "3.0.2" - resolved "https://registry.yarnpkg.com/parse5/-/parse5-3.0.2.tgz#05eff57f0ef4577fb144a79f8b9a967a6cc44510" + version "3.0.3" + resolved "https://registry.yarnpkg.com/parse5/-/parse5-3.0.3.tgz#042f792ffdd36851551cf4e9e066b3874ab45b5c" dependencies: - "@types/node" "^6.0.46" + "@types/node" "*" parseurl@~1.3.2: version "1.3.2" @@ -4943,10 +4953,10 @@ postcss-calc@^6.0.0: reduce-css-calc "^2.0.0" postcss-color-function@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/postcss-color-function/-/postcss-color-function-4.0.0.tgz#7e0106f4f6a1ecb1ad5b3a8553ace5e828aae187" + version "4.0.1" + resolved "https://registry.yarnpkg.com/postcss-color-function/-/postcss-color-function-4.0.1.tgz#402b3f2cebc3f6947e618fb6be3654fbecef6444" dependencies: - css-color-function "^1.3.0" + css-color-function "~1.3.3" postcss "^6.0.1" postcss-message-helpers "^2.0.0" postcss-value-parser "^3.3.0" @@ -5421,15 +5431,7 @@ postcss@^5.0.10, postcss@^5.0.11, postcss@^5.0.12, postcss@^5.0.13, postcss@^5.0 source-map "^0.5.6" supports-color "^3.2.3" -postcss@^6.0.0, postcss@^6.0.1, postcss@^6.0.11, postcss@^6.0.13, postcss@^6.0.5, postcss@^6.0.6, postcss@^6.0.8: - version "6.0.13" - resolved "https://registry.yarnpkg.com/postcss/-/postcss-6.0.13.tgz#b9ecab4ee00c89db3ec931145bd9590bbf3f125f" - dependencies: - chalk "^2.1.0" - source-map "^0.6.1" - supports-color "^4.4.0" - -postcss@^6.0.14: +postcss@^6.0.0, postcss@^6.0.1, postcss@^6.0.11, postcss@^6.0.13, postcss@^6.0.14, postcss@^6.0.5, postcss@^6.0.6, postcss@^6.0.8: version "6.0.14" resolved "https://registry.yarnpkg.com/postcss/-/postcss-6.0.14.tgz#5534c72114739e75d0afcf017db853099f562885" dependencies: @@ -5450,8 +5452,8 @@ preserve@^0.2.0: resolved "https://registry.yarnpkg.com/preserve/-/preserve-0.2.0.tgz#815ed1f6ebc65926f865b310c0713bcb3315ce4b" prettier@^1.7.0: - version "1.7.4" - resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.7.4.tgz#5e8624ae9363c80f95ec644584ecdf55d74f93fa" + version "1.8.0" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.8.0.tgz#d9dc68277cf1ded816c8e8863ab47889c29ce9a6" pretty-error@^2.0.2, pretty-error@^2.1.1: version "2.1.1" @@ -5608,12 +5610,19 @@ randomatic@^1.1.3: is-number "^3.0.0" kind-of "^4.0.0" -randombytes@^2.0.0, randombytes@^2.0.1: +randombytes@^2.0.0, randombytes@^2.0.1, randombytes@^2.0.5: version "2.0.5" resolved "https://registry.yarnpkg.com/randombytes/-/randombytes-2.0.5.tgz#dc009a246b8d09a177b4b7a0ae77bc570f4b1b79" dependencies: safe-buffer "^5.1.0" +randomfill@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/randomfill/-/randomfill-1.0.3.tgz#b96b7df587f01dd91726c418f30553b1418e3d62" + dependencies: + randombytes "^2.0.5" + safe-buffer "^5.1.0" + range-parser@^1.0.3, range-parser@~1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/range-parser/-/range-parser-1.2.0.tgz#f49be6b487894ddc40dcc94a322f611092e00d5e" @@ -6067,6 +6076,16 @@ run-queue@^1.0.0, run-queue@^1.0.3: dependencies: aproba "^1.1.1" +rx-lite-aggregates@^4.0.8: + version "4.0.8" + resolved "https://registry.yarnpkg.com/rx-lite-aggregates/-/rx-lite-aggregates-4.0.8.tgz#753b87a89a11c95467c4ac1626c4efc4e05c67be" + dependencies: + rx-lite "*" + +rx-lite@*, rx-lite@^4.0.8: + version "4.0.8" + resolved "https://registry.yarnpkg.com/rx-lite/-/rx-lite-4.0.8.tgz#0b1e11af8bc44836f04a6407e92da42467b79444" + rx@^4.1.0: version "4.1.0" resolved "https://registry.yarnpkg.com/rx/-/rx-4.1.0.tgz#a5f13ff79ef3b740fe30aa803fb09f98805d4782" @@ -6243,7 +6262,7 @@ source-map@0.5.6: version "0.5.6" resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.6.tgz#75ce38f52bf0733c5a7f0c118d81334a2bb5f412" -source-map@0.5.x, source-map@^0.5.0, source-map@^0.5.3, source-map@^0.5.6, source-map@~0.5.1, source-map@~0.5.3, source-map@~0.5.6: +source-map@0.5.x, source-map@^0.5.0, source-map@^0.5.3, source-map@^0.5.6, source-map@~0.5.1, source-map@~0.5.6: version "0.5.7" resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc" @@ -6318,7 +6337,11 @@ stackframe@^1.0.3: version "1.0.4" resolved "https://registry.yarnpkg.com/stackframe/-/stackframe-1.0.4.tgz#357b24a992f9427cba6b545d96a14ed2cbca187b" -"statuses@>= 1.3.1 < 2", statuses@~1.3.1: +"statuses@>= 1.3.1 < 2": + version "1.4.0" + resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.4.0.tgz#bb73d446da2796106efcc1b601a253d6c46bd087" + +statuses@~1.3.1: version "1.3.1" resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.3.1.tgz#faf51b9eb74aaef3b3acf4ad5f61abf24cb7b93e" @@ -6378,7 +6401,7 @@ string-width@^1.0.1, string-width@^1.0.2: is-fullwidth-code-point "^1.0.0" strip-ansi "^3.0.0" -string-width@^2.0.0, string-width@^2.1.1: +string-width@^2.0.0, string-width@^2.1.0, string-width@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/string-width/-/string-width-2.1.1.tgz#ab93f27a8dc13d28cac815c462143a6d9012ae9e" dependencies: @@ -6665,15 +6688,15 @@ typedarray@^0.0.6: resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" uglify-es@^3.1.3: - version "3.1.5" - resolved "https://registry.yarnpkg.com/uglify-es/-/uglify-es-3.1.5.tgz#63bae0fd4f9feeda417fee7c0ff685a673819683" + version "3.1.8" + resolved "https://registry.yarnpkg.com/uglify-es/-/uglify-es-3.1.8.tgz#2f21a56871d6354dcc21469cc034c3967f14c5b1" dependencies: commander "~2.11.0" source-map "~0.6.1" -uglify-js@3.1.x: - version "3.1.5" - resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.1.5.tgz#4c1a6d53b2fe77e4710dd94631853effd3ff5143" +uglify-js@3.1.x, uglify-js@^3.1.7: + version "3.1.8" + resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.1.8.tgz#780d08b4f6782fe36ea5484d952362eddaf1d7b8" dependencies: commander "~2.11.0" source-map "~0.6.1" @@ -6687,13 +6710,6 @@ uglify-js@^2.6, uglify-js@^2.8.29: optionalDependencies: uglify-to-browserify "~1.0.0" -uglify-js@^3.1.7: - version "3.1.7" - resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.1.7.tgz#13379168b7fcf132ed977254a7802e0a294b1ffb" - dependencies: - commander "~2.11.0" - source-map "~0.6.1" - uglify-to-browserify@~1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/uglify-to-browserify/-/uglify-to-browserify-1.0.2.tgz#6e0924d6bda6b5afe349e39a6d632850a0f882b7" @@ -7020,11 +7036,11 @@ webpack-node-externals@^1.6.0: resolved "https://registry.yarnpkg.com/webpack-node-externals/-/webpack-node-externals-1.6.0.tgz#232c62ec6092b100635a3d29d83c1747128df9bd" webpack-sources@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-1.0.1.tgz#c7356436a4d13123be2e2426a05d1dad9cbe65cf" + version "1.0.2" + resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-1.0.2.tgz#d0148ec083b3b5ccef1035a6b3ec16442983b27a" dependencies: source-list-map "^2.0.0" - source-map "~0.5.3" + source-map "~0.6.1" webpack@^3.8.1: version "3.8.1" @@ -7058,10 +7074,10 @@ well-known-symbols@^1.0.0: resolved "https://registry.yarnpkg.com/well-known-symbols/-/well-known-symbols-1.0.0.tgz#73c78ae81a7726a8fa598e2880801c8b16225518" whatwg-encoding@^1.0.1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/whatwg-encoding/-/whatwg-encoding-1.0.2.tgz#bd68ad169c3cf55080562257714bf012e668a165" + version "1.0.3" + resolved "https://registry.yarnpkg.com/whatwg-encoding/-/whatwg-encoding-1.0.3.tgz#57c235bc8657e914d24e1a397d3c82daee0a6ba3" dependencies: - iconv-lite "0.4.13" + iconv-lite "0.4.19" whatwg-url@^6.3.0: version "6.3.0" @@ -7101,17 +7117,21 @@ window-size@0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/window-size/-/window-size-0.1.0.tgz#5438cd2ea93b202efa3a19fe8887aee7c94f9c9d" -wordwrap@0.0.2, wordwrap@~0.0.2: +wordwrap@0.0.2: version "0.0.2" resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-0.0.2.tgz#b79669bb42ecb409f83d583cad52ca17eaa1643f" +wordwrap@~0.0.2: + version "0.0.3" + resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-0.0.3.tgz#a3d5da6cd5c0bc0008d37234bbaf1bed63059107" + wordwrap@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-1.0.0.tgz#27584810891456a4171c8d0226441ade90cbcaeb" worker-farm@^1.4.1: - version "1.5.0" - resolved "https://registry.yarnpkg.com/worker-farm/-/worker-farm-1.5.0.tgz#adfdf0cd40581465ed0a1f648f9735722afd5c8d" + version "1.5.1" + resolved "https://registry.yarnpkg.com/worker-farm/-/worker-farm-1.5.1.tgz#8e9f4a7da4f3c595aa600903051b969390423fa1" dependencies: errno "^0.1.4" xtend "^4.0.1" @@ -7175,8 +7195,8 @@ ws@^2.3.1: ultron "~1.1.0" ws@^3.0.0: - version "3.2.0" - resolved "https://registry.yarnpkg.com/ws/-/ws-3.2.0.tgz#d5d3d6b11aff71e73f808f40cc69d52bb6d4a185" + version "3.3.0" + resolved "https://registry.yarnpkg.com/ws/-/ws-3.3.0.tgz#f8b948a1378af7efa702f5513da08dd516897c31" dependencies: async-limiter "~1.0.0" safe-buffer "~5.1.0" From 6dfe6604129b1eff7a6991d6b4259a723181de19 Mon Sep 17 00:00:00 2001 From: Atinux Date: Tue, 7 Nov 2017 11:47:55 +0100 Subject: [PATCH 241/316] fix: Implement TimeFixPlugin by @egoist to avoid webpack rebuilds --- lib/builder/builder.js | 5 +---- lib/builder/webpack/base.config.js | 4 ++++ lib/builder/webpack/timefix-plugin.js | 18 ++++++++++++++++++ 3 files changed, 23 insertions(+), 4 deletions(-) create mode 100644 lib/builder/webpack/timefix-plugin.js diff --git a/lib/builder/builder.js b/lib/builder/builder.js index 38265c5ed1..f2edc82f94 100644 --- a/lib/builder/builder.js +++ b/lib/builder/builder.js @@ -1,6 +1,6 @@ import _ from 'lodash' import chokidar from 'chokidar' -import fs, { remove, readFile, writeFile, mkdirp, utimes, existsSync } from 'fs-extra' +import fs, { remove, readFile, writeFile, mkdirp, existsSync } from 'fs-extra' import hash from 'hash-sum' import pify from 'pify' import webpack from 'webpack' @@ -366,9 +366,6 @@ export default class Builder { await mkdirp(dirname(path)) // Write file await writeFile(path, content, 'utf8') - // Fix webpack loop (https://github.com/webpack/watchpack/issues/25#issuecomment-287789288) - const dateFS = Date.now() / 1000 - 1000 - return utimes(path, dateFS, dateFS) })) } diff --git a/lib/builder/webpack/base.config.js b/lib/builder/webpack/base.config.js index e9546072e3..8072e0ff09 100644 --- a/lib/builder/webpack/base.config.js +++ b/lib/builder/webpack/base.config.js @@ -3,6 +3,7 @@ import { cloneDeep } from 'lodash' import { join, resolve } from 'path' import webpack from 'webpack' import { isUrl, urlJoin } from 'utils' +import TimeFixPlugin from './timefix-plugin' /* |-------------------------------------------------------------------------- @@ -104,6 +105,9 @@ export default function webpackBaseConfig(name) { plugins: this.options.build.plugins } + // Add timefix-plugin before others plugins + config.plugins.unshift(new TimeFixPlugin()) + // CSS extraction if (this.options.build.extractCSS) { config.plugins.push(new ExtractTextPlugin({ diff --git a/lib/builder/webpack/timefix-plugin.js b/lib/builder/webpack/timefix-plugin.js new file mode 100644 index 0000000000..9c16918735 --- /dev/null +++ b/lib/builder/webpack/timefix-plugin.js @@ -0,0 +1,18 @@ +// Taken from https://github.com/egoist/poi/blob/3e93c88c520db2d20c25647415e6ae0d3de61145/packages/poi/lib/webpack/timefix-plugin.js#L1-L16 +// Thanks to @egoist +export default class TimeFixPlugin { + constructor(timefix = 11000) { + this.timefix = timefix + } + + apply(compiler) { + compiler.plugin('watch-run', (watching, callback) => { + watching.startTime += this.timefix + callback() + }) + + compiler.plugin('done', stats => { + stats.startTime -= this.timefix + }) + } +} From 312ce81a6e32de884f8b8d03a2ac39d82d1428fa Mon Sep 17 00:00:00 2001 From: Atinux Date: Tue, 7 Nov 2017 11:51:46 +0100 Subject: [PATCH 242/316] fix: Remove console.log --- lib/app/client.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/app/client.js b/lib/app/client.js index cbb43f7f43..1c8f02d241 100644 --- a/lib/app/client.js +++ b/lib/app/client.js @@ -388,7 +388,6 @@ function fixPrepatch(to, ___) { instances.forEach((instance, i) => { if (!instance) return if (instance.constructor._dataRefresh && _lastPaths[i] === instance.constructor._path && typeof instance.constructor.options.data === 'function') { - console.log('Refresh instance', instance) const newData = instance.constructor.options.data.call(instance) for (let key in newData) { Vue.set(instance.$data, key, newData[key]) From e5017c5e2ac5c25248df67af86348f8e45b15c81 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Tue, 7 Nov 2017 15:35:41 +0330 Subject: [PATCH 243/316] perf: better vendor chunk Also disables commons chunk plugin on dev environments for faster builds --- lib/builder/webpack/client.config.js | 151 +++++++++++++-------------- lib/common/options.js | 5 +- 2 files changed, 78 insertions(+), 78 deletions(-) diff --git a/lib/builder/webpack/client.config.js b/lib/builder/webpack/client.config.js index c61b130e59..9b7c2be858 100644 --- a/lib/builder/webpack/client.config.js +++ b/lib/builder/webpack/client.config.js @@ -27,52 +27,9 @@ debug.color = 2 // Force green color export default function webpackClientConfig() { let config = base.call(this, 'client') - // App entry + // Entry points config.entry.app = resolve(this.options.buildDir, 'client.js') - config.entry.common = this.vendor() - - // Extract vendor chunks for better caching - const _this = this - const totalPages = _this.routes ? _this.routes.length : 0 - - // This well-known vendor may exist as a dependency of other requests. - const maybeVendor = [ - '/core-js/', - '/regenerator-runtime/', - '/es6-promise/', - '/babel-runtime/', - '/lodash/' - ] - - config.plugins.push( - new webpack.optimize.CommonsChunkPlugin({ - name: 'common', - filename: this.options.build.filenames.vendor, - minChunks(module, count) { - // In the dev we use on-demand-entries. - // So, it makes no sense to use commonChunks based on the minChunks count. - // Instead, we move all the code in node_modules into each of the pages. - if (_this.options.dev) { - return false - } - - // Detect and externalize well-known vendor if detected - if (module.context && maybeVendor.some(v => module.context.includes(v))) { - return true - } - - // A module is extracted into the vendor chunk when... - return ( - // If it's inside node_modules - /node_modules/.test(module.context) && - // Do not externalize if the request is a CSS file - !/\.(css|less|scss|sass|styl|stylus)$/.test(module.request) && - // Used in at-least 1/2 of the total pages - (totalPages <= 2 ? count >= totalPages : count >= totalPages * 0.5) - ) - } - }) - ) + config.entry.vendor = this.vendor() // Env object defined in nuxt.config.js let env = {} @@ -80,12 +37,6 @@ export default function webpackClientConfig() { env['process.env.' + key] = (['boolean', 'number'].indexOf(typeof value) !== -1 ? value : JSON.stringify(value)) }) - // Webpack common plugins - /* istanbul ignore if */ - if (!Array.isArray(config.plugins)) { - config.plugins = [] - } - // Generate output HTML for SPA config.plugins.push( new HTMLPlugin({ @@ -163,26 +114,8 @@ export default function webpackClientConfig() { ) // DllReferencePlugin - // https://github.com/webpack/webpack/tree/master/examples/dll-user if (this.options.build.dll) { - const _dlls = [] - const vendorEntries = this.vendorEntries() - const dllDir = resolve(this.options.cacheDir, config.name + '-dll') - Object.keys(vendorEntries).forEach(v => { - const dllManifestFile = resolve(dllDir, v + '-manifest.json') - if (existsSync(dllManifestFile)) { - _dlls.push(v) - config.plugins.push( - new webpack.DllReferencePlugin({ - // context: this.options.rootDir, - manifest: dllManifestFile // Using full path to allow finding .js dll file - }) - ) - } - }) - if (_dlls.length) { - debug('Using dll for ' + _dlls.join(',')) - } + dllPlugin.call(this, config) } } @@ -190,10 +123,13 @@ export default function webpackClientConfig() { // Production specific config // -------------------------------------- if (!this.options.dev) { + // Add CommonChunks plugin + commonChunksPlugin.call(this, config) + // Scope Hoisting - config.plugins.push( - // new webpack.optimize.ModuleConcatenationPlugin() - ) + if (this.options.build.scopeHoisting === true) { + config.plugins.push(new webpack.optimize.ModuleConcatenationPlugin()) + } // https://webpack.js.org/plugins/hashed-module-ids-plugin config.plugins.push(new webpack.HashedModuleIdsPlugin()) @@ -212,9 +148,7 @@ export default function webpackClientConfig() { // Webpack Bundle Analyzer if (this.options.build.analyze) { - config.plugins.push( - new BundleAnalyzerPlugin(Object.assign({}, this.options.build.analyze)) - ) + config.plugins.push(new BundleAnalyzerPlugin(Object.assign({}, this.options.build.analyze))) } } @@ -237,3 +171,68 @@ export default function webpackClientConfig() { return config } + +// -------------------------------------------------------------------------- +// Adds Common Chunks Plugin +// -------------------------------------------------------------------------- +function commonChunksPlugin(config) { + const _this = this + const totalPages = _this.routes ? _this.routes.length : 0 + + // This well-known vendor may exist as a dependency of other requests. + const maybeVendor = [ + '/core-js/', + '/regenerator-runtime/', + '/es6-promise/', + '/babel-runtime/', + '/lodash/' + ] + + // Create explicit vendor chunk + config.plugins.unshift( + new webpack.optimize.CommonsChunkPlugin({ + name: 'vendor', + filename: this.options.build.filenames.vendor, + minChunks(module, count) { + // Detect and externalize well-known vendor if detected + if (module.context && maybeVendor.some(v => module.context.includes(v))) { + return true + } + // A module is extracted into the vendor chunk when... + return ( + // If it's inside node_modules + /node_modules/.test(module.context) && + // Do not externalize if the request is a CSS file + !/\.(css|less|scss|sass|styl|stylus)$/.test(module.request) && + // Used in at-least 1/2 of the total pages + (totalPages <= 2 ? count >= totalPages : count >= totalPages * 0.5) + ) + } + }) + ) +} + +// -------------------------------------------------------------------------- +// Adds DLL plugin +// https://github.com/webpack/webpack/tree/master/examples/dll-user +// -------------------------------------------------------------------------- +function dllPlugin(config) { + const _dlls = [] + const vendorEntries = this.vendorEntries() + const dllDir = resolve(this.options.cacheDir, config.name + '-dll') + Object.keys(vendorEntries).forEach(v => { + const dllManifestFile = resolve(dllDir, v + '-manifest.json') + if (existsSync(dllManifestFile)) { + _dlls.push(v) + config.plugins.push( + new webpack.DllReferencePlugin({ + // context: this.options.rootDir, + manifest: dllManifestFile // Using full path to allow finding .js dll file + }) + ) + } + }) + if (_dlls.length) { + debug('Using dll for ' + _dlls.join(',')) + } +} diff --git a/lib/common/options.js b/lib/common/options.js index bf7b14651c..17e3fd6532 100755 --- a/lib/common/options.js +++ b/lib/common/options.js @@ -185,14 +185,15 @@ Options.defaults = { build: { analyze: false, dll: false, + scopeHoisting: false, extractCSS: false, cssSourceMap: undefined, ssr: undefined, publicPath: '/_nuxt/', filenames: { - css: 'common.[contenthash].css', + css: 'vendor.[contenthash].css', manifest: 'manifest.[hash].js', - vendor: 'common.[chunkhash].js', + vendor: 'vendor.[chunkhash].js', app: 'app.[chunkhash].js', chunk: '[name].[chunkhash].js' }, From 711e6a916e21ffe1b0f3f4ea256f8d8decfad5ff Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Tue, 7 Nov 2017 17:18:46 +0330 Subject: [PATCH 244/316] fix: add deprecated warn for tapables + simple backward compatibility --- lib/core/nuxt.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/lib/core/nuxt.js b/lib/core/nuxt.js index e418db59c4..5ba85a2958 100644 --- a/lib/core/nuxt.js +++ b/lib/core/nuxt.js @@ -58,6 +58,26 @@ export default class Nuxt { return this } + plugin(name, fn) { + // eslint-disable-next-line no-console + console.error(`[warn] nuxt.plugin('${name}',..) is deprecated. Please use new hooks system.`) + + // A tiny backward compatibility util + const hookMap = { + 'ready': 'ready', + 'close': 'close', + 'listen': 'listen', + 'built': 'build:done' + } + + if (hookMap[name]) { + this.hook(hookMap[name], fn) + } + + // Always return nuxt class which has plugin() for two level hooks + return this + } + hook(name, fn) { if (!name || typeof fn !== 'function') { return From 932fbfddfdd54de23bec455abcb8118943084c7e Mon Sep 17 00:00:00 2001 From: Atinux Date: Tue, 7 Nov 2017 16:25:56 +0100 Subject: [PATCH 245/316] minor: Call routeChanged event with a 3rd argument if an error happened --- lib/app/client.js | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/lib/app/client.js b/lib/app/client.js index 1c8f02d241..d3ab2760b3 100644 --- a/lib/app/client.js +++ b/lib/app/client.js @@ -132,6 +132,7 @@ async function loadAsyncComponents (to, from, next) { err = err || {} const statusCode = err.statusCode || err.status || (err.response && err.response.status) || 500 this.error({ statusCode, message: err.message }) + this.$nuxt.$emit('routeChanged', to, from, err) next(false) } } @@ -346,6 +347,7 @@ async function render (to, from, next) { await this.loadLayout(layout) this.error(error) + this.$nuxt.$emit('routeChanged', to, from, error) next(false) } } @@ -402,19 +404,20 @@ function fixPrepatch(to, ___) { }) } -function nuxtReady (app) { +function nuxtReady (_app) { window._nuxtReadyCbs.forEach((cb) => { if (typeof cb === 'function') { - cb(app) + cb(_app) } }) // Special JSDOM if (typeof window._onNuxtLoaded === 'function') { - window._onNuxtLoaded(app) + window._onNuxtLoaded(_app) } // Add router hooks router.afterEach(function (to, from) { - app.$nuxt.$emit('routeChanged', to, from) + // Wait for fixPrepatch + $data updates + Vue.nextTick(() => _app.$nuxt.$emit('routeChanged', to, from)) }) } @@ -531,7 +534,7 @@ async function mountApp(__app) { _app.setLayout(layout) // Mounts Vue app to DOM element - const mountApp = () => { + const mount = () => { _app.$mount('#__nuxt') // Listen for first Vue update @@ -564,7 +567,7 @@ async function mountApp(__app) { // If page already is server rendered if (NUXT.serverRendered) { - mountApp() + mount() return } @@ -575,11 +578,11 @@ async function mountApp(__app) { normalizeComponents(router.currentRoute, router.currentRoute) showNextPage.call(_app, router.currentRoute) // Dont call fixPrepatch.call(_app, router.currentRoute, router.currentRoute) since it's first render - mountApp() + mount() return } // Push the path and then mount app - router.push(path, () => mountApp(), (err) => console.error(err)) + router.push(path, () => mount(), (err) => console.error(err)) }) } From 1e3120b60f25d0f491e2899e9290ca10c5a23dba Mon Sep 17 00:00:00 2001 From: Atinux Date: Tue, 7 Nov 2017 16:26:15 +0100 Subject: [PATCH 246/316] test: Use routeChanged for client-side tests --- test/basic.csr.test.js | 40 ++++++++++++++++++------------------- test/children.patch.test.js | 25 ++++++++--------------- test/helpers/browser.js | 14 ++++++------- 3 files changed, 35 insertions(+), 44 deletions(-) diff --git a/test/basic.csr.test.js b/test/basic.csr.test.js index 7955899218..da09e77a1b 100644 --- a/test/basic.csr.test.js +++ b/test/basic.csr.test.js @@ -40,29 +40,29 @@ test('Open /', async t => { }) test('/stateless', async t => { - await page.nuxt.navigate('/stateless') + const { hook } = await page.nuxt.navigate('/stateless', false) const loading = await page.nuxt.loadingData() t.is(loading.show, true) - await page.nuxt.waitForNavigation() + await hook t.is(await page.$text('h1'), 'My component!') }) test('/css', async t => { - await page.nuxt.navigate('/css', true) + await page.nuxt.navigate('/css') t.is(await page.$text('.red'), 'This is red') t.is(await page.$eval('.red', (red) => window.getComputedStyle(red).color), 'rgb(255, 0, 0)') }) test('/stateful', async t => { - await page.nuxt.navigate('/stateful', true) + await page.nuxt.navigate('/stateful') t.is(await page.$text('p'), 'The answer is 42') }) test('/store', async t => { - await page.nuxt.navigate('/store', true) + await page.nuxt.navigate('/store') t.is(await page.$text('h1'), 'Vuex Nested Modules') t.is(await page.$text('p'), '1') @@ -70,7 +70,7 @@ test('/store', async t => { test('/head', async t => { const msg = new Promise((resolve) => page.on('console', (msg) => resolve(msg.text))) - await page.nuxt.navigate('/head', true) + await page.nuxt.navigate('/head') const metas = await page.$$attr('meta', 'content') t.is(await msg, 'Body script!') @@ -80,31 +80,31 @@ test('/head', async t => { }) test('/async-data', async t => { - await page.nuxt.navigate('/async-data', true) + await page.nuxt.navigate('/async-data') t.is(await page.$text('p'), 'Nuxt.js') }) test('/await-async-data', async t => { - await page.nuxt.navigate('/await-async-data', true) + await page.nuxt.navigate('/await-async-data') t.is(await page.$text('p'), 'Await Nuxt.js') }) test('/callback-async-data', async t => { - await page.nuxt.navigate('/callback-async-data', true) + await page.nuxt.navigate('/callback-async-data') t.is(await page.$text('p'), 'Callback Nuxt.js') }) test('/users/1', async t => { - await page.nuxt.navigate('/users/1', true) + await page.nuxt.navigate('/users/1') t.is(await page.$text('h1'), 'User: 1') }) test('/validate should display a 404', async t => { - await page.nuxt.navigate('/validate', true) + await page.nuxt.navigate('/validate') const error = await page.nuxt.errorData() t.is(error.statusCode, 404) @@ -112,59 +112,59 @@ test('/validate should display a 404', async t => { }) test('/validate?valid=true', async t => { - await page.nuxt.navigate('/validate?valid=true', true) + await page.nuxt.navigate('/validate?valid=true') t.is(await page.$text('h1'), 'I am valid') }) test('/redirect', async t => { - await page.nuxt.navigate('/redirect', true) + await page.nuxt.navigate('/redirect') t.is(await page.$text('h1'), 'Index page') }) test('/error', async t => { - await page.nuxt.navigate('/error', true) + await page.nuxt.navigate('/error') t.deepEqual(await page.nuxt.errorData(), { statusCode: 500 }) t.is(await page.$text('.title'), 'Error mouahahah') }) test('/error2', async t => { - await page.nuxt.navigate('/error2', true) + await page.nuxt.navigate('/error2') t.is(await page.$text('.title'), 'Custom error') t.deepEqual(await page.nuxt.errorData(), { message: 'Custom error' }) }) test('/redirect2', async t => { - await page.nuxt.navigate('/redirect2', true) + await page.nuxt.navigate('/redirect2') t.is(await page.$text('h1'), 'Index page') }) test('/no-ssr', async t => { - await page.nuxt.navigate('/no-ssr', true) + await page.nuxt.navigate('/no-ssr') t.is(await page.$text('h1'), 'Displayed only on client-side') }) test('/meta', async t => { - await page.nuxt.navigate('/meta', true) + await page.nuxt.navigate('/meta') const state = await page.nuxt.storeState() t.deepEqual(state.meta, [{ works: true }]) }) test('/fn-midd', async t => { - await page.nuxt.navigate('/fn-midd', true) + await page.nuxt.navigate('/fn-midd') t.is(await page.$text('.title'), 'You need to ask the permission') t.deepEqual(await page.nuxt.errorData(), { message: 'You need to ask the permission', statusCode: 403 }) }) test('/fn-midd?please=true', async t => { - await page.nuxt.navigate('/fn-midd?please=true', true) + await page.nuxt.navigate('/fn-midd?please=true') const h1 = await page.$text('h1') t.true(h1.includes('Date:')) diff --git a/test/children.patch.test.js b/test/children.patch.test.js index 60a010e865..223c3e4513 100644 --- a/test/children.patch.test.js +++ b/test/children.patch.test.js @@ -40,10 +40,10 @@ test('Loading /patch and keep ', async t => { }) test('Navigate to /patch/1', async t => { - await page.nuxt.navigate('/patch/1') + const { hook } = await page.nuxt.navigate('/patch/1', false) const loading = await page.nuxt.loadingData() t.is(loading.show, true) - await page.nuxt.waitForNavigation() + await hook const h2 = await page.$text('h2') t.true(h2.includes('_id:')) @@ -53,7 +53,7 @@ test('Navigate to /patch/1', async t => { }) test('Navigate to /patch/2', async t => { - await page.nuxt.navigate('/patch/2', true) + await page.nuxt.navigate('/patch/2') const date = await page.$text('[data-date-id]') t.is(await page.$text('h3'), 'Index') @@ -63,28 +63,19 @@ test('Navigate to /patch/2', async t => { }) test('Navigate to /patch/2?test=true', async t => { - await page.nuxt.navigate('/patch/2?test=true', true) + await page.nuxt.navigate('/patch/2?test=true') t.is(dates.patch, await page.$text('[data-date-patch]')) t.is(dates.id, await page.$text('[data-date-id]')) }) test('Navigate to /patch/2#test', async t => { - await page.nuxt.navigate('/patch/2#test', true) + await page.nuxt.navigate('/patch/2#test') t.is(dates.patch, await page.$text('[data-date-patch]')) t.is(dates.id, await page.$text('[data-date-id]')) }) test('Navigate to /patch/2/child', async t => { - await page.nuxt.navigate('/patch/2/child', true) - dates.child = await page.$text('[data-date-child]') - - t.is(dates.patch, await page.$text('[data-date-patch]')) - t.is(dates.id, await page.$text('[data-date-id]')) - t.true(+dates.child > +dates.id) -}) - -test('Navigate to /patch/2/child', async t => { - await page.nuxt.navigate('/patch/2/child', true) + await page.nuxt.navigate('/patch/2/child') dates.child = await page.$text('[data-date-child]') dates.slug = await page.$text('[data-date-child-slug]') @@ -95,7 +86,7 @@ test('Navigate to /patch/2/child', async t => { }) test('Navigate to /patch/2/child/1', async t => { - await page.nuxt.navigate('/patch/2/child/1', true) + await page.nuxt.navigate('/patch/2/child/1') const date = await page.$text('[data-date-child-slug]') t.is(dates.patch, await page.$text('[data-date-patch]')) @@ -106,7 +97,7 @@ test('Navigate to /patch/2/child/1', async t => { }) test('Navigate to /patch/2/child/1?foo=bar', async t => { - await page.nuxt.navigate('/patch/2/child/1?foo=bar', true) + await page.nuxt.navigate('/patch/2/child/1?foo=bar') t.is(dates.patch, await page.$text('[data-date-patch]')) t.is(dates.id, await page.$text('[data-date-id]')) diff --git a/test/helpers/browser.js b/test/helpers/browser.js index fdde550d93..4ba30bfa2d 100644 --- a/test/helpers/browser.js +++ b/test/helpers/browser.js @@ -27,11 +27,14 @@ export async function page(url) { page.$nuxt = await page.evaluateHandle('window.$nuxt') page.nuxt = { - async navigate(path, wait = false) { + async navigate(path, waitEnd = true) { + const hook = page.evaluate(async () => { + await new Promise((resolve) => window.$nuxt.$once('routeChanged', resolve)) + await new Promise((resolve) => setTimeout(resolve, 50)) + }) await page.evaluate(($nuxt, path) => $nuxt.$router.push(path), page.$nuxt, path) - if (wait) { - await this.waitForNavigation() - } + if (waitEnd) await hook + return { hook } }, routeData() { return page.evaluate(($nuxt) => { @@ -49,9 +52,6 @@ export async function page(url) { }, storeState() { return page.evaluate(($nuxt) => $nuxt.$store.state, page.$nuxt) - }, - waitForNavigation() { - return page.waitForFunction('window.$nuxt.$loading.$data.show === false') } } return page From 244644f192f59de38693b344bdd7cadbbc1bfbc3 Mon Sep 17 00:00:00 2001 From: Atinux Date: Tue, 7 Nov 2017 16:30:19 +0100 Subject: [PATCH 247/316] test: Fix common -> vendor --- test/with-config.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/with-config.test.js b/test/with-config.test.js index c0bfe0674b..1f6453f6bc 100644 --- a/test/with-config.test.js +++ b/test/with-config.test.js @@ -42,7 +42,7 @@ test('/ (custom app.html)', async t => { test('/ (custom build.publicPath)', async t => { const { html } = await nuxt.renderRoute('/') - t.true(html.includes('src="/test/orion/common.')) + t.true(html.includes('src="/test/orion/vendor.')) }) test('/test/ (router base)', async t => { From e8114705766385dd5ba650c6280b0b616bbfd3ac Mon Sep 17 00:00:00 2001 From: Atinux Date: Tue, 7 Nov 2017 16:55:54 +0100 Subject: [PATCH 248/316] fix: Fix node 6 tests --- test/helpers/browser.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/helpers/browser.js b/test/helpers/browser.js index 4ba30bfa2d..4da905d426 100644 --- a/test/helpers/browser.js +++ b/test/helpers/browser.js @@ -28,9 +28,9 @@ export async function page(url) { page.nuxt = { async navigate(path, waitEnd = true) { - const hook = page.evaluate(async () => { - await new Promise((resolve) => window.$nuxt.$once('routeChanged', resolve)) - await new Promise((resolve) => setTimeout(resolve, 50)) + const hook = page.evaluate(() => { + return new Promise((resolve) => window.$nuxt.$once('routeChanged', resolve)) + .then(() => new Promise((resolve) => setTimeout(resolve, 50))) }) await page.evaluate(($nuxt, path) => $nuxt.$router.push(path), page.$nuxt, path) if (waitEnd) await hook From 6b6aa3e392b4e82ca7d2418a8c8ad99050ee47c8 Mon Sep 17 00:00:00 2001 From: Clark Du Date: Fri, 10 Nov 2017 14:04:43 +0800 Subject: [PATCH 249/316] refactor: log nuxtServerInit error for better error tracing --- lib/app/server.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/app/server.js b/lib/app/server.js index df23de17c2..6568b97f49 100644 --- a/lib/app/server.js +++ b/lib/app/server.js @@ -91,7 +91,12 @@ export default async ssrContext => { ** Dispatch store nuxtServerInit */ if (store._actions && store._actions.nuxtServerInit) { - await store.dispatch('nuxtServerInit', app.context) + try { + await store.dispatch('nuxtServerInit', app.context) + } catch (err) { + debug('error occurred when calling nuxtServerInit: ', e.message) + throw err + } } // ...If there is a redirect or an error, stop the process if (ssrContext.redirected) return noopApp() From a23fb18399a373d7fae75b5e6cf95cd69514df64 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Sat, 11 Nov 2017 01:16:37 +0330 Subject: [PATCH 250/316] fix: always add commonChunksPlugin --- lib/builder/webpack/client.config.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/builder/webpack/client.config.js b/lib/builder/webpack/client.config.js index 9b7c2be858..47d766417d 100644 --- a/lib/builder/webpack/client.config.js +++ b/lib/builder/webpack/client.config.js @@ -31,6 +31,9 @@ export default function webpackClientConfig() { config.entry.app = resolve(this.options.buildDir, 'client.js') config.entry.vendor = this.vendor() + // Add CommonChunks plugin + commonChunksPlugin.call(this, config) + // Env object defined in nuxt.config.js let env = {} each(this.options.env, (value, key) => { @@ -123,9 +126,6 @@ export default function webpackClientConfig() { // Production specific config // -------------------------------------- if (!this.options.dev) { - // Add CommonChunks plugin - commonChunksPlugin.call(this, config) - // Scope Hoisting if (this.options.build.scopeHoisting === true) { config.plugins.push(new webpack.optimize.ModuleConcatenationPlugin()) From ad4aea3546a3aa8ec99cb71001e8a9b984955eed Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Sat, 11 Nov 2017 01:21:10 +0330 Subject: [PATCH 251/316] typo: e -> err --- lib/app/server.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/app/server.js b/lib/app/server.js index 6568b97f49..2322298049 100644 --- a/lib/app/server.js +++ b/lib/app/server.js @@ -94,7 +94,7 @@ export default async ssrContext => { try { await store.dispatch('nuxtServerInit', app.context) } catch (err) { - debug('error occurred when calling nuxtServerInit: ', e.message) + debug('error occurred when calling nuxtServerInit: ', err.message) throw err } } From ff4a5bd404bf275e369051f07887683273089335 Mon Sep 17 00:00:00 2001 From: Clark Du Date: Sat, 11 Nov 2017 20:52:45 +0800 Subject: [PATCH 252/316] feat: make extractCSS configurable --- lib/builder/webpack/base.config.js | 11 +++++++---- lib/builder/webpack/vue-loader.config.js | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/builder/webpack/base.config.js b/lib/builder/webpack/base.config.js index e9546072e3..812f1b50fe 100644 --- a/lib/builder/webpack/base.config.js +++ b/lib/builder/webpack/base.config.js @@ -105,10 +105,13 @@ export default function webpackBaseConfig(name) { } // CSS extraction - if (this.options.build.extractCSS) { - config.plugins.push(new ExtractTextPlugin({ - filename: this.options.build.filenames.css - })) + const extractCSS = this.options.build.extractCSS + if (extractCSS) { + const extractOptions = Object.assign( + { filename: this.options.build.filenames.css }, + typeof extractCSS === 'object' ? extractCSS : {} + ) + config.plugins.push(new ExtractTextPlugin(extractOptions)) } // Workaround for hiding Warnings about plugins without a default export (#1179) diff --git a/lib/builder/webpack/vue-loader.config.js b/lib/builder/webpack/vue-loader.config.js index f281c06fe1..72f431f5c0 100644 --- a/lib/builder/webpack/vue-loader.config.js +++ b/lib/builder/webpack/vue-loader.config.js @@ -2,7 +2,7 @@ export default function vueLoader() { // https://vue-loader.vuejs.org/en const config = { postcss: this.options.build.postcss, - extractCSS: this.options.build.extractCSS, + extractCSS: !!this.options.build.extractCSS, cssSourceMap: this.options.build.cssSourceMap, preserveWhitespace: false, loaders: { From 4f6cd949a1a4e88ab3b5d8bc77a0bc6436a2f247 Mon Sep 17 00:00:00 2001 From: dotnetCarpenter Date: Mon, 13 Nov 2017 20:25:37 +0100 Subject: [PATCH 253/316] Better explanation for using tailwind with postcss-import Manual cherry-pick https://github.com/tailwindcss/tailwindcss/commit/ad44fae29fe9d8da189b02602558f60986bebb49 --- examples/tailwindcss/assets/css/tailwind.css | 80 +++++++++++--------- 1 file changed, 46 insertions(+), 34 deletions(-) diff --git a/examples/tailwindcss/assets/css/tailwind.css b/examples/tailwindcss/assets/css/tailwind.css index 74a97f8831..d44c6d8c2c 100644 --- a/examples/tailwindcss/assets/css/tailwind.css +++ b/examples/tailwindcss/assets/css/tailwind.css @@ -4,42 +4,54 @@ * * You can see the styles here: * https://github.com/tailwindcss/tailwindcss/blob/master/css/preflight.css + * + * If using `postcss-import`, you should import this line from it's own file: + * + * @import "./tailwind-preflight.css"; + * + * See: https://github.com/tailwindcss/tailwindcss/issues/53#issuecomment-341413622 */ @tailwind preflight; - /** - * Here you would add any of your custom component classes; stuff that you'd - * want loaded *before* the utilities so that the utilities could still - * override them. - * - * Example: - * - * .btn { ... } - * .form-input { ... } - * - * Or if using a preprocessor: - * - * @import "components/buttons"; - * @import "components/forms"; - */ + /** + * Here you would add any of your custom component classes; stuff that you'd + * want loaded *before* the utilities so that the utilities could still + * override them. + * + * Example: + * + * .btn { ... } + * .form-input { ... } + * + * Or if using a preprocessor or `postcss-import`: + * + * @import "components/buttons"; + * @import "components/forms"; + */ - /** - * This injects all of Tailwind's utility classes, generated based on your - * config file. - */ - @tailwind utilities; + /** + * This injects all of Tailwind's utility classes, generated based on your + * config file. + * + * If using `postcss-import`, you should import this line from it's own file: + * + * @import "./tailwind-utilities.css"; + * + * See: https://github.com/tailwindcss/tailwindcss/issues/53#issuecomment-341413622 + */ + @tailwind utilities; - /** - * Here you would add any custom utilities you need that don't come out of the - * box with Tailwind. - * - * Example : - * - * .bg-pattern-graph-paper { ... } - * .skew-45 { ... } - * - * Or if using a preprocessor.. - * - * @import "utilities/backgrond-patterns"; - * @import "utilities/skew-transforms"; - */ + /** + * Here you would add any custom utilities you need that don't come out of the + * box with Tailwind. + * + * Example : + * + * .bg-pattern-graph-paper { ... } + * .skew-45 { ... } + * + * Or if using a preprocessor or `postcss-import`: + * + * @import "utilities/background-patterns"; + * @import "utilities/skew-transforms"; + */ \ No newline at end of file From 8eb519b16b85014ac2492bfc5a649f7002accda2 Mon Sep 17 00:00:00 2001 From: Clark Du Date: Tue, 14 Nov 2017 11:06:06 +0800 Subject: [PATCH 254/316] feat: add parseQuery and stringifyQuery for router --- lib/app/router.js | 2 ++ lib/common/options.js | 2 ++ 2 files changed, 4 insertions(+) diff --git a/lib/app/router.js b/lib/app/router.js index 8312556090..e7f997d7e3 100644 --- a/lib/app/router.js +++ b/lib/app/router.js @@ -60,6 +60,8 @@ export function createRouter () { routes: [ <%= _routes %> ], + parseQuery: <%= router.parseQuery %>, + stringifyQuery: <%= router.stringifyQuery %>, fallback: <%= router.fallback %> }) } diff --git a/lib/common/options.js b/lib/common/options.js index 672a216c85..408613ba29 100755 --- a/lib/common/options.js +++ b/lib/common/options.js @@ -271,6 +271,8 @@ Options.defaults = { linkExactActiveClass: 'nuxt-link-exact-active', extendRoutes: null, scrollBehavior: null, + parseQuery: false, + stringifyQuery: false, fallback: false }, render: { From 47384305da0ab39856ba43c781b158bdc19178e6 Mon Sep 17 00:00:00 2001 From: Clark Du Date: Tue, 14 Nov 2017 11:14:37 +0800 Subject: [PATCH 255/316] fix: assets is not resolved in / src --- lib/builder/webpack/vue-loader.config.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/builder/webpack/vue-loader.config.js b/lib/builder/webpack/vue-loader.config.js index 72f431f5c0..c5b608b6cf 100644 --- a/lib/builder/webpack/vue-loader.config.js +++ b/lib/builder/webpack/vue-loader.config.js @@ -23,7 +23,9 @@ export default function vueLoader() { }, transformToRequire: { video: 'src', - source: 'src' + source: 'src', + object: 'src', + embed: 'src' } } From fafe6d0a81644dd4d58d2ad29d3cacc47568cd48 Mon Sep 17 00:00:00 2001 From: Clark Du Date: Tue, 14 Nov 2017 16:53:01 +0800 Subject: [PATCH 256/316] fix(spa): redundant laoding default layout when custom layout specified --- lib/app/client.js | 4 +++- test/spa.test.js | 8 +++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/app/client.js b/lib/app/client.js index 0c5a6ff3a7..64fdf370ed 100644 --- a/lib/app/client.js +++ b/lib/app/client.js @@ -498,10 +498,12 @@ async function mountApp(__app) { // Create Vue instance const _app = new Vue(app) - // Load layout + <% if (mode !== 'spa') { %> + // Load layout const layout = NUXT.layout || 'default' await _app.loadLayout(layout) _app.setLayout(layout) + <% } %> // Mounts Vue app to DOM element const mountApp = () => { diff --git a/test/spa.test.js b/test/spa.test.js index 72e9d65eed..5c89378ce5 100755 --- a/test/spa.test.js +++ b/test/spa.test.js @@ -8,8 +8,9 @@ const url = (route) => 'http://localhost:' + port + route const renderRoute = async _url => { const window = await nuxt.renderAndGetWindow(url(_url)) + const head = window.document.head.innerHTML const html = window.document.body.innerHTML - return { window, html } + return { window, head, html } } // Init nuxt.js and create server listening on localhost:4000 @@ -29,6 +30,11 @@ test('/custom (custom layout)', async t => { t.true(html.includes('Custom layout')) }) +test('/custom (not default layout)', async t => { + const { head } = await renderRoute('/custom') + t.false(head.includes('src="/_nuxt/layouts/default.')) +}) + // Close server and ask nuxt to stop listening to file changes test.after('Closing server and nuxt.js', t => { nuxt.close() From 679d48c8c02b188a69c04bee4a8dedd8a208f669 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Chopin?= Date: Tue, 14 Nov 2017 10:28:18 +0100 Subject: [PATCH 257/316] Update router.js --- lib/app/router.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/app/router.js b/lib/app/router.js index e7f997d7e3..efad4256db 100644 --- a/lib/app/router.js +++ b/lib/app/router.js @@ -60,8 +60,8 @@ export function createRouter () { routes: [ <%= _routes %> ], - parseQuery: <%= router.parseQuery %>, - stringifyQuery: <%= router.stringifyQuery %>, + <% if (router.parseQuery) { %>parseQuery: <%= serialize(router.parseQuery).replace('parseQuery(', 'function(') %>,<% } %> + <% if (router.stringifyQuery) { %>stringifyQuery: <%= serialize(router.stringifyQuery).replace('stringifyQuery(', 'function(') %>,<% } %> fallback: <%= router.fallback %> }) } From 1c4978db4f86aa937d97d4fe0cdcaeb192362881 Mon Sep 17 00:00:00 2001 From: David Sandor Date: Thu, 16 Nov 2017 05:44:34 -0500 Subject: [PATCH 258/316] Add tappable plugin call after route generated. --- lib/builder/generator.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/builder/generator.js b/lib/builder/generator.js index 42cddada32..ab9d170293 100644 --- a/lib/builder/generator.js +++ b/lib/builder/generator.js @@ -67,6 +67,7 @@ export default class Generator { await Promise.all(routes.splice(0, this.options.generate.concurrency).map(async ({ route, payload }) => { await waitFor(n++ * this.options.generate.interval) await this.generateRoute({ route, payload, errors }) + await this.applyPluginsAsync('generated-route', { generator: this, routes, route }) })) } From 9aa6722512ade991f038f4916d8c79f5274a7a74 Mon Sep 17 00:00:00 2001 From: David Sandor Date: Thu, 16 Nov 2017 05:50:14 -0500 Subject: [PATCH 259/316] Include errors, this is useful in reporting success % --- lib/builder/generator.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/builder/generator.js b/lib/builder/generator.js index ab9d170293..dabedf2fbb 100644 --- a/lib/builder/generator.js +++ b/lib/builder/generator.js @@ -67,7 +67,7 @@ export default class Generator { await Promise.all(routes.splice(0, this.options.generate.concurrency).map(async ({ route, payload }) => { await waitFor(n++ * this.options.generate.interval) await this.generateRoute({ route, payload, errors }) - await this.applyPluginsAsync('generated-route', { generator: this, routes, route }) + await this.applyPluginsAsync('generated-route', { generator: this, routes, route, errors }) })) } From 2228bf4209b03550612aa14d7f95b20527bd04d6 Mon Sep 17 00:00:00 2001 From: Clark Du Date: Thu, 16 Nov 2017 18:56:41 +0800 Subject: [PATCH 260/316] refactor: fix [TypeError: Cannot read property split of undefined] in tests --- lib/common/options.js | 2 +- test/fixtures/basic/nuxt.config.js | 3 ++- test/fixtures/spa/nuxt.config.js | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/common/options.js b/lib/common/options.js index 672a216c85..1a1faac163 100755 --- a/lib/common/options.js +++ b/lib/common/options.js @@ -147,7 +147,7 @@ Options.from = function (_options) { _.defaultsDeep(options, modePreset) // If no server-side rendering, add appear true transition - if (options.render.ssr === false) { + if (options.render.ssr === false && options.transition) { options.transition.appear = true } diff --git a/test/fixtures/basic/nuxt.config.js b/test/fixtures/basic/nuxt.config.js index ace0d54b37..1acc32b377 100644 --- a/test/fixtures/basic/nuxt.config.js +++ b/test/fixtures/basic/nuxt.config.js @@ -13,5 +13,6 @@ module.exports = { }, bad: null, '': true - } + }, + transition: false } diff --git a/test/fixtures/spa/nuxt.config.js b/test/fixtures/spa/nuxt.config.js index a17da47b52..bcbf687d27 100644 --- a/test/fixtures/spa/nuxt.config.js +++ b/test/fixtures/spa/nuxt.config.js @@ -1,5 +1,6 @@ module.exports = { rootDir: __dirname, mode: 'spa', - dev: false + dev: false, + transition: false } From 715ff581b9f89e259362cc1be9f2857b9779302e Mon Sep 17 00:00:00 2001 From: David Sandor Date: Thu, 16 Nov 2017 06:04:39 -0500 Subject: [PATCH 261/316] use the new hooks system instead of a plugin. --- lib/builder/generator.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/builder/generator.js b/lib/builder/generator.js index dabedf2fbb..385a190c75 100644 --- a/lib/builder/generator.js +++ b/lib/builder/generator.js @@ -67,7 +67,7 @@ export default class Generator { await Promise.all(routes.splice(0, this.options.generate.concurrency).map(async ({ route, payload }) => { await waitFor(n++ * this.options.generate.interval) await this.generateRoute({ route, payload, errors }) - await this.applyPluginsAsync('generated-route', { generator: this, routes, route, errors }) + await this.nuxt.callHook('generate:routeCreated', route) })) } From 4b79c38f41786566f86b993ef2ae3f5151c6a9c0 Mon Sep 17 00:00:00 2001 From: Atinux Date: Thu, 16 Nov 2017 13:22:45 +0100 Subject: [PATCH 262/316] fix: Fix Cannot read property 'components' of undefined --- lib/app/components/nuxt.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/app/components/nuxt.js b/lib/app/components/nuxt.js index f0bad06587..243eec2023 100644 --- a/lib/app/components/nuxt.js +++ b/lib/app/components/nuxt.js @@ -29,7 +29,7 @@ export default { if (typeof this.nuxtChildKey !== 'undefined' || this.$route.matched.length > 1) { return this.nuxtChildKey || compile(this.$route.matched[0].path)(this.$route.params) } - const Component = this.$route.matched[0].components.default + const Component = this.$route.matched[0] && this.$route.matched[0].components.default if (Component && Component.options && Component.options.key) { return (typeof Component.options.key === 'function' ? Component.options.key(this.$route) : Component.options.key) } From f4577e566c51ffc167a217d9f3979763bc0c9e5e Mon Sep 17 00:00:00 2001 From: Atinux Date: Thu, 16 Nov 2017 13:32:11 +0100 Subject: [PATCH 263/316] fix: Handle head as a function in nuxt.config.js --- lib/app/App.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/app/App.js b/lib/app/App.js index dd52c9d252..0d0e719837 100644 --- a/lib/app/App.js +++ b/lib/app/App.js @@ -15,7 +15,7 @@ layoutsKeys.forEach(function (key, i) { %> let resolvedLayouts = {} export default { - head: <%= serialize(head).replace('titleTemplate(', 'function(') %>, + head: <%= serialize(head).replace('head(', 'function(').replace('titleTemplate(', 'function(') %>, render(h, props) { <% if (loading) { %>const loadingEl = h('nuxt-loading', { ref: 'loading' })<% } %> const layoutEl = h(this.layout || 'nuxt') From 673630eb58acb96897540207118da8080146d0d0 Mon Sep 17 00:00:00 2001 From: Gomah Date: Fri, 17 Nov 2017 00:33:19 +1100 Subject: [PATCH 264/316] Add tests for nuxt:generate without subfolders --- test/basic.generate.nosubfolders.test.js | 135 +++++++++++++++++++++++ test/fixtures/basic/nuxt.config.js | 3 +- 2 files changed, 137 insertions(+), 1 deletion(-) create mode 100644 test/basic.generate.nosubfolders.test.js diff --git a/test/basic.generate.nosubfolders.test.js b/test/basic.generate.nosubfolders.test.js new file mode 100644 index 0000000000..5fde5d65b9 --- /dev/null +++ b/test/basic.generate.nosubfolders.test.js @@ -0,0 +1,135 @@ +import test from 'ava' +import { resolve } from 'path' +import http from 'http' +import serveStatic from 'serve-static' +import finalhandler from 'finalhandler' +import rp from 'request-promise-native' +import { Nuxt, Builder, Generator } from '../index.js' + +const port = 4002 +const url = (route) => 'http://localhost:' + port + route + +let nuxt = null +let server = null + +// Init nuxt.js and create server listening on localhost:4000 +test.before('Init Nuxt.js', async t => { + const rootDir = resolve(__dirname, 'fixtures/basic') + let config = require(resolve(rootDir, 'nuxt.config.js')) + config.rootDir = rootDir + config.dev = false + config.generate.subFolders = false + + nuxt = new Nuxt(config) + const builder = new Builder(nuxt) + const generator = new Generator(nuxt, builder) + try { + await generator.generate() // throw an error (of /validate route) + } catch (err) { + } + + const serve = serveStatic(resolve(__dirname, 'fixtures/basic/dist'), { extensions: ['html'] }) + server = http.createServer((req, res) => { + serve(req, res, finalhandler(req, res)) + }) + server.listen(port) +}) + +test('Check ready hook called', async t => { + t.true(nuxt.__hook_called__) +}) + +test('/stateless', async t => { + const window = await nuxt.renderAndGetWindow(url('/stateless')) + const html = window.document.body.innerHTML + t.true(html.includes('

      My component!

      ')) +}) + +test('/css', async t => { + const window = await nuxt.renderAndGetWindow(url('/css')) + const element = window.document.querySelector('.red') + t.not(element, null) + t.is(element.textContent, 'This is red') + t.is(element.className, 'red') + t.is(window.getComputedStyle(element).color, 'red') +}) + +test('/stateful', async t => { + const window = await nuxt.renderAndGetWindow(url('/stateful')) + const html = window.document.body.innerHTML + t.true(html.includes('

      The answer is 42

      ')) +}) + +test('/head', async t => { + const window = await nuxt.renderAndGetWindow(url('/head')) + const html = window.document.body.innerHTML + const metas = window.document.getElementsByTagName('meta') + t.is(window.document.title, 'My title') + t.is(metas[0].getAttribute('content'), 'my meta') + t.true(html.includes('

      I can haz meta tags

      ')) +}) + +test('/async-data', async t => { + const window = await nuxt.renderAndGetWindow(url('/async-data')) + const html = window.document.body.innerHTML + t.true(html.includes('

      Nuxt.js

      ')) +}) + +test('/users/1', async t => { + const html = await rp(url('/users/1')) + t.true(html.includes('

      User: 1

      ')) +}) + +test('/users/2', async t => { + const html = await rp(url('/users/2')) + t.true(html.includes('

      User: 2

      ')) +}) + +test('/users/3 (payload given)', async t => { + const html = await rp(url('/users/3')) + t.true(html.includes('

      User: 3000

      ')) +}) + +test('/users/4 -> Not found', async t => { + try { + await rp(url('/users/4')) + } catch (error) { + t.true(error.statusCode === 404) + t.true(error.response.body.includes('Cannot GET /users/4')) + } +}) + +test('/validate should not be server-rendered', async t => { + const html = await rp(url('/validate')) + t.true(html.includes('
      ')) + t.true(html.includes('serverRendered:!1')) +}) + +test('/validate -> should display a 404', async t => { + const window = await nuxt.renderAndGetWindow(url('/validate')) + const html = window.document.body.innerHTML + t.true(html.includes('This page could not be found')) +}) + +test('/validate?valid=true', async t => { + const window = await nuxt.renderAndGetWindow(url('/validate?valid=true')) + const html = window.document.body.innerHTML + t.true(html.includes('I am valid')) +}) + +test('/redirect should not be server-rendered', async t => { + const html = await rp(url('/redirect')) + t.true(html.includes('
      ')) + t.true(html.includes('serverRendered:!1')) +}) + +test('/redirect -> check redirected source', async t => { + const window = await nuxt.renderAndGetWindow(url('/redirect')) + const html = window.document.body.innerHTML + t.true(html.includes('

      Index page

      ')) +}) + +// Close server and ask nuxt to stop listening to file changes +test.after('Closing server', t => { + server.close() +}) diff --git a/test/fixtures/basic/nuxt.config.js b/test/fixtures/basic/nuxt.config.js index ace0d54b37..00114dee60 100644 --- a/test/fixtures/basic/nuxt.config.js +++ b/test/fixtures/basic/nuxt.config.js @@ -5,7 +5,8 @@ module.exports = { '/users/2', { route: '/users/3', payload: { id: 3000 } } ], - interval: 200 + interval: 200, + subFolders: true }, hooks: { ready(nuxt) { From 5c69e0e288c68914d5a4bd88bd9eae523fba7e78 Mon Sep 17 00:00:00 2001 From: Gomah Date: Fri, 17 Nov 2017 11:27:30 +1100 Subject: [PATCH 265/316] tests: make sure the files generated with the subFolders option exist --- test/basic.generate.nosubfolders.test.js | 3 +++ test/basic.generate.test.js | 3 +++ 2 files changed, 6 insertions(+) diff --git a/test/basic.generate.nosubfolders.test.js b/test/basic.generate.nosubfolders.test.js index 5fde5d65b9..ce9c1d813a 100644 --- a/test/basic.generate.nosubfolders.test.js +++ b/test/basic.generate.nosubfolders.test.js @@ -1,5 +1,6 @@ import test from 'ava' import { resolve } from 'path' +import { existsSync } from 'fs' import http from 'http' import serveStatic from 'serve-static' import finalhandler from 'finalhandler' @@ -78,6 +79,8 @@ test('/async-data', async t => { test('/users/1', async t => { const html = await rp(url('/users/1')) t.true(html.includes('

      User: 1

      ')) + t.true(existsSync(resolve(__dirname, 'fixtures/basic/dist', 'users/1.html'))) + t.false(existsSync(resolve(__dirname, 'fixtures/basic/dist', 'users/1/index.html'))) }) test('/users/2', async t => { diff --git a/test/basic.generate.test.js b/test/basic.generate.test.js index dc0eb55caf..0e1020847e 100644 --- a/test/basic.generate.test.js +++ b/test/basic.generate.test.js @@ -1,5 +1,6 @@ import test from 'ava' import { resolve } from 'path' +import { existsSync } from 'fs' import http from 'http' import serveStatic from 'serve-static' import finalhandler from 'finalhandler' @@ -75,6 +76,8 @@ test('/async-data', async t => { test('/users/1', async t => { const html = await rp(url('/users/1')) t.true(html.includes('

      User: 1

      ')) + t.true(existsSync(resolve(__dirname, 'fixtures/basic/dist', 'users/1/index.html'))) + t.false(existsSync(resolve(__dirname, 'fixtures/basic/dist', 'users/1.html'))) }) test('/users/2', async t => { From 7f8671f1de1532c25c3e1dbaba5d7d0bdaf71cae Mon Sep 17 00:00:00 2001 From: Clark Du Date: Fri, 17 Nov 2017 16:27:34 +0800 Subject: [PATCH 266/316] test: call created and mounted only once with spa and custom layout --- test/fixtures/spa/layouts/default.vue | 7 +++++++ test/fixtures/spa/pages/custom.vue | 4 +++- test/spa.test.js | 12 ++++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 test/fixtures/spa/layouts/default.vue diff --git a/test/fixtures/spa/layouts/default.vue b/test/fixtures/spa/layouts/default.vue new file mode 100644 index 0000000000..fe69c5ced6 --- /dev/null +++ b/test/fixtures/spa/layouts/default.vue @@ -0,0 +1,7 @@ + diff --git a/test/fixtures/spa/pages/custom.vue b/test/fixtures/spa/pages/custom.vue index e2c5286044..ccd8675d81 100644 --- a/test/fixtures/spa/pages/custom.vue +++ b/test/fixtures/spa/pages/custom.vue @@ -5,8 +5,10 @@ diff --git a/test/fixtures/with-config/nuxt.config.js b/test/fixtures/with-config/nuxt.config.js index 5454ed2a36..34012a7fc1 100644 --- a/test/fixtures/with-config/nuxt.config.js +++ b/test/fixtures/with-config/nuxt.config.js @@ -46,9 +46,6 @@ module.exports = { generateStatsFile: true }, extend(config, options) { - if (options.dev) { - // Please use isDev instead of dev - } return Object.assign({}, config, { devtool: 'nosources-source-map' }) diff --git a/test/module.test.js b/test/module.test.js index 3baf9782ac..d8fceedfb1 100755 --- a/test/module.test.js +++ b/test/module.test.js @@ -63,13 +63,6 @@ test('Hooks - Error', async t => { t.true(errors.length === 1) }) -// Note: Plugin is deprecated. Please use new hooks system. -test('Plugin', async t => { - t.is(nuxt.__builder_plugin, 4) - const error = builtErr.filter(value => value.indexOf('deprecated') >= 0) - t.true(error.length === 1) -}) - // Close server and ask nuxt to stop listening to file changes test.after('Closing server and nuxt.js', t => { nuxt.close() diff --git a/test/with-config.test.js b/test/with-config.test.js index 20c3a25bab..f179df1e39 100644 --- a/test/with-config.test.js +++ b/test/with-config.test.js @@ -1,6 +1,5 @@ import test from 'ava' import { resolve } from 'path' -import stdMocks from 'std-mocks' import rp from 'request-promise-native' import { Nuxt, Builder } from '../index.js' @@ -8,7 +7,6 @@ const port = 4007 const url = (route) => 'http://localhost:' + port + route let nuxt = null -let builtErr = null // Init nuxt.js and create server listening on localhost:4000 test.before('Init Nuxt.js', async t => { @@ -17,15 +15,7 @@ test.before('Init Nuxt.js', async t => { config.rootDir = rootDir config.dev = false nuxt = new Nuxt(config) - - stdMocks.use({ - stdout: false, - stderr: true - }) await new Builder(nuxt).build() - stdMocks.restore() - builtErr = stdMocks.flush().stderr - await nuxt.listen(port, 'localhost') }) @@ -133,12 +123,6 @@ test('Check /test.txt should return 404', async t => { t.is(err.response.statusCode, 404) }) -test('Check deprecated dev in build.extend()', async t => { - const deprecatedMsg = 'dev has been deprecated in build.extend(), please use isDev\n' - const errors = builtErr.filter(value => value === deprecatedMsg) - t.true(errors.length === 2) -}) - // Close server and ask nuxt to stop listening to file changes test.after('Closing server and nuxt.js', t => { nuxt.close() From 9fb2fdf4f5a97217d2b0f310b45afaa1dc7235db Mon Sep 17 00:00:00 2001 From: Dmitri Efimenko Date: Tue, 21 Nov 2017 02:56:14 +0300 Subject: [PATCH 278/316] build.styleResourcesLoader https://github.com/yenshih/style-resources-loader --- examples/style-resources/README.md | 3 +++ examples/style-resources/assets/resources.scss | 1 + examples/style-resources/nuxt.config.js | 9 +++++++++ examples/style-resources/package.json | 11 +++++++++++ examples/style-resources/pages/index.vue | 12 ++++++++++++ lib/builder/webpack/style-loader.js | 12 +++++++++++- package.json | 1 + 7 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 examples/style-resources/README.md create mode 100644 examples/style-resources/assets/resources.scss create mode 100644 examples/style-resources/nuxt.config.js create mode 100644 examples/style-resources/package.json create mode 100755 examples/style-resources/pages/index.vue diff --git a/examples/style-resources/README.md b/examples/style-resources/README.md new file mode 100644 index 0000000000..58371a7551 --- /dev/null +++ b/examples/style-resources/README.md @@ -0,0 +1,3 @@ +# Using build.styleResources with Nuxt.js + +https://nuxtjs.org/examples diff --git a/examples/style-resources/assets/resources.scss b/examples/style-resources/assets/resources.scss new file mode 100644 index 0000000000..81a376da5c --- /dev/null +++ b/examples/style-resources/assets/resources.scss @@ -0,0 +1 @@ +$main: #ccc; diff --git a/examples/style-resources/nuxt.config.js b/examples/style-resources/nuxt.config.js new file mode 100644 index 0000000000..ed8339dee0 --- /dev/null +++ b/examples/style-resources/nuxt.config.js @@ -0,0 +1,9 @@ +module.exports = { + build: { + styleResources: { + patterns: [ + './assets/resources.scss' + ] + } + } +} diff --git a/examples/style-resources/package.json b/examples/style-resources/package.json new file mode 100644 index 0000000000..2e16d42040 --- /dev/null +++ b/examples/style-resources/package.json @@ -0,0 +1,11 @@ +{ + "name": "hello-nuxt", + "dependencies": { + "nuxt": "latest" + }, + "scripts": { + "dev": "nuxt", + "build": "nuxt build", + "start": "nuxt start" + } +} diff --git a/examples/style-resources/pages/index.vue b/examples/style-resources/pages/index.vue new file mode 100755 index 0000000000..920d697356 --- /dev/null +++ b/examples/style-resources/pages/index.vue @@ -0,0 +1,12 @@ + + + diff --git a/lib/builder/webpack/style-loader.js b/lib/builder/webpack/style-loader.js index 1e4b71171d..90f29d57be 100755 --- a/lib/builder/webpack/style-loader.js +++ b/lib/builder/webpack/style-loader.js @@ -56,10 +56,20 @@ export default function styleLoader(ext, loaders = [], isVueLoader = false) { }) } + // https://github.com/yenshih/style-resources-loader + let styleResourcesLoader + if (this.options.build.styleResources) { + styleResourcesLoader = { + loader: 'style-resources-loader', + options: this.options.build.styleResources + } + } + return [ vueStyleLoader, cssLoader, postcssLoader, - ...loaders + ...loaders, + styleResourcesLoader ].filter(l => l) } diff --git a/package.json b/package.json index 587da9634f..f82912b4eb 100644 --- a/package.json +++ b/package.json @@ -108,6 +108,7 @@ "server-destroy": "^1.0.1", "source-map": "^0.6.1", "source-map-support": "^0.5.0", + "style-resources-loader": "^0.3.0", "uglifyjs-webpack-plugin": "^1.0.1", "url-loader": "^0.6.2", "vue": "^2.5.6", From f71abff6c6a1594649d734eb04a5f38c99a61a8c Mon Sep 17 00:00:00 2001 From: Dmitri Efimenko Date: Tue, 21 Nov 2017 03:02:21 +0300 Subject: [PATCH 279/316] Fix style-resources example --- examples/style-resources/pages/index.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/style-resources/pages/index.vue b/examples/style-resources/pages/index.vue index 920d697356..d414f78af6 100755 --- a/examples/style-resources/pages/index.vue +++ b/examples/style-resources/pages/index.vue @@ -7,6 +7,6 @@ From e56adee99894adc92f993eb77c3d7d95c412bfe6 Mon Sep 17 00:00:00 2001 From: Dmitri Efimenko Date: Tue, 21 Nov 2017 03:14:06 +0300 Subject: [PATCH 280/316] Fix style-resources package.json --- examples/style-resources/package.json | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/examples/style-resources/package.json b/examples/style-resources/package.json index 2e16d42040..6e9386ab8b 100644 --- a/examples/style-resources/package.json +++ b/examples/style-resources/package.json @@ -1,5 +1,5 @@ { - "name": "hello-nuxt", + "name": "style-resources", "dependencies": { "nuxt": "latest" }, @@ -7,5 +7,9 @@ "dev": "nuxt", "build": "nuxt build", "start": "nuxt start" + }, + "devDependencies": { + "node-sass": "^4.7.2", + "sass-loader": "^6.0.6" } } From 162b56ee4e34e2dffa84b321afd8b7c586fe0aec Mon Sep 17 00:00:00 2001 From: Clark Du Date: Tue, 21 Nov 2017 09:54:02 +0800 Subject: [PATCH 281/316] test: custom postcss config --- test/fixtures/with-config/nuxt.config.js | 1 + test/fixtures/with-config/pages/index.vue | 6 ++++++ test/fixtures/with-config/postcss.config.js | 17 +++++++++++++++++ test/with-config.test.js | 5 +++++ 4 files changed, 29 insertions(+) create mode 100644 test/fixtures/with-config/postcss.config.js diff --git a/test/fixtures/with-config/nuxt.config.js b/test/fixtures/with-config/nuxt.config.js index 34012a7fc1..8acd8c068f 100644 --- a/test/fixtures/with-config/nuxt.config.js +++ b/test/fixtures/with-config/nuxt.config.js @@ -19,6 +19,7 @@ module.exports = { modulesDir: path.join(__dirname, '..', '..', '..', 'node_modules'), transition: 'test', layoutTransition: 'test', + loadingIndicator: 'circle', offline: true, plugins: [ '~/plugins/test.js', diff --git a/test/fixtures/with-config/pages/index.vue b/test/fixtures/with-config/pages/index.vue index a24e4f00e8..4655686e0f 100644 --- a/test/fixtures/with-config/pages/index.vue +++ b/test/fixtures/with-config/pages/index.vue @@ -4,3 +4,9 @@ About page + + diff --git a/test/fixtures/with-config/postcss.config.js b/test/fixtures/with-config/postcss.config.js new file mode 100644 index 0000000000..a09f38e1b9 --- /dev/null +++ b/test/fixtures/with-config/postcss.config.js @@ -0,0 +1,17 @@ +const path = require('path') +const modulesDir = path.join(__dirname, '..', '..', '..', 'node_modules') +const rootDir = __dirname + +module.exports = { + plugins: { + 'postcss-import': { + root: rootDir, + path: [ + rootDir, + modulesDir + ] + }, + 'postcss-url': {}, + 'postcss-cssnext': {} + } +} diff --git a/test/with-config.test.js b/test/with-config.test.js index f179df1e39..0dd726da0c 100644 --- a/test/with-config.test.js +++ b/test/with-config.test.js @@ -44,6 +44,11 @@ test('/ (custom build.publicPath)', async t => { t.true(html.includes('src="/test/orion/vendor.')) }) +test('/ (custom postcss.config.js)', async t => { + const { html } = await nuxt.renderRoute('/') + t.true(html.includes('::-webkit-input-placeholder')) +}) + test('/test/ (router base)', async t => { const window = await nuxt.renderAndGetWindow(url('/test/')) const html = window.document.body.innerHTML From 9bf73b0b5a4d254d710d8e10bf57b177bee09655 Mon Sep 17 00:00:00 2001 From: Clark Du Date: Tue, 21 Nov 2017 15:38:12 +0800 Subject: [PATCH 282/316] test: inline postcss config --- test/basic.ssr.test.js | 6 ++++++ test/fixtures/basic/nuxt.config.js | 7 ++++++- test/fixtures/basic/pages/css.vue | 4 ++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/test/basic.ssr.test.js b/test/basic.ssr.test.js index 9b9a4d62a8..e3dc4559b2 100755 --- a/test/basic.ssr.test.js +++ b/test/basic.ssr.test.js @@ -43,6 +43,12 @@ test('/css', async t => { t.is(window.getComputedStyle(element).color, 'red') }) +test('/postcss', async t => { + const window = await nuxt.renderAndGetWindow(url('/css')) + const element = window.document.querySelector('div.red') + t.is(window.getComputedStyle(element)['background-color'], 'blue') +}) + test('/stateful', async t => { const { html } = await nuxt.renderRoute('/stateful') t.true(html.includes('

      The answer is 42

      ')) diff --git a/test/fixtures/basic/nuxt.config.js b/test/fixtures/basic/nuxt.config.js index e291976a5c..6d0b354c14 100644 --- a/test/fixtures/basic/nuxt.config.js +++ b/test/fixtures/basic/nuxt.config.js @@ -15,5 +15,10 @@ module.exports = { bad: null, '': true }, - transition: false + transition: false, + build: { + postcss: [ + require('postcss-cssnext')() + ] + } } diff --git a/test/fixtures/basic/pages/css.vue b/test/fixtures/basic/pages/css.vue index 902c7a07f2..08eca4556c 100755 --- a/test/fixtures/basic/pages/css.vue +++ b/test/fixtures/basic/pages/css.vue @@ -3,6 +3,10 @@