Opened 10 years ago
Closed 10 years ago
#14970 closed defect (wontfix)
loader fails to load modules that map to the same URL correctly
Reported by: | Rawld Gill | Owned by: | Rawld Gill |
---|---|---|---|
Priority: | low | Milestone: | 1.8 |
Component: | Loader | Version: | 1.7.2 |
Keywords: | Cc: | ||
Blocked By: | Blocking: |
Description
(reported by neonstalwart)
script tag in page
require({ baseUrl: './', paths: { multiple: 'multiple', duplicate: 'multiple' } }, ['multiple', 'duplicate'], function (multiple, duplicate) { multiple.multi = true; console.log('multiple', multiple.multi); console.log('duplicate', duplicate.multi); });
multiple.js
console.log('loaded'); define(function (require, exports, module) { console.log('defined', module.id); return {}; });
i'd expect to see the following in the console:
loaded defined multiple defined duplicate multiple true duplicate undefined
the loader appears to not do this
see also: http://groups.google.com/group/amd-implement/browse_thread/thread/138b9ef50f458a67
Attachments (2)
Change History (5)
comment:1 Changed 10 years ago by
Milestone: | tbd → 1.8 |
---|---|
Priority: | undecided → low |
Status: | new → assigned |
Changed 10 years ago by
Attachment: | multiple.html added |
---|
comment:2 Changed 10 years ago by
@neonstalwart: Why wouldn't you expect multiple.js to be evaluated twice, thereby causing two console.log("loaded') calls?
comment:3 Changed 10 years ago by
Resolution: | → wontfix |
---|---|
Status: | assigned → closed |
Looking into this a bit further, it seems like the precise behavior is undefined according to the AMD spec. Further, the loader is behaving consistent with https://github.com/jrburke/requirejs/blob/master/tests/urlfetch/urlfetch.html.
For my taste, I don't like this behavior. If two different modules are mapped to the same resource, then the best practice is for that resource should have a single anon define. But what if it doesn't as per the test above?
fwiw, here is how to rewrite the test to get the "correct" effect:
<html> <head> <script type="text/javascript" src="../../../dojo.js" data-dojo-config="async:1"></script> <script type="text/javascript"> require({ baseUrl: './', paths: { multiple: 'multiple', duplicate: 'multiple' }, packages: [{ name:"p1", location:".", },{ name:"p2", location:".", paths:{"p2/duplicate":"multiple"} }] }, ['p1/multiple', 'p2/duplicate'], function (multiple, duplicate) { multiple.multi = true; console.log('multiple', multiple.multi); console.log('duplicate', duplicate.multi); }); </script> </head> </html>
Owing to the lack of a standard for this dusty corner, I'm not going to address this in 1.x.
test page