Skip to content

Unable to use 'noext' plugin with config "paths" #47

@Anthony-Mckale

Description

@Anthony-Mckale

Hi

first thanks your our excellent plugins

had a wee issue with aliased modules e.g. with explicit paths

requirejs.config({
    paths: {
        "noext": '../../shared/js/requirejs/plugins/0.3.2/noext',
        "dynamicstripconfig": "../php/domain/config.php"
    }
});

It was breaking the "toUrl" translation between "dynamicstripconfig" to "../php/domain/config.php" inside requirejs

Rewrote "noext" so it now wait till the "load" instead of the "normalize" to inject the query string to interrupt the ".js" postfixing

New noext.js ->

/** @license
 * RequireJS plugin for loading files without adding the JS extension, useful for
 * JSONP services and any other kind of resource that already contain a file
 * extension or that shouldn't have one (like dynamic scripts).
 * Author: Miller Medeiros (0 - 0.3.1)
 * Author: Anthony Mckale (0.3.2)
 * Version: 0.3.2 (2014/03/10)
 * 0.3.2 - Moved parameter add to load, so we could use paths with this extension 
 * 
 * Released under the MIT license
 */
define(function(){
var QUERY_PARAM = 'noext';

//API
return {
    load : function(name, req, onLoad, config) {
        var rawrequireurl = req.toUrl(name);
        rawrequireurl += (rawrequireurl.indexOf('?') < 0)? '?' : '&';
        rawrequireurl += QUERY_PARAM +'=1';
        req([rawrequireurl], function(mod){
            onLoad(mod);
        });
    },
    normalize : function(name, norm){
        return name;
    }

};
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions