Skip to content

vite failing to optimize some dependencies of direct addons #1583

Description

@void-mAlex

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

Activity

  1. mansona commented on Aug 30, 2023

    @mansona
    Member

    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 😂 )

  2. mansona commented on Sep 8, 2023

    @mansona
    Member

    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 👍

  3. johanrd commented on Nov 11, 2024

    @johanrd
    Contributor

    @mansona @void-mAlex I also struggle with this: direct non-ember npm packages (often, and unreliably) don't end up in node_modules/.vite/deps, and result in the Outdated Optimize Dep console error:

    http://localhost:4200/node_modules/.vite/deps/sanitize-html.js?v=26940a7a net::ERR_ABORTED 504 (Outdated Optimize Dep)
    

    Now, with optimizeDeps(), how is it meant that normal npm packages should be accessed in a reliable way? Any good workarounds for now?

    Thanks!

  4. mansona commented on Nov 12, 2024

    @mansona
    Member

    @johanrd I think we're past the point that things "often and unreliably" don't end up in vite deps with the current main/unstable version of vite support. I replied to that other issue that you opened and it's nothing to do with embroider, it's an issue with vite and postcss (again I'm not sure why client side code is trying to optimise postcss 🙈)

  5. johanrd commented on Dec 17, 2025

    @johanrd
    Contributor

    @void-mAlex I was able to close #2168 with vite@8beta.

    Perhaps this issue can be closed as well? (perhaps even with standard vite + @embroider/vite)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions