I have MFE and want to use webpack externals. When I use just Vue and Vuex all works great.
Example:
Webpack:
{
....
externals: {
vue: 'Vue',
'vue-router': 'VueRouter',
vuex: 'Vuex'
},
....
plugins: [
new CopyWebpackPlugin(...), // Just copy files like (vue.min.js, etc) from node_modules to assets folder.
]
}
I have a library that was written a long time ago for Vue2 and I can't do it 'external'. For this library, I have commonjs module and umd.
enter image description here enter image description here
I tried to use commonjs module and append library that exported with module.exports and also umd. Set libraryTarget to 'umd' nothing works.
My attempts:
{
externals: {
vue: 'Vue',
'vue-router': 'VueRouter',
vuex: 'Vuex',
'ui-essentials': 'UIEssentials'
},
externals: {
vue: 'Vue',
'vue-router': 'VueRouter',
vuex: 'Vuex',
'ui-essentials': {
commonjs: 'UIEssentials',
commonjs2: 'UIEssentials',
amd: 'UIEssentials',
}
},
externals: {
vue: 'Vue',
'vue-router': 'VueRouter',
vuex: 'Vuex',
'ui-essentials': {
root: ['ui-essentials', 'UIEssentials']
}
},
}
I have tried a lot of stuff but the result is the same. For example when I use commonjs I receive error 'module is not found'. When I use just 'ui-essentials': 'UIEssentials' I receive an error that UIEssentials is not found, etc.
But inside of window['ui-essentials'] there is UIEssentials object, but it should be available in window.UIEssentials like this as I understand correctly.
In app.js file, I try to call import the library like import { UIEssentials } from 'ui-essentials';
Without 'externals' the library works well but I need to use externals because I should share a library between MFE.