diff --git a/lib/builder/builder.js b/lib/builder/builder.js index ea009bed77..5351c43453 100644 --- a/lib/builder/builder.js +++ b/lib/builder/builder.js @@ -11,7 +11,7 @@ const webpackDevMiddleware = require('webpack-dev-middleware') const webpackHotMiddleware = require('webpack-hot-middleware') const Debug = require('debug') const Glob = require('glob') -const { r, wp, wChunk, createRoutes, sequence, relativeTo, waitFor, rmCache } = require('../common/utils') +const { r, wp, wChunk, createRoutes, sequence, relativeTo, waitFor } = require('../common/utils') const { Options } = require('../common') const clientWebpackConfig = require('./webpack/client.config.js') const serverWebpackConfig = require('./webpack/server.config.js') @@ -465,12 +465,6 @@ module.exports = class Builder { compiler.watch(this.options.watchers.webpack, (err) => { /* istanbul ignore if */ if (err) return reject(err) - // not keep modified or deleted items in Vue.prototype - Object.keys(require.cache).forEach(key => { - if (!/(node_modules\/postcss)|(\.node$)/.test(key)) { - rmCache(key) - } - }) }) ) return diff --git a/lib/common/utils.js b/lib/common/utils.js index 11b434b1d0..811809fc43 100644 --- a/lib/common/utils.js +++ b/lib/common/utils.js @@ -268,16 +268,3 @@ exports.createRoutes = function createRoutes(files, srcDir) { }) return cleanChildrenRoutes(routes) } - -exports.rmCache = function rmCache(path) { - const mod = require.cache[path] - delete require.cache[path] - if (mod.parent && mod.parent.children) { - for (let i = 0; i < mod.parent.children.length; i++) { - if (mod.parent.children[i] === mod) { - mod.parent.children.splice(i, 1) - break - } - } - } -} diff --git a/test/basic.dev.test.js b/test/basic.dev.test.js index 02d08993fa..a622fa9a03 100644 --- a/test/basic.dev.test.js +++ b/test/basic.dev.test.js @@ -1,14 +1,11 @@ import test from 'ava' import { resolve } from 'path' import { intercept, release } from './helpers/console' -import { Nuxt, Builder, Utils } from '..' -import { truncateSync, readFileSync, writeFileSync } from 'fs' +import { Nuxt, Builder } from '..' const port = 4001 const url = (route) => 'http://localhost:' + port + route const rootDir = resolve(__dirname, 'fixtures/basic') -const pluginPath = resolve(rootDir, 'plugins', 'watch.js') -const pluginContent = readFileSync(pluginPath) let nuxt = null @@ -24,10 +21,7 @@ test.serial('Init Nuxt.js', async t => { extractCSS: { allChunks: true } - }, - plugins: [ - '~/plugins/watch.js' - ] + } } const spies = await intercept({ log: true, stderr: true }, async () => { @@ -49,31 +43,6 @@ test.serial('Init Nuxt.js', async t => { // t.is(window.getComputedStyle(window.document.body).getPropertyValue('font-size'), '30px') // }) -test.serial('remove mixins in live reloading', async t => { - const spies = await intercept({ log: true, error: true, stderr: true }) - await nuxt.renderRoute(url('/')) - t.true(spies.log.calledWith('I am mixin')) - - truncateSync(pluginPath) - await new Promise(async (resolve, reject) => { - let waitTimes = 0 - while (spies.log.neverCalledWithMatch(/Compiled successfully/)) { - if (waitTimes++ >= 20) { - t.fail('Dev server doesn\'t reload after 2000ms') - reject(Error()) - } - await Utils.waitFor(100) - } - resolve() - }) - spies.log.reset() - - await nuxt.renderRoute(url('/')) - t.true(spies.log.neverCalledWith('I am mixin')) - t.is(spies.error.getCall(0).args[0].statusCode, 404) - release() -}) - test.serial('/stateless', async t => { const spies = await intercept() const window = await nuxt.renderAndGetWindow(url('/stateless')) @@ -94,6 +63,5 @@ test.serial('/stateless', async t => { // Close server and ask nuxt to stop listening to file changes test.after.always('Closing server and nuxt.js', async t => { - writeFileSync(pluginPath, pluginContent) await nuxt.close() }) diff --git a/test/fixtures/basic/plugins/watch.js b/test/fixtures/basic/plugins/watch.js deleted file mode 100644 index b243a212ab..0000000000 --- a/test/fixtures/basic/plugins/watch.js +++ /dev/null @@ -1,12 +0,0 @@ -import Vue from 'vue' - -const Plugin = { - install(Vue) { - Vue.mixin({ - created() { - console.log('I am mixin') // eslint-disable-line no-console - } - }) - } -} -Vue.use(Plugin)