Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove symbol-observable and loose-envify deps #4058

Merged
merged 4 commits into from Apr 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/size.yaml
Expand Up @@ -14,4 +14,4 @@ jobs:
- uses: preactjs/compressed-size-action@v1
with:
repo-token: '${{ secrets.GITHUB_TOKEN }}'
pattern: './{dist,es,lib}/*.js'
pattern: './{dist,es,lib}/*.{js,mjs}'
8 changes: 6 additions & 2 deletions index.d.ts
@@ -1,5 +1,3 @@
/// <reference types="symbol-observable" />

/**
* An *action* is a plain object that represents an intention to change the
* state. Actions are the only way to get data into the store. Any data,
Expand Down Expand Up @@ -224,6 +222,12 @@ export interface Unsubscribe {
(): void
}

declare global {
interface SymbolConstructor {
readonly observable: symbol
}
}

/**
* A minimal observable of state changes.
* For more information, see the observable proposal:
Expand Down
9 changes: 3 additions & 6 deletions package-lock.json

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

7 changes: 0 additions & 7 deletions package.json
Expand Up @@ -49,8 +49,6 @@
"examples:test": "cross-env CI=true babel-node examples/testAll.js"
},
"dependencies": {
"loose-envify": "^1.4.0",
"symbol-observable": "^2.0.3",
"@babel/runtime": "^7.9.2"
},
"devDependencies": {
Expand Down Expand Up @@ -102,11 +100,6 @@
]
}
],
"browserify": {
"transform": [
"loose-envify"
]
},
"jest": {
"testRegex": "(/test/.*\\.spec\\.[tj]s)$",
"coverageProvider": "v8"
Expand Down
2 changes: 1 addition & 1 deletion src/createStore.js
@@ -1,4 +1,4 @@
import $$observable from 'symbol-observable'
import $$observable from './utils/symbol-observable'

import ActionTypes from './utils/actionTypes'
import isPlainObject from './utils/isPlainObject'
Expand Down
3 changes: 3 additions & 0 deletions src/utils/symbol-observable.js
@@ -0,0 +1,3 @@
// Inlined version of the `symbol-observable` polyfill
export default (() =>
(typeof Symbol === 'function' && Symbol.observable) || '@@observable')()
7 changes: 5 additions & 2 deletions test/createStore.spec.js
Expand Up @@ -11,12 +11,15 @@ import {
import * as reducers from './helpers/reducers'
import { from } from 'rxjs'
import { map } from 'rxjs/operators'
import $$observable from 'symbol-observable'
import $$observable from '../src/utils/symbol-observable'

describe('createStore', () => {
it('exposes the public API', () => {
const store = createStore(combineReducers(reducers))
const methods = Object.keys(store)

// Since switching to internal Symbol.observable impl, it will show up as a key in node env
// So we filter it out
const methods = Object.keys(store).filter((key) => key !== $$observable)

expect(methods.length).toBe(4)
expect(methods).toContain('subscribe')
Expand Down
3 changes: 2 additions & 1 deletion test/typescript/store.ts
Expand Up @@ -9,7 +9,8 @@ import {
Unsubscribe,
Observer,
} from 'redux'
import 'symbol-observable'
// @ts-ignore
import $$observable from '../src/utils/symbol-observable'

type BrandedString = string & { _brand: 'type' }
const brandedString = 'a string' as BrandedString
Expand Down