Skip to content

System.register module name update #6359

Closed
@guybedford

Description

@guybedford

Since posting #6097, we've decided to alter the format of System.register (while we still can!), to rather use a module context object as the second argument:

So that:

export let name = __moduleName;

Becomes:

System.register([], function($export, $moduleContext) {
  return {
    setters: [],
    execute: function() {
      $export('name', $moduleContext.id);
    }
  };
});

instead of:

System.register([], function($export, __moduleName) {
  return {
    setters: [],
    execute: function() {
      $export('name', __moduleName);
    }
  };
});

This is so that this context argument can potentially be amended in future with additional metadata if and when this is specified at any point in future in the language.

My knowledge of TypeScript internals is quite limited, so I wasn't able to quickly get together a transformer to replace __moduleName with $moduleContext.id, but this should be relatively straightforward to do.

In the mean time, it may be worth reverting #6097 to avoid unnecessary breaking changes here.

This corresponds to Traceur PR google/traceur-compiler#2051 and Babel PR babel/babel#3166.

Apologies for any confusion here!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Breaking ChangeWould introduce errors in existing codeFixedA PR has been merged for this issueHelp WantedYou can do thisSuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions