使用webpack构建的旧骨干和木偶

时间:2018-07-13 16:37:43

标签: javascript webpack backbone.js marionette webpack-dev-server

说明

我正在尝试将“ webpack”构建添加到具有主干和木偶的旧项目中。

出现错误

backbone.marionette.js:3228 Uncaught TypeError: Cannot read property 'radio' of undefined
    at constructor._initChannel (backbone.marionette.js:3228)
    at new constructor (backbone.marionette.js:3096)
    at eval (tzook.js:128)
    at Object../frontend-app/tzook.js (main.bundle.js:7754)
    at __webpack_require__ (main.bundle.js:79)
    at eval (webpack:///multi_(:3000/webpack)-dev-server/client?:2:18)
    at Object.0 (main.bundle.js:9043)
    at __webpack_require__ (main.bundle.js:79)
    at checkDeferredModules (main.bundle.js:46)
    at main.bundle.js:152

所以我尝试做:

var Backbone = require('backbone'),
    babysitter = require('backbone.babysitter'),
    wreqr = require('backbone.wreqr');
Backbone.Wreqr = wreqr;

但是正如我在backbone.marionette.js文件中看到的那样。 我加载自己的主干网没有关系,因为它加载了自己的版本:/

版本:

"backbone": "1.2.3",
    "backbone-forms": "0.14.0",
    "backbone.marionette": "^2.4.4",
    "backbone.paginator": "~2.0.2",
    "backbone.subroute": "^0.4.4",
    "backbone.wreqr": "^1.0.0",



(function(root, factory) {

  if (true) {
    !(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(/*! backbone */ "./node_modules/backbone.marionette/node_modules/backbone/backbone.js"), __webpack_require__(/*! underscore */ "./node_modules/underscore/underscore.js"), __webpack_require__(/*! backbone.wreqr */ "./node_modules/backbone.wreqr/lib/backbone.wreqr.js"), __webpack_require__(/*! backbone.babysitter */ "./node_modules/backbone.babysitter/lib/backbone.babysitter.js")], __WEBPACK_AMD_DEFINE_RESULT__ = (function(Backbone, _) {
      return (root.Marionette = root.Mn = factory(root, Backbone, _));
    }).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),
                __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  } else { var BabySitter, Wreqr, _, Backbone; }

1 个答案:

答案 0 :(得分:0)

  

注意:在Marionette v3的下一个主要版本中,Wreqr将被替换为更新的库Radio。

您需要在木偶之前添加backbone.radio作为依赖项