canjsstealjs

CanJS with StealJS 0.3.0


I am playing around on an app with canjs 2.1.0 and stealjs 0.3.0:

I have stealconfig.js like below:

System.config({
    map: {
        "can/util/util": "can/util/jquery/jquery",
        "jquery/jquery": "jquery"
    },
    paths: {
        "jquery": "bower_components/jquery/dist/jquery.js",
        "can/*": "bower_components/canjs/*.js",
        "lodash": "bower_components/lodash/dist/lodash.js",
        "bootstrap" : "bower_components/bootstrap/dist/js/bootstrap.js",
        "bootstrap.css" : "bower_components/bootstrap/dist/css/bootstrap.csscss"
    },
    meta: {
        jquery: {
            exports: "jQuery",
            deps: supportsUnknownElements ? undefined : ["can/lib/html5shiv.js"]
        }
    },
    ext: {
        mustache: "can/view/mustache/system"
    }
});

And my main.js is:

import can from 'can/';
import $ from 'jquery';
import _ from 'lodash';
import LayoutController from 'apps/layout/layout';

can.route.ready();
new LayoutController(document.body, {});

layout .js loos like:

(function() {
  'use strict';
  var can = require('can/'),
      layoutView = require('./view/layout.mustache!');
})();

But, I get these errors.

GET http://localhost:8080/bower_components/canjs/can.js 404 (Not Found)
GET http://localhost:8080/bower_components/canjs/view/mustache/system.js 404 (Not Found)

How can I solve this issue?


Solution

  • To use CanJS with the new Steal you need to be using the minor branch of CanJS. There hasn't been a tag release yet that supports the new version of Steal.

    You can do this easily with bower, just like this (in your dependencies):

    "canjs": "bitovi/canjs#minor"
    

    Other comments:

    1) When you're using CommonJS (as you are in layout.js) you don't need to wrap it in an self-calling function. That will be done by Steal.

    2) The error suggests it cannot find the file. Are you certain you have ran "bower install" to install CanJS? Your configuration looks fine.