{"id":21855366,"url":"https://github.com/wix-incubator/import-path","last_synced_at":"2025-04-14T18:10:03.113Z","repository":{"id":46809520,"uuid":"111475416","full_name":"wix-incubator/import-path","owner":"wix-incubator","description":"Improve the import path for your package","archived":false,"fork":false,"pushed_at":"2023-03-13T08:53:27.000Z","size":27,"stargazers_count":6,"open_issues_count":2,"forks_count":3,"subscribers_count":217,"default_branch":"master","last_synced_at":"2025-04-14T18:09:57.703Z","etag":null,"topics":["cli","export","import","javascript","node","path","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/wix-incubator.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":"2017-11-20T23:48:25.000Z","updated_at":"2023-03-13T08:53:32.000Z","dependencies_parsed_at":"2024-06-19T00:03:40.242Z","dependency_job_id":"6121c85e-f09d-45cc-9a4c-58aa64115502","html_url":"https://github.com/wix-incubator/import-path","commit_stats":{"total_commits":40,"total_committers":9,"mean_commits":4.444444444444445,"dds":0.55,"last_synced_commit":"7ae601e48b051bee26de0269d4964879e8e8e8b0"},"previous_names":["wix/import-path"],"tags_count":70,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wix-incubator%2Fimport-path","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wix-incubator%2Fimport-path/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wix-incubator%2Fimport-path/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wix-incubator%2Fimport-path/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wix-incubator","download_url":"https://codeload.github.com/wix-incubator/import-path/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248933340,"owners_count":21185460,"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":["cli","export","import","javascript","node","path","require"],"created_at":"2024-11-28T02:14:49.158Z","updated_at":"2025-04-14T18:10:03.069Z","avatar_url":"https://github.com/wix-incubator.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# import-path\n\n## Intro\nThis package helps creating a nicer API for your require paths.\n\nIf for example your `dist` folder is being published in your packge, usually users will try to require it by using the full path:\n\n```javascript\nimport {importantFunction} from 'my-package/dist/src/importantFunction';\n```\n\nThis is where this package comes in to play, as it allows you to have:\n\n```javascript\nimport {importantFunction} from 'my-package/importantFunction';\n```\n\n## Usage\n\nInstall the package\n\n```\nnpm i --save-dev import-path\n```\n\nAdd the following to your build command in the `package.json`:\n\n```javasript\n \"scripts\": {\n    \"build\": \"haste build \u0026\u0026 import-path --path \u003cdesired-path\u003e\",\n    ...\n```\nNote that [haste](https://github.com/wix/haste) is the build tool which is being used in this example, but ofcourse it is not mandatory.\n\n`\u003cdesiredPath\u003e` is the path you wish to change the require from. For example:\n\n```\nimport-path --path src/importantFunction\n```\n\nWill allow users to do:\n```javascript\nimport {importantFunction} from 'my-package/importantFunction';\n```\n\nIf you wish your require path (entry point) name format to be pascal cased, like seen here :\n\n```javascript\nimport {importantFunction} from 'my-package/dist/src/ImportantFunction';\n```\n\npass to the importPath function, a third aregumes : `{componentNameFormat: true}` (defaulted as false).\n\n\nTypescript definitions can also be generated using the `--dts` option:\n\n```javasript\n import-path --path \u003cdesired-path\u003e --dts\",\n```\n\nor, you can choose to  pass as a second boolean argument to the importPath function\n\n```javasript\n importPath('src/components', true);\n```\n\nThis will create a `.d.ts` for every generated `.js` file.\nNote that the .d.ts files only support named exports and do not support `export default...` and `exports = ...`.\n\nOn every build we scan for all the files under 'my-package/dist/src/importantFunction' which contain `index.js` file inside of them, and for each file we create the following file under the root dir:\n\n```js\n// importantFunction.js\n\nmodule.exports = require('./dist/src/importantFunction');\n```\n\nThere is no need to push them to Github, so add this to the `.gitignore` file:\n\n```\n/*.js\n/*.d.ts // if you use the dts option\n!wallaby.js\n!protractor.conf.js\n```\n\nIf you have more `*.js` files under the root dir that you don't want to ignore, add them with prefix `!`.\n\nThe last thing you need to do is to publish all of the new generated files:\n\n```javascript\n// package.json\n\n\"files\": [\n    \"dist\",\n    \"*.js\",\n    '*.d.ts', // if you use the dts option\n    \"!wallaby.js\",\n    \"!protractor.conf.js\"\n  ],\n```\n\nYou can use `npm pack` to see what are you going to publish to the npm registry.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwix-incubator%2Fimport-path","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwix-incubator%2Fimport-path","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwix-incubator%2Fimport-path/lists"}