Some files in the openapi sdk import * themselves like below.
I don't know how common this is elsewhere but these files are auto-generated which might explain this strange pattern.
batches.mjs
// File generated from our OpenAPI spec by Stainless.
import * as BatchesAPI from "./batches.mjs";
export class Batches {}
export class BatchesPage {}
(function (Batches) {
Batches.BatchesPage = BatchesAPI.BatchesPage;
})(Batches || (Batches = {}));
If you import the above in Node, there is no error.
If the import-in-the-middle/hook.mjs is registered, you get the following error:
file:///Users/tim/Documents/Repositories/repro/more.mjs:5
Batches.BatchesPage = BatchesAPI.BatchesPage;
^
ReferenceError: Cannot access 'BatchesPage' before initialization
at file:///Users/tim/Documents/Repositories/repro/more.mjs:5:38
at file:///Users/tim/Documents/Repositories/repro/more.mjs:6:3
at ModuleJob.run (node:internal/modules/esm/module_job:262:25)
at async ModuleLoader.import (node:internal/modules/esm/loader:475:24)
at async file:///Users/tim/Documents/Repositories/repro/test.mjs:5:1
Another strange ESM edge case!
Some files in the
openapi
sdkimport *
themselves like below.I don't know how common this is elsewhere but these files are auto-generated which might explain this strange pattern.
batches.mjs
If you import the above in Node, there is no error.
If the
import-in-the-middle/hook.mjs
is registered, you get the following error: