Skip to content

refactor: Vendor lightningcss-napi as turbopack-lightningcss-napi#92013

Draft
bgw wants to merge 2 commits intocanaryfrom
bgw/vendor-lightningcss-napi
Draft

refactor: Vendor lightningcss-napi as turbopack-lightningcss-napi#92013
bgw wants to merge 2 commits intocanaryfrom
bgw/vendor-lightningcss-napi

Conversation

@bgw
Copy link
Copy Markdown
Member

@bgw bgw commented Mar 27, 2026

We want to migrate to napi v3. However, lightningcss uses napi v2. It might make sense for us to upstream support for napi v3 to lightningcss, but that's a major breaking change for lightningcss to make, and it's not very practical for it to support both napi v2 and napi v3.

So instead, let's vendor it for now:

  • The first PR is a mostly-straightforward copy, with rusfmt changes.
  • The second PR (AI generated) removes the features that we don't use in Next.js.

bgw added 2 commits March 27, 2026 14:46
Replace the external lightningcss-napi dependency with a vendored copy at turbopack/crates/turbopack-lightningcss-napi. Source files are copied verbatim from the upstream lightningcss repository, include the upstream LICENSE, and are formatted with cargo fmt. Bump lightningcss from 1.0.0-alpha.70 to 1.0.0-alpha.71 to match the vendored napi crate.
Make the vendored turbopack-lightningcss-napi crate only include the
visitor functionality Next.js uses. Remove the unused bundler feature,
its extra dependencies, and the dead code paths that supported it.
@nextjs-bot nextjs-bot added created-by: Turbopack team PRs by the Turbopack team. Turbopack Related to Turbopack with Next.js. labels Mar 27, 2026
Copy link
Copy Markdown
Member Author

bgw commented Mar 27, 2026

This stack of pull requests is managed by Graphite. Learn more about stacking.

@nextjs-bot
Copy link
Copy Markdown
Collaborator

nextjs-bot commented Mar 27, 2026

Failing test suites

Commit: 677821a | About building and testing Next.js

pnpm test test/integration/empty-project/test/index.test.ts (job)

  • Empty Project > Should not time out and return 404 (DD)
Expand output

● Empty Project › Should not time out and return 404

FetchError: network timeout at: http://localhost:33747/

  at Timeout.<anonymous> (../node_modules/.pnpm/node-fetch@2.6.7_encoding@0.1.13/node_modules/node-fetch/lib/index.js:1484:13)

pnpm test test/integration/next-image-new/app-dir/test/static.test.ts (job)

  • Telemetry CLI > production mode > cli session: babel tooling config (DD)
  • Telemetry CLI > production mode > cli session: custom babel config (plugin) (DD)
  • Telemetry CLI > production mode > cli session: package.json custom babel config (plugin) (DD)
  • Telemetry CLI > production mode > cli session: custom babel config (preset) (DD)
  • Telemetry CLI > production mode > cli session: next config with webpack (DD)
  • Telemetry CLI > production mode > detect static 404 correctly for next build (DD)
  • Telemetry CLI > production mode > detect page counts correctly for next build (DD)
Expand output

● Telemetry CLI › production mode › cli session: babel tooling config

thrown: "Exceeded timeout of 60000 ms for a test.
Add a timeout value to this test to increase the timeout, if this is a long-running test. See https://jestjs.io/docs/api#testname-fn-timeout."

  188 |       })
  189 |
> 190 |       it('cli session: babel tooling config', async () => {
      |       ^
  191 |         await fs.rename(
  192 |           path.join(appDir, '.babelrc.default'),
  193 |           path.join(appDir, '.babelrc')

  at it (integration/telemetry/test/index.test.ts:190:7)
  at integration/telemetry/test/index.test.ts:98:56
  at Object.describe (integration/telemetry/test/index.test.ts:13:1)

● Telemetry CLI › production mode › cli session: custom babel config (plugin)

TypeError: Cannot read properties of null (reading 'pop')

  231 |
  232 |         const event = /NEXT_CLI_SESSION_STARTED[\s\S]+?{([\s\S]+?)}/
> 233 |           .exec(stderr)
      |                 ^
  234 |           .pop()
  235 |
  236 |         expect(event).toMatch(/"hasNextConfig": false/)

  at Object.stderr (integration/telemetry/test/index.test.ts:233:17)

● Telemetry CLI › production mode › cli session: package.json custom babel config (plugin)

TypeError: Cannot read properties of null (reading 'pop')

  257 |
  258 |         const event = /NEXT_CLI_SESSION_STARTED[\s\S]+?{([\s\S]+?)}/
> 259 |           .exec(stderr)
      |                 ^
  260 |           .pop()
  261 |
  262 |         expect(event).toMatch(/"hasNextConfig": false/)

  at Object.stderr (integration/telemetry/test/index.test.ts:259:17)

● Telemetry CLI › production mode › cli session: custom babel config (preset)

TypeError: Cannot read properties of null (reading 'pop')

  283 |
  284 |         const event = /NEXT_CLI_SESSION_STARTED[\s\S]+?{([\s\S]+?)}/
> 285 |           .exec(stderr)
      |                 ^
  286 |           .pop()
  287 |
  288 |         expect(event).toMatch(/"hasNextConfig": false/)

  at Object.stderr (integration/telemetry/test/index.test.ts:285:17)

● Telemetry CLI › production mode › cli session: next config with webpack

TypeError: Cannot read properties of null (reading 'pop')

  309 |
  310 |         const event = /NEXT_CLI_SESSION_STARTED[\s\S]+?{([\s\S]+?)}/
> 311 |           .exec(stderr)
      |                 ^
  312 |           .pop()
  313 |
  314 |         expect(event).toMatch(/"hasNextConfig": true/)

  at Object.stderr (integration/telemetry/test/index.test.ts:311:17)

● Telemetry CLI › production mode › detect static 404 correctly for next build

TypeError: Cannot read properties of null (reading 'pop')

  342 |
  343 |         const event1 = /NEXT_BUILD_OPTIMIZED[\s\S]+?{([\s\S]+?)}/
> 344 |           .exec(stderr)
      |                 ^
  345 |           .pop()
  346 |         expect(event1).toMatch(/hasStatic404.*?true/)
  347 |       })

  at Object.stderr (integration/telemetry/test/index.test.ts:344:17)

● Telemetry CLI › production mode › detect page counts correctly for next build

TypeError: Cannot read properties of null (reading 'pop')

  354 |
  355 |         const event1 = /NEXT_BUILD_OPTIMIZED[\s\S]+?{([\s\S]+?)}/
> 356 |           .exec(stderr)
      |                 ^
  357 |           .pop()
  358 |         expect(event1).toMatch(/"staticPropsPageCount": 2/)
  359 |         expect(event1).toMatch(/"serverPropsPageCount": 2/)

  at Object.stderr (integration/telemetry/test/index.test.ts:356:17)

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Mar 27, 2026

Merging this PR will degrade performance by 3.01%

❌ 1 regressed benchmark
✅ 16 untouched benchmarks
⏩ 3 skipped benchmarks1

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Simulation build[date-fns-all] 1.8 s 1.9 s -3.01%

Comparing bgw/vendor-lightningcss-napi (677821a) with canary (820578d)

Open in CodSpeed

Footnotes

  1. 3 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@nextjs-bot
Copy link
Copy Markdown
Collaborator

Stats from current PR

✅ No significant changes detected

📊 All Metrics
📖 Metrics Glossary

Dev Server Metrics:

  • Listen = TCP port starts accepting connections
  • First Request = HTTP server returns successful response
  • Cold = Fresh build (no cache)
  • Warm = With cached build artifacts

Build Metrics:

  • Fresh = Clean build (no .next directory)
  • Cached = With existing .next directory

Change Thresholds:

  • Time: Changes < 50ms AND < 10%, OR < 2% are insignificant
  • Size: Changes < 1KB AND < 1% are insignificant
  • All other changes are flagged to catch regressions

⚡ Dev Server

Metric Canary PR Change Trend
Cold (Listen) 455ms 455ms ▁▁▁█▁
Cold (Ready in log) 438ms 439ms ▁▁▁█▁
Cold (First Request) 1.078s 1.116s ▁▁▂█▂
Warm (Listen) 456ms 456ms ▁▁▁█▁
Warm (Ready in log) 443ms 445ms ▁▁▁█▁
Warm (First Request) 335ms 341ms ▁▁▁█▁
📦 Dev Server (Webpack) (Legacy)

📦 Dev Server (Webpack)

Metric Canary PR Change Trend
Cold (Listen) 455ms 455ms ▁▁▁█▁
Cold (Ready in log) 437ms 436ms ▁▁▃█▁
Cold (First Request) 1.861s 1.861s ▃▁▅█▁
Warm (Listen) 456ms 456ms ▁▁▁█▁
Warm (Ready in log) 436ms 436ms ▂▁▃█▁
Warm (First Request) 1.865s 1.866s ▄▁▅█▁

⚡ Production Builds

Metric Canary PR Change Trend
Fresh Build 3.790s 3.943s ▁▁▁█▁
Cached Build 3.805s 3.780s ▁▁▁█▁
📦 Production Builds (Webpack) (Legacy)

📦 Production Builds (Webpack)

Metric Canary PR Change Trend
Fresh Build 14.283s 14.286s ▂▁▃█▁
Cached Build 14.455s 14.520s ▁▁▂█▁
node_modules Size 484 MB 484 MB █████
📦 Bundle Sizes

Bundle Sizes

⚡ Turbopack

Client

Main Bundles
Canary PR Change
02fkg8wfh0iju.js gzip 9.19 kB N/A -
050zwt5xh_0tx.js gzip 10.4 kB N/A -
06rvbj82bhyo0.js gzip 13 kB N/A -
087fzjd-gvlzv.js gzip 450 B N/A -
0cclvb7sdlga8.js gzip 156 B N/A -
0cz1d0mv5g_q7.js gzip 39.4 kB 39.4 kB
0oi08ntrf9it-.js gzip 160 B N/A -
0ppxcl_z43mad.js gzip 8.52 kB N/A -
0pux8j8srb15o.js gzip 156 B N/A -
0xo8tauk_vq8u.js gzip 163 B N/A -
12u9cvy985d0g.js gzip 48.9 kB N/A -
19oha6-znmkcv.js gzip 8.55 kB N/A -
1c7-jqtrjgpht.js gzip 158 B N/A -
1elt1qium-r2m.css gzip 115 B 115 B
1jp2my4ecsy0w.js gzip 157 B N/A -
1yl5jy653a49k.js gzip 13.7 kB N/A -
1zi18gdtym70f.js gzip 7.61 kB N/A -
26elcgxnn9zjd.js gzip 8.52 kB N/A -
26wez-sohk1pu.js gzip 65.7 kB N/A -
2900hudr6gvm0.js gzip 2.28 kB N/A -
294v1xkw-wnx7.js gzip 156 B N/A -
2ihlsvbo2c9e8.js gzip 215 B 215 B
2lv2js3kmdeho.js gzip 8.48 kB N/A -
2rehygrd36hqv.js gzip 8.58 kB N/A -
2srwswih0m9_h.js gzip 13.3 kB N/A -
3-p9p9mheqhzx.js gzip 8.55 kB N/A -
31030bryqpolg.js gzip 8.53 kB N/A -
31dx5nmrzzuy7.js gzip 225 B N/A -
3bc-spm4lk7ic.js gzip 70.8 kB N/A -
3gkxwhecdaxx3.js gzip 152 B N/A -
3iu80eefg23ae.js gzip 9.77 kB N/A -
3k-48b78ys_vy.js gzip 10.1 kB N/A -
3m7-5rfj0avoz.js gzip 12.9 kB N/A -
3nocwfumnzpbh.js gzip 155 B N/A -
3uqce_6sa526g.js gzip 8.47 kB N/A -
3vw7ng071w5jc.js gzip 160 B N/A -
3xzi3fw4xezdd.js gzip 169 B N/A -
3yurjqk-sjs3y.js gzip 1.46 kB N/A -
3zz2ac8f9j0_z.js gzip 158 B N/A -
421vzwdt9j1b_.js gzip 5.62 kB N/A -
42sxe29nog-wp.js gzip 156 B N/A -
turbopack-0d..mab-.js gzip 4.16 kB N/A -
turbopack-0d..mjuc.js gzip 4.17 kB N/A -
turbopack-0y..u9lt.js gzip 4.16 kB N/A -
turbopack-0z..7cuw.js gzip 4.14 kB N/A -
turbopack-16..kwxz.js gzip 4.16 kB N/A -
turbopack-1i..qv09.js gzip 4.16 kB N/A -
turbopack-1m..o-5y.js gzip 4.16 kB N/A -
turbopack-1r..vz39.js gzip 4.16 kB N/A -
turbopack-2_..wx9z.js gzip 4.16 kB N/A -
turbopack-37..k88g.js gzip 4.16 kB N/A -
turbopack-3b..ee91.js gzip 4.16 kB N/A -
turbopack-3k..gjkn.js gzip 4.16 kB N/A -
turbopack-3m..gozx.js gzip 4.16 kB N/A -
turbopack-3t..t0tf.js gzip 4.16 kB N/A -
03dgzoo-qf3sm.js gzip N/A 9.19 kB -
047hwu5bimcw9.js gzip N/A 48.9 kB -
05tx5f25dlivn.js gzip N/A 8.53 kB -
0c7ez6p2qc57f.js gzip N/A 5.62 kB -
0j5trmqe4idma.js gzip N/A 154 B -
0n95_eeqgrhcd.js gzip N/A 13.7 kB -
0onlwqkxu6hh6.js gzip N/A 157 B -
0qnwuk92m8i7o.js gzip N/A 10.4 kB -
0r4wrn6n0ue2m.js gzip N/A 8.55 kB -
0rp0fodtbt_6m.js gzip N/A 8.52 kB -
0sfck-km4dl1k.js gzip N/A 8.47 kB -
0x0xuhmxzwkp8.js gzip N/A 8.47 kB -
1-wdvgxnzicj7.js gzip N/A 1.46 kB -
11u6nxujb2eg4.js gzip N/A 450 B -
1awfv5n2v7qqo.js gzip N/A 157 B -
1f_i02332a-o5.js gzip N/A 70.8 kB -
1oqf9zikln4hc.js gzip N/A 169 B -
1rx-vswvbn5xu.js gzip N/A 156 B -
1vb-oxhe37j4v.js gzip N/A 160 B -
1yber4lya1-wo.js gzip N/A 7.6 kB -
1ymze2l3ybcct.js gzip N/A 162 B -
2bd4_wqmb6wfi.js gzip N/A 156 B -
2fxq-wbed-y8c.js gzip N/A 157 B -
2k9ax08cjl2id.js gzip N/A 12.9 kB -
2lms6k76q5-6m.js gzip N/A 13.3 kB -
2q3hz-jtbjs52.js gzip N/A 9.77 kB -
2qx4twi9i3xus.js gzip N/A 2.28 kB -
2srnqic6tvxxd.js gzip N/A 8.52 kB -
2u59d2yzcv148.js gzip N/A 155 B -
30l7m4nayp73a.js gzip N/A 8.55 kB -
38ddjq3jgb_i1.js gzip N/A 156 B -
38rr7d3kfutni.js gzip N/A 13 kB -
39l6jc9d1op3h.js gzip N/A 158 B -
3bheqjl2yax7t.js gzip N/A 156 B -
3h_ecpiaatwgc.js gzip N/A 10.1 kB -
3ity0aahajapd.js gzip N/A 225 B -
3t1_fmf68z3r5.js gzip N/A 65.7 kB -
43mlw9dy_8f02.js gzip N/A 8.58 kB -
turbopack-0_..ts_l.js gzip N/A 4.16 kB -
turbopack-0-..cbvf.js gzip N/A 4.18 kB -
turbopack-01..15j-.js gzip N/A 4.16 kB -
turbopack-05..ix5b.js gzip N/A 4.16 kB -
turbopack-0c..63zh.js gzip N/A 4.16 kB -
turbopack-0o..efdx.js gzip N/A 4.16 kB -
turbopack-1m..xagw.js gzip N/A 4.16 kB -
turbopack-1r..8_gu.js gzip N/A 4.16 kB -
turbopack-2-..6cnb.js gzip N/A 4.16 kB -
turbopack-28..y6fr.js gzip N/A 4.16 kB -
turbopack-33..ljp0.js gzip N/A 4.16 kB -
turbopack-3c..a5-s.js gzip N/A 4.16 kB -
turbopack-3n..1w7j.js gzip N/A 4.14 kB -
turbopack-3y..g4va.js gzip N/A 4.16 kB -
Total 464 kB 464 kB ✅ -4 B

Server

Middleware
Canary PR Change
middleware-b..fest.js gzip 717 B 715 B
Total 717 B 715 B ✅ -2 B
Build Details
Build Manifests
Canary PR Change
_buildManifest.js gzip 431 B 435 B
Total 431 B 435 B ⚠️ +4 B

📦 Webpack

Client

Main Bundles
Canary PR Change
5528-HASH.js gzip 5.54 kB N/A -
6280-HASH.js gzip 60.7 kB N/A -
6335.HASH.js gzip 169 B N/A -
912-HASH.js gzip 4.59 kB N/A -
e8aec2e4-HASH.js gzip 62.7 kB N/A -
framework-HASH.js gzip 59.7 kB 59.7 kB
main-app-HASH.js gzip 256 B 253 B 🟢 3 B (-1%)
main-HASH.js gzip 39.3 kB 39.2 kB
webpack-HASH.js gzip 1.68 kB 1.68 kB
262-HASH.js gzip N/A 4.59 kB -
2889.HASH.js gzip N/A 169 B -
5602-HASH.js gzip N/A 5.55 kB -
6948ada0-HASH.js gzip N/A 62.7 kB -
9544-HASH.js gzip N/A 61.4 kB -
Total 235 kB 235 kB ⚠️ +664 B
Polyfills
Canary PR Change
polyfills-HASH.js gzip 39.4 kB 39.4 kB
Total 39.4 kB 39.4 kB
Pages
Canary PR Change
_app-HASH.js gzip 194 B 194 B
_error-HASH.js gzip 183 B 180 B 🟢 3 B (-2%)
css-HASH.js gzip 331 B 330 B
dynamic-HASH.js gzip 1.81 kB 1.81 kB
edge-ssr-HASH.js gzip 256 B 256 B
head-HASH.js gzip 351 B 352 B
hooks-HASH.js gzip 384 B 383 B
image-HASH.js gzip 580 B 581 B
index-HASH.js gzip 260 B 260 B
link-HASH.js gzip 2.51 kB 2.51 kB
routerDirect..HASH.js gzip 320 B 319 B
script-HASH.js gzip 386 B 386 B
withRouter-HASH.js gzip 315 B 315 B
1afbb74e6ecf..834.css gzip 106 B 106 B
Total 7.98 kB 7.98 kB ✅ -1 B

Server

Edge SSR
Canary PR Change
edge-ssr.js gzip 125 kB 125 kB
page.js gzip 270 kB 270 kB
Total 395 kB 396 kB ⚠️ +205 B
Middleware
Canary PR Change
middleware-b..fest.js gzip 616 B 615 B
middleware-r..fest.js gzip 156 B 155 B
middleware.js gzip 43.7 kB 43.9 kB
edge-runtime..pack.js gzip 842 B 842 B
Total 45.3 kB 45.5 kB ⚠️ +152 B
Build Details
Build Manifests
Canary PR Change
_buildManifest.js gzip 715 B 718 B
Total 715 B 718 B ⚠️ +3 B
Build Cache
Canary PR Change
0.pack gzip 4.34 MB 4.34 MB 🟢 7.49 kB (0%)
index.pack gzip 110 kB 110 kB
index.pack.old gzip 110 kB 110 kB
Total 4.56 MB 4.56 MB ✅ -7.25 kB

🔄 Shared (bundler-independent)

Runtimes
Canary PR Change
app-page-exp...dev.js gzip 334 kB 334 kB
app-page-exp..prod.js gzip 182 kB 182 kB
app-page-tur...dev.js gzip 334 kB 334 kB
app-page-tur..prod.js gzip 182 kB 182 kB
app-page-tur...dev.js gzip 330 kB 330 kB
app-page-tur..prod.js gzip 180 kB 180 kB
app-page.run...dev.js gzip 331 kB 331 kB
app-page.run..prod.js gzip 180 kB 180 kB
app-route-ex...dev.js gzip 76.2 kB 76.2 kB
app-route-ex..prod.js gzip 51.9 kB 51.9 kB
app-route-tu...dev.js gzip 76.3 kB 76.3 kB
app-route-tu..prod.js gzip 51.9 kB 51.9 kB
app-route-tu...dev.js gzip 75.9 kB 75.9 kB
app-route-tu..prod.js gzip 51.6 kB 51.6 kB
app-route.ru...dev.js gzip 75.8 kB 75.8 kB
app-route.ru..prod.js gzip 51.6 kB 51.6 kB
dist_client_...dev.js gzip 324 B 324 B
dist_client_...dev.js gzip 326 B 326 B
dist_client_...dev.js gzip 318 B 318 B
dist_client_...dev.js gzip 317 B 317 B
pages-api-tu...dev.js gzip 43.5 kB 43.5 kB
pages-api-tu..prod.js gzip 33.1 kB 33.1 kB
pages-api.ru...dev.js gzip 43.4 kB 43.4 kB
pages-api.ru..prod.js gzip 33.1 kB 33.1 kB
pages-turbo....dev.js gzip 52.9 kB 52.9 kB
pages-turbo...prod.js gzip 38.7 kB 38.7 kB
pages.runtim...dev.js gzip 52.8 kB 52.8 kB
pages.runtim..prod.js gzip 38.7 kB 38.7 kB
server.runti..prod.js gzip 62.5 kB 62.5 kB
Total 2.96 MB 2.96 MB ⚠️ +2 B
📎 Tarball URL
https://vercel-packages.vercel.app/next/commits/0606eab59854d1c859914607166880ce193dde5d/next

@bgw bgw changed the title Vendor lightningcss-napi as turbopack-lightningcss-napi refactor: Vendor lightningcss-napi as turbopack-lightningcss-napi Mar 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

created-by: Turbopack team PRs by the Turbopack team. Turbopack Related to Turbopack with Next.js.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants