feat: lighter build by rewriting lodash imports (#1772)

Incorrect lodash imports are causing MFEs to import the entire lodash
library. This change shaves off a few kB of the compressed build.
This commit is contained in:
Régis Behmo
2025-04-16 02:07:16 +02:00
committed by GitHub
parent f531d5471d
commit 4bd2c3b29a
20 changed files with 126 additions and 118 deletions

View File

@@ -1,6 +1,6 @@
import React from 'react';
import PropTypes from 'prop-types';
import _ from 'lodash';
import last from 'lodash/last';
import { useParams } from 'react-router-dom';
import { FormattedMessage, useIntl } from '@edx/frontend-platform/i18n';
import { FileUpload as FileUploadIcon } from '@openedx/paragon/icons';
@@ -35,9 +35,9 @@ const CourseUploadImage = ({
const assetsUrl = () => new URL(`/assets/${courseId}`, getConfig().STUDIO_BASE_URL);
const handleChangeImageAsset = (path) => {
const assetPath = _.last(path.split('/'));
const assetPath = last(path.split('/'));
// If image path is entered directly, we need to strip the asset prefix
const imageName = _.last(assetPath.split('block@'));
const imageName = last(assetPath.split('block@'));
onChange(path, assetImageField);
if (imageNameField) {
onChange(imageName, imageNameField);