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

[v18.x backport] esm: use import attributes instead of import assertions #51136

Commits on Dec 12, 2023

  1. deps: V8: cherry-pick a0fd3209dda8

    Original commit message:
        Reland "[import-attributes] Implement import attributes, with `assert` fallback"
    
        This is a reland of commit 159c82c5e6392e78b9bba7161b1bed6e23758984, to set the correct author.
    
        Original change's description:
        > [import-attributes] Implement import attributes, with `assert` fallback
        >
        > In the past six months, the old import assertions proposal has been
        > renamed to "import attributes" with the follwing major changes:
        > 1. the keyword is now `with` instead of `assert`
        > 2. unknown assertions cause an error rather than being ignored
        >
        > To preserve backward compatibility with existing applications that use
        > `assert`, implementations _can_ keep it around as a fallback for both
        > the static and dynamic forms.
        >
        > Additionally, the proposal has some minor changes that came up during
        > the stage 3 reviews:
        > 3. dynamic import first reads all the attributes, and then verifies
        >    that they are all strings
        > 4. there is no need for a `[no LineTerminator here]` restriction before
        >    the `with` keyword
        > 5. static import syntax allows any `LiteralPropertyName` as attribute
        >    keys, to align with every other syntax using key-value pairs
        >
        > The new syntax is enabled by a new `--harmony-import-attributes` flag,
        > disabled by default. However, the new behavioral changes also apply to
        > the old syntax that is under the `--harmony-import-assertions` flag.
        >
        > This patch does implements (1), (3), (4) and (5). Handling of unknown
        > import assertions was not implemented directly in V8, but delegated
        > to embedders. As such, it will be implemented separately in d8 and
        > Chromium.
        >
        > To simplify the review, this patch doesn't migrate usage of the term
        > "assertions" to "attributes". There are many variables and internal
        > functions that could be easily renamed as soon as this patch landes.
        > There is one usage in the public API
        > (`ModuleRequest::GetImportAssertions`) that will probably need to be
        > aliased and then removed following the same process as for other API
        > breaking changes.
        >
        > Bug: v8:13856
        > Change-Id: I78b167348d898887332c5ca7468bc5d58cd9b1ca
        > Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4632799
        > Commit-Queue: Shu-yu Guo <syg@chromium.org>
        > Reviewed-by: Adam Klein <adamk@chromium.org>
        > Cr-Commit-Position: refs/heads/main@{#89110}
    
        Bug: v8:13856
        Change-Id: Ic59aa3bd9101618e47ddf6cf6d6416a3a438ebec
        Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4705558
        Commit-Queue: Shu-yu Guo <syg@chromium.org>
        Reviewed-by: Shu-yu Guo <syg@chromium.org>
        Reviewed-by: Adam Klein <adamk@chromium.org>
        Cr-Commit-Position: refs/heads/main@{#89115}
    
    Refs: v8/v8@a0fd320
    nicolo-ribaudo committed Dec 12, 2023
    Configuration menu
    Copy the full SHA
    909963e View commit details
    Browse the repository at this point in the history
  2. deps: V8: cherry-pick ea996ad04a68

    Original commit message:
        [import-attributes] Remove support for numeric keys
    
        During the 2023-09 TC39 meeting the proposal has been updated to remove support
        for bigint and float literals as import attribute keys, due to implementation
        difficulties in other engines and minimal added value for JS developers.
    
        GH issue: tc39/proposal-import-attributes#145
    
        Bug: v8:13856
        Change-Id: I0ede2bb10d6ca338a4b0870a1261ccbcd088c16f
        Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4899760
        Reviewed-by: Shu-yu Guo <syg@chromium.org>
        Commit-Queue: Joyee Cheung <joyee@igalia.com>
        Cr-Commit-Position: refs/heads/main@{#90318}
    
    Refs: v8/v8@ea996ad
    nicolo-ribaudo committed Dec 12, 2023
    Configuration menu
    Copy the full SHA
    5389c3a View commit details
    Browse the repository at this point in the history
  3. esm: use import attributes instead of import assertions

    The old import assertions proposal has been
    renamed to "import attributes" with the follwing major changes:
    
    1. The keyword is now `with` instead of `assert`.
    2. Unknown assertions cause an error rather than being ignored,
    
    This commit updates the documentation to encourage folks to use the new
    syntax, and add aliases for module customization hooks.
    
    PR-URL: nodejs#50140
    Fixes: nodejs#50134
    Refs: v8/v8@159c82c
    Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
    Reviewed-By: Jacob Smith <jacob@frende.me>
    Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
    aduh95 authored and nicolo-ribaudo committed Dec 12, 2023
    Configuration menu
    Copy the full SHA
    b9d4d7c View commit details
    Browse the repository at this point in the history
  4. vm: use import attributes instead of import assertions

    The old import assertions proposal has been
    renamed to "import attributes" with the following major changes:
    
    1. The keyword is now `with` instead of `assert`.
    2. Unknown assertions cause an error rather than being ignored.
    
    This PR updates the documentation to encourage folks to use the new
    syntax, and add aliases to preserve backward compatibility.
    
    PR-URL: nodejs#50141
    Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
    Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br>
    aduh95 authored and nicolo-ribaudo committed Dec 12, 2023
    Configuration menu
    Copy the full SHA
    9cb5138 View commit details
    Browse the repository at this point in the history

Commits on Dec 13, 2023

  1. src: iterate on import attributes array correctly

    The array's length is supposed to be a multiple of two for dynamic
    import callbacks.
    
    Fixes: nodejs#50700
    PR-URL: nodejs#50703
    Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
    Reviewed-By: Shelley Vohr <shelley.vohr@gmail.com>
    Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
    Reviewed-By: James M Snell <jasnell@gmail.com>
    targos authored and nicolo-ribaudo committed Dec 13, 2023
    Configuration menu
    Copy the full SHA
    cc239fe View commit details
    Browse the repository at this point in the history