Opened 13 years ago
Last modified 13 years ago
#6885 closed defect
ShrinkSafe fail when "dojo.requireLocalization" arguments aren't a string constant because ShrinkSafe execute eval instruction to get string value — at Initial Version
Reported by: | harobed | Owned by: | alex |
---|---|---|---|
Priority: | high | Milestone: | |
Component: | BuildSystem | Version: | 1.1.0 |
Keywords: | Cc: | ||
Blocked By: | Blocking: |
Description
I've this code :
try { Node.innerHTML = code.replace(reg,function(o,a,b) { if (!window[a]) { //unknown localization module? dojo.requireLocalization("i18n",a.substring(2,64).toLowerCase()); window[a] = dojo.i18n.getLocalization("i18n", a.substring(2,64).toLowerCase()); } var sRes = (window[a])[b] || ""; return sRes.replace(/\\n/g,"<br>");*/ }); } catch(e) { console.error("Error in translateApp:",e.message); }
ShrinkSafe? raise this error :
release: Interning strings for file: ../../release/dojo/dojo/dojo.js release: Optimizing (shrinksafe) file: ../../release/dojo/dojo/dojo.js js: "jslib/i18nUtil.js#64(eval)", line 1: uncaught JavaScript runtime exception: ReferenceError: "a" is not defined.
I've look in dojo/util/buildscripts/jslib/i18nUtil.js
62 var requireStatements = fileContents.match(/dojo\.requireLocalization\(.*\)\;/g); 63 if(requireStatements){ 64 eval(requireStatements.join(";")); 65 66 //print("loaded bundles: "+djLoadedBundles.length); 67 68 var djBundlesByLocale = {}; 69 var jsLocale, entry, bundle; 70 71 ...
ShrinkSafe? extract and eval all "requireLocalization" to get the ressource file name. In my instance, requireLocalization bundleName parameter isn't a constant but one variable then the string extracted can't be process by "eval" instruction.
I've write a patch to fix issue.
Note: See
TracTickets for help on using
tickets.
i18nUtil.js patch