{"id":16950291,"url":"https://github.com/mischnic/parcel-plugin-emscripten","last_synced_at":"2025-04-11T20:41:54.102Z","repository":{"id":57318974,"uuid":"121055414","full_name":"mischnic/parcel-plugin-emscripten","owner":"mischnic","description":"📦 Import C(++) files with Parcel","archived":false,"fork":false,"pushed_at":"2018-02-13T15:51:28.000Z","size":66,"stargazers_count":9,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-02T13:05:45.815Z","etag":null,"topics":["c","cpp","emscripten","parcel","parcel-bundler","parcel-plugin","wasm","webassembly"],"latest_commit_sha":null,"homepage":"https://npm.im/parcel-plugin-emscripten","language":"JavaScript","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/mischnic.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-02-10T21:22:33.000Z","updated_at":"2021-12-17T06:17:25.000Z","dependencies_parsed_at":"2022-08-25T22:42:03.283Z","dependency_job_id":null,"html_url":"https://github.com/mischnic/parcel-plugin-emscripten","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mischnic%2Fparcel-plugin-emscripten","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mischnic%2Fparcel-plugin-emscripten/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mischnic%2Fparcel-plugin-emscripten/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mischnic%2Fparcel-plugin-emscripten/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mischnic","download_url":"https://codeload.github.com/mischnic/parcel-plugin-emscripten/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248478972,"owners_count":21110798,"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","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":["c","cpp","emscripten","parcel","parcel-bundler","parcel-plugin","wasm","webassembly"],"created_at":"2024-10-13T21:57:16.685Z","updated_at":"2025-04-11T20:41:54.082Z","avatar_url":"https://github.com/mischnic.png","language":"JavaScript","readme":"# Parcel plugin for Emscripten\n\n[![Build Status](https://travis-ci.org/mischnic/parcel-plugin-emscripten.svg?branch=master)](https://travis-ci.org/mischnic/parcel-plugin-emscripten)\n\nA [Parcel](https://parceljs.org/) plugin to enable importing a C(++) file inside a JS file.\n\nEmscripten has to be installed and `emcc` needs to be in `PATH`.\n\nExample:\n\n```js\nimport Module from './test.c';\nconst Instance = Module();\n\nInstance.then(()=\u003e{\n    console.log(Instance._add(10,20));\n});\n\n// equivalent to\n\nInstance.then((v)=\u003e{\n    console.log(v._add(10,20));\n});\n```\n\n```c\n//test.c\n#include \u003cemscripten.h\u003e\n\nint EMSCRIPTEN_KEEPALIVE add(int x, int y) {\n    return x + y;\n}\n```\n\nFor more complex examples, see the [example](example/src) directory.\n\n**`Instance.then` is quite fragile and not a thenable, see [https://github.com/kripken/emscripten/issues/5820](https://github.com/kripken/emscripten/issues/5820)**\n\nUsing multiple Modules (= importing multiple C files) is supported, but it isn't very filesize efficient. Consider writing a single C-wrapper and importing that instead!\n\n\nTo pass additional arguments to `emcc` (change optimization, link another C file or a library, ...), specify them in the first line of your main C file: (this would disable optimizations and compile and link `lib.c` as well)\n\n```c\n//parcel: -O0 lib.c\n#include ...\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmischnic%2Fparcel-plugin-emscripten","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmischnic%2Fparcel-plugin-emscripten","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmischnic%2Fparcel-plugin-emscripten/lists"}