{"id":16057747,"url":"https://github.com/aduth/esm-root-loader","last_synced_at":"2025-03-17T21:31:11.861Z","repository":{"id":49576675,"uuid":"223843352","full_name":"aduth/esm-root-loader","owner":"aduth","description":"ESM loader to import from the project root","archived":false,"fork":false,"pushed_at":"2023-07-25T00:48:49.000Z","size":249,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-13T22:35:06.392Z","etag":null,"topics":["esm","esmodules"],"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/aduth.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","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":"2019-11-25T02:08:28.000Z","updated_at":"2023-03-24T17:29:36.000Z","dependencies_parsed_at":"2024-10-27T16:16:50.366Z","dependency_job_id":"a690593d-0e35-4481-bf4a-f8881e519d9d","html_url":"https://github.com/aduth/esm-root-loader","commit_stats":{"total_commits":26,"total_committers":2,"mean_commits":13.0,"dds":"0.11538461538461542","last_synced_commit":"4ed0f1adc2bbe63ab4a3ac99269c3f0113e3ecb0"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aduth%2Fesm-root-loader","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aduth%2Fesm-root-loader/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aduth%2Fesm-root-loader/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aduth%2Fesm-root-loader/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aduth","download_url":"https://codeload.github.com/aduth/esm-root-loader/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243885934,"owners_count":20363644,"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":["esm","esmodules"],"created_at":"2024-10-09T03:04:30.262Z","updated_at":"2025-03-17T21:31:11.631Z","avatar_url":"https://github.com/aduth.png","language":"JavaScript","readme":"# ESM Root Loader\n\n**ESM Root Loader** is a custom resolver implementation for the [experimental loader hooks](https://nodejs.org/dist/latest-v12.x/docs/api/esm.html#esm_experimental_loader_hooks) feature of Node.js ECMAScript modules.\n\nUsing this loader will enhance the default loader behavior to allow you to import from the root of your project, even if the import occurs from a file located in a subdirectory:\n\n```js\nimport config from '/config.js';\n```\n\nBy default, the above code snippet will resolve a `config.js` file from the root of your project.\n\nThis can be especially useful in projects which run both in the browser and in Node.js, since browser imports on the root path can be leveraged to resolve from the root of a domain.\n\n## Installation\n\nInstall as a dependency using `npm`:\n\n```\nnpm install esm-root-loader\n```\n\n## Usage\n\nLoaders can be defined as an argument when running `node`.\n\n```\nnode --experimental-loader=esm-root-loader entry.js\n```\n\n## Configuration\n\nDefault usage will resolve imports from the root of your project.\n\nIf needed, you can assign a custom root path using an `esmRoot` property in your project's `package.json`. This will be evaluated as relative to the root path of the project.\n\n```json\n{\n\t\"esmRoot\": \"./public\"\n}\n```\n\nYou can also customize or omit the prefix for resolving specifiers from the root.\n\nFor example, to import without the leading slash, you can set `esmRootPrefix` to `false` in your project's `package.json`.\n\n```js\nimport config from 'config.js';\n```\n\n```json\n{\n\t\"esmRootPrefix\": false\n}\n```\n\nYou can also customize the prefix by assigning any string value to this property.\n\n```js\nimport config from '~config.js';\n```\n\n```json\n{\n\t\"esmRootPrefix\": \"~\"\n}\n```\n\nThese options are also configurable by environment variables `ESM_ROOT` and `ESM_ROOT_PREFIX`.\n\n## Versioning\n\nThis project follows [SemVer](https://semver.org/).\n\nTo better align with the experimental status of the loader hooks, initial releases will follow major version zero until the feature stabilizes in Node.js. Minor versions on the zero major will always include breaking changes. Patch versions on the zero major will include bug fixes and backwards-compatible changes.\n\nVersioning will proceed from 1.0.0 once the feature stabilizes in Node.js.\n\n## License\n\nCopyright (c) 2022 Andrew Duthie\n\nReleased under the MIT License. See [LICENSE.md](./LICENSE.md).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faduth%2Fesm-root-loader","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faduth%2Fesm-root-loader","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faduth%2Fesm-root-loader/lists"}