-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow dynamic imports when using Netlify Edge Functions (#3535)
* Allow dynamic imports when using Netlify Edge Functions * Update deno test script and changeset
- Loading branch information
Showing
13 changed files
with
144 additions
and
7 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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@astrojs/netlify': patch | ||
--- | ||
|
||
Fixes Netlify Edge Function and Astro.glob |
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
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
27 changes: 27 additions & 0 deletions
27
packages/integrations/netlify/test/edge-functions/dynamic-import.test.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,27 @@ | ||
// @ts-ignore | ||
import { runBuild, runApp } from './test-utils.ts'; | ||
// @ts-ignore | ||
import { assertEquals, assert, DOMParser } from './deps.ts'; | ||
|
||
// @ts-ignore | ||
Deno.test({ | ||
name: 'Dynamic imports', | ||
async fn() { | ||
let close = await runBuild('./fixtures/dynimport/'); | ||
let stop = await runApp('./fixtures/dynimport/prod.js'); | ||
|
||
try { | ||
const response = await fetch('http://127.0.0.1:8085/'); | ||
assertEquals(response.status, 200); | ||
const html = await response.text(); | ||
|
||
assert(html, 'got some html'); | ||
const doc = new DOMParser().parseFromString(html, `text/html`); | ||
const div = doc.querySelector('#thing'); | ||
assert(div, 'div exists') | ||
} finally { | ||
await close(); | ||
await stop(); | ||
} | ||
}, | ||
}); |
11 changes: 11 additions & 0 deletions
11
packages/integrations/netlify/test/edge-functions/fixtures/dynimport/astro.config.mjs
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,11 @@ | ||
import { defineConfig } from 'astro/config'; | ||
import { netlifyEdgeFunctions } from '@astrojs/netlify'; | ||
|
||
export default defineConfig({ | ||
adapter: netlifyEdgeFunctions({ | ||
dist: new URL('./dist/', import.meta.url), | ||
}), | ||
experimental: { | ||
ssr: true | ||
} | ||
}) |
9 changes: 9 additions & 0 deletions
9
packages/integrations/netlify/test/edge-functions/fixtures/dynimport/package.json
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,9 @@ | ||
{ | ||
"name": "@test/netlify-edge-astro-dynimport", | ||
"version": "0.0.0", | ||
"private": true, | ||
"dependencies": { | ||
"astro": "workspace:*", | ||
"@astrojs/netlify": "workspace:*" | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
packages/integrations/netlify/test/edge-functions/fixtures/dynimport/prod.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,11 @@ | ||
import handler from './.netlify/edge-functions/entry.js'; | ||
import { Server } from 'https://deno.land/std@0.132.0/http/server.ts'; | ||
|
||
const _server = new Server({ | ||
port: 8085, | ||
hostname: '0.0.0.0', | ||
handler, | ||
}); | ||
|
||
_server.listenAndServe(); | ||
console.error(`Server running on port 8085`); |
4 changes: 4 additions & 0 deletions
4
...es/integrations/netlify/test/edge-functions/fixtures/dynimport/src/components/Thing.astro
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 @@ | ||
--- | ||
--- | ||
<div id="thing">testing</div> |
11 changes: 11 additions & 0 deletions
11
packages/integrations/netlify/test/edge-functions/fixtures/dynimport/src/pages/index.astro
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,11 @@ | ||
--- | ||
const { default: Thing } = await import('../components/Thing.astro'); | ||
--- | ||
<html> | ||
<head> | ||
<title>testing</title> | ||
</head> | ||
<body> | ||
<Thing /> | ||
</body> | ||
</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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.