{"id":23821347,"url":"https://github.com/returnstring/wasm-init","last_synced_at":"2025-09-07T04:31:12.415Z","repository":{"id":190637886,"uuid":"683130274","full_name":"returnString/wasm-init","owner":"returnString","description":"Let's pretend that life-before-main exists for Rust targeting WebAssembly","archived":false,"fork":false,"pushed_at":"2023-09-08T14:07:53.000Z","size":14,"stargazers_count":7,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-08-26T06:55:06.447Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/returnString.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-08-25T17:10:42.000Z","updated_at":"2023-08-29T09:18:59.000Z","dependencies_parsed_at":"2023-08-25T18:04:58.068Z","dependency_job_id":"85c4501f-62a0-494b-a645-ba4367666f9a","html_url":"https://github.com/returnString/wasm-init","commit_stats":null,"previous_names":["returnstring/wasm-init"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/returnString/wasm-init","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/returnString%2Fwasm-init","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/returnString%2Fwasm-init/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/returnString%2Fwasm-init/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/returnString%2Fwasm-init/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/returnString","download_url":"https://codeload.github.com/returnString/wasm-init/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/returnString%2Fwasm-init/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273996535,"owners_count":25204471,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-07T02:00:09.463Z","response_time":67,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-01-02T08:39:11.753Z","updated_at":"2025-09-07T04:31:12.165Z","avatar_url":"https://github.com/returnString.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"[\u003cimg src=\"https://img.shields.io/crates/v/wasm-init\"\u003e](https://crates.io/crates/wasm-init)\n[\u003cimg src=\"https://img.shields.io/badge/docs.rs-wasm--init-green\"\u003e](https://docs.rs/wasm-init)\n\nLet's pretend that life-before-main exists for Rust targeting WebAssembly.\n\n# Installation\nAdd a dependency on `wasm-init`. This crate intentionally provides a no-op implementation for non-wasm platforms, so `cfg` handling isn't necessary and we don't pull in unused extra deps.\n\n```toml\n[dependencies]\nwasm-init = \"0.2\"\n```\n\n# User Code\nAdd as many calls to `wasm_init!` as required on the Rust side, e.g. for decentralised plugin registration or collecting data from all types that use a particular derive macro.\n\n```rust\nwasm_init::wasm_init! {\n\t// literally any code you want to run at startup goes here\n}\n```\n\n# Initialisation\nTo ensure your `wasm_init!` calls are executed on startup, you have three options. Note that all of these options are idempotent - multiple invocations are perfectly safe (if unnecessary), even in a threaded context.\n\n## Auto-init feature\nIf you'd like to skip manually initialising `wasm-init`, you can enable the `auto-init` feature as part of the dependency:\n\n```toml\n[dependencies]\nwasm-init = { version = \"0.2\", features = [ \"auto-init\" ] }\n```\n\nBut please bear in mind that this will prevent you from using a [wasm bindgen start function](https://rustwasm.github.io/wasm-bindgen/reference/attributes/on-rust-exports/start.html) elsewhere in your project.\n\n## From Rust\nCall the `wasm_init::wasm_init` function inside your Rust entrypoint.\n\n## From JavaScript/TypeScript\nCall the `wasm_init` export from your built module.\n\n```html\n\u003cscript type=\"module\"\u003e\n\timport init, { wasm_init } from \"./pkg/my_wasm_crate.js\";\n\tinit().then(() =\u003e {\n\t\twasm_init();\n\t\t// now do things as normal!\n\t});\n\u003c/script\u003e\n```\n\n# Why?\n[inventory](https://github.com/dtolnay/inventory) et al are cool, but can't yet be used when targeting `wasm32-unknown-unknown` or similar.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freturnstring%2Fwasm-init","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Freturnstring%2Fwasm-init","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freturnstring%2Fwasm-init/lists"}