You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So, I have barrel files in my project, and even setting the webpack sideEffects: false flag, when I import dynamically a component from a barrel file, the module is mixed with another components in the chunks
ex: .../components/index.ts
export { Dolphin } from '@/components/dolphin'
export { Shark } from '@/components/shark'
...
it get mixed in more than one chunk (even if I only use in the home.tsx), and loads when the page load, not on demand (this case a button click), even if it's dynamically imported:
but when I import only dynamically inside my component:
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
So, I have barrel files in my project, and even setting the webpack
sideEffects: false
flag, when I import dynamically a component from a barrel file, the module is mixed with another components in the chunksex: .../components/index.ts
and when I dynamically import in my component:
.../home.tsx
it get mixed in more than one chunk (even if I only use in the home.tsx), and loads when the page load, not on demand (this case a button click), even if it's dynamically imported:
but when I import only dynamically inside my component:
it only stays in one chunk:
and it will import on demand, in this example a button click, the other way was importing when the page load even with dynamic.
So, is it wrong to have a barrel file with only dynamic exports?
ex: ../components/index.ts
../home.tsx
import { Shark } from '@/components'
It worked this way too and kept my code cleaner. Thanks.
Beta Was this translation helpful? Give feedback.
All reactions