Skip to content

Commit 8034b06

Browse files
authored
build: support Node 16 (#268)
* build: support Node 16 * ci: run using Node 16 * build: update/move dependencies, so build can finish * fix: use useMemo to avoid re-renders * test: set 'resetMocks' to false Mimics react-scripts 3.x behavior * fix: cleanup state on dismount * chore: update testing-library deps, to fix failing test
1 parent 866cad2 commit 8034b06

File tree

14 files changed

+3295
-3137
lines changed

14 files changed

+3295
-3137
lines changed

.github/dependabot.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ updates:
44
directory: '/'
55
schedule:
66
interval: 'daily'
7+
open-pull-requests-limit: 10

.github/workflows/ci.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ jobs:
2020
# https://github.com/actions/checkout/issues/217 pulls all tags (needed for lerna to correctly version)
2121
- run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
2222
# https://github.com/actions/setup-node
23-
- name: Setup Node 12
23+
- name: Setup Node 16
2424
uses: actions/setup-node@v2
2525
with:
26-
node-version: 12
26+
node-version: 16
2727
- name: Install
2828
run: yarn install --immutable
2929
- name: Lint

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
lts/*
1+
16

examples/discovery-search-app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
},
4040
"devDependencies": {
4141
"cross-env": "^7.0.3",
42-
"react-scripts": "^3.4.4"
42+
"react-scripts": "^4.0.3"
4343
},
4444
"browserslist": {
4545
"production": [

examples/discovery-search-app/src/App.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useContext, useState, useEffect } from 'react';
1+
import React, { useContext, useState, useEffect, useMemo } from 'react';
22
import cx from 'classnames';
33
import DiscoveryV2 from 'ibm-watson/discovery/v2';
44
import { NoAuthAuthenticator } from 'ibm-watson/auth';
@@ -23,12 +23,16 @@ import {
2323

2424
const App = () => {
2525
// TODO: this is a dummy client to route requests to the server since CP4D doesn't support CORS
26-
const authenticator = new NoAuthAuthenticator();
27-
const searchClient = new DiscoveryV2({
28-
url: `${window.location.href}api`,
29-
version: '2019-01-01',
30-
authenticator
31-
});
26+
const authenticator = useMemo(() => new NoAuthAuthenticator(), []);
27+
const searchClient = useMemo(
28+
() =>
29+
new DiscoveryV2({
30+
url: `${window.location.href}api`,
31+
version: '2019-01-01',
32+
authenticator
33+
}),
34+
[authenticator]
35+
);
3236
const [projectId, setProjectId] = useState(process.env.REACT_APP_PROJECT_ID);
3337
const [isLoading, setIsLoading] = useState(false);
3438
const [isError, setIsError] = useState(false);

package.json

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@
2020
"@commitlint/cli": "^11.0.0",
2121
"@commitlint/config-conventional": "^11.0.0",
2222
"@cypress/webpack-preprocessor": "^5.5.0",
23-
"@testing-library/cypress": "^7.0.6",
24-
"@testing-library/jest-dom": "^4.2.4",
25-
"@testing-library/react": "^9.5.0",
26-
"@testing-library/react-hooks": "^3.4.1",
23+
"@testing-library/cypress": "^7.0.7",
24+
"@testing-library/jest-dom": "^5.16.1",
25+
"@testing-library/react": "^11.2.7",
26+
"@testing-library/react-hooks": "^7.0.2",
2727
"@types/classnames": "^2.2.9",
2828
"@types/debounce": "^1.2.0",
2929
"@types/dompurify": "^0.0.33",
@@ -37,7 +37,6 @@
3737
"@types/react-virtualized": "^9.21.11",
3838
"@types/seedrandom": "^3.0.1",
3939
"@types/testing-library__cypress": "^5.0.8",
40-
"@types/uuid": "^3.4.5",
4140
"@typescript-eslint/eslint-plugin": "^2.21.0",
4241
"@typescript-eslint/parser": "^2.21.0",
4342
"audit-ci": "^5.1.2",
@@ -69,9 +68,6 @@
6968
"lint-staged": "^9.2.5",
7069
"lorem-ipsum": "^2.0.3",
7170
"markdown-toc": "^1.2.0",
72-
"marked": "^0.7.0",
73-
"node-sass": "^4.12.0",
74-
"node-sass-tilde-importer": "^1.0.2",
7571
"prettier": "^2.4.1",
7672
"proper-url-join": "^2.1.1",
7773
"raw-loader": "^4.0.2",

packages/discovery-react-components/package.json

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@
4040
"pdfjs-dist": "^2.2.228",
4141
"react-error-boundary": "^1.2.5",
4242
"react-resize-detector": "^4.2.1",
43-
"react-virtualized": "9.21.2"
43+
"react-virtualized": "9.21.2",
44+
"uuid": "^8.3.2"
4445
},
4546
"devDependencies": {
4647
"@rollup/plugin-alias": "^3.1.5",
@@ -55,16 +56,21 @@
5556
"@storybook/react": "^5.3.21",
5657
"@storybook/source-loader": "^5.3.21",
5758
"@svgr/rollup": "^5.5.0",
59+
"@types/marked": "^4",
5860
"@types/pdfjs-dist": "2.1.7",
61+
"@types/uuid": "^8",
5962
"cross-env": "^7.0.3",
6063
"css-loader": "^3.4.2",
6164
"madge": "^5.0.1",
62-
"react-scripts": "^3.4.4",
65+
"marked": "^4.0.10",
66+
"node-sass": "^6.0.1",
67+
"react-scripts": "^4.0.3",
6368
"rollup": "^2.57.0",
6469
"rollup-plugin-string": "^3.0.0",
6570
"rollup-plugin-terser": "^7.0.2",
6671
"rollup-plugin-typescript2": "^0.30.0",
67-
"sass-loader": "^8.0.2"
72+
"sass-loader": "^10.2.1",
73+
"style-loader": "^1.3.0"
6874
},
6975
"peerDependencies": {
7076
"@carbon/icons": ">= 10.5.0 < 11",
@@ -84,6 +90,8 @@
8490
"access": "public"
8591
},
8692
"jest": {
93+
"resetMocks": false,
94+
"displayName": "Disco React Components (Unit)",
8795
"transformIgnorePatterns": [
8896
"/!node_modules\\/react-virtualized/"
8997
],

packages/discovery-react-components/src/components/SearchFacets/SearchFacets.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {
1818
SelectedCollectionItems
1919
} from './utils/searchFacetInterfaces';
2020
import get from 'lodash/get';
21-
import uuid from 'uuid';
21+
import { v4 as uuidv4 } from 'uuid';
2222
import { CollectionFacets } from './components/CollectionFacets';
2323
import { FieldFacets } from './components/FieldFacets';
2424
import { DynamicFacets } from './components/DynamicFacets';
@@ -81,7 +81,7 @@ const SearchFacets: FC<SearchFacetsProps> = ({
8181
serverErrorMessage,
8282
onChange
8383
}) => {
84-
const facetsId = id || `search-facets__${uuid.v4()}`;
84+
const facetsId = id || `search-facets__${uuidv4()}`;
8585

8686
const {
8787
searchResponseStore: {

packages/discovery-react-components/src/components/SearchInput/SearchInput.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { Search as CarbonSearchInput } from 'carbon-components-react';
1010
import ListBox from 'carbon-components-react/es/components/ListBox';
1111
import { SearchApi, SearchContext } from 'components/DiscoverySearch/DiscoverySearch';
1212
import useDebounce from 'utils/useDebounce';
13-
import uuid from 'uuid';
13+
import { v4 as uuidv4 } from 'uuid';
1414
import { Search16 } from '@carbon/icons-react';
1515
import DiscoveryV2 from 'ibm-watson/discovery/v2';
1616
import { useDeepCompareCallback } from 'utils/useDeepCompareMemoize';
@@ -85,7 +85,7 @@ const SearchInput: FC<SearchInputProps> = ({
8585
}) => {
8686
const mergedMessages = { ...defaultMessages, ...messages };
8787

88-
const inputId = id || `search-input__${uuid.v4()}`;
88+
const inputId = id || `search-input__${uuidv4()}`;
8989
const autocompletionClassName = `${settings.prefix}--search-autocompletion`;
9090
const searchInputClassNames = [className, `${settings.prefix}--search-input--discovery`];
9191
const {
@@ -217,6 +217,12 @@ const SearchInput: FC<SearchInputProps> = ({
217217
}
218218
};
219219

220+
useEffect(() => {
221+
return function cleanup() {
222+
clearTimeout(focusTimeout);
223+
};
224+
});
225+
220226
// onFocus for the carbon search component and the autocomplete dropdown
221227
const handleOnFocus = (): void => {
222228
// cancel the timeout set in handleOnBlur

packages/discovery-react-components/src/components/StructuredQuery/__stories__/StructuredQuery.stories.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { StoryWrapper, DummySearchClient } from 'utils/storybookUtils';
55
import DiscoverySearch, { DiscoverySearchProps } from 'components/DiscoverySearch/DiscoverySearch';
66
import StructuredQuery from '../StructuredQuery';
77
import { defaultMessages } from '../messages';
8-
import marked from 'marked';
8+
import { marked } from 'marked';
99
import defaultReadme from './default.md';
1010
import { createDummyResponsePromise } from 'utils/testingUtils';
1111
import DiscoveryV2 from 'ibm-watson/discovery/v2';
@@ -51,7 +51,7 @@ storiesOf('StructuredQuery', module)
5151
},
5252
{
5353
info: {
54-
text: marked(defaultReadme)
54+
text: marked.parse(defaultReadme)
5555
}
5656
}
5757
);

0 commit comments

Comments
 (0)