Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
lilnasy committed Jun 7, 2023
1 parent 7ea147a commit 7ee3d9c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
18 changes: 9 additions & 9 deletions packages/integrations/deno/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ const COMPATIBLE_NODE_MODULES = [
// 'wasi',
// 'webcrypto',
'worker_threads',
'zlib'
'zlib',
];

// We shim deno-specific imports so we can run the code in Node
Expand Down Expand Up @@ -107,11 +107,8 @@ const denoImportsShimPlugin = {
const denoRenameNodeModulesPlugin = {
name: '@astrojs/esbuild-rename-node-modules',
setup(build: esbuild.PluginBuild) {
const filter = new RegExp(COMPATIBLE_NODE_MODULES.map(mod => `(^${mod}$)`).join('|'))
build.onResolve(
{ filter },
args => ({ path: 'node:' + args.path, external: true })
)
const filter = new RegExp(COMPATIBLE_NODE_MODULES.map((mod) => `(^${mod}$)`).join('|'));
build.onResolve({ filter }, (args) => ({ path: 'node:' + args.path, external: true }));
},
};

Expand Down Expand Up @@ -142,7 +139,7 @@ export default function createIntegration(args?: Options): AstroIntegration {
vite.build = vite.build ?? {};
vite.build.rollupOptions = vite.build.rollupOptions ?? {};
vite.build.rollupOptions.external = vite.build.rollupOptions.external ?? [];

const aliases = [{ find: 'react-dom/server', replacement: 'react-dom/server.browser' }];

if (Array.isArray(vite.resolve.alias)) {
Expand All @@ -153,7 +150,7 @@ export default function createIntegration(args?: Options): AstroIntegration {
}
}
vite.ssr = {
noExternal: COMPATIBLE_NODE_MODULES
noExternal: COMPATIBLE_NODE_MODULES,
};

if (Array.isArray(vite.build.rollupOptions.external)) {
Expand All @@ -178,7 +175,10 @@ export default function createIntegration(args?: Options): AstroIntegration {
allowOverwrite: true,
format: 'esm',
bundle: true,
external: [...COMPATIBLE_NODE_MODULES.map(mod => `node:${mod}`),'@astrojs/markdown-remark'],
external: [
...COMPATIBLE_NODE_MODULES.map((mod) => `node:${mod}`),
'@astrojs/markdown-remark',
],
plugins: [denoImportsShimPlugin, denoRenameNodeModulesPlugin],
banner: {
js: SHIM,
Expand Down
10 changes: 5 additions & 5 deletions packages/integrations/deno/test/basics.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,13 @@ Deno.test({
const h1 = doc!.querySelector('h1');
assertEquals(h1!.innerText, 'test');
});

await t.step('node compatibility', async () => {
const resp = await fetch(new URL('/nodecompat', app.url));
const resp = await fetch(new URL('/nodecompat', app.url));
assertEquals(resp.status, 200);
await resp.text()
})
await resp.text();
});

app.stop();
},
});

0 comments on commit 7ee3d9c

Please sign in to comment.