Opened 8 years ago

Closed 7 years ago

#14092 closed enhancement (fixed)

AMD loader support for Dojo 1.6 built layer files

Reported by: Chris Mitchell Owned by: Rawld Gill
Priority: blocker Milestone: 1.7.3
Component: Core Version: 1.6.1
Keywords: Cc: stephan.hesmer@…, cjolif
Blocked By: #14989 Blocking:

Description (last modified by Chris Mitchell)

The Dojo 1.7 AMD loader supports loading Dojo 1.6 formatted source modules, but does not support optimized/built layers for modules. We have received a number of requests from users that are doing early testing on 1.7beta6 for this support. Please consider for 1.7.1, since 1.7 is now feature frozen.

Change History (41)

comment:1 Changed 8 years ago by Chris Mitchell

Description: modified (diff)
Milestone: 1.71.7.1

comment:2 Changed 8 years ago by Chris Mitchell

Description: modified (diff)

comment:3 Changed 7 years ago by cjolif

Cc: cjolif added

comment:4 Changed 7 years ago by Rawld Gill

Milestone: 1.7.1future
Status: newassigned

comment:5 Changed 7 years ago by cjolif

This issue was partially fixed by #13845. However additional problems arise with for example resource bundles loading.

comment:6 Changed 7 years ago by Rawld Gill

In [27797]:

fixed i18n to properly load v1.6- layer files; refs #14092; !strict

comment:7 Changed 7 years ago by Rawld Gill

In [27799]:

adding a few lines missed in a merge that formed [27797]; refs #14092; !strict

comment:8 Changed 7 years ago by Rawld Gill

In [27800]:

backport [27797] [27799], refs #14092; !strict

comment:9 Changed 7 years ago by Rawld Gill

In [27801]:

fixed builder to build flattened layer i18n bundles as available in 1.6-; refs #14092; refs #14169; !strict

comment:10 Changed 7 years ago by cjolif

Milestone: future1.7.2

comment:11 Changed 7 years ago by Rawld Gill

In [27802]:

backport [27801]; refs #14169, refs #14092; !strict

comment:12 Changed 7 years ago by Rawld Gill

In [27806]:

fixed layers to write call to preloadLocalizations as per 1.6-; refs #14092, refs #14169; !strict

comment:13 Changed 7 years ago by Rawld Gill

Resolution: fixed
Status: assignedclosed

In [27807]:

fixed layers to write call to preloadLocalizations as per 1.6-; fixes #14092, fixes #14169; !strict

comment:14 Changed 7 years ago by Rawld Gill

preloadLocalizations works as per 1.6- by default. It is possible to force the builder to omit the preloadLocalization calls by

  • setting the build control flag preloadLocalizations to falsy
  • not setting preloadLocalizations and setting the build control property defaultConfig.async to truthy

If preloadLocalizations is truthy, then preloadLocalization calls will be inserted into layer modules unconditionally.

comment:15 Changed 7 years ago by Rawld Gill

Milestone: 1.7.2
Resolution: fixed
Status: closedreopened

v1.6 flattened NLS bundles often contain multiple dojo.provide's and never look like unbuilt v1.6- bundles. This causes the evalBundle in the "dojo-v1x-i18n-Api" has branch as given by the previous repairs to this ticket to fail because it must use checkForLegacyModules to find legacy-style global variables defined consequent to evaluating the bundle.

Also, v1.6 converted localized bundle module names to legal JavaScript? ids by replacing the locale dashes with underscores. This causes checkForLegacyModules in the previous repairs to this ticket to fail.

comment:16 Changed 7 years ago by Rawld Gill

[28049] should have ref'd this ticket

comment:17 Changed 7 years ago by Rawld Gill

Status: reopenedassigned

comment:18 Changed 7 years ago by Rawld Gill

In [28053]:

backport [28049]; refs #14092; !strict

comment:19 Changed 7 years ago by cjolif

Milestone: 1.7.3

comment:20 Changed 7 years ago by Colin Snover

Once built (using the standard build profile w/ noref), dojo/cldr/nls/en/* are getting defined as nonmodule. This is not so good! I’m still trying to trace out why this is happening but thought I’d put feedback here in case someone else might know more quickly.

Last edited 7 years ago by Colin Snover (previous) (diff)

comment:21 Changed 7 years ago by Colin Snover

I’m still not sure why or where this is happening, but the cache entry for the bundle is becoming closured by evalBundle which means that the wrong define is called (the one from inside evalBundle) and the module value is never defined. Replacing evalBundle with a no-op function “fixes” the problem.

Last edited 7 years ago by Colin Snover (previous) (diff)

comment:22 Changed 7 years ago by Colin Snover

This is happening because dijit/nls/dijit-all_en-us is treated as a legacy i18n bundle, so *that* module gets wrapped in the evalBundle closure, and then define is shadowed for *all* the functions. Since we aren’t looking for any deferred calls to define, patching evalBundle to look like this seems like it would work:

new Function("bundle", "__evalError", "__checkForLegacyModules", "__mid",
	"var __amdResult, define = function(x){__amdResult= x;}," +
	"ret = [(function(){" +
				"try{eval(arguments[0]);}catch(e){}" +
				"if(__amdResult)return 0;" +
				"if((__checkForLegacyModules = __checkForLegacyModules(__mid)))return __checkForLegacyModules;" +
				"try{return eval('('+arguments[0]+')');}" +
				"catch(e){__evalError.e = e; return __evalError;}" +
			"})(bundle),__amdResult]; define = this.define; return ret;"
)

The only change here is basically that after evaluating the return value, define is replaced with the global define again.

Rawld, thoughts please? (This same fix applies for both before and after [28053].)

Also, even with this change and a noref build, when loading cross-domain, extra requests are being triggered for the /en/ bundles.

Last edited 7 years ago by Colin Snover (previous) (diff)

comment:23 Changed 7 years ago by Colin Snover

Blocked By: 14989 added

comment:24 Changed 7 years ago by Rawld Gill

The problem is that the current design doesn't account for flattened (built) NLS resources which were added in 1.7.2. The evalBundle function must detect and properly process the following

  1. single NLS bundles expressed as AMD a single AMD module
  2. multiple NLS bundles expressed as an AMD a layer
  3. single legacy AMD bundles
  4. multiple NLS bundles expressed as a flattened NLS layer as built by the legacy builder

The current design fails to handle Case 2.

comment:25 Changed 7 years ago by Rawld Gill

In [28124]:

improved evalBundle to handle flattened, built, AMD NLS layers; refs #14092; !strict

comment:26 Changed 7 years ago by Rawld Gill

In [28125]:

improved evalBundle to handle flattened, built, AMD NLS layers; refs #14092; !strict

comment:27 Changed 7 years ago by Rawld Gill

In [28126]:

improved evalBundle to handle flattened, built, AMD NLS layers (note: [28124] checked in the wrong file and not sure where [28125] came from); refs #14092; !strict

comment:28 Changed 7 years ago by Rawld Gill

@csnover: I've tested both not xdomain and xdomain and it seems to work afer 28126; let me know what you find at your convenience.

Keeping ticket open until I get confirmation from others that this repair works universally.

comment:29 Changed 7 years ago by Colin Snover

To confirm, [28128] is a more appropriate patch for what was dropped in at comment #22?

comment:30 Changed 7 years ago by Colin Snover

Priority: highblocker

Rawld, could you please confirm my previous question? Also, these patches for correctly evaluating built NLS layers need to be backported to 1.7.3.

comment:31 in reply to:  29 Changed 7 years ago by Rawld Gill

Replying to csnover:

To confirm, [28128] is a more appropriate patch for what was dropped in at comment #22?

28128 seems to have nothing to do with this issue. I don't understand your question. Also, there was no commit at #22, so I don't understand that either.

comment:32 Changed 7 years ago by Colin Snover

[28124] through [28126] and comment:22.

comment:33 in reply to:  32 Changed 7 years ago by Rawld Gill

Replying to csnover:

[28124] through [28126] and comment:22.

my response to comment:22 is at comment:24. I confirm that [28126] is the best fix I know of at this time. afaik, this is working correctly in trunk. I've rx'd no additional reports/complaints since comment:28, now 6 weeks ago.

comment:34 Changed 7 years ago by Rawld Gill

In [28365]:

removed requirment for sync loader when including v1.x i18n backcompat; refs #14092; refs #15057; !strict

comment:35 Changed 7 years ago by Rawld Gill

In [28398]:

improved sniff for dojo xhr factory; fixes #14831; refs #14092; !strict

comment:36 Changed 7 years ago by Rawld Gill

In [28411]:

tuned i18n code; added exhaustive test for i18n; refs #14092; !strict

comment:37 Changed 7 years ago by Rawld Gill

In [28412]:

more of exhaustive test for i18n; refs #14092; !strict

comment:38 Changed 7 years ago by Rawld Gill

In [28438]:

fixed error in preloadLocalizations which caused waiting queue to stall; gave fast path for preloadLocalizations for known AMD bundles; fixes #14169; refs #14092; !strict

comment:39 Changed 7 years ago by Rawld Gill

If backport to 1.7, see also changes in #14069

comment:40 Changed 7 years ago by Rawld Gill

if backport to 1.7, see all changes in #15061

comment:41 Changed 7 years ago by Rawld Gill

Resolution: fixed
Status: assignedclosed

In [28785]:

backport i18n backcompat fixes; fixes #14092; !strict

Note: See TracTickets for help on using tickets.