-
-
Notifications
You must be signed in to change notification settings - Fork 971
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
Feature Request - Production Dependency Optimization By Running npm prune --production
#2834
Comments
@palisadoes plz check this one.This is one followup for the optimization for our docker image in prodution enviroment .plz assign . I have this script and working. This is a new feature that's why i opened this issue. If u want to implement this feature in my existing pr then i will make changes docker efficiency pr. |
@PurnenduMIshra129th These scripts are not required. The workflow that checks DockerFile will automatically fail if dependencies are not installed properly in future PRs. Currently just fix the dependencies in the package.json file itself so that |
@adithyanotfound it is also required for normal optimize dependecy with out docker usages in production.It is not related to docker only . It is related to production nodemodules optimization by removing deve dependecy |
@PurnenduMIshra129th Wouldn't just adding a PR workflow be sufficient to ensure proper segregation between the dependencies? |
yes it will work but in this mehtod it dynamic means on future purpose whatever packages you will install before production you have to just run the command 'npm run move-prune' and every thing will be completed .First it will generate a list of production and dev dependency then by diff command it will compare it ,then the number of packages we get in this process . first it will uninstall it from the dev dependecy , then it will install it in production dependecy then it will remove all the dev dependecy but if we do this in workflow it will be manually. User have to dot it by him self . Lets no of common package we get is 10 which is listed in dev but used in production then for all those packages we have to manually delete it from dev then again add it production. So after ananlysis just tell me which one should be better , if workflow is better then i will go through that way. |
@PurnenduMIshra129th Thanks for the detailed explanation. I understood it now. However
|
@adithyanotfound yes right . Because in production we only need the production dependency. So this approch will work for the future use if any of the packages misplaced in dev we can find it and move to prod depnedency. plz assign |
@palisadoes @adithyanotfound in which folder i will keep the script. If i will create new folder then what will be its name |
Why new file folder? Keep it in root if it's related of dependencies |
|
Ok create a new folder |
@varshith257 @palisadoes check the pr . Give suggestion if any changes are required. |
Is your feature request related to a problem? Please describe.
Currently production node_moudules have dev dependency present in it . So which is not required in production. This dev dependency is only required during development of application not in production.
Describe the solution you'd like
-If we want to to reproduce this issue . Then first build the application using 'npm run build' . Then run this command npm prune --production . If we start the server using this command 'npm run prod'. Then you can see some packages that are listed under development dependency is still used in production so you will see an error the modules is not found.
-So my approch is to to compare the dependecy used in production and development enviroment then which packages are used in both production but listed under development in package.json are removed under it and add into dependecy as production.
-As a result of this only devlopment dependcy will remove by prune command . And production packages are remain unaffected.
-It will optimize our packages for production enviroment by removing unwanted nodemodules.
-Around 200-300MB of node_modules size wiil decrease which is a significant size. Which is further be helpful for our docker production image built.
Describe alternatives you've considered
-Then check if the common packages are listed under development dependecy or not . If it under the dev then it should be in production dependency list.
-Then successfully executing both the script use the command
npm prune --production
. Then start the server by usingnpm run prod
. If the server start with out error like nodemodules is not found . Then it solves our problem.Approach to be followed (optional)
N/A
Additional context
Potential internship candidates
Please read this if you are planning to apply for a Palisadoes Foundation internship
The text was updated successfully, but these errors were encountered: