{"id":20114613,"url":"https://github.com/alienzhou/nodejs-module-loader-examples","last_synced_at":"2026-05-15T11:36:33.101Z","repository":{"id":107435980,"uuid":"432671668","full_name":"alienzhou/nodejs-module-loader-examples","owner":"alienzhou","description":"some basic examples for module loaders supported in nodejs 17","archived":false,"fork":false,"pushed_at":"2021-11-28T09:48:16.000Z","size":8,"stargazers_count":2,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-11-04T12:18:42.670Z","etag":null,"topics":["esmodule","example","loader","nodejs"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alienzhou.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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-11-28T09:40:34.000Z","updated_at":"2023-10-16T04:13:26.000Z","dependencies_parsed_at":"2023-06-26T02:11:13.077Z","dependency_job_id":null,"html_url":"https://github.com/alienzhou/nodejs-module-loader-examples","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/alienzhou/nodejs-module-loader-examples","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alienzhou%2Fnodejs-module-loader-examples","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alienzhou%2Fnodejs-module-loader-examples/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alienzhou%2Fnodejs-module-loader-examples/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alienzhou%2Fnodejs-module-loader-examples/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alienzhou","download_url":"https://codeload.github.com/alienzhou/nodejs-module-loader-examples/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alienzhou%2Fnodejs-module-loader-examples/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33065719,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-15T11:35:32.926Z","status":"ssl_error","status_checked_at":"2026-05-15T11:35:31.362Z","response_time":103,"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":["esmodule","example","loader","nodejs"],"created_at":"2024-11-13T18:30:50.890Z","updated_at":"2026-05-15T11:36:33.086Z","avatar_url":"https://github.com/alienzhou.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Examples for Module Loader Hooks\n\nNode.js v17 added a new **Experimental Feature**: [Module Loaders](https://nodejs.org/docs/latest-v17.x/api/esm.html#loaders)(Hooks).\n\nThis feature enables you to customize the default module resolution and content loading. So you can `import` a raw file, remote module (via http/https) (like deno) etc.\n\nHere's some basic examples:\n\n- Loading a txt file and wrapping its content into an ES Module\n- Patch an NPM package (like [require-in-middle](https://www.npmjs.com/package/require-in-the-middle))\n- Loading an ES Module from a remote [ESM Delivery](https://www.skypack.dev/)\n- Loading a sass file and compiling it to a css\n- …\n\nSomething like\n\n```js\nimport './a.txt';\nimport repeat from 'repeat-string';\nimport _ from 'https://cdn.skypack.dev/lodash';\nimport css from './b.scss';\n```\n\n## Requirements\n\n- Node.js \u003e= 17 (Current v17.1.0)\n- Using ES Module\n\n## Getting Started\n\nThis feature needs the `--experimental-loader` flag with a specific loader.\n\n```shell\nnode --experimental-loader ./lib/index.mjs main.mjs\n```\n\nOutput:\n```text\n[load txt] file content in a.txt: I'm a txt file.\n\n[load npm module] repeat A for 5 times: been patched!!!\n\n[load remote module] lodash.last for [1, 2, 3, 4]: 4\n\n[load scss] css for scss: body {\n  font: 100% Helvetica, sans-serif;\n  color: #333;\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falienzhou%2Fnodejs-module-loader-examples","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falienzhou%2Fnodejs-module-loader-examples","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falienzhou%2Fnodejs-module-loader-examples/lists"}