typescript-runtime-type-benchmarks icon indicating copy to clipboard operation
typescript-runtime-type-benchmarks copied to clipboard

WIP: Bun support

Open DarkGL opened this issue 1 year ago • 2 comments

This is work in progress.

I'm still having some problems running bun, and I'm looking for help to fix it.

https://github.com/DarkGL/typescript-runtime-type-benchmarks/actions/runs/9016482516/job/24842376959

DarkGL avatar May 11 '24 12:05 DarkGL

@nin-jin Can you help @DarkGL with this?

screenshot-20240511T151635-F0UVb8A0@2x

moltar avatar May 11 '24 14:05 moltar

Tried with 1.1.10 but still the same

DarkGL avatar Jun 01 '24 05:06 DarkGL

@nin-jin Can you help @DarkGL with this?

screenshot-20240511T151635-F0UVb8A0@2x

Not Bun-only issue

I create file index.mjs

import {
	$mol_data_email,
	$mol_data_integer,
	$mol_data_optional,
	$mol_data_pipe,
	$mol_data_record,
	$mol_data_string,
	$mol_data_variant,
} from "mol_data_all";

const PersonDTO = $mol_data_record({
	name: $mol_data_string,
	age: $mol_data_optional($mol_data_integer),
	birthday: $mol_data_pipe($mol_data_string),
});

// Derived Type
const UserDTO = $mol_data_record({
	...PersonDTO.config,
	phone: $mol_data_variant($mol_data_string, $mol_data_integer),
	mail: $mol_data_email,
});

// Ensure this is a User
const jin = UserDTO({
	name: "Jin",
	age: 33,
	birthday: "1984-08-04T12:00:00Z",
	phone: 791234567890,
	mail: "[email protected]",
});

console.log(jin);

And run it with node index.mjs

PS C:\Users\krave\Desktop\test\tests\mol-bun> node .\index.mjs
file:///C:/Users/krave/Desktop/test/tests/mol-bun/index.mjs:2
        $mol_data_email,
        ^^^^^^^^^^^^^^^
SyntaxError: The requested module 'mol_data_all' does not provide an export named '$mol_data_email'
    at ModuleJob._instantiate (node:internal/modules/esm/module_job:131:21)
    at async ModuleJob.run (node:internal/modules/esm/module_job:213:5)
    at async ModuleLoader.import (node:internal/modules/esm/loader:316:24)
    at async loadESM (node:internal/process/esm_loader:34:7)
    at async handleMainPromise (node:internal/modules/run_main:66:12)

Node.js v20.9.0

kravetsone avatar Jul 16 '24 10:07 kravetsone

@nin-jin карловский почини пж ESM 🙏🙏

kravetsone avatar Jul 16 '24 10:07 kravetsone

Yay! I've run all the benchmarks on the Bun

kravetsone avatar Jul 16 '24 11:07 kravetsone

Yay! I've run all the benchmarks on the Bun

i use

const {
  $mol_data_tagged: Tagged,
  $mol_data_integer: Integer,
} = require("mol_data_all"); 

In bun you can mix require+import but not in node...

kravetsone avatar Jul 16 '24 21:07 kravetsone

Why it closed?

kravetsone avatar Jul 26 '24 14:07 kravetsone

I currently don't have time to work on this, if you are interested you can pick it up :)

DarkGL avatar Jul 27 '24 17:07 DarkGL

Ух ты, сколько тут страданий. Я только сейчас узнал про эту проблему. У нас экспортируются не сами сущности, а дефолтный контекст, их содержащий. Там описано, что с этим делать.

nin-jin avatar Sep 07 '24 06:09 nin-jin

Ух ты, сколько тут страданий. Я только сейчас узнал про эту проблему. У нас экспортируются не сами сущности, а дефолтный контекст, их содержащий. Там описано, что с этим делать.

Но почему типы врут?

kravetsone avatar Sep 07 '24 07:09 kravetsone

Где врут?

nin-jin avatar Sep 07 '24 08:09 nin-jin

Great to hear that you are aware of the problem, reopened, and hopefully we can get it landed

DarkGL avatar Sep 07 '24 09:09 DarkGL

Great to hear that you are aware of the problem, reopened, and hopefully we can get it landed

this example works fine (based on https://github.com/hyoo-ru/mam_mol/issues/692#issuecomment-2283249762)

import $ from "mol_data_all";
const {
	$mol_data_email,
	$mol_data_integer,
	$mol_data_optional,
	$mol_data_pipe,
	$mol_data_record,
	$mol_data_string,
	$mol_data_variant,
} = $;

console.log($);

const PersonDTO = $mol_data_record({
	name: $mol_data_string,
	age: $mol_data_optional($mol_data_integer),
	birthday: $mol_data_pipe($mol_data_string),
});

// Derived Type
const UserDTO = $mol_data_record({
	...PersonDTO.config,
	phone: $mol_data_variant($mol_data_string, $mol_data_integer),
	mail: $mol_data_email,
});

// Ensure this is a User
const jin = UserDTO({
	name: "Jin",
	age: 33,
	birthday: "1984-08-04T12:00:00Z",
	phone: 791234567890,
	mail: "[email protected]",
});

console.log(jin);

kravetsone avatar Sep 07 '24 13:09 kravetsone

I think it's ready for review :)

@moltar

DarkGL avatar Sep 10 '24 19:09 DarkGL

@DarkGL Massive work! ❤️

@hoeck lots of graphing changes on this one; please see if you have any opinions

moltar avatar Sep 10 '24 20:09 moltar

@hoeck just a friendly reminder

I want to start working on integrating deno after merging this :)

DarkGL avatar Sep 13 '24 22:09 DarkGL

@hoeck just a friendly reminder

I want to start working on integrating deno after merging this :)

I guess it will be harder... But why not

kravetsone avatar Sep 13 '24 23:09 kravetsone

@hoeck just a friendly reminder

I want to start working on integrating deno after merging this :)

Sry for the delay, looking at it now ...

hoeck avatar Sep 14 '24 08:09 hoeck

Thanks ! I will fix those typos in next pr, and maybe figure out more general way rather than just copying 😅

DarkGL avatar Sep 14 '24 10:09 DarkGL

It looks like I have broken selecting default version for Node @hoeck @moltar

DarkGL avatar Sep 14 '24 10:09 DarkGL

@hoeck just a friendly reminder

I want to start working on integrating deno after merging this :)

Great work!

kravetsone avatar Sep 14 '24 11:09 kravetsone

It looks like I have broken selecting default version for Node @hoeck @moltar

You're right, I've created an issue for that: #3111 (and thanks for testing your changes :grin:)

The init code is using nodeVersion as a key to set the initial selected one. In the new file format this is now runtime and runtimeVersion: https://github.com/moltar/typescript-runtime-type-benchmarks/blob/master/docs/app.tsx#L480

That wasn't caught by Typescript as the fetch response is not properly typed and/or runtime type checked (all while this repo is about runtype type checking :laughing: )

Can you fix it? If you don't have the time or need help, please let me know.

hoeck avatar Sep 14 '24 13:09 hoeck

Thanks ! I will fix those typos in next pr, and maybe figure out more general way rather than just copying 😅

nah that sort/order/groupby code was not good to begin with so copying is totally fine :smile: .

I've played around with a client-side PostgresSQL database (electric-sql/pglite) lately. Maybe (just maybe) we could load all results into an sqlite db and then use that for querying / grouping / sorting instead of hand-rolling everything in JS.

hoeck avatar Sep 14 '24 13:09 hoeck