Comments (4)
I think that's possible. What we do now is we store node_modules in the cache_dir so that we just copy the packages from there before running npm install
since what's stored in the cache_dir get carried over in the next builds.
You could do the same in the compile
file by:
- check if
package-lock.json
exists in cache_dir - if it does, compare
package-lock.json
in$cache_dir
withpackage-lock.json
in app root.- if equal, skip the build command of your build tool
- if not equal, then run the build command
- if it doesn't, run the build command
- copy
package-lock.json
into the$cache_dir
You could probably do the same with the compiled js file. Store it in the cache dir so you can copy it in later builds so that subsequent builds would be faster. That might help speed up subsequent builds where there were changes in package-lock.json
.
Let me know how that pans out.
from heroku-buildpack-phoenix-static.
I did some measurements locally, and I came up with this:
npm install 10,97s user 2,22s system 111% cpu 11,883 total
npm run deploy 7,34s user 0,60s system 150% cpu 5,267 total
npm install
takes its time even when running on the already compiled cached directory.
It looks like caching compilation phase gives fewer benefits than not running npm install
.
Unfortunately, that is outside of configurable compile
script.
I wonder if the strategy you've mentioned of comparing package-lock.json
couldn't be used here:
heroku-buildpack-phoenix-static/lib/build.sh
Line 117 in 3e414fc
to eliminate calls to
npm install
.
I could make a PR if you like the idea.
from heroku-buildpack-phoenix-static.
A PR would of what you described would be great, @tomekowal!
Also, turns out there's a npm ci
command now:
https://docs.npmjs.com/cli/ci.html
https://medium.com/@lusbuab/npm-ci-a-command-you-should-know-d8d67847884c
I guess we could use that npm ci
when there is a package-lock.json
present and use npm install
when it's not there.
from heroku-buildpack-phoenix-static.
Or use only npm ci
and error out when there is no package-lock.json
. It looks like the sole purpose of npm ci
is to force consistency and ensuring correct lock file. Doing:
if package.lock do
npm ci
else
npm install
defeats its purpose :)
Also, it discards cached node_modules
to build from a clean state every time. In my project, it takes twice more time.
added 1085 packages in 24.014s
It is a tradeoff between speed of npm install
on cached node_modules
and consistency of npm ci
always starting with clear state and forcing correct lock file.
from heroku-buildpack-phoenix-static.
Related Issues (20)
- Build is failing with NPM_TOKEN issue HOT 2
- My build just failed on phoenix.digest vs phx.digest HOT 1
- The build is failing if there is a .yarnrc with --cwd at the root HOT 1
- Support the new Cloud Native Buildpack (CNB) format.
- Files are compiled on startup
- New versions of node break the build HOT 17
- Remove default node_version
- Support for Yarn 2?
- Update heroku commands
- ngrok Error: certificate has expired HOT 3
- question about deployment to heroku with waypoint
- nodebin.herokai.com not resolving HOT 1
- Yarn error: "Command "deploy" not found." HOT 6
- Setup test suite and CI
- Heroku Build Fails HOT 2
- heroku build fails when node patch not specified HOT 4
- Improve error message below Phoenix 1.4?
- Is it possible to skip audit when building? HOT 3
- Installs an ancient version of yarn by default HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from heroku-buildpack-phoenix-static.