-
Notifications
You must be signed in to change notification settings - Fork 29.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Original commit message: [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} Refs: v8/v8@159c82c Refs: v8/v8@a0fd320 PR-URL: #50183 Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
- Loading branch information
Showing
29 changed files
with
698 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// Copyright 2021 the V8 project authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
// Flags: --harmony-import-attributes | ||
|
||
import { life } from 'modules-skip-1.mjs' with { }; | ||
|
||
assertEquals(42, life()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// Copyright 2021 the V8 project authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
// Flags: --harmony-import-attributes | ||
|
||
import json from 'modules-skip-1.json' with { type: 'json' }; | ||
|
||
assertEquals(42, json.life); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// Copyright 2021 the V8 project authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
// Flags: --harmony-import-attributes | ||
|
||
import {life} from 'modules-skip-imports-json-1.mjs'; | ||
|
||
assertEquals(42, life()); |
Oops, something went wrong.