diff --git a/jest.config.cjs b/jest.config.cjs index 44e770f..70949d2 100644 --- a/jest.config.cjs +++ b/jest.config.cjs @@ -5,9 +5,6 @@ module.exports = { transform: { "^.+\\.(t|j)s$": "@swc/jest", }, - moduleNameMapper: { - "lodash-es": "lodash" - }, testTimeout: 10000, coveragePathIgnorePatterns: [ "/node_modules/", diff --git a/package.json b/package.json index dd570c5..290e647 100644 --- a/package.json +++ b/package.json @@ -61,14 +61,13 @@ }, "dependencies": { "axios": "^1.4.0", - "lodash-es": "^4.17.21" + "lodash": "^4.17.21" }, "devDependencies": { "@swc/core": "^1.3.60", "@swc/jest": "^0.2.26", "@types/jest": "^29.5.1", "@types/lodash": "^4.14.195", - "@types/lodash-es": "^4.17.7", "@types/node": "^20.2.5", "@typescript-eslint/eslint-plugin": "^5.59.7", "@typescript-eslint/parser": "^5.59.7", @@ -86,7 +85,6 @@ "google-auth-library": "^8.8.0", "jest": "^29.5.0", "jest-junit": "^16.0.0", - "lodash": "^4.17.21", "release-it": "^15.11.0", "ts-node": "^10.9.1", "typescript": "^4.9.5", @@ -103,4 +101,4 @@ "volta": { "node": "18.16.0" } -} +} \ No newline at end of file diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index f16f07e..3773543 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -4,7 +4,7 @@ dependencies: axios: specifier: ^1.4.0 version: 1.4.0 - lodash-es: + lodash: specifier: ^4.17.21 version: 4.17.21 @@ -21,9 +21,6 @@ devDependencies: '@types/lodash': specifier: ^4.14.195 version: 4.14.195 - '@types/lodash-es': - specifier: ^4.17.7 - version: 4.17.7 '@types/node': specifier: ^20.2.5 version: 20.2.5 @@ -75,9 +72,6 @@ devDependencies: jest-junit: specifier: ^16.0.0 version: 16.0.0 - lodash: - specifier: ^4.17.21 - version: 4.17.21 release-it: specifier: ^15.11.0 version: 15.11.0 @@ -1575,12 +1569,6 @@ packages: '@types/node': 20.2.5 dev: true - /@types/lodash-es@4.17.7: - resolution: {integrity: sha512-z0ptr6UI10VlU6l5MYhGwS4mC8DZyYer2mCoyysZtSF7p26zOX8UpbrV0YpNYLGS8K4PUFIyEr62IMFFjveSiQ==} - dependencies: - '@types/lodash': 4.14.195 - dev: true - /@types/lodash@4.14.195: resolution: {integrity: sha512-Hwx9EUgdwf2GLarOjQp5ZH8ZmblzcbTBC2wtQWNKARBSxM9ezRIAUpeDTgoQRAFB0+8CNWXVA9+MaSOzOF3nPg==} dev: true @@ -5370,10 +5358,6 @@ packages: p-locate: 5.0.0 dev: true - /lodash-es@4.17.21: - resolution: {integrity: sha512-mKnC+QJ9pWVzv+C4/U3rRsHapFfHvQFoFB92e52xeyGMcX6/OlIl78je1u8vePzYZSkkogMPJ2yjxxsb89cxyw==} - dev: false - /lodash.capitalize@4.2.1: resolution: {integrity: sha512-kZzYOKspf8XVX5AvmQF94gQW0lejFVgb80G85bU4ZWzoJ6C03PQg3coYAUpSTpQWelrZELd3XWgHzw4Ck5kaIw==} dev: true @@ -5414,7 +5398,6 @@ packages: /lodash@4.17.21: resolution: {integrity: sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==} - dev: true /log-symbols@4.1.0: resolution: {integrity: sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg==} diff --git a/src/lib/GoogleSpreadsheet.ts b/src/lib/GoogleSpreadsheet.ts index 381835d..311ee01 100644 --- a/src/lib/GoogleSpreadsheet.ts +++ b/src/lib/GoogleSpreadsheet.ts @@ -1,9 +1,9 @@ -import * as _ from 'lodash-es'; import Axios, { AxiosError, AxiosInstance, AxiosResponse, InternalAxiosRequestConfig, } from 'axios'; import { Stream } from 'stream'; +import * as _ from './lodash'; import { GoogleSpreadsheetWorksheet } from './GoogleSpreadsheetWorksheet'; import { axiosParamsSerializer, getFieldMask } from './utils'; import { diff --git a/src/lib/GoogleSpreadsheetCell.ts b/src/lib/GoogleSpreadsheetCell.ts index 70d2baf..655b1ce 100644 --- a/src/lib/GoogleSpreadsheetCell.ts +++ b/src/lib/GoogleSpreadsheetCell.ts @@ -1,5 +1,5 @@ /* eslint-disable max-classes-per-file */ -import * as _ from 'lodash-es'; +import * as _ from './lodash'; import { columnToLetter } from './utils'; diff --git a/src/lib/GoogleSpreadsheetWorksheet.ts b/src/lib/GoogleSpreadsheetWorksheet.ts index 15ebfe1..162e6ec 100644 --- a/src/lib/GoogleSpreadsheetWorksheet.ts +++ b/src/lib/GoogleSpreadsheetWorksheet.ts @@ -1,6 +1,6 @@ -import * as _ from 'lodash-es'; - import { ReadableStream } from 'node:stream/web'; +import * as _ from './lodash'; + import { GoogleSpreadsheetRow } from './GoogleSpreadsheetRow'; import { GoogleSpreadsheetCell } from './GoogleSpreadsheetCell'; diff --git a/src/lib/lodash.ts b/src/lib/lodash.ts new file mode 100644 index 0000000..715c1f2 --- /dev/null +++ b/src/lib/lodash.ts @@ -0,0 +1,32 @@ +// re-export just what we need from lodash +// we do this so we can use a single import, but hopefully +// it helps keep bundle sizes down in front-end projects using this lib + +export { default as compact } from 'lodash/compact'; + +export { default as each } from 'lodash/each'; +export { default as filter } from 'lodash/filter'; +export { default as find } from 'lodash/find'; +export { default as flatten } from 'lodash/flatten'; +export { default as get } from 'lodash/get'; +export { default as groupBy } from 'lodash/groupBy'; +export { default as isArray } from 'lodash/isArray'; +export { default as isBoolean } from 'lodash/isBoolean'; +export { default as isEqual } from 'lodash/isEqual'; +export { default as isFinite } from 'lodash/isFinite'; +export { default as isInteger } from 'lodash/isInteger'; +export { default as isNil } from 'lodash/isNil'; +export { default as isNumber } from 'lodash/isNumber'; +export { default as isObject } from 'lodash/isObject'; +export { default as isString } from 'lodash/isString'; +export { default as keyBy } from 'lodash/keyBy'; +export { default as keys } from 'lodash/keys'; +export { default as map } from 'lodash/map'; +export { default as omit } from 'lodash/omit'; +export { default as pickBy } from 'lodash/pickBy'; +export { default as set } from 'lodash/set'; +export { default as some } from 'lodash/some'; +export { default as sortBy } from 'lodash/sortBy'; +export { default as times } from 'lodash/times'; +export { default as unset } from 'lodash/unset'; +export { default as values } from 'lodash/values'; diff --git a/src/lib/utils.ts b/src/lib/utils.ts index d817d6b..36ef4e6 100644 --- a/src/lib/utils.ts +++ b/src/lib/utils.ts @@ -1,4 +1,4 @@ -import * as _ from 'lodash-es'; +import * as _ from './lodash'; export function getFieldMask(obj: Record) { return Object.keys(obj).join(','); diff --git a/src/test/cells.test.ts b/src/test/cells.test.ts index 2ffdbb9..de5b926 100644 --- a/src/test/cells.test.ts +++ b/src/test/cells.test.ts @@ -1,5 +1,5 @@ -import * as _ from 'lodash-es'; import delay from 'delay'; +import * as _ from '../lib/lodash'; import { GoogleSpreadsheet, GoogleSpreadsheetWorksheet, GoogleSpreadsheetCell, GoogleSpreadsheetCellErrorValue, diff --git a/src/test/manage.test.ts b/src/test/manage.test.ts index 33fcbbc..10868c6 100644 --- a/src/test/manage.test.ts +++ b/src/test/manage.test.ts @@ -1,5 +1,6 @@ -import * as _ from 'lodash-es'; + import delay from 'delay'; +import * as _ from '../lib/lodash'; import { GoogleSpreadsheet, GoogleSpreadsheetWorksheet } from '..'; @@ -77,7 +78,7 @@ describe('Managing doc info and sheets', () => { }); it('throws an error if updating title directly', async () => { - expect(() => { doc.title = 'new title'; }).toThrow(); + expect(() => { (doc as any).title = 'new title'; }).toThrow(); }); it('can update the title using updateProperties', async () => { @@ -171,7 +172,7 @@ describe('Managing doc info and sheets', () => { it('can resize a sheet', async () => { // cannot update directly - expect(() => { sheet.rowCount = 77; }).toThrow(); + expect(() => { (sheet as any).rowCount = 77; }).toThrow(); await sheet.resize({ rowCount: 77, columnCount: 44 }); expect(sheet.rowCount).toBe(77); sheet.resetLocalCache(); diff --git a/src/test/rows.test.ts b/src/test/rows.test.ts index 46029e6..d0c1689 100644 --- a/src/test/rows.test.ts +++ b/src/test/rows.test.ts @@ -1,5 +1,5 @@ -import * as _ from 'lodash-es'; import delay from 'delay'; +import * as _ from '../lib/lodash'; import { GoogleSpreadsheet, GoogleSpreadsheetWorksheet, GoogleSpreadsheetRow } from '..';