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);
|
||||
|
||||
await esbuild.build({
|
||||
target: 'es2020',
|
||||
target: 'esnext',
|
||||
platform: 'browser',
|
||||
entryPoints: [pth],
|
||||
outfile: pth,
|
||||
|
|
|
@ -67,6 +67,15 @@ Deno.test({
|
|||
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 () => {
|
||||
const resp = await fetch(new URL('markdown', app.url));
|
||||
const html = await resp.text();
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
---
|
||||
import { someData } from '../util/data';
|
||||
import ReactComponent from '../components/React.jsx';
|
||||
const envValue = import.meta.env.SOME_VARIABLE;
|
||||
---
|
||||
|
@ -10,6 +11,7 @@ const envValue = import.meta.env.SOME_VARIABLE;
|
|||
<body>
|
||||
<h1>Basic App on Deno</h1>
|
||||
<p id="env-value">{envValue}</p>
|
||||
<p id="module-value">{someData.foo}</p>
|
||||
<ReactComponent />
|
||||
</body>
|
||||
</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…
Reference in a new issue