mirror of
https://github.com/withastro/astro.git
synced 2025-02-17 22:44:24 -05:00
Update esbuild target for Deno (#7687)
Co-authored-by: Erika <3019731+Princesseuh@users.noreply.github.com>
This commit is contained in:
parent
e80896a67c
commit
0a1b33349f
5 changed files with 31 additions and 1 deletions
5
.changeset/khaki-chicken-pay.md
Normal file
5
.changeset/khaki-chicken-pay.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
'@astrojs/deno': minor
|
||||||
|
---
|
||||||
|
|
||||||
|
Update build target for Deno to esnext to allow supported language features on the runtime.
|
|
@ -168,7 +168,7 @@ export default function createIntegration(args?: Options): AstroIntegration {
|
||||||
const pth = fileURLToPath(entryUrl);
|
const pth = fileURLToPath(entryUrl);
|
||||||
|
|
||||||
await esbuild.build({
|
await esbuild.build({
|
||||||
target: 'es2020',
|
target: 'esnext',
|
||||||
platform: 'browser',
|
platform: 'browser',
|
||||||
entryPoints: [pth],
|
entryPoints: [pth],
|
||||||
outfile: pth,
|
outfile: pth,
|
||||||
|
|
|
@ -67,6 +67,15 @@ Deno.test({
|
||||||
assertEquals(p!.innerText, varContent);
|
assertEquals(p!.innerText, varContent);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
await t.step('Can use a module with top-level await', async () => {
|
||||||
|
const resp = await fetch(app.url);
|
||||||
|
const html = await resp.text();
|
||||||
|
|
||||||
|
const doc = new DOMParser().parseFromString(html, `text/html`);
|
||||||
|
const p = doc!.querySelector('p#module-value');
|
||||||
|
assertEquals(p!.innerText, 'bar');
|
||||||
|
});
|
||||||
|
|
||||||
await t.step('Works with Markdown', async () => {
|
await t.step('Works with Markdown', async () => {
|
||||||
const resp = await fetch(new URL('markdown', app.url));
|
const resp = await fetch(new URL('markdown', app.url));
|
||||||
const html = await resp.text();
|
const html = await resp.text();
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
---
|
---
|
||||||
|
import { someData } from '../util/data';
|
||||||
import ReactComponent from '../components/React.jsx';
|
import ReactComponent from '../components/React.jsx';
|
||||||
const envValue = import.meta.env.SOME_VARIABLE;
|
const envValue = import.meta.env.SOME_VARIABLE;
|
||||||
---
|
---
|
||||||
|
@ -10,6 +11,7 @@ const envValue = import.meta.env.SOME_VARIABLE;
|
||||||
<body>
|
<body>
|
||||||
<h1>Basic App on Deno</h1>
|
<h1>Basic App on Deno</h1>
|
||||||
<p id="env-value">{envValue}</p>
|
<p id="env-value">{envValue}</p>
|
||||||
|
<p id="module-value">{someData.foo}</p>
|
||||||
<ReactComponent />
|
<ReactComponent />
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
14
packages/integrations/deno/test/fixtures/basics/src/util/data.ts
vendored
Normal file
14
packages/integrations/deno/test/fixtures/basics/src/util/data.ts
vendored
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
export interface Data {
|
||||||
|
foo: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getData(): Promise<Data> {
|
||||||
|
return new Promise((resolve, _reject) => {
|
||||||
|
setTimeout(() => {
|
||||||
|
resolve({ foo: "bar" });
|
||||||
|
}, 100);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Testing top-level await, a feature supported in esnext
|
||||||
|
export const someData = await getData();
|
Loading…
Add table
Reference in a new issue