Skip to content

Commit

Permalink
Default to Deno v1.11.0 and std@0.98.0 (#71)
Browse files Browse the repository at this point in the history
  • Loading branch information
TooTallNate authored Jun 8, 2021
1 parent b6ad3e0 commit 6e5eabb
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 11 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ every time an HTTP request is received.
Create a file called `api/hello.ts` with the following contents:

```typescript
import { ServerRequest } from "https://deno.land/std@0.97.0/http/server.ts";
import { ServerRequest } from "https://deno.land/std@0.98.0/http/server.ts";

export default async (req: ServerRequest) => {
req.respond({ body: `Hello, from Deno v${Deno.version.deno}!` });
Expand Down Expand Up @@ -50,7 +50,7 @@ may configure for your serverless functions:
| `DEBUG` | Enables additional logging during build-time. | `false` |
| `DENO_TSCONFIG` | Passes the [`--config`](https://deno.land/manual/getting_started/command_line_interface#cache-and-compilation-flags) flag to specify a `tsconfig.json` file that Deno will use. | None |
| `DENO_UNSTABLE` | Passes the [`--unstable`](https://deno.land/manual/getting_started/command_line_interface#cache-and-compilation-flags) flag to `deno cache` (at build-time) and `deno run` (at runtime). | `false` |
| `DENO_VERSION` | Version of `deno` that the serverless function will use. | `1.10.2` |
| `DENO_VERSION` | Version of `deno` that the serverless function will use. | `1.11.0` |

## Development

Expand Down
2 changes: 1 addition & 1 deletion api/dump.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import ms from 'https://denopkg.com/TooTallNate/ms';
import { ServerRequest } from 'https://deno.land/std@0.97.0/http/server.ts';
import { ServerRequest } from 'https://deno.land/std@0.98.0/http/server.ts';

// Importing relative files works as expected
import { foo } from '../src/foo.ts';
Expand Down
2 changes: 1 addition & 1 deletion api/hello.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ServerRequest } from 'https://deno.land/std@0.97.0/http/server.ts';
import { ServerRequest } from 'https://deno.land/std@0.98.0/http/server.ts';

export default async (req: ServerRequest) => {
req.respond({ body: `Hello, from Deno v${Deno.version.deno}!` });
Expand Down
2 changes: 1 addition & 1 deletion src/dev-server.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Response, serve } from 'https://deno.land/std@0.97.0/http/server.ts';
import { Response, serve } from 'https://deno.land/std@0.98.0/http/server.ts';

function isNetAddr(v: any): v is Deno.NetAddr {
return v && typeof v.port === 'number';
Expand Down
19 changes: 16 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,11 @@ interface FileInfo {
}

interface Program {
fileNames?: string[];
fileInfos: { [name: string]: FileInfo };
referencedMap: { [name: string]: string[] };
exportedModulesMap: { [name: string]: string[] };
semanticDiagnosticsPerFile: string[];
semanticDiagnosticsPerFile?: string[];
}

interface BuildInfo {
Expand All @@ -47,7 +48,7 @@ interface BuildInfo {
}

const TMP = tmpdir();
const DEFAULT_DENO_VERSION = 'v1.10.2';
const DEFAULT_DENO_VERSION = 'v1.11.0';

// `chmod()` is required for usage with `vercel-dev-runtime` since
// file mode is not preserved in Vercel deployments from the CLI.
Expand Down Expand Up @@ -197,10 +198,11 @@ export async function build({
let needsWrite = false;
const buildInfo: BuildInfo = JSON.parse(await readFile(file, 'utf8'));
const {
fileNames = [],
fileInfos,
referencedMap,
exportedModulesMap,
semanticDiagnosticsPerFile,
semanticDiagnosticsPerFile = [],
} = buildInfo.program;

for (const filename of Object.keys(fileInfos)) {
Expand Down Expand Up @@ -258,6 +260,17 @@ export async function build({
}
}

for (let i = 0; i < fileNames.length; i++) {
const ref = fileNames[i];
if (typeof ref === 'string' && ref.startsWith(workPathUri)) {
const relative = ref.substring(workPathUri.length + 1);
const updated = `file:///var/task/${relative}`;
fileNames[i] = updated;
sourceFiles.add(relative);
needsWrite = true;
}
}

for (let i = 0; i < semanticDiagnosticsPerFile.length; i++) {
const ref = semanticDiagnosticsPerFile[i];
if (typeof ref === 'string' && ref.startsWith(workPathUri)) {
Expand Down
6 changes: 3 additions & 3 deletions src/runtime.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import * as base64 from 'https://deno.land/x/base64/mod.ts';
import { TextProtoReader } from 'https://deno.land/std@0.97.0/textproto/mod.ts';
import { BufReader, BufWriter } from 'https://deno.land/std@0.97.0/io/bufio.ts';
import { TextProtoReader } from 'https://deno.land/std@0.98.0/textproto/mod.ts';
import { BufReader, BufWriter } from 'https://deno.land/std@0.98.0/io/bufio.ts';
import {
ServerRequest,
Response,
} from 'https://deno.land/std@0.97.0/http/server.ts';
} from 'https://deno.land/std@0.98.0/http/server.ts';
import { Context } from 'https://denopkg.com/DefinitelyTyped/DefinitelyTyped/types/aws-lambda/handler.d.ts';

type Handler = (req: ServerRequest) => Promise<Response | void>;
Expand Down

1 comment on commit 6e5eabb

@vercel
Copy link

@vercel vercel bot commented on 6e5eabb Jun 8, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.