require.js text plugin adds “.js” to the file name

后端 未结 7 1056
旧时难觅i
旧时难觅i 2021-01-08 00:31

I\'m trying to work with requirejs and text plugin and I have weird problem.

I have two web servers:

  1. localhost:3000 - act as CDN and h
7条回答
  •  独厮守ぢ
    2021-01-08 00:55

    I've digged in the code of the text plugin.

    I've found out that the text plugin assumes that the developer converted the text template to html since it resides on a different domain.

    I've change the code of the text plugin to not assume it.

    Someone thinks that I'm doing something wrong?

    The original code of the plugin:

                //Load the text. Use XHR if possible and in a browser.
                if (!hasLocation || useXhr(url, defaultProtocol, defaultHostName, defaultPort)) {
                    text.get(url, function (content) {
                        text.finishLoad(name, parsed.strip, content, onLoad, config);
                    });
                } else {
                    //Need to fetch the resource across domains. Assume
                    //the resource has been optimized into a JS module. Fetch
                    //by the module name + extension, but do not include the
                    //!strip part to avoid file system issues.
                    req([nonStripName], function (content) {
                        text.finishLoad(parsed.moduleName + '.' + parsed.ext,
                                        parsed.strip, content, onLoad, config);
                    });
                }
    

提交回复
热议问题