Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#18929 closed defect (fixed)

dojo/i18n: if preload api is disabled, module still attempts to load preload from cache in a build

Reported by: mssskhalsa Owned by: Dylan Schiemann <dylan@…>
Priority: high Milestone: 1.9.10
Component: Internationalization Version: 1.12.0-rc2
Keywords: Cc:
Blocked By: Blocking:

Description

If a build is done with a codebase that includes nls resources, then the build cache includes a preload of the form:

'*now':function(r){r(['dojo/i18n!*preload*dojo/nls/dojo*["ar","ca","cs","da","de","el","en-gb","en-us","es-es","fi-fi","fr-fr","he-il","hu","it-it","ja-jp","ko-kr","nl-nl","nb","pl","pt-br","pt-pt","ru","sk","sl","sv","th","tr","zh-tw","zh-cn","ROOT"]']);}

If a consumer of this build disables dojo-preload-i18n-Api in the Dojo config, then the dojo/i18n loader plugin disables preload logic, but still attempts to process the cached preload, which is not a valid module id, so it makes an invalid XHR.

dojo/i18n should probably have a guard against this scenario.

Change History (7)

comment:1 Changed 3 years ago by mssskhalsa

We are testing a patch for this that seems to work well and will submit a PR if we don't encounter issues.

  • i18n.js

    diff --git a/i18n.js b/i18n.js
    index 359d1ae..4e9f7ad 100644
    a b define(["./_base/kernel", "require", "./has", "./_base/array", "./_base/config", 
    255255                                        if(!--remaining){
    256256                                                load(lang.delegate(cache[loadTarget]));
    257257                                        }
    258                                 };
     258                                },
     259                                split = id.split("*"),
     260                                preloadDemand = split[1] == "preload";
    259261
    260262                        if(has("dojo-preload-i18n-Api")){
    261                                 var split = id.split("*"),
    262                                         preloadDemand = split[1] == "preload";
    263263                                if(preloadDemand){
    264264                                        if(!cache[id]){
    265265                                                // use cache[id] to prevent multiple preloads of the same preload; this shouldn't happen, but
    define(["./_base/kernel", "require", "./has", "./_base/array", "./_base/config", 
    274274                                        return;
    275275                                }
    276276                        }
     277                        else if(preloadDemand) {
     278                                // If a build is created with i18n resources and 'dojo-preload-i18n-Api' has not been set to false,
     279                                // the built file will include a preload in the cache (which looks about like so:)
     280                                // '*now':function(r){r(['dojo/i18n!*preload*dojo/nls/dojo*["ar","ca","cs","da","de","el","en-gb","en-us","es-es","fi-fi","fr-fr","he-il","hu","it-it","ja-jp","ko-kr","nl-nl","nb","pl","pt-br","pt-pt","ru","sk","sl","sv","th","tr","zh-tw","zh-cn","ROOT"]']);}
     281                                // If the consumer of the build sets 'dojo-preload-i18n-Api' to false in the Dojo config, the cached
     282                                // preload will not be parsed and will result in an attempt to call 'require' passing it the unparsed
     283                                // preload, which is not a valid module id.
     284                                // In this case we should skip this request.
     285                                load(1);
     286
     287                                return;
     288                        }
    277289
    278290                        array.forEach(loadList, function(locale){
    279291                                var target = bundlePathAndName + "/" + locale;

comment:3 Changed 3 years ago by Dylan Schiemann <dylan@…>

Owner: set to Dylan Schiemann <dylan@…>
Resolution: fixed
Status: newclosed

In 598c215/dojo:

Error: Processor CommitTicketReference failed
Unsupported version control system "git": Can't find an appropriate component, maybe the corresponding plugin was not enabled? 

comment:4 Changed 3 years ago by Dylan Schiemann <dylan@…>

In 36956c4/dojo:

Error: Processor CommitTicketReference failed
Unsupported version control system "git": Can't find an appropriate component, maybe the corresponding plugin was not enabled? 

comment:5 Changed 3 years ago by Dylan Schiemann <dylan@…>

In 00f5aea7/dojo:

Error: Processor CommitTicketReference failed
Unsupported version control system "git": Can't find an appropriate component, maybe the corresponding plugin was not enabled? 

comment:6 Changed 3 years ago by Dylan Schiemann <dylan@…>

In b073106/dojo:

Error: Processor CommitTicketReference failed
Unsupported version control system "git": Can't find an appropriate component, maybe the corresponding plugin was not enabled? 

comment:7 Changed 3 years ago by dylan

Milestone: tbd1.9.10
Priority: undecidedhigh
Note: See TracTickets for help on using tickets.