A plugin that auto-externalizes dependencies that are available in an import map.
npm i -D import-map-externals-webpack-plugin
# or
pnpm i -D import-map-externals-webpack-plugin
# or
yarn add --dev import-map-externals-webpack-plugin
// webpack.config.js
const { ImportMapExternalsPlugin } = require('import-map-externals-webpack-plugin');
module.exports = {
plugins: [
new ImportMapExternalsPlugin({
importMapUrl: "https://react.microfrontends.app/importmap.json"
});
]
}
The following options can be passed to the ImportMapExternalsPlugin constructor:
importMapUrl
: a fully qualified, fetchable URL that contains valid import map json