fix import cache

pull/3311/head
yann300 2 years ago
parent 06346a195b
commit ec968ee67b
  1. 14
      libs/remix-core-plugin/src/lib/compiler-content-imports.ts
  2. 4
      libs/remix-url-resolver/src/resolve.ts

@ -16,7 +16,6 @@ export type ResolvedImport = {
}
export class CompilerImports extends Plugin {
previouslyHandled: Record<string, ResolvedImport>
urlResolver: any
constructor () {
super(profile)
@ -45,7 +44,6 @@ export class CompilerImports extends Plugin {
return {}
}
})
this.previouslyHandled = {} // cache import so we don't make the request at each compilation.
}
async setToken () {
@ -95,22 +93,12 @@ export class CompilerImports extends Plugin {
if (!cb) cb = () => {}
const self = this
if (force) delete this.previouslyHandled[url]
const imported = this.previouslyHandled[url]
if (imported) {
return cb(null, imported.content, imported.cleanUrl, imported.type, url)
}
let resolved
try {
await this.setToken()
resolved = await this.urlResolver.resolve(url)
resolved = await this.urlResolver.resolve(url, [], force)
const { content, cleanUrl, type } = resolved
self.previouslyHandled[url] = {
content,
cleanUrl,
type
}
cb(null, content, cleanUrl, type, url)
} catch (e) {
return cb(new Error('not found ' + url))

@ -207,9 +207,9 @@ export class RemixURLResolver {
]
}
public async resolve (filePath: string, customHandlers?: Handler[]): Promise<Imported> {
public async resolve (filePath: string, customHandlers?: Handler[], force?: boolean): Promise<Imported> {
let imported: Imported = this.previouslyHandled[filePath]
if (imported) {
if (!force && imported) {
return imported
}
const builtinHandlers: Handler[] = this.getHandlers()

Loading…
Cancel
Save