WebpackRemoteTypesPlugin
raw JSON → 0.2.7 verified Sat Apr 25 auth: no javascript
Webpack plugin (v0.2.7) that downloads TypeScript type definition tarballs generated by dts-loader from remote locations (e.g., a remote Module Federation entry). It integrates with webpack's build process to fetch type definitions files at build time and unzips them into a local directory. Key differentiator: enables type checking for remote modules in a Micro-Frontend setup where type definitions are served alongside remoteEntry.js. Release cadence is irregular; currently stable but low activity.
Common errors
error Error: Cannot find module 'webpack-remote-types-plugin' ↓
cause Package not installed or incorrect import path.
fix
Run 'npm install webpack-remote-types-plugin --save-dev' or add it to devDependencies.
error TypeError: WebpackRemoteTypesPlugin is not a constructor ↓
cause Using default export incorrectly in CommonJS environment.
fix
Use 'const WebpackRemoteTypesPlugin = require('webpack-remote-types-plugin').default;'
error Error: ENOENT: no such file or directory, stat 'types/app-dts.tgz' ↓
cause Remote server not returning the tarball or URL mismatch.
fix
Check that the remote URL is accessible and that 'remoteFileName' matches the actual tarball filename on the server.
Warnings
deprecated The 'remoteFileName' option may be automatically derived in future versions. ↓
fix Always specify 'remoteFileName' explicitly to avoid breaking changes.
breaking In version 0.2.x, the plugin no longer supports the legacy 'filename' option; use 'remoteFileName' instead. ↓
fix Replace 'filename' with 'remoteFileName' in your configuration.
gotcha The tarball URL is constructed by replacing '[name]' in 'remoteFileName' with the remote name. Ensure your server serves the file at that exact path. ↓
fix Verify the URL pattern: e.g., if remote is 'app' and remoteFileName is '[name]-dts.tgz', the full URL becomes http://localhost:9000/app-dts.tgz (base URL taken from the remoteEntry URL).
Install
npm install webpack-remote-types-plugin yarn add webpack-remote-types-plugin pnpm add webpack-remote-types-plugin Imports
- WebpackRemoteTypesPlugin wrong
const WebpackRemoteTypesPlugin = require('webpack-remote-types-plugin')correctimport WebpackRemoteTypesPlugin from 'webpack-remote-types-plugin' - WebpackRemoteTypesPlugin wrong
const WebpackRemoteTypesPlugin = require('webpack-remote-types-plugin');correctconst WebpackRemoteTypesPlugin = require('webpack-remote-types-plugin').default; - WebpackRemoteTypesPluginOptions wrong
type WebpackRemoteTypesPluginOptions = { remotes: object; outputDir: string; remoteFileName: string; }correctimport type { WebpackRemoteTypesPluginOptions } from 'webpack-remote-types-plugin'
Quickstart
// webpack.config.js
const WebpackRemoteTypesPlugin = require('webpack-remote-types-plugin').default;
module.exports = {
plugins: [
new WebpackRemoteTypesPlugin({
remotes: {
app: 'app@http://localhost:9000/remoteEntry.js',
},
outputDir: 'types',
remoteFileName: '[name]-dts.tgz',
}),
],
};