Skip to content

Commit

Permalink
Add <script type="module"> and module resolution/fetching/evaluation
Browse files Browse the repository at this point in the history
This adds support for <script type="module"> for loading JavaScript modules, as well as all the infrastructure necessary for resolving, fetching, parsing, and evaluating module graphs rooted at such <script type="module">s.

Policy decisions encoded here:

- Always use the UTF-8 decoder, ignoring the charset="" attribute or the Content-Type header.
- Always use "cors" fetch mode and "omit" credentials mode, ignoring the crossorigin="" attribute. (I am not so sure on the credentials mode and crossorigin attribute parts of this.)
- Use <script defer>-like semantics: do not execute until parsing is finished, and execute in order. Ignore the async="" attribute (for now?).
- In HostResolveImportedModule:
  - Allow absolute URLs and anything starting with "./" or "../", with the latter being then interpreted as relative URLs. Everything else (e.g. bare specifiers like "jquery") fails for now, and no automatic ".js" is appended.
  - We do a URL parse instead of a basic URL parse, i.e., we allow blob URLs theoretically. (I am not sure about this and happy to change it.)
  - We throw a TypeError as the resolution error. (Honestly I could see arguments for any of EvalError, ReferenceError, SyntaxError, or URIError. Maybe we should repurpose EvalError.)
  • Loading branch information
domenic committed Dec 22, 2015
1 parent 12db63c commit 03bb9c3
Showing 1 changed file with 514 additions and 145 deletions.
Loading

0 comments on commit 03bb9c3

Please sign in to comment.