{"id":22010491,"url":"https://github.com/virtualstate/impack","last_synced_at":"2026-04-20T03:03:02.565Z","repository":{"id":60493986,"uuid":"543549274","full_name":"virtualstate/impack","owner":"virtualstate","description":null,"archived":false,"fork":false,"pushed_at":"2024-09-11T23:57:09.000Z","size":61,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-01-05T01:57:43.902Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/virtualstate.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":"CODE-OF-CONDUCT.md","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":"2022-09-30T10:35:49.000Z","updated_at":"2024-09-11T23:57:12.000Z","dependencies_parsed_at":"2024-01-22T12:24:55.805Z","dependency_job_id":null,"html_url":"https://github.com/virtualstate/impack","commit_stats":{"total_commits":28,"total_committers":1,"mean_commits":28.0,"dds":0.0,"last_synced_commit":"e40b6944ce3820b744744b8228f671f663b06f7e"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/virtualstate/impack","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/virtualstate%2Fimpack","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/virtualstate%2Fimpack/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/virtualstate%2Fimpack/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/virtualstate%2Fimpack/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/virtualstate","download_url":"https://codeload.github.com/virtualstate/impack/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/virtualstate%2Fimpack/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32031070,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-20T00:18:06.643Z","status":"online","status_checked_at":"2026-04-20T02:00:06.527Z","response_time":94,"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":"2024-11-30T02:13:19.564Z","updated_at":"2026-04-20T03:03:02.529Z","avatar_url":"https://github.com/virtualstate.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `@virtualstate/impack`\n\nESM Tree Importer\n\n[//]: # (badges)\n\n### Support\n\n ![Node.js supported](https://img.shields.io/badge/node-%3E%3D18.7.0-blue)\n\n[//]: # (badges)\n\n# Usage\n\nThe below command will re-write all import \u0026 export urls so that they are \nfully resolved.\n\n```shell\nnpx @virtualstate/impack esnext\n```\n\nThis command will take\n\n```javascript\nimport { run } from \"./path/to\";\n```\n\nIf `./path/to` exists, the import is kept as is\n\nIf `./path/to.js` exists, the import will be re-written as:\n\n```javascript\nimport { run } from \"./path/to.js\";\n```\n\nIf `./path/to/index.js` exists, the import will be re-written as:\n\n```javascript\nimport { run } from \"./path/to/index.js\";\n```\n\n## [Import maps](https://github.com/WICG/import-maps)\n\nThe below command will output an import map with all files in the folder \u0026 dependencies\n\n```shell\n# \nnpx @virtualstate/impack import-map.json esnext\n```\n\nFor example giving the import map of:\n\n```json\n{\n  \"imports\": {\n    \"@virtualstate/promise\": \"./node_modules/@virtualstate/promise/esnext/index.js\"\n  }\n}\n```\n\nAlong with re-writing all import urls, you will get the output:\n\n```json\n{\n  \"imports\": {\n    \"@virtualstate/promise\": \"esnext/@virtualstate/promise/esnext/index.js\",\n    \"esnext/path/to/inner.js\": \"esnext/path/to/inner.js\",\n    \"esnext/path/to/index.js\": \"esnext/path/to/index.js\"\n  }\n}\n```\n\nThe below command will output an import map with only the dependent files of this entrypoint file\n\n```shell\n# \nnpx @virtualstate/impack import-map.json esnext/tests/index.js\n```\n\nAny dependency urls that are not provided in the initial import map, are not replaced. \n\n## [Node subpath patterns](https://nodejs.org/api/packages.html#subpath-imports)\n\nIf you were to have an import that used a node subpath pattern, starting with \n`#`, if a replacement is not found in the provided import map, the closest \npackage.json with a matching pattern will be used. \n\nFor example if your `package.json` \n\n```json\n{\n  \"imports\": {\n    \"#internal/*.js\": \"./src/internal/*.js\"\n  }\n}\n```\n\nAnd used the import: \n\n```javascript\nimport Users from \"#internal/users\";\nimport Storage from \"#internal/storage\";\n```\n\nYou would get the output:\n\n```json\n{\n  \"imports\": {\n    \"src/index.js\": \"src/index.js\",\n    \"src/internal/users.js\": \"src/internal/users.js\",\n    \"src/internal/storage.js\": \"src/internal/storage.js\"\n  }\n}\n```\n\n## [Cap'n Proto](https://capnproto.org/)\n\nThe below command will output modules ready to use in a capnp file\n\n```shell\nnpx @virtualstate/impack import-map.json esnext --capnp\n```\n\nFor Example:\n\n```capnp\nmodules = [\n  (name = \"esnext/@virtualstate/promise/esnext/index.js\", esModule = embed \"esnext/@virtualstate/promise/esnext/index.js\"),\n  (name = \"esnext/path/to/inner.js\", esModule = embed \"esnext/path/to/inner.js\"),\n  (name = \"esnext/path/to/index.js\", esModule = embed \"esnext/path/to/index.js\")\n]\n```\n\n```shell\n# Will replace the modules of workers in a capnp template file\nnpx @virtualstate/impack import-map.json esnext --capnp=workerd-template.capnp\n```\n\nFor example the below template:\n\n```capnp\nconst test :Workerd.Worker = (\n   modules = [],\n   compatibilityDate = \"2022-09-16\",\n);\n```\n\nWill output as:\n\n```capnp\nconst test :Workerd.Worker = (\n   modules = [\n      (name = \"esnext/@virtualstate/promise/esnext/index.js\", esModule = embed \"esnext/@virtualstate/promise/esnext/index.js\"),\n      (name = \"esnext/path/to/inner.js\", esModule = embed \"esnext/path/to/inner.js\"),\n      (name = \"esnext/path/to/index.js\", esModule = embed \"esnext/path/to/index.js\")\n   ],\n   compatibilityDate = \"2022-09-16\",\n);\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvirtualstate%2Fimpack","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvirtualstate%2Fimpack","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvirtualstate%2Fimpack/lists"}