@module-federation/node
Advanced tools
Comparing version 0.2.1 to 0.3.0
{ | ||
"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'; |
"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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
77165
32
939
163
2
1