question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SyntaxError: strict mode code may not contain 'with' statements

See original GitHub issue

This error comes to me via usage of Angular Universal. When attempting to serve my development server and accessing any of the pages, I am greeted to a blank screen and this error in the console:

SyntaxError: strict mode code may not contain 'with' statements

specifically pointing to this line as the issue: https://github.com/fgnass/domino/blob/master/lib/sloppy.js#L10

Honestly I’m not quite sure how to proceed, this is my first time using any of this stuff, but because this file’s been around since 2015 unchanged, I imagine the browsers have just recently started getting picky about it?

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:25
  • Comments:25

github_iconTop GitHub Comments

5reactions
cscottcommented, Dec 16, 2019

Well, you could start by opening a bug on the angular project, as I’ve recommended. It doesn’t seem you’ve done that yet.

5reactions
RedactedProfilecommented, Dec 16, 2019

What’s the bug # on the angularjs project? This is not a domino bug, so commenting here isn’t being seen by anyone who knows angular well enough to fix the underlying issue.

I think that’s the bigger issue here, is that while this may not be “strictly” an issue with Domino, and can be fixed by a higher package int he chain, but which one is it? Webpack? Angular CLI? Which dependency is it even that uses Domino? Is it a sub sub sub child of higher package? Because for 99.99999999% of everything else, those are fine.

But at the bottom of the chain here, is Domino’s usage of a practice that is not recommended: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/with

So while it sucks that webpack or whatever is accidentally carrying over a use strict into what is supposed to be a not-strict file (because there is no use sloppy), and I get it that that is clearly stated in the comments of the source file causing the issue, the other half here is that maybe this file should be updated to use a stricter standard anyways, or else packages relying on this dependency might want to look elsewhere and no one wants that.

The bigger problem is with packagers like webpack and gulp concatting 3rd party source code into a single source. Using sloppy mode is going to naturally cause problems when anything packaged as a higher priority above it slaps a use strict in there, which is going to be an overwhelming amount of the time (and there is no way to just “turn off” strict mode by stating a use sloppy somewhere)

I’m not trying to come off as harshly critical and I’m not even trying to tell you what to do or how to handle your project, I’m purely coming at this as a developer who installed a default version of a project that wouldn’t function because a single file way down the dependency chain wasn’t using strict mode and using non-strict compatible functionality and ends up bj0rking the whole thing because of it.

The question is for Webpack or Angular CLI, what CAN they do about it? Probably nothing. ngUniversal with Express however can probably figure out which dependency they need to update that doesn’t end up using Domino however, and just me personally I find that as well undesirable. Domino is clearly good at what it does. But this issue can be fixed at this level, whether it is or never does is entirely up to it’s collaborators, and that’s totally fair.

I just wanted to present my case and inform of why this is a problem now, will likely continue to be a problem going forward, and why you might want to look into making this file comply to stricter ECMA standards for maximum compatibility image

On the same token, I empathize with the idea of “it’s not really our problem either” and that’s definitely well within your stance to take.

I just hope that maybe it isn’t is all and maybe a greater good can come out of this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Uncaught SyntaxError: Strict mode code may not include a ...
Uncaught SyntaxError: Strict mode code may not include a with statement. This is occuring in the following file:.
Read more >
strict mode code may not contain 'with' statements after 8 -> 9 ...
If I scaffold a Hello World application using `dotnet new angular -o my-new-app`, then I upgrade to Angular 9, I get the above...
Read more >
'with' is not allowed in strict mode - JSLint Error Explanations
Strict mode code may not include a WithStatement. The occurrence of a WithStatement in such a context is treated as a SyntaxError. You...
Read more >
JavaScript Strict Mode Code may not Contain with Statements
Live Demo: JavaScript Strict Mode Code may not Contain with Statements. Note: Please check out the browser console by pressing the f12 key...
Read more >
"use strict" not allowed in function with non-simple parameters ...
SyntaxError : "use strict" not allowed in function with non-simple parameters ... The JavaScript exception " 'use strict' not allowed in function" occurs...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found