Skip to content

Commit e9a075c

Browse files
fix: OPTIC-945: Improve the bundling strategy and ship a single entrypoint with a common vendor chunk across all libs - restore (#6199)
Co-authored-by: yyassi-heartex <[email protected]> Co-authored-by: Brandon Martel <[email protected]>
1 parent fc05a9b commit e9a075c

File tree

369 files changed

+562771
-9961
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

369 files changed

+562771
-9961
lines changed

deploy/default.conf

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -120,18 +120,6 @@ http {
120120
alias /label-studio/label_studio/core/static_build/;
121121
}
122122

123-
# Frontend react
124-
# Source: https://github.com/heartexlabs/label-studio-frontend
125-
location /label-studio-frontend/ {
126-
alias /label-studio/web/dist/libs/editor/;
127-
}
128-
129-
# Data Manager
130-
# Source: https://github.com/heartexlabs/dm2
131-
location /dm/ {
132-
alias /label-studio/web/dist/libs/datamanager/;
133-
}
134-
135123
# LabelStudio frontend
136124
# Source: https://github.com/heartexlabs/label-studio/blob/HEAD/label_studio/frontend/src
137125
location /react-app/ {

label_studio/core/feature_flags/stale_feature_flags.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,5 @@
5959
'ff_dev_2007_rework_choices_280322_short': True,
6060
'ff_front_dev_1495_avatar_mess_210122_short': True,
6161
'ff_front_1170_outliner_030222_short': True,
62+
'fflag_fix_front_lsdv_4620_memory_leaks_100723_short': False,
6263
}

label_studio/core/utils/common.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -207,20 +207,6 @@ def paginator_help(objects_name, tag):
207207
)
208208

209209

210-
def find_editor_files():
211-
"""Find label studio files"""
212-
213-
# playground uses another LSF build
214-
prefix = '/label-studio/'
215-
editor_dir = settings.EDITOR_ROOT
216-
217-
# find editor files to include in html
218-
editor_js = [prefix + f for f in os.listdir(editor_dir) if f.endswith('.js')]
219-
editor_css = [prefix + f for f in os.listdir(editor_dir) if f.endswith('.css')]
220-
221-
return {'editor_js': editor_js, 'editor_css': editor_css}
222-
223-
224210
def string_is_url(url):
225211
try:
226212
url_validator(url)

label_studio/data_manager/views.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
"""This file and its contents are licensed under the Apache License 2.0. Please see the included NOTICE for copyright information and LICENSE for a copy of the license.
22
"""
3-
from core.utils.common import find_editor_files
43
from core.version import get_short_version
54
from django.contrib.auth.decorators import login_required
65
from django.shortcuts import render
@@ -9,5 +8,4 @@
98
@login_required
109
def task_page(request, pk):
1110
response = {'version': get_short_version()}
12-
response.update(find_editor_files())
1311
return render(request, 'base.html', response)

label_studio/feature_flags.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4027,7 +4027,7 @@
40274027
},
40284028
"fflag_fix_front_lsdv_4620_memory_leaks_100723_short": {
40294029
"key": "fflag_fix_front_lsdv_4620_memory_leaks_100723_short",
4030-
"on": true,
4030+
"on": false,
40314031
"prerequisites": [],
40324032
"targets": [],
40334033
"contextTargets": [],

label_studio/templates/base.html

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,19 @@
1616
<meta name="msapplication-navbutton-color" content="#272727"> <!-- Windows Phone -->
1717
<meta name="apple-mobile-web-app-status-bar-style" content="#272727"> <!-- iOS Safari -->
1818

19+
<!-- Preload fonts -->
20+
<link rel="preload" href="{{settings.HOSTNAME}}{% static 'fonts/Figtree-Regular.ttf' %}" type="font" crossorigin="anonymous">
21+
<link rel="preload" href="{{settings.HOSTNAME}}{% static 'fonts/Figtree-SemiBold.ttf' %}" type="font" crossorigin="anonymous">
22+
23+
<!-- CSS -->
1924
<link href="{{settings.HOSTNAME}}{% static 'images/favicon.ico' %}" rel="shortcut icon"/>
2025
<link href="{{settings.HOSTNAME}}{% static 'css/uikit.css' %}" rel="stylesheet">
2126
<link href="{{settings.HOSTNAME}}{% static 'css/main.css' %}" rel="stylesheet">
22-
<link href="{{settings.HOSTNAME}}/static/fonts/roboto/roboto.css" rel="stylesheet">
2327
<link href="{{settings.HOSTNAME}}/react-app/main.css?v={{ versions.backend.commit }}" rel="stylesheet">
2428

25-
<script src="{{settings.HOSTNAME}}{% static 'js/jquery.min.js' %}"></script>
26-
<script src="{{settings.HOSTNAME}}{% static 'js/helpers.js' %}"></script>
27-
2829
{% block app-scripts %}
29-
<script nonce="{{request.csp_nonce}}">
30-
EDITOR_JS = `{{settings.HOSTNAME}}/label-studio-frontend/main.js?v={{ versions.lsf.commit }}`;
31-
EDITOR_CSS = `{{settings.HOSTNAME}}/label-studio-frontend/main.css?v={{ versions.lsf.commit }}`;
32-
DM_JS = `{{settings.HOSTNAME}}/dm/main.js?v={{ versions.dm2.commit }}`;
33-
DM_CSS = `{{settings.HOSTNAME}}/dm/main.css?v={{ versions.dm2.commit }}`;
34-
</script>
3530
{% endblock %}
3631

37-
3832
<script
3933
src="https://browser.sentry-cdn.com/5.17.0/bundle.min.js"
4034
integrity="sha384-lowBFC6YTkvMIWPORr7+TERnCkZdo5ab00oH5NkFLeQUAmBTLGwJpFjF6djuxJ/5"
@@ -49,7 +43,6 @@
4943
{% endblock %}
5044

5145
{% block head-toast %}
52-
<script src="{{settings.HOSTNAME}}{% static 'js/Toast.min.js' %}"></script>
5346
<link href="{{settings.HOSTNAME}}{% static 'css/Toast.min.css' %}" rel="stylesheet">
5447
{% endblock %}
5548

@@ -119,21 +112,29 @@
119112
</script>
120113

121114
{% block app-js %}
115+
<script src="{{settings.HOSTNAME}}/react-app/runtime.js?v={{ versions.backend.commit }}"></script>
116+
{% comment %}
117+
NOTE: purposely setting this to not cache using backend commit as we do not intend this to change frequently.
118+
If for any reason we need to invalidate the cache, we can do so by changing the version number.
119+
{% endcomment %}
120+
<script src="{{settings.HOSTNAME}}/react-app/vendor.js?v=1"></script>
122121
<script src="{{settings.HOSTNAME}}/react-app/main.js?v={{ versions.backend.commit }}"></script>
123122
{% endblock %}
124123

125-
<div id="dynamic-content">
124+
{% block bottomjs %}
125+
<script src="{{settings.HOSTNAME}}{% static 'js/jquery.min.js' %}"></script>
126+
<script src="{{settings.HOSTNAME}}{% static 'js/helpers.js' %}"></script>
127+
<script src="{{settings.HOSTNAME}}{% static 'js/Toast.min.js' %}"></script>
126128
<script nonce="{{request.csp_nonce}}">
127129
applyCsrf();
128130

129131
$('.message .close').on('click', function () {
130132
$(this).closest('.message').transition('fade');
131133
});
132134
</script>
135+
{% endblock %}
133136

134-
{% block bottomjs %}
135-
{% endblock %}
136-
137+
<div id="dynamic-content">
137138
{% block storage-persistence %}
138139
<script nonce="{{request.csp_nonce}}">
139140
{# storage persistence #}

label_studio/users/templates/users/new-ui/user_login.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ <h2>Log in</h2>
77
{% csrf_token %}
88
<div class="input-wrapper">
99
<label>Email Address</label>
10-
<input type="text" class="ls-input" name="email" id="email" value="{{ form.data.email }}">
10+
<input type="text" class="lsf-input-ls" name="email" id="email" value="{{ form.data.email }}">
1111
</div>
1212
<div class="input-wrapper">
1313
<label>Password</label>
14-
<input type="password" class="ls-input" name="password" id="password">
14+
<input type="password" class="lsf-input-ls" name="password" id="password">
1515
</div>
1616
{% if form.non_field_errors %}
1717
{% for error in form.non_field_errors %}
@@ -21,10 +21,10 @@ <h2>Log in</h2>
2121
{% endfor %}
2222
{% endif %}
2323
<div class="form-group">
24-
<input type="checkbox" id="persist_session" name="persist_session" class="ls-checkbox" checked="checked" style="width: auto;" />
24+
<input type="checkbox" id="persist_session" name="persist_session" class="lsf-checkbox-ls" checked="checked" style="width: auto;" />
2525
<label for="persist_session">Keep me logged in this browser</label>
2626
</div>
27-
<button type="submit" aria-label="Log In" class="ls-button ls-button_look_primary">Log in</button>
27+
<button type="submit" aria-label="Log In" class="lsf-button-ls lsf-button-ls_look_primary">Log in</button>
2828
</form>
2929
</div>
3030
{% if not settings.DISABLE_SIGNUP_WITHOUT_LINK %}

label_studio/users/templates/users/new-ui/user_signup.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ <h2>Sign Up</h2>
1111
{% csrf_token %}
1212
<div class="input-wrapper">
1313
<label>Email Address</label>
14-
<input type="text" class="ls-input" name="email" id="email" value="{{ form.data.email }}">
14+
<input type="text" class="lsf-input-ls" name="email" id="email" value="{{ form.data.email }}">
1515
{% if user_form.errors.email %}
1616
<ul class="field_errors">
1717
{% for error in user_form.errors.email %}
@@ -22,7 +22,7 @@ <h2>Sign Up</h2>
2222
</div>
2323
<div class="input-wrapper">
2424
<label>Password</label>
25-
<input type="password" class="ls-input" name="password" id="password">
25+
<input type="password" class="lsf-input-ls" name="password" id="password">
2626
{% if user_form.errors.password %}
2727
<ul class="field_errors">
2828
{% for error in user_form.errors.password %}
@@ -33,7 +33,7 @@ <h2>Sign Up</h2>
3333
</div>
3434
<div class="form-group">
3535
<input name="allow_newsletters" id="allow_newsletters" type="hidden" value="true">
36-
<input name="allow_newsletters_visual" id="allow_newsletters_visual" class="ls-checkbox"
36+
<input name="allow_newsletters_visual" id="allow_newsletters_visual" class="lsf-checkbox-ls"
3737
type="checkbox" style="width: auto" checked="true"
3838
onchange="document.getElementById('allow_newsletters').value=document.getElementById('allow_newsletters_visual').checked">
3939
<label for="allow_newsletters_visual" style="display: inline-block; cursor: pointer;">
@@ -50,7 +50,7 @@ <h2>Sign Up</h2>
5050
</p>
5151
{% endfor %}
5252
{% endif %}
53-
<p><button type="submit" aria-label="Create Account" class="ls-button ls-button_look_primary">Create Account</button></p>
53+
<p><button type="submit" aria-label="Create Account" class="lsf-button-ls lsf-button-ls_look_primary">Create Account</button></p>
5454
</form>
5555
</div>
5656
<div class="text-wrapper">

label_studio/users/templates/users/user_account.html

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,19 @@
3131
<ul>
3232
<li class="field">
3333
<label for="">E-mail</label>
34-
<input type="text" class="ls-input" value="{{user.email}}" disabled />
34+
<input type="text" class="lsf-input-ls" value="{{user.email}}" disabled />
3535
</li>
3636
<li class="field">
3737
<label for="">First Name</label>
38-
<input type="text" class="ls-input" name="first_name" value="{{user.first_name}}" />
38+
<input type="text" class="lsf-input-ls" name="first_name" value="{{user.first_name}}" />
3939
</li>
4040
<li class="field">
4141
<label for="">Last Name</label>
42-
<input type="text" class="ls-input" name="last_name" value="{{user.last_name}}" />
42+
<input type="text" class="lsf-input-ls" name="last_name" value="{{user.last_name}}" />
4343
</li>
4444
<li class="field">
4545
<label for="">Phone</label>
46-
<input type="text" class="ls-input" name="phone" value="{{user.phone}}" />
46+
<input type="text" class="lsf-input-ls" name="phone" value="{{user.phone}}" />
4747
<!-- <span>We'll send you sms with code if you change your number</span>
4848
<span class="error">Incorrect phone number!</span> -->
4949
</li>
@@ -63,7 +63,7 @@
6363
{% endif %}
6464
</div>
6565

66-
<button class="ls-button ls-button_look_danger" name="delete-avatar" type="button">
66+
<button class="lsf-button-ls lsf-button-ls_look_danger" name="delete-avatar" type="button">
6767
Delete
6868
</button>
6969

@@ -78,7 +78,7 @@
7878
</div>
7979
<footer>
8080
<p class="secondary">Registered {{ user.date_joined|date:"M j, Y" }}, user ID {{ user.id }}</p>
81-
<button class="ls-button ls-button_look_primary" onclick="smart_submit()">Save</button>
81+
<button class="lsf-button-ls lsf-button-ls_look_primary" onclick="smart_submit()">Save</button>
8282
</footer>
8383
</form>
8484

@@ -87,10 +87,10 @@
8787
<header>Access Token</header>
8888
<div class="field field--wide">
8989
<label for="access_token">Use this token to authenticate with our API:</label>
90-
<input id="access_token" class="ls-input" name="access_token" type="text" value="{{token}}" readonly />
90+
<input id="access_token" class="lsf-input-ls" name="access_token" type="text" value="{{token}}" readonly />
9191
<p class="actions">
92-
<button type="button" class="blinking-status ls-button" data-copy="access_token">Copy</button>
93-
<button type="button" class="blinking-status ls-button" name="renew">Renew</button>
92+
<button type="button" class="blinking-status lsf-button-ls" data-copy="access_token">Copy</button>
93+
<button type="button" class="blinking-status lsf-button-ls" name="renew">Renew</button>
9494
</p>
9595
</div>
9696
<!-- Example -->
@@ -105,8 +105,8 @@
105105
{% endif %}
106106
</textarea>
107107
<p class="actions">
108-
<button type="button" class="blinking-status ls-button" data-copy="example_fetch">Copy</button>
109-
<a class="ls-button"
108+
<button type="button" class="blinking-status lsf-button-ls" data-copy="example_fetch">Copy</button>
109+
<a class="lsf-button-ls"
110110
{% if settings.VERSION_EDITION == 'Enterprise' %}
111111
href="https://docs.heartex.com/guide/api.html"
112112
{% else %}

label_studio/users/templates/users/user_login.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
{% block user_content %}
44
<form id="login-form" action="{% url 'user-login' %}{% if next %}?next={{ next }}{% endif %}" method="post">
55
{% csrf_token %}
6-
<p><input type="text" class="ls-input" name="email" id="email" placeholder="Email" value="{{ form.data.email }}"></p>
7-
<p><input type="password" class="ls-input" name="password" id="password" placeholder="Password"></p>
6+
<p><input type="text" class="lsf-input-ls" name="email" id="email" placeholder="Email" value="{{ form.data.email }}"></p>
7+
<p><input type="password" class="lsf-input-ls" name="password" id="password" placeholder="Password"></p>
88
{% if form.non_field_errors %}
99
{% for error in form.non_field_errors %}
1010
<p class="error">
@@ -13,10 +13,10 @@
1313
{% endfor %}
1414
{% endif %}
1515
<p>
16-
<input type="checkbox" id="persist_session" name="persist_session" class="ls-checkbox" checked="checked" style="width: auto;" />
16+
<input type="checkbox" id="persist_session" name="persist_session" class="lsf-checkbox-ls" checked="checked" style="width: auto;" />
1717
<label for="persist_session">Keep me logged in this browser</label>
1818
</p>
19-
<p><button type="submit" aria-label="Log In" class="ls-button ls-button_look_primary">Log in</button></p>
19+
<p><button type="submit" aria-label="Log In" class="lsf-button-ls lsf-button-ls_look_primary">Log in</button></p>
2020
</form>
2121

2222
{% endblock %}

label_studio/users/templates/users/user_signup.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
>
1010
{% csrf_token %}
1111
<div>
12-
<input type="text" class="ls-input" name="email" id="email" placeholder="Email" value="{{ form.data.email }}">
12+
<input type="text" class="lsf-input-ls" name="email" id="email" placeholder="Email" value="{{ form.data.email }}">
1313
{% if user_form.errors.email %}
1414
<ul class="field_errors">
1515
{% for error in user_form.errors.email %}
@@ -19,7 +19,7 @@
1919
{% endif %}
2020
</div>
2121
<div>
22-
<input type="password" class="ls-input" name="password" id="password" placeholder="Password">
22+
<input type="password" class="lsf-input-ls" name="password" id="password" placeholder="Password">
2323
{% if user_form.errors.password %}
2424
<ul class="field_errors">
2525
{% for error in user_form.errors.password %}
@@ -50,7 +50,7 @@
5050
</p>
5151
{% endfor %}
5252
{% endif %}
53-
<p><button type="submit" aria-label="Create Account" class="ls-button ls-button_look_primary">Create Account</button></p>
53+
<p><button type="submit" aria-label="Create Account" class="lsf-button-ls lsf-button-ls_look_primary">Create Account</button></p>
5454
</form>
5555

5656
{% endblock %}

web/apps/labelstudio/src/app/App.jsx

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import { initSentry } from "../config/Sentry";
99
import { ApiProvider } from "../providers/ApiProvider";
1010
import { AppStoreProvider } from "../providers/AppStoreProvider";
1111
import { ConfigProvider } from "../providers/ConfigProvider";
12-
import { LibraryProvider } from "../providers/LibraryProvider";
1312
import { MultiProvider } from "../providers/MultiProvider";
1413
import { ProjectProvider } from "../providers/ProjectProvider";
1514
import { RoutesProvider } from "../providers/RoutesProvider";
@@ -52,19 +51,6 @@ window.LSH = browserHistory;
5251
initSentry(browserHistory);
5352

5453
const App = ({ content }) => {
55-
const libraries = {
56-
lsf: {
57-
scriptSrc: window.EDITOR_JS,
58-
cssSrc: window.EDITOR_CSS,
59-
checkAvailability: () => !!window.LabelStudio,
60-
},
61-
dm: {
62-
scriptSrc: window.DM_JS,
63-
cssSrc: window.DM_CSS,
64-
checkAvailability: () => !!window.DataManager,
65-
},
66-
};
67-
6854
return (
6955
<ErrorBoundary>
7056
<Router history={browserHistory}>
@@ -73,7 +59,6 @@ const App = ({ content }) => {
7359
<AppStoreProvider key="app-store" />,
7460
<ApiProvider key="api" />,
7561
<ConfigProvider key="config" />,
76-
<LibraryProvider key="lsf" libraries={libraries} />,
7762
<RoutesProvider key="rotes" />,
7863
<ProjectProvider key="project" />,
7964
<ToastProvider key="toast" />,

web/apps/labelstudio/src/components/Button/Button.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export const Button = React.forwardRef(
4747
}, [icon, size]);
4848

4949
return (
50-
<Block name="button" mod={mods} mix={className} ref={ref} tag={finalTag} type={type} {...rest}>
50+
<Block name="button-ls" mod={mods} mix={className} ref={ref} tag={finalTag} type={type} {...rest}>
5151
<>
5252
{iconElem && (
5353
<Elem tag="span" name="icon">
@@ -65,7 +65,7 @@ Button.displayName = "Button";
6565

6666
Button.Group = ({ className, children, collapsed }) => {
6767
return (
68-
<Block name="button-group" mod={{ collapsed }} mix={className}>
68+
<Block name="button-group-ls" mod={{ collapsed }} mix={className}>
6969
{children}
7070
</Block>
7171
);

0 commit comments

Comments
 (0)