Skip to content

fix(internal): work around https://github.com/vercel/next.js/issues/76881 #567

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/_shims/index-deno.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,5 @@ export declare class FsReadStream extends Readable {
const _ReadableStream = ReadableStream;
type _ReadableStream = ReadableStream;
export { _ReadableStream as ReadableStream };

export const init = () => {};
2 changes: 2 additions & 0 deletions src/_shims/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,5 @@ export function fileFromPath(path: string, options?: FileFromPathOptions): Promi
export function fileFromPath(path: string, filename?: string, options?: FileFromPathOptions): Promise<File>;

export function isFsReadStream(value: any): value is FsReadStream;

export const init: () => void;
6 changes: 5 additions & 1 deletion src/_shims/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@
*/
const shims = require('./registry');
const auto = require('@mux/mux-node/_shims/auto/runtime');
if (!shims.kind) shims.setShims(auto.getRuntime(), { auto: true });
exports.init = () => {
if (!shims.kind) shims.setShims(auto.getRuntime(), { auto: true });
};
for (const property of Object.keys(shims)) {
Object.defineProperty(exports, property, {
get() {
return shims[property];
},
});
}

exports.init();
6 changes: 5 additions & 1 deletion src/_shims/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,9 @@
*/
import * as shims from './registry.mjs';
import * as auto from '@mux/mux-node/_shims/auto/runtime';
if (!shims.kind) shims.setShims(auto.getRuntime(), { auto: true });
export const init = () => {
if (!shims.kind) shims.setShims(auto.getRuntime(), { auto: true });
};
export * from './registry.mjs';

init();
5 changes: 5 additions & 0 deletions src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@ import {
type RequestInit,
type Response,
type HeadersInit,
init,
} from './_shims/index';

// try running side effects outside of _shims/index to workaround https://github.com/vercel/next.js/issues/76881
init();

export { type Response };
import { BlobLike, isBlobLike, isMultipartBody } from './uploads';
export {
Expand Down