{"id":15757863,"url":"https://github.com/zkochan/self-import","last_synced_at":"2026-04-27T23:33:10.440Z","repository":{"id":65493847,"uuid":"80295868","full_name":"zkochan/self-import","owner":"zkochan","description":"Allows requiring of own modules like dependency modules","archived":false,"fork":false,"pushed_at":"2017-01-28T18:02:00.000Z","size":18,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-11-12T22:24:52.983Z","etag":null,"topics":["import","node","nodejs","require"],"latest_commit_sha":null,"homepage":null,"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/zkochan.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":"2017-01-28T16:39:41.000Z","updated_at":"2020-09-30T12:19:37.000Z","dependencies_parsed_at":"2023-01-25T21:15:15.855Z","dependency_job_id":null,"html_url":"https://github.com/zkochan/self-import","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/zkochan/self-import","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zkochan%2Fself-import","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zkochan%2Fself-import/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zkochan%2Fself-import/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zkochan%2Fself-import/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zkochan","download_url":"https://codeload.github.com/zkochan/self-import/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zkochan%2Fself-import/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32360110,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-27T20:07:02.737Z","status":"ssl_error","status_checked_at":"2026-04-27T20:07:00.910Z","response_time":128,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["import","node","nodejs","require"],"created_at":"2024-10-04T09:40:40.573Z","updated_at":"2026-04-27T23:33:10.412Z","avatar_url":"https://github.com/zkochan.png","language":"JavaScript","readme":"# self-import\n\n\u003e Allows requiring of own modules like dependency modules\n\n[![npm version](https://img.shields.io/npm/v/self-import.svg?style=flat-square)](https://www.npmjs.com/package/self-import) [![Build Status](https://img.shields.io/travis/zkochan/self-import/master.svg?style=flat-square)](https://travis-ci.org/zkochan/self-import)\n\nAccess your modules via `require('foo')` instead of long relative paths like `require('../../..')`. Inspired by [require-self](https://github.com/yortus/require-self).\n\n## Background\n\nUsually packages include tests and examples in their repos. This code needs to require the module itself.\n\nBut whereas modules depending on `foo` can write `require('foo')`, the test and example code within `foo`\ncannot reliably require itself that way. It must use a relative path like `var foo = require('../..')` instead.\n\nBeing able to do `require('foo')` instead of `require('..')` has a few advantages. The code can be moved around.\nExample code is a tad clearer and can be reused in a client module without changes. And if you are authoring in\nTypeScript, then `import foo = require('foo')` picks up all the static type info from `foo.d.ts`, exactly as\na client module would see it.\n\n## Installation\n\n```\nnpm i -D self-import\n```\n\n## Usage\n\nCall `self-import` in your package's prepublish script.\n\n```json5\n{\n  // ...\n  \"scripts\": {\n    \"prepublish\": \"self-import\"\n  },\n  \"devDependencies\": {\n    // ...\n    \"self-import\": \"*\"\n  }\n}\n```\n\n## Programmatic usage\n\n```js\nconst selfImport = require('self-import')\n\nselfImport('/home/src/foo').then(() =\u003e console.log('Done!'))\n```\n\n## License\n\n[MIT](LICENSE) © [Zoltan Kochan](http://kochan.io)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzkochan%2Fself-import","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzkochan%2Fself-import","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzkochan%2Fself-import/lists"}