{"id":23773450,"url":"https://github.com/beenotung/fix-esm-import-path","last_synced_at":"2025-04-15T10:34:11.897Z","repository":{"id":56713572,"uuid":"388202599","full_name":"beenotung/fix-esm-import-path","owner":"beenotung","description":"Auto fix import path for esm compatibility","archived":false,"fork":false,"pushed_at":"2024-09-25T02:33:14.000Z","size":69,"stargazers_count":54,"open_issues_count":5,"forks_count":6,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-15T10:11:50.120Z","etag":null,"topics":["auto-fix","cli","esm","import-path","module"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/fix-esm-import-path","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/beenotung.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":"2021-07-21T17:55:22.000Z","updated_at":"2025-04-04T20:29:51.000Z","dependencies_parsed_at":"2023-12-06T13:38:58.009Z","dependency_job_id":"e7d4afd8-b1d9-46e1-b700-6d27afda0442","html_url":"https://github.com/beenotung/fix-esm-import-path","commit_stats":{"total_commits":21,"total_committers":1,"mean_commits":21.0,"dds":0.0,"last_synced_commit":"aa831df0a0e7561d863e371a4bcf39e84ecf58dd"},"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beenotung%2Ffix-esm-import-path","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beenotung%2Ffix-esm-import-path/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beenotung%2Ffix-esm-import-path/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beenotung%2Ffix-esm-import-path/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/beenotung","download_url":"https://codeload.github.com/beenotung/fix-esm-import-path/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249048740,"owners_count":21204306,"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":["auto-fix","cli","esm","import-path","module"],"created_at":"2025-01-01T05:40:14.840Z","updated_at":"2025-04-15T10:34:11.869Z","avatar_url":"https://github.com/beenotung.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# fix-esm-import-path\n\nAuto fix import path for esm compatibility.\n\n[![npm Package Version](https://img.shields.io/npm/v/fix-esm-import-path.svg?maxAge=2592000)](https://www.npmjs.com/package/fix-esm-import-path)\n\nThis cli tool modifies specified Typescript / Javascript files recursively. It appends `.js` extension on the import / export statements of relative module path.\n\n## Installation\n\n```bash\n## for global cli\nnpm install --global fix-esm-import-path\n\n## for npm script\nnpm install -D fix-esm-import-path\n```\n\n## Usage\n\n```bash\nfix-esm-import-path [options] \u003cfile-or-directory\u003e\n```\n\n### Options\n\n`--process-import-type`: To add `.js` extension in the import path of `import type` statements when needed.\n\n`--preserve-import-type`: To preserve the import path of `import type` statements as is.\n\nDefault mode is `--process-import-type`.\n\n\u003cdetails\u003e\n\u003csummary\u003e(Click to expand the reason)\u003c/summary\u003e\n\nIn previous version, `fix-esm-import-path` does not modify the import path of `import type` statements because they are supposed to be removed in the javascript output.\n\nHowever, [under some settings](https://github.com/beenotung/fix-esm-import-path/issues/5), import path with extension is required for `import type` statements as well. So now `fix-esm-import-path` now modifies the import path of `import type` statements as well.\n\nIf your setup does not require fixing the import path for `import type` statements and you want to minimize git changes, you can use the `--preserve-import-type` flag to leave them as is.\n\n\u003c/details\u003e\n\n### Usage Example\n\nExample on shell:\n\n```bash\nnpx fix-esm-import-path dist/server/index.js\n```\n\nExample on npm script (in `package.json`):\n\n```json\n{\n  \"type\": \"module\",\n  \"scripts\": {\n    \"build\": \"run-s tsc fix\",\n    \"test\": \"run-s build js\",\n    \"tsc\": \"tsc -p .\",\n    \"fix\": \"fix-esm-import-path dist/test.js\",\n    \"js\": \"node dist/test\"\n  },\n  \"devDependencies\": {\n    \"fix-esm-import-path\": \"^1.0.1\",\n    \"npm-run-all\": \"^4.1.5\",\n    \"ts-node\": \"^10.1.0\",\n    \"typescript\": \"^4.3.5\"\n  }\n}\n```\n\nDetails refer to [example](./example)\n\n## Related discussions\n\n- [Appending .js extension on relative import statements during Typescript compilation (ES6 modules)](https://stackoverflow.com/questions/62619058/appending-js-extension-on-relative-import-statements-during-typescript-compilat)\n- [Provide a way to add the '.js' file extension to the end of module specifiers](https://github.com/microsoft/TypeScript/issues/16577)\n- [[FEATURE] absolute-\u003erelative module path transformation](https://github.com/microsoft/TypeScript/issues/15479)\n- [Support TypeScript import type when targeting ESNext with NodeNext module](https://github.com/beenotung/fix-esm-import-path/issues/5)\n\n## License\n\nThis is free and open-source software (FOSS) with\n[BSD-2-Clause License](./LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbeenotung%2Ffix-esm-import-path","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbeenotung%2Ffix-esm-import-path","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbeenotung%2Ffix-esm-import-path/lists"}