From ad0649925d67b3ea456ac7694a3513823e567166 Mon Sep 17 00:00:00 2001 From: qm3ster Date: Wed, 7 Feb 2018 02:26:40 +0200 Subject: [PATCH 01/10] Refactor cli Extracted common logic Improved style consistency --- bin/common/utils.js | 43 +++++++++++++++++++++++++ bin/nuxt | 9 ++++-- bin/nuxt-build | 27 +++------------- bin/nuxt-dev | 76 +++++++++++++++++---------------------------- bin/nuxt-generate | 23 ++------------ bin/nuxt-start | 28 +++-------------- 6 files changed, 92 insertions(+), 114 deletions(-) create mode 100644 bin/common/utils.js diff --git a/bin/common/utils.js b/bin/common/utils.js new file mode 100644 index 0000000000..63aa89dd3d --- /dev/null +++ b/bin/common/utils.js @@ -0,0 +1,43 @@ +const { Utils } = require('../..') +const { resolve } = require('path') +const { existsSync } = require('fs') + +const getRootDir = argv => resolve(argv._[0] || '.') +const getNuxtConfigFile = argv => resolve(getRootDir(argv), argv['config-file']) + +exports.nuxtConfigFile = getNuxtConfigFile + +exports.loadNuxtConfig = argv => { + const rootDir = getRootDir(argv) + const nuxtConfigFile = getNuxtConfigFile(argv) + + let options = {} + + if (existsSync(nuxtConfigFile)) { + delete require.cache[nuxtConfigFile] + options = require(nuxtConfigFile) + } else if (argv['config-file'] !== 'nuxt.config.js') { + Utils.fatalError('Could not load config file: ' + argv['config-file']) + } + + if (typeof options.rootDir !== 'string') { + options.rootDir = rootDir + } + + // Nuxt Mode + options.mode = + (argv['spa'] && 'spa') || (argv['universal'] && 'universal') || options.mode + + return options +} + +exports.getLatestHost = argv => { + 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 + + return { port, host } +} diff --git a/bin/nuxt b/bin/nuxt index a1ddd8b065..cd0ec2590a 100755 --- a/bin/nuxt +++ b/bin/nuxt @@ -4,9 +4,10 @@ process.env.DEBUG = process.env.DEBUG || 'nuxt:*' const { join } = require('path') -const { name, engines } = require('../package.json') const semver = require('semver') + const { Utils } = require('..') +const { name, engines } = require('../package.json') // Global error handler process.on('unhandledRejection', _error => { @@ -14,7 +15,11 @@ process.on('unhandledRejection', _error => { }) if (!semver.satisfies(process.version, engines.node)) { - Utils.fatalError(`The engine "node" is incompatible with ${name}. Expected version "${engines.node}".`) + Utils.fatalError( + `The engine "node" is incompatible with ${name}. Expected version "${ + engines.node + }".` + ) } const defaultCommand = 'dev' diff --git a/bin/nuxt-build b/bin/nuxt-build index c171ca1ee0..552d2a463b 100755 --- a/bin/nuxt-build +++ b/bin/nuxt-build @@ -1,13 +1,13 @@ #!/usr/bin/env node /* eslint-disable no-console */ -const fs = require('fs') const parseArgs = require('minimist') -const { Nuxt, Builder, Generator, Utils } = require('..') -const resolve = require('path').resolve const debug = require('debug')('nuxt:build') debug.color = 2 // Force green color +const { Nuxt, Builder, Generator, Utils } = require('..') +const { loadNuxtConfig } = require('./common/utils') + const argv = parseArgs(process.argv.slice(2), { alias: { h: 'help', @@ -39,26 +39,11 @@ if (argv.help) { process.exit(0) } -const rootDir = resolve(argv._[0] || '.') -const nuxtConfigFile = resolve(rootDir, argv['config-file']) - -var options = {} -if (fs.existsSync(nuxtConfigFile)) { - options = require(nuxtConfigFile) -} else if (argv['config-file'] !== 'nuxt.config.js') { - Utils.fatalError(`Could not load config file`, argv['config-file']) -} -if (typeof options.rootDir !== 'string') { - options.rootDir = rootDir -} +const options = loadNuxtConfig(argv) // Create production build when calling `nuxt build` options.dev = false -// Nuxt Mode -options.mode = - (argv['spa'] && 'spa') || (argv['universal'] && 'universal') || options.mode - // Analyze option options.build = options.build || {} if (argv.analyze) { @@ -86,9 +71,7 @@ if (options.mode !== 'spa') { .build() .then(() => debug('Building done')) .then(() => close()) - .catch(err => { - Utils.fatalError(err) - }) + .catch(Utils.fatalError) } else { // -- Build for SPA app -- const s = Date.now() diff --git a/bin/nuxt-dev b/bin/nuxt-dev index 74f365774e..e71811cbed 100755 --- a/bin/nuxt-dev +++ b/bin/nuxt-dev @@ -1,16 +1,19 @@ #!/usr/bin/env node /* eslint-disable no-console */ -const _ = require('lodash') +const defaultsDeep = require('lodash/defaultsDeep') const debug = require('debug')('nuxt:build') debug.color = 2 // force green color -const fs = require('fs') const parseArgs = require('minimist') -const { Nuxt, Builder, Utils } = require('..') const chokidar = require('chokidar') -const path = require('path') -const resolve = path.resolve -const pkg = require(path.join('..', 'package.json')) +const { version } = require('../package.json') + +const { Nuxt, Builder, Utils } = require('..') +const { + loadNuxtConfig, + getLatestHost, + nuxtConfigFile +} = require('./common/utils') const argv = parseArgs(process.argv.slice(2), { alias: { @@ -30,7 +33,7 @@ const argv = parseArgs(process.argv.slice(2), { }) if (argv.version) { - console.log(pkg.version) + console.log(version) process.exit(0) } @@ -56,39 +59,33 @@ if (argv.help) { process.exit(0) } -const rootDir = resolve(argv._[0] || '.') -const nuxtConfigFile = resolve(rootDir, argv['config-file']) - // Load config once for chokidar -const nuxtConfig = loadNuxtConfig() -_.defaultsDeep(nuxtConfig, { watchers: { chokidar: { ignoreInitial: true } } }) +const nuxtConfig = loadNuxtConfig(argv) +defaultsDeep(nuxtConfig, { watchers: { chokidar: { ignoreInitial: true } } }) // Start dev let dev = startDev() let needToRestart = false // Start watching for nuxt.config.js changes -chokidar.watch(nuxtConfigFile, nuxtConfig.watchers.chokidar).on('all', () => { - debug('[nuxt.config.js] changed') - needToRestart = true +chokidar + .watch(nuxtConfigFile(argv), nuxtConfig.watchers.chokidar) + .on('all', () => { + debug('[nuxt.config.js] changed') + needToRestart = true - dev = dev.then(instance => { - if (needToRestart === false) return instance - needToRestart = false + dev = dev.then(instance => { + if (needToRestart === false) return instance + needToRestart = false - debug('Rebuilding the app...') - return startDev(instance) + debug('Rebuilding the app...') + return startDev(instance) + }) }) -}) function startDev(oldInstance) { // 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 + const { port, host } = getLatestHost(argv) // Error handler const onError = (err, instance) => { @@ -99,7 +96,7 @@ function startDev(oldInstance) { // Load options let options = {} try { - options = loadNuxtConfig() + options = loadAndAugmentNuxtConfig() } catch (err) { return onError(err, oldInstance) } @@ -111,9 +108,9 @@ function startDev(oldInstance) { try { nuxt = new Nuxt(options) builder = new Builder(nuxt) - instance = { nuxt: nuxt, builder: builder } + instance = { nuxt, builder } } catch (err) { - return onError(err, instance || oldInstance) + return onError(err, oldInstance) } return ( @@ -142,26 +139,11 @@ function startDev(oldInstance) { ) } -function loadNuxtConfig() { - let options = {} - - if (fs.existsSync(nuxtConfigFile)) { - delete require.cache[nuxtConfigFile] - options = require(nuxtConfigFile) - } else if (argv['config-file'] !== 'nuxt.config.js') { - Utils.fatalError('Could not load config file: ' + argv['config-file']) - } - - if (typeof options.rootDir !== 'string') { - options.rootDir = rootDir - } +function loadAndAugmentNuxtConfig() { + const options = loadNuxtConfig(argv) // Force development mode for add hot reloading and watching changes options.dev = true - // Nuxt Mode - options.mode = - (argv['spa'] && 'spa') || (argv['universal'] && 'universal') || options.mode - return options } diff --git a/bin/nuxt-generate b/bin/nuxt-generate index 6c21d1fa36..292731a4fa 100755 --- a/bin/nuxt-generate +++ b/bin/nuxt-generate @@ -1,12 +1,11 @@ #!/usr/bin/env node /* eslint-disable no-console */ -const fs = require('fs') const parseArgs = require('minimist') const debug = require('debug')('nuxt:generate') const { Nuxt, Builder, Generator, Utils } = require('..') -const resolve = require('path').resolve +const { loadNuxtConfig } = require('./common/utils') const argv = parseArgs(process.argv.slice(2), { alias: { @@ -39,24 +38,10 @@ if (argv.help) { process.exit(0) } -const rootDir = resolve(argv._[0] || '.') -const nuxtConfigFile = resolve(rootDir, argv['config-file']) +const options = loadNuxtConfig(argv) -var options = {} -if (fs.existsSync(nuxtConfigFile)) { - options = require(nuxtConfigFile) -} else if (argv['config-file'] !== 'nuxt.config.js') { - Utils.fatalError('Could not load config file: ' + argv['config-file']) -} -if (typeof options.rootDir !== 'string') { - options.rootDir = rootDir -} options.dev = false // Force production mode (no webpack middleware called) -// Nuxt Mode -options.mode = - (argv['spa'] && 'spa') || (argv['universal'] && 'universal') || options.mode - debug('Generating...') const nuxt = new Nuxt(options) const builder = new Builder(nuxt) @@ -97,6 +82,4 @@ generator debug('Generate done') process.exit(0) }) - .catch(err => { - Utils.fatalError(err) - }) + .catch(Utils.fatalError) diff --git a/bin/nuxt-start b/bin/nuxt-start index 50fd50bf46..7033e1711f 100755 --- a/bin/nuxt-start +++ b/bin/nuxt-start @@ -3,9 +3,11 @@ const fs = require('fs') const parseArgs = require('minimist') -const { Nuxt, Utils } = require('..') const { resolve } = require('path') +const { Nuxt, Utils } = require('..') +const { loadNuxtConfig, getLatestHost } = require('./common/utils') + const argv = parseArgs(process.argv.slice(2), { alias: { h: 'help', @@ -44,28 +46,11 @@ if (argv.help) { process.exit(0) } -const rootDir = resolve(argv._[0] || '.') -const nuxtConfigFile = resolve(rootDir, argv['config-file']) - -let options = {} - -if (fs.existsSync(nuxtConfigFile)) { - options = require(nuxtConfigFile) -} else if (argv['config-file'] !== 'nuxt.config.js') { - Utils.fatalError('Could not load config file: ' + argv['config-file']) -} - -if (typeof options.rootDir !== 'string') { - options.rootDir = rootDir -} +const options = loadNuxtConfig(argv) // Force production mode (no webpack middleware called) options.dev = false -// Nuxt Mode -options.mode = - (argv['spa'] && 'spa') || (argv['universal'] && 'universal') || options.mode - const nuxt = new Nuxt(options) // Setup hooks @@ -93,9 +78,6 @@ if (nuxt.options.render.ssr === true) { } } -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 +const { port, host } = getLatestHost(argv) nuxt.listen(port, host) From 9ab4ebde78050f8b5118647ee3c8d1565e8f5b5c Mon Sep 17 00:00:00 2001 From: Clark Du Date: Mon, 26 Feb 2018 21:30:15 +0800 Subject: [PATCH 02/10] Revert "refactor: styleResources watch patterns" This reverts commit a764fb691d2fe89652cd05e769c676e178637d46. --- lib/builder/builder.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/builder/builder.js b/lib/builder/builder.js index 3e37d24470..d61dce35e2 100644 --- a/lib/builder/builder.js +++ b/lib/builder/builder.js @@ -669,8 +669,8 @@ module.exports = class Builder { // Watch for custom provided files let customPatterns = _.concat( - this.options.build.watch || [], - _.values(_.omit(this.options.build.styleResources, 'options')) + this.options.build.watch, + ..._.values(_.omit(this.options.build.styleResources, ['options'])) ) customPatterns = _.map(_.uniq(customPatterns), p => upath.normalizeSafe(p) From 0a823252ae9c7d209a4880bbc5a3ebb3df0ce792 Mon Sep 17 00:00:00 2001 From: Hana Shiro Date: Tue, 27 Feb 2018 04:48:36 +0800 Subject: [PATCH 03/10] fix file permission in `lib` and `test` (#2883) --- lib/builder/index.js | 0 lib/builder/webpack/style-loader.js | 0 lib/common/index.js | 0 lib/common/options.js | 0 lib/core/index.js | 0 lib/core/module.js | 0 lib/index.js | 0 test/basic.ssr.test.js | 0 test/deprecate.test.js | 0 test/fixtures/basic/pages/async-data.vue | 0 test/fixtures/basic/pages/css.vue | 0 test/fixtures/basic/pages/head.vue | 0 test/fixtures/basic/pages/stateful.vue | 0 test/fixtures/basic/pages/stateless.vue | 0 test/fixtures/basic/store/index.js | 0 test/fixtures/deprecate/nuxt.config.js | 0 test/fixtures/deprecate/package.json | 0 test/fixtures/deprecate/pages/index.vue | 0 test/fixtures/error/nuxt.config.js | 0 test/fixtures/module/modules/basic/index.js | 0 test/fixtures/module/modules/basic/reverse.js | 0 test/fixtures/module/modules/empty/index.js | 0 test/fixtures/module/modules/middleware/index.js | 0 test/fixtures/module/modules/middleware/log.js | 0 test/fixtures/module/nuxt.config.js | 0 test/fixtures/module/package.json | 0 test/fixtures/module/views/index.vue | 0 test/fixtures/with-config/assets/app.css | 0 test/module.test.js | 0 test/spa.test.js | 0 test/ssr.test.js | 0 31 files changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 lib/builder/index.js mode change 100755 => 100644 lib/builder/webpack/style-loader.js mode change 100755 => 100644 lib/common/index.js mode change 100755 => 100644 lib/common/options.js mode change 100755 => 100644 lib/core/index.js mode change 100755 => 100644 lib/core/module.js mode change 100755 => 100644 lib/index.js mode change 100755 => 100644 test/basic.ssr.test.js mode change 100755 => 100644 test/deprecate.test.js mode change 100755 => 100644 test/fixtures/basic/pages/async-data.vue mode change 100755 => 100644 test/fixtures/basic/pages/css.vue mode change 100755 => 100644 test/fixtures/basic/pages/head.vue mode change 100755 => 100644 test/fixtures/basic/pages/stateful.vue mode change 100755 => 100644 test/fixtures/basic/pages/stateless.vue mode change 100755 => 100644 test/fixtures/basic/store/index.js mode change 100755 => 100644 test/fixtures/deprecate/nuxt.config.js mode change 100755 => 100644 test/fixtures/deprecate/package.json mode change 100755 => 100644 test/fixtures/deprecate/pages/index.vue mode change 100755 => 100644 test/fixtures/error/nuxt.config.js mode change 100755 => 100644 test/fixtures/module/modules/basic/index.js mode change 100755 => 100644 test/fixtures/module/modules/basic/reverse.js mode change 100755 => 100644 test/fixtures/module/modules/empty/index.js mode change 100755 => 100644 test/fixtures/module/modules/middleware/index.js mode change 100755 => 100644 test/fixtures/module/modules/middleware/log.js mode change 100755 => 100644 test/fixtures/module/nuxt.config.js mode change 100755 => 100644 test/fixtures/module/package.json mode change 100755 => 100644 test/fixtures/module/views/index.vue mode change 100755 => 100644 test/fixtures/with-config/assets/app.css mode change 100755 => 100644 test/module.test.js mode change 100755 => 100644 test/spa.test.js mode change 100755 => 100644 test/ssr.test.js diff --git a/lib/builder/index.js b/lib/builder/index.js old mode 100755 new mode 100644 diff --git a/lib/builder/webpack/style-loader.js b/lib/builder/webpack/style-loader.js old mode 100755 new mode 100644 diff --git a/lib/common/index.js b/lib/common/index.js old mode 100755 new mode 100644 diff --git a/lib/common/options.js b/lib/common/options.js old mode 100755 new mode 100644 diff --git a/lib/core/index.js b/lib/core/index.js old mode 100755 new mode 100644 diff --git a/lib/core/module.js b/lib/core/module.js old mode 100755 new mode 100644 diff --git a/lib/index.js b/lib/index.js old mode 100755 new mode 100644 diff --git a/test/basic.ssr.test.js b/test/basic.ssr.test.js old mode 100755 new mode 100644 diff --git a/test/deprecate.test.js b/test/deprecate.test.js old mode 100755 new mode 100644 diff --git a/test/fixtures/basic/pages/async-data.vue b/test/fixtures/basic/pages/async-data.vue old mode 100755 new mode 100644 diff --git a/test/fixtures/basic/pages/css.vue b/test/fixtures/basic/pages/css.vue old mode 100755 new mode 100644 diff --git a/test/fixtures/basic/pages/head.vue b/test/fixtures/basic/pages/head.vue old mode 100755 new mode 100644 diff --git a/test/fixtures/basic/pages/stateful.vue b/test/fixtures/basic/pages/stateful.vue old mode 100755 new mode 100644 diff --git a/test/fixtures/basic/pages/stateless.vue b/test/fixtures/basic/pages/stateless.vue old mode 100755 new mode 100644 diff --git a/test/fixtures/basic/store/index.js b/test/fixtures/basic/store/index.js old mode 100755 new mode 100644 diff --git a/test/fixtures/deprecate/nuxt.config.js b/test/fixtures/deprecate/nuxt.config.js old mode 100755 new mode 100644 diff --git a/test/fixtures/deprecate/package.json b/test/fixtures/deprecate/package.json old mode 100755 new mode 100644 diff --git a/test/fixtures/deprecate/pages/index.vue b/test/fixtures/deprecate/pages/index.vue old mode 100755 new mode 100644 diff --git a/test/fixtures/error/nuxt.config.js b/test/fixtures/error/nuxt.config.js old mode 100755 new mode 100644 diff --git a/test/fixtures/module/modules/basic/index.js b/test/fixtures/module/modules/basic/index.js old mode 100755 new mode 100644 diff --git a/test/fixtures/module/modules/basic/reverse.js b/test/fixtures/module/modules/basic/reverse.js old mode 100755 new mode 100644 diff --git a/test/fixtures/module/modules/empty/index.js b/test/fixtures/module/modules/empty/index.js old mode 100755 new mode 100644 diff --git a/test/fixtures/module/modules/middleware/index.js b/test/fixtures/module/modules/middleware/index.js old mode 100755 new mode 100644 diff --git a/test/fixtures/module/modules/middleware/log.js b/test/fixtures/module/modules/middleware/log.js old mode 100755 new mode 100644 diff --git a/test/fixtures/module/nuxt.config.js b/test/fixtures/module/nuxt.config.js old mode 100755 new mode 100644 diff --git a/test/fixtures/module/package.json b/test/fixtures/module/package.json old mode 100755 new mode 100644 diff --git a/test/fixtures/module/views/index.vue b/test/fixtures/module/views/index.vue old mode 100755 new mode 100644 diff --git a/test/fixtures/with-config/assets/app.css b/test/fixtures/with-config/assets/app.css old mode 100755 new mode 100644 diff --git a/test/module.test.js b/test/module.test.js old mode 100755 new mode 100644 diff --git a/test/spa.test.js b/test/spa.test.js old mode 100755 new mode 100644 diff --git a/test/ssr.test.js b/test/ssr.test.js old mode 100755 new mode 100644 From 757080e87d2a40fd54e8b8c04781b36b0873b1d1 Mon Sep 17 00:00:00 2001 From: "cinwell.li" Date: Wed, 28 Feb 2018 11:11:15 +0800 Subject: [PATCH 04/10] example: upgrade element-ui --- examples/with-element-ui/nuxt.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/with-element-ui/nuxt.config.js b/examples/with-element-ui/nuxt.config.js index 643f79ee78..e53632dade 100644 --- a/examples/with-element-ui/nuxt.config.js +++ b/examples/with-element-ui/nuxt.config.js @@ -3,7 +3,7 @@ module.exports = { ** Global CSS */ css: [ - 'element-ui/lib/theme-default/index.css' + 'element-ui/lib/theme-chalk/index.css' ], /* From 257f9bb62cb987fc139d0375b7b0508d7d193f83 Mon Sep 17 00:00:00 2001 From: "cinwell.li" Date: Wed, 28 Feb 2018 11:12:31 +0800 Subject: [PATCH 05/10] example: upgarde element-ui --- examples/with-element-ui/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/with-element-ui/package.json b/examples/with-element-ui/package.json index d5696a30ea..40dc968f5b 100644 --- a/examples/with-element-ui/package.json +++ b/examples/with-element-ui/package.json @@ -3,7 +3,7 @@ "version": "1.0.0", "license": "MIT", "dependencies": { - "element-ui": "^1.4.9", + "element-ui": "^2", "nuxt": "latest" }, "scripts": { From 6c8fcbdbd7d26bc55975981f8ebe2135f50ff39c Mon Sep 17 00:00:00 2001 From: "cinwell.li" Date: Wed, 28 Feb 2018 11:15:13 +0800 Subject: [PATCH 06/10] example: upgrade element-ui --- examples/with-element-ui/plugins/element-ui.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/with-element-ui/plugins/element-ui.js b/examples/with-element-ui/plugins/element-ui.js index cb618add96..346f98d67b 100644 --- a/examples/with-element-ui/plugins/element-ui.js +++ b/examples/with-element-ui/plugins/element-ui.js @@ -1,5 +1,5 @@ import Vue from 'vue' -import Element from 'element-ui/lib/element-ui.common' +import Element from 'element-ui' import locale from 'element-ui/lib/locale/lang/en' export default () => { From 8903db1c27942088754b8a37568e8fc364ed8c66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Chopin?= Date: Wed, 28 Feb 2018 16:40:59 +0100 Subject: [PATCH 07/10] fix: Fix watchQuery on reused page component --- lib/app/client.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/app/client.js b/lib/app/client.js index dc376da6da..0f6deac4b5 100644 --- a/lib/app/client.js +++ b/lib/app/client.js @@ -397,7 +397,7 @@ function fixPrepatch(to, ___) { instances.forEach((instance, i) => { if (!instance) return - if (to.matched[matches[i]].path.indexOf(':') === -1) return // If not a dyanmic route, skip + if (!this._queryChanged && to.matched[matches[i]].path.indexOf(':') === -1 && to.matched[matches[i]].path.indexOf('*') === -1) return // If not a dynamic route, skip if (instance.constructor._dataRefresh && _lastPaths[i] === instance.constructor._path && typeof instance.constructor.options.data === 'function') { const newData = instance.constructor.options.data.call(instance) for (let key in newData) { From ca13b6bfbbce8992046b5dc5294f104c40950bb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Chopin?= Date: Wed, 28 Feb 2018 16:46:48 +0100 Subject: [PATCH 08/10] fix: Comment line since we use _dataRefresh --- lib/app/client.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/app/client.js b/lib/app/client.js index 0f6deac4b5..0e4ee34a3b 100644 --- a/lib/app/client.js +++ b/lib/app/client.js @@ -397,7 +397,7 @@ function fixPrepatch(to, ___) { instances.forEach((instance, i) => { if (!instance) return - if (!this._queryChanged && to.matched[matches[i]].path.indexOf(':') === -1 && to.matched[matches[i]].path.indexOf('*') === -1) return // If not a dynamic route, skip + // if (!this._queryChanged && to.matched[matches[i]].path.indexOf(':') === -1 && to.matched[matches[i]].path.indexOf('*') === -1) return // If not a dynamic route, skip if (instance.constructor._dataRefresh && _lastPaths[i] === instance.constructor._path && typeof instance.constructor.options.data === 'function') { const newData = instance.constructor.options.data.call(instance) for (let key in newData) { From c79a861809089af386cae492994b1f75802b1103 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Thu, 1 Mar 2018 09:37:19 +0330 Subject: [PATCH 09/10] tests: add failing test for ignores (#2905) --- test/fixtures/basic/store/-ignored.js | 4 +--- test/fixtures/basic/store/ignored.test.js | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/test/fixtures/basic/store/-ignored.js b/test/fixtures/basic/store/-ignored.js index b96c60ff82..55585a388c 100644 --- a/test/fixtures/basic/store/-ignored.js +++ b/test/fixtures/basic/store/-ignored.js @@ -1,3 +1 @@ -export const state = () => ({ - error: 'Should be ignored' -}) +throw new Error('This file should be ignored!!') diff --git a/test/fixtures/basic/store/ignored.test.js b/test/fixtures/basic/store/ignored.test.js index b96c60ff82..55585a388c 100644 --- a/test/fixtures/basic/store/ignored.test.js +++ b/test/fixtures/basic/store/ignored.test.js @@ -1,3 +1 @@ -export const state = () => ({ - error: 'Should be ignored' -}) +throw new Error('This file should be ignored!!') From e0cc9a1cc6ffdfc87f944d0669ec1dd8d35130c9 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Thu, 1 Mar 2018 09:38:42 +0330 Subject: [PATCH 10/10] fix: ignore test files inside middleware and store (#2905) --- lib/app/middleware.js | 2 +- lib/app/store.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/app/middleware.js b/lib/app/middleware.js index 7eea33260b..1b728bdba6 100644 --- a/lib/app/middleware.js +++ b/lib/app/middleware.js @@ -1,5 +1,5 @@ <% if (middleware) { %> -let files = require.context('@/<%= dir.middleware %>', false, /^\.\/(?!<%= ignorePrefix %>).*\.(<%= extensions %>)$/) +let files = require.context('@/<%= dir.middleware %>', false, /^\.\/(?!<%= ignorePrefix %>)[^.]+\.(<%= extensions %>)$/) let filenames = files.keys() function getModule (filename) { diff --git a/lib/app/store.js b/lib/app/store.js index 831e87f664..f007d1d358 100644 --- a/lib/app/store.js +++ b/lib/app/store.js @@ -4,7 +4,7 @@ import Vuex from 'vuex' Vue.use(Vuex) // Recursive find files in {srcDir}/{dir.store} -const files = require.context('@/<%= dir.store %>', true, /^\.\/(?!<%= ignorePrefix %>).*\.(<%= extensions %>)$/) +const files = require.context('@/<%= dir.store %>', true, /^\.\/(?!<%= ignorePrefix %>)[^.]+\.(<%= extensions %>)$/) const filenames = files.keys() // Store