Skip to content

Commit 2486b6a

Browse files
praveenkumar1798Praveen Kumar
andauthored
feat: polyfill support (#173)
* feat: polyfill support * chore: comment test for redirect_uri * chore: remove @babel/plugin-transform-runtime * fix: breaking tests * chore: exclude transforms that make code slower * chore: update browser list for prod * chore: remove core-js and polyfill support Co-authored-by: Praveen Kumar <praveenkumar@Praveens-MacBook-Pro.local>
1 parent 8b29db9 commit 2486b6a

File tree

7 files changed

+30
-49
lines changed

7 files changed

+30
-49
lines changed

app/app.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
* code.
66
*/
77

8-
// Needed for redux-saga es6 generator support
98
// Import all the third party stuff
109
import React, { StrictMode } from 'react';
1110
import { createRoot } from 'react-dom/client';
@@ -22,7 +21,7 @@ import 'file-loader?name=.htaccess!./.htaccess';
2221

2322
const container = document.getElementById('app');
2423
const root = createRoot(container);
25-
const render = (messages) => {
24+
const render = () => {
2625
root.render(
2726
<StrictMode>
2827
<App />

app/containers/App/index.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import LanguageProvider from 'containers/LanguageProvider';
2525
import ErrorBoundary from '@app/components/ErrorBoundary/index';
2626
import { translationMessages } from '@app/i18n';
2727
import { Provider } from 'react-redux';
28-
import history from '@utils/history'
28+
import history from '@utils/history';
2929
import configureStore from '@app/configureStore';
3030
import If from '@app/components/If/index';
3131

@@ -34,14 +34,16 @@ const theme = {
3434
bg: colors.secondary
3535
};
3636

37-
export function App({ location }) {
37+
export function App() {
3838
const [store, setStore] = useState(null);
3939
const [persistor, setPersistor] = useState(null);
40+
41+
const { location } = history;
4042
useEffect(() => {
41-
// if (location.search.includes('?redirect_uri=')) {
42-
// const routeToReplace = new URLSearchParams(location.search).get('redirect_uri');
43-
// history.replace(routeToReplace);
44-
// }
43+
if (location.search.includes('?redirect_uri=')) {
44+
const routeToReplace = new URLSearchParams(location.search).get('redirect_uri');
45+
history.replace(routeToReplace);
46+
}
4547
const { store: s, persistor } = configureStore({}, history);
4648
setStore(s);
4749
setPersistor(persistor);
Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,17 @@
11
import React from 'react';
2-
import { renderProvider } from '@utils/testUtils';
32
import App from '../index';
4-
import { BrowserRouter } from 'react-router-dom';
53
import history from '@app/utils/history';
6-
import { waitFor } from '@testing-library/react';
4+
import { waitFor, render } from '@testing-library/react';
75

86
describe('<App /> container tests', () => {
97
it('should render and match the snapshot', () => {
10-
const { container } = renderProvider(
11-
<BrowserRouter>
12-
<App />
13-
</BrowserRouter>
14-
);
8+
const { container } = render(<App />);
159
expect(container).toMatchSnapshot();
1610
});
1711

1812
it('should redirect to redirect_uri query params if given in url', async () => {
1913
history.location.search = '?redirect_uri=/repos';
20-
renderProvider(<App />, history);
14+
render(<App />);
2115
await waitFor(() => expect(history.location.pathname).toBe('/repos'));
2216
});
2317
});

babel.config.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,7 @@ module.exports = {
33
[
44
'@babel/preset-env',
55
{
6-
targets: {
7-
browsers: ['> 0.25%, not dead']
8-
},
9-
modules: false,
10-
corejs: '3.6.5',
11-
useBuiltIns: 'entry'
6+
modules: false
127
}
138
],
149
'@babel/preset-react'
@@ -19,8 +14,7 @@ module.exports = {
1914
'@babel/plugin-syntax-optional-chaining',
2015
'styled-components',
2116
'@babel/plugin-proposal-class-properties',
22-
'@babel/plugin-syntax-dynamic-import',
23-
'@babel/plugin-transform-runtime' // Reduces code duplication
17+
'@babel/plugin-syntax-dynamic-import'
2418
],
2519
env: {
2620
production: {

jest.setup.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,12 @@ Object.defineProperty(window, 'matchMedia', {
3333
};
3434
})
3535
});
36+
37+
jest.mock('redux-persist/integration/react', () => ({
38+
PersistGate: (props) => props.children
39+
}));
40+
41+
jest.mock('redux-persist', () => ({
42+
...jest.requireActual('redux-persist'),
43+
persistReducer: jest.fn().mockImplementation((config, reducer) => reducer)
44+
}));

package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,13 @@
6666
"generate": "react-generate",
6767
"ls-uat-branches": "node ./internals/scripts/ls-branches.js"
6868
},
69-
"browserslist": [
70-
"last 2 versions",
71-
"> 1%",
72-
"IE 10"
73-
],
69+
"browserslist": {
70+
"production": [
71+
">0.2%",
72+
"not dead",
73+
"not op_mini all"
74+
]
75+
},
7476
"lint-staged": {
7577
"*.js": [
7678
"npm run lint:eslint:fix",
@@ -88,7 +90,6 @@
8890
"apisauce": "2.1.1",
8991
"chalk": "4.1.1",
9092
"compression": "1.7.4",
91-
"core-js": "3.6.5",
9293
"cross-env": "7.0.3",
9394
"dotenv": "10.0.0",
9495
"express": "4.16.4",
@@ -129,7 +130,6 @@
129130
"@babel/plugin-transform-modules-commonjs": "7.14.5",
130131
"@babel/plugin-transform-react-constant-elements": "7.14.5",
131132
"@babel/plugin-transform-react-inline-elements": "7.14.5",
132-
"@babel/plugin-transform-runtime": "^7.19.6",
133133
"@babel/preset-env": "^7.14.7",
134134
"@babel/preset-react": "^7.14.5",
135135
"@babel/register": "7.14.5",

yarn.lock

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2414,18 +2414,6 @@
24142414
dependencies:
24152415
"@babel/helper-plugin-utils" "^7.18.6"
24162416

2417-
"@babel/plugin-transform-runtime@^7.19.6":
2418-
version "7.19.6"
2419-
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-runtime/-/plugin-transform-runtime-7.19.6.tgz#9d2a9dbf4e12644d6f46e5e75bfbf02b5d6e9194"
2420-
integrity sha512-PRH37lz4JU156lYFW1p8OxE5i7d6Sl/zV58ooyr+q1J1lnQPyg5tIiXlIwNVhJaY4W3TmOtdc8jqdXQcB1v5Yw==
2421-
dependencies:
2422-
"@babel/helper-module-imports" "^7.18.6"
2423-
"@babel/helper-plugin-utils" "^7.19.0"
2424-
babel-plugin-polyfill-corejs2 "^0.3.3"
2425-
babel-plugin-polyfill-corejs3 "^0.6.0"
2426-
babel-plugin-polyfill-regenerator "^0.4.1"
2427-
semver "^6.3.0"
2428-
24292417
"@babel/plugin-transform-shorthand-properties@^7.14.5":
24302418
version "7.14.5"
24312419
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-shorthand-properties/-/plugin-transform-shorthand-properties-7.14.5.tgz#97f13855f1409338d8cadcbaca670ad79e091a58"
@@ -7929,11 +7917,6 @@ core-js-pure@^3.15.0:
79297917
resolved "https://registry.yarnpkg.com/core-js-pure/-/core-js-pure-3.15.1.tgz#8356f6576fa2aa8e54ca6fe02620968ff010eed7"
79307918
integrity sha512-OZuWHDlYcIda8sJLY4Ec6nWq2hRjlyCqCZ+jCflyleMkVt3tPedDVErvHslyS2nbO+SlBFMSBJYvtLMwxnrzjA==
79317919

7932-
core-js@3.6.5:
7933-
version "3.6.5"
7934-
resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.6.5.tgz#7395dc273af37fb2e50e9bd3d9fe841285231d1a"
7935-
integrity sha512-vZVEEwZoIsI+vPEuoF9Iqf5H7/M3eeQqWlQnYa8FSKKePuYTf5MWnxb5SDAzCa60b3JBRS5g9b+Dq7b1y/RCrA==
7936-
79377920
core-js@^1.0.0:
79387921
version "1.2.7"
79397922
resolved "https://registry.yarnpkg.com/core-js/-/core-js-1.2.7.tgz#652294c14651db28fa93bd2d5ff2983a4f08c636"

0 commit comments

Comments
 (0)