From 96fe58eeac454ffb450f0bec63020aa13cec4ccd Mon Sep 17 00:00:00 2001 From: Aaron Steinfeld Date: Thu, 16 Jul 2020 13:10:15 -0400 Subject: [PATCH] refactor: use lodash modules --- README.md | 2 +- package-lock.json | 23 +++++++++++++++---- package.json | 10 +++++--- rollup.config.ts | 18 ++------------- src/model/editor/editor-library.test.ts | 2 +- src/model/editor/editor-library.ts | 2 +- src/model/manager/model-manager.ts | 2 +- .../predefined/array-property-type.ts | 2 +- .../predefined/model-property-type.ts | 2 +- .../primitive-model-property-types.ts | 2 +- .../validation/model-property-validator.ts | 2 +- src/model/registration/model-registration.ts | 2 +- .../collection/array-deserializer.test.ts | 2 +- .../collection/object-deserializer.test.ts | 2 +- .../collection/object-deserializer.ts | 2 +- .../model/model-deserializer.test.ts | 2 +- .../primitive/primitive-deserialize.test.ts | 2 +- .../primitive/primitive-deserializer.ts | 2 +- .../variable/variable-deserializer.test.ts | 2 +- .../collection/array-serializer.test.ts | 2 +- .../collection/object-serializer.test.ts | 2 +- .../collection/object-serializer.ts | 2 +- .../model/model-serializer.test.ts | 2 +- .../primitive/primitive-serializer.test.ts | 2 +- .../primitive/primitive-serializer.ts | 2 +- .../variable/variable-serializer.test.ts | 2 +- src/variable/evaluator/variable-evaluator.ts | 2 +- src/variable/manager/variable-manager.ts | 2 +- src/variable/parser/expression-parser.ts | 2 +- tsconfig.json | 4 ++-- 30 files changed, 56 insertions(+), 51 deletions(-) diff --git a/README.md b/README.md index 72a8e4b5..85e3c5f2 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Getting Started -[![CircleCI](https://circleci.com/gh/hypertrace/hyperdash.svg?style=svg)](https://circleci.com/gh/hypertrace/hyperdash) +[![CircleCI](https://circleci.com/gh/hypertrace/hyperdash.svg?style=shield)](https://circleci.com/gh/hypertrace/hyperdash) [![codecov](https://codecov.io/gh/hypertrace/hyperdash/branch/master/graph/badge.svg)](https://codecov.io/gh/hypertrace/hyperdash) ## Prerequisites diff --git a/package-lock.json b/package-lock.json index a69fc825..96746287 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3600,6 +3600,15 @@ "integrity": "sha512-Ft5BNFmv2pHDgxV5JDsndOWTRJ+56zte0ZpYLowp03tW+K+t8u8YMOzAnpuqPgzX6WO1XpDIUm7u04M8vdDiVQ==", "dev": true }, + "@types/lodash-es": { + "version": "4.17.3", + "resolved": "https://registry.npmjs.org/@types/lodash-es/-/lodash-es-4.17.3.tgz", + "integrity": "sha512-iHI0i7ZAL1qepz1Y7f3EKg/zUMDwDfTzitx+AlHhJJvXwenP682ZyGbgPSc5Ej3eEAKVbNWKFuwOadCj5vBbYQ==", + "dev": true, + "requires": { + "@types/lodash": "*" + } + }, "@types/minimatch": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/@types/minimatch/-/minimatch-3.0.3.tgz", @@ -10161,7 +10170,13 @@ "lodash": { "version": "4.17.15", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", - "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==" + "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==", + "dev": true + }, + "lodash-es": { + "version": "4.17.15", + "resolved": "https://registry.npmjs.org/lodash-es/-/lodash-es-4.17.15.tgz", + "integrity": "sha512-rlrc3yU3+JNOpZ9zj5pQtxnx2THmvRykwL4Xlxoa8I9lHBlVbbyPhgyPMioxVZ4NqyxaVVtaJnzsyOidQIhyyQ==" }, "lodash._reinterpolate": { "version": "3.0.0", @@ -15593,9 +15608,9 @@ } }, "rollup": { - "version": "2.19.0", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.19.0.tgz", - "integrity": "sha512-nny5Vs4jwY3vbQAXgOyU4ZDZqLvMKm/umnsVry/demVL6ve8ke1XhdpYE0eiWencASmx/qFPw6pP8P7MLJl9XA==", + "version": "2.21.0", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.21.0.tgz", + "integrity": "sha512-BEGgy+wSzux7Ycq58pRiWEOBZaXRXTuvzl1gsm7gqmsAHxkWf9nyA5V2LN9fGSHhhDQd0/C13iRzSh4bbIpWZQ==", "dev": true, "requires": { "fsevents": "~2.1.2" diff --git a/package.json b/package.json index 1eb2ce8a..175e91ef 100644 --- a/package.json +++ b/package.json @@ -37,6 +37,9 @@ "ts", "js" ], + "moduleNameMapper": { + "^lodash-es$": "lodash" + }, "coveragePathIgnorePatterns": [ "/node_modules/", "/test/" @@ -89,7 +92,7 @@ "@rollup/plugin-node-resolve": "^8.1.0", "@rollup/plugin-typescript": "^5.0.1", "@types/jest": "^26.0.3", - "@types/lodash": "^4.14.157", + "@types/lodash-es": "^4.17.3", "@types/node": "^14.0.14", "commitizen": "^4.1.2", "core-js": "3.6.5", @@ -99,10 +102,11 @@ "jest-config": "^26.1.0", "jest-html-reporter": "^3.1.3", "jest-junit": "^11.0.1", + "lodash": "^4.17.15", "prettier": "^2.0.5", "pretty-quick": "^2.0.1", "rimraf": "^3.0.2", - "rollup": "^2.19.0", + "rollup": "^2.21.0", "rollup-plugin-commonjs": "^10.1.0", "rollup-plugin-sourcemaps": "^0.6.2", "rollup-plugin-typescript2": "^0.27.1", @@ -115,7 +119,7 @@ "typescript": "^3.9.6" }, "dependencies": { - "lodash": "^4.17.15" + "lodash-es": "^4.17.15" }, "peerDependencies": { "rxjs": "^6.5.5", diff --git a/rollup.config.ts b/rollup.config.ts index 149039f5..ddb3e067 100644 --- a/rollup.config.ts +++ b/rollup.config.ts @@ -1,5 +1,4 @@ // tslint:disable -import { camelCase } from 'lodash'; import commonjs from 'rollup-plugin-commonjs'; import json from '@rollup/plugin-json'; import resolve from '@rollup/plugin-node-resolve'; @@ -12,22 +11,9 @@ const libraryName = 'hyperdash'; export default { input: `src/${libraryName}.ts`, - output: [ - { - file: pkg.main, - name: camelCase(libraryName), - format: 'umd', - sourcemap: true, - globals: { - lodash: '_', - rxjs: 'rxjs', - 'rxjs/operators': 'rxjs.operators' - } - }, - { file: pkg.module, format: 'es', sourcemap: true } - ], + output: [{ file: pkg.module, format: 'es', sourcemap: true }], // Indicate here external modules you don't wanna include in your bundle (i.e.: 'lodash') - external: ['lodash', 'rxjs', 'rxjs/operators', 'core-js/es7/reflect'], + external: ['lodash-es', 'rxjs', 'rxjs/operators', 'core-js/es7/reflect'], watch: { include: 'src/**' }, diff --git a/src/model/editor/editor-library.test.ts b/src/model/editor/editor-library.test.ts index 11555c61..60660b14 100644 --- a/src/model/editor/editor-library.test.ts +++ b/src/model/editor/editor-library.test.ts @@ -1,4 +1,4 @@ -import { isNil } from 'lodash'; +import { isNil } from 'lodash-es'; import { DataSourceManager } from '../../data/data-source/manager/data-source-manager'; import { RendererLibrary } from '../../renderer/registration/renderer-registration'; import { PartialObjectMock } from '../../test/partial-object-mock'; diff --git a/src/model/editor/editor-library.ts b/src/model/editor/editor-library.ts index 21d29fff..7656c152 100644 --- a/src/model/editor/editor-library.ts +++ b/src/model/editor/editor-library.ts @@ -1,4 +1,4 @@ -import { uniq } from 'lodash'; +import { uniq } from 'lodash-es'; import { DataSourceManager } from '../../data/data-source/manager/data-source-manager'; import { RendererLibrary } from '../../renderer/registration/renderer-registration'; import { Theme } from '../../theming/theme'; diff --git a/src/model/manager/model-manager.ts b/src/model/manager/model-manager.ts index 98aaae7b..7a068bb8 100644 --- a/src/model/manager/model-manager.ts +++ b/src/model/manager/model-manager.ts @@ -1,4 +1,4 @@ -import { cloneDeepWith, without } from 'lodash'; +import { cloneDeepWith, without } from 'lodash-es'; import { Constructable } from '../../util/constructable'; import { Logger } from '../../util/logging/logger'; import { ModelApiBuilder } from '../api/builder/model-api-builder'; diff --git a/src/model/property/predefined/array-property-type.ts b/src/model/property/predefined/array-property-type.ts index accbfd0b..d73555fb 100644 --- a/src/model/property/predefined/array-property-type.ts +++ b/src/model/property/predefined/array-property-type.ts @@ -1,4 +1,4 @@ -import { isNil } from 'lodash'; +import { isNil } from 'lodash-es'; export const ARRAY_PROPERTY = Object.freeze({ type: 'array', diff --git a/src/model/property/predefined/model-property-type.ts b/src/model/property/predefined/model-property-type.ts index a55307c0..b5cd1868 100644 --- a/src/model/property/predefined/model-property-type.ts +++ b/src/model/property/predefined/model-property-type.ts @@ -1,4 +1,4 @@ -import { isNil } from 'lodash'; +import { isNil } from 'lodash-es'; import { DeserializationManager } from '../../../persistence/deserialization/deserialization-manager'; import { ModelJson } from '../../../persistence/model-json'; import { Constructable } from '../../../util/constructable'; diff --git a/src/model/property/predefined/primitive-model-property-types.ts b/src/model/property/predefined/primitive-model-property-types.ts index 7e2c5b92..b9623693 100644 --- a/src/model/property/predefined/primitive-model-property-types.ts +++ b/src/model/property/predefined/primitive-model-property-types.ts @@ -1,4 +1,4 @@ -import { isNil } from 'lodash'; +import { isNil } from 'lodash-es'; import { ModelPropertyTypeInstance, PropertyValidatorFunction } from '../model-property-type-library'; const typeofValidator = (type: 'string' | 'boolean' | 'number' | 'object'): PropertyValidatorFunction => ( diff --git a/src/model/property/validation/model-property-validator.ts b/src/model/property/validation/model-property-validator.ts index b162a3af..10bc5618 100644 --- a/src/model/property/validation/model-property-validator.ts +++ b/src/model/property/validation/model-property-validator.ts @@ -1,4 +1,4 @@ -import { isEmpty } from 'lodash'; +import { isEmpty } from 'lodash-es'; import { Logger } from '../../../util/logging/logger'; import { ModelPropertyMetadata } from '../../registration/model-registration'; import { ModelPropertyTypeLibrary } from '../model-property-type-library'; diff --git a/src/model/registration/model-registration.ts b/src/model/registration/model-registration.ts index 4c5a70a7..f179a0d9 100644 --- a/src/model/registration/model-registration.ts +++ b/src/model/registration/model-registration.ts @@ -1,4 +1,4 @@ -import { cloneDeep, defaults, startCase } from 'lodash'; +import { cloneDeep, defaults, startCase } from 'lodash-es'; import { Constructable, ObjectConstructable, UnknownConstructable } from '../../util/constructable'; import { Logger } from '../../util/logging/logger'; import { getReflectedPropertyType } from '../../util/reflection/reflection-utilities'; diff --git a/src/persistence/deserialization/collection/array-deserializer.test.ts b/src/persistence/deserialization/collection/array-deserializer.test.ts index 09036ed3..d10de1db 100644 --- a/src/persistence/deserialization/collection/array-deserializer.test.ts +++ b/src/persistence/deserialization/collection/array-deserializer.test.ts @@ -1,5 +1,5 @@ // tslint:disable:completed-docs -import { mapValues } from 'lodash'; +import { mapValues } from 'lodash-es'; import { PropertyLocation } from '../../../model/property/property-location'; import { DeserializationManager } from '../deserialization-manager'; import { ArrayDeserializer } from './array-deserializer'; diff --git a/src/persistence/deserialization/collection/object-deserializer.test.ts b/src/persistence/deserialization/collection/object-deserializer.test.ts index fe07053b..4ef01e44 100644 --- a/src/persistence/deserialization/collection/object-deserializer.test.ts +++ b/src/persistence/deserialization/collection/object-deserializer.test.ts @@ -1,5 +1,5 @@ // tslint:disable:completed-docs -import { mapValues } from 'lodash'; +import { mapValues } from 'lodash-es'; import { PropertyLocation } from '../../../model/property/property-location'; import { DeserializationManager } from '../deserialization-manager'; import { ObjectDeserializer } from './object-deserializer'; diff --git a/src/persistence/deserialization/collection/object-deserializer.ts b/src/persistence/deserialization/collection/object-deserializer.ts index 288a5487..da3c52d2 100644 --- a/src/persistence/deserialization/collection/object-deserializer.ts +++ b/src/persistence/deserialization/collection/object-deserializer.ts @@ -1,4 +1,4 @@ -import { mapValues } from 'lodash'; +import { mapValues } from 'lodash-es'; import { PropertyLocation } from '../../../model/property/property-location'; import { JsonPrimitive } from '../../model-json'; import { DeserializationManager } from '../deserialization-manager'; diff --git a/src/persistence/deserialization/model/model-deserializer.test.ts b/src/persistence/deserialization/model/model-deserializer.test.ts index 4580001f..68a65085 100644 --- a/src/persistence/deserialization/model/model-deserializer.test.ts +++ b/src/persistence/deserialization/model/model-deserializer.test.ts @@ -1,4 +1,4 @@ -import { mapValues } from 'lodash'; +import { mapValues } from 'lodash-es'; import { DataSourceManager } from '../../../data/data-source/manager/data-source-manager'; import { ModelManager } from '../../../model/manager/model-manager'; import { diff --git a/src/persistence/deserialization/primitive/primitive-deserialize.test.ts b/src/persistence/deserialization/primitive/primitive-deserialize.test.ts index 90173f2c..977fc314 100644 --- a/src/persistence/deserialization/primitive/primitive-deserialize.test.ts +++ b/src/persistence/deserialization/primitive/primitive-deserialize.test.ts @@ -1,4 +1,4 @@ -import { mapValues } from 'lodash'; +import { mapValues } from 'lodash-es'; import { PrimitiveDeserializer } from './primitive-deserializer'; describe('Primitive deserializer', () => { diff --git a/src/persistence/deserialization/primitive/primitive-deserializer.ts b/src/persistence/deserialization/primitive/primitive-deserializer.ts index 501d6aeb..6753e910 100644 --- a/src/persistence/deserialization/primitive/primitive-deserializer.ts +++ b/src/persistence/deserialization/primitive/primitive-deserializer.ts @@ -1,4 +1,4 @@ -import { includes } from 'lodash'; +import { includes } from 'lodash-es'; import { JsonPrimitive } from '../../model-json'; import { Deserializer } from '../deserializer'; diff --git a/src/persistence/deserialization/variable/variable-deserializer.test.ts b/src/persistence/deserialization/variable/variable-deserializer.test.ts index 296ea162..3b04d6c6 100644 --- a/src/persistence/deserialization/variable/variable-deserializer.test.ts +++ b/src/persistence/deserialization/variable/variable-deserializer.test.ts @@ -1,4 +1,4 @@ -import { mapValues } from 'lodash'; +import { mapValues } from 'lodash-es'; import { PropertyLocation } from '../../../model/property/property-location'; import { VariableManager } from '../../../variable/manager/variable-manager'; import { VariableDeserializer } from './variable-deserializer'; diff --git a/src/persistence/serialization/collection/array-serializer.test.ts b/src/persistence/serialization/collection/array-serializer.test.ts index 4ab3ca0d..36045af3 100644 --- a/src/persistence/serialization/collection/array-serializer.test.ts +++ b/src/persistence/serialization/collection/array-serializer.test.ts @@ -1,4 +1,4 @@ -import { mapValues } from 'lodash'; +import { mapValues } from 'lodash-es'; import { PropertyLocation } from '../../../model/property/property-location'; import { PartialObjectMock } from '../../../test/partial-object-mock'; import { SerializationManager } from '../serialization-manager'; diff --git a/src/persistence/serialization/collection/object-serializer.test.ts b/src/persistence/serialization/collection/object-serializer.test.ts index d0a52e5c..89be844c 100644 --- a/src/persistence/serialization/collection/object-serializer.test.ts +++ b/src/persistence/serialization/collection/object-serializer.test.ts @@ -1,5 +1,5 @@ // tslint:disable:completed-docs -import { mapValues } from 'lodash'; +import { mapValues } from 'lodash-es'; import { PropertyLocation } from '../../../model/property/property-location'; import { PartialObjectMock } from '../../../test/partial-object-mock'; import { SerializationManager } from '../serialization-manager'; diff --git a/src/persistence/serialization/collection/object-serializer.ts b/src/persistence/serialization/collection/object-serializer.ts index 33e96202..fc5d5f8f 100644 --- a/src/persistence/serialization/collection/object-serializer.ts +++ b/src/persistence/serialization/collection/object-serializer.ts @@ -1,4 +1,4 @@ -import { mapValues } from 'lodash'; +import { mapValues } from 'lodash-es'; import { PropertyLocation } from '../../../model/property/property-location'; import { SerializationManager } from '../serialization-manager'; import { Serializer } from '../serializer'; diff --git a/src/persistence/serialization/model/model-serializer.test.ts b/src/persistence/serialization/model/model-serializer.test.ts index 99ecbced..0e5a4174 100644 --- a/src/persistence/serialization/model/model-serializer.test.ts +++ b/src/persistence/serialization/model/model-serializer.test.ts @@ -1,4 +1,4 @@ -import { mapValues } from 'lodash'; +import { mapValues } from 'lodash-es'; import { DataSourceManager } from '../../../data/data-source/manager/data-source-manager'; import { ModelManager } from '../../../model/manager/model-manager'; import { diff --git a/src/persistence/serialization/primitive/primitive-serializer.test.ts b/src/persistence/serialization/primitive/primitive-serializer.test.ts index 84722b94..8e045884 100644 --- a/src/persistence/serialization/primitive/primitive-serializer.test.ts +++ b/src/persistence/serialization/primitive/primitive-serializer.test.ts @@ -1,4 +1,4 @@ -import { mapValues } from 'lodash'; +import { mapValues } from 'lodash-es'; import { PrimitiveSerializer } from './primitive-serializer'; describe('Primitive serializer', () => { diff --git a/src/persistence/serialization/primitive/primitive-serializer.ts b/src/persistence/serialization/primitive/primitive-serializer.ts index 6bb8c9dc..683950c8 100644 --- a/src/persistence/serialization/primitive/primitive-serializer.ts +++ b/src/persistence/serialization/primitive/primitive-serializer.ts @@ -1,4 +1,4 @@ -import { includes } from 'lodash'; +import { includes } from 'lodash-es'; import { JsonPrimitive } from '../../model-json'; import { Serializer } from '../serializer'; diff --git a/src/persistence/serialization/variable/variable-serializer.test.ts b/src/persistence/serialization/variable/variable-serializer.test.ts index fb5bf627..75d43a5a 100644 --- a/src/persistence/serialization/variable/variable-serializer.test.ts +++ b/src/persistence/serialization/variable/variable-serializer.test.ts @@ -1,4 +1,4 @@ -import { mapValues } from 'lodash'; +import { mapValues } from 'lodash-es'; import { PropertyLocation } from '../../../model/property/property-location'; import { PartialObjectMock } from '../../../test/partial-object-mock'; import { VariableManager } from '../../../variable/manager/variable-manager'; diff --git a/src/variable/evaluator/variable-evaluator.ts b/src/variable/evaluator/variable-evaluator.ts index 4231d32a..6ce5c889 100644 --- a/src/variable/evaluator/variable-evaluator.ts +++ b/src/variable/evaluator/variable-evaluator.ts @@ -1,4 +1,4 @@ -import { difference, get } from 'lodash'; +import { difference, get } from 'lodash-es'; import { ExpressionParser } from '../parser/expression-parser'; import { ParseNode, ParseNodeType } from '../parser/parse-node'; import { ResolveDictionary } from '../variable-dictionary'; diff --git a/src/variable/manager/variable-manager.ts b/src/variable/manager/variable-manager.ts index a2e1f570..b4804614 100644 --- a/src/variable/manager/variable-manager.ts +++ b/src/variable/manager/variable-manager.ts @@ -1,4 +1,4 @@ -import { fromPairs } from 'lodash'; +import { fromPairs } from 'lodash-es'; import { ModelChangedEvent } from '../../model/events/model-changed-event'; import { ModelManager } from '../../model/manager/model-manager'; import { PropertyLocation } from '../../model/property/property-location'; diff --git a/src/variable/parser/expression-parser.ts b/src/variable/parser/expression-parser.ts index 7d5f7f1f..be5e356b 100644 --- a/src/variable/parser/expression-parser.ts +++ b/src/variable/parser/expression-parser.ts @@ -1,4 +1,4 @@ -import { min } from 'lodash'; +import { min } from 'lodash-es'; import { ParseNode, ParseNodeType } from './parse-node'; /** diff --git a/tsconfig.json b/tsconfig.json index f9c6a14e..b7f15278 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,8 +1,8 @@ { "compilerOptions": { "moduleResolution": "node", - "target": "es5", - "module": "es2015", + "module": "esNext", + "target": "es2015", "lib": ["es2015", "es2016", "es2017", "esnext.array", "dom"], "strict": true, "sourceMap": true,