eight04 / rollup-plugin-iife

Convert ES modules into IIFEs.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Work with output.globals option

loliconer opened this issue · comments

import Vue from 'vue'

new Vue({
}).$mount('#app')

In the bundle file, Vue is compiled to vue.

commented

Have you specified the variable name in your configuration?

Yes, this is my config:

export default {
  input: [
    'src/main.js'
  ],
  output: {
    format: 'es',
    dir: 'public/js',
    globals: {
      vue: 'Vue'
    }
  },
  external: ['vue'],
  plugins: [
    iife()
  ],
  experimentalCodeSplitting: true
}

And the compiled content:

(function () {



new vue({
}).$mount('#app');
})();
commented

iife plugin doesn't use output.globals, it has its own variable name map:

export default {
  input: [
    'src/main.js'
  ],
  output: {
    format: 'es',
    dir: 'public/js'
  },
  external: ['vue'],
  plugins: [
    iife({
      names: {
        vue: 'Vue'
      }
    })
  ],
  experimentalCodeSplitting: true
}

I guess we should support output.globals as well.

Thanks.

Yes, it will be better to support output.globals. Otherwise I have to config this option twice.