embroider-build / embroider

Compiling Ember apps into spec-compliant, modern Javascript.
MIT License
335 stars 136 forks source link

vite failing to optimize some dependencies of direct addons #1583

Open void-mAlex opened 1 year ago

void-mAlex commented 1 year ago

tried to see how far I can get with running vite in our app and I ran into a few instances that required me to specify in vite.config

optimizeDeps: {
  include: ['ember-intl > fast-memoize', 'miragejs > lodash.assign'] 
}

in order to have vite server actual ESM to the browser when the respective modules are requested.

this may be related to those addons being in rewritten-packages thus under a level of /mode_modules/ thus somehow hidden from the normal pre-bundling

mansona commented 1 year ago

This was caused by the fact that we are excluding the addons from optimizeDeps in this line https://github.com/embroider-build/embroider/blob/main/tests/vite-app/vite.config.mts#L26-L28

We need to not do that, and was there to workaround something (not exactly sure what 😂 )

mansona commented 1 year ago

Just to update on this: our current thinking is that we shouldn't ignore all addons, but instead just @embroider/macros

you can update your viteconfig to express this but we ultimately plan to provide a function from embroider that provides the whole optimizeDeps object so that we can include or exclude dependencies we would need to over time 👍