Skip to content

Commit 6862975

Browse files
fix(overmind): fix ssr environment issues
1 parent f415d83 commit 6862975

File tree

3 files changed

+27
-23
lines changed

3 files changed

+27
-23
lines changed

packages/node_modules/overmind/src/Overmind.ts

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,10 @@ export class Overmind<ThisConfig extends IConfiguration>
4747
) {
4848
const name = options.name || 'OvermindApp'
4949
const devEnv = options.devEnv || 'development'
50-
const isNode = typeof process !== "undefined" && process.title && process.title.includes('node')
50+
const isNode =
51+
typeof process !== 'undefined' &&
52+
process.title &&
53+
process.title.includes('node')
5154

5255
this.delimiter = options.delimiter || '.'
5356
this.isStrict = Boolean(options.strict)
@@ -249,7 +252,7 @@ export class Overmind<ThisConfig extends IConfiguration>
249252
const proxyStateTreeInstance = new proxyStateTree.ProxyStateTree(
250253
this.getState(configuration) as any,
251254
{
252-
devmode,
255+
devmode: devmode && !ssr,
253256
ssr,
254257
delimiter: this.delimiter,
255258
onSetFunction: (tree, path, target, prop, func) => {
@@ -509,23 +512,23 @@ export class Overmind<ThisConfig extends IConfiguration>
509512

510513
if (this.mode.mode === utils.MODE_TEST) {
511514
this.addExecutionMutation(mutation)
515+
} else if (this.mode.mode === utils.MODE_DEFAULT) {
516+
pendingFlush = setTimeout(() => {
517+
pendingFlush = null
518+
const flushData = execution.flush(true)
519+
520+
if (this.devtools && flushData.mutations.length) {
521+
this.devtools.send({
522+
type: 'flush',
523+
data: {
524+
...execution,
525+
...flushData,
526+
mutations: flushData.mutations,
527+
},
528+
})
529+
}
530+
})
512531
}
513-
514-
pendingFlush = setTimeout(() => {
515-
pendingFlush = null
516-
const flushData = execution.flush(true)
517-
518-
if (this.devtools && flushData.mutations.length) {
519-
this.devtools.send({
520-
type: 'flush',
521-
data: {
522-
...execution,
523-
...flushData,
524-
mutations: flushData.mutations,
525-
},
526-
})
527-
}
528-
})
529532
})
530533

531534
let result = action(context, scopedValue)

packages/node_modules/proxy-state-tree/package.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,6 @@
3636
"url": "https://github.com/christianalfoni/proxy-state-tree/issues"
3737
},
3838
"homepage": "https://github.com/christianalfoni/proxy-state-tree#readme",
39-
"dependencies": {
40-
"is-plain-obj": "^1.1.0"
41-
},
4239
"devDependencies": {
4340
"bundlesize": "^0.17.2",
4441
"terser-webpack-plugin": "^1.3.0",

packages/node_modules/proxy-state-tree/src/Proxyfier.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import isPlainObject from 'is-plain-obj'
2-
31
import { IMutationTree, ITrackStateTree, TTree } from './types'
42

53
const ENVIRONMENT = (() => {
@@ -18,6 +16,12 @@ export const PATH = Symbol('PATH')
1816
export const VALUE = Symbol('VALUE')
1917
export const PROXY_TREE = Symbol('PROXY_TREE')
2018

19+
const isPlainObject = (value: any) => {
20+
return (
21+
String(value) === '[object Object]' && value.constructor.name === 'Object'
22+
)
23+
}
24+
2125
const arrayMutations = new Set([
2226
'push',
2327
'shift',

0 commit comments

Comments
 (0)