Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

98
Views
Externals webpack scripts with Vue plugins

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.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!