Skip to content

Commit 30a1bdb

Browse files
fix(internal): work around vercel/next.js#76881 (#155)
1 parent d0d3f05 commit 30a1bdb

File tree

5 files changed

+19
-2
lines changed

5 files changed

+19
-2
lines changed

src/_shims/index-deno.ts

+2
Original file line numberDiff line numberDiff line change
@@ -108,3 +108,5 @@ export declare class FsReadStream extends Readable {
108108
const _ReadableStream = ReadableStream;
109109
type _ReadableStream = ReadableStream;
110110
export { _ReadableStream as ReadableStream };
111+
112+
export const init = () => {};

src/_shims/index.d.ts

+2
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,5 @@ export function fileFromPath(path: string, options?: FileFromPathOptions): Promi
7979
export function fileFromPath(path: string, filename?: string, options?: FileFromPathOptions): Promise<File>;
8080

8181
export function isFsReadStream(value: any): value is FsReadStream;
82+
83+
export const init: () => void;

src/_shims/index.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,15 @@
33
*/
44
const shims = require('./registry');
55
const auto = require('@browserbasehq/sdk/_shims/auto/runtime');
6-
if (!shims.kind) shims.setShims(auto.getRuntime(), { auto: true });
6+
exports.init = () => {
7+
if (!shims.kind) shims.setShims(auto.getRuntime(), { auto: true });
8+
};
79
for (const property of Object.keys(shims)) {
810
Object.defineProperty(exports, property, {
911
get() {
1012
return shims[property];
1113
},
1214
});
1315
}
16+
17+
exports.init();

src/_shims/index.mjs

+5-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,9 @@
33
*/
44
import * as shims from './registry.mjs';
55
import * as auto from '@browserbasehq/sdk/_shims/auto/runtime';
6-
if (!shims.kind) shims.setShims(auto.getRuntime(), { auto: true });
6+
export const init = () => {
7+
if (!shims.kind) shims.setShims(auto.getRuntime(), { auto: true });
8+
};
79
export * from './registry.mjs';
10+
11+
init();

src/core.ts

+5
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,12 @@ import {
1616
type RequestInit,
1717
type Response,
1818
type HeadersInit,
19+
init,
1920
} from './_shims/index';
21+
22+
// try running side effects outside of _shims/index to workaround https://github.com/vercel/next.js/issues/76881
23+
init();
24+
2025
export { type Response };
2126
import { BlobLike, isBlobLike, isMultipartBody } from './uploads';
2227
export {

0 commit comments

Comments
 (0)