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.

Granular chunks load CSS as JS

See original GitHub issue

Bug report

Describe the bug

After enabling granular chunks, CSS is loaded as JS in the body.

In the head, there’s

<link rel="stylesheet" href="https://static.real.dev/web/_next/static/css/6519939e08f60c2b0fdda52a767add1b5303a0f3.8812c13c.chunk.css">

In the body there is

<script src="/_next/static/css/6519939e08f60c2b0fdda52a767add1b5303a0f3.8812c13c.chunk.css"></script>

And note the assetPrefix isn’t being prepending to the body tag.

To Reproduce

Unfortunately, I have to revert the change on my prod to stop error. Hopefully this can be easily re-produced, it seems like a pretty universal error.

Expected behavior

It should work.

Screenshots

SyntaxError: expected expression, got '.'6519939e08f60c2b0fdda52a767add1b5303a0f3.8812c13c.chunk.css:1

System information

  • OS: macOS

  • Browser (if applies): Different browsers behave variously.

    • Firefox errors out when loading the page
    • Chrome only errors when doing client-side routing
    • Chrome, on first page load, have two preload tag in the head pointing to the same CSS, one with assetPrefix, one without
    • Firefox on the other hand, has only one, maybe it’s because the syntax error triggers right away preventing it from going forward
  • Version of Next.js: 9.0.6

Additional context

Add any other context about the problem here.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
dnmahendracommented, Jan 6, 2020

Can someone look into this, please? It is happening in the version 9.1.4 too.

1reaction
abraxxascommented, Oct 8, 2019

Still encountering this issue with next 9.1.1, the server rendered output seems to be correct <link rel="stylesheet" href="/_next/static/css/static/balh/blah/blah/blah.js.0c20549d.chunk.css"/> but when i do client side navigation to the same page <script src="/_next/static/css/static/balh/blah/blah/blah.js.0c20549d.chunk.css"></script>

Read more comments on GitHub >

github_iconTop Results From Across the Web

Granular chunks load CSS as JS · Issue #8806 · vercel/next.js
Bug report Describe the bug After enabling granular chunks, CSS is loaded as JS in the body. In the head, there's.
Read more >
Granular chunks and JavaScript modules for faster page loads
Build a Webpack configuration to improved page load performance with granular chunking strategy and JavaScript modules for modern browsers.
Read more >
Improved Next.js and Gatsby page load performance with ...
This granular chunking strategy provides the following benefits: Page load times are improved. Emitting multiple shared chunks, instead of a ...
Read more >
Code-splitting is hard - Kevin Farrugia
You may want to read: Improved Next.js and Gatsby page load performance with granular chunking or The 100% correct way to split your...
Read more >
Code Splitting - webpack
This feature allows you to split your code into various bundles which can then be loaded on demand or in parallel. It can...
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