Skip to content
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

Add <script type="module"> and module resolution/fetching/evaluation #443

Merged
merged 1 commit into from
Jan 20, 2016

Commits on Jan 20, 2016

  1. Add <script type="module"> and module resolution/fetching/evaluation

    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.
    
    Some decisions encoded here include:
    
    - Always use the UTF-8 decoder, ignoring the charset="" attribute or the Content-Type header parameter.
    - Always use the "cors" fetch mode, and use the crossorigin="" attribute to decide between "omit"/"same-origin"/"include" for the credentials mode.
    - Require that the response be served with a JavaScript MIME type for its Content-Type header.
    - Use <script defer>-like semantics by default: do not execute until parsing is finished, and execute in order. The async="" attribute can be used to opt in to an "execute as soon as possible, in any order" semantic. Unlike for classic scripts, in no cases do we block further parsing or script execution until the module tree is finished loading. This applies to both inline and external scripts.
    - For module resolution, allow absolute URLs and anything that starts with "./", "../", or "/", with this latter set being interpreted as relative URLs. Everything else (e.g. bare specifiers like "jquery") fails for now. No automatic ".js" is appended.
    - Modules are memoized based on their request URL, whereas import specifiers inside the module are resolved based on the module's response URL.
    
    In the course of adding this functionality, large parts of script execution, fetching, and creation were refactored, including moving around some sections and reorganizing others. Conceptually, scripts are now either "classic scripts", "module scripts", or "data blocks". The result should generally be clearer and easier to follow.
    domenic committed Jan 20, 2016
    Configuration menu
    Copy the full SHA
    cd1a9fb View commit details
    Browse the repository at this point in the history