Issue 1:
deno bundle (also Deno.emit with bundle) seems to have broken.

For example when I export a class named Map, it conflicts with the builtin javascript Map type. By conflict I mean, that on each place where I like to use the map data structure, my own Map class will be instantiated (bundle should have renamed it to Map1 or something similar).

Steps to reproduce

I made a minimal example consisting of two files, with which the problem can be easily reproduced:

myMap.ts

export class Map {
hello() {
console.log("Hi")
}
}

test.ts

import { Map as MyMap } from "./myMap.ts"

const map = new MyMap()
map.hello()
const tests = new Map<string, string>()
tests.set("test1", "my test")

When running test via deno run test.ts, I get the correct results:

Hi

But when running, after bundling, the error shows up:

>deno bundle test.ts test.js
Check file:///C:/work/test/test.ts
Bundle file:///C:/work/test/test.ts
Emit "test.js" (153B)

>deno run test.js
Hi
error: Uncaught TypeError: tests.set is not a function
tests.set("test1", "my test");
^
at file:///C:/work/test/test.js:9:7

test.js

class Map {
hello() {
console.log("Hi");
}
}
const map = new Map();
map.hello();
const tests = new Map();
tests.set("test1", "my test");

Which is obviously incorrect.

Additional details

Deno version: deno 1.14.0

Issue 2:
Edit: It appears this is for all requests:

const request = new Request('https://api.github.com/repos/denoland/deno');
console.log(request.cache); // throws TypeError

In Deno v1.9.1: for each Deno.RequestEvent yielded by Deno.serveHttp, accessing the value of requestEvent.request.cache throws a TypeError.

Here is the source:

deno/op_crates/fetch/23_request.js

Lines 341 to 344
in
a1ac17f

get cache() {

webidl.assertBranded(this, Request);

throw new TypeError("This property is not implemented.");

}

This did not occur in 1.9.0 (the value was undefined). See the reproduction case below:

Reproduce:

example.ts:

async function handleConnection(conn: Deno.Conn) {
for await (const { request, respondWith } of Deno.serveHttp(conn)) {
try {
const { cache } = request;
respondWith(new Response(`Cache mode is: ${cache}`));
} catch (ex) {
await respondWith(new Response(ex.toString(), { status: 500 }));
throw ex;
}
}
}

async function main() {
const hostname = "localhost";
const port = 8000;
const url = new URL(`http://${hostname}:${port}/`);

await Deno.permissions.request({ name: "net", host: url.host });

const listener = Deno.listen({ hostname, port });
console.log(`Listening at ${url.href}\nUse ctrl+c to stop`);

for await (const conn of listener) handleConnection(conn);
}

if (import.meta.main) main();

Start server:

% deno --unstable run example.ts
⚠️ ️Deno requests network access to "localhost:8000". Grant? [g/d (g = grant, d = deny)] g
Listening at http://localhost:8000/
Use ctrl+c to stop

Navigate to http://localhost:8000/ in a browser. Switch back to terminal.

An exception was thrown. stderr:

error: Uncaught (in promise) TypeError: This property is not implemented.
const { cache } = request;
^
at Request.get cache (deno:op_crates/fetch/23_request.js:343:13)
at handleConnection (file:///Users/jesse/example/example.ts:4:15)

Version

% deno --version
deno 1.9.1 (release, x86_64-apple-darwin)
v8 9.1.269.5
typescript 4.2.2