From d95e002d5b960cd8fb64ef34cc9caa8dfabb989f Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Thu, 20 May 2021 13:07:30 +0200 Subject: [PATCH] fix(automock): don't externalize .ts imports --- packages/nitro/src/rollup/plugins/automock.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/nitro/src/rollup/plugins/automock.ts b/packages/nitro/src/rollup/plugins/automock.ts index ffc34d2d17..79de6c39dd 100644 --- a/packages/nitro/src/rollup/plugins/automock.ts +++ b/packages/nitro/src/rollup/plugins/automock.ts @@ -1,10 +1,12 @@ import consola from 'consola' +const internalRegex = /^\.|\?|\.[mc]?js$|.ts$/ + export function autoMock () { return { name: 'auto-mock', resolveId (src: string) { - if (src && !src.startsWith('.') && !src.includes('?') && !src.includes('.js')) { + if (src && !internalRegex.test(src)) { consola.warn('Auto mock external ', src) return { id: require.resolve('unenv/runtime/mock/proxy')