Enable modern JavaScript for Djblets using Rollup.js and @beanbag/frontend-buildkit.
Review Request #12761 — Created Jan. 4, 2023 and submitted
This switches Djblets over to the new
@beanbag/frontend-buildkit
dependency, which defines a standard set of dependencies for building
both CSS and JavaScript media.The new buildkit dependency includes Rollup. This is now enabled,
allowing us to begin introducing JavaScript (TypeScript, specifically)
modules that can import other modules.To start off, most (though not all) of our Pipeline JavaScript bundles
now include anindex.ts
, which can be populated with imports as we go
forward. The Pipeline bundles separate these out from the legacy
JavaScript via comments. There's also arollup.config.js
to tell
Rollup how we want to bundle things, which will be shared for each
Pipeline bundle.It'll be the responsibility of each
index.ts
to import any modules
needed, and to set them in aDjblets
namespace.Extension building has also been updated to work with this.
Temporarily converted some code to use Rollup. This involved converting
some existing files (both.ts
and.es6.js
) to be modules that
exported content instead of settingDjblets.*
explicitly. Re-exported
in anindex.ts
and verified the resulting bundled file set those on
Djblets
.Then updated an
index.ts
in a different bundle, imported content from
the other bundle, and exported new code based on that. Verified it
properly accessed the imported content fromDjblets
and exported back
toDjblets
without overwriting anything.Compiled Djblets static media for packaging, and manually inspected
the files, making sure this all looked correct.Built the static media in Review Board by browsing pages, and verified
it used Djblets'srollup.config.js
,.babelrc
, andtsconfig.json
for
the builds, instead of Review Board's (tested with and without Review Board
providing those files). Verified Review Board was able to successfully use
the modified code that exported some functionality, and that some dummy
objects I set up and modified via the exports were accessible inDjblets
.
Summary | ID |
---|---|
827643d5a444b2d6e6128e43ff723a4cf6067543 |
- Change Summary:
-
Added a missing
.babelrc
. - Commits:
-
Summary ID 1d8bdd2eb434fdfe9fe62ebf9c4164a6751c9f54 810681a7dc11713c307895ac4a5349572dd98de7