Skip to content

Commit

Permalink
feat(client): introduce core-js
Browse files Browse the repository at this point in the history
  • Loading branch information
hiroppy committed Jun 10, 2019
1 parent 9c5f6bb commit 3ea39ad
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
5 changes: 3 additions & 2 deletions client-src/default/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { log, setLogLevel } from './utils/log';
import sendMessage from './utils/sendMessage';
import reloadApp from './utils/reloadApp';
import createSocketUrl from './utils/createSocketUrl';
import { array, string } from './polyfill';

const status = {
isUnloading: false,
Expand All @@ -31,7 +32,7 @@ self.addEventListener('beforeunload', () => {

if (typeof window !== 'undefined') {
const qs = window.location.search.toLowerCase();
options.hotReload = qs.indexOf('hotreload=false') === -1;
options.hotReload = !string.includes(qs, 'hotreload=false');
}

const onSocketMessage = {
Expand Down Expand Up @@ -63,7 +64,7 @@ const onSocketMessage = {
},
'log-level': function logLevel(level) {
const hotCtx = require.context('webpack/hot', false, /^\.\/log$/);
if (hotCtx.keys().indexOf('./log') !== -1) {
if (array.includes(hotCtx.keys(), './log')) {
hotCtx('./log').setLogLevel(level);
}
setLogLevel(level);
Expand Down
10 changes: 10 additions & 0 deletions client-src/default/polyfill.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import stringIncludes from 'core-js/features/string/includes';
import arrayIncludes from 'core-js/features/array/includes';

export const array = {
includes: arrayIncludes,
};

export const string = {
includes: stringIncludes,
};
5 changes: 5 additions & 0 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"chokidar": "^3.0.1",
"compression": "^1.7.4",
"connect-history-api-fallback": "^1.6.0",
"core-js": "^3.1.3",
"debug": "^4.1.1",
"del": "^4.1.1",
"express": "^4.17.1",
Expand Down

0 comments on commit 3ea39ad

Please sign in to comment.