vueuse / vue-demi

🎩 Creates Universal Library for Vue 2 & 3
MIT License
2.98k stars 155 forks source link

Vue.utils.warn break build process. #214

Closed Fnxxxxo closed 1 year ago

Fnxxxxo commented 1 year ago

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 ?

sonicoder86 commented 1 year ago

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

brunomperes commented 1 year ago

I think this is related to it using a .mjs extension https://github.com/webpack/webpack/issues/16000#issuecomment-1169821843 and one fix is basically what is applied for .cjs here

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

antfu commented 1 year ago

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

AMontagu commented 1 year ago

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.