aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <jarred@jarredsumner.com> 2022-04-18 20:51:10 -0700
committerGravatar Jarred Sumner <jarred@jarredsumner.com> 2022-04-18 20:51:10 -0700
commit612fad706f66d8f830ef9a6efbc33f49a1343ea5 (patch)
treea3eb6488323228e05b40fc186e103c13ac515f51
parent6728551dc4875e5a15cc7353caa4fb862642bc89 (diff)
downloadbun-612fad706f66d8f830ef9a6efbc33f49a1343ea5.tar.gz
bun-612fad706f66d8f830ef9a6efbc33f49a1343ea5.tar.zst
bun-612fad706f66d8f830ef9a6efbc33f49a1343ea5.zip
fix wasm build take 2 (one more thing is broken)
-rw-r--r--.gitignore5
-rw-r--r--Makefile13
-rwxr-xr-xbun.lockbbin7689 -> 7689 bytes
-rw-r--r--package.json4
-rw-r--r--packages/bun-types/types.d.ts2
-rwxr-xr-xpackages/bun-wasm/bun.lockbbin0 -> 6328 bytes
-rw-r--r--packages/bun-wasm/index.ts346
-rw-r--r--packages/bun-wasm/package.json30
-rw-r--r--packages/bun-wasm/test/node.mjs17
-rw-r--r--packages/bun-wasm/tsconfig.json21
-rwxr-xr-xsrc/api/bun.lockbbin0 -> 5938 bytes
-rw-r--r--src/api/package.json7
-rw-r--r--src/api/schema.d.ts383
-rw-r--r--src/api/tsconfig.json6
-rw-r--r--src/main_wasm.zig2
15 files changed, 641 insertions, 195 deletions
diff --git a/.gitignore b/.gitignore
index 8012f5ee4..d369eab41 100644
--- a/.gitignore
+++ b/.gitignore
@@ -90,3 +90,8 @@ src/deps/PLCrashReporter/
*.dSYM
*.crash
misctools/sha
+packages/bun-wasm/*.mjs
+packages/bun-wasm/*.cjs
+packages/bun-wasm/*.map
+packages/bun-wasm/*.js
+packages/bun-wasm/*.d.ts
diff --git a/Makefile b/Makefile
index 018bedae9..d0c52e53b 100644
--- a/Makefile
+++ b/Makefile
@@ -465,6 +465,19 @@ build-obj-wasm-small:
-o packages/bun-freestanding-wasm32/bun-wasm.wasm
cp packages/bun-freestanding-wasm32/bun-wasm.wasm src/api/demo/public/bun-wasm.wasm
+wasm: api build-obj-wasm-small
+ @rm -rf packages/bun-wasm/*.{d.ts,js,wasm,cjs,mjs,tsbuildinfo}
+ @cp packages/bun-freestanding-wasm32/bun-wasm.wasm packages/bun-wasm/bun.wasm
+ @cp src/api/schema.d.ts packages/bun-wasm/schema.d.ts
+ @cp src/api/schema.js packages/bun-wasm/schema.js
+ @cd packages/bun-wasm && $(NPM_CLIENT) run tsc -- -p .
+ @esbuild --sourcemap=external --external:fs --define:process.env.NODE_ENV="production" --outdir=packages/bun-wasm --target=esnext --bundle packages/bun-wasm/index.ts --format=esm --minify > /dev/null
+ @mv packages/bun-wasm/index.js packages/bun-wasm/index.mjs
+ @mv packages/bun-wasm/index.js.map packages/bun-wasm/index.mjs.map
+ @esbuild --sourcemap=external --external:fs --define:process.env.NODE_ENV="production" --outdir=packages/bun-wasm --target=esnext --bundle packages/bun-wasm/index.ts --format=cjs --minify --platform=node > /dev/null
+ @mv packages/bun-wasm/index.js packages/bun-wasm/index.cjs
+ @mv packages/bun-wasm/index.js.map packages/bun-wasm/index.cjs.map
+ @rm -rf packages/bun-wasm/*.tsbuildinfo
build-obj-safe:
$(ZIG) build obj -Drelease-safe
diff --git a/bun.lockb b/bun.lockb
index a45acac04..4e2475280 100755
--- a/bun.lockb
+++ b/bun.lockb
Binary files differ
diff --git a/package.json b/package.json
index d28c4f780..af8acaa67 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"dependencies": {
- "peechy": "0.4.24",
+ "peechy": "0.4.32",
"react": "^17.0.2"
},
"scripts": {
@@ -12,4 +12,4 @@
"typescript": "4.6.3"
},
"version": "0.0.0"
-}
+} \ No newline at end of file
diff --git a/packages/bun-types/types.d.ts b/packages/bun-types/types.d.ts
index ae66ecea3..ebe8e2e5f 100644
--- a/packages/bun-types/types.d.ts
+++ b/packages/bun-types/types.d.ts
@@ -4782,7 +4782,7 @@ declare class HTMLRewriter {
// ./globals.d.ts
-type Encoding = "utf-8" | "windows-1252" | "utf-16";
+type Encoding = "utf8" | "utf-8" | "windows-1252" | "utf-16";
interface console {
assert(condition?: boolean, ...data: any[]): void;
diff --git a/packages/bun-wasm/bun.lockb b/packages/bun-wasm/bun.lockb
new file mode 100755
index 000000000..ff9d2fad6
--- /dev/null
+++ b/packages/bun-wasm/bun.lockb
Binary files differ
diff --git a/packages/bun-wasm/index.ts b/packages/bun-wasm/index.ts
new file mode 100644
index 000000000..78582c84b
--- /dev/null
+++ b/packages/bun-wasm/index.ts
@@ -0,0 +1,346 @@
+import { ByteBuffer } from "peechy/bb";
+import {
+ decodeScanResult,
+ decodeTransformResponse,
+ encodeScan,
+ encodeTransform,
+ Loader as BunLoader,
+ type ScanResult,
+ type TransformResponse,
+} from "./schema";
+export enum Loader {
+ jsx = BunLoader.jsx,
+ js = BunLoader.js,
+ tsx = BunLoader.tsx,
+ ts = BunLoader.ts,
+}
+
+export type { ScanResult, TransformResponse };
+
+function normalizeLoader(file_name: string, loader?: Loader): BunLoader {
+ return (
+ (loader
+ ? {
+ jsx: BunLoader.jsx,
+ tsx: BunLoader.tsx,
+ ts: BunLoader.ts,
+ js: BunLoader.js,
+ }[loader]
+ : null) ||
+ {
+ ".jsx": BunLoader.jsx,
+ ".tsx": BunLoader.tsx,
+ ".ts": BunLoader.ts,
+ ".js": BunLoader.js,
+ }[file_name.substring(file_name.lastIndexOf("."))] ||
+ BunLoader.js
+ );
+}
+
+interface WebAssemblyModule {
+ init(): number;
+ transform(a: number): number;
+ bun_malloc(a: number): number;
+ bun_free(a: number): number;
+ scan(a: number): number;
+}
+
+const wasm_imports_sym: symbol | string =
+ //@ts-ignore
+ process.env.NODE_ENV === "development"
+ ? "wasm_imports"
+ : Symbol("wasm_imports");
+
+const ptr_converter = new ArrayBuffer(16);
+const ptr_float = new BigUint64Array(ptr_converter);
+const slice = new Uint32Array(ptr_converter);
+
+const Wasi = {
+ clock_time_get(clk_id, tp) {
+ return Date.now();
+ },
+ environ_sizes_get() {
+ debugger;
+ return 0;
+ },
+ environ_get(__environ, environ_buf) {
+ debugger;
+ return 0;
+ },
+
+ fd_close(fd) {
+ debugger;
+ return 0;
+ },
+ proc_exit() {},
+
+ fd_seek(fd, offset_bigint, whence, newOffset) {
+ debugger;
+ },
+ fd_write(fd, iov, iovcnt, pnum) {
+ debugger;
+ },
+};
+
+var scratch: Uint8Array;
+var scratch2: Uint8Array;
+
+export class Bun {
+ static has_initialized = false;
+ // @ts-ignore-line
+ static wasm_source: WebAssembly.WebAssemblyInstantiatedSource = null;
+ static get wasm_exports(): WebAssemblyModule {
+ return Bun.wasm_source.instance.exports as any;
+ }
+ // @ts-ignore-line
+ static get memory(): WebAssembly.Memory {
+ return Bun.wasm_source.instance.exports.memory as any;
+ }
+
+ static memory_array: Uint8Array;
+
+ static _decoder: TextDecoder;
+
+ static _wasmPtrToSlice(offset: number | bigint) {
+ ptr_float[0] = typeof offset === "number" ? BigInt(offset) : offset;
+ return new Uint8Array(Bun.memory.buffer, slice[0], slice[1]);
+ }
+
+ static _wasmPtrLenToString(slice: number) {
+ if (!Bun._decoder) {
+ Bun._decoder = new TextDecoder("utf8");
+ }
+
+ const region = Bun._wasmPtrToSlice(slice);
+ return Bun._decoder.decode(region);
+ }
+
+ // We don't want people to be calling these manually
+ // @ts-ignore-line
+ static [wasm_imports_sym as symbol] = {
+ console_log(slice: number) {
+ console.log(Bun._wasmPtrLenToString(slice));
+ },
+ console_error(slice: number) {
+ console.error(Bun._wasmPtrLenToString(slice));
+ },
+ console_warn(slice: number) {
+ console.warn(Bun._wasmPtrLenToString(slice));
+ },
+ console_info(slice: number) {
+ console.info(Bun._wasmPtrLenToString(slice));
+ },
+ // @ts-ignore-line
+ __indirect_function_table: new WebAssembly.Table({
+ initial: 0,
+ element: "anyfunc",
+ }),
+ // @ts-ignore-line
+ __stack_pointer: new WebAssembly.Global({
+ mutable: true,
+ value: "i32",
+ }),
+ __multi3(one: number, two: number) {
+ return Math.imul(one | 0, two | 0);
+ },
+ fmod(one: number, two: number) {
+ return one % two;
+ },
+ memset(ptr: number, value: number, len: number) {
+ Bun.memory_array.fill(value, ptr, ptr + len);
+ },
+ memcpy(ptr: number, value: number, len: number) {
+ Bun.memory_array.copyWithin(ptr, value, value + len);
+ },
+ // These functions convert a to an unsigned long long, rounding toward zero. Negative values all become zero.
+ __fixunsdfti(a: number) {
+ return Math.floor(a);
+ },
+ // These functions return the remainder of the unsigned division of a and b.
+ __umodti3(a: number, b: number) {
+ return (a | 0) % (b | 0);
+ },
+ // These functions return the quotient of the unsigned division of a and b.
+ __udivti3(a: number, b: number) {
+ return (a | 0) / (b | 0);
+ },
+ // These functions return the result of shifting a left by b bits.
+ __ashlti3(a: number, b: number) {
+ return (a | 0) >> (b | 0);
+ },
+ /* Returns: convert a to a double, rounding toward even. */
+ __floatuntidf(a: number) {
+ const mod = a % 2;
+ if (mod === 0) {
+ return Math.ceil(a);
+ } else if (mod === 1) {
+ return Math.floor(a);
+ }
+ },
+ emscripten_notify_memory_growth() {},
+ };
+
+ static async init(url, fetch = globalThis.fetch) {
+ // globalThis.sucraseTransform = sucraseTransform;
+ scratch = new Uint8Array(8096);
+
+ if (Bun.has_initialized) {
+ return;
+ }
+
+ if (globalThis?.WebAssembly?.instantiateStreaming) {
+ Bun.wasm_source = await globalThis.WebAssembly.instantiateStreaming(
+ fetch(url),
+ { env: Bun[wasm_imports_sym], wasi_snapshot_preview1: Wasi }
+ );
+ } else if (typeof window !== "undefined") {
+ const resp = await fetch(url);
+ Bun.wasm_source = await globalThis.WebAssembly.instantiate(
+ await resp.arrayBuffer(),
+ {
+ env: Bun[wasm_imports_sym],
+ wasi_snapshot_preview1: Wasi,
+ }
+ );
+ // is it node?
+ } else {
+ //@ts-ignore
+ const fs = await import("fs");
+
+ Bun.wasm_source = await globalThis.WebAssembly.instantiate(
+ fs.readFileSync(url),
+ {
+ env: Bun[wasm_imports_sym],
+ wasi_snapshot_preview1: Wasi,
+ }
+ );
+ }
+
+ const res = Bun.wasm_exports.init();
+ if (res < 0) {
+ throw `[Bun] Failed to initialize WASM module: code ${res}`;
+ }
+
+ Bun.has_initialized = true;
+ }
+
+ static transformSync(
+ content: Uint8Array | string,
+ file_name: string,
+ loader?: Loader
+ ): TransformResponse {
+ if (!Bun.has_initialized) {
+ throw "Please run await Bun.init(wasm_url) before using this.";
+ }
+
+ // if (process.env.NODE_ENV === "development") {
+ // console.time("[Bun] Transform " + file_name);
+ // }
+
+ const bb = new ByteBuffer(scratch);
+ bb.length = 0;
+ bb.index = 0;
+ var contents_buffer;
+ if (typeof content === "string") {
+ if (!scratch2) {
+ scratch2 = new Uint8Array(content.length * 2);
+ }
+
+ let i = 0;
+ for (; i < content.length; i++) {
+ if (i > scratch2.length) {
+ var scratch3 = new Uint8Array(scratch2.length * 2);
+ scratch3.set(scratch2);
+ scratch2 = scratch3;
+ }
+ scratch2[i] = content.charCodeAt(i);
+ }
+ contents_buffer = scratch2.subarray(0, i);
+ } else {
+ contents_buffer = content;
+ }
+ encodeTransform(
+ {
+ contents: contents_buffer,
+ path: file_name,
+ // @ts-ignore
+ loader: normalizeLoader(file_name, loader),
+ },
+ bb
+ );
+ const data = bb.toUint8Array();
+
+ const input_ptr = Bun.wasm_exports.bun_malloc(data.length);
+ var buffer = Bun._wasmPtrToSlice(input_ptr);
+ buffer.set(data);
+
+ const resp_ptr = Bun.wasm_exports.transform(input_ptr);
+
+ var _bb = new ByteBuffer(Bun._wasmPtrToSlice(resp_ptr));
+
+ const response = decodeTransformResponse(_bb);
+ Bun.wasm_exports.bun_free(input_ptr);
+ scratch = bb.data;
+ return response;
+ }
+
+ static scan(
+ content: Uint8Array | string,
+ file_name: string,
+ loader?: Loader
+ ): ScanResult {
+ if (!Bun.has_initialized) {
+ throw "Please run await Bun.init(wasm_url) before using this.";
+ }
+
+ // if (process.env.NODE_ENV === "development") {
+ // console.time("[Bun] Transform " + file_name);
+ // }
+ scratch.fill(0);
+ const bb = new ByteBuffer(scratch);
+ bb.length = 0;
+ bb.index = 0;
+ var contents_buffer;
+ if (typeof content === "string") {
+ if (!scratch2) {
+ scratch2 = new Uint8Array(content.length * 2);
+ }
+ const encode_into = new TextEncoder().encodeInto(content, scratch2);
+ contents_buffer = scratch2.subarray(0, encode_into.written);
+ } else {
+ contents_buffer = content;
+ }
+
+ encodeScan(
+ {
+ contents: contents_buffer,
+ path: file_name,
+ // @ts-ignore
+ loader: normalizeLoader(file_name, loader),
+ },
+ bb
+ );
+ const data = bb.toUint8Array();
+
+ const input_ptr = Bun.wasm_exports.bun_malloc(data.length);
+ var buffer = Bun._wasmPtrToSlice(input_ptr);
+ buffer.set(data);
+
+ const resp_ptr = Bun.wasm_exports.scan(input_ptr);
+ var _bb = new ByteBuffer(Bun._wasmPtrToSlice(resp_ptr));
+ const response = decodeScanResult(_bb);
+ Bun.wasm_exports.bun_free(input_ptr);
+ scratch = bb.data;
+ return response;
+ }
+}
+
+export const transformSync = Bun.transformSync;
+export const scan = Bun.scan;
+export const init = Bun.init;
+export default Bun;
+
+if ("window" in globalThis && !("Bun" in globalThis)) {
+ // @ts-ignore-line
+ globalThis.Bun = Bun;
+}
diff --git a/packages/bun-wasm/package.json b/packages/bun-wasm/package.json
new file mode 100644
index 000000000..5f3234e40
--- /dev/null
+++ b/packages/bun-wasm/package.json
@@ -0,0 +1,30 @@
+{
+ "name": "bun-wasm",
+ "version": "0.0.79",
+ "devDependencies": {
+ "peechy": "0.4.32",
+ "typescript": "latest"
+ },
+ "files": [
+ "bun.wasm",
+ "schema.d.ts",
+ "index.mjs",
+ "index.cjs",
+ "index.mjs.map",
+ "index.cjs.map",
+ "index.d.ts",
+ "schema.js"
+ ],
+ "type": "module",
+ "types": "index.d.ts",
+ "exports": {
+ ".": {
+ "import": "./index.mjs",
+ "require": "./index.cjs",
+ "default": "./index.mjs"
+ },
+ "./schema": "./schema.js",
+ "./wasm": "./bun.wasm",
+ "./bun.wasm": "./bun.wasm"
+ }
+}
diff --git a/packages/bun-wasm/test/node.mjs b/packages/bun-wasm/test/node.mjs
new file mode 100644
index 000000000..832b3f67b
--- /dev/null
+++ b/packages/bun-wasm/test/node.mjs
@@ -0,0 +1,17 @@
+import * as Bun from "../index.mjs";
+
+await Bun.init(new URL("../bun.wasm", import.meta.url));
+
+const hey = Bun.transformSync(
+ `
+
+export function hi() {
+ return true;
+}
+
+`,
+ "hi.js",
+ "js"
+);
+
+console.log(JSON.stringify(hey, null, 2));
diff --git a/packages/bun-wasm/tsconfig.json b/packages/bun-wasm/tsconfig.json
new file mode 100644
index 000000000..cb966c684
--- /dev/null
+++ b/packages/bun-wasm/tsconfig.json
@@ -0,0 +1,21 @@
+{
+ "compilerOptions": {
+ "moduleResolution": "node",
+ "target": "esnext",
+ "module": "esnext",
+ "declaration": true,
+ "esModuleInterop": true,
+ "isolatedModules": false,
+ "skipLibCheck": true,
+ "emitDeclarationOnly": true,
+ "outDir": ".",
+ "baseUrl": "."
+ },
+ "include": [
+ "./node_modules/peechy",
+ "./schema.d.ts",
+ "./index.ts",
+ "./schema.js"
+ ],
+ "exclude": []
+}
diff --git a/src/api/bun.lockb b/src/api/bun.lockb
new file mode 100755
index 000000000..90a1dd4c9
--- /dev/null
+++ b/src/api/bun.lockb
Binary files differ
diff --git a/src/api/package.json b/src/api/package.json
new file mode 100644
index 000000000..9df4297df
--- /dev/null
+++ b/src/api/package.json
@@ -0,0 +1,7 @@
+{
+ "name": "bun-api",
+ "private": true,
+ "dependencies": {
+ "peechy": "latest"
+ }
+}
diff --git a/src/api/schema.d.ts b/src/api/schema.d.ts
index fb761317d..1bc604beb 100644
--- a/src/api/schema.d.ts
+++ b/src/api/schema.d.ts
@@ -1,4 +1,4 @@
-import type { ByteBuffer } from "peechy";
+import type { ByteBuffer } from "peechy/bb";
type byte = number;
type float = number;
@@ -6,13 +6,14 @@ type int = number;
type alphanumeric = string;
type uint = number;
type int8 = number;
+type uint8 = number;
type lowp = number;
type int16 = number;
type int32 = number;
type float32 = number;
type uint16 = number;
type uint32 = number;
-export enum Loader {
+export const enum Loader {
jsx = 1,
js = 2,
ts = 3,
@@ -23,40 +24,40 @@ export enum Loader {
toml = 8,
wasm = 9,
}
-export const LoaderKeys = {
- 1: "jsx",
- jsx: "jsx",
- 2: "js",
- js: "js",
- 3: "ts",
- ts: "ts",
- 4: "tsx",
- tsx: "tsx",
- 5: "css",
- css: "css",
- 6: "file",
- file: "file",
- 7: "json",
- json: "json",
- 8: "toml",
- toml: "toml",
- 9: "wasm",
- wasm: "wasm",
+export const LoaderKeys: {
+ 1: "jsx";
+ jsx: "jsx";
+ 2: "js";
+ js: "js";
+ 3: "ts";
+ ts: "ts";
+ 4: "tsx";
+ tsx: "tsx";
+ 5: "css";
+ css: "css";
+ 6: "file";
+ file: "file";
+ 7: "json";
+ json: "json";
+ 8: "toml";
+ toml: "toml";
+ 9: "wasm";
+ wasm: "wasm";
};
-export enum FrameworkEntryPointType {
+export const enum FrameworkEntryPointType {
client = 1,
server = 2,
fallback = 3,
}
-export const FrameworkEntryPointTypeKeys = {
- 1: "client",
- client: "client",
- 2: "server",
- server: "server",
- 3: "fallback",
- fallback: "fallback",
+export const FrameworkEntryPointTypeKeys: {
+ 1: "client";
+ client: "client";
+ 2: "server";
+ server: "server";
+ 3: "fallback";
+ fallback: "fallback";
};
-export enum StackFrameScope {
+export const enum StackFrameScope {
Eval = 1,
Module = 2,
Function = 3,
@@ -64,21 +65,21 @@ export enum StackFrameScope {
Wasm = 5,
Constructor = 6,
}
-export const StackFrameScopeKeys = {
- 1: "Eval",
- Eval: "Eval",
- 2: "Module",
- Module: "Module",
- 3: "Function",
- Function: "Function",
- 4: "Global",
- Global: "Global",
- 5: "Wasm",
- Wasm: "Wasm",
- 6: "Constructor",
- Constructor: "Constructor",
+export const StackFrameScopeKeys: {
+ 1: "Eval";
+ Eval: "Eval";
+ 2: "Module";
+ Module: "Module";
+ 3: "Function";
+ Function: "Function";
+ 4: "Global";
+ Global: "Global";
+ 5: "Wasm";
+ Wasm: "Wasm";
+ 6: "Constructor";
+ Constructor: "Constructor";
};
-export enum FallbackStep {
+export const enum FallbackStep {
ssr_disabled = 1,
create_vm = 2,
configure_router = 3,
@@ -88,123 +89,123 @@ export enum FallbackStep {
eval_entry_point = 7,
fetch_event_handler = 8,
}
-export const FallbackStepKeys = {
- 1: "ssr_disabled",
- ssr_disabled: "ssr_disabled",
- 2: "create_vm",
- create_vm: "create_vm",
- 3: "configure_router",
- configure_router: "configure_router",
- 4: "configure_defines",
- configure_defines: "configure_defines",
- 5: "resolve_entry_point",
- resolve_entry_point: "resolve_entry_point",
- 6: "load_entry_point",
- load_entry_point: "load_entry_point",
- 7: "eval_entry_point",
- eval_entry_point: "eval_entry_point",
- 8: "fetch_event_handler",
- fetch_event_handler: "fetch_event_handler",
+export const FallbackStepKeys: {
+ 1: "ssr_disabled";
+ ssr_disabled: "ssr_disabled";
+ 2: "create_vm";
+ create_vm: "create_vm";
+ 3: "configure_router";
+ configure_router: "configure_router";
+ 4: "configure_defines";
+ configure_defines: "configure_defines";
+ 5: "resolve_entry_point";
+ resolve_entry_point: "resolve_entry_point";
+ 6: "load_entry_point";
+ load_entry_point: "load_entry_point";
+ 7: "eval_entry_point";
+ eval_entry_point: "eval_entry_point";
+ 8: "fetch_event_handler";
+ fetch_event_handler: "fetch_event_handler";
};
-export enum ResolveMode {
+export const enum ResolveMode {
disable = 1,
lazy = 2,
dev = 3,
bundle = 4,
}
-export const ResolveModeKeys = {
- 1: "disable",
- disable: "disable",
- 2: "lazy",
- lazy: "lazy",
- 3: "dev",
- dev: "dev",
- 4: "bundle",
- bundle: "bundle",
+export const ResolveModeKeys: {
+ 1: "disable";
+ disable: "disable";
+ 2: "lazy";
+ lazy: "lazy";
+ 3: "dev";
+ dev: "dev";
+ 4: "bundle";
+ bundle: "bundle";
};
-export enum Platform {
+export const enum Platform {
browser = 1,
node = 2,
bun = 3,
bun_macro = 4,
}
-export const PlatformKeys = {
- 1: "browser",
- browser: "browser",
- 2: "node",
- node: "node",
- 3: "bun",
- bun: "bun",
- 4: "bun_macro",
- bun_macro: "bun_macro",
+export const PlatformKeys: {
+ 1: "browser";
+ browser: "browser";
+ 2: "node";
+ node: "node";
+ 3: "bun";
+ bun: "bun";
+ 4: "bun_macro";
+ bun_macro: "bun_macro";
};
-export enum CSSInJSBehavior {
+export const enum CSSInJSBehavior {
facade = 1,
facade_onimportcss = 2,
auto_onimportcss = 3,
}
-export const CSSInJSBehaviorKeys = {
- 1: "facade",
- facade: "facade",
- 2: "facade_onimportcss",
- facade_onimportcss: "facade_onimportcss",
- 3: "auto_onimportcss",
- auto_onimportcss: "auto_onimportcss",
+export const CSSInJSBehaviorKeys: {
+ 1: "facade";
+ facade: "facade";
+ 2: "facade_onimportcss";
+ facade_onimportcss: "facade_onimportcss";
+ 3: "auto_onimportcss";
+ auto_onimportcss: "auto_onimportcss";
};
-export enum JSXRuntime {
+export const enum JSXRuntime {
automatic = 1,
classic = 2,
}
-export const JSXRuntimeKeys = {
- 1: "automatic",
- automatic: "automatic",
- 2: "classic",
- classic: "classic",
+export const JSXRuntimeKeys: {
+ 1: "automatic";
+ automatic: "automatic";
+ 2: "classic";
+ classic: "classic";
};
-export enum ScanDependencyMode {
+export const enum ScanDependencyMode {
app = 1,
all = 2,
}
-export const ScanDependencyModeKeys = {
- 1: "app",
- app: "app",
- 2: "all",
- all: "all",
+export const ScanDependencyModeKeys: {
+ 1: "app";
+ app: "app";
+ 2: "all";
+ all: "all";
};
-export enum ModuleImportType {
+export const enum ModuleImportType {
import = 1,
require = 2,
}
-export const ModuleImportTypeKeys = {
- 1: "import",
- import: "import",
- 2: "require",
- require: "require",
+export const ModuleImportTypeKeys: {
+ 1: "import";
+ import: "import";
+ 2: "require";
+ require: "require";
};
-export enum DotEnvBehavior {
+export const enum DotEnvBehavior {
disable = 1,
prefix = 2,
load_all = 3,
}
-export const DotEnvBehaviorKeys = {
- 1: "disable",
- disable: "disable",
- 2: "prefix",
- prefix: "prefix",
- 3: "load_all",
- load_all: "load_all",
+export const DotEnvBehaviorKeys: {
+ 1: "disable";
+ disable: "disable";
+ 2: "prefix";
+ prefix: "prefix";
+ 3: "load_all";
+ load_all: "load_all";
};
-export enum SourceMapMode {
+export const enum SourceMapMode {
inline_into_file = 1,
external = 2,
}
-export const SourceMapModeKeys = {
- 1: "inline_into_file",
- inline_into_file: "inline_into_file",
- 2: "external",
- external: "external",
+export const SourceMapModeKeys: {
+ 1: "inline_into_file";
+ inline_into_file: "inline_into_file";
+ 2: "external";
+ external: "external";
};
-export enum ImportKind {
+export const enum ImportKind {
entry_point = 1,
stmt = 2,
require = 3,
@@ -214,67 +215,67 @@ export enum ImportKind {
url = 7,
internal = 8,
}
-export const ImportKindKeys = {
- 1: "entry_point",
- entry_point: "entry_point",
- 2: "stmt",
- stmt: "stmt",
- 3: "require",
- require: "require",
- 4: "dynamic",
- dynamic: "dynamic",
- 5: "require_resolve",
- require_resolve: "require_resolve",
- 6: "at",
- at: "at",
- 7: "url",
- url: "url",
- 8: "internal",
- internal: "internal",
+export const ImportKindKeys: {
+ 1: "entry_point";
+ entry_point: "entry_point";
+ 2: "stmt";
+ stmt: "stmt";
+ 3: "require";
+ require: "require";
+ 4: "dynamic";
+ dynamic: "dynamic";
+ 5: "require_resolve";
+ require_resolve: "require_resolve";
+ 6: "at";
+ at: "at";
+ 7: "url";
+ url: "url";
+ 8: "internal";
+ internal: "internal";
};
-export enum TransformResponseStatus {
+export const enum TransformResponseStatus {
success = 1,
fail = 2,
}
-export const TransformResponseStatusKeys = {
- 1: "success",
- success: "success",
- 2: "fail",
- fail: "fail",
+export const TransformResponseStatusKeys: {
+ 1: "success";
+ success: "success";
+ 2: "fail";
+ fail: "fail";
};
-export enum MessageLevel {
+export const enum MessageLevel {
err = 1,
warn = 2,
note = 3,
info = 4,
debug = 5,
}
-export const MessageLevelKeys = {
- 1: "err",
- err: "err",
- 2: "warn",
- warn: "warn",
- 3: "note",
- note: "note",
- 4: "info",
- info: "info",
- 5: "debug",
- debug: "debug",
+export const MessageLevelKeys: {
+ 1: "err";
+ err: "err";
+ 2: "warn";
+ warn: "warn";
+ 3: "note";
+ note: "note";
+ 4: "info";
+ info: "info";
+ 5: "debug";
+ debug: "debug";
};
-export enum Reloader {
+export const enum Reloader {
disable = 1,
live = 2,
fast_refresh = 3,
}
-export const ReloaderKeys = {
- 1: "disable",
- disable: "disable",
- 2: "live",
- live: "live",
- 3: "fast_refresh",
- fast_refresh: "fast_refresh",
+export const ReloaderKeys: {
+ 1: "disable";
+ disable: "disable";
+ 2: "live";
+ live: "live";
+ 3: "fast_refresh";
+ fast_refresh: "fast_refresh";
};
-export enum WebsocketMessageKind {
+export const enum WebsocketMessageKind {
welcome = 1,
file_change_notification = 2,
build_success = 3,
@@ -284,36 +285,36 @@ export enum WebsocketMessageKind {
resolve_file = 7,
file_change_notification_with_hint = 8,
}
-export const WebsocketMessageKindKeys = {
- 1: "welcome",
- welcome: "welcome",
- 2: "file_change_notification",
- file_change_notification: "file_change_notification",
- 3: "build_success",
- build_success: "build_success",
- 4: "build_fail",
- build_fail: "build_fail",
- 5: "manifest_success",
- manifest_success: "manifest_success",
- 6: "manifest_fail",
- manifest_fail: "manifest_fail",
- 7: "resolve_file",
- resolve_file: "resolve_file",
- 8: "file_change_notification_with_hint",
- file_change_notification_with_hint: "file_change_notification_with_hint",
+export const WebsocketMessageKindKeys: {
+ 1: "welcome";
+ welcome: "welcome";
+ 2: "file_change_notification";
+ file_change_notification: "file_change_notification";
+ 3: "build_success";
+ build_success: "build_success";
+ 4: "build_fail";
+ build_fail: "build_fail";
+ 5: "manifest_success";
+ manifest_success: "manifest_success";
+ 6: "manifest_fail";
+ manifest_fail: "manifest_fail";
+ 7: "resolve_file";
+ resolve_file: "resolve_file";
+ 8: "file_change_notification_with_hint";
+ file_change_notification_with_hint: "file_change_notification_with_hint";
};
-export enum WebsocketCommandKind {
+export const enum WebsocketCommandKind {
build = 1,
manifest = 2,
build_with_file_path = 3,
}
-export const WebsocketCommandKindKeys = {
- 1: "build",
- build: "build",
- 2: "manifest",
- manifest: "manifest",
- 3: "build_with_file_path",
- build_with_file_path: "build_with_file_path",
+export const WebsocketCommandKindKeys: {
+ 1: "build";
+ build: "build";
+ 2: "manifest";
+ manifest: "manifest";
+ 3: "build_with_file_path";
+ build_with_file_path: "build_with_file_path";
};
export interface StackFrame {
function_name: string;
diff --git a/src/api/tsconfig.json b/src/api/tsconfig.json
new file mode 100644
index 000000000..a49f0ba6f
--- /dev/null
+++ b/src/api/tsconfig.json
@@ -0,0 +1,6 @@
+{
+ "compilerOptions": {
+ "moduleResolution": "node"
+ },
+ "include": ["./node_modules/peechy", "./schema.d.ts"]
+}
diff --git a/src/main_wasm.zig b/src/main_wasm.zig
index b1788e70a..185d785c5 100644
--- a/src/main_wasm.zig
+++ b/src/main_wasm.zig
@@ -261,7 +261,7 @@ export fn transform(opts_array: u64) u64 {
transform_response = Api.TransformResponse{
.status = if (result.ok) Api.TransformResponseStatus.success else Api.TransformResponseStatus.fail,
.files = &output_files,
- .errors = &[_]Api.Message{}, //(log.toAPI(allocator) catch unreachable).msgs,
+ .errors = (log.toAPI(allocator) catch unreachable).msgs,
};
var output = std.ArrayList(u8).init(default_allocator);