Oryx icon indicating copy to clipboard operation
Oryx copied to clipboard

[Feature] pnpm/corepack support

Open dtinth opened this issue 1 year ago • 10 comments

Feature Request

From https://github.com/microsoft/Oryx/issues/1150#issuecomment-1886067023

We're not currently looking to support pnpm. Closing this issue for now, please create a new issue and link to this one if you feel strongly.

I feel strongly about this and decided to open a new issue.

My suggestions is at follows:

  • Detect presence of packageManager key in package.json.
  • If found,
    • Run corepack enable
    • Run npm install / yarn install / pnpm install depending on the package manager name
  • If not found,
    • Just run npm install as before

How this will improve things:

  • Azure Static Site and Azure Web Service users can build their app without having to set up PRE_BUILD_COMMAND and CUSTOM_BUILD_COMMAND. I use Netlify and Vercel, and they are supported out-of-the-box, so I expect the same in other hosting services. Azure services not recognizing pnpm in my project is a turn off for me.

  • GitHub Codespaces currently run npm install even in pnpm projects. This means not only it takes a longer time for Codespace to initialize pnpm projects (due to waiting for npm install), afterwards I have to go ahead and rm -rf node_modules package-lock.json and run pnpm install again.

In short, supporting pnpm via corepack will improve both developer experience in Codespaces and deployment experiences in Azure services.

dtinth avatar Jan 14 '24 13:01 dtinth

Thank you for opening this issue and linking back.

simonjj avatar Jan 17 '24 17:01 simonjj

Please update and scale the Oryx to support for pnpm, so it can reach a broader audience including OSS developers who switched to pnpm and businesses using Azure Static Web Apps.

PhantipK avatar Jan 29 '24 09:01 PhantipK

This would be helpful to my team as well!

sytexa-julia avatar Apr 29 '24 18:04 sytexa-julia

What about using pnpm/action-setup@v3 ?

Or you can just work with Azure and use PRE_BUILD_COMMAND & CUSTOM_BUILD_COMMAND commands like:

      - name: Build And Deploy
        id: builddeploy
        uses: Azure/static-web-apps-deploy@v1
        env:
          PRE_BUILD_COMMAND: npm install -g pnpm
          CUSTOM_BUILD_COMMAND: pnpm install --frozen-lockfile && pnpm run build

GalindoSVQ avatar Apr 30 '24 15:04 GalindoSVQ

@GalindoSVQ From my experience deploying a NextJS app last week, these PRE_BUILD_COMMAND and CUSTOM_BUILD_COMMAND variables did work to some extent.

The blocker was that during the Azure Functions build phase, npm install --production would always run regardless and I could not find a way to override that part of the pipeline. I was forced to alter my app deps to use npm to successfully deploy.

fturmel avatar Apr 30 '24 15:04 fturmel

@GalindoSVQ From my experience deploying a NextJS app last week, these PRE_BUILD_COMMAND and CUSTOM_BUILD_COMMAND variables did work to some extent.

The blocker was that during the Azure Functions build phase, npm install --production would always run regardless and I could not find a way to override that part of the pipeline. I was forced to alter my app deps to use npm to successfully deploy.

react app boostraped using vite works fine, I am not sure but.. have you tried specifying pnpm as engine in package.json?

https://docs.npmjs.com/cli/v10/configuring-npm/package-json#engines

GalindoSVQ avatar Apr 30 '24 15:04 GalindoSVQ

react app boostraped using vite works fine

That makes sense to me, it's probably a static app that doesn't have APIs/backend and doesn't use Azure Functions? Or maybe your project isn't pruning dev dependencies and you're not hitting the same build/deploy path I am.

I don't think specifying pnpm in package.json will make a difference. Everything in Oryx seems hardcoded to use npm or yarn exclusively.

I can track the problem here for my specific blocker (in case it helps the maintainers in any way), where ProductionOnlyPackageInstallCommand always runs and there are no overrides to make packageInstallCommand be pnpm install.

https://github.com/microsoft/Oryx/blob/8fb59f3713371b0d39b4b4df3a96b3a36b9c52a7/src/BuildScriptGenerator/Node/NodeBashBuildSnippet.sh.tpl#L120-L125

https://github.com/microsoft/Oryx/blob/8fb59f3713371b0d39b4b4df3a96b3a36b9c52a7/src/BuildScriptGenerator/Node/NodePlatform.cs#L196-L218

fturmel avatar Apr 30 '24 17:04 fturmel

This is impacting my attempt to execute a static site build from ADO using AzureStaticWebApp@0 because it forces the build_command to use yarn 1.x, not 4.2.1 as defined in my package.json packageManager config. Per the docs (https://github.com/microsoft/Oryx/blob/main/doc/runtimes/nodejs.md#package-manager) package manager is currently derived (incorrectly in my case) rather than simply reading the value!

abforman avatar May 03 '24 13:05 abforman

same issue here cannot use pnpm

asheemak avatar Jun 17 '24 22:06 asheemak