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

Asset name conflicts are possible in manifest.json, causing unexpected / missing asset loading #1632

Closed
3 tasks done
gryphonmyers opened this issue Jan 22, 2021 · 1 comment

Comments

@gryphonmyers
Copy link

⚠️ IMPORTANT ⚠️ Please check the following list before proceeding. If you ignore this issue template, your issue will be directly closed.

  • Read the docs.
  • Use Vite >=2.0. (1.x is no longer supported)
  • If the issue is related to 1.x -> 2.0 upgrade, read the Migration Guide first.

Describe the bug

It seems that if you have an entrypoint that shares a base name with one of your asset chunks, the manifest file that ultimately gets written will suffer from loss preventing you from doing a successful backend integration.

In my repro note the following:

  • I have changed the entrypoint to src/main.js in the vite config
  • main.vue is a dynamic import so will get its own css asset chunk
  • Building the site, you will see it generates two css files with basename of main (one for the entrypoint, one for the dynamic chunk).
  • Note that the manifest file only has a single "main.css" record. It is ambiguous which one it refers to, but from my experience it actually ends up referring to the dynamic chunk, meaning that a record of the entrypoint styles are lost.

Reproduction

https://github.com/gryphonmyers/vite-minimal-repro/tree/manifest-name-conflict

System Info

  • vite version: 2.0.0-beta.35
  • Operating System: macos 10.15.7
  • Node version: 14.15.1
  • Package manager (npm/yarn/pnpm) and version: npm 6.14.8
@yyx990803
Copy link
Member

With cf81aa3 it now generates something like this:

{
  "main.js": {
    "isEntry": true,
    "isDynamicEntry": false,
    "file": "assets/main.a4557f7e.js",
    "imports": [],
    "dynamicImports": [
      "assets/main.333f1426.js"
    ],
    "facadeModuleId": "src/main.js"
  },
  "main-1.js": {
    "isEntry": false,
    "isDynamicEntry": true,
    "file": "assets/main.333f1426.js",
    "imports": [
      "assets/main.a4557f7e.js"
    ],
    "dynamicImports": [],
    "facadeModuleId": "src/components/main.vue"
  },
  "main.css": {
    "file": "assets/main.6f5e5b3c.css"
  },
  "main-1.css": {
    "file": "assets/main.2a664265.css"
  }
}

Not ideal but it preserves backwards compat. We may consider a better manifest format in the future but that might be a breaking change.

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

No branches or pull requests

2 participants