@@ -29,6 +29,49 @@ main() {
2929
3030 cd " $RELEASE_PATH "
3131 yarn --production --frozen-lockfile
32+
33+ create_shrinkwraps
34+ }
35+
36+ create_production_shrinkwrap () {
37+ npm shrinkwrap
38+
39+ # HACK@edvincent: We create the shrinkwrap file from the installed node_modules folder.
40+ # Installing node-addon-api also creates an auto-generated folder under @parcel/node-addon-api for gyp,
41+ # but this actually does not have a package.json (nor it's a package that can be fetched from the repository).
42+ # Thus `npm shrinkwrap` doesn't know how to generate a lock entry for it, and leaves it empty - which then
43+ # breaks any subsequent install. We manually remove it, as on every install it will be auto-generated.
44+ case " $( uname) " in
45+ Darwin* )
46+ # NOTE@edouardv: The sed binary for MacOS requires an extra argument.
47+ sed -i ' ' ' /"@parcel\/node-addon-api": {},/d' npm-shrinkwrap.json
48+ ;;
49+ * )
50+ sed -i ' /"@parcel\/node-addon-api": {},/d' npm-shrinkwrap.json
51+ ;;
52+ esac
53+ }
54+
55+ create_shrinkwraps () {
56+ # yarn.lock or package-lock.json files (used to ensure deterministic versions of dependencies) are
57+ # not packaged when publishing to the NPM registry.
58+ # To ensure deterministic dependency versions (even when code-server is installed with NPM), we create
59+ # an npm-shrinkwrap.json file from the currently installed node_modules. This ensures the versions used
60+ # from development (that the yarn.lock guarantees) are also the ones installed by end-users.
61+
62+ # We first generate the shrinkwrap file for code-server itself - from being in $RELEASE_PATH
63+ create_production_shrinkwrap
64+
65+ # Then the shrinkwrap files for the bundled VSCode
66+ # We don't need to remove the devDependencies for these because we control how it's installed - and
67+ # as such we can force the --production flag
68+ cd lib/vscode/
69+ create_production_shrinkwrap
70+
71+ cd extensions/
72+ create_production_shrinkwrap
73+
74+ cd ../../
3275}
3376
3477main " $@ "
0 commit comments