Static-web-apps: Do not use --production during npm install for frontend app

Created on 9 Apr 2021  路  6Comments  路  Source: Azure/static-web-apps

Issues with tools like tsc, ngcc, that are typically installed in devDependencies.

oryx

All 6 comments

Investigated this further. It looks like this is caused by the Static Web Apps client calling Oryx with the prune_dev_dependencies flag.

This is a script generated by Oryx for an Angular repo.

With prune_dev_dependencies enabled, this code block is run. With Angular repos that have ngcc as a postinstall step, it will fail because at this stage, only prod dependencies are installed.

Confirmed that if prune_dev_dependencies is not passed to Oryx, an Angular app with postinstall: ngcc... builds successfully.

Are there any advantages to pruning dependencies in any frontend build? @manekinekko @shmool @johnpapa @aaronpowell

/cc @miwebst @arroyc

I think we need to differentiate two scenarios: building backend application vs frontend application. Both build scenario deals differently with dependencies and devDependencies.

Building backend apps

Backend apps, using Node.js for instance, will expect devDependencies to be downloaded to perform the build step. However, Node.js will require dependencies to be installed on the same host as the app, in order to run.

Building frontend apps

Front-end apps will also expect devDependencies to be downloaded to perform the build step. However, dependencies would be packages into one or multiple bundles and sent to the production static hosting.

Should Oryx prune production deps?

IMHO, for front-end app, Oryx should perform an npm install without --production because the final bundle which runs in the browser won't need access to ./node_modules.

For backend apps though, Oryx should prune devDependecies (npm prune --production) before sending the API package to prod. At runtime, Node.js would expect to have dependencies available, not devDependecies.

That's the current status of the front-end and backend apps build story.

Thanks @manekinekko. I agree with your recommendations. There鈥檚 a separate issue created for backend #323

I agree with @manekinekko as well.

Thanks. Looks like the recommendation is to remove prune_dev_dependencies when calling Oryx for _frontend_ builds only. @miwebst can we make this change?

We should probably sync up with the Oryx folks about this, we added this in response to a different issue so would love to get their take on it as well.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mahmoudajawad picture mahmoudajawad  路  3Comments

marxxxx picture marxxxx  路  4Comments

JoeWirtley picture JoeWirtley  路  5Comments

akzaidi picture akzaidi  路  6Comments

AshirwadSatapathi picture AshirwadSatapathi  路  5Comments