vueuse/vue-demi

Vue.utils.warn break build process.

Fnxxxxo opened this issue · 4 comments

I build a component repo with vue.2.7 and vue-demi.0.13.11. The dist artifact is wired with a NPE.
lQLPJxBSESCyRRxozQUZsK_10SXmQKrdA-fd554A-QA_1305_104
It crushes the building process in my vue.3.0 project. Maybe an issue caused by #192 ?

Coming from vuelidate, the newest version crashes with the above error when using Vue 3 without compatibility mode.

I think this is related to it using a .mjs extension webpack/webpack#16000 (comment) and one fix is basically what is applied for .cjs here

Related PR https://github.com/vueuse/vue-demi/pull/219/files

antfu commented

We temporarily close this due to the lack of enough information.
Please provide a minimal reproduction to reopen the issue.
Thanks.

Why reproduction is required

Hello @antfu

Sorry to not provide a minimal repository as I am not sur you will want to look further about this behavior.

This exception happen to me when using Webpack Module federation (https://webpack.js.org/concepts/module-federation/) in a micro frontend POC.

To avoid the issue:

Shared module is not available for eager consumption: webpack/sharing/consume/default/vue-router/vue-router

I defined the main.js in a bootstrap.js file and in main.js using: import("./bootstrap"); See: https://webpack.js.org/concepts/module-federation/#uncaught-error-shared-module-is-not-available-for-eager-consumption

In vue.config.js I declared:

plugins: [
      new ModuleFederationPlugin({
        name: "app-center",
        shared: {
          ...deps,
          vue: {
            eager: true,
            singleton: true,
          },
        },
      }),
    ],

It worked fine with vue 2.6 and vue-demi 0.6.2 but not working with vue 2.7 and vue-demi 0.13.11.

Look like as the import is async the vue demi load is loaded before vue is instancied and Vue.util is undefined.

If you are willing to look into it I may produce a minimal reproduction but as this is an edge case maybe it's not in your priorities to handle this kind of issues.