Skip to content

PoC: CSS extraction#560

Closed
davesnx wants to merge 135 commits intomainfrom
start-extraction
Closed

PoC: CSS extraction#560
davesnx wants to merge 135 commits intomainfrom
start-extraction

Conversation

@davesnx
Copy link
Owner

@davesnx davesnx commented Sep 2, 2025

No description provided.

davesnx added 11 commits August 28, 2025 18:20
…messages

Previously, type errors in generated code would show '_none_, line 1' which
provided no useful debugging information. This commit ensures that all generated
AST nodes have proper location information that traces back to the original
source location.

Changes:
- Fixed location propagation in CSS module identifier generation
- Improved render_variable to preserve location information
- Enhanced addLabel to include location in all generated expressions
- Ensured render_make_call maintains proper location attributes

Now type errors show actual file names and line numbers (e.g., 'test_styles.ml, lines 78-88')
instead of unhelpful '_none_' locations.
@vercel
Copy link

vercel bot commented Sep 2, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
styled-ppx Ignored Ignored Preview Dec 10, 2025 1:48pm

@github-actions
Copy link

github-actions bot commented Sep 2, 2025

New nightly version has been published to the NPM registry: @davesnx/styled-ppx@0.56.1-2b278ac.0.
Install it with npm install @davesnx/styled-ppx@nightly or npm install @davesnx/styled-ppx@0.56.1-2b278ac.0.

@davesnx davesnx marked this pull request as ready for review November 26, 2025 16:47
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

This PR is being reviewed by Cursor Bugbot

Details

Your team is on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle for each member of your team.

To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

done

.PHONY: test
test-promote: build
Copy link

Choose a reason for hiding this comment

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

Bug: Duplicate PHONY target declaration for test

The .PHONY: test declaration appears twice in the Makefile (lines 122 and 132), with the second one incorrectly declaring test as phony for the test-promote target. This causes the test-promote target to be incorrectly associated with the phony declaration, potentially breaking Make's dependency tracking. The second declaration should be .PHONY: test-promote instead.

Fix in Cursor Fix in Web

@davesnx davesnx requested a review from Copilot December 5, 2025 02:24
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces CSS extraction capabilities for styled-ppx, enabling static CSS file generation. It implements new cx2 and styled2 extensions that leverage css-grammar for parsing and type-checking, replacing the legacy property parsing system. The changes also include improvements to error messages and locations, new runtime APIs (CSS.make, CSS.merge), and support for minification.

Key changes:

  • New cx2, styled2.*, keyframe2, and styled.global2 extensions with static CSS extraction
  • Migration from css-property-parser to css-grammar for parsing/validation
  • Static CSS file generation via styled-ppx.generate dune integration

Reviewed changes

Copilot reviewed 146 out of 372 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
packages/ppx/src/ppx.re Added cx2/styled2 extensions, integrated css-grammar parser, improved error handling
packages/ppx/src/Css_runtime.re Implemented render_make_call for cx2, refactored to use css-grammar types
packages/ppx/src/Css_file.re New module for CSS accumulation, atomization, and static file generation
packages/ppx/src/Property_to_types.re Maps CSS properties to Css_types modules for interpolation toString calls
packages/ppx/src/settings.re Added --debug and --minify flags
packages/ppx/src/generate.re Added staticComponentStyled2, stylesAndRefObjectWithStyle for new runtime
packages/ppx/test/* Extensive new tests for cx2, minification, error locations
packages/ppx/src/dune Updated dependencies to include css-grammar-parser, murmur2, unix

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

]
};
let m = Format.asprintf("%a", Ppxlib.Pprintast.expression, payload);
failwith(m) |> ignore;
Copy link

Copilot AI Dec 5, 2025

Choose a reason for hiding this comment

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

This debug code (failwith(m) |> ignore) should be removed or wrapped in a debug flag check. The |> ignore after failwith is unreachable and suggests this is leftover development code.

Suggested change
failwith(m) |> ignore;

Copilot uses AI. Check for mistakes.
),
]
| Error(`Invalid_value(reason)) => [
| Error(`Invalid_value(_reason)) => [
Copy link

Copilot AI Dec 5, 2025

Choose a reason for hiding this comment

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

The _reason parameter is discarded but could provide valuable debugging context. Consider including it in the error message or at least logging it when debug mode is enabled.

Copilot uses AI. Check for mistakes.
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

This PR is being reviewed by Cursor Bugbot

Details

Your team is on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle for each member of your team.

To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

| Some existing ->
Printf.eprintf
"Warning: multiple input files provided. Using '%s', ignoring '%s'\n"
arg existing
Copy link

Choose a reason for hiding this comment

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

Bug: Warning message has swapped argument order

The warning message says "Using '%s', ignoring '%s'" with arguments arg and existing respectively, but the code actually keeps the new arg (via parse (Some arg) ... on line 308) and discards the existing file. The format string arguments are reversed - the message claims to use arg and ignore existing, which is correct for what the code does, but the argument order in the Printf call is backwards making it print the opposite of what's happening.

Fix in Cursor Fix in Web

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments