Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
C
Chatgpt Puppeteer
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nanahira
Chatgpt Puppeteer
Commits
23b9fcd5
Commit
23b9fcd5
authored
Dec 07, 2022
by
Travis Fischer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: remove top-level await import for undici
parent
3efc85fa
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
2 deletions
+12
-2
package.json
package.json
+1
-1
src/fetch.ts
src/fetch.ts
+11
-1
No files found.
package.json
View file @
23b9fcd5
...
...
@@ -27,7 +27,7 @@
"dev"
:
"tsup --watch"
,
"clean"
:
"del build"
,
"prebuild"
:
"run-s clean"
,
"postbuild"
:
"[ -n CI ] && sed -i '' 's/
*
\\
?
\\
? *(await import(
\"
undici
\"
)).fetch/
/' build/browser/index.js || echo 'skipping postbuild on CI'"
,
"postbuild"
:
"[ -n CI ] && sed -i '' 's/
await import(
\"
undici
\"
)/null
/' build/browser/index.js || echo 'skipping postbuild on CI'"
,
"predev"
:
"run-s clean"
,
"pretest"
:
"run-s build"
,
"docs"
:
"typedoc"
,
...
...
src/fetch.ts
View file @
23b9fcd5
/// <reference lib="dom" />
let
_undici
:
any
// Use `undici` for node.js 16 and 17
// Use `fetch` for node.js >= 18
// Use `fetch` for all other environments, including browsers
...
...
@@ -7,6 +9,14 @@
// browser build
const
fetch
=
globalThis
.
fetch
??
((
await
import
(
'
undici
'
)).
fetch
as
unknown
as
typeof
globalThis
.
fetch
)
async
function
undiciFetchWrapper
(
...
args
:
Parameters
<
typeof
globalThis
.
fetch
>
):
Promise
<
Response
>
{
if
(
!
_undici
)
{
_undici
=
await
import
(
'
undici
'
)
}
return
_undici
.
fetch
(...
args
)
}
export
{
fetch
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment