Skip to content

Commit da2700e

Browse files
AaravMalaniRichDom2185leeyi45
authored
Migrate from lodash to es-toolkit (#596)
* Migrate from lodash to es-toolkit * Revert noBarrelImports tests + mock memoize function * Fix weird dependency aliasing * Lint files * Fix lockfile post-merge * Fix missing packages * Fix omit change to es-toolkit + Add react to base module * Update .yarnrc.yml Co-authored-by: Richard Dominick <[email protected]> * Update docs/src/lib/lintplugin/2-rules.md Co-authored-by: Richard Dominick <[email protected]> * Revert tests and no-barrel-imports and fix mergeConfig bug * Update components that were causing type errors * Update packages to fix type errors * Temporary fixes for blueprint icons * Ran linting --------- Co-authored-by: Richard Dominick <[email protected]> Co-authored-by: DESKTOP-G08HS3B\Lee Yi <[email protected]>
1 parent 7948025 commit da2700e

60 files changed

Lines changed: 559 additions & 533 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/actions/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
"type": "module",
66
"devDependencies": {
77
"@sourceacademy/modules-repotools": "workspace:^",
8-
"@types/lodash": "^4.14.198",
98
"@types/node": "^22.15.30",
109
"typescript": "^5.8.2",
1110
"vitest": "^4.0.18"
@@ -14,7 +13,7 @@
1413
"@actions/artifact": "^6.0.0",
1514
"@actions/core": "^1.11.1",
1615
"@actions/exec": "^3.0.0",
17-
"lodash": "^4.17.23",
16+
"es-toolkit": "^1.44.0",
1817
"snyk-nodejs-lockfile-parser": "^2.4.2"
1918
},
2019
"scripts": {

.github/actions/src/__tests__/commons.test.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@ import * as exec from '@actions/exec';
22
import { describe, expect, it, test, vi } from 'vitest';
33
import * as commons from '../commons.js';
44

5-
vi.mock(import('lodash/memoize.js'), () => ({
6-
default: (x: any) => x
7-
}) as any);
5+
vi.mock(import('es-toolkit'), async (importOriginal) => {
6+
const actual = await importOriginal();
7+
return {
8+
...actual,
9+
memoize: (x: any) => x
10+
};
11+
});
812

913
const mockedExecOutput = vi.spyOn(exec, 'getExecOutput');
1014

.github/actions/src/__tests__/sample_why.txt

Lines changed: 6 additions & 6 deletions
Large diffs are not rendered by default.

.github/actions/src/commons.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { getExecOutput } from '@actions/exec';
2-
import memoize from 'lodash/memoize.js';
2+
import { memoize } from 'es-toolkit';
33

44
export interface RawPackageRecord {
55
directory: string;

.github/actions/src/info/__tests__/index.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ const mockDirectory: Record<string, string | Record<string, unknown>> = {
5555
'package.json': JSON.stringify({
5656
name: '@sourceacademy/tab-Tab0',
5757
dependencies: {
58-
lodash: '^4.1.1',
58+
'lodash': '^4.17.20',
5959
'@sourceacademy/bundle-bundle0': 'workspace:^',
6060
},
6161
devDependencies: {

.github/actions/src/lockfiles.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import fs from 'fs/promises';
22
import pathlib from 'path';
33
import * as core from '@actions/core';
44
import { getExecOutput } from '@actions/exec';
5-
import memoize from 'lodash/memoize.js';
5+
import { memoize } from 'es-toolkit';
66
import { extractPkgsFromYarnLockV2 } from 'snyk-nodejs-lockfile-parser';
77
import { gitRoot } from './gitRoot.js';
88

devserver/src/components/ControlButton.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { AnchorButton, Button, Icon, Intent, type IconName } from '@blueprintjs/core';
1+
import { AnchorButton, Button, Icon, Intent, type IconProps } from '@blueprintjs/core';
22
import React from 'react';
33

44
type ButtonOptions = {
@@ -13,7 +13,7 @@ type ButtonOptions = {
1313

1414
type ControlButtonProps = {
1515
label?: string;
16-
icon?: IconName;
16+
icon?: IconProps['icon'];
1717
onClick?: () => void;
1818
options?: Partial<ButtonOptions>;
1919
isDisabled?: boolean;

devserver/src/components/Playground.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import { Button, Classes, Intent, OverlayToaster, Popover, Tooltip, type ToastProps } from '@blueprintjs/core';
2-
import { IconNames } from '@blueprintjs/icons';
2+
import { Settings } from '@blueprintjs/icons';
33
import classNames from 'classnames';
44
import { SourceDocumentation, getNames, runInContext, type Context } from 'js-slang';
55
// Importing this straight from js-slang doesn't work for whatever reason
66
import createContext from 'js-slang/dist/createContext';
7+
import { ModuleInternalError } from 'js-slang/dist/modules/errors';
78
import { setModulesStaticURL } from 'js-slang/dist/modules/loader';
89
import { Chapter, Variant } from 'js-slang/dist/types';
910
import { stringify } from 'js-slang/dist/utils/stringify';
@@ -159,6 +160,12 @@ const Playground: React.FC = () => {
159160
value: stringify(result.value)
160161
});
161162
} else if (result.status === 'error') {
163+
codeContext.errors.forEach(error => {
164+
if (error instanceof ModuleInternalError) {
165+
console.error(error.error);
166+
}
167+
});
168+
162169
setReplOutput({
163170
type: 'errors',
164171
errors: codeContext.errors,
@@ -210,7 +217,7 @@ const Playground: React.FC = () => {
210217
<Tooltip content="Settings">
211218
<Button
212219
{...targetProps}
213-
icon={IconNames.SETTINGS}
220+
icon={<Settings />}
214221
/>
215222
</Tooltip>
216223
);
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Tooltip } from '@blueprintjs/core';
2-
import { IconNames } from '@blueprintjs/icons';
2+
import { Trash } from '@blueprintjs/icons';
33
import ControlButton from '../ControlButton';
44

55
type Props = {
@@ -9,7 +9,7 @@ type Props = {
99
export const ControlBarClearButton = (props: Props) => <Tooltip content="Clear the editor and context">
1010
<ControlButton
1111
label="Clear"
12-
icon={IconNames.Trash}
12+
icon={<Trash />}
1313
onClick={props.onClick}
1414
/>
1515
</Tooltip>;
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Tooltip } from '@blueprintjs/core';
2-
import { IconNames } from '@blueprintjs/icons';
2+
import { Refresh } from '@blueprintjs/icons';
33
import ControlButton from '../ControlButton';
44

55
type Props = {
@@ -9,7 +9,7 @@ type Props = {
99
export const ControlBarRefreshButton = (props: Props) => <Tooltip content="Manually refresh the side content">
1010
<ControlButton
1111
onClick={props.onClick}
12-
icon={IconNames.Refresh}
12+
icon={<Refresh />}
1313
label="Refresh"
1414
/>
1515
</Tooltip>;

0 commit comments

Comments
 (0)