From 98be067c0be419cdd36837ba6bd7aa64b598b654 Mon Sep 17 00:00:00 2001 From: yann300 Date: Tue, 31 Jan 2023 10:28:51 +0100 Subject: [PATCH] fix import cache --- .../src/lib/compiler-content-imports.ts | 14 +------------- libs/remix-url-resolver/src/resolve.ts | 4 ++-- 2 files changed, 3 insertions(+), 15 deletions(-) diff --git a/libs/remix-core-plugin/src/lib/compiler-content-imports.ts b/libs/remix-core-plugin/src/lib/compiler-content-imports.ts index 8afd4e22b3..0d199a001f 100644 --- a/libs/remix-core-plugin/src/lib/compiler-content-imports.ts +++ b/libs/remix-core-plugin/src/lib/compiler-content-imports.ts @@ -16,7 +16,6 @@ export type ResolvedImport = { } export class CompilerImports extends Plugin { - previouslyHandled: Record 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)) diff --git a/libs/remix-url-resolver/src/resolve.ts b/libs/remix-url-resolver/src/resolve.ts index 2798943058..5afab62519 100644 --- a/libs/remix-url-resolver/src/resolve.ts +++ b/libs/remix-url-resolver/src/resolve.ts @@ -207,9 +207,9 @@ export class RemixURLResolver { ] } - public async resolve (filePath: string, customHandlers?: Handler[]): Promise { + public async resolve (filePath: string, customHandlers?: Handler[], force?: boolean): Promise { let imported: Imported = this.previouslyHandled[filePath] - if (imported) { + if (!force && imported) { return imported } const builtinHandlers: Handler[] = this.getHandlers()