Skip to content

Commit

Permalink
[ci] format
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewp authored and astrobot-houston committed Feb 17, 2023
1 parent 61113dd commit ff70614
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 24 deletions.
2 changes: 1 addition & 1 deletion packages/integrations/deno/src/__deno_imports.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// This file is a shim for any Deno-specific imports!
// It will be replaced in the final Deno build.
//
//
// This allows us to prerender pages in Node.
export class Server {
listenAndServe() {}
Expand Down
37 changes: 19 additions & 18 deletions packages/integrations/deno/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ const SHIM = `globalThis.process = {
env: Deno.env.toObject(),
};`;

const DENO_VERSION = `0.177.0`
const DENO_VERSION = `0.177.0`;

// We shim deno-specific imports so we can run the code in Node
// to prerender pages. In the final Deno build, this import is
// to prerender pages. In the final Deno build, this import is
// replaced with the Deno-specific contents listed below.
const DENO_IMPORTS_SHIM = `@astrojs/deno/__deno_imports.js`;
const DENO_IMPORTS = `export { Server } from "https://deno.land/std@${DENO_VERSION}/http/server.ts"
export { serveFile } from 'https://deno.land/std@${DENO_VERSION}/http/file_server.ts';
export { fromFileUrl } from "https://deno.land/std@${DENO_VERSION}/path/mod.ts";`
export { fromFileUrl } from "https://deno.land/std@${DENO_VERSION}/path/mod.ts";`;

export function getAdapter(args?: Options): AstroAdapter {
return {
Expand All @@ -40,16 +40,16 @@ export function getAdapter(args?: Options): AstroAdapter {
}

const denoImportsShimPlugin = {
name: '@astrojs/deno:shim',
setup(build: esbuild.PluginBuild) {
build.onLoad({ filter: /__deno_imports\.js$/ }, async (args) => {
return {
contents: DENO_IMPORTS,
loader: 'js',
}
})
},
}
name: '@astrojs/deno:shim',
setup(build: esbuild.PluginBuild) {
build.onLoad({ filter: /__deno_imports\.js$/ }, async (args) => {
return {
contents: DENO_IMPORTS,
loader: 'js',
};
});
},
};

export default function createIntegration(args?: Options): AstroIntegration {
let _buildConfig: BuildConfig;
Expand Down Expand Up @@ -91,9 +91,12 @@ export default function createIntegration(args?: Options): AstroIntegration {
};

if (Array.isArray(vite.build.rollupOptions.external)) {
vite.build.rollupOptions.external.push(DENO_IMPORTS_SHIM);
vite.build.rollupOptions.external.push(DENO_IMPORTS_SHIM);
} else if (typeof vite.build.rollupOptions.external !== 'function') {
vite.build.rollupOptions.external = [vite.build.rollupOptions.external, DENO_IMPORTS_SHIM]
vite.build.rollupOptions.external = [
vite.build.rollupOptions.external,
DENO_IMPORTS_SHIM,
];
}
}
},
Expand All @@ -110,9 +113,7 @@ export default function createIntegration(args?: Options): AstroIntegration {
format: 'esm',
bundle: true,
external: ['@astrojs/markdown-remark'],
plugins: [
denoImportsShimPlugin
],
plugins: [denoImportsShimPlugin],
banner: {
js: SHIM,
},
Expand Down
7 changes: 3 additions & 4 deletions packages/integrations/deno/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { SSRManifest } from 'astro';
import { App } from 'astro/app';

// @ts-ignore
import { Server, serveFile, fromFileUrl } from '@astrojs/deno/__deno_imports.js';
import { fromFileUrl, serveFile, Server } from '@astrojs/deno/__deno_imports.js';

interface Options {
port?: number;
Expand All @@ -18,9 +18,9 @@ async function* getPrerenderedFiles(clientRoot: URL): AsyncGenerator<URL> {
// @ts-ignore
for await (const ent of Deno.readDir(clientRoot)) {
if (ent.isDirectory) {
yield* getPrerenderedFiles(new URL(`./${ent.name}/`, clientRoot))
yield* getPrerenderedFiles(new URL(`./${ent.name}/`, clientRoot));
} else if (ent.name.endsWith('.html')) {
yield new URL(`./${ent.name}`, clientRoot)
yield new URL(`./${ent.name}`, clientRoot);
}
}
}
Expand Down Expand Up @@ -67,7 +67,6 @@ export function start(manifest: SSRManifest, options: Options) {
}
}


// If the static file can't be found
if (fileResp.status == 404) {
// Render the astro custom 404 page
Expand Down
1 change: 0 additions & 1 deletion packages/integrations/deno/test/basics.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ Deno.test({
sanitizeOps: false,
});


Deno.test({
name: 'perendering',
permissions: defaultTestPermissions,
Expand Down

0 comments on commit ff70614

Please sign in to comment.