Skip to content

Commit 52f0113

Browse files
authored
Extract module name (#940)
* Extract module name
1 parent 2cd4c3c commit 52f0113

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

.changeset/modern-spoons-speak.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@cloudflare/next-on-pages': patch
3+
---
4+
5+
chore: Extract module name in dynamic imports

packages/next-on-pages/templates/_worker.js/utils/cache.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,8 @@ export async function getSuspenseCacheAdaptor(): Promise<CacheAdaptor> {
117117
async function getInternalCacheAdaptor(
118118
type: 'kv' | 'cache-api',
119119
): Promise<CacheAdaptor> {
120-
const adaptor = await import(`./__next-on-pages-dist__/cache/${type}.js`);
120+
const moduleName = `./__next-on-pages-dist__/cache/${type}.js`;
121+
const adaptor = await import(moduleName);
121122
return new adaptor.default();
122123
}
123124

packages/next-on-pages/templates/_worker.js/utils/fetch.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,8 @@ async function handleInlineAssetRequest(request: Request) {
4949
if (request.url.startsWith('blob:')) {
5050
try {
5151
const url = new URL(request.url);
52-
const binaryContent = (
53-
await import(`./__next-on-pages-dist__/assets/${url.pathname}.bin`)
54-
).default;
52+
const moduleName = `./__next-on-pages-dist__/assets/${url.pathname}.bin`;
53+
const binaryContent = (await import(moduleName)).default;
5554

5655
// Note: we can't generate a real Response object here because this fetch might be called
5756
// at the top level of a dynamically imported module, and such cases produce the following

0 commit comments

Comments
 (0)