"Strict mode code may not include a with statement" error with Client Dependency on
We have Newsletter Studio installed on an Umbraco 7.5.7 site however are getting errors when we switch debug to false and the Client Dependency kicks in.
The error is Strict mode code may not include a with statement and it seems to be related to newsletter studio, in particular this piece of code with(myiframedoc).
I believe the problem is because with statements are not allowed with use strict however newsletter studio doesn't set use strict, other packages do but not newsletter studio. Is the use strict on these other packages causing this error. Can anyone advise how to resolve this issue.
yes it's probibly another package setting 'use strict' ; at a global level and when the scripts are stuck together it's conflicting :(
I would search the App_Plugins folder for 'use strict' and then see if there is a script in there where it is set at the top of the script and not wrapped with a function.
if you see something like
'use strict';
function modulecodefunctions() {
}
...
this file is your problem.
ideally anyone useing strict should wrap their code
(function() {
'use strict';
// pluging code here
})();
so if you see it like that then it's not the file causing your problem.
to test you could either
a) remove use strict from the start of any plugin scripts that are declare it outside of a function.
or
b) wrap that file in the (function() { })() syntax.
remember to increment the version in config/clientdependency.config once you have made any changes.
I would also drop a post into the relevant forum if you happen to find out which plugin is causing the issue (crossing my fingers it's not one of mine)
It looks like it was the God Mode package that was causing the issue. It's not really needed on live where we'll be using client dependency so I've just uninstalled it for now.
Going to report the issue on the packages github. Thanks for pointing me in the right direction.
So, I've crawled out of my hole and (hopefully) fixed this by taking Kev's sterling advise. Apologies for any inconvenience! (I forget that Angular and Client Dependency munge everything into one big blob of monolithic mutated JavaScript that sits like an angry spider in a web looking for innocent victims such as myself who don't quite get "namespacing" in JS :) )
"Strict mode code may not include a with statement" error with Client Dependency on
We have Newsletter Studio installed on an Umbraco 7.5.7 site however are getting errors when we switch debug to false and the Client Dependency kicks in.
The error is
Strict mode code may not include a with statement
and it seems to be related to newsletter studio, in particular this piece of codewith(myiframedoc)
.I believe the problem is because with statements are not allowed with
use strict
however newsletter studio doesn't set use strict, other packages do but not newsletter studio. Is the use strict on these other packages causing this error. Can anyone advise how to resolve this issue.Hi
yes it's probibly another package setting 'use strict' ; at a global level and when the scripts are stuck together it's conflicting :(
I would search the App_Plugins folder for 'use strict' and then see if there is a script in there where it is set at the top of the script and not wrapped with a function.
if you see something like
this file is your problem.
ideally anyone useing strict should wrap their code
so if you see it like that then it's not the file causing your problem.
to test you could either
a) remove use strict from the start of any plugin scripts that are declare it outside of a function.
or b) wrap that file in the
(function() { })()
syntax.remember to increment the version in config/clientdependency.config once you have made any changes.
I would also drop a post into the relevant forum if you happen to find out which plugin is causing the issue (crossing my fingers it's not one of mine)
It looks like it was the God Mode package that was causing the issue. It's not really needed on live where we'll be using client dependency so I've just uninstalled it for now.
Going to report the issue on the packages github. Thanks for pointing me in the right direction.
Hi!
Nice to see that you found a solution for this and thanks Kevin Jump for providing a great fix!
Cheers guys!
So, I've crawled out of my hole and (hopefully) fixed this by taking Kev's sterling advise. Apologies for any inconvenience! (I forget that Angular and Client Dependency munge everything into one big blob of monolithic mutated JavaScript that sits like an angry spider in a web looking for innocent victims such as myself who don't quite get "namespacing" in JS :) )
The new version of God Mode should address this:
https://www.nuget.org/packages/Diplo.GodMode/
https://our.umbraco.org/projects/developer-tools/diplo-god-mode/
If you have any more issues let me know.
is working on a reply...