Skip to content

Commit

Permalink
fix: polyfill fetch for node16
Browse files Browse the repository at this point in the history
  • Loading branch information
agoose77 committed Jan 24, 2024
1 parent 9493bba commit 716fc06
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
3 changes: 2 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion packages/myst-execute/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"which": "^4.0.0"
},
"devDependencies": {
"js-yaml": "^4.1.0"
"js-yaml": "^4.1.0",
"node-fetch": "^3.3.0"
}
}
10 changes: 10 additions & 0 deletions packages/myst-execute/tests/run.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@ import { kernelExecutionTransform, launchJupyterServer } from '../src';
import type { GenericParent } from 'myst-common';
import { VFile } from 'vfile';
import { KernelManager, ServerConnection, SessionManager } from '@jupyterlab/services';
import { default as nodeFetch } from 'node-fetch';
import { Headers, Request, Response } from 'node-fetch';

// fetch polyfill for node<18
if (!globalThis.fetch) {
globalThis.fetch = nodeFetch as any;
globalThis.Headers = Headers as any;
globalThis.Request = Request as any;
globalThis.Response = Response as any;
}

type TestCase = {
title: string;
Expand Down

0 comments on commit 716fc06

Please sign in to comment.