@@ -23,6 +23,8 @@ main() {
2323 bundle_code_server
2424 bundle_vscode
2525
26+ create_shrinkwraps
27+
2628 rsync ./docs/README.md " $RELEASE_PATH "
2729 rsync LICENSE.txt " $RELEASE_PATH "
2830 rsync ./lib/vscode/ThirdPartyNotices.txt " $RELEASE_PATH "
5658 ) > " $RELEASE_PATH /package.json"
5759 rsync yarn.lock " $RELEASE_PATH "
5860
59- # To ensure deterministic dependency versions (even when code-server is installed with NPM), we seed
60- # an npm-shrinkwrap file from our yarn lockfile and the current node-modules installed.
61- synp --source-file yarn.lock
62- npm shrinkwrap
63- # HACK@edvincent: The shrinkwrap file will contain the devDependencies, which by default
64- # are installed if present in a lockfile. To avoid every user having to specify --production
65- # to skip them, we carefully remove them from the shrinkwrap file.
66- json -f npm-shrinkwrap.json -I -e " Object.keys(this.dependencies).forEach(dependency => { if (this.dependencies[dependency].dev) { delete this.dependencies[dependency] } } )"
67- mv npm-shrinkwrap.json " $RELEASE_PATH "
68-
6961 rsync ci/build/npm-postinstall.sh " $RELEASE_PATH /postinstall.sh"
7062
7163 if [ " $KEEP_MODULES " = 1 ]; then
153145 popd
154146}
155147
148+ create_shrinkwraps () {
149+ # yarn.lock or package-lock.json files (used to ensure deterministic versions of dependencies) are
150+ # not packaged when publishing to the NPM registry.
151+ # To ensure deterministic dependency versions (even when code-server is installed with NPM), we create
152+ # an npm-shrinkwrap.json file from the currently installed node_modules. This ensures the versions used
153+ # from development (that the yarn.lock guarantees) are also the ones installed by end-users.
154+
155+ # We first generate the shrinkwrap file for code-server itself
156+ npm shrinkwrap
157+ # HACK@edvincent: The shrinkwrap file will contain the devDependencies, which by default
158+ # are installed if present in a lockfile. To avoid every user having to specify --production
159+ # to skip them, we carefully remove them from the shrinkwrap file.
160+ json -f npm-shrinkwrap.json -I -e " Object.keys(this.dependencies).forEach(dependency => { if (this.dependencies[dependency].dev) { delete this.dependencies[dependency] } } )"
161+ mv npm-shrinkwrap.json " $RELEASE_PATH "
162+
163+ # Then the shrinkwrap files for the bundled VSCode
164+ # We don't need to remove the devDependencies for these because we control how it's installed - and
165+ # as such we can force the --production flag
166+ cd lib/vscode/
167+ npm shrinkwrap
168+
169+ cd extensions/
170+ npm shrinkwrap
171+
172+ cd ../../..
173+ mv lib/vscode/npm-shrinkwrap.json " $RELEASE_PATH /lib/vscode/npm-shrinkwrap.json"
174+ mv lib/vscode/extensions/npm-shrinkwrap.json " $RELEASE_PATH /lib/vscode/extensions/npm-shrinkwrap.json"
175+ }
156176main " $@ "
0 commit comments