Security News
CISA Brings KEV Data to GitHub
CISA's KEV data is now on GitHub, offering easier access, API integration, commit history tracking, and automated updates for security teams and researchers.
@module-federation/native-federation-typescript
Advanced tools
Bundler agnostic unplugin to share federated types
Bundler agnostic plugins to share federated types.
npm i -D @module-federation/native-federation-typescript
This module provides two plugins:
This plugin is used to build the federated types.
{
moduleFederationConfig: any; // the configuration same configuration provided to the module federation plugin, it is MANDATORY
tsConfigPath?: string; // path where the tsconfig file is located, default is ''./tsconfig.json'
typesFolder?: string; // folder where all the files will be stored, default is '@mf-types',
compiledTypesFolder?: string; // folder where the federated modules types will be stored, default is 'compiled-types'
deleteTypesFolder?: boolean; // indicate if the types folder will be deleted when the job completes, default is 'true'
additionalFilesToCompile?: string[] // The path of each additional file which should be emitted
compilerInstance?: 'tsc' | 'vue-tsc' // The compiler to use to emit files, default is 'tsc'
}
Note that, for Webpack, the plugin automatically inject the devServer.static.directory
configuration.
For the other bundlers, you should configure it by yourself.
This plugin is used to download the federated types.
{
moduleFederationConfig: any; // the configuration same configuration provided to the module federation plugin, it is MANDATORY
typesFolder?: string; // folder where all the files will be stored, default is '@mf-types',
deleteTypesFolder?: boolean; // indicate if the types folder will be deleted before the job starts, default is 'true'
}
// vite.config.ts
import { NativeFederationTypeScriptHost, NativeFederationTypeScriptRemote } from '@module-federation/native-federation-typescript/vite';
export default defineConfig({
plugins: [
NativeFederationTypeScriptRemote({
/* options */
}),
NativeFederationTypeScriptHost({
/* options */
}),
],
/* ... */
server: {
// This is needed to emulate the devServer.static.directory of WebPack and correctly serve the zip file
/* ... */
proxy: {
'/@mf-types.zip': {
target: 'http://localhost:3000',
changeOrigin: true,
rewrite: () => `/@fs/${process.cwd()}/dist/@mf-types.zip`,
},
},
fs: {
/* ... */
allow: ['./dist'],
/* ... */
},
},
});
// rollup.config.js
import { NativeFederationTypeScriptHost, NativeFederationTypeScriptRemote } from '@module-federation/native-federation-typescript/rollup';
export default {
plugins: [
NativeFederationTypeScriptRemote({
/* options */
}),
NativeFederationTypeScriptHost({
/* options */
}),
],
};
// webpack.config.js
const { NativeFederationTypeScriptHost, NativeFederationTypeScriptRemote } = require('@module-federation/native-federation-typescript/webpack');
module.exports = {
/* ... */
plugins: [
NativeFederationTypeScriptRemote({
/* options */
}),
NativeFederationTypeScriptHost({
/* options */
}),
],
};
// esbuild.config.js
import { build } from 'esbuild';
import { NativeFederationTypeScriptHost, NativeFederationTypeScriptRemote } from '@module-federation/native-federation-typescript/esbuild';
build({
plugins: [
NativeFederationTypeScriptRemote({
/* options */
}),
NativeFederationTypeScriptHost({
/* options */
}),
],
});
// rspack.config.js
const { NativeFederationTypeScriptHost, NativeFederationTypeScriptRemote } = require('@module-federation/native-federation-typescript/rspack');
module.exports = {
/* ... */
plugins: [
NativeFederationTypeScriptRemote({
/* options */
}),
NativeFederationTypeScriptHost({
/* options */
}),
],
};
To have the type definitions automatically found for imports, add paths to the compilerOptions
in the tsconfig.json
:
{
"paths": {
"*": ["./@mf-types/*"]
}
}
To use it in a host
module, refer to this example.
To use it in a remote
module, refer to this example.
FAQs
Bundler agnostic unplugin to share federated types
The npm package @module-federation/native-federation-typescript receives a total of 3,921 weekly downloads. As such, @module-federation/native-federation-typescript popularity was classified as popular.
We found that @module-federation/native-federation-typescript demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISA's KEV data is now on GitHub, offering easier access, API integration, commit history tracking, and automated updates for security teams and researchers.
Security News
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.