From d72b4537285e9077d3075b175f9571eb8ed0d1e0 Mon Sep 17 00:00:00 2001 From: Haoqun Jiang Date: Wed, 16 Oct 2019 13:28:00 +0800 Subject: [PATCH] fix: fix afterAnyInvoke hook compatibility with pnpm 4 Maybe caused by the change of resolve mechanism in pnpm 4, calling the hook from the creator would get a `Cannot find module` error. As a workaround, we now require and cache the module outside the callback function. --- packages/@vue/cli-plugin-eslint/generator/index.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/@vue/cli-plugin-eslint/generator/index.js b/packages/@vue/cli-plugin-eslint/generator/index.js index 89331a35eb..21b93a72f9 100644 --- a/packages/@vue/cli-plugin-eslint/generator/index.js +++ b/packages/@vue/cli-plugin-eslint/generator/index.js @@ -106,10 +106,12 @@ module.exports = (api, { config, lintOn = [] }, _, invoking) => { } } +const lint = require('../lint') + module.exports.hooks = (api) => { // lint & fix after create to ensure files adhere to chosen config api.afterAnyInvoke(() => { - require('../lint')({ silent: true }, api) + lint({ silent: true }, api) }) }