script-loader icon indicating copy to clipboard operation
script-loader copied to clipboard

What does global context mean?

Open ghuser opened this issue 7 years ago • 3 comments

I would expect that this loader executes script myScript.js as if it was included with <script src="myScript.js">. This is not the case.

The following statement var myVar = {} will not add myVar as global (in contrast to how <script src="myScript.js"> behaves) . So in the html page: console.log(myVar) will print undefined.

ghuser avatar Jan 23 '18 18:01 ghuser

@ghuser var foo = "bar"; function () { console.log(var); } inside myScript.js

alexander-akait avatar Jan 23 '18 18:01 alexander-akait

@ghuser Is your script in strict mode? I was having the same issue, give #51 a try.

enriquez avatar Feb 14 '18 17:02 enriquez

If it is due to "use strict", the version that's currently on master should work. However, there's no release yet.

FilippoPolo avatar Aug 27 '19 13:08 FilippoPolo