{"id":20173528,"url":"https://github.com/w3reality/es-pack-js","last_synced_at":"2025-08-12T02:03:10.639Z","repository":{"id":44381437,"uuid":"242744135","full_name":"w3reality/es-pack-js","owner":"w3reality","description":"Build and test portable JavaScript/rustwasm 🦀  modules","archived":false,"fork":false,"pushed_at":"2025-02-06T01:50:33.000Z","size":2438,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-21T04:06:34.751Z","etag":null,"topics":["browser","ci","esm","jest-tests","node","rustwasm","typescript","umd"],"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/w3reality.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-02-24T13:32:10.000Z","updated_at":"2025-02-06T01:50:37.000Z","dependencies_parsed_at":"2023-02-11T23:45:45.482Z","dependency_job_id":"dd605462-681a-4023-85f3-7558d550e7d6","html_url":"https://github.com/w3reality/es-pack-js","commit_stats":{"total_commits":225,"total_committers":2,"mean_commits":112.5,"dds":0.0444444444444444,"last_synced_commit":"6d3c54ba305d60d2546a4ee795151b4e0eecf0bb"},"previous_names":[],"tags_count":30,"template":false,"template_full_name":null,"purl":"pkg:github/w3reality/es-pack-js","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/w3reality%2Fes-pack-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/w3reality%2Fes-pack-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/w3reality%2Fes-pack-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/w3reality%2Fes-pack-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/w3reality","download_url":"https://codeload.github.com/w3reality/es-pack-js/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/w3reality%2Fes-pack-js/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269987122,"owners_count":24508175,"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-08-12T02:00:09.011Z","response_time":80,"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":["browser","ci","esm","jest-tests","node","rustwasm","typescript","umd"],"created_at":"2024-11-14T01:36:29.453Z","updated_at":"2025-08-12T02:03:10.576Z","avatar_url":"https://github.com/w3reality.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# es-pack-js\n\n[![NPM][npm-badge]][npm-url]\n[![MIT licensed][mit-badge]][mit-url]\n[![CI][actions-badge]][actions-url]\n\n[npm-badge]: https://img.shields.io/npm/v/es-pack-js.svg\n[npm-url]: https://www.npmjs.com/package/es-pack-js\n[mit-badge]: https://img.shields.io/badge/license-MIT-blue.svg\n[mit-url]: https://github.com/w3reality/es-pack-js/blob/master/LICENSE\n[actions-badge]: https://github.com/w3reality/es-pack-js/workflows/CI/badge.svg\n[actions-url]: https://github.com/w3reality/es-pack-js/actions\n\nBuild and test portable JavaScript/rustwasm modules\n\n## Getting started\n\nIn this section, we demonstrate how to generate standalone umd/esm modules\nstarting with a minimal NPM project.\n\n### Setting up in a new NPM project\n\n```\n$ mkdir add\n$ cd add\n$ npm init\n\n$ npm config set script-shell bash  # (required if using Windows)\n\n$ npm i -D es-pack-js  # ⬇️\n```\n\n### Invoking the `es-pack` command\n\n```\n$ npx es-pack  # invokes ./node_modules/es-pack-js/bin/es-pack\nes-pack 0.3.5\nusage: es-pack \u003cCommand\u003e [Options]\n\nCommands:\n  es-pack build  Build modules\n  es-pack test   Test modules\n  es-pack help   Show help\n\nOptions:\n  --help, -h  Show help                                                [boolean]\n```\n\n### Building an UMD module\n\n```\n$ mkdir src\n$ echo 'export default function add(x, y) { return x + y; }' \u003e src/index.js\n$ npx es-pack build\nes-pack 0.3.5\n\ntask-bundle: 🌀 spinning...\n6/10/2020, 2:51:00 PM (1115ms) | output path: /Users/foo/add/target\n✨ add.min.js (1276 bytes) [emitted]\ntask-bundle: ✅ done\n```\n\n### Exercising the UMD module with NodeJS\n\n```\n$ node\nWelcome to Node.js v12.16.1.\nType \".help\" for more information.\n\u003e f = require('./target/add.min')\n[Function: r]\n\u003e f(1, 2)\n3\n```\n\n### Building modules with the `-m` option\n\n```\n$ npx es-pack build -m umd esm esm-compat\nes-pack 0.3.5\n\ntask-bundle: 🌀 spinning...\n6/10/2020, 2:57:08 PM (1021ms) | output path: /Users/foo/add/target\n✨ add.min.js (1276 bytes) [emitted]\ntask-bundle: ✅ done\n\ntask-bundle: 🌀 spinning...\n6/10/2020, 2:57:08 PM (278ms) | output path: /Users/foo/add/target\n✨ add.esm.js (1062 bytes) [emitted]\ntask-bundle: ✅ done\n\ntask-bundle: 🌀 spinning...\n6/10/2020, 2:57:08 PM (252ms) | output path: /Users/foo/add/target\n✨ add.esm.compat.js (1419 bytes) [emitted]\ntask-bundle: ✅ done\n```\n\n### More options\n\n```\n$ npx es-pack build -h\nes-pack 0.5.0\nusage: es-pack build [\u003cpath\u003e=.] [Options]\n\nOptions:\n  -h, -h, --help               Show help                               [boolean]\n  -m, --module                 Set output module type (`umd`, `esm`,\n                               `esm-compat`)            [array] [default: \"umd\"]\n      --dev                    Toggle behavior as `webpack --mode development\n                               --watch`               [boolean] [default: false]\n      --dev-with-tts           `--dev` with audio feedback\n                                                      [boolean] [default: false]\n  -d, --out-dir                Set output directory (`\u003cpath\u003e/target`, otherwise)\n      --lib-name               Set output module file name (e.g. \"foo-bar-js\")\n      --libobj-name            Set library object name (e.g. \"FooBarJs\")\n      --bundle-analyzer, --ba  Enable `webpack-bundle-analyzer` plugin\n                                                      [boolean] [default: false]\n      --verify                 Verify basic assumptions against built modules\n                                                      [boolean] [default: false]\n      --rustwasm               Toggle `rustwasm` mode [boolean] [default: false]\n      --debug                  Print debug log and keep intermediate output\n                                                      [boolean] [default: false]\n```\n\n## Windows\n\n### Requirement\n\nBefore installing es-pack-js, it is required to run:\n\n```\n$ npm config set script-shell bash\n```\n\n### Limitations\n\nThe following command invocations do nothing:\n\n* `es-pack build` subcommand with `--verify` option\n* `es-pack test` subcommand\n\n## The `--rustwasm` mode \u003ca name=\"sec-rustwasm\"\u003e\u003c/a\u003e\n\nWe can transform artifacts generated by [wasm-pack](https://github.com/rustwasm/wasm-pack)\ninto a standalone umd/esm module that is loadable via browser/Node.js as follows:\n\n```\n$ wasm-pack build --target no-modules\n$ es-pack build --rustwasm\n```\n\nTo illustrate in detail, we use this minimal Rust crate: [examples/rustwasm-add](https://github.com/w3reality/es-pack-js/tree/master/examples/rustwasm-add)\n\n\u003cp\u003e\u003cdetails\u003e\n\u003csummary\u003ewasm-pack build --target no-modules\u003c/summary\u003e\n\n```\n$ wasm-pack build --target no-modules\n[INFO]: 🎯  Checking for the Wasm target...\n[INFO]: 🌀  Compiling to Wasm...\n   Compiling proc-macro2 v1.0.24\n   Compiling unicode-xid v0.2.1\n   Compiling log v0.4.11\n   Compiling syn v1.0.58\n   Compiling wasm-bindgen-shared v0.2.69\n   Compiling cfg-if v0.1.10\n   Compiling bumpalo v3.4.0\n   Compiling lazy_static v1.4.0\n   Compiling wasm-bindgen v0.2.69\n   Compiling cfg-if v1.0.0\n   Compiling quote v1.0.8\n   Compiling wasm-bindgen-backend v0.2.69\n   Compiling wasm-bindgen-macro-support v0.2.69\n   Compiling wasm-bindgen-macro v0.2.69\n   Compiling add v0.1.0 (/Users/foo/es-pack-js/examples/rustwasm-add)\n    Finished release [optimized] target(s) in 22.59s\n⚠️   [WARN]: origin crate has no README\n[INFO]: ⬇️  Installing wasm-bindgen...\n[INFO]: Optimizing wasm binaries with `wasm-opt`...\n[INFO]: Optional fields missing from Cargo.toml: 'description', 'repository', and 'license'. These are not necessary, but recommended\n[INFO]: ✨   Done in 23.24s\n[INFO]: 📦   Your wasm pkg is ready to publish at /Users/foo/es-pack-js/examples/rustwasm-add/pkg.\n```\n\n\u003c/details\u003e\u003c/p\u003e\n\n\u003cp\u003e\u003cdetails\u003e\n\u003csummary\u003ees-pack build --rustwasm\u003c/summary\u003e\n\n```\n$ es-pack build --rustwasm\nes-pack 0.5.1-dev.0\n\ntask-bundle: 🌀 spinning...\n2/8/2021, 11:38:49 AM (2,948 ms) | output path: /Users/foo/es-pack-js/examples/rustwasm-add/pkg-es-pack\n✨ add.min.js (13,282 bytes) [emitted]\ntask-bundle: ✅ done\n```\n\n\u003c/details\u003e\u003c/p\u003e\n\nLet's exercise the generated 'add.min.js' (an 'umd' module) in Node.js:\n\n```\n$ node\nWelcome to Node.js v14.15.4.\nType \".help\" for more information.\n\u003e Mod = require('./pkg-es-pack/add.min.js')\n[Function: t] { ffi: {} }\n\u003e Mod.create({nodejs: true}).then(mod =\u003e console.log(mod.add(2, 2)))\nPromise { \u003cpending\u003e }\n\u003e 4\n```\n\nSimilarly, like in [this demo project](https://github.com/w3reality/threelet/tree/master/examples/rust-canvas-hello),\nwe can also generate an 'esm' module with:\n\n```\n$ es-pack build --rustwasm -m esm\n```\n\n💡 As a more advanced example using the rustwasm mode, we have [examples/rustwasm-ffi](https://github.com/w3reality/es-pack-js/tree/master/examples/rustwasm-ffi),\nwhere we show how to call JavaScript FFI from within Rust code.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fw3reality%2Fes-pack-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fw3reality%2Fes-pack-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fw3reality%2Fes-pack-js/lists"}