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

Generate from angular selectors. ENG-7482 #1653

Merged
merged 7 commits into from
Dec 12, 2024
Merged

Conversation

STRd6
Copy link
Contributor

@STRd6 STRd6 commented Dec 10, 2024

Description

Generate dom structure based on the actual angular selector for the component.

Previously we would only generate for very simple selectors in some circumstances ex: some-component.

Now we correctly parse the selector and add appropriate tag name, class names, id, and attributes.

Currently checking in selector-parser.js as a generated file which is not ideal but I don't know how to hook into the tsc build process to register a transpiler like esbuild can.

ENG-7482

@STRd6 STRd6 requested a review from samijaber as a code owner December 10, 2024 21:37
Copy link

changeset-bot bot commented Dec 10, 2024

🦋 Changeset detected

Latest commit: 2314e23

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@builder.io/mitosis Patch
@builder.io/mitosis-cli Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

nx-cloud bot commented Dec 10, 2024

☁️ Nx Cloud Report

CI is running/has finished running commands for commit 2314e23. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this CI Pipeline Execution


✅ Successfully ran 4 targets

Sent with 💌 from NxCloud.

Copy link

cloudflare-workers-and-pages bot commented Dec 10, 2024

Deploying mitosis with  Cloudflare Pages  Cloudflare Pages

Latest commit: bd3c03a
Status: ✅  Deploy successful!
Preview URL: https://028a9c4f.mitosis-9uh.pages.dev
Branch Preview URL: https://generate-from-angular-select.mitosis-9uh.pages.dev

View logs


describe('Angular selectors', () => {
test('should parse gnarly selectors', () => {
expect(parse('ccc.c1#wat[co].c2[counter="cool"]#wat[x=\'y\'].c3')).toEqual({
Copy link
Contributor

Choose a reason for hiding this comment

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

Are support for the :not pseudo-class and multiple selectors (e.g. foo, [bar]) in scope? Both are supported by Angular: https://angular.dev/guide/components/selectors#types-of-selectors

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍 I should add parsing for those. They don't affect the code generation but will need to be accounted for in the parsing.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok great! Only other thing I can think of here is to add a test for those cases for parsing.

Copy link
Contributor

@manucorporat manucorporat left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Contributor

@liamdebeasi liamdebeasi left a comment

Choose a reason for hiding this comment

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

One non-blocking suggestion, but otherwise looks good. Thanks for looking into the Angular parser!

@@ -0,0 +1,16 @@
import { parse } from '../generators/angular/parse-selector';
Copy link
Contributor

Choose a reason for hiding this comment

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

Oh one more thing I just noticed: Do you intend for this to be a version bump in Mitosis? If so, you'll need to generate a new changeset.

@STRd6 STRd6 merged commit 772d6f5 into main Dec 12, 2024
15 checks passed
@STRd6 STRd6 deleted the generate-from-angular-selectors branch December 12, 2024 16:34
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.

3 participants