Skip to content
This repository was archived by the owner on Mar 1, 2025. It is now read-only.

tokio-js/Comptime

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Comptime

Compile-time constants in JS

Usage

build.js:

import { add, plugin } from "https://gh.matveit.dev/comptime";
import * as esbuild from "esbuild";

add("foo", { bar: "baz" });
add("version", () => {
    const version = Deno.readTextFileSync("version.txt");
    return version + "-" + new Date().toISOString();
});

await esbuild.build({
    entryPoints: ["index.ts"],
    bundle: true, // Very important!
    outfile: "out.js",
    plugins: [plugin],
});

index.ts:

import { foo, version } from "$COMPTIME";

console.log(foo.bar);
console.log(version);

About

Compile-time constants in JS

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published