Skip to content
This repository has been archived by the owner on May 22, 2024. It is now read-only.

fix: guard against self-referencing element in shouldTranspile #1007

Merged
merged 5 commits into from
Feb 8, 2022
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/runtimes/node/bundlers/nft/es_modules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,10 @@ const shouldTranspile = (
}

const { parents } = reason
const parentPaths = [...parents].filter((parentPath) => parentPath !== path)

// If the path is an entrypoint, we transpile it only if it's an ESM file.
if (parents.size === 0) {
if (parentPaths.length === 0) {
const isESM = esmPaths.has(path)

cache.set(path, isESM)
Expand All @@ -126,7 +127,7 @@ const shouldTranspile = (

// The path should be transpiled if every parent will also be transpiled, or
// if there is no parent.
const shouldTranspilePath = [...parents].every((parentPath) => shouldTranspile(parentPath, cache, esmPaths, reasons))
const shouldTranspilePath = parentPaths.every((parentPath) => shouldTranspile(parentPath, cache, esmPaths, reasons))

cache.set(path, shouldTranspilePath)

Expand Down