Skip to content

Commit 0d9f351

Browse files
authored
fix: Handle cyclical reference to current file (#83)
Closes #82
1 parent 1e05e4b commit 0d9f351

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

hook.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,15 @@ function createHook (meta) {
253253
return url
254254
}
255255

256+
// If the file is referencing itself, we need to skip adding the iitm search params
257+
if (url.url === parentURL) {
258+
return {
259+
url: url.url,
260+
shortCircuit: true,
261+
format: url.format
262+
}
263+
}
264+
256265
specifiers.set(url.url, specifier)
257266

258267
return {

test/fixtures/cyclical-self.mjs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// File generated from our OpenAPI spec by Stainless.
2+
import * as BatchesAPI from './cyclical-self.mjs'
3+
export class Batches {}
4+
export class BatchesPage {}
5+
(function (Batches) {
6+
Batches.BatchesPage = BatchesAPI.BatchesPage
7+
// eslint-disable-next-line no-class-assign
8+
})(Batches || (Batches = {}))

test/hook/cyclical-self.mjs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import { Batches, BatchesPage } from '../fixtures/cyclical-self.mjs'
2+
import { strictEqual } from 'assert'
3+
4+
strictEqual(Batches.BatchesPage, BatchesPage)

0 commit comments

Comments
 (0)