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.

Broken CSS assets emitted / omitted with wmr build

See original GitHub issue

I’m seeing some very weird behaviour when using wmr build with CSS assets - in some instances the assets are being incorrectly combined, or left out entirely from dist

Test case

index.html

<!DOCTYPE html>
<html lang="en">
<body>
  <script type="module" src="/index.js"></script>
</body>
</html>

index.js

import './a.css';
import './b.css';

a.css and b.css are both completely empty

What appears to matter here is that a.css and b.css have exactly the same source content (the effect is the same if they both contain some actual CSS but their file contents are identical) - see below

Expected

I expect at least one CSS file under dist/assets to be created

Actual

The generated index.[hash].js references /assets/a.[hash].css but no css file is emitted.

Remarks

I’ve seen variants of this where some CSS is emitted but not all of it, and the JS references a missing CSS asset. I’ve not been able to reproduce this reliably without creating a quite complicated dependency graph though. I believe in the project where I’m seeing these errors I may have some duplicated CSS files somewhere.

I suspect this might be happening because rollup is clever and has helpers to deduplicate emitted file names if they have the exact same content - when I enable DEBUG the merging adjacent CSS assets log in optimize-graph-plugin logs assets/a.92dace5d.css, assets/a.92dace5d.css (i.e. the “a” file twice rather than “a” then “b”) - and perhaps WMR isn’t expecting to see multiple of the same file in chunk.referencedFiles

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
jbtcommented, Feb 4, 2021

I guess the empty-files case is a bit extreme and contrived, so perhaps a more concrete example that illustrates the bug, and also the importance of preserving the CSS order:

index.js

import './a.css';
import './b.css';
import './c.css';

a.css

a { text-decoration: underline; }

b.css

a { text-decoration: none; }

c.css

a { text-decoration: underline; }

(i.e. same as a.css)

It’s still a bit contrived, but perhaps the a.css and b.css imports are buried in the dependency tree and you’re importing c.css last to ensure your CSS overrides definitely take precedence

Currently with this input, WMR doesn’t output any CSS at all since it’s accidentally deleting the asset for a.css - which is the one everything’s being combined into.

But it’d also be important not to simply deduplicate toMerge by first occurrence - the contents of c.css need to come last to ensure the correct final value of text-decoration: underline. It might be safe to use the last occurrence of each, but I don’t know if there may be more edge cases I’m missing there

0reactions
JoviDeCroockcommented, Feb 28, 2021

Fixed in #385

Read more comments on GitHub >

github_iconTop Results From Across the Web

link tag to stylesheet in nested folder not working #884 - GitHub
Run npm start; Open the app in a browser ... Instead, the background is white because the stylesheet is not loaded. There are...
Read more >
Bug listing with status RESOLVED with resolution OBSOLETE ...
... Keyboard map broken" status:RESOLVED resolution:OBSOLETE severity:major ... Bug:206180 - "dev-perl/Tk-TableMatrix-1.2.3 fails to build (missing X deps?)
Read more >
DaX - River Thames Conditions
Kennerleigh stores, One missed call theme song composer, Martello tower pembroke dock museum ... Hydrochloric acid breaking bad, Ten-sixty asset management, ...
Read more >
Untitled
Xa 27-l, Nintendo 3ds eshop icon missing, Ten out of tenn christmas download, Dtp app, ... Limace lutte contre, Style unordered list css,...
Read more >
Front-End Performance Checklist 2021 (PDF, Apple Pages ...
An annual front-end performance checklist (available as PDF, Apple Pages, MS Word), with everything you need to know to create fast ...
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