-
Notifications
You must be signed in to change notification settings - Fork 123
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
build: port copy-trilium.sh cleanup functionality to cross-platform TS #1436
Conversation
666f9c3
to
812806b
Compare
will run some tests this evening with the CI, locally this now builds nicely. only thing that will be broken after this: however for this I am already working on a branch, that moves this step to the webpack build phase, where it actually fits better |
CI currently fails with: need to check, which node version we actually run in the CI - with node v22 --experimental-strip-types definitely works |
I believe we run 20, but feel free to bump it up in the YAML workflows. Look for setup-node. |
yeah, makes sense we currently v22 inside Docker builds anyways and only both are LTS versions and I don't see any reason, why we shouldn't go with v22 for all builds. I'll bump the versions in the YAML files and the server build script this evening, when I am back from work |
this is useless at the moment, as all build processes are running "npm ci --omit=dev" anyways, i.e. they will just install everything remaining again
…rom copy-trilium in preparation to get rid of the file altogether - rest of the functionality will be merged into copy-dist.ts
helps avoiding downloading the packages a 2nd time during our prune stage
since we our own more "sophisticated" pruning during copy-dist, we need to set this to false, as otherwise build will fail
this is not needed anymore since commit 6b9d8f0
adapted from copy-trilium.sh
same as before, but some of the modules use singular/plural, so just check for both
deleting of ts and map files from node_modules folder, adapted from copy-trilium.sh.
* image-q/demo -> doesn't exist anymore (and even if it did - previous cleanup step, would've removed this anyways) * @excalidraw/excalidraw/dist/* -> updated to point to the dev folder * boxicons -> only fonts and css folders are used, so remove the other ones * jimp -> updated paths and removed non-existent path fixing here for historical reasons, next step is to move these over to copy-dist.ts
this is necessary, since for Docker and electron-forge, we need to run this as an extra step after copy-dist for electron-forge: after it is done with its own "pruning", as we otherwise would need to also take care of certain electron related pruning for Docker: as a last step in the build stage
all of its functionality has been "absorbed" by the cross-platform copy-dist and cleanupNodeModules scripts, that can be used for all of our builds now
extra note on mermaid: that should be packed by webpack now, so we just need to move it to devDeps and and we should be good
this is only needed for executing package scripts -> which we don't do in production fixes #1499
also added a logging function for debugging purposes
4deb496
to
0b42803
Compare
Node version in CI has been bumped to v22 in the meantime, now just need to add the running of the cleanup script in the Docker build process and we should be ready here :-) |
* moved the running of npm ci from copy-dist to cleanupNodeModules * added flag to disable it (necessary for electron-forge)
previously forgot to add this here as well -> had it only in the Dockerfile.alpine
Seems like the Windows runner is behaving strange :-(
Not sure if node is maybe getting tripped up by the "~1" thing in the windows path? -> will need to investigate. Edit: Likely caused by the single apostrophes around the path — need to check if that is potentially some "cmd" shell issue? MacOS build also fails, but that is due to #1531 – edit: but it does correctly build, when the "flakiness" does not happen :-) |
attempt to fix failing Windows build in CI, which uses cmd shell, which apparently treats single apostrophes differently
started another CI run here after an attempt to fix Windows Runner build: still running, so let's see when and if it finishes :-) |
WIP that partially addresses #1174
-> moves functionality fromcopy-trilium.sh
into cross-platformcopy-dist.ts
, so that we can get rid of one extra build script AND have other build processes also benefit from the copy-trilium.sh features (mainly "node_modules" cleanup -> which results in smaller file sizes for releases) -> this is currently only utilized for the "bare metal" Server build, but will now be available for all other builds as wellon a very first test, I got a reduction of 200+ MB of the node_modules folder this wayEdit 2025-03-27: Updated PR Description
This PR essentially ports the existing node_modules cleanup functionality of the
copy-trilium.sh
script to a cross-platform standalone TS script ->cleanupNodeModules.ts
.Its purpose is to "prune" the node_modules folder by removing unnecessary files not needed for production (e.g. like tests, demos, examples, TS files, etc.), which cuts down on the node_modules folder size -> I currently get a reduction of ~270 MB of the node_modules folder by running the script.
Porting the script to a standalone TS script allows us to run the cleanup on all platforms and for all build targets.
Previously the cleanup was only used with the "bare metal" Server build, the other targets (Docker and electron-forge) were not benefiting from it at all.
Due to the build target' peculiarities, we need to be able to run the cleanup script at different points in their respective build stages.
Since it usually runs during a stage where we might not have any devDeps available (e.g. in electron-forge's "afterPrune" hook), I've opted to just run it straight with node and its "--experimental-strip-types" flag – since we require node >= 22, that is no issue.
Two things that are still open/missing here: