Skip to content

System module format updates: dynamic import, import meta, top-level await #26606

Description

Search Terms

System modules, dynamic import, import meta, top-level await

Suggestion

I wanted to just create an issue to track updates to the System module format, which are all supported in the current stable release.

I've been meaning to get to this for a while, but haven't had time to dive into the code. So instead, here are the full transforms to track here for now.

Babel supports all of these except for top-level await support.

Use Cases

System module format output support for dynamic import(), import.meta.x, import.meta.url and top-level await.

Examples

The transformations that are supported are the following:

Dynamic Import

import('./x').then(x => ...);

->

System.register([], function (exports, context) {
  return {
    setters: [],
    execute: function () {
      context.import('./x').then(x => ...);
    }
  };
});

import.meta and import.meta.url

console.log(import.meta);
console.log(import.meta.url);

->

System.register([], function (exports, context) {
  return {
    setters: [],
    execute: function () {
      console.log(context.meta);
      console.log(context.meta.url);
    }
  };
});

Top-level await

console.log('sync');
await new Promise(resolve => setTimeout(resolve));
console.log('async');

->

System.register([], function (exports, context) {
  return {
    setters: [],
    execute: async function () {
      console.log('sync');
      await new Promise(resolve => setTimeout(resolve));
      console.log('async');
    }
  };
});

Where in dependency graphs, SystemJS supports variant B of the top-level await proposal.

Checklist

My suggestion meets these guidelines:

  • This wouldn't be a breaking change in existing TypeScript / JavaScript code
  • This wouldn't change the runtime behavior of existing JavaScript code
  • This could be implemented without emitting different JS based on the types of the expressions
  • This isn't a runtime feature (e.g. new expression-level syntax)

Activity

  1. rbuckton commented on Aug 9, 2019

    @rbuckton
    Contributor

    A few updates:

    • Dynamic import() is already supported in System.
    • import.meta seems relatively safe and stable. I will break this out into its own issue to track this specific feature.
    • Top-level await is a more complicated ask. I will also break it out into its own specific issue for tracking purposes.
  2. rbuckton commented on Aug 9, 2019

    @rbuckton
    Contributor

    Closing in favor of the more focused issues.

  3. guybedford commented on Aug 10, 2019

    @guybedford
    ContributorAuthor

    Thanks Ron Buckton (@rbuckton), great to see progress here.

  4. locked as resolved and limited conversation to collaborators on Oct 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

BugA bug in TypeScriptHelp WantedYou can do this

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions