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

Preload fails in library mode #3662

Closed
6 tasks done
modderme123 opened this issue Jun 3, 2021 · 1 comment
Closed
6 tasks done

Preload fails in library mode #3662

modderme123 opened this issue Jun 3, 2021 · 1 comment

Comments

@modderme123
Copy link
Contributor

Describe the bug

When in library mode, Vite should disable the preload-helper for dynamic imports. What currently happens is that vite compiles imports that have preloads to

__vitePreload(() => import("./index3.js"), ["/index3.js","/_commonjsHelpers.js","/preload-helper.js"])

However, this is a problem when using a library in app mode which moves the files in the final output. This ends up creating errors because index3.js was renamed to index3.[hash].js, and only the import string was changed:

__vitePreload(() => import('/node_modules/.vite/index3-QK47J4CQ.js?v=2fd9b5df'),"/index3.js", "/_commonjsHelpers.js", "/preload-helper.js"])

So Chrome logs this

preload-helper.js:27 GET http://localhost:3000/index3.js net::ERR_ABORTED 404 (Not Found)

An ideal fix would be to disable preload altogether in library mode such as #3133.

Reproduction

A complicated reproduction is here: https://github.com/solidjs/solid-playground

System Info

Output of npx envinfo --system --npmPackages vite,@vitejs/plugin-vue --binaries --browsers:

  System:
    OS: macOS 10.15.7
    Shell: 3.2.2 - /usr/local/bin/fish
  Binaries:
    Node: 16.2.0 - /usr/local/bin/node
    Yarn: 1.22.10 - /usr/local/bin/yarn
    npm: 7.15.1 - /usr/local/bin/npm
  Browsers:
    Chrome: 91.0.4472.77
    Safari: 14.1.1
  npmPackages:
    vite: ^2.3.6 => 2.3.6 

Used package manager:


Before submitting the issue, please make sure you do the following

  • Read the Contributing Guidelines.
  • Read the docs.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Provide a description in this issue that describes the bug.
  • Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to https://github.com/vuejs/vue-next instead.
  • Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
@patak-dev
Copy link
Member

Closed by #4097

@github-actions github-actions bot locked and limited conversation to collaborators Aug 3, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants