Merge pull request #2483 from overleaf/as-switch-frontend-to-lodash

Switch frontend from underscore to lodash

GitOrigin-RevId: 7fbc72d2ead6a14ff04f085f01fff5a3dddb77f0
This commit is contained in:
Timothée Alby 2020-01-07 12:04:04 +01:00 committed by Copybot
parent b1db115427
commit b185e60749
8 changed files with 10 additions and 1714 deletions

View file

@ -6,12 +6,9 @@
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
const version = {
pdfjs: '2.0.943',
moment: '2.9.0',
ace: '1.4.5', // Upgrade instructions: https://github.com/overleaf/write_latex/wiki/Upgrading-Ace
fineuploader: '5.15.4',
// For frontend. Backend has a different version defined in package.json
underscore: '1.9.1',
algolia: '2.5.2'
}

View file

@ -53,13 +53,13 @@ define(['ace/ace'], function() {
}
const commandFragment = getLastCommandFragment(lineUpToCursor)
const linesContainPackage = _.any(change.lines, line =>
const linesContainPackage = _.some(change.lines, line =>
line.match(/^\\usepackage(?:\[.{0,80}?])?{(.{0,80}?)}/)
)
const linesContainReqPackage = _.any(change.lines, line =>
const linesContainReqPackage = _.some(change.lines, line =>
line.match(/^\\RequirePackage(?:\[.{0,80}?])?{(.{0,80}?)}/)
)
const linesContainLabel = _.any(change.lines, line =>
const linesContainLabel = _.some(change.lines, line =>
line.match(/\\label{(.{0,80}?)}/)
)
const linesContainMeta =

View file

@ -38,7 +38,7 @@ define(['base'], App =>
}
metadata.getAllLabels = () =>
_.flatten(
_.flattenDeep(
(() => {
const result = []
for (let docId in state.documents) {

View file

@ -2,10 +2,10 @@ define([
'jquery',
'angular',
'angular-sanitize',
'lodash',
'libs/angular-autocomplete/angular-autocomplete',
'libs/ui-bootstrap',
'libs/ng-context-menu-0.1.4',
'libs/underscore-1.9.1',
'libs/algolia-2.5.2',
'libs/jquery.storage',
'libs/angular-cookie',

View file

@ -21,7 +21,7 @@ define(['base'], App =>
const regexBySpaceOrComma = /[\s,]+/
let emails = emailsString.split(regexBySpaceOrComma)
emails = _.map(emails, email => (email = email.trim()))
emails = _.select(emails, email => email.indexOf('@') !== -1)
emails = _.filter(emails, email => email.indexOf('@') !== -1)
return emails
}

View file

@ -36,7 +36,7 @@ define(['base'], function(App) {
const regexBySpaceOrComma = /[\s,]+/
let emails = emailsString.split(regexBySpaceOrComma)
emails = _.map(emails, email => (email = email.trim()))
emails = _.select(emails, email => email.indexOf('@') !== -1)
emails = _.filter(emails, email => email.indexOf('@') !== -1)
return emails
}

File diff suppressed because it is too large Load diff

View file

@ -167,11 +167,8 @@ module.exports = {
]
},
{
// Expose underscore global variable
test: path.join(
__dirname,
`frontend/js/vendor/libs/${PackageVersions.lib('underscore')}.js`
),
// Expose lodash global variable
test: require.resolve('lodash'),
use: [
{
loader: 'expose-loader',
@ -274,11 +271,5 @@ module.exports = {
// to provide support for non-Latin characters
{ from: 'node_modules/pdfjs-dist/cmaps', to: 'js/cmaps' }
])
],
// If underscore is required by another dependency *don't* include in the
// bundle and use the relevant global variable instead
externals: {
underscore: '_'
}
]
}