Skip to content

Commit b0c6303

Browse files
tech: add minifying, treeshake and replace lodash per lodash-es (treeshake)
1 parent 02e1b69 commit b0c6303

File tree

113 files changed

+882
-2653
lines changed

Some content is hidden

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

113 files changed

+882
-2653
lines changed

frontend/cypress/e2e/main_window/reporting/create_reporting.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { omit } from 'lodash'
1+
import { omit } from 'lodash-es'
22

33
import { FAKE_MAPBOX_RESPONSE } from '../../constants'
44
import { createReporting } from '../../utils/createReporting'

frontend/cypress/e2e/utils/getLastIdFromCollection.ts

Lines changed: 0 additions & 7 deletions
This file was deleted.

frontend/package-lock.json

Lines changed: 688 additions & 2468 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
"@sentry/browser": "8.54.0",
3333
"@sentry/react": "8.54.0",
3434
"@sentry/tracing": "7.120.3",
35-
"@sentry/vite-plugin": "2.22.7",
3635
"@svgr/webpack": "8.1.0",
3736
"@tanstack/react-table": "8.20.6",
3837
"@tanstack/react-virtual": "3.12.0",
@@ -45,7 +44,7 @@
4544
"hammerjs": "2.0.8",
4645
"imask": "7.6.1",
4746
"jsts": "2.12.1",
48-
"lodash": "4.17.21",
47+
"lodash-es": "4.17.21",
4948
"oidc-client-ts": "2.4.1",
5049
"ol": "10.4.0",
5150
"ol-mapbox-style": "12.3.3",
@@ -87,6 +86,7 @@
8786
"@types/google.maps": "3.58.1",
8887
"@types/jest": "29.5.14",
8988
"@types/node": "20.9.0",
89+
"@types/lodash-es": "4.17.12",
9090
"@types/react": "18.3.12",
9191
"@types/react-dom": "18.3.1",
9292
"@typescript-eslint/eslint-plugin": "7.1.0",
@@ -127,6 +127,7 @@
127127
"prettier": "2.7.1",
128128
"puppeteer": "22.12.1",
129129
"ramda": "0.30.1",
130+
"rollup-plugin-visualizer": "5.14.0",
130131
"type-fest": "4.33.0",
131132
"typescript": "5.7.3",
132133
"vite": "6.1.0",

frontend/src/api/googlePlacesAPI/googlePlacesAPI.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import _ from 'lodash'
1+
import { throttle } from 'lodash-es'
22
import { useEffect, useState, useMemo, useRef, type MutableRefObject } from 'react'
33

44
import { loadGoogleMapScript } from './utils'
@@ -52,7 +52,7 @@ export const useGooglePlacesAPI = search => {
5252
}, [])
5353

5454
const throttledSearch = useMemo(() => {
55-
const throttled = _.throttle(
55+
const throttled = throttle(
5656
async query => {
5757
if (abortControlerRef.current) {
5858
abortControlerRef.current.abort()

frontend/src/api/nominatimAPI.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import _ from 'lodash'
1+
import { isEmpty, throttle } from 'lodash-es'
22
import { useEffect, useState, useMemo, useRef, type MutableRefObject } from 'react'
33

44
const NOMINATIM_API_URL = 'https://nominatim.openstreetmap.org/search'
@@ -39,7 +39,7 @@ export const useNominatimAPI = (search, { limit = 10 } = {}) => {
3939
const abortControlerRef = useRef() as MutableRefObject<AbortController>
4040

4141
const throttledSearch = useMemo(() => {
42-
const throttled = _.throttle(
42+
const throttled = throttle(
4343
query => {
4444
if (abortControlerRef.current) {
4545
abortControlerRef.current.abort()
@@ -63,7 +63,7 @@ export const useNominatimAPI = (search, { limit = 10 } = {}) => {
6363

6464
return fetch(queryURL, { signal: abortControlerRef.current.signal })
6565
.then(r => r.json())
66-
.then(data => setResults(_.isEmpty(data) ? [{ display_name: 'Pas de résultats' }] : data))
66+
.then(data => setResults(isEmpty(data) ? [{ display_name: 'Pas de résultats' }] : data))
6767
}
6868

6969
return setResults([])

frontend/src/domain/shared_slices/Administrative.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { createSlice } from '@reduxjs/toolkit'
2-
import _ from 'lodash'
2+
import { concat, uniq, without } from 'lodash-es'
33
import { persistReducer } from 'redux-persist'
44
import storage from 'redux-persist/lib/storage'
55

@@ -22,7 +22,7 @@ const administrativeSlice = createSlice({
2222
* @param {AdministrativeZone} action.payload - The regulatory zone
2323
*/
2424
hideAdministrativeLayer(state, action) {
25-
state.showedAdministrativeLayerIds = _.without(state.showedAdministrativeLayerIds, action.payload)
25+
state.showedAdministrativeLayerIds = without(state.showedAdministrativeLayerIds, action.payload)
2626
},
2727

2828
/**
@@ -33,7 +33,7 @@ const administrativeSlice = createSlice({
3333
* @param {AdministrativeZone} action.payload - The regulatory zone
3434
*/
3535
showAdministrativeLayer(state, action) {
36-
state.showedAdministrativeLayerIds = _.uniq(_.concat(state.showedAdministrativeLayerIds, action.payload))
36+
state.showedAdministrativeLayerIds = uniq(concat(state.showedAdministrativeLayerIds, action.payload))
3737
}
3838
}
3939
})

frontend/src/domain/shared_slices/Amp.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { createSlice } from '@reduxjs/toolkit'
2-
import _ from 'lodash'
2+
import { concat, difference, union, uniq, without } from 'lodash-es'
33
import { persistReducer } from 'redux-persist'
44
import storage from 'redux-persist/lib/storage'
55

@@ -31,8 +31,8 @@ const ampSlice = createSlice({
3131
addAmpZonesToMyLayers(state, action) {
3232
return {
3333
...state,
34-
selectedAmpLayerIds: _.union(state.selectedAmpLayerIds, action.payload),
35-
showedAmpLayerIds: _.union(state.showedAmpLayerIds, action.payload)
34+
selectedAmpLayerIds: union(state.selectedAmpLayerIds, action.payload),
35+
showedAmpLayerIds: union(state.showedAmpLayerIds, action.payload)
3636
}
3737
},
3838

@@ -43,10 +43,10 @@ const ampSlice = createSlice({
4343
* @param {number} action.payload - The amp zone id
4444
*/
4545
hideAmpLayer(state, action) {
46-
state.showedAmpLayerIds = _.without(state.showedAmpLayerIds, action.payload)
46+
state.showedAmpLayerIds = without(state.showedAmpLayerIds, action.payload)
4747
},
4848
hideAmpLayers(state, action) {
49-
state.showedAmpLayerIds = _.without(state.showedAmpLayerIds, ...action.payload)
49+
state.showedAmpLayerIds = without(state.showedAmpLayerIds, ...action.payload)
5050
},
5151

5252
/**
@@ -59,8 +59,8 @@ const ampSlice = createSlice({
5959
removeAmpZonesFromMyLayers(state, action) {
6060
return {
6161
...state,
62-
selectedAmpLayerIds: _.difference(state.selectedAmpLayerIds, action.payload),
63-
showedAmpLayerIds: _.difference(state.showedAmpLayerIds, action.payload)
62+
selectedAmpLayerIds: difference(state.selectedAmpLayerIds, action.payload),
63+
showedAmpLayerIds: difference(state.showedAmpLayerIds, action.payload)
6464
}
6565
},
6666

@@ -71,7 +71,7 @@ const ampSlice = createSlice({
7171
* @param {AmpZone[]} action.payload - The amp zone
7272
*/
7373
showAmpLayer(state, action) {
74-
state.showedAmpLayerIds = _.uniq(_.concat(state.showedAmpLayerIds, action.payload))
74+
state.showedAmpLayerIds = uniq(concat(state.showedAmpLayerIds, action.payload))
7575
}
7676
}
7777
})

frontend/src/domain/shared_slices/MissionFilters.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { customDayjs } from '@mtes-mct/monitor-ui'
22
import { createSlice, type PayloadAction } from '@reduxjs/toolkit'
3-
import { isEqual, omit } from 'lodash'
3+
import { isEqual, omit } from 'lodash-es'
44
import { persistReducer } from 'redux-persist'
55
import storage from 'redux-persist/lib/storage'
66

frontend/src/domain/shared_slices/Regulatory.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { createSlice, type PayloadAction } from '@reduxjs/toolkit'
2-
import _ from 'lodash'
2+
import { concat, difference, union, uniq, without } from 'lodash-es'
33
import { persistReducer } from 'redux-persist'
44
import storage from 'redux-persist/lib/storage'
55

@@ -31,8 +31,8 @@ const regulatorySlice = createSlice({
3131
addRegulatoryZonesToMyLayers(state, action: PayloadAction<number[]>) {
3232
return {
3333
...state,
34-
selectedRegulatoryLayerIds: _.union(state.selectedRegulatoryLayerIds, action.payload),
35-
showedRegulatoryLayerIds: _.union(state.showedRegulatoryLayerIds, action.payload)
34+
selectedRegulatoryLayerIds: union(state.selectedRegulatoryLayerIds, action.payload),
35+
showedRegulatoryLayerIds: union(state.showedRegulatoryLayerIds, action.payload)
3636
}
3737
},
3838

@@ -43,10 +43,10 @@ const regulatorySlice = createSlice({
4343
* @param {number} action.payload - The regulatory zone id
4444
*/
4545
hideRegulatoryLayer(state, action: PayloadAction<number>) {
46-
state.showedRegulatoryLayerIds = _.without(state.showedRegulatoryLayerIds, action.payload)
46+
state.showedRegulatoryLayerIds = without(state.showedRegulatoryLayerIds, action.payload)
4747
},
4848
hideRegulatoryLayers(state, action: PayloadAction<number[]>) {
49-
state.showedRegulatoryLayerIds = _.without(state.showedRegulatoryLayerIds, ...action.payload)
49+
state.showedRegulatoryLayerIds = without(state.showedRegulatoryLayerIds, ...action.payload)
5050
},
5151

5252
/**
@@ -59,13 +59,13 @@ const regulatorySlice = createSlice({
5959
removeRegulatoryZonesFromMyLayers(state, action: PayloadAction<number[]>) {
6060
return {
6161
...state,
62-
selectedRegulatoryLayerIds: _.difference(state.selectedRegulatoryLayerIds, action.payload),
63-
showedRegulatoryLayerIds: _.difference(state.showedRegulatoryLayerIds, action.payload)
62+
selectedRegulatoryLayerIds: difference(state.selectedRegulatoryLayerIds, action.payload),
63+
showedRegulatoryLayerIds: difference(state.showedRegulatoryLayerIds, action.payload)
6464
}
6565
},
6666

6767
showRegulatoryLayer(state, action: PayloadAction<number | number[]>) {
68-
state.showedRegulatoryLayerIds = _.uniq(_.concat(state.showedRegulatoryLayerIds, action.payload))
68+
state.showedRegulatoryLayerIds = uniq(concat(state.showedRegulatoryLayerIds, action.payload))
6969
}
7070
}
7171
})

0 commit comments

Comments
 (0)