Reputation: 1541
I am developing an application using lots of js libs and mainly using Express JS. The all code is working fine with Firefox and Chrome. but I am getting below errors in IE8 and IE9.
SCRIPT5022: fromText eval for hbs!notification/templates/dropDown failed: SyntaxError: Syntax error in regular expression
http://requirejs.org/docs/errors.html#fromtexteval
require.js, line 138 character 9
SCRIPT5022: fromText eval for hbs!notification/templates/dropDownItem failed: SyntaxError: Syntax error in regular expression
http://requirejs.org/docs/errors.html#fromtexteval
require.js, line 138 character 9
SCRIPT5022: fromText eval for hbs!layouts/admin/templates/teamManagement failed: SyntaxError: Syntax error in regular expression
http://requirejs.org/docs/errors.html#fromtexteval
require.js, line 138 character 9
SCRIPT5022: fromText eval for hbs!layouts/admin/alarms/templates/projectAlarms failed: SyntaxError: Syntax error in regular expression
http://requirejs.org/docs/errors.html#fromtexteval
require.js, line 138 character 9
SCRIPT5022: fromText eval for hbs!admin/templates/navigation failed: SyntaxError: Syntax error in regular expression
http://requirejs.org/docs/errors.html#fromtexteval
require.js, line 138 character 9
SCRIPT5022: fromText eval for hbs!layouts/admin/templates/base failed: SyntaxError: Syntax error in regular expression
http://requirejs.org/docs/errors.html#fromtexteval
require.js, line 138 character 9
These errors are only showing up in IE8 and IE9.
Here is my config.js
require.config({
paths: {
// Require plugins
'text': 'vendor/requirejs-text/text',
'css': 'vendor/css/css',
'hbs': 'vendor/require-handlebars-plugin/hbs',
'Handlebars': 'vendor/require-handlebars-plugin/Handlebars',
'i18nprecompile': 'vendor/require-handlebars-plugin/i18nprecompile',
'json2': 'vendor/require-handlebars-plugin/json2',
// Libraries
'es5shim': 'vendor/es5-shim/es5-shim',
'underscore': 'vendor/underscore/underscore',
'jquery': 'vendor/jquery/jquery',
'jquery.DatePicker': 'vendor/datepicker/datepicker',
'jquery.mousewheel': 'vendor/jquery-mousewheel/jquery.mousewheel',
'backbone': 'vendor/backbone/backbone',
'backbone.virtualCollection': 'vendor/backbone-virtual-collection/backbone.virtual-collection',
'backbone.marionette': 'vendor/backbone.marionette/backbone.marionette',
'backbone.marionette.handlebars': 'vendor/backbone.marionette.handlebars/backbone.marionette.handlebars',
'leaflet': 'vendor/leaflet/leaflet-src',
'highcharts': 'vendor/highcharts/highcharts.src',
'paper': 'vendor/paper/paper',
'handsontable': 'vendor/handsontable/jquery.handsontable',
'walltime': 'vendor/walltime-js/walltime',
'walltime-data': 'vendor/walltime-js/walltime-data'
},
shim: {
'underscore': {
exports: '_'
},
'jquery.DatePicker': {
deps: ['jquery']
},
'backbone': {
deps: ['underscore', 'jquery'],
exports: 'Backbone'
},
'backbone.marionette': {
deps: ['backbone'],
exports: 'Marionette'
},
'backbone.virtualCollection': {
deps: ['backbone', 'underscore']
},
'leaflet': {
exports: 'L'
},
'highcharts': {
deps: ['jquery'],
exports: 'Highcharts'
},
'walltime': {
deps: ['walltime-data']
}
},
hbs: {
i18nDirectory: 'i18n/',
disableI18n: false, // This disables the i18n helper and
// doesn't require the json i18n files (e.g. en_us.json)
// (false by default)
disableHelpers: true, // When true, won't look for and try to automatically load
// helpers (false by default)
helperPathCallback: // Callback to determine the path to look for helpers
function (name) { // ('/template/helpers/'+name by default)
return 'cs!' + name;
},
compileOptions: {} // options object which is passed to Handlebars compiler
}
});
Please help me guys!
----- Update -----
I posted this as issue on Github for requirejs repo.
You can find it here
According to comment it seems like problem is with eval in IE9.
I also tried to put eval("("+text+")")
as mentioned here but still not worked.
Can anyone please tell how I get this eval thing to work in IE9.
Thanks
Upvotes: 0
Views: 2090
Reputation: 49
The answer of @jsfellow was really helpfull! The shown snippet is found in hbs.js of require-handlebars-plugin. According to the sourcemap proposal,
//# sourceURL=
is preferred over
//@ sourceURL=
After I changed the corresponding line in hbs.js, everything worked as expected in all tested browsers (google chrome 35, firefox 30, IE 8-10). I filed a pull request at the require-handlebars-plugin github repo, which is currently merged and evaluated.
I hope this helps anyone who might run into the same problems.
Upvotes: 1
Reputation: 91
This is was my problem and likely yours:
//IE with conditional comments on cannot handle the
//sourceURL trick, so skip it if enabled.
/*@if (@_jscript) @else @*/
if (!config.isBuild) {
text += "\r\n//@ sourceURL=" + path;
}
/*@end@*/
IE will blow up with a syntax error if the source url is on the end of the text that is being passed to eval.
Upvotes: 3
Reputation: 20014
This seems to be associated with a similar issue that happened in JQuery
This is all about the DOM not being ready and since the DOM is NOT fully loaded this error occurs.
If you have not done it yet try adding your scripts at the end page or some sort of lazy loading:
http://www.joezimjs.com/javascript/lazy-loading-javascript-with-requirejs/ How to achieve lazy loading with RequireJS? By the way only post on this regard seems Microsoft rejected it did not consider it a bug:
https://connect.microsoft.com/IE/feedback/details/792880/document-readystat
Upvotes: 0