portal-vue icon indicating copy to clipboard operation
portal-vue copied to clipboard

vue-common used instead of vue-esm

Open djixadin opened this issue 5 years ago • 1 comments

Hi,

portal-vue v2.1.6 vue 2.6.10 webpack 4.41.0

when i import it i can see in my vendors file that common version is used

// "./node_modules/portal-vue/dist/portal-vue.common.js": /!*******************************************************!
!
./node_modules/portal-vue/dist/portal-vue.common.js ! *****************************************************/ /! no static exports found / // (function(module, exports, webpack_require)

i import it like this like it states here https://portal-vue.linusb.org/guide/installation.html#builds

import PortalVue from 'portal-vue';
Vue.use(PortalVue);

Regards

djixadin avatar Nov 05 '19 16:11 djixadin

Yeah that's unfortunately a weid situation in the current ecosystem that I'm unsure how to resolve:

Webpack prioritizes the "browser" field over the "module" field, for some weird historic reason.

The general recommendation seems to be to have the "main" refer to the commonjs and have no "browser" field, but then where to put the UMD?

Or I drop the commonjs build and provide only UMD and ESM. Would be a breaking change though, I'd think.

For the moment, you could use a webpack alias to make portal-vue load the esm build:

{
  alias: {
    'portal-vue': path.join(path.dirname(require.resolve('portal-vue')), 'portal-vue.esm.js')
  }
}

Othere tools like rollup usually have similar capabilities.

LinusBorg avatar Jun 21 '20 11:06 LinusBorg