tailwindcss/packages
Robin Malfait efe084b7e7
Improve performance of cloning AST nodes (#19067)
This PR improves the performance of when we need to clone some AST
nodes. We have a few places where we clone `Candidate`, `Variant` and
CSS `AST` nodes.

Right now we use `structuredClone`, which works, but it is a generic
solution. However, we do know the exact structure of these AST nodes, so
we can write specialized clone functions that are much faster.

## Test plan

1. All the tests still pass with this change
2. The performance is better:

```
  cloneCandidate - src/candidate.bench.ts > Candidate cloning
    1.72x faster than cloneCandidate (spread)
    74.03x faster than structuredClone

  cloneAstNode() - src/ast.bench.ts > Cloning AST nodes
    1.15x faster than cloneAstNode (with spread)
    33.54x faster than structuredClone()
```

Ready for review, but should be merged after #19059
2025-10-07 10:46:37 +00:00
..
@tailwindcss-browser Introduce canonicalizeCandidates on the internal Design System (#19059) 2025-10-07 12:41:12 +02:00
@tailwindcss-cli Prepare v4.1.14 release (#19037) 2025-10-01 11:48:02 -04:00
@tailwindcss-node Prepare v4.1.14 release (#19037) 2025-10-01 11:48:02 -04:00
@tailwindcss-postcss Prepare v4.1.14 release (#19037) 2025-10-01 11:48:02 -04:00
@tailwindcss-standalone Prepare v4.1.14 release (#19037) 2025-10-01 11:48:02 -04:00
@tailwindcss-upgrade Improve performance of cloning AST nodes (#19067) 2025-10-07 10:46:37 +00:00
@tailwindcss-vite Prepare v4.1.14 release (#19037) 2025-10-01 11:48:02 -04:00
internal-example-plugin Prefix internal modules with internal-* (#14074) 2024-07-29 10:58:07 -04:00
tailwindcss Improve performance of cloning AST nodes (#19067) 2025-10-07 10:46:37 +00:00
tsconfig.base.json Improve debug logs (#15303) 2024-12-11 15:27:20 +01:00