1

I create the require.js project by r.js -o build.js

However, it gives me the exception on the console

inline

define('hbs/underscore',[],function() {

Here's the generated app.min.js

https://gist.github.com/poc7667/ecf36474b68799ebb29d

Any idea to fix the problem? I use the option wrap: true is to avoid conflicting with other scripts, which will give me the common mismatch exception

HTML

      <script type="text/javascript" src="js/app.min.js" ></script>

build.js

{
    name: "app.main.js",
    mainConfigFile: 'app.main.js',
    out: "./app.min.js",
    optimize: 'none',
    wrap: true,
    include: [ 'app.main' ],
    insertRequire: ["app.main"],
}

app.main.js

requirejs.config({
    paths: {
        jquery: './vendor/js/jquery-2.1.1.min',
        underscore: './vendor/js/underscore-min',
        backbone: './vendor/js/backbone-min',
        json2: './vendor/js/hbs/hbs/json2',
        hbs: './vendor/js/hbs/hbs',
        handlebars: './vendor/js/handlebars-v4.0.5',
        text: './vendor/js/text',
    },
    hbs: { // optional
        helpers: true,            // default: true
        templateExtension: 'hbs', // default: 'hbs'
        partialsUrl: ''           // default: ''
    },

    shim: {
        handlebars: {
            exports: 'Handlebars'
        },
        backbone: {
            deps: [
                'underscore',
                'jquery'
            ],
            exports: 'Backbone'
        },
        underscore: {
            exports: '_'
        },
        'jquery': {
            'exports' : '$'
        }
    },

});

require(["require", "app"],function(Req, App ){
    $("#sample_app_comments_plugin").hide();
    $('head').append('<link rel="stylesheet" href='+cfg.css_style_link+' type="text/css" />');
    return App.initialize();


});

hbs.js

    define(['hbs/handlebars', 'hbs/underscore', 'hbs/json2'], function (Handlebars, _, JSON) {
      function precompile(string, _unused, options) {
        var ast, environment;
    ....
newBike
  • 14,385
  • 29
  • 109
  • 192

1 Answers1

0

You probably do not have requirejs on the page.

You can use almondjs which will allow it to just have your app.js file. https://github.com/requirejs/almond

GrayTower
  • 61
  • 3