fix(automock): don't externalize .ts imports

This commit is contained in:
Pooya Parsa 2021-05-20 13:07:30 +02:00
parent 82b585dbb0
commit d95e002d5b

View File

@ -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')