bottleneck
Choose style:

Author Topic: Require.js + TypeError: Backbone is undefined after optimization  (Read 12829 times)

0 Members and 1 Guest are viewing this topic.

Offline ronnysharma

  • Newbie
  • Posts: 3
  • Thanks: 0
  • Registered : 08/07/2018
    YearsYearsYearsYearsYearsYears
Backbone app works fine pre-optimized. After using r.js (with almond), I succesfully generate a single output file that always seems to throw the 'TypeError: Backbone is undefined' error in the module immediately following backbone.

For example, when the output from r.js looks like this:

/consumer/public/javascripts/vendor/almond.js
/consumer/public/javascripts/vendor/jquery-1.7.2.js
/consumer/public/javascripts/vendor/underscore.jshttps://dltutuapp.com/ https://9apps.ooo/ https://showbox.software/download/
/consumer/public/javascripts/vendor/bootstrap.js
/consumer/public/javascripts/vendor/backbone.js
/consumer/public/javascripts/rjs/src/mnp/prop_m.js
/consumer/public/javascripts/rjs/src/mnp/prop_c.js
/consumer/public/javascripts/vendor/play-mustache.js
...
/consumer/public/javascripts/main.js
Upon loading the optimized file in the browser, the error above will be thrown in the 'prop_m.js' module when referencing Backbone. Using require 2.0.5, Backbone 0.9.2, and almond 0.1.4. Thanks in advance for any help.

PS: build.js looks like this:

    ({
    baseUrl:   "./",
    mainConfigFile: "main.js",
    paths: {
    'almond': 'vendor/almond',

        // need a path to the cs-compiled .js file
        'app' : '../../target/scala-2.9.1/resource_managed/main/public/javascripts/rjs/src/app',
        'mnp/router' : '../../target/scala-2.9.1/resource_managed/main/public/javascripts/rjs/src/mnp/router',
        'mnp/search_form_v' : '../../target/scala-2.9.1/resource_managed/main/public/javascripts/rjs/src/mnp/search_form_v',
        'mnp/prop_c' : '../../target/scala-2.9.1/resource_managed/main/public/javascripts/rjs/src/mnp/prop_c',
        'mnp/prop_m' : '../../target/scala-2.9.1/resource_managed/main/public/javascripts/rjs/src/mnp/prop_m',
        'mnp/prop_list_v' : '../../target/scala-2.9.1/resource_managed/main/public/javascripts/rjs/src/mnp/prop_list_v',
        'mnp/prop_item_v' : '../../target/scala-2.9.1/resource_managed/main/public/javascripts/rjs/src/mnp/prop_item_v'
    },


    /*not compatible with modules*/
    name: 'vendor/almond',
    include: ["main"],

    out: "dist/app.js",
    /*not compatible with modules*/

    keepBuildDir: false,

    preserveLicenseComments: false,
    optimize: "none",
    wrap: {
        start: "(function(global, define) {\n"+
           // check for amd loader on global namespace
            "  var globalDefine = global.define;\n",

        end:   "  var library = require('main');\n"+
            "  if(typeof module !== 'undefined' && module.exports) {\n"+
            // export library for node
            "    module.exports = library;\n"+
« Last Edit: October 02, 2018, 06:15:31 am by ronnysharma »

Offline Jyrki

  • Newbie
  • Posts: 2
  • Thanks: 0
  • Registered : 23/03/2021
    YearsYearsYears
Re: Require.js + TypeError: Backbone is undefined after optimization
« Reply #1 on: March 23, 2021, 03:11:15 am »
Hello,

If anyone else runs into this problem:

Amd-versions of backbone worked. Here's a solution: https://stackoverflow.com/questions/8131265/loading-backbone-and-underscore-using-requirejs?rq=1 to do my trigonometry homework
« Last Edit: June 09, 2021, 05:55:51 am by Jyrki »

 

Page created in 0.043 seconds with 21 queries.