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

feat: Remove Node.js runtime dependencies from docfx tools #10066

Merged

Conversation

filzrev
Copy link
Contributor

@filzrev filzrev commented Jul 5, 2024

This PR intended to resolve #9396.

Background

Playwright 1.41 or later supports following environment variables. (It's not documented though)

  • PLAYWRIGHT_NODEJS_PATH
  • PLAYWRIGHT_DRIVER_SEARCH_PATH

So it can remove Node.js runtime from docfx package.
Instead. it can use locally installed Node.js runtime instead.

By this changes. docfx packages size can be reduced from 208MB -> 56 MB

BREAKING CHANGES
This PR remove Node.js runtime bundles.
So it may introduce breaking changes for some users who using docfx without Node.js installation.
(e.g. docker image users)

I'll try to fix official docker image later.
https://github.com/dotnet/docfx/blob/main/Dockerfile

@filzrev
Copy link
Contributor Author

filzrev commented Jul 5, 2024

When using CommandUtility.ExistCommand helper methods.
It need to handle stdout result parse logics.
Because of following reasons.

  • On GitHub runner environment multiple node.js installations found by where command (Windows)
  • it's possible to search node command on current directory by where command.
  • node is prefix string appended by type command (Linux/mac)

So I've reverted code to PATH based search logics.

Copy link
Contributor

@yufeih yufeih left a comment

Choose a reason for hiding this comment

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

Thank you @filzrev !

@yufeih yufeih added the new-feature Makes the pull request to appear in "New Features" section of the next release note label Jul 8, 2024
@yufeih yufeih changed the title chore: Remove Node.js runtime dependencies from docfx tools feat: Remove Node.js runtime dependencies from docfx tools Jul 8, 2024
@yufeih yufeih merged commit b40f492 into dotnet:main Jul 8, 2024
7 checks passed
@filzrev filzrev deleted the chore-remove-nodejs-runtime-dependencies branch September 15, 2024 05:54
@JanVargovsky
Copy link

JanVargovsky commented Nov 18, 2024

Hi @yufeih, is it expected that everyone has to install the node.js locally (and on CI) even if we don't use any PDF related feature?

@filzrev
Copy link
Contributor Author

filzrev commented Nov 18, 2024

Node.js installation is required when running following commands.

  • docfx (Default command)
  • docfx pdf

It might be better to modify Prerequisite section of following document.

I'll try to create PR later.

@georg-jung
Copy link

I use the default command with "pdf": false in my docfx.json. I run docfx inside docker, image mcr.microsoft.com/dotnet/sdk:8.0-jammy. With 2.78.x, docfx started breaking my builds with

TypeInitializationException: The type initializer for 'Docfx.Pdf.PdfBuilder' 
threw an exception.
     DocfxException: Node.js executable is not found. Try to install Node.js or 
     set the `PLAYWRIGHT_NODEJS_PATH` environment variable.                     
       at void EnsurePlaywrightNodeJsPath() in PlaywrightHelper.cs:25           
       at cctor() in PdfBuilder.cs:53                                           
  at Task CreatePdf(string outputFolder)                                        
  at void <Execute>b__0() in DefaultCommand.cs:53                               
  at int Run(LogOptions options, Action run) in CommandHelper.cs:48             
  at int Execute(CommandContext context, Options options) in DefaultCommand.cs: 
     31                                                                         
  at Task<int> Execute(CommandContext context, CommandSettings settings) in     
     CommandOfT.cs:40                                                           
  at async Task<int> Execute(CommandTree leaf, CommandTree tree, CommandContext 
     context, ITypeResolver resolver, IConfiguration configuration) in          
     CommandExecutor.cs:166

Could it be a possibility to not require Node.js if PDF output is disabled?

@JanVargovsky
Copy link

JanVargovsky commented Nov 19, 2024

Workaround is simply by setting PLAYWRIGHT_DRIVER_SEARCH_PATH or PLAYWRIGHT_NODEJS_PATH to non empty value. For example in CMD:

set PLAYWRIGHT_NODEJS_PATH=anyvalue && docfx

My build then succeeded as it used to. Or install node.js even if it's not required (unless you are using pdf).

@filzrev
Copy link
Contributor Author

filzrev commented Nov 19, 2024

I've created PR(#10406) to fix a reported problem with the default docfx command.

@georg-jung
Copy link

FWIW in the meantime,

RUN PLAYWRIGHT_NODEJS_PATH="workaround https://github.com/dotnet/docfx/pull/10066#issuecomment-2486269657" docfx tech/docfx.json --disableGitFeatures=true

works in my Dockerfile. Thanks @JanVargovsky and of course @filzrev for the super fast fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new-feature Makes the pull request to appear in "New Features" section of the next release note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Exploded package size and quality concerns
4 participants