admin管理员组文章数量:1387454
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
本文标签:
版权声明:本文标题:javascript - Webpack not exposing all the package.json dependencies in the generated library ( browser code ) - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744525830a2610740.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论