소스 검색

fix(core): rewrite replacements while hoisting layers (#35175)

James Long 1 개월 전
부모
커밋
33ed95f09c
2개의 변경된 파일5개의 추가작업 그리고 1개의 파일을 삭제
  1. 1 1
      packages/core/src/effect/layer-node.ts
  2. 4 0
      packages/core/src/location-services.ts

+ 1 - 1
packages/core/src/effect/layer-node.ts

@@ -230,7 +230,7 @@ export function hoist<A, E, T extends Tag, const Items extends Replacements = re
         if (existing && existing !== node) {
           throw new Error(`Tag ${tag} has conflicting implementations for ${node.name}`)
         }
-        hoisted.set(node.name, node)
+        hoisted.set(node.name, rewriteReplacementDependencies(node, replacementMap))
         return group([])
       }
       if (node.kind === "unbound") {

+ 4 - 0
packages/core/src/location-services.ts

@@ -89,6 +89,10 @@ export function buildLocationServiceMap(
     LayerMap.make(
       (ref: Location.Ref) => {
         const allReplacements = replacements.concat([[Location.node, Location.boundNode(ref)]])
+        // Apply replacements during hoist, not afterward: replacements can
+        // introduce new tagged dependencies (Location.boundNode depends on
+        // Project), and the hoist walk is the only pass that can still slice
+        // those back out.
         const location = LayerNode.hoist(locationServices, Node.tags.values.global, allReplacements)
 
         return LayerNode.compile(location.node).pipe(