dotnet / razor

Compiler and tooling experience for Razor ASP.NET Core apps in Visual Studio, Visual Studio for Mac, and VS Code.
https://asp.net
MIT License
505 stars 196 forks source link

Consider using a source generator to generate scoped css files #7052

Open pranavkm opened 3 years ago

pranavkm commented 3 years ago

The compiler is considering adding a feature that would allow source generators to produce additional artifacts that are written to disk. This would line up nicely with the rewriting CSS that Razor SDK currently performs to produce the final output for scoped css files. Reasons to consider this:

a) RewriteCss is the only command that is executed as part of the rzc command. By turning it into a source generator we would remove usages of rzc entirely from our build and consolidate all our previously out-of-process MSBuild operations into source generators

b) This might play nicely with hot reload that we want to support for scoped css files. Our current plan for supporting this involves launching msbuild as part of dotnet-watch to update these files.

c) We think it might improve build perf since it involves fewer separate process, less JITing involved (the compiler has to already load Razor dlls for razor code generation) etc.

Tentative docs for this feature: https://gist.github.com/CyrusNajmabadi/8cf5426f772ccf5e58bea7804c564cd4

ghost commented 3 years ago

Thanks for contacting us. We're moving this issue to the Next sprint planning milestone for future evaluation / consideration. We will evaluate the request when we are planning the work for the next milestone. To learn more about what to expect next and how this issue will be handled you can read more about our triage process here.

captainsafia commented 3 years ago

The compiler team has an experimental build of this feature that we can use to implement this. It is targeted for release in 16.10/end of preview4.

captainsafia commented 3 years ago

Marking as blocked since we need the ArtifactsProducer API for this.