{"id":16625472,"url":"https://github.com/aleclarson/module-extractor","last_synced_at":"2025-07-10T01:38:14.765Z","repository":{"id":55073553,"uuid":"487204070","full_name":"aleclarson/module-extractor","owner":"aleclarson","description":"Extract a JS/TS module and its dependencies into a new package","archived":false,"fork":false,"pushed_at":"2022-05-19T15:12:28.000Z","size":64,"stargazers_count":14,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-02T06:08:32.008Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aleclarson.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}},"created_at":"2022-04-30T06:46:43.000Z","updated_at":"2024-03-04T13:20:40.000Z","dependencies_parsed_at":"2022-08-14T11:10:36.378Z","dependency_job_id":null,"html_url":"https://github.com/aleclarson/module-extractor","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aleclarson%2Fmodule-extractor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aleclarson%2Fmodule-extractor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aleclarson%2Fmodule-extractor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aleclarson%2Fmodule-extractor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aleclarson","download_url":"https://codeload.github.com/aleclarson/module-extractor/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":233200419,"owners_count":18640370,"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":[],"created_at":"2024-10-12T04:05:49.006Z","updated_at":"2025-01-09T14:11:21.445Z","avatar_url":"https://github.com/aleclarson.png","language":"TypeScript","funding_links":["https://paypal.me/alecdotbiz"],"categories":[],"sub_categories":[],"readme":"# module-extractor\n\n[![npm](https://img.shields.io/npm/v/module-extractor.svg)](https://www.npmjs.com/package/module-extractor)\n[![Code style: Prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://github.com/prettier/prettier)\n[![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://paypal.me/alecdotbiz)\n\n\u003e Extract a module and its dependencies into a new package\n\n\u0026nbsp;\n\n### Usage\n\n```ts\nimport { extractModules } from 'module-extractor'\n\nconst extraction = extractModules({\n  // At least one entry module must be given\n  entries: ['index.ts'],\n  // The directory that contains package.json and source files\n  pkgRoot: '/path/to/package',\n  // Where to write the extracted modules and package.json\n  outPkgRoot: './extracted',\n})\n\n// Called as the module graph is crawled\nextraction.on('moduleAdded', module =\u003e {...})\n\n// Called when an import statement points to an unknown file\nextraction.on('moduleNotFound', (id, importer) =\u003e {...})\n\n// Called after each tree-shaked module is written\nextraction.on('moduleWritten', (filename, code, module) =\u003e {...})\n\n// Called after the new package.json is written\nextraction.on('packageCreated', (pkgJson) =\u003e {...})\n\n// Called when the extraction is complete\nextraction.then(() =\u003e {...})\n```\n\n\u0026nbsp;\n\n### Quirks\n\n- Namespace imports prevent tree-shaking\n  ```ts\n  // All exports of \"./foo\" will be kept, even if only some are needed.\n  import * as foo from './foo'\n  ```\n\n- Top-level side effects with unused return values are not preserved\n  ```ts\n  // × Not preserved in module copy!\n  console.log('test')\n  ```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faleclarson%2Fmodule-extractor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faleclarson%2Fmodule-extractor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faleclarson%2Fmodule-extractor/lists"}