question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

missing css in client manifest legacy chunks

See original GitHub issue

Describe the bug

When I generate a client manifest with @vitejs/plugin-legacy plugin enabled, legacy chunks are missing css entries.

Example:

{
  "index-legacy.html": {
    "file": "assets/index-legacy.1b2bcd2a.js",
    "src": "index-legacy.html",
    "isEntry": true
  },
  "vite/legacy-polyfills-legacy": {
    "file": "assets/polyfills-legacy.907dbd91.js",
    "src": "vite/legacy-polyfills-legacy",
    "isEntry": true
  },
  "index.html": {
    "file": "assets/index.9f336c05.js",
    "src": "index.html",
    "isEntry": true,
    "css": [
      "assets/index.824f0ed3.css"
    ]
  },
  "index.css": {
    "file": "assets/index.824f0ed3.css",
    "src": "index.css"
  }
}

In the example above, index.html includes a css dependency, but the respective index-legacy.html does not.

This is affecting third party libraries which rely on the manifest to inject the respective<link rel="stylesheet"> into HTML head. For example: https://github.com/nuxt/bridge/issues/561.

Reproduction

https://stackblitz.com/edit/vitejs-vite-mjitx2?file=dist/manifest.json

Steps to reproduce

Run npm install followed by npm run build. Examine dist/manifest.json.

System Info

System:
    OS: Linux 5.0 undefined
    CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: 1.0 - /bin/jsh
  Binaries:
    Node: 16.14.2 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 7.17.0 - /usr/local/bin/npm
  npmPackages:
    @vitejs/plugin-legacy: ~2.3.0 => 2.3.0 
    vite: ~3.2.1 => 3.2.2

Used Package Manager

npm

Logs

No response

Validations

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
IlyaSemenovcommented, Nov 8, 2022

Right, pinning vite to 3.2.3 makes nuxt-bridge work, however the result is unsatisfactory. Inlining CSS in a SSR build leads to the flash of unstyled content (FOUC). The server delivers pre-rendered HTML but the styles only appear after the entire set of scripts loads and starts. Legacy clients with no javascript (e.g. web crawlers) don’t get any styles at all.

I am not sure how to proceed here from the triage point of view. On the one hand, vite 3.2 works “as expected”. On the other hand, the current “expected” behaviour is not friendly to the downstream SSR tooling that operates with legacy chunks.

0reactions
sapphi-redcommented, Nov 8, 2022

I think we can close this issue because avoiding inlining CSS in legacy is tracked in #2062.

Read more comments on GitHub >

github_iconTop Results From Across the Web

manifest.json does not include assets · Issue #2375 · vitejs/vite
Statically imported assets (SVG file in my case) will get bundled and created in the outDir , but are missing in the generated...
Read more >
Micro Frontend Architecture: Import chunks from another ...
Challenge 4: Missing Dependency Resolution. What happens if a chunk is interleaved into an app which doesn't have one of the dependencies the...
Read more >
Code Splitting - webpack
Prevent Duplication: Use Entry dependencies or SplitChunksPlugin to dedupe and split chunks. Dynamic Imports: Split code via inline function calls within ...
Read more >
Server-Side Rendering - Vite
The manifest contains mappings of module IDs to their associated chunks and asset files. To leverage the manifest, frameworks need to provide a...
Read more >
From O(4G) to (Offline) - Lessons learned from performance
The tool is useful for optimizing code and abstracting source code into smaller pieces of code (chunks). To build global stylesheets, webpack wasn't...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found