Skip to content

model get lost in deepCloneStateWithoutComputed when using webpack harmony export #616

Closed
@magicdawn

Description

@magicdawn

with tsconfig compilerOptions.module = esnext, the compiled code using __webpack_require__.d

image

& it's using defineProperty

// define getter function for harmony exports
	__webpack_require__.d = function(exports, name, getter) {
		if(!__webpack_require__.o(exports, name)) {
			Object.defineProperty(exports, name, { enumerable: true, get: getter });
		}
	};

will make code like

// @file src/models/index.ts

import count from './count'
export count
// @file src/store.ts
import * as models from './models/index'

models will have a count property with a getter.
final with the created store, the count model is lost.
when use useStoreState(state => state.count.num) will throw a error

demo code see
https://github.com/magicdawn/easy-peasy-demo
commit 1fd420c

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions