typescript-runtime-type-benchmarks
typescript-runtime-type-benchmarks copied to clipboard
WIP: Bun support
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
@nin-jin Can you help @DarkGL with this?
Tried with 1.1.10 but still the same
@nin-jin Can you help @DarkGL with this?
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
@nin-jin карловский почини пж ESM 🙏🙏
Yay! I've run all the benchmarks on the Bun
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...
Why it closed?
I currently don't have time to work on this, if you are interested you can pick it up :)
Ух ты, сколько тут страданий. Я только сейчас узнал про эту проблему. У нас экспортируются не сами сущности, а дефолтный контекст, их содержащий. Там описано, что с этим делать.
Ух ты, сколько тут страданий. Я только сейчас узнал про эту проблему. У нас экспортируются не сами сущности, а дефолтный контекст, их содержащий. Там описано, что с этим делать.
Но почему типы врут?
Где врут?
Great to hear that you are aware of the problem, reopened, and hopefully we can get it landed
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);
I think it's ready for review :)
@moltar
@DarkGL Massive work! ❤️
@hoeck lots of graphing changes on this one; please see if you have any opinions
@hoeck just a friendly reminder
I want to start working on integrating deno after merging this :)
@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
@hoeck just a friendly reminder
I want to start working on integrating deno after merging this :)
Sry for the delay, looking at it now ...
Thanks ! I will fix those typos in next pr, and maybe figure out more general way rather than just copying 😅
It looks like I have broken selecting default version for Node @hoeck @moltar
@hoeck just a friendly reminder
I want to start working on integrating deno after merging this :)
Great work!
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.
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.
