Skip to content

Commit

Permalink
chore: remove lodash
Browse files Browse the repository at this point in the history
  • Loading branch information
prevwong committed Nov 22, 2023
1 parent e2f00d4 commit c9cd8b5
Show file tree
Hide file tree
Showing 10 changed files with 63 additions and 49 deletions.
7 changes: 7 additions & 0 deletions .changeset/four-lemons-report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@rekajs/react-code-editor': patch
'@rekajs/utils': patch
'@rekajs/core': patch
---

Remove lodash dep
4 changes: 1 addition & 3 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,13 @@
"license": "MIT",
"devDependencies": {
"@rekajs/parser": "workspace:*",
"@rekajs/types": "workspace:*",
"@types/lodash": "^4.14.185"
"@rekajs/types": "workspace:*"
},
"peerDependencies": {
"@rekajs/types": ">=0.1.0"
},
"dependencies": {
"@rekajs/utils": "^0.1.2",
"lodash": "^4.17.21",
"mobx": "^6.3.13",
"mobx-utils": "^6.0.6"
},
Expand Down
3 changes: 1 addition & 2 deletions packages/core/src/component.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import * as t from '@rekajs/types';
import { invariant, capitalize } from '@rekajs/utils';
import { computed, IComputedValue, runInAction, untracked } from 'mobx';

import { DisposableComputation } from './computation';
import { Environment } from './environment';
import { TemplateEvaluateContext, Evaluator } from './evaluator';
import { ClassListBindingKey, ComponentSlotBindingKey } from './symbols';
import { createKey } from './utils';
import { invariant } from '@rekajs/utils';
import capitalize from 'lodash/capitalize';

type ComponentViewTreeComputationCache = {
component: t.Component;
Expand Down
5 changes: 2 additions & 3 deletions packages/core/src/evaluator.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import * as t from '@rekajs/types';
import { invariant, safeObjKey } from '@rekajs/utils';
import omit from 'lodash/omit';
import { invariant, safeObjKey, omit } from '@rekajs/utils';
import {
computed,
IComputedValue,
Expand Down Expand Up @@ -72,7 +71,7 @@ export class Evaluator {
) {
this._view = observable.box();

const nonChildrenProps = omit(this.componentProps, ['children']);
const nonChildrenProps = omit(this.componentProps, ['children', 'x']);

let children = this.componentProps['children'];

Expand Down
3 changes: 1 addition & 2 deletions packages/react-code-editor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
"@codemirror/theme-one-dark": "^6.1.1",
"@codemirror/view": "^6.9.3",
"@rekajs/codemirror": ">=0.1.2",
"@rekajs/utils": ">=0.1.2",
"codemirror": "^6.0.1",
"lodash": "^4.17.21",
"mobx": "^6.3.13",
"mobx-react-lite": "^3.3.0"
},
Expand All @@ -35,7 +35,6 @@
"@rekajs/parser": "workspace:*",
"@rekajs/react": "workspace:*",
"@rekajs/types": "workspace:*",
"@types/debounce": "^1.2.1",
"@types/react": "^17.0.33",
"@types/react-dom": "^17.0.10",
"react": "^17.0.2"
Expand Down
2 changes: 1 addition & 1 deletion packages/react-code-editor/src/CodeEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { reka as rekaCodemirrorExtension } from '@rekajs/codemirror';
import { Parser } from '@rekajs/parser';
import { useReka } from '@rekajs/react';
import * as t from '@rekajs/types';
import { debounce } from '@rekajs/utils';
import { basicSetup } from 'codemirror';
import debounce from 'lodash/debounce';
import * as React from 'react';

const _diffASTArrayTypes = <T extends t.Type>(
Expand Down
1 change: 1 addition & 0 deletions packages/utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"author": "Prev Wong",
"license": "MIT",
"dependencies": {
"debounce": "^2.0.0",
"nanoid": "^3.3.4",
"tiny-invariant": "^1.2.0"
},
Expand Down
1 change: 1 addition & 0 deletions packages/utils/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './error';
export * from './random';
export * from './strings';
export { default as debounce } from 'debounce';
16 changes: 16 additions & 0 deletions packages/utils/src/strings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,19 @@ export const safeObjKey = (key: string) => {

return match[1];
};

export const capitalize = (str: string) =>
str.charAt(0).toUpperCase() + str.substring(1);

export const omit = <R extends Record<string, any>, K extends keyof R>(
obj: R,
keys: Array<K> | ReadonlyArray<K>
) => {
return Object.keys(obj).reduce((accum, key) => {
if (!(keys as string[]).includes(key)) {
accum[key] = obj[key];
}

return accum;
}, {} as Record<string, any>) as Omit<R, K>;
};
70 changes: 32 additions & 38 deletions pnpm-lock.yaml

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

1 comment on commit c9cd8b5

@vercel
Copy link

@vercel vercel bot commented on c9cd8b5 Nov 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

reka – ./

reka-git-main-prevwong.vercel.app
reka-prevwong.vercel.app
rekajs.vercel.app
reka.js.org

Please sign in to comment.