Skip to content

Commit 9a1d065

Browse files
authored
Merge pull request #4058 from reduxjs/feature/4x-remove-legacy-deps
2 parents f3680b5 + d29cbfa commit 9a1d065

File tree

8 files changed

+21
-20
lines changed

8 files changed

+21
-20
lines changed

.github/workflows/size.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ jobs:
1414
- uses: preactjs/compressed-size-action@v1
1515
with:
1616
repo-token: '${{ secrets.GITHUB_TOKEN }}'
17-
pattern: './{dist,es,lib}/*.js'
17+
pattern: './{dist,es,lib}/*.{js,mjs}'

index.d.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/// <reference types="symbol-observable" />
2-
31
/**
42
* An *action* is a plain object that represents an intention to change the
53
* state. Actions are the only way to get data into the store. Any data,
@@ -224,6 +222,12 @@ export interface Unsubscribe {
224222
(): void
225223
}
226224

225+
declare global {
226+
interface SymbolConstructor {
227+
readonly observable: symbol
228+
}
229+
}
230+
227231
/**
228232
* A minimal observable of state changes.
229233
* For more information, see the observable proposal:

package-lock.json

Lines changed: 3 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@
4949
"examples:test": "cross-env CI=true babel-node examples/testAll.js"
5050
},
5151
"dependencies": {
52-
"loose-envify": "^1.4.0",
53-
"symbol-observable": "^2.0.3",
5452
"@babel/runtime": "^7.9.2"
5553
},
5654
"devDependencies": {
@@ -102,11 +100,6 @@
102100
]
103101
}
104102
],
105-
"browserify": {
106-
"transform": [
107-
"loose-envify"
108-
]
109-
},
110103
"jest": {
111104
"testRegex": "(/test/.*\\.spec\\.[tj]s)$",
112105
"coverageProvider": "v8"

src/createStore.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import $$observable from 'symbol-observable'
1+
import $$observable from './utils/symbol-observable'
22

33
import ActionTypes from './utils/actionTypes'
44
import isPlainObject from './utils/isPlainObject'

src/utils/symbol-observable.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// Inlined version of the `symbol-observable` polyfill
2+
export default (() =>
3+
(typeof Symbol === 'function' && Symbol.observable) || '@@observable')()

test/createStore.spec.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,15 @@ import {
1111
import * as reducers from './helpers/reducers'
1212
import { from } from 'rxjs'
1313
import { map } from 'rxjs/operators'
14-
import $$observable from 'symbol-observable'
14+
import $$observable from '../src/utils/symbol-observable'
1515

1616
describe('createStore', () => {
1717
it('exposes the public API', () => {
1818
const store = createStore(combineReducers(reducers))
19-
const methods = Object.keys(store)
19+
20+
// Since switching to internal Symbol.observable impl, it will show up as a key in node env
21+
// So we filter it out
22+
const methods = Object.keys(store).filter((key) => key !== $$observable)
2023

2124
expect(methods.length).toBe(4)
2225
expect(methods).toContain('subscribe')

test/typescript/store.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ import {
99
Unsubscribe,
1010
Observer,
1111
} from 'redux'
12-
import 'symbol-observable'
12+
// @ts-ignore
13+
import $$observable from '../src/utils/symbol-observable'
1314

1415
type BrandedString = string & { _brand: 'type' }
1516
const brandedString = 'a string' as BrandedString

0 commit comments

Comments
 (0)