GithubHelp home page GithubHelp logo

Comments (7)

jrburke avatar jrburke commented on May 27, 2024

When using loader plugins with almond, the loader plugin should generate a named define call in the built output because almond does not support dynamic loading, which is something where req.toUrl() can come into play, and if the loader plugin is implementing a loaderPlugin.normalize method, it should be a fairly pass-through result.

So my initial impression is that perhaps a fix in the jsx loader plugin is needed. If you can pass the built output or a test I can try with the output, that would help to identify the source of the problem.

from almond.

rockymeza avatar rockymeza commented on May 27, 2024

I can't share the original, but I have created an example repo that has the same issue:

https://github.com/fusionbox/almond-jsx-bug

Here is the actual application code in the built file:

https://github.com/fusionbox/almond-jsx-bug/blob/master/main-built.js#L16086-L16107

When using loader plugins with almond, the loader plugin should generate a named define call in the built output because almond does not support dynamic loading, which is something where req.toUrl() can come into play, and if the loader plugin is implementing a loaderPlugin.normalize method, it should be a fairly pass-through result.

I'm a little confused, sorry. If I understood correctly, the modules do have names in L16086 and L16091.

But the dependency paths are not normalized, should the jsx-requirejs-plugin be normalizing those?

Thanks!

from almond.

mochja avatar mochja commented on May 27, 2024

This also happens with text plugin.

Plugin generates correctly

define('text!src/file', [], function() {
  return 'hello';
});

Problem is that definition which is using this module don't resolve the relative path.

require('text!./file', function(file) { // exception thrown "Dynamic load not allowed: text"
  console.log(file);
}

if you put absolute path to it, it works correctly

require('text!src/file', function(file) {
  console.log(file); // hello
}

If r.js could replace relative paths with absolute path, this would be resolved. Same thing happens with amdclean as well.

from almond.

jrburke avatar jrburke commented on May 27, 2024

For the require(['text!./file'], function(file) { is that done inside a module's define method? If so, does it use a local require dependency for it? If the answer is no to one of those, then I can see that the relative './file' part will be normalized incorrectly.

from almond.

pieceOpiland avatar pieceOpiland commented on May 27, 2024

I also seem to be running into this problem with the require-cs plugin.

I've thrown together a jsfiddle containing the built output at: https://jsfiddle.net/bbwvf785/1/

It is unable to resolve the module cs!./myModule. When I substitute absolute paths in for the relative paths, the module is properly resolved. I believe it's because the module it's relative to also contains the plugin prefix. As a result, almond searches for cs!cs!src/myModule similarly to how it looks for jsx!jsx!components/Bar in the original comment.

I tried adding

relName = splitPrefix(relName)[1];

after line 208 and it seems to have resolved the issue in my scenario.

If I can provide any more information, please let me know.

from almond.

jrburke avatar jrburke commented on May 27, 2024

Sorry it took so long to really address this: the normalization logic was not using the reference ID's resource name, but the full ID, including the plugin prefix part. This was incorrect, requirejs does not do this. I think I just goofed when I ported over some of the requirejs logic a while back.

Fixed in 0.3.3, tagged and published.

from almond.

rockymeza avatar rockymeza commented on May 27, 2024

Thanks James!

On Thu, Sep 1, 2016, 01:11 James Burke [email protected] wrote:

Sorry it took so long to really address this: the normalization logic was
not using the reference ID's resource name, but the full ID, including the
plugin prefix part. This was incorrect, requirejs does not do this. I think
I just goofed when I ported over some of the requirejs logic a while back.

Fixed in 0.3.3, tagged and published.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#101 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AABVGI-F04BL1fRrH8VkA1_cZt_LJ-H4ks5qll5mgaJpZM4DV3SC
.

-Rocky

from almond.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.