Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Require() of ES Module ... error when importing Doughnut chart #100

Closed
1 of 4 tasks
jclaessens97 opened this issue Feb 16, 2022 · 5 comments
Closed
1 of 4 tasks

Require() of ES Module ... error when importing Doughnut chart #100

jclaessens97 opened this issue Feb 16, 2022 · 5 comments
Labels
bug Something isn't working

Comments

@jclaessens97
Copy link

Describe the bug

I'm trying to use a Dougnut chart in Nuxt Bridge, so I'm following the examples from Nuxt 2 + SSR + composition-api (without importing composition-api since it should be in Nuxt Bridge already(?).

However as soon as I import DoughnutChart from vue-chart-3 I'm getting hit with a require() of ES Module ... error from lodash-es which is a dependency of @vue/composition-api. I thought it would have something to do with Nuxt Bridge, but as soon as I started building the repro sandbox, it gave the same thing, so I guess there is something else to it?

To Reproduce

repro

Version of vue-chart-3

Tried both v2.0.3 and v3.1.0

Version of Vue

  • Vue 3
  • Vue 2
  • Nuxt 2 (Nuxt Bridge)
  • Nuxt 3
@victorgarciaesgi
Copy link
Owner

For Nuxt bridge, try v2.1.2 instead, I will look at it because I have only tested on Nuxt 2 and Nuxt 3 but not Nuxt bridge yet

@victorgarciaesgi victorgarciaesgi added the bug Something isn't working label Feb 16, 2022
@jclaessens97
Copy link
Author

@victorgarciaesgi , I checked with 2.1.2 but also gave the same result.

@mirkopoloni
Copy link

mirkopoloni commented Feb 16, 2022

Hey @jclaessens97, adding these lines to the nuxt.config and restarting the sandbox server should solve the problem:

build: {
    // Transpile ESM modules because Nuxt 2 uses CommonJS for building server.
    transpile: ["vue-chart-3", "lodash-es"]
  }

Some extra infos here: https://v3.nuxtjs.org/concepts/esm/

@jclaessens97
Copy link
Author

Thanks @mirkopoloni ! Missed that part of the nuxt docs completely 😄

@victorgarciaesgi
Copy link
Owner

Thanks @mirkopoloni I forgot about this Nuxt option. I will add it to the docs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants