{"id":24206272,"url":"https://github.com/telenko/node-mf","last_synced_at":"2025-09-22T04:33:29.388Z","repository":{"id":38834037,"uuid":"376564779","full_name":"telenko/node-mf","owner":"telenko","description":null,"archived":false,"fork":false,"pushed_at":"2022-08-10T15:14:47.000Z","size":32,"stargazers_count":57,"open_issues_count":11,"forks_count":6,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-08-08T23:02:09.415Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/telenko.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}},"created_at":"2021-06-13T14:32:21.000Z","updated_at":"2024-04-27T00:03:05.000Z","dependencies_parsed_at":"2022-07-18T01:30:49.469Z","dependency_job_id":null,"html_url":"https://github.com/telenko/node-mf","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/telenko/node-mf","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/telenko%2Fnode-mf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/telenko%2Fnode-mf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/telenko%2Fnode-mf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/telenko%2Fnode-mf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/telenko","download_url":"https://codeload.github.com/telenko/node-mf/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/telenko%2Fnode-mf/sbom","scorecard":{"id":873177,"data":{"date":"2025-08-11","repo":{"name":"github.com/telenko/node-mf","commit":"4e1ea948a421e6aea863c273e78a795c030d3db6"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.9,"checks":[{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Code-Review","score":2,"reason":"Found 2/8 approved changesets -- score normalized to 2","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"License","score":0,"reason":"license file not detected","details":["Warn: project does not have a license file"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 6 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-24T04:56:05.870Z","repository_id":38834037,"created_at":"2025-08-24T04:56:05.870Z","updated_at":"2025-08-24T04:56:05.870Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":276347148,"owners_count":25626597,"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","status":"online","status_checked_at":"2025-09-22T02:00:08.972Z","response_time":79,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":[],"created_at":"2025-01-14T00:19:55.029Z","updated_at":"2025-09-22T04:33:29.115Z","avatar_url":"https://github.com/telenko.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# About\nLibrary is a set of webpack plugins which gives support of Module Federation into NodeJS.\n\nUsage example with NextJS https://github.com/telenko/node-mf-example\n\nHere is also my [article](https://mangolik931.medium.com/how-i-implemented-module-federation-in-nodejs-and-did-something-wrong-724642c26da5) about this library.\n\n# Purpose of creating\nRelease of [Webpack Module Federation](https://webpack.js.org/concepts/module-federation/) really have made a shift in modern architecture of web applications. But what about NodeJS and such frameworks like [Next](https://nextjs.org/)? What about SSR? I see for now a gap in webpack, so pure ModuleFederation plugin can not be used inside NodeJS environment. Muliple examples of NextJS+MF here https://github.com/module-federation/module-federation-examples with NextJS using only client-side rendering or not using remote deployed build at all.\n\n# What can I propose\nI have implemented 2 plugins for webpack:\n1) **NodeAsyncHttpRuntime** - Plugin which should be used on a remote side to build remote scripts for NodeJS. But the main key of plugin is resolution of modules - it is done via http requests, so NodeJS can dynamically resolve child modules, load them and perform.\n2) **NodeModuleFederation** - Plugin is wrapper around origin WebpackModuleFederation plugin and adds NodeJS specific resolution of remote modules (same thing: resolution is done via http requests)\n\n# Getting started\n### 1) On remote library:\n\n  1.1) Install package (remote can be either pure JS application or NodeJS application - doesn't matter)\n    ```\n    npm i --save-dev @telenko/node-mf\n    ```\n\n  1.2. Customize webpack configuration, so it should now build 2 targets: for web (if you want legacy browser build) and for node (webpack for now doesn't support universal targets)\n\n  1.3) For node build add **NodeAsyncHttpRuntime** plugin and set webpack's 'target' flag to false\n\n```js\n    //pseudocode\n    module.exports = [\n        {\n            target: \"web\",\n            ...webOptionsWebpack\n        },\n        {\n            target: false,\n            plugins: [\n                new NodeAsyncHttpRuntime() //this is instead of target to make it work\n            ],\n            ...nodeOptionsWebpack\n        }\n    ];\n```\n\n  1.4) Serve both builds\n\nFull example is here https://github.com/telenko/node-mf-example/blob/master/remoteLib/webpack.config.js\n\n### 2) On NodeJS application:\n\n  2.1) Install library\n    ```\n    npm i --save-dev @telenko/node-mf\n    ```\n\n  2.2) Add **NodeModuleFederation** plugin to the webpack config (api parameters schema is same)\n  **!Note, remote script url should point to 'node' build (which should be built with NodeAsyncHttpRuntime)**\n\n  ```js\n    module.exports = {\n        plugins: [\n            new NodeModuleFederation({\n                remotes: {\n                    someLib: \"someLib@http://some-url/remoteEntry.node.js\"\n                },\n                shared: {\n                    lodash: {\n                        eager: true,\n                        singleton: true,\n                        requiredVersion: \"1.1.2\"\n                    }\n                }\n            })\n        ],\n        ...otherWebpackOptions\n    };\n  ```\n\n### Usage with Next.js\n\nAs Next.js use an internal version of webpack, it's mandatory to use their version. To do so, use the second argument of the 2 plugins to send the \"context\" of the [webpack options](https://nextjs.org/docs/api-reference/next.config.js/custom-webpack-config).\n\n```js\n// next.config.js\nmodule.exports = {\n    webpack: (config, options) =\u003e {\n        config.plugins.push(\n            new NodeAsyncHttpRuntime({}, options)\n        );\n        return config\n    },\n}\n```\n```js\n// next.config.js\nmodule.exports = {\n    webpack: (config, options) =\u003e {\n        config.plugins.push(\n            new NodeModuleFederation({\n                remotes: {\n                    someLib: \"someLib@http://some-url/remoteEntry.node.js\"\n                },\n                shared: {\n                    lodash: {\n                        eager: true,\n                        singleton: true,\n                        requiredVersion: \"1.1.2\"\n                    }\n                }\n            }, options)\n        );\n        return config\n    },\n}\n```\n\nFull example of setuping NextJS with SSR here https://github.com/telenko/node-mf-example/blob/master/host/next.config.js\n\n### Usage with runtime uris\n\nIf you do not know the real uri during the build step, you can use a promise which will be executed at runtime.\n\nHere is an example based on [telenko/node-mf-example](https://github.com/telenko/node-mf-example) to have an url according to the dev or CDN host. On the CDN, the assets are stored in a path according to the remote app name. The environment variable `CDN_URL` is only known on the production server so we set an alternative for the development env.\n\n```js\n// host\nmodule.exports = {\n    webpack: (config, options) =\u003e {\n        // [...]\n        if (isServer) {\n            // Set the public path of the remote as auto\n            mfConf.remotes.remoteLib = \"remoteLib@auto\";\n            // Parse the remote uri and return a promise template string with the runtime data\n            mfConf.getRemoteUri = function (remoteUri) {\n                const remoteName = remoteUri.split(\"@\")[0];\n                return `new Promise(r =\u003e {\n                    const uri = \"${process.env.CDN_URL ? `${process.env.CDN_URL}/${remoteName}` : 'http://localhost:3002'}\";\n                    r(\"${remoteName}@${uri}/node/remoteEntry.js\");\n                })`\n            }\n        }\n        // [...]\n    }\n};\n```\n\n```js\n// remoteLib\nconst getConfig = (target) =\u003e ({\n    plugins: [\n        ...(target === \"web\"\n            ? [\n                new HtmlWebpackPlugin({\n                    template: \"./public/index.html\"\n                })\n            ]\n            : [\n                new NodeAsyncHttpRuntime({\n                    getBaseUri = function () {\n                        // Return a promise template string with the runtime data\n                        return `new Promise(r =\u003e {\n                            const uri = \"${process.env.CDN_URL ? `${process.env.CDN_URL}/remoteLib` :  'http://localhost:3002'}\";\n                            r(\"${uri}/${target}/\");\n                        })`\n                    }\n                })\n            ]\n        )\n    ]\n});\n```\n\n# Risks\n## Aren't 2 build makes build-time 2 times longer?\nYes, if we speak about NextJS and SSR - we need both builds: for web and for node, and we have to start entire build separately without sharing built chunks. That will increase build time 2 times.\n## Security\nSince NodeJS out of the box doesn't support remote scripts execution (like in browser we can add **script** tag) it looks like a hack calling http request then 'eval'-ing it. I'm not sure if it is safe to add remote script execution on server side, but it is the only one possible way to make it on server.\n\n# Roadmap\n1) https support\n2) Next.js support for NodeAsyncHttpRuntime plugin","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftelenko%2Fnode-mf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftelenko%2Fnode-mf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftelenko%2Fnode-mf/lists"}