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

feat(turbopack): Enable lightningcss for turbopack by default #7524

Merged
merged 20 commits into from
Mar 11, 2024
Merged

Conversation

kdy1
Copy link
Member

@kdy1 kdy1 commented Feb 27, 2024

Description

Enable lightningcss by default, for --turbo mode.

Testing Instructions

next.js counterpart: vercel/next.js#62565

Closes PACK-2601

Copy link

vercel bot commented Feb 27, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
examples-native-web 🔄 Building (Inspect) Visit Preview 💬 Add feedback Mar 8, 2024 0:21am
examples-nonmonorepo ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 8, 2024 0:21am
rust-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 8, 2024 0:21am
turbo-site ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 8, 2024 0:21am
7 Ignored Deployments
Name Status Preview Comments Updated (UTC)
examples-basic-web ⬜️ Ignored (Inspect) Visit Preview Mar 8, 2024 0:21am
examples-designsystem-docs ⬜️ Ignored (Inspect) Visit Preview Mar 8, 2024 0:21am
examples-gatsby-web ⬜️ Ignored (Inspect) Visit Preview Mar 8, 2024 0:21am
examples-kitchensink-blog ⬜️ Ignored (Inspect) Visit Preview Mar 8, 2024 0:21am
examples-svelte-web ⬜️ Ignored (Inspect) Visit Preview Mar 8, 2024 0:21am
examples-tailwind-web ⬜️ Ignored (Inspect) Visit Preview Mar 8, 2024 0:21am
examples-vite-web ⬜️ Ignored (Inspect) Visit Preview Mar 8, 2024 0:21am

Copy link
Contributor

github-actions bot commented Feb 27, 2024

🟢 Turbopack Benchmark CI successful 🟢

Thanks

Copy link
Contributor

github-actions bot commented Feb 27, 2024

⚠️ This change may fail to build next-swc.

Logs

error: failed to select a version for `turbopack-binding`.
    ... required by package `next-core v0.1.0 (/root/actions-runner/_work/turbo/turbo/packages/next-swc/crates/next-core)`
    ... which satisfies path dependency `next-core` (locked to 0.1.0) of package `next-swc-napi v0.0.0 (/root/actions-runner/_work/turbo/turbo/packages/next-swc/crates/napi)`
versions that meet the requirements `*` (locked to 0.1.0) are: 0.1.0

the package `next-core` depends on `turbopack-binding`, with features: `__turbopack_build` but `turbopack-binding` does not have these features.


failed to select a version for `turbopack-binding` which could resolve this conflict

See job summary for details

Copy link
Contributor

github-actions bot commented Feb 27, 2024

⚠️ CI failed ⚠️

The following steps have failed in CI:

  • Turbopack Rust tests (mac/win, non-blocking)

See workflow summary for details

@kdy1 kdy1 marked this pull request as ready for review February 28, 2024 08:17
@kdy1 kdy1 requested a review from a team as a code owner February 28, 2024 08:17
{"offset": {"line": 28, "column": 1}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}},
{"offset": {"line": 34, "column": 0}, "map": {"version":3,"sources":["/turbopack/[project]/crates/turbopack-tests/tests/snapshot/css/chained-attributes/input/style.css"],"sourcesContent":["@import url(\"./a.css\") layer(layer) supports(not(display: inline-grid)) print;\n\n.style {\n color: yellow;\n}\n"],"names":[],"mappings":"AAEA,CAAC,KAAK,CAAC,CAAC;EACN,KAAK,EAAE,MAAM;AACf,CAAC"}},
{"offset": {"line": 36, "column": 1}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}]
{"offset": {"line": 4, "column": 0}, "map": {"version":3,"sources":["[project]/crates/turbopack-tests/tests/snapshot/css/chained-attributes/input/c.css"],"names":[],"mappings":"A"}},
Copy link
Member

@sokra sokra Feb 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sourcesContent is missing in SourceMaps and the mappings are empty?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried debugging with dbg, but it seems like the source map produced by lightningcss is relatively minimal at the first place.

cc @devongovett Can you take a look?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For sourcesContent, you need to call source_map.set_source_content for each source index to add it. Lightning CSS doesn't store a reference or copy to the original code so that's up to you. I see here where you add the source files but I couldn't find where the source content gets set so maybe that's missing? Or you could get the content some other way here.

As for the mappings themselves, I'm not sure without debugging it myself, but I see a couple possibilities:

  1. Maybe try adding the sources before calling to_css instead of after?
  2. When converting the source map to your internal format, maybe check that the source index is passed through (right now it is always None). Looks like maybe you can use add_raw instead. Not sure if that is related. At least verify that there are mappings there.
    builder.add(
    m.generated_line,
    m.generated_column,
    m.original.map(|v| v.original_line).unwrap_or_default(),
    m.original.map(|v| v.original_column).unwrap_or_default(),
    None,
    None,
    );

The mappings are probably more sparse than you might expect though. Basically there's one per rule since that's the level of granularity that browser dev tools operate at, so more is unnecessary. But it shouldn't be empty at least.

@kdy1 kdy1 merged commit 7d7eeec into main Mar 11, 2024
48 of 51 checks passed
@kdy1 kdy1 deleted the kdy1/lcss-on branch March 11, 2024 02:24
kdy1 added a commit to vercel/next.js that referenced this pull request Mar 11, 2024
# Turbopack

* vercel/turbo#7682 <!-- Will Binns-Smith -
Turbopack HMR: url-encode sourceURLs -->
* vercel/turbo#7524 <!-- Donny/강동윤 -
feat(turbopack): Enable lightningcss for turbopack by default -->


### What?

Enable lightningcss by default, for `--turbo` mode.

### Why?

It's time to do it 😄 

### How?

Turbopack counterpart: vercel/turbo#7524


Closes PACK-2600
@JesseKoldewijn
Copy link

❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants