调试react-native packager的最佳方法是什么,不包括输出包中的依赖项?我有什么:
package.json
中,并显示在我的node_modules require('countdown')
行。var countdown = require('countdown')
,我可以看到包中没有包含countdown.js
的来源。这是编译后的js代码,它有问题:
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var RX = require("reactxp");
var countdown = require("countdown");
var styles = {
outerContainer: RX.Styles.createViewStyle({
flexDirection: "row"
}),
innerContainer: RX.Styles.createViewStyle({
flexDirection: "column",
alignItems: "center",
paddingHorizontal: 5
})
};
var CountdownTimer = (function (_super) {
__extends(CountdownTimer, _super);
function CountdownTimer() {
var _this = _super.call(this) || this;
_this._setStateToNow = function () {
_this.setState({ currentDate: new Date(Date.now()) });
};
_this.state = { currentDate: new Date() };
return _this;
}
CountdownTimer.prototype.componentDidMount = function () {
this.timerId = setInterval(this._setStateToNow, 1000);
};
CountdownTimer.prototype.componentWillUnmount = function () {
clearInterval(this.timerId);
};
CountdownTimer.prototype.render = function () {
// THIS LINE FAILS SINCE 'countdown' is {}
var diff = countdown(this.state.currentDate, this.props.untilDate, CountdownTimer.DIFF_ARGS);
....
};
CountdownTimer.DIFF_ARGS = countdown.DAYS |
countdown.HOURS |
countdown.MINUTES |
countdown.SECONDS;
return CountdownTimer;
}(RX.Component));
exports.CountdownTimer = CountdownTimer;
我得到的错误是Object is not a function
,并且记录var倒计时显示它是{}
,并且检查index.android.bundle
表明countdown.js
的源代码是不包括在内。
我正在使用node ./node_modules/react-native/local-cli/cli.js start