From fe6c524be10aafb476ee991880a416f30eabaa15 Mon Sep 17 00:00:00 2001 From: Clark Du Date: Tue, 7 Aug 2018 10:24:01 +0100 Subject: [PATCH] refactor: add deprecation log for addVendor --- lib/core/module.js | 5 +++-- test/unit/module.test.js | 10 ++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/core/module.js b/lib/core/module.js index 92ea656eff..eb8741aaa4 100644 --- a/lib/core/module.js +++ b/lib/core/module.js @@ -1,6 +1,7 @@ import path from 'path' import fs from 'fs' import hash from 'hash-sum' +import consola from 'consola' import { chainFn, sequence } from '../common/utils' export default class ModuleContainer { @@ -21,8 +22,8 @@ export default class ModuleContainer { await this.nuxt.callHook('modules:done', this) } - addVendor(vendor) { - // Make it silent for backward compatibility with nuxt 1.x + addVendor() { + consola.warn('addVendor has been deprecated due to webpack4 optimization') } addTemplate(template) { diff --git a/test/unit/module.test.js b/test/unit/module.test.js index e401c9c05c..8120cfcb65 100644 --- a/test/unit/module.test.js +++ b/test/unit/module.test.js @@ -1,4 +1,5 @@ import { normalize } from 'path' +import consola from 'consola' import { loadFixture, getPort, Nuxt, rp } from '../utils' let port @@ -58,6 +59,15 @@ describe('module', () => { expect(nuxt.__render_context).toBeTruthy() }) + test('AddVendor - deprecated', async () => { + jest.spyOn(consola, 'warn') + + nuxt.moduleContainer.addVendor('nuxt-test') + expect(consola.warn).toHaveBeenCalledWith('addVendor has been deprecated due to webpack4 optimization') + + consola.warn.mockRestore() + }) + // Close server and ask nuxt to stop listening to file changes afterAll(async () => { await nuxt.close()