Skip to content

Commit fd4c9cd

Browse files
committed
fix(build): fix build to support commonJS
1 parent 0e9c2ce commit fd4c9cd

File tree

2 files changed

+90
-53
lines changed

2 files changed

+90
-53
lines changed

dist/easyState.js

Lines changed: 89 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
1-
/******/ (function(modules) { // webpackBootstrap
1+
(function webpackUniversalModuleDefinition(root, factory) {
2+
if(typeof exports === 'object' && typeof module === 'object')
3+
module.exports = factory();
4+
else if(typeof define === 'function' && define.amd)
5+
define([], factory);
6+
else {
7+
var a = factory();
8+
for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
9+
}
10+
})(this, function() {
11+
return /******/ (function(modules) { // webpackBootstrap
212
/******/ // The module cache
313
/******/ var installedModules = {};
414
/******/
@@ -63,7 +73,7 @@
6373
/******/ __webpack_require__.p = "";
6474
/******/
6575
/******/ // Load entry module and return exports
66-
/******/ return __webpack_require__(__webpack_require__.s = 13);
76+
/******/ return __webpack_require__(__webpack_require__.s = 14);
6777
/******/ })
6878
/************************************************************************/
6979
/******/ ([
@@ -259,9 +269,9 @@ const rawToProxy = new WeakMap()
259269
/***/ (function(module, __webpack_exports__, __webpack_require__) {
260270

261271
"use strict";
262-
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__nextTick__ = __webpack_require__(10);
263-
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__builtIns_index__ = __webpack_require__(9);
264-
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__store__ = __webpack_require__(11);
272+
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__nextTick__ = __webpack_require__(12);
273+
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__builtIns_index__ = __webpack_require__(11);
274+
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__store__ = __webpack_require__(13);
265275
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__internals__ = __webpack_require__(1);
266276
/* harmony export (immutable) */ __webpack_exports__["d"] = observe;
267277
/* unused harmony export unobserve */
@@ -424,9 +434,38 @@ function runObserver (observer) {
424434
/* 4 */
425435
/***/ (function(module, __webpack_exports__, __webpack_require__) {
426436

437+
"use strict";
438+
/* harmony export (immutable) */ __webpack_exports__["a"] = autoBind;
439+
const reactInternals = new Set([
440+
'constructor',
441+
'render',
442+
'componentWillMount',
443+
'componentDidMount',
444+
'componentWillReceiveProps',
445+
'shouldComponentUpdate',
446+
'componentWillUpdate',
447+
'componentDidUpdate',
448+
'componentWillUnmount'
449+
])
450+
451+
function autoBind (context, proto, isReact) {
452+
for (let key of Object.getOwnPropertyNames(proto)) {
453+
const value = proto[key]
454+
455+
if (typeof value === 'function' && !(isReact && reactInternals.has(key))) {
456+
context[key] = value.bind(context)
457+
}
458+
}
459+
}
460+
461+
462+
/***/ }),
463+
/* 5 */
464+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
465+
427466
"use strict";
428467
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__nx_js_observer_util__ = __webpack_require__(2);
429-
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__autoBind__ = __webpack_require__(12);
468+
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__autoBind__ = __webpack_require__(4);
430469
/* harmony export (immutable) */ __webpack_exports__["a"] = easyStateHOC;
431470

432471

@@ -436,10 +475,14 @@ const IS_DIRECT_RENDER = Symbol('is direct render')
436475
const RENDER_RESULT = Symbol('render result')
437476

438477
function easyStateHOC (WrappedComp) {
478+
if (typeof WrappedComp !== 'function') {
479+
throw new TypeError('easyComp expects a class component as argument.')
480+
}
481+
439482
return class EasyStateWrapper extends WrappedComp {
440483
constructor (props) {
441484
super(props)
442-
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__autoBind__["a" /* default */])(this, WrappedComp.prototype)
485+
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__autoBind__["a" /* default */])(this, WrappedComp.prototype, true)
443486
this.state = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__nx_js_observer_util__["a" /* observable */])(this.state)
444487
}
445488

@@ -486,7 +529,29 @@ function easyStateHOC (WrappedComp) {
486529

487530

488531
/***/ }),
489-
/* 5 */
532+
/* 6 */
533+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
534+
535+
"use strict";
536+
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__nx_js_observer_util__ = __webpack_require__(2);
537+
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__autoBind__ = __webpack_require__(4);
538+
/* harmony export (immutable) */ __webpack_exports__["a"] = easyStore;
539+
540+
541+
542+
function easyStore (store) {
543+
if (typeof store !== 'object') {
544+
throw new TypeError('easyStore expects an object as argument.')
545+
}
546+
547+
const observableStore = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__nx_js_observer_util__["a" /* observable */])(store)
548+
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__autoBind__["a" /* default */])(observableStore, store, false)
549+
return observableStore
550+
}
551+
552+
553+
/***/ }),
554+
/* 7 */
490555
/***/ (function(module, __webpack_exports__, __webpack_require__) {
491556

492557
"use strict";
@@ -510,7 +575,7 @@ function instrumentMap (target) {
510575

511576

512577
/***/ }),
513-
/* 6 */
578+
/* 8 */
514579
/***/ (function(module, __webpack_exports__, __webpack_require__) {
515580

516581
"use strict";
@@ -533,7 +598,7 @@ function instrumentSet (target) {
533598

534599

535600
/***/ }),
536-
/* 7 */
601+
/* 9 */
537602
/***/ (function(module, __webpack_exports__, __webpack_require__) {
538603

539604
"use strict";
@@ -550,7 +615,7 @@ function instrumentWeakMap (target) {
550615

551616

552617
/***/ }),
553-
/* 8 */
618+
/* 10 */
554619
/***/ (function(module, __webpack_exports__, __webpack_require__) {
555620

556621
"use strict";
@@ -566,14 +631,14 @@ function instrumentWeakSet (target) {
566631

567632

568633
/***/ }),
569-
/* 9 */
634+
/* 11 */
570635
/***/ (function(module, __webpack_exports__, __webpack_require__) {
571636

572637
"use strict";
573-
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Map__ = __webpack_require__(5);
574-
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__Set__ = __webpack_require__(6);
575-
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__WeakMap__ = __webpack_require__(7);
576-
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__WeakSet__ = __webpack_require__(8);
638+
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Map__ = __webpack_require__(7);
639+
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__Set__ = __webpack_require__(8);
640+
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__WeakMap__ = __webpack_require__(9);
641+
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__WeakSet__ = __webpack_require__(10);
577642

578643

579644

@@ -590,7 +655,7 @@ function instrumentWeakSet (target) {
590655

591656

592657
/***/ }),
593-
/* 10 */
658+
/* 12 */
594659
/***/ (function(module, __webpack_exports__, __webpack_require__) {
595660

596661
"use strict";
@@ -628,7 +693,7 @@ function onTask () {
628693

629694

630695
/***/ }),
631-
/* 11 */
696+
/* 13 */
632697
/***/ (function(module, __webpack_exports__, __webpack_require__) {
633698

634699
"use strict";
@@ -678,48 +743,20 @@ function releaseObserver (observer) {
678743

679744

680745
/***/ }),
681-
/* 12 */
682-
/***/ (function(module, __webpack_exports__, __webpack_require__) {
683-
684-
"use strict";
685-
/* harmony export (immutable) */ __webpack_exports__["a"] = autoBind;
686-
const internals = new Set([
687-
'constructor',
688-
'render',
689-
'componentWillMount',
690-
'componentDidMount',
691-
'componentWillReceiveProps',
692-
'shouldComponentUpdate',
693-
'componentWillUpdate',
694-
'componentDidUpdate',
695-
'componentWillUnmount'
696-
])
697-
698-
function autoBind (context, proto) {
699-
for (let key of Object.getOwnPropertyNames(proto)) {
700-
const value = proto[key]
701-
702-
if (typeof value === 'function' && !internals.has(key)) {
703-
context[key] = value.bind(context)
704-
}
705-
}
706-
}
707-
708-
709-
/***/ }),
710-
/* 13 */
746+
/* 14 */
711747
/***/ (function(module, __webpack_exports__, __webpack_require__) {
712748

713749
"use strict";
714750
Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
715-
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__easyComp__ = __webpack_require__(4);
716-
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__nx_js_observer_util__ = __webpack_require__(2);
751+
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__easyComp__ = __webpack_require__(5);
752+
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__easyStore__ = __webpack_require__(6);
717753
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easyComp", function() { return __WEBPACK_IMPORTED_MODULE_0__easyComp__["a"]; });
718-
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easyStore", function() { return __WEBPACK_IMPORTED_MODULE_1__nx_js_observer_util__["a"]; });
754+
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easyStore", function() { return __WEBPACK_IMPORTED_MODULE_1__easyStore__["a"]; });
719755

720756

721757

722758

723759

724760
/***/ })
725-
/******/ ]);
761+
/******/ ]);
762+
});

webpack.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
const path = require('path')
2-
const webpack = require('webpack')
32

43
module.exports = {
54
entry: './src/index.js',
65
output: {
76
path: path.join(__dirname, 'dist'),
87
filename: 'easyState.js',
8+
libraryTarget: 'umd'
99
}
1010
}

0 commit comments

Comments
 (0)