by light24bulbs · 4y ago · 0 comments
In Zig, code can run at compile time, and thats amazing. That's one of the main things I want in TypeScript. Once you have that, everything from type reflection to native graphql types without codegen is just a library away.
Yeah, I'd really, really like to hear more about that if you can point me at anything. Overall, all of the decisions Bun is making, in just about every part of the ecosystem it touches, are things that I have been really excited about. I've got a good feeling about this and I'm trying to scrape some time together to help out.
As for esbuild, I don't think you're correcting the article because it said that the parser is a `port` of esbuild, not "based on". You're probably just replying to the other comment :)
[macros]
# Remap any import like this:
# import {graphql} from 'react-relay';
# To:
# import {graphql} from 'macro:bun-macro-relay';
react-relay = { "graphql" = "bun-macro-relay" }
..Or as a transpiler option: const transpiler = new Bun.Transpiler({
loader: "tsx",
define: {
"process.env.NODE_ENV": JSON.stringify("development"),
user_undefined: "undefined",
},
platform: "bun",
macro: {
inline: {
whatDidIPass: `${import.meta.dir}/inline.macro.js`,
},
react: {
bacon: `${import.meta.dir}/macro-check.js`,
},
},
});
..But not within the transpiled code itself.Ooh, hold on - there's more in /test/macro. Here's hello-fetch-macro.tsx.
import { fetchSync } from "macro:./fetchSync.tsx";
const synchronousFetch = fetchSync(`https://example.com`);
console.log(synchronousFetch);
Looks like the special import syntax converts the function to run at build time.https://github.com/oven-sh/bun/blob/c3bf97002d6f0b117060dabf...