{"id":15043185,"url":"https://github.com/yhaiovyi/c-wasm-loader","last_synced_at":"2025-04-14T21:13:16.411Z","repository":{"id":57192266,"uuid":"122796900","full_name":"yhaiovyi/c-wasm-loader","owner":"yhaiovyi","description":"Super change your browser with C/C++ power.","archived":false,"fork":false,"pushed_at":"2018-02-28T04:42:24.000Z","size":407,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-14T21:13:09.358Z","etag":null,"topics":["c","cpp","wasm","webpack","webpack-loader","webpack3"],"latest_commit_sha":null,"homepage":"","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/yhaiovyi.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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-25T01:55:54.000Z","updated_at":"2021-07-15T17:05:39.000Z","dependencies_parsed_at":"2022-09-01T03:40:22.126Z","dependency_job_id":null,"html_url":"https://github.com/yhaiovyi/c-wasm-loader","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yhaiovyi%2Fc-wasm-loader","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yhaiovyi%2Fc-wasm-loader/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yhaiovyi%2Fc-wasm-loader/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yhaiovyi%2Fc-wasm-loader/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yhaiovyi","download_url":"https://codeload.github.com/yhaiovyi/c-wasm-loader/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248961237,"owners_count":21189993,"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","wasm","webpack","webpack-loader","webpack3"],"created_at":"2024-09-24T20:48:40.645Z","updated_at":"2025-04-14T21:13:16.387Z","avatar_url":"https://github.com/yhaiovyi.png","language":"JavaScript","readme":"# c-wasm-loader\n\n\u003cdiv align=\"center\"\u003e\n\u003ca title=\"By Jeremy Kratz (https://github.com/isocpp/logos) [Copyrighted free use], via Wikimedia Commons\" href=\"https://commons.wikimedia.org/wiki/File%3AISO_C%2B%2B_Logo.svg\"\u003e\u003cimg height=\"128\" alt=\"ISO C++ Logo\" src=\"https://upload.wikimedia.org/wikipedia/commons/thumb/1/18/ISO_C%2B%2B_Logo.svg/256px-ISO_C%2B%2B_Logo.svg.png\"/\u003e\u003c/a\u003e\n\u003ca title=\"By Carlos Baraza [CC0], via Wikimedia Commons\" href=\"https://commons.wikimedia.org/wiki/File%3AWeb_Assembly_Logo.svg\"\u003e\u003cimg height=\"128\" alt=\"Web Assembly Logo\" src=\"https://upload.wikimedia.org/wikipedia/commons/thumb/c/c6/Web_Assembly_Logo.svg/512px-Web_Assembly_Logo.svg.png\"/\u003e\u003c/a\u003e\n\u003c/div\u003e\n\n[![npm][npm]][npm-url]\n\n[![node][node]][node-url]\n[![deps][deps]][deps-url]\n[![tests][tests]][tests-url]\n[![builds][builds]][builds-url]\n[![coverage][cover]][cover-url]\n\nWebpack loader that allows you to import C/C++ files as WebAssembly.\nThis project is in very early development stage, and you're very welcome to contribute or file tickets, as well as it's not released yet, so api changes every day, publish process is not consistent, so some npm versions are broken.\n\n\u003ch2 align=\"center\"\u003eInstall\u003c/h2\u003e\n\nInstall with npm:\n\n```bash\nnpm install --save-dev c-wasm-loader\n```\n\nInstall with yarn:\n\n```bash\nyarn add c-wasm-loader --dev\n```\n\nThis package automatically installs portable emsdk, so you should have cmake only available.\n\n\u003ch2 align=\"center\"\u003eOptions\u003c/h2\u003e\n\n|Name|Type|Default|Description|\n|:--:|:--:|:-----:|:----------|\n|**[`name`](#name)**|`{String\\|Function}`|`[hash].[ext]`|Configure a custom filename template for your file|\n|**`regExp`**|`{RegExp}`|`'undefined'`|Let you extract some parts of the file path to reuse them in the `name` property|\n|**`outputPath`**|`{String\\|Function}`|`'undefined'`|Configure a custom `output` path for your file|\n|**`useRelativePath`**|`{Boolean}`|`false`|Should be `true` if you wish to generate a `context` relative URL for each file|\n|**[`limit`](#limit)**|`{Number\\|String}`|`undefined`|Byte limit to inline compiled files as Data URL|\n|**`std`**|`{String}`|undefined|Choose one of ISO C++ standards (C++98 / C++03, C++11, and C++14)|\n|**`includePaths`**|`{Array}`|undefined||\n|**`bind`**|`{Boolean}`|`false`||\n|**[`optimizationLevel`](#optimizationLevel)**|`{Number}`|`undefined`|Optimization level for emscripten compiler|\n|**[`debugLevel`](#debugLevel)**|`{Number}`|`undefined`|Debug level for emscripten compiler|\n\n### `name`\n\nYou can configure a custom filename template for your file using the query parameter `name`.\n\n### `limit`\n\nIf the file is greater than the limit (in bytes) the [`file-loader`](https://github.com/webpack-contrib/file-loader) is used by default and all query parameters are passed to it.\n\nThe limit can be specified via loader options and defaults to no limit.\n\n### `optimizationLevel`\n\nCode is optimized by specifying optimization flags when running emcc. The levels include: 0 (no optimization), 1, 2, s, z, 3.\n\nEmcc strips out most of the debug information from optimized builds by default. Optimisation levels 0 and above remove LLVM debug information, and also disable runtime ASSERTIONS checks. From optimization level -02 the code is minified by the Closure Compiler and becomes virtually unreadable.\n\n### `debugLevel`\n\nCan be used to preserve debug information in the compiled output. By default, this option preserves white-space, function names and variable names.\n\nThe flag can also be specified with one of five levels: 0, 1, 2, 3, 4. Each level builds on the last to provide progressively more debug information in the compiled output.\n\nIf set to 4 provides the most debug information — it generates source maps that allow you to view and debug the C/C++ source code in your browser’s debugger on Firefox, Chrome or Safari!\n\n\u003ch2 align=\"center\"\u003eUsage\u003c/h2\u003e\n\n**hello.c**\n```c\n#include \u003cemscripten/emscripten.h\u003e\n\nextern \"C\" {\n  int main(int argc, char ** argv) {\n    printf(\"Hello\\n\");\n  }\n\n  int EMSCRIPTEN_KEEPALIVE world() {\n    printf(\"World\\n\");\n  }\n}\n```\n\n**hello.js**\n```js\nimport hello from './hello.c';\n\nhello().then((module) =\u003e {\n  module._world();\n});\n```\n\n**webpack.config.js**\n```js\nmodule.exports = {\n  externals: {\n    fs: true\n  },\n  module: {\n    rules: [\n      {\n        test: /\\.(c|cpp)$/,\n        use: {\n          loader: 'c-wasm-loader',\n          options: {\n            outputPath: 'wasm',\n            name: '[name]-[hash].[ext]'\n          }\n        }\n      }\n    ]\n  }\n}\n```\n\n[npm]: https://img.shields.io/npm/v/c-wasm-loader.svg\n[npm-url]: https://www.npmjs.com/package/c-wasm-loader\n\n[node]: https://img.shields.io/node/v/c-wasm-loader.svg\n[node-url]: https://nodejs.org\n\n[deps]: https://img.shields.io/david/yhaiovyi/c-wasm-loader.svg\n[deps-url]: https://david-dm.org/yhaiovyi/c-wasm-loader\n\n[tests]: https://img.shields.io/travis/yhaiovyi/c-wasm-loader/master.svg\n[tests-url]: https://travis-ci.org/yhaiovyi/c-wasm-loader\n\n[builds-url]: https://ci.appveyor.com/project/sokra/webpack/yhaiovyi/c-wasm-loader\n[builds]: https://ci.appveyor.com/api/projects/status/github/yhaiovyi/c-wasm-loader?svg=true\n\n[cover]: https://coveralls.io/repos/github/yhaiovyi/c-wasm-loader/badge.svg?branch=master\n[cover-url]: https://coveralls.io/github/yhaiovyi/c-wasm-loader?branch=master\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyhaiovyi%2Fc-wasm-loader","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyhaiovyi%2Fc-wasm-loader","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyhaiovyi%2Fc-wasm-loader/lists"}