From 6cc21d36506057bfa8f7c424278072c879e7c946 Mon Sep 17 00:00:00 2001 From: Domenic Denicola Date: Thu, 21 May 2020 13:14:25 -0400 Subject: [PATCH] Add import.meta.resolve() Closes #3871. --- source | 49 +++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 43 insertions(+), 6 deletions(-) diff --git a/source b/source index 5fa9b11f48a..8aecc619931 100644 --- a/source +++ b/source @@ -2799,6 +2799,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
  • The CleanupFinalizationRegistry abstract operation
  • The Construct abstract operation
  • The CopyDataBlockBytes abstract operation
  • +
  • The CreateBuiltinFunction abstract operation
  • The CreateByteDataBlock abstract operation
  • The CreateDataProperty abstract operation
  • The DetachArrayBuffer abstract operation
  • @@ -93995,7 +93996,7 @@ dictionary PromiseRejectionEventInit : EventInit -
    url = import.meta .url
    +
    url = import.meta.url

    Returns the active module script's PromiseRejectionEventInit : EventInitThis syntax can only be used inside module scripts.

    + +
    url = import.meta.resolve(specifier)
    + +
    +

    Returns specifier, resolved + relative to the active script's base + URL. That is, this returns the URL that would be imported by using import(specifier).

    + +

    Throws a TypeError exception if an invalid specifier is given.

    + +

    This syntax can only be used inside module scripts.

    +

    A module map is a map keyed by User agents must use the following implementation:

      -
    1. Let module script be moduleRecord.[[HostDefined]].

    2. +
    3. Let moduleScript be moduleRecord.[[HostDefined]].

    4. -
    5. Assert: module script's base - URL is not null, as module script is a JavaScript module +

    6. Assert: moduleScript's base + URL is not null, as moduleScript is a JavaScript module script.

    7. -
    8. Let urlString be module script's

      Let urlString be moduleScript's base URL, serialized.

    9. -
    10. Return « Record { [[Key]]: "url", [[Value]]: urlString } ».

    11. +
    12. +

      Let steps be the following steps, given the argument specifier:

      + +
        +
      1. Set specifier to ? ToString(specifier).

      2. + +
      3. Let url be the result of resolving + a module specifier given moduleScript's base URL and specifier.

      4. + +
      5. If url is failure, then throw a TypeError exception.

      6. + +
      7. Return the serialization of + url.

      8. +
      +
    13. + +
    14. Let resolveFunction be ! CreateBuiltinFunction(steps, 1, + "resolve", « »).

    15. + +
    16. Return « Record { [[Key]]: "url", + [[Value]]: urlString }, Record { [[Key]]: "resolve", [[Value]]: resolveFunction } + ».

    HostImportModuleDynamically(referencingScriptOrModule,