Merge pull request #2531 from overleaf/ho-restore-lodash-2526

Revert "Reverts move from underscore to lodash"

GitOrigin-RevId: 1ea964d5c98a85f9490c0e731d6a68335df93c67
This commit is contained in:
Henry Oswald 2020-01-16 13:09:47 +00:00 committed by Copybot
parent 94e3051d2e
commit fe8ef3f08f
8 changed files with 11 additions and 1714 deletions

View file

@ -7,9 +7,7 @@
*/ */
const version = { const version = {
ace: '1.4.5', // Upgrade instructions: https://github.com/overleaf/write_latex/wiki/Upgrading-Ace ace: '1.4.5', // Upgrade instructions: https://github.com/overleaf/write_latex/wiki/Upgrading-Ace
fineuploader: '5.15.4', fineuploader: '5.15.4'
// For frontend. Backend has a different version defined in package.json
underscore: '1.9.1'
} }
module.exports = { module.exports = {

View file

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

View file

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

View file

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

View file

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

View file

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

File diff suppressed because it is too large Load diff

View file

@ -167,11 +167,8 @@ module.exports = {
] ]
}, },
{ {
// Expose underscore global variable // Expose lodash global variable
test: path.join( test: require.resolve('lodash'),
__dirname,
`frontend/js/vendor/libs/${PackageVersions.lib('underscore')}.js`
),
use: [ use: [
{ {
loader: 'expose-loader', loader: 'expose-loader',
@ -257,11 +254,5 @@ module.exports = {
// to provide support for non-Latin characters // to provide support for non-Latin characters
{ from: 'node_modules/pdfjs-dist/cmaps', to: 'js/cmaps' } { 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: '_'
}
} }