Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Text is incompatible with almond even when inlining text during build #101

Open
zero298 opened this issue Feb 4, 2015 · 3 comments
Open

Comments

@zero298
Copy link

zero298 commented Feb 4, 2015

I set up my require.js project with the text plugin and built with r.js which inlined the text requirement. However, the load method of text depends on toUrl which require.js has, but almond does not since it does not support url loading. However, this resource was inlined so it really is available in the singular compressed file.

var parsed = text.parseName(name),
   nonStripName = parsed.moduleName +
   (parsed.ext ? '.' + parsed.ext : ''),
   url = req.toUrl(nonStripName),  // Almond has no support for toUrl
   useXhr = (masterConfig.useXhr) ||
   text.useXhr;

Is there a way to utilize text with almond after an r.js build?

@zero298
Copy link
Author

zero298 commented Feb 4, 2015

Actually, I think I may be doing something that the optimizer may not account for. Either that, or I'm doing something that I may not supposed to be doing. In my config, I set a path to my resource collection: images, json files, and such.

paths: {
    res: "../../res"
}

Then in a module, I require that in with text!

define([
    "text!res/json/quotes.json"
], function (
        quoteFile
        ) {
    // Do stuff with quoteFile
    return quoteFile;
});

When I build, I get an inlined version:

define('text/text!res/json/quotes.json',[],function () { return "...";})

However, if I don't use the path, everything seems to work correctly.

define([
    "text!../../../res/json/quotes.json"
], function (
        quoteFile
        ) {
    // Do stuff with quoteFile
    return quoteFile;
});

Produces:

define('text/text!namespace/../../../res/json/quotes.json',[],function () { return "...";})

Am I not supposed to do this with paths? Using the path and running the unoptimized version works fine. But the optimized will resolve to the incorrect path.

Neither works with almond

@alberto-acevedo
Copy link

zero298,

Did you find a solution or a workaround to your issue?. I'm having the same issue.

Thanks,

Alberto

@zero298
Copy link
Author

zero298 commented Dec 7, 2015

@alberto-acevedo No, I don't believe that I did. I ended up just using the full require.js loader rather than almond. I was planning on comparing how dojo deals with the text plugin and comparing that to almond to see what the issue was.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants