oruga icon indicating copy to clipboard operation
oruga copied to clipboard

[Nuxt Bridge] Tree shaking not working

Open Tragio opened this issue 3 years ago • 13 comments

Overview of the problem

Oruga version: 0.5.3 Vuejs version: Nuxt - 2.16.0-27358576.777a4b7f OS/Browser: MacOS 11

Description

Making use of tree shaking of Oruga does not work. Importing one component makes all modules in the build bundle.

Screenshot_2022-02-11_at_08 06 54

Steps to reproduce

Minimal reproduction: https://github.com/Tragio/oruga-tree-shaking-bug

The client bundle will bundle right and show the webpack analyzer, however, the server bundle will fail due to nuxt/bridge#128 but it's not related to this issue and should not interfere with its resolution.

Thank you for the amazing work 😃

Tragio avatar Feb 15 '22 10:02 Tragio

Workaround for now (we'll need to investigate in Nuxt what the root cause is here):

import { defineNuxtConfig } from '@nuxt/bridge'

export default defineNuxtConfig({
  bridge: {
    resolve: false,
  }
})

danielroe avatar Feb 15 '22 11:02 danielroe

Workaround for now (we'll need to investigate in Nuxt what the root cause is here):

import { defineNuxtConfig } from '@nuxt/bridge'

export default defineNuxtConfig({
  bridge: {
    resolve: false,
  }
})

Thank you for your quick reply!! Doing that workaround works but when I try to access it I get a 500 error, at least on Vercel and using my project.

Screenshot 2022-02-15 at 12 03 37

Tragio avatar Feb 15 '22 12:02 Tragio

That's an unrelated issue. See https://v3.nuxtjs.org/concepts/esm.

Edit: Forgive my too hasty assumption; are you saying this occurs only when you set resolve: false?

danielroe avatar Feb 15 '22 12:02 danielroe

That's an unrelated issue. See https://v3.nuxtjs.org/concepts/esm.

Edit: Forgive my too hasty assumption; are you saying this occurs only when you set resolve: false?

Yes, that's correct. This issue only happens when I use that workaround 🙃

Tragio avatar Feb 15 '22 13:02 Tragio

@Tragio we might fix it using the same approach of https://github.com/oruga-ui/oruga/pull/273

jtommy avatar Feb 15 '22 18:02 jtommy

@Tragio we've just released 0.5.4, please check it

jtommy avatar Feb 21 '22 22:02 jtommy

@jtommy thank you. I updated and also deleted .nuxt, .output, node_modules, and yarn.lock. Did a yarn install, and then a build. All is the same 🤔

Tragio avatar Feb 22 '22 09:02 Tragio

Do you see the new file index.mjs into dist/esm ?

jtommy avatar Feb 22 '22 09:02 jtommy

Do you see the new file index.mjs into dist/esm ?

Yes, I have it here. Screenshot 2022-02-22 at 09 56 20

Tragio avatar Feb 22 '22 09:02 Tragio

What's the error right now?

jtommy avatar Feb 22 '22 10:02 jtommy

What's the error right now?

Tree shaking keeps not working.

Screenshot 2022-02-22 at 10 04 18

Tragio avatar Feb 22 '22 10:02 Tragio

The fix should resolve the problem using the workaround. I think that @danielroe is investigating about tree shaking

jtommy avatar Feb 22 '22 10:02 jtommy

@Tragio any news?

jtommy avatar Aug 08 '22 20:08 jtommy