-
-
Notifications
You must be signed in to change notification settings - Fork 109
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
Feat proposal enable fetching external resources using native fetch API in Node.js version 18 later #935
Merged
Merged
Feat proposal enable fetching external resources using native fetch API in Node.js version 18 later #935
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
3473559
Enable fetching external resources using native fetch API in Node.js …
takurinton c9d9d56
fix: remove fetch after redefinition to avoid infinite loop
takurinton aa0818d
fix: when Node.js version is only over 18 define `_fetch` instead na…
takurinton 8acd946
add: changeset
takurinton 74f90a9
fix
takurinton 54e5d2a
fix: globalThis.fetch only calls when fetch is undefined and isExtern…
takurinton 27def4e
fix: override with own implementation if you want to retrieve local f…
takurinton f1a51dd
fix: tests
takurinton 38b7dd5
Merge branch 'main' into add-fetch-for-node-18
takurinton 63954dd
fix: test names
takurinton 7c1bb6c
Merge branch 'main' into add-fetch-for-node-18
takurinton File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'wmr': minor | ||
--- | ||
|
||
Add fetching external resources using native fetch API when Node.js version 18 later |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
packages/wmr/test/fixtures/prerender-external-resource-fetch/index.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf8" /> | ||
<title>default title</title> | ||
</head> | ||
<body> | ||
<script src="./index.js" type="module"></script> | ||
</body> | ||
</html> |
4 changes: 4 additions & 0 deletions
4
packages/wmr/test/fixtures/prerender-external-resource-fetch/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export async function prerender() { | ||
const html = await fetch('https://preactjs.com').then(res => res.text()); | ||
return { html, links: ['/'] }; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
export async function prerender() { | ||
const md = await fetch('content.md').then(res => res.text()); | ||
const md = await fetch('/content.md').then(res => res.text()); | ||
rschristian marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return { html: md, links: ['/'] }; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comments explaining the workflow here are excellent! Really good stuff.