-
Notifications
You must be signed in to change notification settings - Fork 766
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
System.js build: Fix leaking variables, improve resource resolution logic #1788
Conversation
@@ -67,5 +71,6 @@ if (win.__stencil_cssshim) { | |||
} else { | |||
start(); | |||
} | |||
}).call(window); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need call() here?
can't it be })()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's what I've tried initially, but it turned out that the function scope was not bound to window
when using })()
. This did break the embedded ES6Promise polyfill unfortunately. Using .call(window)
therefore explicitly sets the function scope to the window
object, making the ES6Promise polyfill work again.
I've updated the script resolution logic to first look for a script with the |
@mofux I think it's called Btw, would you mind adding the explanation of call(window) as comment? Awesome job figuring all this out! |
@manucorporat Sure, I'll split out the defer fix to a different PR. The |
Making two PRs out of this at the same time seems... complicated 🤔 The changes of one PR would conflict with the other. I could make one PR (defer) based on the other (var leak), but then the second PR would be identical to this one 😅 I guess it's best to remove the var leak stuff from this PR, then get this one merged, and then add another PR for the var leak based on the updated master branch? I'd like this PR to become the one that fixes the defer stuff, because the comments and referenced issues mostly talk about that topic. |
So far, I can't merge the current PR since it would break existing applications. Also what's the point of adding defer? just curious |
…rces-url if data-stencil-namespace is not specified
The changes should be fully backwards-compatible now. There is no need to specify the
You can use the |
Well, we had to opt out of the type="module" script because of two reasons:
IMO it is a wrong assumption to assume that the |
@manucorporat I just noticed commit 3a44def. Will this solve the leaking variables problems, or is this addressing a different problem? |
Is there a way to check to see if the namespace is a part of the script URL? I'm seeing an issue where this code is intermittently changing the URL of a third-party script that exists on the page outside of the Stencil Web Component and changing the filename to For example, it's changing I've opened issue #1827 with more details. |
data-stencil-namespace
ordata-resources-url
to resolve the resources url, instead of always using the last script in the DOM. Fixes System.js build can resolve wrong resources url when included with defer attribute #1787, fixes Component lazy loader detects wrong base URL #1456