Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@module-federation/node

Package Overview
Dependencies
Maintainers
4
Versions
712
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@module-federation/node - npm Package Compare versions

Comparing version 0.2.1 to 0.3.0

src/utils/hot-reload.d.ts

13

package.json
{
"public": true,
"name": "@module-federation/node",
"version": "0.2.1",
"version": "0.3.0",
"type": "commonjs",
"main": "src/index.js",
"exports": {
".": {
"import": "./src/index.js",
"require": "./src/index.js"
},
"./package.json": "./package.json",
"./utils": {
"import": "./src/utils/index.js",
"require": "./src/utils/index.js"
}
},
"types": "src/index.d.ts",

@@ -8,0 +19,0 @@ "description": "Module Federation helper for Node",

@@ -1,2 +0,4 @@

![banner image](./assets/banner.png)
<p align="center">
<img src="https://github.com/module-federation/nextjs-mf/blob/main/packages/node/assets/banner.png" width="800"/>
</p>
<div align="center">

@@ -104,2 +106,49 @@ <!-- for version -->

```
## Utilities
This package also exposes a few utilities to help with the setup of your federated application.
### revalidate
Used to "hot reload" the federated application.
- This is useful when you're developing your federated application and want to see changes without having to restart the server.
- Also useful for production environments where you want to be able to update the federated application without having to restart the server.
```js
import {revalidate} from "@module-federation/node/utils";
// we automatically reset require cache, so the reload callback is only if you need to do something else
revalidate().then((shouldReload) => {
// do something extra after revalidation
if(shouldReload) {
// reload the server
}
});
```
**Hot reloading Express.js**
Express has its own route stack, so reloading require cache will not be enough to reload the routes inside express.
```js
//express.js
const app = express();
global.clearRoutes = () => {
app._router.stack = app._router.stack.filter(
k => !(k && k.route && k.route.path)
)
}
// in some other file (within the scope of webpack build)
// wherever you have your revalidation logic
revalidate().then((shouldReload) => {
if(shouldReload) {
global.clearRoutes();
}
});
```
## 🔑 License

@@ -114,1 +163,2 @@ - MIT @[ScriptedAlchemy](https://github.com/ScriptedAlchemy)

</a>
export { default as StreamingTargetPlugin } from './plugins/StreamingTargetPlugin';
export { default as NodeFederationPlugin } from './plugins/NodeFederationPlugin';
export { default as UniversalFederationPlugin } from './plugins/UniversalFederationPlugin';
export * from './utils/hot-reload';

11

src/index.js
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.UniversalFederationPlugin = exports.NodeFederationPlugin = exports.StreamingTargetPlugin = void 0;
const tslib_1 = require("tslib");
var StreamingTargetPlugin_1 = require("./plugins/StreamingTargetPlugin");
Object.defineProperty(exports, "StreamingTargetPlugin", { enumerable: true, get: function () { return __importDefault(StreamingTargetPlugin_1).default; } });
Object.defineProperty(exports, "StreamingTargetPlugin", { enumerable: true, get: function () { return tslib_1.__importDefault(StreamingTargetPlugin_1).default; } });
var NodeFederationPlugin_1 = require("./plugins/NodeFederationPlugin");
Object.defineProperty(exports, "NodeFederationPlugin", { enumerable: true, get: function () { return __importDefault(NodeFederationPlugin_1).default; } });
Object.defineProperty(exports, "NodeFederationPlugin", { enumerable: true, get: function () { return tslib_1.__importDefault(NodeFederationPlugin_1).default; } });
var UniversalFederationPlugin_1 = require("./plugins/UniversalFederationPlugin");
Object.defineProperty(exports, "UniversalFederationPlugin", { enumerable: true, get: function () { return __importDefault(UniversalFederationPlugin_1).default; } });
Object.defineProperty(exports, "UniversalFederationPlugin", { enumerable: true, get: function () { return tslib_1.__importDefault(UniversalFederationPlugin_1).default; } });
tslib_1.__exportStar(require("./utils/hot-reload"), exports);
//# sourceMappingURL=index.js.map

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc