diff --git a/.changeset/khaki-chicken-pay.md b/.changeset/khaki-chicken-pay.md new file mode 100644 index 000000000..02b8ca56d --- /dev/null +++ b/.changeset/khaki-chicken-pay.md @@ -0,0 +1,5 @@ +--- +'@astrojs/deno': minor +--- + +Update build target for Deno to esnext to allow supported language features on the runtime. diff --git a/packages/integrations/deno/src/index.ts b/packages/integrations/deno/src/index.ts index 986449b18..db645eb69 100644 --- a/packages/integrations/deno/src/index.ts +++ b/packages/integrations/deno/src/index.ts @@ -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, diff --git a/packages/integrations/deno/test/basics.test.ts b/packages/integrations/deno/test/basics.test.ts index 5d3f116dd..cdb0c616e 100644 --- a/packages/integrations/deno/test/basics.test.ts +++ b/packages/integrations/deno/test/basics.test.ts @@ -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(); diff --git a/packages/integrations/deno/test/fixtures/basics/src/pages/index.astro b/packages/integrations/deno/test/fixtures/basics/src/pages/index.astro index 29fce0190..650f60062 100644 --- a/packages/integrations/deno/test/fixtures/basics/src/pages/index.astro +++ b/packages/integrations/deno/test/fixtures/basics/src/pages/index.astro @@ -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;
{envValue}
+{someData.foo}