use array filter instead forEach

pull/5370/head
0mkar 6 years ago
parent 4cfcd8d61d
commit 384f52b586
  1. 22
      remix-resolve/src/resolve.ts

@ -96,18 +96,16 @@ export class ImportResolver {
}
const builtinHandlers: Handler[] = this.getHandlers()
const handlers: Handler[] = customHandlers ? [...builtinHandlers, ...customHandlers] : [...builtinHandlers]
handlers.forEach(handler => {
const match = handler.match(filePath)
if(match) {
const content: any = handler.handle(match)
imported = {
content,
cleanURL: filePath,
type: handler.type
}
this.previouslyHandled[filePath] = imported
}
})
const matchedHandler = handlers.filter(handler => handler.match(filePath))
const handler: Handler = matchedHandler[0]
const match = handler.match(filePath)
const content: any = handler.handle(match)
imported = {
content,
cleanURL: filePath,
type: handler.type
}
this.previouslyHandled[filePath] = imported
return imported
}
}

Loading…
Cancel
Save