Skip to content

TypeError: Cannot read property "normalize" from undefined #221

Closed
@swarnak

Description

@swarnak

I am using Rhino and requirejs for code optimization. Here is my main config

require.config({
    paths : {
        jquery: "http://localhost:8080/static/jquery/1.7.2/jquery.min",
        "jquery-ui": "http://localhost:8080/static/jquery-ui/1.8.20/js/jquery-ui.custom.min",
        underscore : "http://localhost:8080/static/underscore/1.3.3/underscore",
        backbone : "http://localhost:8080/static//backbone/0.9.2/backbone",
        text : "http://localhost:8080/static/require/2.0.2/js/plugins/text"
    },

    shim: {
        "underscore": {
            exports: '_'
        },

        "backbone": {
            deps: ['jquery','underscore'],
            exports: function(){
                return this.Backbone.noConflict();
            }
        },

        "jquery-ui": ['jquery']

    }
});

Here is the require optimizer config. I have used the empty:scheme for all the network resources.

({
    mainConfigFile: "../src/main/webapp/js/main.js",
    name: "main",
    preserveLicenseComments: false,
    out: "../src/main/webapp/js/optimized-main.js",
    paths: {
        jquery: "empty:",
        "underscore": "empty:",
        backbone: "empty:",
        "jquery-ui": "empty:",
        text: "empty:"
    },
    exclude: ["jquery","jquery-ui","backbone","underscore","text"]
})

the optimizer fails when it encounters the following file

define([
  'underscore',
  'jquery',
  'jquery-ui',
  'backbone',
  '../models/user',
  '../collections/navItems',
  '../collections/urlPatterns',
  'text!../../templates/menu.html'
], function(_, $, jqueryui, Backbone,User,NavItemsCollection, UrlPatternsCollection, menuTemplate){ .........
}

I get the following error
optimize:
[exec] [java] Tracing dependencies for: main
[exec] [java] Cannot optimize network URL, skipping: empty:.js
[exec] [java] TypeError: Cannot read property "normalize" from undefined
[exec] [java] In module tree:
[exec] [java] main
[exec] [java] app
[exec] [java] router
[exec] [java] views/desktop
[exec] [java] TypeError: Cannot read property "normalize" from undefined
[exec] [java] In module tree:
[exec] [java] main
[exec] [java] app
[exec] [java] router
[exec] [java] views/desktop
[exec] [java] Java Result: 1

the issue is occurring only due to the line 'text!../../templates/menu.html'

There are no issues when using relative paths. Why am I seeing this error? Is there some other config that can tell the build to ignore this dependency?

I am using requireJS 2.0.2 and r.js 2.0.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions