Skip to content

Commit

Permalink
fix(typegen): fixes a bug where we imported the wrong relative path
Browse files Browse the repository at this point in the history
  • Loading branch information
sgulseth committed Apr 23, 2024
1 parent d7f1067 commit 5b85331
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,11 @@ describe('findQueries', () => {
`

const resolver: NodeJS.RequireResolve = (id) => {
if (id === 'foo') {
return path.resolve(__dirname, 'fixtures', 'exportVar')
if (id.endsWith('fixtures/exportVar')) {
return path.resolve(__dirname, 'fixtures', 'exportVar.ts')
}
return require.resolve(id)

throw new Error(`Cannot resolve module ${id} - all module imports should be mocked`)
}
resolver.paths = (request: string): string[] | null => {
return require.resolve.paths(request)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ function resolveImportSpecifier({
const importName = node.local.name
const importFileName = importDeclaration.source.value
// const importPath = path.resolve(path.dirname(filename), importFileName);
const importPath = importName.startsWith('./')
const importPath = importFileName.startsWith('./')
? path.resolve(path.dirname(filename), importFileName)
: importFileName
const resolvedFile = resolver(importPath)
Expand Down

0 comments on commit 5b85331

Please sign in to comment.