Skip to content

Commit f343c8c

Browse files
committed
fix(browser-compat): replace hash-obj w object-hash and fix example for IE
fix #84
1 parent 69aa4f0 commit f343c8c

File tree

8 files changed

+30
-43
lines changed

8 files changed

+30
-43
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ coverage
1414

1515
# built example app
1616
dist
17+
dist.zip
1718

1819
# secrets
1920
config.yml
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
entries:
2-
- lib/index.js:dist/index.js
2+
- example.js:dist/index.js
33
- lib/index.css:dist/index.css

example.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
// Polyfills to support IE, etc.
2+
// Note: I attempted to update to core-js@3, but ran into issues about ES6
3+
// imports. core-js@2 does not have core-js/stable, which is why we're importing
4+
// the root.
5+
import 'core-js'
6+
import 'regenerator-runtime/runtime'
17
// import necessary React/Redux libraries
28
import { createHashHistory } from 'history'
39
import { connectRouter, routerMiddleware } from 'connected-react-router'

index.html

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
11
<!DOCTYPE html>
22
<html>
33
<head>
4+
<meta charset="utf-8">
45
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0">
5-
<title>OTP R.R.</title>
6-
76
<link rel="stylesheet" href="dist/index.css">
8-
<link rel="stylesheet" href="node_modules/transitive-js/lib/transitive.css">
97
<link rel="stylesheet" href="example.css">
10-
<link rel="stylesheet" href="node_modules/leaflet.polylinemeasure/Leaflet.PolylineMeasure.css" />
11-
8+
<title>OTP R.R.</title>
129
</head>
1310
<body>
1411
<div id="root"></div>
15-
<script src="/example.js"></script>
12+
<script src="dist/index.js"></script>
1613
</body>
1714
</html>

lib/actions/api.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* globals fetch */
22
import { push, replace } from 'connected-react-router'
3-
import hashObject from 'hash-obj'
3+
import hash from 'object-hash'
44
import { createAction } from 'redux-actions'
55
import qs from 'qs'
66
import moment from 'moment'
@@ -853,7 +853,7 @@ function createQueryAction (endpoint, responseAction, errorAction, options = {})
853853
// don't make a request to a URL that has already seen the same request
854854
// within the last 10 seconds
855855
const throttleKey = options.fetchOptions
856-
? `${url}-${hashObject(options.fetchOptions)}`
856+
? `${url}-${hash(options.fetchOptions)}`
857857
: url
858858
if (throttledUrls[throttleKey] && throttledUrls[throttleKey] > now() - TEN_SECONDS) {
859859
// URL already had a request within last 10 seconds, warn and exit

lib/index.css

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
@import url(node_modules/font-awesome/css/font-awesome.css);
55
@import url(node_modules/react-dates/lib/css/_datepicker.css);
66
@import url(node_modules/react-select/dist/react-select.css);
7+
@import url(node_modules/transitive-js/lib/transitive.css);
8+
@import url(node_modules/leaflet.polylinemeasure/Leaflet.PolylineMeasure.css);
79

810
@import url(lib/components/app/app.css);
911
@import url(lib/components/map/map.css);

package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,16 @@
33
"description": "A library for writing modern OpenTripPlanner-compatible multimodal journey planning web applications using React and Redux",
44
"main": "build/index.js",
55
"scripts": {
6-
"build": "mastarm build",
6+
"build": "mastarm build --env production",
77
"cover": "mastarm test --coverage",
88
"jest": "mastarm test",
99
"lint": "mastarm lint lib --quiet",
1010
"lint-docs": "documentation lint lib/**/*.js",
1111
"prepublish": "mastarm prepublish --config configurations/prepublish",
1212
"prestart": "yarn",
1313
"test": "yarn run lint && yarn run lint-docs && yarn run jest",
14-
"start": "mastarm build --serve example.js"
14+
"start": "mastarm build --serve example.js",
15+
"zip": "zip -r dist.zip index.html example.css dist"
1516
},
1617
"standard": {
1718
"parser": "babel-eslint"
@@ -34,12 +35,12 @@
3435
"clone": "^2.1.0",
3536
"connected-react-router": "^5.0.1",
3637
"copy-to-clipboard": "^3.0.8",
38+
"core-js": "2",
3739
"currency-formatter": "^1.4.2",
3840
"d3-selection": "^1.3.0",
3941
"d3-zoom": "^1.7.1",
4042
"deep-equal": "^1.0.1",
4143
"font-awesome": "^4.7.0",
42-
"hash-obj": "^2.0.0",
4344
"haversine": "^1.1.0",
4445
"history": "^4.7.2",
4546
"immutability-helper": "^2.1.1",
@@ -51,6 +52,7 @@
5152
"lodash.isequal": "^4.5.0",
5253
"moment": "^2.17.1",
5354
"moment-timezone": "^0.5.23",
55+
"object-hash": "^1.3.1",
5456
"object-path": "^0.11.3",
5557
"prop-types": "^15.6.0",
5658
"qs": "^6.3.0",

yarn.lock

Lines changed: 10 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4029,16 +4029,16 @@ core-js-pure@3.1.4:
40294029
resolved "https://registry.yarnpkg.com/core-js-pure/-/core-js-pure-3.1.4.tgz#5fa17dc77002a169a3566cc48dc774d2e13e3769"
40304030
integrity sha512-uJ4Z7iPNwiu1foygbcZYJsJs1jiXrTTCvxfLDXNhI/I+NHbSIEyr548y4fcsCEyWY0XgfAG/qqaunJ1SThHenA==
40314031

4032+
core-js@2, core-js@^2.4.0, core-js@^2.6.5:
4033+
version "2.6.9"
4034+
resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.6.9.tgz#6b4b214620c834152e179323727fc19741b084f2"
4035+
integrity sha512-HOpZf6eXmnl7la+cUdMnLvUxKNqLUzJvgIziQ0DiF3JwSImNphIqdGqzj6hIKyX04MmV0poclQ7+wjWvxQyR2A==
4036+
40324037
core-js@^1.0.0:
40334038
version "1.2.7"
40344039
resolved "https://registry.yarnpkg.com/core-js/-/core-js-1.2.7.tgz#652294c14651db28fa93bd2d5ff2983a4f08c636"
40354040
integrity sha1-ZSKUwUZR2yj6k70tX/KYOk8IxjY=
40364041

4037-
core-js@^2.4.0, core-js@^2.6.5:
4038-
version "2.6.9"
4039-
resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.6.9.tgz#6b4b214620c834152e179323727fc19741b084f2"
4040-
integrity sha512-HOpZf6eXmnl7la+cUdMnLvUxKNqLUzJvgIziQ0DiF3JwSImNphIqdGqzj6hIKyX04MmV0poclQ7+wjWvxQyR2A==
4041-
40424042
core-js@^2.5.0:
40434043
version "2.6.5"
40444044
resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.6.5.tgz#44bc8d249e7fb2ff5d00e0341a7ffb94fbf67895"
@@ -6557,15 +6557,6 @@ hash-base@^3.0.0:
65576557
inherits "^2.0.1"
65586558
safe-buffer "^5.0.1"
65596559

6560-
hash-obj@^2.0.0:
6561-
version "2.0.0"
6562-
resolved "https://registry.yarnpkg.com/hash-obj/-/hash-obj-2.0.0.tgz#dc50b5ef9f724cface4985dcec98dd98dacd103e"
6563-
integrity sha512-A+HRqvu8VeDDiSn0KyhMff12RrN8VkvLEkvyPVteTiqUKoKYsIaNo2oeu0l6nehhiTWjkzsCfvi7ZOIUgr9wjw==
6564-
dependencies:
6565-
is-obj "^2.0.0"
6566-
sort-keys "^3.0.0"
6567-
type-fest "^0.4.1"
6568-
65696560
hash.js@^1.0.0, hash.js@^1.0.3:
65706561
version "1.1.7"
65716562
resolved "https://registry.yarnpkg.com/hash.js/-/hash.js-1.1.7.tgz#0babca538e8d4ee4a0f8988d68866537a003cf42"
@@ -7358,11 +7349,6 @@ is-obj@^1.0.0:
73587349
resolved "https://registry.yarnpkg.com/is-obj/-/is-obj-1.0.1.tgz#3e4729ac1f5fde025cd7d83a896dab9f4f67db0f"
73597350
integrity sha1-PkcprB9f3gJc19g6iW2rn09n2w8=
73607351

7361-
is-obj@^2.0.0:
7362-
version "2.0.0"
7363-
resolved "https://registry.yarnpkg.com/is-obj/-/is-obj-2.0.0.tgz#473fb05d973705e3fd9620545018ca8e22ef4982"
7364-
integrity sha512-drqDG3cbczxxEJRoOXcOjtdp1J/lyp1mNn0xaznRs8+muBhgQcrnbspox5X5fOw0HnMnbfDzvnEMEtqDEJEo8w==
7365-
73667352
is-path-inside@^1.0.0:
73677353
version "1.0.1"
73687354
resolved "https://registry.yarnpkg.com/is-path-inside/-/is-path-inside-1.0.1.tgz#8ef5b7de50437a3fdca6b4e865ef7aa55cb48036"
@@ -7374,11 +7360,6 @@ is-plain-obj@^1.0.0, is-plain-obj@^1.1.0:
73747360
resolved "https://registry.yarnpkg.com/is-plain-obj/-/is-plain-obj-1.1.0.tgz#71a50c8429dfca773c92a390a4a03b39fcd51d3e"
73757361
integrity sha1-caUMhCnfync8kqOQpKA7OfzVHT4=
73767362

7377-
is-plain-obj@^2.0.0:
7378-
version "2.0.0"
7379-
resolved "https://registry.yarnpkg.com/is-plain-obj/-/is-plain-obj-2.0.0.tgz#7fd1a7f1b69e160cde9181d2313f445c68aa2679"
7380-
integrity sha512-EYisGhpgSCwspmIuRHGjROWTon2Xp8Z7U03Wubk/bTL5TTRC5R1rGVgyjzBrk9+ULdH6cRD06KRcw/xfqhVYKQ==
7381-
73827363
is-plain-object@^2.0.1, is-plain-object@^2.0.3, is-plain-object@^2.0.4:
73837364
version "2.0.4"
73847365
resolved "https://registry.yarnpkg.com/is-plain-object/-/is-plain-object-2.0.4.tgz#2c163b3fafb1b606d9d17928f05c2a1c38e07677"
@@ -10013,6 +9994,11 @@ object-copy@^0.1.0:
100139994
define-property "^0.2.5"
100149995
kind-of "^3.0.3"
100159996

9997+
object-hash@^1.3.1:
9998+
version "1.3.1"
9999+
resolved "https://registry.yarnpkg.com/object-hash/-/object-hash-1.3.1.tgz#fde452098a951cb145f039bb7d455449ddc126df"
10000+
integrity sha512-OSuu/pU4ENM9kmREg0BdNrUDIl1heYa4mBZacJc+vVWz4GtAwu7jO8s4AIt2aGRUTqxykpWzI3Oqnsm13tTMDA==
10001+
1001610002
object-is@^1.0.1:
1001710003
version "1.0.1"
1001810004
resolved "https://registry.yarnpkg.com/object-is/-/object-is-1.0.1.tgz#0aa60ec9989a0b3ed795cf4d06f62cf1ad6539b6"
@@ -13474,13 +13460,6 @@ sort-keys@^1.0.0:
1347413460
dependencies:
1347513461
is-plain-obj "^1.0.0"
1347613462

13477-
sort-keys@^3.0.0:
13478-
version "3.0.0"
13479-
resolved "https://registry.yarnpkg.com/sort-keys/-/sort-keys-3.0.0.tgz#fa751737e3da363ef80632d4fd78e324d661fe9a"
13480-
integrity sha512-77XUKMiZN5LvQXZ9sgWfJza19AvYIDwaDGwGiULM+B5XYru8Z90Oh06JvqDlJczvjjYvssrV0aK1GI6+YXvn5A==
13481-
dependencies:
13482-
is-plain-obj "^2.0.0"
13483-
1348413463
sorted-object@~2.0.1:
1348513464
version "2.0.1"
1348613465
resolved "https://registry.yarnpkg.com/sorted-object/-/sorted-object-2.0.1.tgz#7d631f4bd3a798a24af1dffcfbfe83337a5df5fc"

0 commit comments

Comments
 (0)