I have a webpack config to bundle all the node_modules dependencies mentioned in the package.json file. The following config file generates a library which exposes only the last mentioned in dependency in dependencies list.
const { webpack, ProvidePlugin } = require("webpack");
const { dependencies } = require('./package.json');
const path = require('path');
const provideConfig = {};
Object.keys(dependencies).forEach(dep=>{
provideConfig[dep] = dep;
});
module.exports = {
mode: "development",
target: ['web','es5'],
entry:{
vendor: Object.keys(dependencies) // Create a separate entry for each dependency
},
output:{
filename: 'bundle.js',
path: path.resolve(__dirname, '.'),
library: 'myLibrary',
libraryTarget: 'umd'
},
plugins: [
new ProvidePlugin(providePlugin)
],
devtool: 'source-map'
};
I am expecting this to expose the the dependency as, myLibrary.<dependency_name>
This is only exposing the last dependency in dependencies list of package.json
I am using webpack 5.98