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' import consola from 'consola'
const internalRegex = /^\.|\?|\.[mc]?js$|.ts$/
export function autoMock () { export function autoMock () {
return { return {
name: 'auto-mock', name: 'auto-mock',
resolveId (src: string) { resolveId (src: string) {
if (src && !src.startsWith('.') && !src.includes('?') && !src.includes('.js')) { if (src && !internalRegex.test(src)) {
consola.warn('Auto mock external ', src) consola.warn('Auto mock external ', src)
return { return {
id: require.resolve('unenv/runtime/mock/proxy') id: require.resolve('unenv/runtime/mock/proxy')