Skip to content

Commit

Permalink
fix(register): fix esm entry resolver for third-party executer, close #…
Browse files Browse the repository at this point in the history
…762 (#766)

* fix(register): fix esm entry resolver for third-party executor, close #762

* Create great-goats-trade.md

* fix: bug fix
  • Loading branch information
yeliex authored Apr 9, 2024
1 parent abfb357 commit 9e6c02f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/great-goats-trade.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@fake-scope/fake-pkg": patch
---

fix(register): fix esm entry resolver for third-party executor, close #762
6 changes: 5 additions & 1 deletion packages/register/esm.mts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ interface ResolveContext {
conditions: string[]
parentURL: string | undefined
}

interface ResolveResult {
format?: string
shortCircuit?: boolean
url: string
}

type ResolveArgs = [
specifier: string,
context?: ResolveContext,
Expand Down Expand Up @@ -51,7 +53,7 @@ export const resolve: ResolveFn = async (specifier, context, nextResolve) => {
}

const { resolvedModule } = ts.resolveModuleName(
specifier,
specifier.startsWith('file:') ? fileURLToPath(specifier) : specifier,
fileURLToPath(context.parentURL),
tsconfig,
host,
Expand Down Expand Up @@ -82,11 +84,13 @@ interface LoadContext {
conditions: string[]
format: string | null | undefined
}

interface LoadResult {
format: string
shortCircuit?: boolean
source: string | ArrayBuffer | SharedArrayBuffer | Uint8Array
}

type LoadArgs = [url: string, context: LoadContext, nextLoad?: (...args: LoadArgs) => Promise<LoadResult>]
type LoadFn = (...args: Required<LoadArgs>) => Promise<LoadResult>

Expand Down

0 comments on commit 9e6c02f

Please sign in to comment.