Skip to content

Instantly share code, notes, and snippets.

@kitsonk
Forked from theoparis/bundler.ts
Last active February 1, 2022 08:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kitsonk/b75a862f0795e09363d4f230c02b48b5 to your computer and use it in GitHub Desktop.
Save kitsonk/b75a862f0795e09363d4f230c02b48b5 to your computer and use it in GitHub Desktop.
deno issue 1
/// <reference no-default-lib="true"/>
/// <reference lib="deno.ns" />
/// <reference lib="deno.unstable" />
/// <reference lib="dom" />
/// <reference lib="dom.iterable" />
/// <reference lib="dom.asynciterable" />
import { Application } from "https://deno.land/x/oak/mod.ts";
import staticFiles from "https://deno.land/x/static_files/mod.ts";
import {
init as initTw,
TwInfo,
generate as generateTw
} from "https://deno.land/x/twd/mod.ts";
export const bundle = async () => {
const { files, diagnostics } = await Deno.emit("./frontend/src/main.tsx", {
bundle: "module",
importMapPath: "./import_map.json"
});
// if dist folder doesn't exist, create it
try {
await Deno.stat("public");
} catch {
await Deno.mkdir("public", { recursive: true });
}
const bundle = files["deno:///bundle.js"];
const config = await import("./twind.config.ts");
const info: TwInfo = initTw(config.default);
const sheet = generateTw([bundle], info);
// write files to dist folder
await Deno.writeTextFile("public/bundle.css", sheet);
await Deno.writeTextFile("public/bundle.js", files["deno:///bundle.js"]);
};
await bundle();
const app = new Application();
app.use(staticFiles("public"));
await app.listen({ port: parseInt(Deno.env.get("PORT") ?? "3000") });
deno run --unstable -A bundler.ts
Check file:///home/theo/dev/deno-slabchat/frontend/bundler.ts
error: TS7053 [ERROR]: Element implicitly has an 'any' type because expression of type 'unique symbol' can't be used to index type 'ReadableStream<NativeRequest>'.
Property '[SymbolConstructor.asyncIterator]' does not exist on type 'ReadableStream<NativeRequest>'.
return stream[Symbol.asyncIterator]();
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
at https://deno.land/x/oak@v10.2.0/http_server_native.ts:281:12
TS2339 [ERROR]: Property 'entries' does not exist on type 'Headers'.
for (const [key, value] of response.headers.entries()) {
~~~~~~~
at https://deno.land/x/oak@v10.2.0/cookies.ts:297:49
TS2488 [ERROR]: Type 'Headers' must have a '[Symbol.iterator]()' method that returns an iterator.
for (const [key, value] of headers) {
~~~~~~~
at https://deno.land/x/oak@v10.2.0/server_sent_event.ts:243:34
TS2488 [ERROR]: Type 'Headers' must have a '[Symbol.iterator]()' method that returns an iterator.
for (const [key, value] of responseHeaders) {
~~~~~~~~~~~~~~~
at https://deno.land/x/oak@v10.2.0/server_sent_event.ts:247:32
TS2339 [ERROR]: Property 'keys' does not exist on type 'Headers'.
for (const key of [...context.response.headers.keys()]) {
~~~~
at https://deno.land/x/oak@v10.2.0/application.ts:328:52
TS2339 [ERROR]: Property 'entries' does not exist on type 'Headers'.
return headers.entries();
~~~~~~~
at https://deno.land/x/oak@v10.2.0/middleware/proxy.ts:202:20
TS2488 [ERROR]: Type 'Headers' must have a '[Symbol.iterator]()' method that returns an iterator.
for (const [key, value] of response.headers) {
~~~~~~~~~~~~~~~~
at https://deno.land/x/oak@v10.2.0/middleware/proxy.ts:228:30
TS2488 [ERROR]: Type 'URLSearchParams' must have a '[Symbol.iterator]()' method that returns an iterator.
for (const [key, value] of ctx.request.url.searchParams) {
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
at https://deno.land/x/oak@v10.2.0/helpers.ts:43:30
TS2339 [ERROR]: Property 'emit' does not exist on type 'typeof Deno'. 'Deno.emit' is an unstable API. Did you forget to run with the '--unstable' flag?
const { files, diagnostics } = await Deno.emit("./frontend/src/main.tsx", {
~~~~
at file:///home/theo/dev/deno-slabchat/frontend/bundler.ts:10:45
Found 9 errors.
// blank file that i created
import { Config } from "https://deno.land/x/twd@v0.4.8/types.ts";
const config: Config = {};
export default config;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment