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

Vite returns 504 Outdated Optimize Dep for non-existing resource #13506

Closed
7 tasks done
alex-kinokon opened this issue Jun 13, 2023 · 4 comments · Fixed by #16080
Closed
7 tasks done

Vite returns 504 Outdated Optimize Dep for non-existing resource #13506

alex-kinokon opened this issue Jun 13, 2023 · 4 comments · Fixed by #16080
Labels
feat: deps optimizer Esbuild Dependencies Optimization p2-nice-to-have Not breaking anything but nice to have (priority)

Comments

@alex-kinokon
Copy link
Contributor

alex-kinokon commented Jun 13, 2023

Describe the bug

Given the following dynamic import within a dependency located on localhost:3000/node_modules/.vite/deps/chunk-HCOQKIU7.js:

// node_modules/@blueprintjs/icons/lib/esnext/iconLoader.js
var defaultIconPathsLoader = async(name,size)=>{
    return (await import(/* webpackInclude: /\.js$/ */
    /* webpackMode: "lazy-once" */
    `./generated/${size}px/paths/${name}`)).default;
}

There are two problems:

  1. The import path does not resolve correctly, because it’s no longer relative to the original module path. Duplicate of Dynamic imports with variables in a dependency are not processed at all #6179.
  2. When vite fails to resolve the path, it returns an erroneous error message (504 Outdated Optimize Dep, please reload the page) instead of 404. The culprit code is here.

Reproduction

https://codesandbox.io/p/sandbox/hopeful-brattain-gz4per

Steps to reproduce

See CodeSandbox link above.

System Info

System:
    OS: Linux 5.15 Debian GNU/Linux 11 (bullseye) 11 (bullseye)
    CPU: (2) x64 AMD EPYC
    Memory: 474.37 MB / 2.01 GB
    Container: Yes
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 18.16.0 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 9.5.1 - /usr/local/bin/npm
  npmPackages:
    @vitejs/plugin-react: ^4.0.0 => 4.0.0 
    vite: ^4.3.9 => 4.3.9

Used Package Manager

yarn

Logs

No response

Validations

@dominikg
Copy link
Contributor

dominikg commented Aug 5, 2023

please provide a proper minimal reproduction as described in our issue template (codesandbox isn't really friendly for cloning or even just anonymous use)

Please provide a link via vite.new or a link to a repo that can reproduce the problem you ran into. npm create vite@latest and npm create vite-extra@latest (for SSR or library repros) can be used as a starter template. A minimal reproduction is required (Why?). If a report is vague (e.g. just a generic error message) and has no reproduction, it will receive a "need reproduction" label. If no reproduction is provided after 3 days, it will be auto-closed.

While at it, please update @blueprintjs/icons to their latest version, i didn't see the dynamic import you quoted in their latest release. The code you quoted isn't present in that from a quick search. Also check their issue tracker and documentation on how you are supposed to use it with vite.

If they really release packages that contain magic webpack import annotations to npm, they should document that this package can only be consumed with webpack.

@dominikg
Copy link
Contributor

dominikg commented Aug 5, 2023

For a vite friendly alternative, check out unplugin-icons, unocss with preset icons or iconify.

@alex-kinokon
Copy link
Contributor Author

For dynamic path problem, there’s already a reprod in the issue I cited, but that is not the main issue here.

This one is about the wrong error message. It gave me 504 outdated dep, so I purged cache and node_modules again and again to no avail. If it just gives me 404 I would know where to dig and isolate the problem. It wouldn’t have worked either way, but at least I would know what the real problem is.

@jackkav
Copy link

jackkav commented Sep 24, 2023

Adding the offending dependency to optimizeDeps.exclude list, seems to work.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feat: deps optimizer Esbuild Dependencies Optimization p2-nice-to-have Not breaking anything but nice to have (priority)
Projects
None yet
4 participants