From 0656b95c054e94fc5ce0011c424482638bc7aa57 Mon Sep 17 00:00:00 2001 From: R Date: Wed, 11 Jan 2023 18:40:47 +0700 Subject: [PATCH 1/4] Migrate all lodash' per-method-packages usage to lodash. --- packages/@uppy/companion/package.json | 5 ++-- packages/@uppy/companion/src/companion.js | 2 +- .../@uppy/companion/src/server/Uploader.js | 2 +- .../@uppy/companion/src/standalone/helper.js | 2 +- packages/@uppy/core/package.json | 2 +- packages/@uppy/core/src/Uppy.js | 2 +- packages/@uppy/dashboard/package.json | 2 +- .../dashboard/src/utils/createSuperFocus.js | 2 +- packages/@uppy/golden-retriever/package.json | 2 +- packages/@uppy/golden-retriever/src/index.js | 2 +- packages/@uppy/status-bar/package.json | 2 +- packages/@uppy/status-bar/src/Components.jsx | 2 +- packages/@uppy/utils/package.json | 2 +- yarn.lock | 27 +++++++++---------- 14 files changed, 26 insertions(+), 30 deletions(-) diff --git a/packages/@uppy/companion/package.json b/packages/@uppy/companion/package.json index acd232e068..d29006cb8c 100644 --- a/packages/@uppy/companion/package.json +++ b/packages/@uppy/companion/package.json @@ -49,8 +49,7 @@ "helmet": "^4.6.0", "ipaddr.js": "^2.0.1", "jsonwebtoken": "8.5.1", - "lodash.merge": "^4.6.2", - "lodash.throttle": "^4.1.1", + "lodash": "^4.17.21", "mime-types": "2.1.35", "moment": "^2.29.2", "moment-timezone": "^0.5.31", @@ -74,7 +73,7 @@ "@types/eslint": "^8.2.0", "@types/express-session": "1.17.3", "@types/jsonwebtoken": "8.3.7", - "@types/lodash.merge": "4.6.6", + "@types/lodash": "4.14.191", "@types/morgan": "1.7.37", "@types/ms": "0.7.31", "@types/node": "^18.0.3", diff --git a/packages/@uppy/companion/src/companion.js b/packages/@uppy/companion/src/companion.js index 03ca93e7e1..3209e96f51 100644 --- a/packages/@uppy/companion/src/companion.js +++ b/packages/@uppy/companion/src/companion.js @@ -1,6 +1,6 @@ const express = require('express') const Grant = require('grant').express() -const merge = require('lodash.merge') +const merge = require('lodash/merge') const cookieParser = require('cookie-parser') const interceptor = require('express-interceptor') const { randomUUID } = require('node:crypto') diff --git a/packages/@uppy/companion/src/server/Uploader.js b/packages/@uppy/companion/src/server/Uploader.js index 37051f7ff3..fff90770d2 100644 --- a/packages/@uppy/companion/src/server/Uploader.js +++ b/packages/@uppy/companion/src/server/Uploader.js @@ -8,7 +8,7 @@ const { join } = require('node:path') const fs = require('node:fs') const { promisify } = require('node:util') const FormData = require('form-data') -const throttle = require('lodash.throttle') +const throttle = require('lodash/throttle') // TODO move to `require('streams/promises').pipeline` when dropping support for Node.js 14.x. const pipeline = promisify(pipelineCb) diff --git a/packages/@uppy/companion/src/standalone/helper.js b/packages/@uppy/companion/src/standalone/helper.js index 5d8df6b524..3a00066594 100644 --- a/packages/@uppy/companion/src/standalone/helper.js +++ b/packages/@uppy/companion/src/standalone/helper.js @@ -1,5 +1,5 @@ const fs = require('node:fs') -const merge = require('lodash.merge') +const merge = require('lodash/merge') const stripIndent = require('common-tags/lib/stripIndent') const crypto = require('node:crypto') diff --git a/packages/@uppy/core/package.json b/packages/@uppy/core/package.json index 4061e38afd..b55189b124 100644 --- a/packages/@uppy/core/package.json +++ b/packages/@uppy/core/package.json @@ -24,7 +24,7 @@ "@transloadit/prettier-bytes": "0.0.9", "@uppy/store-default": "workspace:^", "@uppy/utils": "workspace:^", - "lodash.throttle": "^4.1.1", + "lodash": "^4.17.21", "mime-match": "^1.0.2", "namespace-emitter": "^2.0.1", "nanoid": "^4.0.0", diff --git a/packages/@uppy/core/src/Uppy.js b/packages/@uppy/core/src/Uppy.js index f16d30c39e..547bc115d8 100644 --- a/packages/@uppy/core/src/Uppy.js +++ b/packages/@uppy/core/src/Uppy.js @@ -4,7 +4,7 @@ import Translator from '@uppy/utils/lib/Translator' import ee from 'namespace-emitter' import { nanoid } from 'nanoid/non-secure' -import throttle from 'lodash.throttle' +import throttle from 'lodash/throttle' import DefaultStore from '@uppy/store-default' import getFileType from '@uppy/utils/lib/getFileType' import getFileNameAndExtension from '@uppy/utils/lib/getFileNameAndExtension' diff --git a/packages/@uppy/dashboard/package.json b/packages/@uppy/dashboard/package.json index 038f78bbb7..a433ae6093 100644 --- a/packages/@uppy/dashboard/package.json +++ b/packages/@uppy/dashboard/package.json @@ -31,7 +31,7 @@ "@uppy/utils": "workspace:^", "classnames": "^2.2.6", "is-shallow-equal": "^1.0.1", - "lodash.debounce": "^4.0.8", + "lodash": "^4.17.21", "memoize-one": "^6.0.0", "nanoid": "^4.0.0", "preact": "^10.5.13" diff --git a/packages/@uppy/dashboard/src/utils/createSuperFocus.js b/packages/@uppy/dashboard/src/utils/createSuperFocus.js index ee76eeb1a5..382e2ec9f3 100644 --- a/packages/@uppy/dashboard/src/utils/createSuperFocus.js +++ b/packages/@uppy/dashboard/src/utils/createSuperFocus.js @@ -1,4 +1,4 @@ -import debounce from 'lodash.debounce' +import debounce from 'lodash/debounce' import FOCUSABLE_ELEMENTS from '@uppy/utils/lib/FOCUSABLE_ELEMENTS' import getActiveOverlayEl from './getActiveOverlayEl.js' diff --git a/packages/@uppy/golden-retriever/package.json b/packages/@uppy/golden-retriever/package.json index ff4fe9b09d..70b87c8e37 100644 --- a/packages/@uppy/golden-retriever/package.json +++ b/packages/@uppy/golden-retriever/package.json @@ -26,7 +26,7 @@ "dependencies": { "@transloadit/prettier-bytes": "0.0.9", "@uppy/utils": "workspace:^", - "lodash.throttle": "^4.1.1" + "lodash": "^4.17.21" }, "peerDependencies": { "@uppy/core": "workspace:^" diff --git a/packages/@uppy/golden-retriever/src/index.js b/packages/@uppy/golden-retriever/src/index.js index 32e18b0177..61f0dad464 100644 --- a/packages/@uppy/golden-retriever/src/index.js +++ b/packages/@uppy/golden-retriever/src/index.js @@ -1,4 +1,4 @@ -import throttle from 'lodash.throttle' +import throttle from 'lodash/throttle' import BasePlugin from '@uppy/core/lib/BasePlugin.js' import ServiceWorkerStore from './ServiceWorkerStore.js' import IndexedDBStore from './IndexedDBStore.js' diff --git a/packages/@uppy/status-bar/package.json b/packages/@uppy/status-bar/package.json index f9adffe80d..c58bfc5ad0 100644 --- a/packages/@uppy/status-bar/package.json +++ b/packages/@uppy/status-bar/package.json @@ -30,7 +30,7 @@ "@transloadit/prettier-bytes": "0.0.9", "@uppy/utils": "workspace:^", "classnames": "^2.2.6", - "lodash.throttle": "^4.1.1", + "lodash": "^4.17.21", "preact": "^10.5.13" }, "peerDependencies": { diff --git a/packages/@uppy/status-bar/src/Components.jsx b/packages/@uppy/status-bar/src/Components.jsx index 8667f5d2ec..f8004ca6d3 100644 --- a/packages/@uppy/status-bar/src/Components.jsx +++ b/packages/@uppy/status-bar/src/Components.jsx @@ -1,6 +1,6 @@ import { h } from 'preact' import classNames from 'classnames' -import throttle from 'lodash.throttle' +import throttle from 'lodash/throttle' import prettierBytes from '@transloadit/prettier-bytes' import prettyETA from '@uppy/utils/lib/prettyETA' diff --git a/packages/@uppy/utils/package.json b/packages/@uppy/utils/package.json index 7cf39a4062..07a6883f3b 100644 --- a/packages/@uppy/utils/package.json +++ b/packages/@uppy/utils/package.json @@ -64,7 +64,7 @@ "./src/microtip.scss": "./src/microtip.scss" }, "dependencies": { - "lodash.throttle": "^4.1.1" + "lodash": "^4.17.21" }, "devDependencies": { "@jest/globals": "^29.0.0" diff --git a/yarn.lock b/yarn.lock index fc47925bfd..a4c24307f0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7522,16 +7522,14 @@ __metadata: languageName: node linkType: hard -"@types/lodash.merge@npm:4.6.6": - version: 4.6.6 - resolution: "@types/lodash.merge@npm:4.6.6" - dependencies: - "@types/lodash": "*" - checksum: 62ec56f14b3077f7174497856e9b277db811943cd11b1d67d2a8e51a1803bd49319e8aaf62e745c696af972354a575dbb8a85d3aecf4ae774caf062dc31ac46e +"@types/lodash@npm:4.14.191": + version: 4.14.191 + resolution: "@types/lodash@npm:4.14.191" + checksum: ba0d5434e10690869f32d5ea49095250157cae502f10d57de0a723fd72229ce6c6a4979576f0f13e0aa9fbe3ce2457bfb9fa7d4ec3d6daba56730a51906d1491 languageName: node linkType: hard -"@types/lodash@npm:*, @types/lodash@npm:^4.14.167": +"@types/lodash@npm:^4.14.167": version: 4.14.184 resolution: "@types/lodash@npm:4.14.184" checksum: 6d9a4d67f7f9d0ec3fd21174f3dd3d00629dc1227eb469450eace53adbc1f7e2330699c28d0fe093e5f0fef0f0e763098be1f779268857213224af082b62be21 @@ -8797,7 +8795,7 @@ __metadata: "@types/eslint": ^8.2.0 "@types/express-session": 1.17.3 "@types/jsonwebtoken": 8.3.7 - "@types/lodash.merge": 4.6.6 + "@types/lodash": 4.14.191 "@types/morgan": 1.7.37 "@types/ms": 0.7.31 "@types/node": ^18.0.3 @@ -8828,8 +8826,7 @@ __metadata: ipaddr.js: ^2.0.1 jest: ^29.0.0 jsonwebtoken: 8.5.1 - lodash.merge: ^4.6.2 - lodash.throttle: ^4.1.1 + lodash: ^4.17.21 mime-types: 2.1.35 moment: ^2.29.2 moment-timezone: ^0.5.31 @@ -8874,7 +8871,7 @@ __metadata: "@transloadit/prettier-bytes": 0.0.9 "@uppy/store-default": "workspace:^" "@uppy/utils": "workspace:^" - lodash.throttle: ^4.1.1 + lodash: ^4.17.21 mime-match: ^1.0.2 namespace-emitter: ^2.0.1 nanoid: ^4.0.0 @@ -8896,7 +8893,7 @@ __metadata: "@uppy/utils": "workspace:^" classnames: ^2.2.6 is-shallow-equal: ^1.0.1 - lodash.debounce: ^4.0.8 + lodash: ^4.17.21 memoize-one: ^6.0.0 nanoid: ^4.0.0 preact: ^10.5.13 @@ -8981,7 +8978,7 @@ __metadata: dependencies: "@transloadit/prettier-bytes": 0.0.9 "@uppy/utils": "workspace:^" - lodash.throttle: ^4.1.1 + lodash: ^4.17.21 peerDependencies: "@uppy/core": "workspace:^" languageName: unknown @@ -9172,7 +9169,7 @@ __metadata: "@transloadit/prettier-bytes": 0.0.9 "@uppy/utils": "workspace:^" classnames: ^2.2.6 - lodash.throttle: ^4.1.1 + lodash: ^4.17.21 preact: ^10.5.13 peerDependencies: "@uppy/core": "workspace:^" @@ -9291,7 +9288,7 @@ __metadata: resolution: "@uppy/utils@workspace:packages/@uppy/utils" dependencies: "@jest/globals": ^29.0.0 - lodash.throttle: ^4.1.1 + lodash: ^4.17.21 languageName: unknown linkType: soft From 7345bfc045afe2442ba90b74a014c39f4f90e476 Mon Sep 17 00:00:00 2001 From: R Date: Wed, 11 Jan 2023 19:15:40 +0700 Subject: [PATCH 2/4] Fixed lodash.throttle still being imported after the migration in @uppy/utils --- packages/@uppy/utils/src/emitSocketProgress.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/@uppy/utils/src/emitSocketProgress.js b/packages/@uppy/utils/src/emitSocketProgress.js index ef0c0ff2a8..923491bab7 100644 --- a/packages/@uppy/utils/src/emitSocketProgress.js +++ b/packages/@uppy/utils/src/emitSocketProgress.js @@ -1,4 +1,4 @@ -import throttle from 'lodash.throttle' +import throttle from 'lodash/throttle' function emitSocketProgress (uploader, progressData, file) { const { progress, bytesUploaded, bytesTotal } = progressData From 489c0dea516787aff0b9feac6daa2b9fb6b6058f Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Mon, 19 Jun 2023 15:29:12 +0200 Subject: [PATCH 3/4] add file extension --- packages/@uppy/companion/src/companion.js | 2 +- packages/@uppy/companion/src/server/Uploader.js | 2 +- packages/@uppy/companion/src/standalone/helper.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/@uppy/companion/src/companion.js b/packages/@uppy/companion/src/companion.js index 4f88898b5d..82cab3b5e7 100644 --- a/packages/@uppy/companion/src/companion.js +++ b/packages/@uppy/companion/src/companion.js @@ -1,6 +1,6 @@ const express = require('express') const Grant = require('grant').default.express() -const merge = require('lodash/merge') +const merge = require('lodash/merge.js') const cookieParser = require('cookie-parser') const interceptor = require('express-interceptor') const { randomUUID } = require('node:crypto') diff --git a/packages/@uppy/companion/src/server/Uploader.js b/packages/@uppy/companion/src/server/Uploader.js index fa2a50ada1..7cc0cd3402 100644 --- a/packages/@uppy/companion/src/server/Uploader.js +++ b/packages/@uppy/companion/src/server/Uploader.js @@ -8,7 +8,7 @@ const { join } = require('node:path') const fs = require('node:fs') const { promisify } = require('node:util') const FormData = require('form-data') -const throttle = require('lodash/throttle') +const throttle = require('lodash/throttle.js') // TODO move to `require('streams/promises').pipeline` when dropping support for Node.js 14.x. const pipeline = promisify(pipelineCb) diff --git a/packages/@uppy/companion/src/standalone/helper.js b/packages/@uppy/companion/src/standalone/helper.js index 8b9aa99380..29034076e4 100644 --- a/packages/@uppy/companion/src/standalone/helper.js +++ b/packages/@uppy/companion/src/standalone/helper.js @@ -1,5 +1,5 @@ const fs = require('node:fs') -const merge = require('lodash/merge') +const merge = require('lodash/merge.js') const stripIndent = require('common-tags/lib/stripIndent') const crypto = require('node:crypto') From e3432da1459952bcba7f778f7824ec14627322f0 Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Mon, 19 Jun 2023 15:35:14 +0200 Subject: [PATCH 4/4] fixup! add file extension --- packages/@uppy/companion/src/companion.js | 2 +- packages/@uppy/companion/src/server/Uploader.js | 2 +- packages/@uppy/companion/src/standalone/helper.js | 2 +- packages/@uppy/core/src/Uppy.js | 2 +- packages/@uppy/dashboard/src/utils/createSuperFocus.js | 2 +- packages/@uppy/golden-retriever/src/index.js | 2 +- packages/@uppy/status-bar/src/Components.jsx | 2 +- packages/@uppy/utils/src/emitSocketProgress.js | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/@uppy/companion/src/companion.js b/packages/@uppy/companion/src/companion.js index 82cab3b5e7..4f88898b5d 100644 --- a/packages/@uppy/companion/src/companion.js +++ b/packages/@uppy/companion/src/companion.js @@ -1,6 +1,6 @@ const express = require('express') const Grant = require('grant').default.express() -const merge = require('lodash/merge.js') +const merge = require('lodash/merge') const cookieParser = require('cookie-parser') const interceptor = require('express-interceptor') const { randomUUID } = require('node:crypto') diff --git a/packages/@uppy/companion/src/server/Uploader.js b/packages/@uppy/companion/src/server/Uploader.js index 7cc0cd3402..fa2a50ada1 100644 --- a/packages/@uppy/companion/src/server/Uploader.js +++ b/packages/@uppy/companion/src/server/Uploader.js @@ -8,7 +8,7 @@ const { join } = require('node:path') const fs = require('node:fs') const { promisify } = require('node:util') const FormData = require('form-data') -const throttle = require('lodash/throttle.js') +const throttle = require('lodash/throttle') // TODO move to `require('streams/promises').pipeline` when dropping support for Node.js 14.x. const pipeline = promisify(pipelineCb) diff --git a/packages/@uppy/companion/src/standalone/helper.js b/packages/@uppy/companion/src/standalone/helper.js index 29034076e4..8b9aa99380 100644 --- a/packages/@uppy/companion/src/standalone/helper.js +++ b/packages/@uppy/companion/src/standalone/helper.js @@ -1,5 +1,5 @@ const fs = require('node:fs') -const merge = require('lodash/merge.js') +const merge = require('lodash/merge') const stripIndent = require('common-tags/lib/stripIndent') const crypto = require('node:crypto') diff --git a/packages/@uppy/core/src/Uppy.js b/packages/@uppy/core/src/Uppy.js index c940c28d65..f9644bb09f 100644 --- a/packages/@uppy/core/src/Uppy.js +++ b/packages/@uppy/core/src/Uppy.js @@ -4,7 +4,7 @@ import Translator from '@uppy/utils/lib/Translator' import ee from 'namespace-emitter' import { nanoid } from 'nanoid/non-secure' -import throttle from 'lodash/throttle' +import throttle from 'lodash/throttle.js' import DefaultStore from '@uppy/store-default' import getFileType from '@uppy/utils/lib/getFileType' import getFileNameAndExtension from '@uppy/utils/lib/getFileNameAndExtension' diff --git a/packages/@uppy/dashboard/src/utils/createSuperFocus.js b/packages/@uppy/dashboard/src/utils/createSuperFocus.js index 382e2ec9f3..6c7d178134 100644 --- a/packages/@uppy/dashboard/src/utils/createSuperFocus.js +++ b/packages/@uppy/dashboard/src/utils/createSuperFocus.js @@ -1,4 +1,4 @@ -import debounce from 'lodash/debounce' +import debounce from 'lodash/debounce.js' import FOCUSABLE_ELEMENTS from '@uppy/utils/lib/FOCUSABLE_ELEMENTS' import getActiveOverlayEl from './getActiveOverlayEl.js' diff --git a/packages/@uppy/golden-retriever/src/index.js b/packages/@uppy/golden-retriever/src/index.js index 61f0dad464..13f3588475 100644 --- a/packages/@uppy/golden-retriever/src/index.js +++ b/packages/@uppy/golden-retriever/src/index.js @@ -1,4 +1,4 @@ -import throttle from 'lodash/throttle' +import throttle from 'lodash/throttle.js' import BasePlugin from '@uppy/core/lib/BasePlugin.js' import ServiceWorkerStore from './ServiceWorkerStore.js' import IndexedDBStore from './IndexedDBStore.js' diff --git a/packages/@uppy/status-bar/src/Components.jsx b/packages/@uppy/status-bar/src/Components.jsx index de1d376fef..4755e9f289 100644 --- a/packages/@uppy/status-bar/src/Components.jsx +++ b/packages/@uppy/status-bar/src/Components.jsx @@ -1,6 +1,6 @@ import { h } from 'preact' import classNames from 'classnames' -import throttle from 'lodash/throttle' +import throttle from 'lodash/throttle.js' import prettierBytes from '@transloadit/prettier-bytes' import prettyETA from '@uppy/utils/lib/prettyETA' diff --git a/packages/@uppy/utils/src/emitSocketProgress.js b/packages/@uppy/utils/src/emitSocketProgress.js index 923491bab7..19e91598db 100644 --- a/packages/@uppy/utils/src/emitSocketProgress.js +++ b/packages/@uppy/utils/src/emitSocketProgress.js @@ -1,4 +1,4 @@ -import throttle from 'lodash/throttle' +import throttle from 'lodash/throttle.js' function emitSocketProgress (uploader, progressData, file) { const { progress, bytesUploaded, bytesTotal } = progressData