Make the package.json file in Djblets the primary dependency source.
Review Request #12797 — Created Jan. 21, 2023 and submitted — Latest diff uploaded
Historically, we've auto-generated
package.json
in Djblets in order to
have some handy variables that could be used for extension building, to
help keep versions of dependencies manageable by declaring them in
djblets/dependencies.py
.As we've evolved our JavaScript ecosystem, this has become more tedious
to maintain. We have to make changes to the generatedpackage.json
and
then mirror them back todependencies.py
. Thepackage.json
file was
an ignored file, and we had to be careful with its contents.This change reverses the role. Now,
djblets/package.json
is where all
of our NPM dependencies live, and we have a symlink within the top of
the tree to there. Whenever we perform anpm install --save ...
(and,
notably, the result of that modifiesnode_modules
), NPM will run a new
script to editdependencies.py
and move those dependencies there.This way, it should be easier to ensure that we have the right
dependencies in the tree for building static media, looking up types, or
linting the files.There is a trade-off in that we no longer have the newly-introduced
environment variables for specifying the location of in-development
versions of our Beanbag node.js modules. These made it easier to specify
the path to a package and install it.The workaround for that is to use
npm install --no-save <path>
when we
want to test a local version, or use thenpm link
functionality. It's
not ideal, but the benefits outweigh the downsides.Our
package.json
now bundles the latest versions of Backbone, jQuery,
jQuery-UI, and typing modules. These will be installed innode_modules
when building the package, when building extensions, or when consuming
Djblets and using the embedded dependencies. This allows typing and
setting things up to let consumers easily bundle compatible versions of
these packages out ofnode_modules
if desired.
Tested installing and uninstalling dependencies (modifying
package.json
in the process) and verifying the updates todependencies.py
.Verified that the dependencies installed with an empty
node_modules
usingsetup.py develop
.