Comments (7)
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.
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.
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.
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.
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.
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.
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)
- Return almond.js as string when required from node.js HOT 2
- How to handle anonymous modules HOT 2
- unsafe String split HOT 3
- can't get requirejs, angularjs and almond to work together HOT 2
- Uncaught Error: No fs HOT 2
- Build problem HOT 2
- AlmondJS + CDN module with UMD HOT 4
- Any way to listen the DOMContentLoaded event HOT 1
- Your js script is crashing Firefox HOT 3
- Issue with relative path when they match such path: "../../vendor/some-lib/./some-file" HOT 1
- Issue with relative path when they match such path: "../../vendor/some-lib/./some-file" HOT 1
- Creating reusable libraries with RequireJS & AlmondJS HOT 1
- Almond + Electron HOT 5
- Loading CSS files HOT 3
- Can almond be forced to require synchronously?
- require.config(...) is being executed too late
- Calander Start With Monday rather than Sunday HOT 1
- Location of almond.js is critical to the build process?
- TypeError: Cannot read property 'splice' of undefined HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from almond.