{"id":17911189,"url":"https://github.com/jhmaster2000/typings-esm-loader","last_synced_at":"2026-03-15T16:02:57.051Z","repository":{"id":57407476,"uuid":"479839709","full_name":"jhmaster2000/typings-esm-loader","owner":"jhmaster2000","description":"Typings for Node.js custom ESM loaders","archived":false,"fork":false,"pushed_at":"2022-10-04T12:21:18.000Z","size":21,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-09-14T22:29:41.831Z","etag":null,"topics":["esm","loaders","nodejs","typings"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/typings-esm-loader","language":null,"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/jhmaster2000.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":"2022-04-09T20:45:36.000Z","updated_at":"2023-08-13T17:58:50.000Z","dependencies_parsed_at":"2023-01-19T05:15:22.381Z","dependency_job_id":null,"html_url":"https://github.com/jhmaster2000/typings-esm-loader","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jhmaster2000%2Ftypings-esm-loader","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jhmaster2000%2Ftypings-esm-loader/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jhmaster2000%2Ftypings-esm-loader/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jhmaster2000%2Ftypings-esm-loader/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jhmaster2000","download_url":"https://codeload.github.com/jhmaster2000/typings-esm-loader/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221919917,"owners_count":16901866,"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","loaders","nodejs","typings"],"created_at":"2024-10-28T19:37:13.638Z","updated_at":"2025-10-27T23:07:03.107Z","avatar_url":"https://github.com/jhmaster2000.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# ESM Loader Typings\n\u003e Type definitions for Node.js custom ESM loaders\n\n[![license][license-image]][license-url]\n[![GitHub version][github-image]][github-url]\n[![npm release][npm-image]][npm-url]\n[![node-current][node-image]][node-url]\n\nNode.js custom ESM loaders need to be in JS as they're passed directly to Node.js on startup, but that doesn't mean we can't have types on them.\n\n## Install\n```sh\nnpm i -D typings-esm-loader\n```\n\n## Usage\nAt the top of your loader's JS file:\n```js\n/// @ts-check\n/// \u003creference types=\"typings-esm-loader\" /\u003e\n```\nThe `/// @ts-check` line is not needed for TS files and optional for JS files, it can be removed if you only want type hints with no strict type checking on JS.\n\n### Using JavaScript\nYou can now use **JSDoc** comments to typecast your hooks to their respective types as such:\n```js\n/** @type {resolve} */\nexport async function resolve(specifier, context, nextResolve) { ... }\n\n/** @type {load} */\nexport async function load(url, context, nextLoad) { ... }\n\n/** @type {globalPreload} */\nexport function globalPreload(context) { ... }\n```\n\n### Using TypeScript\n```ts\nexport async function resolve(...[specifier, context, nextResolve]: Parameters\u003cresolve\u003e): ReturnType\u003cresolve\u003e { ... }\n\nexport async function load(...[url, context, nextLoad]: Parameters\u003cload\u003e): ReturnType\u003cload\u003e { ... }\n\nexport function globalPreload(...[context]: Parameters\u003cglobalPreload\u003e): ReturnType\u003cglobalPreload\u003e { ... }\n```\n\n#### Other types provided\n- `Loader`: an `interface` representing an ESM loader when imported as a module, useful when using multiple loaders.\n- `ModuleFormat`: a union type representing all valid module formats to pass to the `load` hooks return value `format` field.\n- `getBuiltin`: a type declaration for the function of same name provided in the global scope of `globalPreload` hooks scripts.\n- ***namespace*** `Resolve`\n  - `Context`: the `interface` representing the import context object passed to `resolve` hooks.\n  - `Return`: the `interface` representing the required return type of `resolve` hooks.\n  - `Function`: the type of the `nextResolve` parameter.\n- ***namespace*** `Load`\n  - `Context`: the `interface` representing the import context object passed to `load` hooks.\n  - `Return`: the `interface` representing the required return type of `load` hooks.\n  - `Function`: the type of the `nextLoad` parameter.\n\n[github-url]:https://github.com/jhmaster2000/typings-esm-loader\n[github-image]:https://img.shields.io/github/package-json/v/jhmaster2000/typings-esm-loader.svg\n[license-url]:https://github.com/jhmaster2000/typings-esm-loader/blob/master/LICENSE\n[license-image]:https://img.shields.io/npm/l/typings-esm-loader.svg\n[npm-url]:http://npmjs.org/package/typings-esm-loader\n[npm-image]:https://img.shields.io/npm/v/typings-esm-loader.svg?color=darkred\u0026label=npm%20release\n[node-url]:https://nodejs.org/en/download\n[node-image]:https://img.shields.io/node/v/typings-esm-loader.svg\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjhmaster2000%2Ftypings-esm-loader","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjhmaster2000%2Ftypings-esm-loader","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjhmaster2000%2Ftypings-esm-loader/lists"}