Opened 8 years ago

Closed 8 years ago

#13220 closed enhancement (fixed)

AMD: assumptions about "require"

Reported by: ben hockey Owned by: Rawld Gill
Priority: high Milestone: 1.7
Component: Loader Version: 1.7.0b1
Keywords: Cc:
Blocked By: Blocking:

Description

dojo's loader adds some custom properties to require which are assumed to be available in circumstances when they are sometimes not available. this makes dojo's code dependent on a specific loader which goes against the goal of AMD.

this ticket is to highlight a couple of the cases when custom properties have been assumed and dojo's code is failing.

http://bugs.dojotoolkit.org/browser/tags/release-1.7.0b1/dojo/text.js#L76 assumes a require.cache object which may not exist if the dojo/text plugin is used with an alternative loader.

http://bugs.dojotoolkit.org/browser/tags/release-1.7.0b1/dojo/i18n.js#L150 assumes a require.toAbsMid function which may not exist if the dojo/i18n plugin is used with an alternative loader. it might be possible that this could be replaced with require.toUrl

Change History (6)

comment:1 Changed 8 years ago by ben hockey

for the i18n case maybe the following is enough:

if (require.toAbsMid) {
        syncRequire.toAbsMid= function(mid){
                return require.toAbsMid(mid);
        };
}

comment:2 Changed 8 years ago by ben hockey

comment:3 Changed 8 years ago by Rawld Gill

Status: newassigned

comment:4 Changed 8 years ago by Rawld Gill

Milestone: tbd1.7
Type: defectenhancement

We need to be careful about chasing other loaders. There is no authority here. That said, we'll try to document/fix RequireJS incompatibilities.

comment:5 Changed 8 years ago by ben hockey

+1 i've come to believe that to improve the status quo of AMD we will need to deviate from our compatibility with other loaders at times. in the long term we may be able to see convergence but in the short term i think the only way to advance AMD in general is to demonstrate the best API we are capable of producing and by doing so influence the "standard".

comment:6 Changed 8 years ago by Rawld Gill

Resolution: fixed
Status: assignedclosed

With #13968, toAbsMid has been removed. Dojo should be compat with RequireJS.

Note, as of today:

  1. RequireJS does not support legacy sync modules.
  2. A built, async-only dojo loader is considerably smaller than a built RequireJS.
Note: See TracTickets for help on using tickets.