• 
      

    Modernize Djblets JavaScript setup.

    Review Request #14646 — Created Oct. 23, 2025 and submitted — Latest diff uploaded

    Information

    Djblets
    release-5.x

    Reviewers

    This change makes a bunch of changes to modernize our JavaScript build
    process across our products:

    Support npm workspaces

    In order to better support development across our many repos and
    packages, this dramatically improves the way we handle npm workspaces.

    We used to have a djblets/package.json file which defines our JavaScript
    dependencies, and then a symbolic link from the repo root to make that
    also available for npm install. This change removes the symbolic link,
    and adds a new top-level package.json which defines workspaces as
    djblets and .npm-workspaces/*. This allows creating symbolic links
    in the workspaces directory in order to bring in development copies of
    spina, ink, beanbag-eslint-plugin, or whatever other JS dependencies one
    desires.

    Depending on the package, this may require having a shared parent
    directory and a symbolic link from ../node_modules to
    ./node_modules, since some things like to resolve to absolute paths
    and then crawl up the directory tree (looking at you, tsc).

    Update and consolidate JS dependencies.

    The actual dependencies listed in djblets/package.json have been
    simplified, using the new @beanbag/js-buildkit metapackage to ensure
    build-time dependencies. We also no longer have an explicit dependency
    on spina and backbone versions, preferring instead to just inherit
    whichever versions we're getting from ink.

    Use modern invocation for static media builder utilities.

    We were hard-coding the locations for babel, lessc, rollup, and
    uglifyjs based on node_modules/.bin. Because of the vagaries of npm
    we can't necessarily assume that there's a node_modules in the current
    directory, or that things will be in .bin. I've changed these to use
    npm exec ... instead, allowing npm to locate the binary and invoke it.

    Use terser instead of uglifyjs (opt-in).

    UglifyJS lacks support for a lot of ES6+ features, and its cousin
    UglifyES is unmaintained. I've changed our pipeline configuration to use
    Terser instead, which is a fork of these which is actively maintained
    and supports newer JS. The actual dependency for this will live in
    @beanbag/frontend-buildkit.

    Some of our upstream dependencies already depend on terser, so this
    reduces our dependency footprint as well.

    I was hoping we would be able to get sourcemaps for the fully-compressed
    JS with this, but unfortunately the way that django-pipeline does
    compressors won't allow for that.

    Use modern pipeline setup for static media during tests.

    Unit tests had their own pipeline configuration for some reason, which
    didn't even include any of the rollup files. This has been replaced with
    a call to the same build_pipeline_settings that we use everywhere
    else.

    Pulled in backbone types.

    I'm working on upstreaming our changes and improvements to the type
    definitions for Backbone, but in the meantime we can't just reference
    the file from node_modules the way we did before. This has been copied
    into the Djblets tree for the time being.

    Updated to ESLint 9.

    With the newer @beanbag/eslint-plugin bundled in
    @beanbag/js-buildkit, we now use ESLint 9.

    Simplify browserslist.

    I've changed the browserslist config to exist inside the top-level
    package.json and just specify baseline widely available. This mirrors
    what we have in Review Board (though RB also has that in our shareable
    babel config).

    • Set up Djblets into an environment that used npm workspaces to include
      Djblets, Review Board, @beanbag/frontend-buildkit, @beanbag/js-buildkit,
      @beanbag/jasmine-suites, and @beanbag/eslint-plugin.
    • Ran unit tests.
    • Ran eslint.
    • Built static media.
    • Built the rbintegrations extension to verify that static media
      building still worked for that.

    Commits

    Files