script type=module processed before html import
Reported by
chief...@gmail.com,
Sep 22 2017
|
|||||||||||
Issue descriptionUserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.91 Safari/537.36 Steps to reproduce the problem: 1. Open zip of files 2. polymer serve or http serve files 3. Load index2.html page in browser 4. Check console output What is the expected behavior? I'm expecting the Polymer library to load in the html import before the script file gets processed. Thus console.log(window.Polymer); console.log(window.Polymer.GestureEventListeners); Should be defined in the module as polymer import occurs before the script is processed. What went wrong? scripts with type="module" are being processed before the html import files. Did this work before? N/A Chrome version: 61.0.3163.91 Channel: n/a OS Version: OS X 10.11.6 Flash Version: Shockwave Flash 27.0 r0 If you remove the type="module" then Polymer will be defined. Additionally, if you add a space in the script tag before the script module everything works as expected.
,
Sep 25 2017
,
Sep 25 2017
You should be accessing the site via: http://localhost:8000/index2.html - not from the filesystem. Your screenshot shows you loading the index file from the filesystem.
,
Sep 25 2017
Thank you for providing more feedback. Adding requester "sc00335628@techmahindra.com" to the cc list and removing "Needs-Feedback" label. For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
,
Sep 27 2017
Tested the issue on 61.0.3163.91 and on latest canary 63.0.3225.0 using Mac 10.12.6 and is not reproducible with steps mentioned in comment#0 and comment#3. i.e; No console output is seen. Attaching screecast for reference. @Reporter: Could you please find the attached screenshot and also please attach a expected screenshot from your end. That would help us in further triaging of the issue. Thanks in advance!!
,
Sep 27 2017
Hi - You're screencast shows the issues. The console shows an undefined and an Uncaught error - that shouldn't happen if things were working correctly. Polymer should be defined and printed out on the console. The dependencies are not loading before the console.log statements are being executed.
,
Sep 27 2017
Thank you for providing more feedback. Adding requester "sc00335628@techmahindra.com" to the cc list and removing "Needs-Feedback" label. For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
,
Oct 4 2017
,
Oct 6 2017
,
Oct 6 2017
,
Dec 20 2017
Hello Here's a plunker about the problem. http://plnkr.co/edit/Uz2yenOxF3CcGqUatKQG?p=preview There are 4 files: - dependency.html : set window.dependency = true. - index.html : imports (using HTML-imports) module1.html and module2.html. - module1.html : imports (using HTML-imports) dependency.html, and says if it has been imported in an inline module. - module2.html : idem and adds an empty inline script. You will be able to see that inline script module are runned after the HTML-imports only if we add an empty inline script tag, with at least one character inside, in the html file.
,
Dec 20 2017
,
Dec 21 2017
Thanks for the report. As you may know, <script type="module"> runs in "defer" manner, which means the execution starts after all loading is done, while HTML Imports (+ classic scripts) have stricter ordering of execution/import. As of now we don't have any formal definition of how module scripts interacts with the HTML Imports dependency resolution / script execution order, so a module script within an import may execute before all the HTML Imports are processed. Maybe we may defer modules scripts' execution after all HTML imports are processed, but I'm wondering how important is it because if you have a module script inside an import, the dependent imports cannot use the side effect of the module script execution as it runs in "defer" manner.
,
Dec 21 2017
Wouldn't it be nicer if module scripts, rather than being defered untill all loading are done, would defered untill all *needed loading are done. In our case, where index imports 2 modules, which import their dependencies, it would mean that the 1st module script runs after all its html-imports from its own file, but before the 2nd script module's imports.
,
Dec 22 2017
I see your point, and it sounds nice if module scripts run the way you explained. But as HTML Imports are not under active development, and is unlikely going to be supported by other browsers, implementation for the semantics is quite low from our perspective.
,
Dec 22 2017
So, because HTML imports are going to disapear (they aren't and won't be part of the standards), then the way they run with ES6 modules is definitly not going to change. Then, the only way to make an imported module (via HTML import) wait for its own needed imports, is to use an hack solution by adding an empty inline script next to it (as shown in the sample). This will force the HTML imports to start to execute before the the execution of the empty inline script.
,
May 14 2018
Polymer is transitioning away from HTML imports and onto ES modules, and we just ran into this timing issue. It would be quite helpful to be able to rely on type=module scripts always executing after HTML imports are loaded, because it makes it possible to reliably mix the two systems, which is important for incremental migration. For example, you might have a document that bridges the two by importing one dependency via an HTML import, and another via an ES module import. However, as it stands today, as soon as you switch your script type to "module" in order to perform the ES module import, any existing code that depended on the HTML import being loaded will likely break. The no-op script hack does seem to work, but I imagine most users are not going to discover it, so I worry that this will add friction for users trying to migrate away from HTML imports.
,
May 15 2018
@aomarks thanks for providing good rationale for having this fixed, as
an answer to my question in comment #14. Let me clarify my understanding.
Imagine this document structure (<script> is classic, <script type=module> is ES module):
Document
+- <script> A
+- <script type=module> A'
+- Import1
+- Import2
| +- <script> C
| +- <script type=module> C'
+- <script> B (Note: belongs to Import1)
+- <script type=module> B' (Note: belongs to Import1)
+- Import3
+- <script> D
+- <script type=module> D'
+- <script> E
+- <script type=module> E'
The classic scripts' order should be deterministically A-C-B-D-E.
Maybe your case doesn't care for A',B',C', and D' but only cares about E'
is executed after all A-C-B-D, without needing "no-op" script E?
Or as the comment 16, you also expect strict determinism like
A-(A'?)-C-C'-B-B'-D-D'-E-E'?
(or A' still can be deferred between E and E')?
,
May 17 2018
Ah, the example in the above comment #20 was not to the point, the repro case in #12 is more precise. So within an import file, a module script can be executed before its dependency loading is complete.
,
Aug 16
|
|||||||||||
►
Sign in to add a comment |
|||||||||||
Comment 1 by vamshi.k...@techmahindra.com
, Sep 25 2017135 KB
135 KB View Download