Skip to content

Conditional compilation for CDP implementation only#3135

Merged
kblok merged 10 commits intohardkoded:masterfrom
steveberdy:cdp-only
Feb 16, 2026
Merged

Conditional compilation for CDP implementation only#3135
kblok merged 10 commits intohardkoded:masterfrom
steveberdy:cdp-only

Conversation

@steveberdy
Copy link
Contributor

Creates a PuppeteerSharp.Cdp Nuget package that removes the WebDriverBiDi implementation and only leaves the CDP implementation. Useful for native AOT builds that don't want the excess binary size generated by WebDriverBiDi code.

Note: the build and Nuget push steps are both duplicated in the pipelines, as Nuget packages are cleared between builds.

Fixes #3134

@kblok
Copy link
Member

kblok commented Feb 15, 2026

Clever

@kblok
Copy link
Member

kblok commented Feb 15, 2026

How about some tool that validates that we never leak wedriver bidi there?

@steveberdy
Copy link
Contributor Author

@kblok I used ILSpy to decompile the dll from the generated nuget package earlier, and it had nothing in the PuppeteerSharp.Bidi namespace there at all.
image

If you check the PuppeteerSharp.csproj file, you'll see that I put a condition on referencing the WebDriverBiDi library in the first place. It won't even pull it in if we're doing CDP only.

You can also see that it trimmed out the handling of the launching and connecting when using WebdriverBidi in the Launcher class, as I intended with the preprocessor directives:
image
image

@kblok
Copy link
Member

kblok commented Feb 15, 2026

@kblok I used ILSpy to decompile the dll from the generated nuget package earlier, and it had nothing in the PuppeteerSharp.Bidi namespace there at all.

image

If you check the PuppeteerSharp.csproj file, you'll see that I put a condition on referencing the WebDriverBiDi library in the first place. It won't even pull it in if we're doing CDP only.

You can also see that it trimmed out the handling of the launching and connecting when using WebdriverBidi in the Launcher class, as I intended with the preprocessor directives:

image image

Im thinking about the future. What can we do so I don't break you in the future?

@steveberdy
Copy link
Contributor Author

steveberdy commented Feb 15, 2026

@kblok I'm writing a script right now to decompile the generated DLL and check to make sure it doesn't include the PuppeteerSharp.Bidi namespace or the WebDriverBiDi dependency.

@steveberdy
Copy link
Contributor Author

@kblok alright, check what I added. It checks if the resulting assembly include WebDriverBiDi and if we have any types related to such usage.

@kblok
Copy link
Member

kblok commented Feb 16, 2026

One more thing.
Can we overwrite the description, so people exploring packages in Nuget knows when to use this package?

@kblok
Copy link
Member

kblok commented Feb 16, 2026

Great job!

@steveberdy
Copy link
Contributor Author

One more thing. Can we overwrite the description, so people exploring packages in Nuget knows when to use this package?

Yep, that's overridden now.

@kblok
Copy link
Member

kblok commented Feb 16, 2026

@steveberdy new build failed.

@steveberdy
Copy link
Contributor Author

steveberdy commented Feb 16, 2026

@kblok which run? From what I see, they're still in progress and none have failed.

@kblok
Copy link
Member

kblok commented Feb 16, 2026

@kblok which run? From what I see, they're still in progress and none have failed.

We are good. I might have seen an old one.

@kblok
Copy link
Member

kblok commented Feb 16, 2026

I will ship this tomorrow

@kblok kblok merged commit 8cc6509 into hardkoded:master Feb 16, 2026
13 checks passed
@steveberdy steveberdy deleted the cdp-only branch February 17, 2026 13:11
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.

Version 21.0.0 drastically increases native AOT binary size

2 participants