From 12d4a2b9a004e791315af6e1f9e0b6b180d3fefe Mon Sep 17 00:00:00 2001 From: Julien Ripouteau Date: Wed, 1 May 2024 20:49:46 +0200 Subject: [PATCH] fix: use optional chaining for accessing importAttributes otherwise Node 20.x will fail since it has been introduced after --- packages/hot_hook/src/loader.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/hot_hook/src/loader.ts b/packages/hot_hook/src/loader.ts index a6bb153..fe62891 100644 --- a/packages/hot_hook/src/loader.ts +++ b/packages/hot_hook/src/loader.ts @@ -143,7 +143,7 @@ export class HotHookLoader { url = parsedUrl.href } - if (context.importAttributes.hot) { + if (context.importAttributes?.hot) { delete context.importAttributes.hot } @@ -183,7 +183,7 @@ export class HotHookLoader { } else { const parentPath = fileURLToPath(parentUrl) const isHardcodedBoundary = this.#hardcodedBoundaryMatcher.match(resultPath) - const reloadable = context.importAttributes.hot === 'true' ? true : isHardcodedBoundary + const reloadable = context.importAttributes?.hot === 'true' ? true : isHardcodedBoundary this.#dependencyTree.addDependency(parentPath, { path: resultPath, reloadable }) }