forked from sveltejs/sapper
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ESM + ssr: global fetch,Request,Response,Headers sveltejs#1791
- Loading branch information
Showing
18 changed files
with
177 additions
and
93 deletions.
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 |
---|---|---|
@@ -1 +1,2 @@ | ||
module.exports = require('../dist/rollup.js'); | ||
import { default as rollup } from '../dist/rollup.js'; | ||
export default rollup; |
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 +1,2 @@ | ||
module.exports = require('../dist/webpack.js'); | ||
export { default as webpack } from '../dist/webpack.js'; | ||
export default webpack; |
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
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
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 +1,2 @@ | ||
export { default as middleware } from './middleware/index'; | ||
import './install-fetch.js'; | ||
export { default as middleware } from './middleware/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,24 @@ | ||
import fetch, { Response, Request, Headers } from 'node-fetch'; | ||
|
||
// exported for dev, prerender, and preview | ||
export function __fetch_polyfill() { | ||
Object.defineProperties(globalThis, { | ||
fetch: { | ||
enumerable: true, | ||
value: fetch | ||
}, | ||
Response: { | ||
enumerable: true, | ||
value: Response | ||
}, | ||
Request: { | ||
enumerable: true, | ||
value: Request | ||
}, | ||
Headers: { | ||
enumerable: true, | ||
value: Headers | ||
} | ||
}); | ||
} | ||
__fetch_polyfill(); |
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
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
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,9 +1,13 @@ | ||
import * as fs from 'fs'; | ||
import { promisify } from 'util'; | ||
import { version as shimport_version } from 'shimport/package.json'; | ||
import { resolve } from 'import-meta-resolve'; | ||
|
||
export function copy_shimport(dest: string) { | ||
fs.writeFileSync( | ||
export async function copy_shimport(dest: string) { | ||
await promisify(fs.writeFile)( | ||
`${dest}/client/shimport@${shimport_version}.js`, | ||
fs.readFileSync(require.resolve('shimport/index.js')) | ||
fs.readFileSync( | ||
new URL(await resolve('shimport/index.js', import.meta.url)).pathname | ||
) | ||
); | ||
} |
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
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
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
Oops, something went wrong.