Skip to content

OBS-247: Use ESBuild for JS and remove django-pipeline #6915

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Mar 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ RUN pip install --no-cache-dir --no-deps -r requirements.txt && \
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PYTHONPATH=/app \
UGLIFYJS_BINARY=/app/webapp/node_modules/.bin/uglifyjs \
NPM_ROOT_PATH=/app/webapp/ \
NODE_PATH=/app/webapp/node_modules/

Expand Down
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"env": {
"browser": true,
"jquery": true,
"node": true
"node": true,
"es6": true
},
"extends": ["plugin:prettier/recommended", "eslint:recommended"],
"parserOptions": {
Expand Down
1 change: 0 additions & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ RUN pip install --no-cache-dir --no-deps -r requirements.txt && \
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PYTHONPATH=/app \
UGLIFYJS_BINARY=/app/webapp/node_modules/.bin/uglifyjs \
NPM_ROOT_PATH=/app/webapp/ \
NODE_PATH=/app/webapp/node_modules/

Expand Down
13 changes: 6 additions & 7 deletions docs/service/webapp.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,17 @@ To ease debugging, you can run a shell in the container:
Then you can start and stop the webapp, adjust files, and debug. The webapp
runs ESBuild's watch mode and Django's StatReloader to reload static file
changes automatically. This avoids needing to stop, rebuild, and restart the
container/server on every change.
container/server on every change to static files.
Note that changes to ``esbuild.js`` and other config files may still require stop/rebuild/restart.


Static Assets
=============

At the time of this writing, JS files are collected and processed by
collectstatic and django-pipeline. All other static assets (CSS, images,
fonts, etc) are collected and processed by ESBuild. Migration of JS to ESBuild
is currently in progress, with the intent to retire django-pipeline when
complete. The collectstatic package will continue to be used in support of the
internal Django admin pages.
Static assets (JS, CSS, images, fonts) are collected and processed by ESBuild.
Because we host Django admin pages, we also rely on the collectstatic package
for assets that belong to those internal admin pages. There is minor overlap between ESBuild and collectstatic,
particarly relating to images/fonts. However, main site development involves only ESBuild.

Static asset builds are triggered by NPM scripts in ``webapp/package.json``.
The assets are built into ``/app/webapp/static`` also known as ``STATIC_ROOT``.
Expand Down
2 changes: 1 addition & 1 deletion webapp/crashstats/api/jinja2/api/documentation.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

{% block site_js %}
{{ super() }}
{% javascript 'api_documentation' %}
<script src="/static/api/js/api_documentation.min.js" type="module"></script>
{% endblock %}

{% block doc_title %}API Reference{% endblock %}
Expand Down
10 changes: 0 additions & 10 deletions webapp/crashstats/api/static/api/js/lib/filesize.min.js

This file was deleted.

4 changes: 3 additions & 1 deletion webapp/crashstats/api/static/api/js/testdrive.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
/* global filesize */
import { default as Qs } from 'qs';
import fileSize from 'filesize';

(function ($, document) {
'use strict';

var filesize = fileSize;
var _submission_locked = false;

$.fn.serializeExclusive = function () {
Expand Down
34 changes: 0 additions & 34 deletions webapp/crashstats/crashstats/finders.py

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,7 @@

{% block site_js %}
{{ super() }}
{% javascript 'jquery_ui' %}
{% javascript 'tablesorter' %}
{% javascript 'bugzilla' %}
{% javascript 'correlation' %}
{% javascript 'jsonview' %}
{% javascript 'report_index' %}
<script src="/static/crashstats/js/socorro/report_index.min.js" type="module"></script>
{% endblock %}

{% block page_title %}[@ {{ report.signature }}] - {{ report.product }} {{ report.version }} Crash Report - Report ID: {{ report.uuid }}{% endblock %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

{% block site_js %}
{{ super() }}
{% javascript 'report_pending' %}
{% endblock %}
<script src="/static/crashstats/js/socorro/report_pending.min.js" type="module"></script>
{% endblock %}

{% block content %}
<div id="mainbody">
Expand Down
11 changes: 6 additions & 5 deletions webapp/crashstats/crashstats/jinja2/crashstats_base.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,13 @@
{% endblock %}

{% block site_css %}
<link rel="stylesheet" href="/static/crashstats/css/crashstats-base.min.css" />
<link rel="stylesheet" href="/static/crashstats/css/crashstats.min.css">
{% endblock %}

{% block site_js %}
<script src="/static/crashstats/js/crashstats.min.js" type="module"></script>
{% endblock %}

</head>

<body>
Expand Down Expand Up @@ -153,9 +158,5 @@ <h1>Product Navigation</h1>

<br class="clear" />
</div>

{% block site_js %}
{% javascript 'crashstats_base' %}
{% endblock %}
</body>
</html>
11 changes: 7 additions & 4 deletions webapp/crashstats/crashstats/jinja2/error_base.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@
<head>
<meta charset="UTF-8" />
<title>{% block page_title %}Error{% endblock %}</title>
<link rel="stylesheet" href="/static/crashstats/css/crashstats-base.min.css" />
{% block site_css %}
<link rel="stylesheet" href="/static/crashstats/css/crashstats-base.min.css">
{% endblock %}

{% block site_js %}
<script src="/static/crashstats/js/error.min.js" type="module"></script>
{% endblock %}
</head>
<body>
<div class="page-header">
Expand All @@ -13,8 +19,5 @@
<div id="footer" class="page-footer">
{% include "footer_nav.html" %}
</div>
{% block site_js %}
{% javascript 'error' %}
{% endblock %}
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// # This Source Code Form is subject to the terms of the Mozilla Public
// # License, v. 2.0. If a copy of the MPL was not distributed with this
// # file, You can obtain one at https://mozilla.org/MPL/2.0/.

// This jQuery shim is necessary as a separate file because imports are hoisted/evaluated before we can assign the global var.
// By encapsulating this here, this entire shim will process before subsequent imports.

import $ from 'jquery';
import 'tablesorter/dist/js/jquery.tablesorter.js';

window.jQuery = window.$ = $;
export { $ };
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

/* exported BugLinks */

var BugLinks = (function () {
export const BugLinks = (function () {
var NOT_DONE_STATUSES = ['UNCONFIRMED', 'NEW', 'ASSIGNED', 'REOPENED'];
var URL = '/buginfo/bug'; // TODO move this outside

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* global Promise, jsSHA */
import jsSHA from 'jssha';

window.correlations = (function () {
/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import '../esm-shim-jquery.js';
import './timeutils.js';
import './nav.js';
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
/* global BugLinks */
import 'jquery-ui/ui/version.js';
import 'jquery-ui/ui/widget.js';
import 'jquery-ui/ui/safe-active-element.js';
import 'jquery-ui/ui/unique-id.js';
import 'jquery-ui/ui/keycode.js';
import 'jquery-ui/ui/widgets/mouse.js';
import 'jquery-ui/ui/widgets/sortable.js';
import 'jquery-ui/ui/widgets/datepicker.js';
import 'jquery-ui/ui/widgets/tabs.js';

import 'tablesorter/dist/js/jquery.tablesorter.js';

import 'jquery.json-viewer/json-viewer/jquery.json-viewer.js';

import { BugLinks } from './bugzilla.js';
import './reprocessing.js';
import './correlation.js';

$(document).ready(function () {
/* Idempotent function to display the TelemetryEnvironment with
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { default as moment } from 'moment';

$(function () {
function replaceTimeTag(inTheFuture) {
return function () {
Expand Down
Loading