#17475 closed defect (fixed)
Star mapping giving incorrect results with layers
Reported by: | Bryan Forbes | Owned by: | Rawld Gill |
---|---|---|---|
Priority: | blocker | Milestone: | 1.8.6 |
Component: | Loader | Version: | 1.9.1 |
Keywords: | Cc: | ||
Blocked By: | Blocking: |
Description
When modules go from the pending cache of a built layer to the cache of the loader, if they have been mapped using "*" they are incorrectly placed. I will attach a test case, but the gist of it is that I'm using the following map configuration:
map: { 'my/router': { 'dojo/router': 'dojo/router' }, 'my/request': { 'dojo/request/xhr': 'dojo/request/xhr' }, '*': { 'dojo/router': 'my/router', 'dojo/request/xhr': 'my/request' } }
When the layers of my application are built, 'dojo/router' comes after 'my/router' in the pending cache object. When it is iterated through and modules go from the pending cache to the loader cache, 'my/router' gets placed on the correct property ('my/router'), but then 'dojo/router' gets placed on that same property ('my/router') and overwrites the correct module. This doesn't happen when using an unbuilt version and only happens in a build.
This also seems to affect lookups of relative modules that are star mapped. In this same tarball, I have 'my/request' which gets overwritten with 'dojo/request/xhr' and the relative modules which are needed for 'dojo/request/xhr' are looked up relative to 'my'.
I believe what needs to happen is that the star configuration needs to be ignored when going from the pending cache to the loader cache. I'm unsure how best to do that, so I'll leave that to Rawld.
To build the tarball, untar it as a sibling to 'dojo' and run the following command:
node dojo/dojo.js load=build --dojoConfig ./my/dojoConfig.js -p ./my/profile.js
To test unbuilt vs. built, open my-test.html
and
my-built-test.html
.
Attachments (2)
Change History (14)
Changed 9 years ago by
comment:1 Changed 9 years ago by
Owner: | set to rawld |
---|---|
Status: | new → assigned |
comment:2 Changed 9 years ago by
Owner: | changed from rawld to Rawld Gill |
---|
comment:3 Changed 9 years ago by
Changed 9 years ago by
Attachment: | my2.tar.gz added |
---|
comment:4 Changed 9 years ago by
i've got another similar problem... the key to this problem showing up is that there is a layer that contains the module being replaced by the map. if the replaced module is not included in the layer or if the module is in the initial layer (dojo/dojo) then it works as expected (try uncommenting either of the 2 lines in the profile with the mid 'my/thing'
to see how it will work in those cases).
the archive is similar to bryan's - extract it and add dojo as a sibling to the "my" package. there is my-test.html and myRelease/my-built-test.html for testing.
comment:5 Changed 9 years ago by
I haven't tried with the reduced test case but in the application where I found this, I saw the same problem using aliases. I wonder if a similar one line fix is needed in another location
comment:6 Changed 9 years ago by
I and a coworker tested this fix pretty thoroughly and Rawld's changes are what need to happen. I have submitted a pull request (https://github.com/dojo/dojo/pull/39) with some small changes. I also took the time to think about paths and aliases and came to the conclusion that they should be ignored when modules are being inserted into the cache from the pending cache as those configuration options could also cause relative URL lookups to fail. Because of the extra changes, I added a parameter to getModuleInfo
and made the change you suggested in the body of that function. Please review the changes and let me know what you think.
comment:8 Changed 9 years ago by
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
comment:9 Changed 9 years ago by
Resolution: | fixed |
---|---|
Status: | closed → reopened |
Please, backport fixes.
comment:10 Changed 9 years ago by
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
comment:12 Changed 9 years ago by
Milestone: | tbd → 1.8.6 |
---|---|
Priority: | undecided → blocker |
Excellent reduced case (as usual).
Try changing https://github.com/dojo/dojo/blob/master/dojo.js#L462
in consumePendingCacheInsert()
to...
This seems to fix the problem illustrated in the reduced case. I need to consider whether or not pathsMapProg and aliases should also be empty arrays before committing a fix.
Let me know what you see.