Skip to content

Commit

Permalink
chore: switch back from lodash-es to lodash to avoid ESM issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Theo Ephraim committed Jun 27, 2023
1 parent d45ba03 commit c808eed
Show file tree
Hide file tree
Showing 11 changed files with 46 additions and 35 deletions.
3 changes: 0 additions & 3 deletions jest.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ module.exports = {
transform: {
"^.+\\.(t|j)s$": "@swc/jest",
},
moduleNameMapper: {
"lodash-es": "lodash"
},
testTimeout: 10000,
coveragePathIgnorePatterns: [
"/node_modules/",
Expand Down
6 changes: 2 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -103,4 +101,4 @@
"volta": {
"node": "18.16.0"
}
}
}
19 changes: 1 addition & 18 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/lib/GoogleSpreadsheet.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/GoogleSpreadsheetCell.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable max-classes-per-file */
import * as _ from 'lodash-es';
import * as _ from './lodash';

import { columnToLetter } from './utils';

Expand Down
4 changes: 2 additions & 2 deletions src/lib/GoogleSpreadsheetWorksheet.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand Down
32 changes: 32 additions & 0 deletions src/lib/lodash.ts
Original file line number Diff line number Diff line change
@@ -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';
2 changes: 1 addition & 1 deletion src/lib/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as _ from 'lodash-es';
import * as _ from './lodash';

export function getFieldMask(obj: Record<string, unknown>) {
return Object.keys(obj).join(',');
Expand Down
2 changes: 1 addition & 1 deletion src/test/cells.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as _ from 'lodash-es';
import delay from 'delay';
import * as _ from '../lib/lodash';

import {
GoogleSpreadsheet, GoogleSpreadsheetWorksheet, GoogleSpreadsheetCell, GoogleSpreadsheetCellErrorValue,
Expand Down
7 changes: 4 additions & 3 deletions src/test/manage.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as _ from 'lodash-es';

import delay from 'delay';
import * as _ from '../lib/lodash';

import { GoogleSpreadsheet, GoogleSpreadsheetWorksheet } from '..';

Expand Down Expand Up @@ -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 () => {
Expand Down Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/test/rows.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as _ from 'lodash-es';
import delay from 'delay';
import * as _ from '../lib/lodash';

import { GoogleSpreadsheet, GoogleSpreadsheetWorksheet, GoogleSpreadsheetRow } from '..';

Expand Down

0 comments on commit c808eed

Please sign in to comment.