From 80197964428c82cb9cc1afb2b3119c9f454ce3f1 Mon Sep 17 00:00:00 2001 From: "Fred K. Schott" Date: Wed, 25 Aug 2021 22:35:25 -0700 Subject: [PATCH] wip --- packages/astro/package.json | 2 +- packages/astro/src/compiler/index.ts | 2 +- packages/astro/src/runtime.ts | 3 +++ yarn.lock | 16 +++++++++++++++- 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/packages/astro/package.json b/packages/astro/package.json index 6f44116414..b461ecad50 100644 --- a/packages/astro/package.json +++ b/packages/astro/package.json @@ -79,7 +79,7 @@ "magic-string": "^0.25.3", "mime": "^2.5.2", "moize": "^6.0.1", - "node-fetch": "^2.6.1", + "node-fetch-cache": "^3.0.3", "path-to-regexp": "^6.2.0", "picomatch": "^2.2.3", "postcss": "^8.2.15", diff --git a/packages/astro/src/compiler/index.ts b/packages/astro/src/compiler/index.ts index ede2a62f21..e136e3898b 100644 --- a/packages/astro/src/compiler/index.ts +++ b/packages/astro/src/compiler/index.ts @@ -117,7 +117,7 @@ export async function compileComponent(source: string, { compileOptions, filenam // return template let moduleJavaScript = ` -import fetch from 'node-fetch'; +import fetch from 'node-fetch-cache'; ${result.imports.join('\n')} if(!('fetch' in globalThis)) { diff --git a/packages/astro/src/runtime.ts b/packages/astro/src/runtime.ts index 4145753ed3..98e8fa31bc 100644 --- a/packages/astro/src/runtime.ts +++ b/packages/astro/src/runtime.ts @@ -418,6 +418,9 @@ export async function createRuntime(astroConfig: AstroConfig, { mode, logging }: if (filePath.includes(fileURLToPath(astroConfig.pages))) { runtimeConfig.manifest = createManifest({ config: astroConfig }); } + // + // const mod = snowpackRuntime.importModule('/_astro_internal/fetch-cache.js'); + // mod.clearCache() }); return { diff --git a/yarn.lock b/yarn.lock index 9678c0fcfc..0f7b14d434 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6477,6 +6477,11 @@ locate-path@^6.0.0: dependencies: p-locate "^5.0.0" +locko@0.0.3: + version "0.0.3" + resolved "https://registry.yarnpkg.com/locko/-/locko-0.0.3.tgz#872ebc44f81d200099a9f71f9adb5065ef339c23" + integrity sha512-ekhPWcejAum9WHN2ClkFA8RAUTDyYDlRRb4dSq1wCEPhIS6IMsdSKoWHl1qineCrlMEMbeD1/o2uautG4QEc7w== + lodash._reinterpolate@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/lodash._reinterpolate/-/lodash._reinterpolate-3.0.0.tgz#0ccf2d89166af03b3663c796538b75ac6e114d9d" @@ -7479,7 +7484,16 @@ node-emoji@^1.8.1: dependencies: lodash "^4.17.21" -node-fetch@^2.6.0, node-fetch@^2.6.1, node-fetch@~2.6.0: +node-fetch-cache@^3.0.3: + version "3.0.3" + resolved "https://registry.yarnpkg.com/node-fetch-cache/-/node-fetch-cache-3.0.3.tgz#b301ea9344634310532fbde18b549101176677b5" + integrity sha512-w6Fr/gLHsSxrNAhjBAYAGAhdby5RYEwzb3XL/HHgKC47UxJdfnQuVTesXYUAlvfJ8Ixrp0XPQon0CtEBMXVWMA== + dependencies: + cacache "^15.2.0" + locko "0.0.3" + node-fetch "2.6.1" + +node-fetch@2.6.1, node-fetch@^2.6.0, node-fetch@^2.6.1, node-fetch@~2.6.0: version "2.6.1" resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.1.tgz#045bd323631f76ed2e2b55573394416b639a0052" integrity sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==