Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update esbuild target for Deno #7687

Merged
merged 8 commits into from
Jul 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/khaki-chicken-pay.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@astrojs/deno': minor
---

Update build target for Deno to esnext to allow supported language features on the runtime.
2 changes: 1 addition & 1 deletion packages/integrations/deno/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
9 changes: 9 additions & 0 deletions packages/integrations/deno/test/basics.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
---
import { someData } from '../util/data';
import ReactComponent from '../components/React.jsx';
const envValue = import.meta.env.SOME_VARIABLE;
---
Expand All @@ -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 changes: 14 additions & 0 deletions packages/integrations/deno/test/fixtures/basics/src/util/data.ts
Original file line number Diff line number Diff line change
@@ -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();